Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.30.01 RN All Other Issues
Author Message
614cooker
New Member
New Member



Joined: Nov 12, 2006
Posts: 24

PostPosted: Wed Jul 01, 2009 11:06 am Reply with quote

hello everyone, Im in need of some help, does anyone know how to restrict download speeds or restrict the number of downloads that unregistered and registered members can download.

kind regards,
martin mullen
 
View user's profile Send private message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Jul 01, 2009 6:10 pm Reply with quote

Unfortunately for download speeds, that really is a server-side thing. I don't know if any PHP script has control over that.

For restrictions, you can possible code an artificial restriction per user.... only give them a download link if they are below a certain count. That doesn't prevent anyone from downloading if they had the actual link. Nor is there a system in place to measure anonymous and user downloads right now.

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
eldorado
Involved
Involved



Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Thu Jul 02, 2009 1:22 am Reply with quote

just a code snippet.
Code:
// local file that should be send to the client

$local_file = 'test-file.zip';
// filename that the user gets as default
$download_file = 'your-download-name.zip';
 
// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5;
if(file_exists($local_file) && is_file($local_file)) {
    // send headers
    header('Cache-control: private');
    header('Content-Type: application/octet-stream');
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: filename='.$download_file);
 
    // flush content
    flush();   
    // open file stream
    $file = fopen($local_file, "r");   
    while(!feof($file)) {
 
        // send the current file part to the browser
        print fread($file, round($download_rate * 1024));   
 
        // flush the content to the browser
        flush();
 
        // sleep one second
        sleep(1);   
    }   
 
    // close file stream
    fclose($file);}
else {
    die('Error: The file '.$local_file.' does not exist!');
}

_________________
United-holy-dragons.net (My RN site)- Rejekz(cod4 clan) - gamerslounge 
View user's profile Send private message Visit poster's website MSN Messenger
614cooker







PostPosted: Thu Jul 02, 2009 4:21 pm Reply with quote

I have over 4200 downloads would i need to added this code over 4200 times or just the once and it will limit all downloads.

Just what i was hoping for was a unregistered member can download at 10KPS and registered 50Kbps and donated members unlimited.

or

Unregistered can only download 2 downloads, registered 20 downloads and donated members unlimited.

I hope you can understand what i am trying to do.
 
eldorado







PostPosted: Fri Jul 03, 2009 6:14 am Reply with quote

no I was just posting some code snippet. Might be wise to implement it on the download page rather than every downloads. Php is quite good to automatize these such things.
 
evaders99







PostPosted: Sat Jul 04, 2009 12:59 am Reply with quote

Interesting code snippet, I like it Smile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.30.01 RN All Other Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©