- /**
- * Protection against DDoS, DNS, cluster attacks
- * Edit bbs.it-home.org
- */
- Query prohibit IP
- $ip =$_server[' remote_addr '];
- $fileht = ". Htaccess2";
- if (!file_exists ($fileht))
- File_put_contents ($fileht, "");
- $filehtarr = @file ($fileht);
- if (In_array ($ip. " \ r \ n ", $filehtarr))
- Die ("Warning:". ")
"." Your IP address is forbided by some reason and IF you had any question Pls Emill to shop@jbxue.com! ");
- Add Forbidden IP
- $time =time ();
- $fileforbid = "Log/forbidchk.dat";
- if (file_exists ($fileforbid)) {
- if ($time-filemtime ($fileforbid) >60)
- Unlink ($fileforbid);
- else {
- $fileforbidarr = @file ($fileforbid);
- if ($ip ==substr ($fileforbidarr [0],0,strlen ($IP))) {
- if ($time-substr ($fileforbidarr [1],0,strlen ($time)) >600)
- Unlink ($fileforbid);
- ElseIf ($fileforbidarr [2]>600) {
- File_put_contents ($fileht, $ip. " \ r \ n ", file_append);
- Unlink ($fileforbid);
- } else {
- $fileforbidarr [2]++;
- File_put_contents ($fileforbid, $fileforbidarr);
- }
- }
- }
- }
- Anti-Refresh
- $str = "";
- $file = "Log/ipdate.dat";
- if (!file_exists ("Log") &&!is_dir ("Log"))
- mkdir ("Log", 0777);
- if (!file_exists ($file))
- File_put_contents ($file, "");
- $allowTime = 120;//anti-refresh Time
- $allowNum =10;//anti-refresh times
- $uri =$_server[' Request_uri '];
- $checkip =md5 ($IP);
- $checkuri =md5 ($uri);
- $yesno =true;
- $ipdate = @file ($file);
- foreach ($ipdate as $k = = $v) {
- $iptem =substr ($v, 0,32);
- $uritem =substr ($v, 32,32);
- $timetem =substr ($v, 64,10);
- $numtem =substr ($v, 74);
- if ($time-$timetem < $allowTime) {
- if ($iptem! = $checkip)
- $str. = $v;
- else {
- $yesno =false;
- if ($uritem! = $checkuri)
- $str. = $iptem. $checkuri. $time. " 1\r\n ";
- ElseIf ($numtem < $allowNum)
- $str. = $iptem. $uritem. $timetem. ($numtem + 1). " \ r \ n ";
- else {
- if (!file_exists ($fileforbid)) {
- $addforbidarr =array ($ip. " \ r \ n ", Time ()." \ r \ n ", 1);
- File_put_contents ($fileforbid, $addforbidarr);
- }
- File_put_contents ("Log/forbided_ip.log", $ip. " --". Date (" Y-m-d h:i:s ", Time ())." --". $uri." \ r \ n ", file_append);
- $timepass = $timetem + $allowTime-$time;
- Die ("Warning:". ")
"." Sorry,you is forbided by refreshing frequently too much, Pls wait for ". $timepass." Seconds to continue! ");
- }
- }
- }
- }
- if ($yesno) $str. = $checkip. $checkuri. $time. " 1\r\n ";
- File_put_contents ($file, $STR);
- ?>
Copy Code |