PHP anti-CC attack implementation code. In this case, your statistical system (which may be quantum or Baidu) cannot be used. However, we can use some anti-attack software to achieve this. However, sometimes the results are unclear. in this case, your statistical system (which may be quantum or Baidu) is of course not statistical. However, we can use some anti-attack software, but the effect is sometimes not obvious. Next I will provide a piece of PHP code to prevent CC attacks.
Main function: Refresh the page more than 5 times in 3 seconds and direct it to the local http: // 127.0.0.1
The code is 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 relies on cookies. what if the COOKIE is blocked?
The process of TCP/IP> apache> php has consumed a lot. at this step, there are no more computing operations and MYSQL connections.
These lines of code cannot solve the problem. At most, users can click F5 in the browser to fl the page.
Therefore, we recommend that you install a firewall to prevent cc attacks on your servers. You can go to s.jb51.net to view related software.
Attention (which may be quantum or Baidu) cannot be counted. However, we can use some anti-attack software to achieve this, but the effect is sometimes unknown...