index.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. header('Control-type:image/*');
  37. header("Access-Control-Allow-Origin: *");
  38. header("Access-Control-Allow-Methods:POST,GET");
  39. header("Access-Control-Allow-Headers:x-requested-with,content-type");
  40. header("Content-type:text/json;charset=utf-8");
  41. require __DIR__ . '/../vendor/autoload.php';
  42. define("app_paths", __DIR__ . "/../");
  43. define('APP_PATHS', __DIR__ . '/../app/');
  44. define('Pah', __DIR__ . "/");
  45. // 执行HTTP应用并响应
  46. $http = (new App())->http;
  47. $response = $http->run();
  48. $response->send();
  49. $http->end($response);