In the previous article WordPress anti-CC attack code, we have mentioned a method to prevent WordPress from being attacked by CC attacks, but the disadvantage of this method is that the false blocking rate is high, if a person Refreshes a few times and the result is blocked, the user experience will be poor. Therefore, the following provides another code, the main function is to refresh the page more than five times in three seconds and direct the IP address to 127.0.0.1 of the local machine. This method works better.
To put it few words, paste the code first:
<? Php
// Come form www.90blog.org
Session_start (); // enable session
$ Timestamp = time ();
$ Ll_nowtime = $ timestamp;
// Determine whether a session exists. If a session exists, assign an initialization value if it does not exist.
If ($ _ SESSION ){
$ Ll_lasttime = $ _ SESSION ['ll _ lasttime'];
$ Ll_times = $ _ SESSION ['ll _ times '] + 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
} Else {
$ Ll_lasttime = $ ll_nowtime;
$ Ll_times = 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
$ _ SESSION ['ll _ lasttime '] = $ ll_lasttime;
}
// Current time-start logon time to determine if frequent logon jumps or the session is assigned a value
If ($ ll_nowtime-$ ll_lasttime) <3 ){
If ($ ll_times> = 5 ){
Header ("location: http: // 127.0.0.1 ");
Exit;
} Www.2cto.com
} Else {
$ Ll_times = 0;
$ _ SESSION ['ll _ lasttime'] = $ ll_nowtime;
$ _ SESSION ['ll _ times '] = $ ll_times;
}
?>
The above code is adapted from the PHP code that has been widely circulated on the Internet, but this code can be run. If you don't believe it, press F5 to try it. Of course, this is something I can ask someone else to come...
Similarly, it is recommended to add it to the header in WordPress, so the effect will be better. In addition, the preceding parameters can be modified. You can modify the parameters as needed to achieve better results.