AgentCheckBehavior.class.php 1.0 KB

123456789101112131415161718192021222324
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2009 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. namespace Behavior;
  12. /**
  13. * 行为扩展:代理检测
  14. */
  15. class AgentCheckBehavior {
  16. public function run(&$params) {
  17. // 代理访问检测
  18. $limitProxyVisit = C('LIMIT_PROXY_VISIT',null,true);
  19. if($limitProxyVisit && ($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'] || $_SERVER['HTTP_PROXY_CONNECTION'] || $_SERVER['HTTP_USER_AGENT_VIA'])) {
  20. // 禁止代理访问
  21. exit('Access Denied');
  22. }
  23. }
  24. }