Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace think\agent\driver;
  3. /**
  4. * 系统行为扩展:
  5. */
  6. class BhvhomeVF {
  7. protected static $actionName;
  8. protected static $controllerName;
  9. protected static $moduleName;
  10. protected static $method;
  11. /**
  12. * 构造方法
  13. * @param Request $request Request对象
  14. * @access public
  15. */
  16. public function __construct()
  17. {
  18. }
  19. // 行为扩展的执行入口必须是run
  20. public function run(&$params){
  21. self::$actionName = request()->action();
  22. self::$controllerName = request()->controller();
  23. self::$moduleName = request()->module();
  24. self::$method = request()->method();
  25. $this->_initialize($params);
  26. }
  27. private function _initialize(&$params) {
  28. // $this->agentcode($params);
  29. }
  30. /**
  31. * @access public
  32. */
  33. private function agentcode(&$params)
  34. {
  35. $agentcode = config('tpcache.php_agentcode');
  36. if (1 == $agentcode) {
  37. $php_eyou_blacklist = tpCache('php.php_eyou_blacklist');
  38. if (!empty($php_eyou_blacklist)) {
  39. $web_basehost = request()->host(true);
  40. if (false !== filter_var($web_basehost, FILTER_VALIDATE_IP) || file_exists('./data/conf/multidomain.txt')) {
  41. $web_basehost = tpCache('web.web_basehost');
  42. }
  43. $web_basehost = preg_replace('/^(http(s)?:)?(\/\/)?([^\/\:]*)(.*)$/i', '${4}', $web_basehost);
  44. $values = array(
  45. 'client_domain' => urldecode($web_basehost),
  46. 'agentcode' => 1,
  47. 'root_dir' => ROOT_DIR,
  48. );
  49. $service_ey = config('service_ey');
  50. $url = base64_decode($service_ey).'/index.php?m=api&c=Service&a=get_authortoken&'.http_build_query($values);
  51. $response = httpRequest($url);
  52. $data = json_decode($response,true);
  53. if (!empty($data['errcode']) && $data['errcode'] == 10002) {
  54. $params = $data['errmsg'];
  55. return false;
  56. }
  57. } else {
  58. $jsStr = <<<EOF
  59. <script type="text/javascript">
  60. // 步骤一:创建异步对象
  61. var ajax = new XMLHttpRequest();
  62. // 步骤二:设置请求的url参数,参数一是请求的类型,参数二是请求的url,可以带参数,动态的传递参数starName到服务端
  63. ajax.open("post", "{$this->root_dir}/index.php?close_web=1&ey_agent=1", true);
  64. // 给头部添加ajax信息
  65. ajax.setRequestHeader("X-Requested-With","XMLHttpRequest");
  66. // 如果需要像 HTML 表单那样 POST 数据,请使用 setRequestHeader() 来添加 HTTP 头。然后在 send() 方法中规定您希望发送的数据:
  67. ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  68. // 步骤三:发送请求
  69. ajax.send('_ajax=1');
  70. // 步骤四:注册事件 onreadystatechange 状态改变就会调用
  71. ajax.onreadystatechange = function () {
  72. // 步骤五 如果能够进到这个判断 说明 数据 完美的回来了,并且请求的页面是存在的
  73. if (ajax.readyState==4 && ajax.status==200) {
  74.  }
  75. }
  76. </script>
  77. EOF;
  78. $params = str_ireplace('</body>', $jsStr."\n</body>", $params);
  79. }
  80. }
  81. }
  82. }