rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: Kremlin on October 22, 2009, 03:40:01 PM

Title: Premium hour / Folder lock
Post by: Kremlin on October 22, 2009, 03:40:01 PM
Hi everyone, it's been a while :) (University..)

So basically i'm trying to figure out how to enforce a premium hour service, as in some folders get automatically locked at a certain time in the day lets say [at 19:00]. These folders should preferably get locked with an already existing account user and pass (this part if flexible). Is there anyway to do so in the 'diff template' sections with the 'if' 'set ini' and 'at' macros? Other suggestions are also welcome.

PS. I do not wish to lock the entire site, just the folders that appear in the site.
Title: Re: Premium hour / Folder lock
Post by: Mars on October 22, 2009, 09:14:21 PM
uses the events (hfs.events)

they accept times events and more ...

http://www.rejetto.com/wiki/index.php/HFS:_Event_scripts

 ;)
Title: Re: Premium hour / Folder lock
Post by: rejetto on October 24, 2009, 04:00:26 PM
with diff templates you may get to hide the files, not showing the list on some hours.
but the best solution is: events + account
Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 29, 2009, 06:01:58 PM
hmm, when i use set user/pass on a folder with the interface option, is there a way to put that action in form of a macro in the diff template?

I would then use something like,

[at 18:00]
{.set ini|%user%=xxxx ...
Title: Re: Premium hour / Folder lock
Post by: Mars on October 29, 2009, 08:30:37 PM
Quote
hmm, when i use set user/pass on a folder with the interface option, is there a way to put that action in form of a macro in the diff template?

I would then use something like,

[at 18:00]
{.set ini|%user%=xxxx ...

events as [at 18:00] are only allowed in hfs.events, not inside a tpl or a diff tpl

time events are tested every minutes

Quote from: WIKI Rejetto
Timed events
You can ask HFS to run a script at a certain time, or interval.

To run a script at 1PM o'clock, you can make an event [at 13:00].

To run every 15 minutes instead you should make an event [every 15 minutes].


scripts and events in hfs
http://www.rejetto.com/forum/index.php?topic=6588.msg1042304#msg1042304

Small reminder about EVENTS and hfs.events
http://www.rejetto.com/forum/index.php?topic=6845.msg1042396#msg1042396


but you know all of that ;)
Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 29, 2009, 09:19:43 PM
Yeah, I kinda figured that the [at xx:xx] would only work for the events, but with this comes an idea, how about adding an option to the events to only affect certain folders in the hfs tree. For example:

[for /Movies/2009/]
[at 18:00]
{.set ...
[/for]

this way we could use the events in a partial way. Anyway it's just a suggestion for rejetto  :P
Title: Re: Premium hour / Folder lock
Post by: Mars on October 29, 2009, 10:39:02 PM
Quote
[for /Movies/2009/]
[at 18:00]
{.set ...
[/for]


[at 18:00]
{set item|/Movies/2009|remove access=Kremlin.}

[at 06:00]
{set item|/Movies/2009|add access=Kremlin.}

Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 29, 2009, 10:40:53 PM
Nevermind rejetto. Mars u rock :)
Title: Re: Premium hour / Folder lock
Post by: Mars on October 29, 2009, 10:49:55 PM
always reading the wiki :D

http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands#Account_manipulation
Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 29, 2009, 11:05:13 PM
Yet something is missing in a little script i'm making

Code: [Select]
[unauthorized]
{.if|%password%=||{.append|/template/log.txt|[%date][%ip%] %user%:%password%
.}.}

Keep in mind when i place nothing in front of the =, i mean it not to log when someone has not entered a password. But it still keeps logging it, making the number of lines in the txt file massive :S
Title: Re: Premium hour / Folder lock
Post by: Mars on October 29, 2009, 11:30:03 PM
Quote
[unauthorized]
{.if|%password%=||{.append|/template/log.txt|[%date][%ip%] %user%:%password%
.}.}

exactly the same with

[unauthorized]
{.if|%user%%password%|{:{.append|/template/log.txt|
[%date%] [%ip%] %user%:%password%.}:}.}

never forget to quote any macro inside {.if| .... |{: .... :}|{: .... :} .}

Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 29, 2009, 11:44:22 PM
Figured it out, just bad syntax  :P

Code: [Select]
[unauthorized]
{.if not|{.%password%=.}|{:{.append|/template/log.txt|[%date][%ip] %user%:%password%
.}:}.}

Works like a charm  :)
Title: Re: Premium hour / Folder lock
Post by: Mars on October 30, 2009, 07:37:04 AM
you can reduce
{.if not|{.%password%=.}|{:{.

by
{.if|%password%|{:{.

Title: Re: Premium hour / Folder lock
Post by: Kremlin on October 31, 2009, 01:26:40 AM
Just to conclude the purpose of this thread and if anyone else is interested in something similar, I chose these lines to use in the hfs.events (ALT+F6)

Code: [Select]
[at 18:00]
{.set ini|speed-limit-ip=5.}
{.set item|/|add access=Administrator.}

[at 18:01]
{.disconnect|192.168.12.1-192.168.12.255.}

[at 00:00]
{.set ini|speed-limit-ip=-1.}
{.set item|/|remove access=Administrator.}

Obviously the 'Administrator' account needs the no limits option, otherwise speed would be very slow :P