<?
/*-----------------------------------------------------------------
/------------------------------------------------------------------\
| KO Panel PHP Protector .
| ßy Maxis .
\------------------------------------------------------------------/
------------------------------------------------------------------*/
class APS {
var $RequestLimit = "5"; // Bir saniyede Kaç kere girilme sayısı
/*Log kayıtcısı*/
function LogVisits() {
$Ip = $_SERVER["REMOTE_ADDR"];
$Now = date("i:s");
$GetContent = @file_get_contents("logs/".$Ip.".txt");
if(empty($GetContent)) {
$FileHandle = fopen("logs/".$Ip.".txt",'w+');
}
else {
$FileHandle = fopen("logs/".$Ip.".txt",'a');
}
fwrite($FileHandle,"$Now|\r\n");
fclose($FileHandle);
$NewContent = @file_get_contents("logs/".$Ip.".txt");
$SplitLines = explode('|',$NewContent);
foreach($SplitLines as $Line) {
$Second[$Line][] = $Line;
}
foreach($Second as $data) {
if(count($data) > $this->RequestLimit) {
/* Seni yakaladım JackaL :) Saldırı hea :) */
$this->Save($Ip);
}
}
}
/* Şimdi kendine el salla ip ni kaydediyorum... Artık bu ip 'den girmen yasak */
function Save($Ip) {
$Handle = fopen("banneds.txt",'a+');
fwrite($Handle,"$Ip\r\n");
fclose($Handle);
$this->Ban($Ip);
}
/*Ip BAN At .htaccess*/
function Ban($Ip) {
$Escape = "\r\n";
$FileHandle = fopen('.htaccess', 'w+');
$Banned = file_get_contents("banneds.txt");
$BannedUsers = explode("\r\n",$Banned);
fwrite($FileHandle,'order allow,deny '.$Escape.'deny from');
if(is_array($BannedUsers)) {
foreach($BannedUsers as $IpA) {
fwrite($FileHandle," $IpA");
}
}
fwrite($FileHandle,"\r\n"."allow from all");
fwrite($FileHandle,"\r\n".file_get_contents("extraht.txt"));
fclose($FileHandle);
/* Sil bakem Log'u */
unlink("logs/".$Ip.".txt");
}
}
/* Now Maxis's Time*/
$APS = new APS;
$APS->LogVisits();
?>