GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   I need a php script to limit download (https://gfy.com/showthread.php?t=721833)

pornmasta 04-06-2007 01:06 PM

I need a php script to limit download
 
I want that to rpevent that a user download more that (let's say) 3 files in a day.
And i need a php script to do this.

Does someone has a free solution ?

misfit138 04-06-2007 02:27 PM

you can use php sessions... example;

<?php
session_start();

if (!session_is_registered('count')) {
session_register('count');
$count = 1;
} else {
$count++;
}
?>
<?
if ($_SESSION['count']>="3") {
?>you have reached you download limit...etc...
<? } else { ?>download code here<? } ?>

hope this helps ;)

pornmasta 04-06-2007 04:28 PM

in fact i programmed this:

Code:

<?php

$fifi = @$_GET['file'];
$dlimit = 2;
$tlimit = 86400;

if (!$fifi) {echo "error"; exit;};


$sites[1] = array("somewhere", "somewhere");
$sites[2] = array("somewhere", "somewhere");
$sites[3] = array("somewhere", "somewhere");





function dl_file_resume($fi1,$fi2)
{

//$tailleFichier = remote_file_size($fi1);
header('Content-Type: application/octet-stream');
//header("Content-Length: $tailleFichier");
header("Content-Disposition: attachment; filename=\"$fi2\"");
readfile($fi1,$fi2);
}





if (isset($_COOKIE['TimeCookie'])) {
  foreach ($_COOKIE['TimeCookie'] as $name => $value) {


if ($value<$dlimit) {
    // echo "$name : $value <br />\n";



setcookie("TimeCookie[1]", $value+1, time()+$tlimit);

dl_file_resume($sites[$fifi][0],$sites[$fifi][1]);



}
else {echo "Download limit reached, try again 24 hours after your last download";
exit;
}
  }
}
else {

$value = '1';

setcookie("TimeCookie[1]", $value, time()+$tlimit);  /* expire dans une heure */

dl_file_resume($sites[$fifi][0],$sites[$fifi][1]);

}


?>



All times are GMT -7. The time now is 11:36 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123