Date: 07/21/05 (PHP Community) Keywords: php So, I was going to ask for some ideas on how to do IP Throttling with PHP, but came up with something before I had a chance to post anything:
IP_LIMIT);
if(!$denied)
$data[$_SERVER['REMOTE_ADDR']]++;
}
// write the data back to the file
$data_string = serialize($data);
$fp = fopen(DATAFILE, "w");
fputs($fp, $data_string);
fclose($fp);
if($denied) {
switch(THROTTLING_ACTION) {
case "redirect":
header("Location: " . THROTTLING_MESSAGE);
die;
break;
default:
echo THROTTLING_MESSAGE;
die;
break;
}
}
?>
Then in a file to be throttled: throttleme.php Any thoughts on how to improve this? Source: http://www.livejournal.com/community/php/322901.html
|