KingOfHeart Posted March 24, 2009 Share Posted March 24, 2009 I like creating php images, and linking them on other sites. Since I do not own the site I need to make sure I don't use up all their bandwith. So I created a htaccess file to only allow certain hosts to link to my image. I also created a php script. Is this a good php script for controlling the bandwith for an image? function UpdateTable() { $tsql="SELECT * FROM Bandwith"; $tresult=mysql_query($tsql); while($trows=mysql_fetch_array($tresult)) { $time = $trows['id']; if(date("His") > $time + 500 || date("His") < $time - 500) mysql_query("DELETE FROM Bandwith WHERE id='$time'"); } $tresult=mysql_query($tsql); if(mysql_num_rows($tresult) > 40)//too many views within 5 min so shut down { $Handle = fopen(".htaccess", 'a'); $Data = chr(10) . "Deny from all"; fwrite($Handle, $Data); } } I have this line later on in my script. mysql_query("INSERT INTO Bandwith (id, ip, host,page) VALUES('$time', '$ip', '$host','$page') "); mysql_query("Update Bandwith SET image = '$image' WHERE id = '$time' AND ip = '$ip'"); I now question myself on why I separated those two lines, which I think I'll combine. Anyways, is this a good method for controlling bandwith abuse? Link to comment https://forums.phpfreaks.com/topic/150816-php-bandwith-control-advice/ Share on other sites More sharing options...
KingOfHeart Posted March 25, 2009 Author Share Posted March 25, 2009 *Bump* With so many active topics today, my thread got pushed down fast. Link to comment https://forums.phpfreaks.com/topic/150816-php-bandwith-control-advice/#findComment-793341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.