rejetto forum

Event scripts!

rejetto · 38 · 31155

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
.
.
This feature will be available in version 2.3

Hi guys.
It's a long time i want to introduce a feature like this.
You know you can use template macros for much more than just painting web pages: you can load and save files, run programs, etc.
Why limit this potential to the template? So, don't!
From next 2.3 beta build you will be able to use your editor to make a file named "hfs.events" (next to "hfs.exe").
Using the same syntax as the templates one, you'll be able to DO things when some events occur.

Example
Code: [Select]
[connected]
{.disconnect.}

This will prevent any access to your HFS, because any connection will just be disconnected. Quite useless, i know, but it's to keep the example easy. ;) You can be selective over disconnections by using other macros.

Another example, this will limit to 10KB/s every file with "hey" in the name
Code: [Select]
[download]
{.if|{.is substring|%item-name%|hey.}| {:
  {.set speed limit for connection| 10 .}
:}.}

Currently supported events are: connected, disconnected, request, download, download completed, upload completed.
As you can see from the examples, new useful macros are coming, designed with events in mind.
Stay tuned for the next beta in the "beta" forum.


Suggestions?
« Last Edit: September 09, 2008, 04:54:45 PM by rejetto »


ebola

  • Guest
Hi

Sounds great.
First thing I thought reading while "Events" was zFTPServer Suite.
This freeware FTP-Server has Events allready included. Maybee you (we) find there some things and hints for v2.3?

Thx for developing HFS in this great way,
ebola


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Just a little post to say to you that for some time I had the same idea on this principle, but I above all have to look at sources to understand  the new functioning, and push more forward my investigations.
[on_connect]
[on_disconnect]
[on_loggedin]
[on_upload-failed]
[on_ban]
[on_deny]
[on_unauthorized]

some other suggestions

[on_start]  //every time server start

[on_stop]  //every time server stop

[on_run]   //every time hfs is running

[on_close]   //every time hfs is quitting

[on_upload_success]  // every time an upload is finished
{.if|{.exec|scanvirus.exe|%upload-filename%.}
     |{:{.delete|%upload-filename%.}:}
     |{:{.exec|md5 calculate.exe or update mp3 info.exe or ... .}:}
.}
[on_low-disk-space]

.... à suivre


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i added: start, quit, upload failed.
loggedin doesn't really exist until we use http authentication.
other events will be added as we see they are useful, no need to overdo.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
MAIN.PAS

updateEventScripts() into the procedure everyTenth()

As hfs.tpl , hfs.events is relaoded every time his date change.

Can you add a fast shortcut to edit  the hfs.events as follows

Quote
procedure TmainFrm.EditHFSEvents1Click(Sender: TObject);
const default='[start]' + CRLF +CRLF +
              '[quit]' + CRLF +CRLF +
              '[connected]'+ CRLF +CRLF +
              '[disconnected]' + CRLF +CRLF +
              '[download]' + CRLF +CRLF +
              '[download completed]' + CRLF +CRLF +
              '[upload failed]' + CRLF +CRLF +
              '[request]' + CRLF +CRLF
              ;
begin
if not fileExists(EVENTSCRIPTS_FILE) then
  begin
    saveFile(EVENTSCRIPTS_FILE,default);
  end;
exec(or_([
  nonEmptyConcat('"', tplEditor, '"'),
  loadregistry('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe', '', HKEY_LOCAL_MACHINE),
  'notepad.exe'
]), '"'+EVENTSCRIPTS_FILE+'"');
end;


I was again going to forget a thing as usual: thanks.

If those this sometimes miss in my demands, they are always in my thoughts, face to face of you it goes without saying ;)

« Last Edit: September 16, 2008, 08:43:57 AM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Following stage and not the slightest:

To differentiate the events according to the used folders, mainly there upload, it would indeed be necessary to be able to use in a real folder the usage of a hfs.diff.events.

Quote
DIFF_EVENTSCRIPTS_FILE = 'hfs.diff.events';

It is easier to manage certain events individually and with many differences according to the used real folder

Only some events will can be defined in these diff events (upload, download,.....), but not those who are bound to the functioning of the server (start, stop, connected, disconnected,...) because here they would have no action valid and could interfere with the main hfs.events

I hope that these some explanations will be enough. (Rejetto, I had no time(weather) to tilt me on the programming, because I preferred to put the idea on the paper before forgetting it, and I already have my small idea on the question). Good courage  ;)


Offline Fysack

  • Tireless poster
  • ****
    • Posts: 598
  • present picture
    • View Profile
    • Admin
You know you can use template macros for much more than just painting web pages:
So macros are here to stay... Fu*k, imgetting to old for this shit. And i only in my best 30`s. That IS crazy.maybenot
Ive said it before, the sky is the limit.
quote
"life is what`s happening while you are planning tomorrow"
I have a suggestion:  :-* Can you make a event like: [on_filesize_increase] or [on_write_to_file] or [on_incremental_overdrive]
Scenario:
If i attach a photosensor to a camera. Then the camera start write to a file. That file is hosted by hfs, and hfs will trigger the event. My phone is pip-pip-ing. I`ll go online. And watch the latest release.
An other ting that would be really cool, is to make any of those events play a sound, or even send a mail.
Rock`n`roll rejetto, im going to a Paul Van Dyk "concert" Saturday
GOD CAN READ YOUR MIND


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile

Quote
An other ting that would be really cool, is to make any of those events play a sound,
Working since build 176

{.play system event|sound_system_event_name.}

( example {.play system event|systemstart.} )

or

{.play system event|c:\........\your file.wav}


Offline Fysack

  • Tireless poster
  • ****
    • Posts: 598
  • present picture
    • View Profile
    • Admin

Quote
An other ting that would be really cool, is to make any of those events play a sound,
Working since build 176

I was afraid so ::) ;) thx mars
..we should have a lexipedia or somethig.

 :o :o :o What!! 1 7 6 ? ..that is a long time ago.  ok..

GOD CAN READ YOUR MIND


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
To differentiate the events according to the used folders, mainly there upload, it would indeed be necessary to be able to use in a real folder the usage of a hfs.diff.events.

now, this works on my personnal version



Offline Fysack

  • Tireless poster
  • ****
    • Posts: 598
  • present picture
    • View Profile
    • Admin
lol so that is macros. Just like logic gates. No wonder why people fear them  :D
Its a great wiki rejetto, it pull`d me true many times. When i say lexipedia, i meant something more like a alphabetical list of all the things you can do with HFS. FAQ style maybe. Tutorialic. My point is: how can you search for something if you dont know it exsist.
Ok, maybe not a lexica, but a collection of tips & tricks. Cool things to do with your HFS
This would be a great topic:
Tips,Tricks & Cool things to do with your HFS.
If the reason was not that im extremly tired right now, i would make it myself. So if anyone wake up before me, feel free  ;)
Peace
GOD CAN READ YOUR MIND


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Fysack

That the WIKI Bible  can throw you the light ;)

http://www.rejetto.com/forum/index.php?topic=5542.0

It is the grateful passage of the book that is my preferred :D ;D


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
finding something in a big pool is hard most of the times, a serious problem.