![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Too lazy to set a custom title
Join Date: Jun 2006
Posts: 19,196
|
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 ? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Registered User
Join Date: Nov 2006
Posts: 2
|
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 ;) |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Too lazy to set a custom title
Join Date: Jun 2006
Posts: 19,196
|
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]); } ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |