PDA

View Full Version : Download limit using PHP script or any



holydevil
July 23rd, 2005, 18:44
Hi Guys,

i am looking for a php script or any other script that limits downloads per day
example, an IP address can only download 5 files in 24hrs

There is another option which is not exactly required, i just thought it would be a neat feature the feature is that it shows the user what he/she has downloaded and how many dls are left in that 24 hr period

U can PM me or reply 2 this post

Thanx In Advance
:-)

holydevil
July 24th, 2005, 04:42
can any one pls help me; my site is on hault

kabatak
July 24th, 2005, 05:12
you may need a custom script for that

holydevil
July 25th, 2005, 09:34
dose any care to reply

overulehost
July 25th, 2005, 12:32
Try hotscripts.com ... if not i suggest you to hire a freelance programmer to do the job

killaH
July 28th, 2005, 19:19
If you need a freelance programmer to do this, please feel free to contact me

holydevil
July 30th, 2005, 09:14
killaH i have pm u just have a look


If you need a freelance programmer to do this, please feel free to contact me

ryza
July 30th, 2005, 11:38
just create a text file. make your script write 1 line in this text file (it will automatically adjust the files modification time).

Then you can make your page check if this file is older then 24 hours,
if it is then u delete all ip's from database.
Next write to the text file again which will reset the modification time (starting the 24 hours again).


Another way u can do it is just continually execute the query:
delete * from table where time<$timecheck;

better using text file cause u dont want mysql query happening everytime the page loads.

tip. store the ip's in a HEAP table (memory), it will be alot faster but when machine reboots all data is lost.

killaH
July 30th, 2005, 16:31
just create a text file. make your script write 1 line in this text file (it will automatically adjust the files modification time).

Then you can make your page check if this file is older then 24 hours,
if it is then u delete all ip's from database.
Next write to the text file again which will reset the modification time (starting the 24 hours again).


Another way u can do it is just continually execute the query:
delete * from table where time<$timecheck;

better using text file cause u dont want mysql query happening everytime the page loads.

tip. store the ip's in a HEAP table (memory), it will be alot faster but when machine reboots all data is lost.

You have ONE text file that will add IPs of people downloading, or one text file for each IP?

R4g1ng
July 31st, 2005, 06:10
I think its one text file. Doesn't seem too hard to make.

ryza
July 31st, 2005, 09:09
Yeh just one file, u just want to use the files modification time for your updates...

Doesnt need any content, i would just write some random line to it (change its modification time everytime u do the update.)
this way your script knows when it has to update next by checking this files mod time.

anyway, hope you get it, really is a simple task..

holydevil
July 31st, 2005, 14:32
Yeh just one file, u just want to use the files modification time for your updates...

Doesnt need any content, i would just write some random line to it (change its modification time everytime u do the update.)
this way your script knows when it has to update next by checking this files mod time.

anyway, hope you get it, really is a simple task..

hey ryra can u do the script for me i really need it but i dont have cash to pay but can add u has a scriptor on my site like

*site scripted by RYRA or ur site name in sponsor

shaiff_
August 2nd, 2005, 05:33
i have no idea about that

killaH
August 2nd, 2005, 15:11
hey ryra can u do the script for me i really need it but i dont have cash to pay but can add u has a scriptor on my site like

*site scripted by RYRA or ur site name in sponsor

Contact me if he doesn't reply, and I'll see if I can make it for you.

ryza
August 2nd, 2005, 15:38
You will have to setup your own database heap table,


<?php
$time=time();
$cachetime= @filemtime("$_SERVER[DOCUMENT_ROOT]/data/time.txt");
/* check if its time to do another update. */
if($cachetime+1800<$time) {
/* remove old ip's */
$compare=$time-86400;
#mysql_query("DELETE from `ip_log` WHERE time<'$compare'");
/* update text files modification time */
$file = @fopen("$_SERVER[DOCUMENT_ROOT]/data/time.txt", "w");
fwrite($file,"$time");
fclose($file);
}
?>

Also note some countrys use a proxy for thousands of computers
which means that you could effectively stop alot of people from downloading by blocking 1 IP.

killaH
August 2nd, 2005, 16:03
To find out if a user is using a proxy, you can try a function like this:



function getProxy() {
$proxy = array();

if(isset($_SERVER['HTTP_CLIENT_IP']))
$proxy = array_merge($proxy, explode(',', $_SERVER['HTTP_CLIENT_IP']));

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$proxy = array_merge($proxy, explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));

if (!count($proxy) > 0) {
if (isset($_SERVER["HTTP_PROXY_CONNECTION"]) || isset($_SERVER["HTTP_VIA"])) {
return "::Proxy Detected";
}
return "";
}
$proxy = implode('::', $proxy);
return '::' . $proxy;
}