PHP anti-CC attack implementation code _php skills

Source: Internet
Author: User
This time your statistical system (may be quantum, Baidu, etc.) of course is also not statistically. However, we can use some software to prevent attacks, but the effect is sometimes not obvious. Below I provide a section of PHP code, can play a certain anti-CC effect.

Main function: in 3 seconds to refresh the page continuously more than 5 times will point to the local http://127.0.0.1
Copy Code code as follows:

$P _s_t = $t _array[0] + $t _array[1];
$timestamp = time ();

Session_Start ();
$ll _nowtime = $timestamp;
if (session_is_registered (' Ll_lasttime ')) {
$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;
}
if (($ll _nowtime-$ll _lasttime) <3) {
if ($ll _times>=5) {
Header (sprintf ("Location:%s", ' http://127.0.0.1 '));
Exit
}
}else{
$ll _times = 0;
$_session[' ll_lasttime ' = $ll _nowtime;
$_session[' ll_times ' = $ll _times;
}

The following is a reply from a netizen:
The session is based on cookies, what if the cookie is blocked off?
TCP/IP-> Apache-> php This process has consumed a lot of things, to this step just no more computing operations and MySQL connection
With these lines of code, it does not solve the problem. At most for those in the browser to press the F5 Brush page operation off.

So we recommend that the server install anti-CC attack firewall effect will be better. You can go to s.jb51.net to view the relevant software.

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.