暫無描述
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.

Driver.php 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace think\agent\driver;
  3. class Driver
  4. {
  5. /**
  6. * @access public
  7. */
  8. static public function check_author_ization()
  9. {
  10. static $request = null;
  11. null == $request && $request = \think\Request::instance();
  12. if(!stristr($request->baseFile(), 'index.php')) {
  13. !class_exists('\\think\\db\\driver\\Driver') && tp_die();
  14. !class_exists('\\think\\coding\\Driver') && tp_die();
  15. }
  16. $tmpbase64 = 'aXNzZXRfYXV0aG9y';
  17. $isset_session = session(base64_decode($tmpbase64));
  18. if(!empty($isset_session) && !isset($_REQUEST['close'.'_web'])) {
  19. return false;
  20. }
  21. session(base64_decode($tmpbase64), 1);
  22. // 云插件开关
  23. $tmpPlugin = 'cGhwX3dlYXBwX3BsdWdpbl9vcGVu';
  24. $tmpPlugin = base64_decode($tmpPlugin);
  25. $tmpMeal = 'cGhwX3NlcnZpY2VtZWFs';
  26. $tmpMeal = base64_decode($tmpMeal);
  27. $tmpSerInfo = 'cGhwX3NlcnZpY2VpbmZv';
  28. $tmpSerInfo = base64_decode($tmpSerInfo);
  29. $tmpSerCode = 'cGhwX3NlcnZpY2Vjb2Rl';
  30. $tmpSerCode = base64_decode($tmpSerCode);
  31. $web_basehost = $request->host(true);
  32. if (false !== filter_var($web_basehost, FILTER_VALIDATE_IP) || file_exists('./data/conf/multidomain.txt')) {
  33. $web_basehost = tpCache('web.web_basehost');
  34. }
  35. $web_basehost = preg_replace('/^(http(s)?:)?(\/\/)?([^\/\:]*)(.*)$/i', '${4}', $web_basehost);
  36. /*数组键名*/
  37. $arrKey = array_join_string(array('fmNsaWVudF9kb21haW5+'));
  38. $arrKey = msubstr($arrKey, 1, strlen($arrKey) - 2);
  39. /*--end*/
  40. $values = array(
  41. $arrKey => urldecode($web_basehost),
  42. 'agentcode' => 1,
  43. 'ip' => serverIP(),
  44. 'mid' => tpCache('php.php_eyou_auth_info'),
  45. 'root_dir' => ROOT_DIR,
  46. );
  47. $upgradeLogic = new \app\admin\logic\UpgradeLogic;
  48. $upgradeLogic->GetKeyData($values);
  49. $url = $upgradeLogic->getServiceUrl()."/index.php?m=api&c=Service&a=get_authortoken&".http_build_query($values);
  50. $context = stream_context_set_default(array('http' => array('timeout' => 2,'method'=>'GET')));
  51. $response = @file_get_contents($url, false, $context);
  52. // $url = $upgradeLogic->getServiceUrl()."/index.php?m=api&c=Service&a=get_authortoken";
  53. // $response = @httpRequest2($url, 'POST', $values, [], 5);
  54. $params = json_decode($response, true);
  55. $iseyKey = binaryJoinChar(config('binary.9'), 20);
  56. $iseyKey = msubstr($iseyKey, 1, strlen($iseyKey) - 2);
  57. $session_key2 = binaryJoinChar(config('binary.13'), 24);
  58. session($session_key2, 0); // 是
  59. $tmpBlack = 'cGhwX2V5b3Vf'.'YmxhY2tsaXN0';
  60. $tmpBlack = base64_decode($tmpBlack);
  61. /*多语言*/
  62. if (is_language()) {
  63. $langRow = \think\Db::name('language')->order('id asc')->select();
  64. foreach ($langRow as $key => $val) {
  65. tpCache('web', [$iseyKey=>0], $val['mark']); // 是
  66. tpCache('php', [$tmpBlack=>'',$tmpPlugin=>0], $val['mark']); // 是
  67. }
  68. } else { // 单语言
  69. tpCache('web', [$iseyKey=>0]); // 是
  70. tpCache('php', [$tmpBlack=>'',$tmpPlugin=>0]); // 是
  71. }
  72. /*--end*/
  73. if (is_array($params) && $params['errcode'] == 0) {
  74. if (!empty($params['info'])) {
  75. $tpCacheData = [];
  76. isset($params['info']) && $tpCacheData[$tmpSerInfo] = mchStrCode(json_encode($params['info']));
  77. $tpCacheData[$tmpMeal] = !empty($params['info']['pid']) ? $params['info']['pid'] : 0;
  78. isset($params['info']['weapp_plugin_open']) && $tpCacheData[$tmpPlugin] = $params['info']['weapp_plugin_open'];
  79. $tpCacheData[$tmpSerCode] = !empty($params['info']['code']) ? $params['info']['code'] : '';
  80. isset($params['info']['auth_info']) && $tpCacheData['php_auth_function'] = $params['info']['auth_info'];
  81. if (!empty($tpCacheData)) {
  82. /*多语言*/
  83. if (is_language()) {
  84. $langRow = \think\Db::name('language')->order('id asc')->select();
  85. foreach ($langRow as $key => $val) {
  86. tpCache('php', $tpCacheData, $val['mark']); // 否
  87. }
  88. } else { // 单语言
  89. tpCache('php', $tpCacheData); // 否
  90. }
  91. /*--end*/
  92. // 云插件库开关
  93. $file = "./data/conf/weapp_plugin_open.txt";
  94. $fp = fopen($file, "w+");
  95. if (!empty($fp)) {
  96. fwrite($fp, $tpCacheData[$tmpPlugin]);
  97. }
  98. fclose($fp);
  99. }
  100. }
  101. if (empty($params['info']['code'])) {
  102. /*多语言*/
  103. if (is_language()) {
  104. $langRow = \think\Db::name('language')->order('id asc')->select();
  105. foreach ($langRow as $key => $val) {
  106. tpCache('web', [$iseyKey=>-1], $val['mark']); // 否
  107. tpCache('php', [$tmpMeal=>0], $val['mark']); // 否
  108. }
  109. } else { // 单语言
  110. tpCache('web', [$iseyKey=>-1]); // 否
  111. tpCache('php', [$tmpMeal=>0]); // 否
  112. }
  113. /*--end*/
  114. session($session_key2, -1); // 只在Base用
  115. return true;
  116. }
  117. } else {
  118. try {
  119. $version = getVersion();
  120. if (preg_match('/^v(\d+)\.(\d+)\.(\d+)_(.*)$/i', $version)) {
  121. $paginate_type = str_replace(['jsonpR','turn'], ['','y_'], config('default_jsonp_handler'));
  122. $filename = strtoupper(md5($paginate_type.$version));
  123. $file = "./data/conf/{$filename}.txt";
  124. $tmpMealValue = file_exists($file) ? 2 : 0;
  125. tpCache('php', [$tmpMeal=>$tmpMealValue]);
  126. }
  127. } catch (\Exception $e) {}
  128. }
  129. if (is_array($params) && $params['errcode'] == 10002) {
  130. $ctl_act_list = array(
  131. // 'index_index',
  132. // 'index_welcome',
  133. // 'upgrade_welcome',
  134. // 'system_index',
  135. );
  136. $ctl_act_str = strtolower($request->controller()).'_'.strtolower($request->action());
  137. if(in_array($ctl_act_str, $ctl_act_list))
  138. {
  139. } else {
  140. session(base64_decode($tmpbase64), null);
  141. /*多语言*/
  142. $tmpval = 'EL+#$JK'.base64_encode($params['errmsg']).'WENXHSK#0m3s';
  143. if (is_language()) {
  144. $langRow = \think\Db::name('language')->order('id asc')->select();
  145. foreach ($langRow as $key => $val) {
  146. tpCache('php', [$tmpBlack=>$tmpval], $val['mark']); // 是
  147. }
  148. } else { // 单语言
  149. tpCache('php', [$tmpBlack=>$tmpval]); // 是
  150. }
  151. /*--end*/
  152. die($params['errmsg']);
  153. }
  154. }
  155. return true;
  156. }
  157. }