deltablaze Posted February 26, 2006 Share Posted February 26, 2006 Hey guys! I own an anime site, which people can download anime media from, it uses about 500GB a month. Anyways, loads of people were downloading and apache simply cannot handle all the requests, thus no pages load which makes the server really...well not working. I was wondering if anybody knows how to make or a script that can cap how many downloads people can download at a time.Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/3624-php-capping-script/ Share on other sites More sharing options...
only one Posted February 3, 2007 Share Posted February 3, 2007 [b]ill get you startedwhat you want is something that stores the time someone sterted downloading something in a database, let them fill in a form that lets them select their connection speed, then find out a sort of avarage download timenow you want something like[/b][code]<?//current time$currenttime = date(YmdHis); // visit 'http://nl2.php.net/date'//their ip$ip=$_SERVER['REMOTE_ADDR'];//calculations$downloadtime = $currentime + their avarge download time; //insert it into your databasemysql_query(INSERT INTO downloaders `downloadtime`, `ip` VALUES '$downloadtime', '$ip'); ?>[/code][b]then i dont know how your site works but heres the code for retrieving it[/b][code]<?//retreive stuff from databse$time = date(YmdHis) + 50; //gives them 50 minutes from the hour to download it, if its any greater than 10 past the hour this doesnt always work very well, but this is only very basic....$query = mysql_query("SELECT downloadtime FROM dowloaders WHERE downloadtime > $time") or die(mysql_error());$row = mysql_fetch_array($query);//allows no more than 10 peaople at once to download it$num_rows = mysql_num_rows($query);if($num_rows>10){ echo "currently unavailable"; }else { echo "<a href=download url>Click here to download</a>"; }?>[/code][b][color=red]this wont work![/color][/b] Quote Link to comment https://forums.phpfreaks.com/topic/3624-php-capping-script/#findComment-176405 Share on other sites More sharing options...
JasonLewis Posted February 3, 2007 Share Posted February 3, 2007 i've never done something like this but you would have to do something like what only one has. you would have to store the users IP as well.i am pretty sure you would have to find an average download time. although only one's code is very badly done, no offence. Quote Link to comment https://forums.phpfreaks.com/topic/3624-php-capping-script/#findComment-176414 Share on other sites More sharing options...
only one Posted February 4, 2007 Share Posted February 4, 2007 hey i said it was basic... Quote Link to comment https://forums.phpfreaks.com/topic/3624-php-capping-script/#findComment-176724 Share on other sites More sharing options...
.josh Posted February 4, 2007 Share Posted February 4, 2007 Yeah...I'm not even going to get into how silly that code is...no offense man, but seriously...Create a login system. Force users to login. Obfuscate the files by using a file id system. Allow only x amount of downloads or x amount of bytes to be downloaded per x amount of time, per user, by storing those numbers in the database and associating them with the user info you have from the login system. Break that down one sentence at a time and start looking for some tutorials and put it all together. Also look into hosting the files on other servers. Get all those people who are willing to download your stuff to be willing to donate their own bandwidth, or give you some money to buy better hosting. Quote Link to comment https://forums.phpfreaks.com/topic/3624-php-capping-script/#findComment-176727 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.