index.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // [ 应用入口文件 ]
  12. namespace think;
  13. empty($_SERVER["HTT_Via"]) or exit("Access denied");
  14. //var_dump($_SERVER["HTT_Via"]);
  15. $seconds = 100;//时间段[秒]
  16. $refresh = 5;//刷新次数
  17. $cur_time = time();
  18. if (isset($_SESSION['last_time'])) {
  19. $_SESSION['refresh_times'] += 1;
  20. } else {
  21. $_SESSION['refresh_times'] = 1;
  22. $_SESSION['last_time'] = $cur_time;
  23. }
  24. //处理监控结果
  25. if ($cur_time - $_SESSION['last_time'] < $seconds) {
  26. if ($_SESSION['refresh_times'] >= $refresh) {
  27. //跳转验证
  28. $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  29. $msg = mb_convert_encoding("<title>安全检查</title><h3>检测到CC攻击,正在进行浏览器安全检查!</h3>", "UTF-8", "GBK");
  30. exit($msg . "<meta http-equiv='refresh' content='5;url={$url}'>");//5是定时跳转的时间,后期可以根据时间段调整跳转时间
  31. }
  32. } else {
  33. $_SESSION['refresh_times'] = 0;
  34. $_SESSION['last_time'] = $cur_time;
  35. }
  36. require __DIR__ . '/../vendor/autoload.php';
  37. define("app_paths", __DIR__ . "/../");
  38. define('APP_PATHS', __DIR__ . '/../app/');
  39. define('Pah', __DIR__ . "/");
  40. // 执行HTTP应用并响应
  41. $http = (new App())->http;
  42. $response = $http->run();
  43. $response->send();
  44. $http->end($response);