SunQuest
           Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 31st, 2005, 10:15 AM
Crono Crono is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 Crono User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 9 sec
Reputation Power: 0
Download Limiting Script

I'm looking for a script that will limit the amount of downloads per user per a day. I need something like this because my website is using too much transfer (have max of 1800 GB/month) and I want to make sure the users are downloading a max of 10 files each. Or if there is a script that could automatically disable downloads once a certain "maximum daily bandwidth" has been used (60GB a day), or something of the sort, that would be equally helpful. I'm willing to pay for this type of script, but not too much as nearly all the funds I have are being eaten up by server costs. I have very limited programming experience, so the easier to implement, the better. Thanks in advance for your help

Reply With Quote
  #2  
Old February 1st, 2005, 04:43 PM
Rare-Designer Rare-Designer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Newark, England
Posts: 30 Rare-Designer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 18 m 41 sec
Reputation Power: 4
Send a message via AIM to Rare-Designer Send a message via MSN to Rare-Designer
This wouldnt be hard, although to make it work they would have to register otherwise cookies and sessions are the only option and people can get round that easily.

If they are signed up, then make a field in the table thats called "BytesToday" then each time they click a download add to that "BytesToday" limit, every night reset everyones "BytesToday" to zero.

Do you hide the origin of your downloads with a PHP script like this:

PHP Code:
<?
function dl_file($file){

   
//First, see if the file exists
   
if (!is_file($file)) { die("<b>404 File not found!</b>"); }

   
//Gather relevent info about file
   
$len filesize($file);
   
$filename basename($file);
   
$file_extension strtolower(substr(strrchr($filename,"."),1));

   
//This will set the Content-Type to the appropriate setting for the file
   
switch( $file_extension ) {
         case 
"pdf"$ctype="application/pdf"; break;
     case 
"exe"$ctype="application/octet-stream"; break;
     case 
"zip"$ctype="application/zip"; break;
     case 
"doc"$ctype="application/msword"; break;
     case 
"xls"$ctype="application/vnd.ms-excel"; break;
     case 
"ppt"$ctype="application/vnd.ms-powerpoint"; break;
     case 
"gif"$ctype="image/gif"; break;
     case 
"png"$ctype="image/png"; break;
     case 
"jpeg":
     case 
"jpg"$ctype="image/jpg"; break;
     case 
"mp3"$ctype="audio/mpeg"; break;
     case 
"wav"$ctype="audio/x-wav"; break;
     case 
"mpeg":
     case 
"mpg":
     case 
"mpe"$ctype="video/mpeg"; break;
     case 
"mov"$ctype="video/quicktime"; break;
     case 
"avi"$ctype="video/x-msvideo"; break;

     
//The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
     
case "php":
     case 
"htm":
     case 
"html":
     case 
"txt": die("<b>Cannot be used for "$file_extension ." files!</b>"); break;

     default: 
$ctype="application/force-download";
   }

   
//Begin writing headers
   
header("Pragma: public");
   
header("Expires: 0");
   
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   
header("Cache-Control: public"); 
   
header("Content-Description: File Transfer");
   
   
//Use the switch-generated Content-Type
   
header("Content-Type: $ctype");

   
//Force the download
   
$header="Content-Disposition: attachment; filename=".$filename.";";
   
header($header );
   
header("Content-Transfer-Encoding: binary");
   
header("Content-Length: ".$len);
   @
readfile($file);
   exit;
}
dl_file($_SERVER['DOCUMENT_ROOT']."/downloads/file.zip");
?>

Email me for more details i have that on my website and it works nicely.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Download Limiting Script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway