XFileSharing Pro - Possibility to switch from days to hours

Message
Author
Nick
Posts: 35
Joined: Aug 07, 2008 9:03 am

Possibility to switch from days to hours

#1 Postby Nick » Aug 15, 2008 8:53 am

Hello,

I was wondering if it would be possible to switch from days to hours in the system.

What I would want is that instead of "Download volume x in y days" to have "Download volume x in y hours" and even more if the system could check the number downloads made by an IP or user within a certain amount of time would be great. Something like "You can download x times in y hours".

Would this be possible?

Thank you,

Nick

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#2 Postby PilgrimX182 » Aug 15, 2008 9:13 am

Nothing is impossible in SibSoft :)
To change days to hours here's quick hack:
in index.cgi find these 2 lines:

Code: Select all

my $bw = $db->SelectOne("SELECT SUM(size) FROM IP2Files WHERE ip=INET_ATON(?) AND created > NOW()-INTERVAL ? DAY",$ses->getIP,$c->{bw_limit_days});
$ses->message("You have reached the download-limit: $c->{bw_limit} Mb for last $c->{bw_limit_days} days") if ($bw > 1024*1024*$c->{bw_limit});
and replace "DAY" with "HOUR" in 1st line, and then replace "days" with "hours" in 2nd line.

Use the same field in config, only it will be hours, not days.

Nick
Posts: 35
Joined: Aug 07, 2008 9:03 am

Re: Possibility to switch from days to hours

#3 Postby Nick » Aug 15, 2008 9:20 am

Hehe I know nothing is impossible, just wanted to tease you :)

What about the second option?
Nick wrote:Hello,

[..] and even more if the system could check the number downloads made by an IP or user within a certain amount of time would be great. Something like "You can download x times in y hours".
Thank you,

Nick

Nick
Posts: 35
Joined: Aug 07, 2008 9:03 am

#4 Postby Nick » Aug 15, 2008 9:34 am

I'm a bit confused to be honest :)

I have in index.cgi:

Code: Select all

     my $bw = $db->SelectOne("SELECT SUM(size) FROM IP2Files WHERE ip=INET_ATON(?) AND created > NOW()-INTERVAL ? HOUR",$ses->getIP,$c->{bw_limit_hours});
      $ses->message("You have reached the download-limit: $c->{bw_limit} Mb for last $c->{bw_limit_hours} hours") if ($bw > 1024*1024*$c->{bw_limit});
which i presume it is correct.

Now, in XFileConfig.pm i have the following:

Code: Select all


 # Used for BW limit
 bw_limit_days => '1',

 # Limit Max bandwidth for IP per 'bw_limit_days' days
 bw_limit_anon => '100',

 # Incrementally limit bandwidth per day
 bw_daily_limit_anon => '100',

 # Limit Max bandwidth for IP per 'bw_limit_days' days
 bw_limit_reg => '500',

 # Incrementally limit bandwidth per day
 bw_daily_limit_reg => '500',

 # Limit Max bandwidth for IP per 'bw_limit_days' days
 bw_limit_prem => '3000',

 # Incrementally limit bandwidth per day
 bw_daily_limit_prem => '0',

Where should I change the values in config?

Thank you,

Nick

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#5 Postby PilgrimX182 » Aug 15, 2008 9:37 am

add this code after that 2 lines:

Code: Select all

my $dlnum = $db->SelectOne("SELECT COUNT(*) FROM IP2Files WHERE ip=INET_ATON(?) AND created > NOW()-INTERVAL ? HOUR",$ses->getIP,$c->{limit_maxdl_hours});
$ses->message("You have reached the download-limit: $c->{limit_maxdl_num} downloads for last $c->{limit_maxdl_hours} hours") if $dlnum > $c->{limit_maxdl_num};
and add 2 keys into XFileConfig.pm:

Code: Select all

limit_maxdl_num => 5,
limit_maxdl_hours => 3,
which means max 5 downloads last 3 hours.

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#6 Postby PilgrimX182 » Aug 15, 2008 9:41 am

Damn. You've made wrong edit. Here's correct code for 1st feature:

Code: Select all

my $bw = $db->SelectOne("SELECT SUM(size) FROM IP2Files WHERE ip=INET_ATON(?) AND created > NOW()-INTERVAL ? HOUR",$ses->getIP,$c->{bw_limit_days}); 
$ses->message("You have reached the download-limit: $c->{bw_limit} Mb for last $c->{bw_limit_days} hours") if ($bw > 1024*1024*$c->{bw_limit});

Nick
Posts: 35
Joined: Aug 07, 2008 9:03 am

#7 Postby Nick » Aug 15, 2008 9:50 am

Corrected and added the lines.

Now the premium page looks like this:

http://www.self-share.com/premium.html

I'll PM you with links for downloading index.cgi and XFileConfig.cgi as it seems I'm still doing it wrong :)

Nick