Home > Backend Development > PHP Tutorial > PHP anti-CC attack code example

PHP anti-CC attack code example

WBOY
Release: 2016-07-25 08:54:27
Original
1274 people have browsed it
  1. $P_S_T = $t_array[0] + $t_array[1];

  2. $timestamp = time();

  3. session_start( );

  4. $ll_nowtime = $timestamp ;
  5. if (session_is_registered('ll_lasttime')){
  6. $ll_lasttime = $_SESSION['ll_lasttime'];
  7. $ll_times = $_SESSION['ll_times'] + 1;
  8. $_SESSION[ 'll_times'] = $ll_times;
  9. }else{
  10. $ll_lasttime = $ll_nowtime;
  11. $ll_times = 1;
  12. $_SESSION['ll_times'] = $ll_times;
  13. $_SESSION['ll_lasttime'] = $ll_lasttime;
  14. }
  15. if (($ll_nowtime - $ll_lasttime)<3){
  16. if ($ll_times>=5){
  17. header(sprintf("Location: %s",'http://127.0.0.1'));
  18. exit;
  19. }
  20. }else{
  21. $ll_times = 0;
  22. $_SESSION['ll_lasttime'] = $ll_nowtime;
  23. $_SESSION['ll_times'] = $ll_times;
  24. }

Copy the code

User reply: SESSION relies on COOKIE. What if COOKIE is blocked? TCP/IP -> apache -> php This process has consumed a lot of things. At this point, there are just no more calculation operations and MYSQL connections. Just these few lines of code cannot solve the problem. At most, it is disabled for those operations where you press F5 to refresh the page in the browser.

It is still recommended to install a firewall to prevent CC attacks on the server for better results.



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template