WordPress anti-CC attack code (continued)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.