rejetto forum

Macro: set ini (+plus method to schedule commands)

Kremlin · 10 · 3938

0 Members and 1 Guest are viewing this topic.

Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
[you will find a better solution some posts below]

Well i've added this code to my server since the new macro came out, it will set the speed (total & ip), max simultaneous ips downloading and downloads/ip via the HFS page, use it if you like  :)

Add the two codes in the template file.

Buttons will appear when you login into an account (you may want to change it depending on your situation)
Code: [Select]
[special begin]
{.if|{.and| %user% | {.urlvar|speedtotalB.} .}|{:
{.set ini|speed-limit={.urlvar|speedtotal.}.}
:}/if.}
{.if|{.and| %user% | {.urlvar|speedipB.} .}|{:
{.set ini|speed-limit-ip={.urlvar|speedip.}.}
:}/if.}
{.if|{.and| %user% | {.urlvar|downloadsipB.} .}|{:
{.set ini|max-contemporary-dls-ip={.urlvar|downloadsip.}.}
:}/if.}
{.if|{.and| %user% | {.urlvar|ipsdownloadingB.} .}|{:
{.set ini|max-ips-downloading={.urlvar|ipsdownloading.}.}
:}/if.}

These are the buttons which i personally added in the [files] section, but again it's up to you where you find it more suitable to place
Code: [Select]
[files]
{.if not|%user%||
<input type='text'   name='speedtotal' maxlength="6" size="5"  value="-1" onclick="if(this.value=='-1')this.value=''">
<input type='submit' name='speedtotalB' value='Speed Limit'>
<input type='text'   name='speedip' maxlength="6" size="5"  value="-1" onclick="if(this.value=='-1')this.value=''">
<input type='submit' name='speedipB' value='IP Speed Limit'>
<input type='text'   name='downloadsip' maxlength="6" size="5"  value="0" onclick="if(this.value=='0')this.value=''">
<input type='submit' name='downloadsipB' value='Downloads / IP'>
<input type='text'   name='ipsdownloading' maxlength="6" size="5"  value="0" onclick="if(this.value=='0')this.value=''">
<input type='submit' name='ipsdownloadingB' value='Max IPs Downloading'>
.}

This is part of my admin panel with "style settings" filtered out, and the values that appear in the text boxes are the default values for HFS.

PS. Hope people add more functions using this new macro in this topic  ;)
« Last Edit: April 12, 2009, 09:44:17 PM by rejetto »


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
More code to add from another topic (UNTESTED):

This will make the 'Speed Limit' cap to the value 100 KBps from 18h to 00h
Code: [Select]
[download]
{.if|{.{.time|h.} = 18.} | {:{.set ini|speed-limit=100.}:}.}
{.if|{.{.time|h.} = 0.} | {:{.set ini|speed-limit=-1.}:}.}

Macro {.time.} syntax: http://www.rejetto.com/wiki/index.php/HFS:_Time_format

Edit:

I've now thought of using the same code but with the application of switching on and off the server automatically with a schedule

Simply set the speed-limit to 0 (which in essence is the 'Pause Streaming' option). Server will be turned off between 18h and 00h
Code: [Select]
[download]
{.if|{.{.time|h.} = 18.} | {:{.set ini|speed-limit=0.}:}.}
{.if|{.{.time|h.} = 0.} | {:{.set ini|speed-limit=-1.}:}.}

(Code corrected by rejetto, was missing the ":")

Forget what's above, read my other post below about hfs.events, that's the proper way for it to work.
« Last Edit: April 12, 2009, 09:05:57 PM by Kremlin »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13517
    • View Profile
after midnight the speed will stay 100, if the user doesn't change it manually.
that's what you want?


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2060
    • View Profile
Quote
after midnight the speed will stay 100, if the user doesn't change it manually.
that's what you want?
It is very there that is the problem, as long as you will not integrate(join) a time event in hfs, as I proposed it two or three times, only an action of distant connection will allow to make changes of parameters

[every hour]
{.if|{.{.time|h.} = 18.} | {.set ini|speed-limit=100.}.}
{.if|{.{.time|h.} = 0.} | {.set ini|speed-limit=-1.}.}

[every minute]
{.if|{.current downloads.}>10|| {.set ini|speed-limit-ip50.}| {.set ini|speed-limit-ip=-1.}.}

The use of speed-limit here is only an example, for a normal functioning it would be preferable to use him it in a [request]

[request]
{.if|{.current downloads.}>10|| {.set ini|speed-limit-ip=20.}| {.set ini|speed-limitip=-1.}.}
{.if|{.{.time|h.} = 18.} | {.set ini|speed-limit=100.}.}
{.if|{.{.time|h.} = 0.} | {.set ini|speed-limit=-1.}.}
« Last Edit: March 19, 2009, 09:29:08 PM by mars »


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
speed-limit (by connect) = speed-limit-ip


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13517
    • View Profile
you guys, are forgetting {:quotings:}

{.if|{.{.time|h.} = 18.} | {:{.set ini|speed-limit=100.}:}.}
{.if|{.{.time|h.} = 0.} | {:{.set ini|speed-limit=-1.}:}.}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13517
    • View Profile
please, post the full code and report where you put it (template or events)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13517
    • View Profile
mmm, maybe because no download was issued since 18.00 till 18.59
this should work better, until i don't find the time to introduce timed events (as in mars' version)

[request]
{.set ini|speed-limit={.if|{.{.time|s.} >= 18.} |100|-1.}.}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13517
    • View Profile
But that doesn't complete the cycle, it is only time defined for 100KBps not for the -1.

no, the code says: when HOUR is 18 or more than give "100", else (when it is less than 18) give "-1"
you'll get "-1" for 0-17

Quote
Now that I think of it why not introduce a time interval format to the time macro?

give a look to {.in range.}

Quote
PS. downloads were currently going when time shifted from 17h59 to 18h

eh, this script is limited to the fact that it runs only when a new request is done.
if you don't get any new HTTP request, it never runs.
this problem will disappear with timed events.


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
UPDATE

Apparently you should add these commands instead of the previously posted set ini schedule commands.

1.Open HFS
2.Trigger ALT+F6 (will open hfs.events)
3.Add a code using such format:

Code: [Select]
[AT 18:00]
{.set ini|speed-limit=100.}
[AT 00:00]
{.set ini|speed-limit=-1.}

4.Save & Exit

A hfs.events file will be created next to your hfs.exe file and this is were such commands need to be in order to function since it doesn't seem to work in the template file, this is currently the best way to schedule speed-limits or any other command.

PS. [AT ..], [Every ..] commands will only work with HFS Beta 232 or later.
PS 2. I removed my previous posts so people would notice this one more, rather than wasting time reading what was before.
« Last Edit: April 12, 2009, 09:13:21 PM by Kremlin »