Author Topic: a script to easily get the IP of a friend  (Read 8097 times)

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
a script to easily get the IP of a friend
« on: May 11, 2009, 02:21:42 PM »
by installing this text in your event scripts file (ALT+F6)
Code: [Select]
[+request]
{.if|{.%url% = /get-ip.}|{:
{.clipboard|%ip%.}
{.dialog|%ip%
GO!.}
:}.}

you must only tell your friend to click on http://youraddress/get-ip
and his IP address will be automatically copied in your clipboard.

this stuff requires HFS 2.3 build 238 or higher

someone asked for this feature years ago. :)

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1880
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #1 on: May 20, 2009, 08:20:01 PM »
I have just tested the link which you put, but it returns ' not found page '. A solution can be to propose us?   ???

on verra combien se feront prendre au pi├Ęge de ce post ;) :D
« Last Edit: May 20, 2009, 08:22:04 PM by mars »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #2 on: May 20, 2009, 08:51:40 PM »
tu es terrible

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #3 on: May 21, 2009, 07:33:55 AM »
by installing this text in your event scripts file (ALT+F6)

That's so cool, if I could get to the "event scripts file."

Tonight I thought, I'll look on google for a free http file server.  I ended up here.  I like trying beta versions and learning new things.
I'm using HFS 2.3 build 238 and the latest stable version simultaneously on different ports.

2.3 build 238 gives an error dialog on every startup "This file contains no valid data."  Maybe the virtual file system file?

Anyway, pressing alt+F6 gives the vista style hourglass icon for 1 second and does nothing else and it does the same thing by clicking it in the menu.  No event scripts file ever shows.  Does it need to be created first?  What filename?

I haven't read much of the forum yet as I'm going to bed now.
I'm using Vista Ultimate x64.


edit: This image is hosted by me.
« Last Edit: May 21, 2009, 07:38:37 AM by 80063r »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #4 on: May 21, 2009, 08:41:37 AM »
welcome!

the startup error, i guess, is the same that i fixed in #239.
sadly #239 was "returned to factory" because of an heavy bug. but yes, it's about a VFS file it tries to load on startup, so you can clear it, or load/save to workaround it.

the ALT+F6 not working:
1. please, check if beside HFS.EXE you can see a file named HFS.EVENTS, and report here
2. it may be a bug, or you may have defined a bad template editor. Menu > html template > change editor
if you never used this menu, HFS should just call NOTEPAD.
If, instead, this is the problem, you can find it by using Menu > debug > show customized options


anyway, what ALT+F6 does is just to call a text editor (like notepad) on the file HFS.EVENTS
not very much, you can even do it yourself. but i would be very interested in knowing what's wrong with your HFS.
every time you save, HFS will reload the file.

