HuyPV
Wednesday, April 22, 2009
<?php
function UpdateLog() {
chdir("iplog/");
$ip=$_SERVER['REMOTE_ADDR'];
$now = time();
if (file_exists("$ip")) {
$f = fopen($ip, "r");
$last = fread($f, 255);
fclose($f);
$f = fopen($ip, "w");
fwrite($f, $now);
fclose($f);
if ($now - $last < 2) {
exit("I am tired!");
} else {
//echo "OK. You are welcome! " . date("h:i:s d/m/Y", $last);
}
} else {
$f = fopen($ip, "w");
fwrite($f, $now);
fclose($f);
}
}
UpdateLog();
// main processing
?>
Title:
Using IP log to prevent DoS attack
Description:
<?php function UpdateLog() { chdir("iplog/"); $ip=$_SERVER['REMOTE_ADDR']; $now = time(); ...
...
Rating:
4