rejetto forum

Software => HFS ~ HTTP File Server => Beta => Topic started by: rejetto on May 11, 2009, 02:21:42 PM

Title: a script to easily get the IP of a friend
Post by: rejetto 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. :)
Title: Re: a script to easily get the IP of a friend
Post by: Mars 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
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 20, 2009, 08:51:40 PM
tu es terrible
Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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.

(http://techneurosa.com:84/hfs%20other%20options.jpg)
edit: This image is hosted by me.
Title: Re: a script to easily get the IP of a friend
Post by: rejetto 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.
Title: Re: a script to easily get the IP of a friend
Post by: r][m 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?  :-\
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 21, 2009, 02:25:50 PM
it's expected to run the editor on file HFS.EVENTS
Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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 (http://www.techneurosa.com:82/get-ip)
Go ahead, somebody else try it...
Title: Re: a script to easily get the IP of a friend
Post by: rejetto 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.
Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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/ (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.
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 22, 2009, 12:03:59 AM
not working here.
what does your "self test" say?

gotta run to bed now
see you
Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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.
Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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.
Title: Re: a script to easily get the IP of a friend
Post by: bacter 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 (http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros)


Title: Re: a script to easily get the IP of a friend
Post by: 80063r 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.
Title: Re: a script to easily get the IP of a friend
Post by: 80063r on May 22, 2009, 07:50:30 AM
Ok, now I have an on-topic question.  Wil the dialog being displayed prevent HFS from serving the get-ip template to someone else before I click OK on the dialog?  Or will it open another dialog on top or close the previous dialog?
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 22, 2009, 07:55:40 AM
yes, the "other server" is rejetto.com
it must see you ALL if you want to pass the self-test. it's the big uncle.

{.dialog.} is blocking.
an easy non-blocking alternative is {.add to log.}
or if you need something different you may use {.exec.} to pass the message to anything you like.
you may save the message to a temp file, with date-time as name, and run notepad on it.
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 22, 2009, 08:02:29 AM
if you refuse the {.add to log.} solution because it will be lost in the mess, ok.
but consider you can use custom colors, and you have a quite usable "search".
Title: Re: a script to easily get the IP of a friend
Post by: 80063r on May 22, 2009, 02:56:52 PM
I think I got the hang of it now.

I added:
Code: [Select]
{.append|get-ip.txt|%ip%.}
I'm having fun with this stuff.
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 22, 2009, 03:16:32 PM
{.append|get-ip.txt|%ip%
.}

to get a new line after the ip
Title: Re: a script to easily get the IP of a friend
Post by: 80063r on May 22, 2009, 03:19:53 PM
I need a carriage return in the above code.

Also, I can't figure out the color codes for .add to log.  I searched the forum and the wiki page is blank.  I tried many different types of color codes in upper and lower case and single digit and RGB html.

Oh, thanx.  You posted while I was typing.
Title: Re: a script to easily get the IP of a friend
Post by: rejetto on May 23, 2009, 01:37:47 AM
next version will support classic color formats, like blue and #RGB and #RRGGBB
in the while you should use this syntax instead
$BBGGRR

where "$" is exactly the dollar sign, and other 6 characters are similar to the html, but reversed.
Title: Re: a script to easily get the IP of a friend
Post by: 80063r on May 23, 2009, 06:09:43 AM
$BBGGRR

Thanks, I wouldn't have guessed that $.