Offline r][m

  • Tireless poster
  • ****
  • Posts: 347
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #5 on: May 21, 2009, 01:42:17 PM »
Here, alt + F6 or both at once, opens menu, nothing more.
F6 down first + alt opens editor.
Expected?  :-\

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #6 on: May 21, 2009, 02:25:50 PM »
it's expected to run the editor on file HFS.EVENTS

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #7 on: May 21, 2009, 06:49:25 PM »
2. it may be a bug, or you may have defined a bad template editor. Menu > html template > change editor
if you never used this menu, HFS should just call NOTEPAD.

I had previously defined coffee cup html editor as the editor.  Coffee.exe isn't a good editor anyway because it cant show the html template preview anyway.  There is a problem with showing the preview.

I switched it back to notepad.exe and now it works.  PS Pad editor also works.

Also, looking back, I see that the HSF.EVENTS file was already there.

Thank you

edit: looking back again, coffee cup html editor was opening the HFS.EVENTS file, but it was not focusing it so I didn't know.  I didn't realize that the html template editor would be the same editor for the HSF.EVENTS file.
Posted on: May 21, 2009, 01:42:57 PM
Also, is there a way to add a script to show the IP to the client instead of a "page not found" type message?

edit: for my end, it picked up my LAN IP.
http://www.techneurosa.com/get-ip
Go ahead, somebody else try it...
« Last Edit: May 21, 2009, 07:17:36 PM by 80063r »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #8 on: May 21, 2009, 10:03:41 PM »
i just tried but your server was not online.

well, i now think i chose not the best solution.
a better solution would be to create a virtual folder, named "get-ip" or whatever you like,
and then put this diff template on it

Code: [Select]
{.clipboard|%ip%.}
{.dialog|%ip% GO!.}
I got your IP address, thank you.

anyway, an error will be displayed, because of {.clipboard.}
it will be fixed in next release.
if you want to use it with a version lower than #240, use this workarounding version ;)

Code: [Select]
{.comment|{.clipboard|%ip%.}.}
{.dialog|%ip%
GO!.}
I got your IP address, thank you.
« Last Edit: May 21, 2009, 10:05:17 PM by rejetto »

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #9 on: May 21, 2009, 11:56:08 PM »
Ok, just figured some of it out myself.  Here's my hfs.diff.tpl in a real folder "get-ip"

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<!--{.comment|--><h1 style='margin-bottom:100em'>WARNING: this template is only to be used with HFS 2.3 (and macros enabled)</h1> <!--.} -->
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="/~style.css" type="text/css">
  <link rel="stylesheet" href="/~style.menu.css" type="text/css">
  <title>HFS %folder%</title>
  <link rel="shortcut icon" href="/favicon.ico">

<!--[if lte IE 5.5]>
<style type="text/css">
.menu ul li a, .menu ul li a:visited { width:151px; w\idth:139px; }
</style>
<![endif]-->
<style type="text/css">{.$style.user.}</style>
<script>
function _(id) { return typeof id == 'string' ? document.getElementById(id) : id; }
</script>

</head>
<body>
<div id='folder'>%ip%</div>
</body>
</html>
<!-- Build-time: %build-time% -->

[style.css|no log]
body, th { font-family:tahoma, verdana, arial, helvetica, sans; font-weight:normal; font-size:9pt; }
body { background-color:#DDF; padding:10px; }
body, p, form { margin:0 }
#folder, .big { font-size:14pt; font-weight:bold;  }

#body {
  border-bottom: 4px solid #BBF;
     border-top: 4px solid #BBF;
    border-left: 1px dotted #BBF;
   border-right: 1px dotted #BBF;
  background:#F3F3FF;
  padding:15px;
  margin:15px;
}
.comment { font-size:7pt; color:#888; background:#EEE; padding:3px; border:1px solid #DDD; margin-top:2px; }
.button { height:24px; padding:4px 10px; margin:5px; border:2px solid black; background:white; font-size:8pt; font-weight:bold; }
a.button { padding:8px 10px; }
a.button img { vertical-align:text-bottom; }
.flag { font-weight:bold; font-size:8pt; background:white; color:red; text-align:center; border:1px solid red; }
.item-folder { font-size:smaller; margin-top:4px; }


[file=folder=link]
  <tr><td>
  {.if|{.get|can delete.}{.and|{.get|can access.}|{.get|can archive item.}.}| <input type='checkbox' name='selection' value="%item-url%"> .}
  {.if|{.get|is new.}|<span class='flag'>&nbsp;NEW&nbsp;</span>.}
  {.if not|{.get|can access.}|<img src='/~img_lock'>.}
  <a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
  {.if| {.?search.} |{:<div class='item-folder'>{.!item folder.} {.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}:} .}
  {.if| %item-comment% | <div class='comment'>%item-comment%</div> .}

[+folder]
<td align='center'><i>folder</i><td align='right'>%item-modified%<td align='right'>%item-dl-count%

I haven't yet refined it, I'm just playing around to learn what's going on.  This language is new to me.  Are these {.if|... and etc. similar to the delphi language?  I've never worked with delphi so sorry if that's a dumb question.

Oh, by the way, it's actually showing my router ip, not my pc's lan IP.

Try this link again. It should be online, though I've been messing with it a lot.  Sorry.
http://www.techneurosa.com:82/get-ip/

And that's port 82 if the :82 isn't showing in the url above.

edit:  One more thing:  the dialog window doesn't show if HFS is minimized to the system tray.
« Last Edit: May 21, 2009, 11:59:52 PM by 80063r »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #10 on: May 22, 2009, 12:03:59 AM »
not working here.
what does your "self test" say?

gotta run to bed now
see you

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #11 on: May 22, 2009, 12:33:22 AM »
I just now changed a bunch of settings in my firewall.  It should work now.

My self test says "Your internet connection does not work."  The message could be a little more specific.  What does the self test actually do?  Is it WAN access?

My firewall was blocking port 82 as protection from "Net-Sky" or whatever.

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #12 on: May 22, 2009, 01:19:34 AM »
Now with the .clipboard and .dialog in the template, HFS restores and shows the dialog even if minimized to the system tray.

Offline bacter

  • Operator
  • Tireless poster
  • *****
  • Posts: 682
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #13 on: May 22, 2009, 01:20:32 AM »
The self test checks your WAN connection: if ok, then your server can be reached from wan.

I think you did the selftest before the changes in firewall: You are now online!  :)

Answer to your question about {.if...

This is the sintax of 'macro', the server-side scripting language (used in templates and events) of HFS, opposed to javascript (the client-side scripting language). The HFS program itself is written in delphi and has nothing to do with 'macro'. The unique sintax of macro with a lot of {. |  | .} was choosed to avoid confusion with javascript and wide known serverside-scripting languages like php, which is not supported by hfs.

Here you can learn someting about macro: http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros


your computer has no brain - use your own !

Offline 80063r

  • Occasional poster
  • *
  • Posts: 40
    • View Profile
Re: a script to easily get the IP of a friend
« Reply #14 on: May 22, 2009, 01:33:14 AM »
... server-side scripting language of HFS ...

Thank you, I understand what server-side scripting is and why it would need to be different than PHP and others.  That makes sense now.

And yes, I retested the self-test at different points of making changes an now it confirms that it works.  Does the self-test invoke another server to test the connection?  Just curious.