diff --git a/application/third_party/wwwlog/controllers/index.php b/application/third_party/wwwlog/controllers/index.php index 67f885a3..eb29e692 100644 --- a/application/third_party/wwwlog/controllers/index.php +++ b/application/third_party/wwwlog/controllers/index.php @@ -83,7 +83,7 @@ class Index extends CI_Controller if ($orders) { foreach ($orders as $item) { $site_code = strtolower($item->COLI_WebCode); - if (in_array($site_code, array('gm', 'gmhw', 'jp', 'jphw', 'ru', 'ruhw', 'it', 'ts','ithw', 'vac', 'vachw', 'vc', 'vchw', 'gh_vac', 'gh_jp', 'gh_vc', 'gh_gm', 'gh_ru', 'gh_it'))) { + if (in_array($site_code, array('gm', 'gmhw', 'jp', 'jphw', 'ru', 'ruhw', 'it', 'ts', 'ithw', 'vac', 'vachw', 'vc', 'vchw', 'gh_vac', 'gh_jp', 'gh_vc', 'gh_gm', 'gh_ru', 'gh_it'))) { try { $this->orders_view_path_int($item->COLI_SN, $site_code, $item->COLI_SenderIP, 0, $item->COLI_OrderDetailText); } catch (Exception $err) { @@ -276,4 +276,95 @@ class Index extends CI_Controller logVarDump($ex); } } + + //测试接口权限 - lmr + public function test($COLI_SN, $sitecode = 'cht', $ip, $offset = 0, $order_text) + { + // 测试数据 - 2 + //$COLI_SN = 1004250; + //$sitecode = 'gmhw'; + //$ip = '2a00:6020:41c7:3900:20c1:3c5c:c854:7095'; + //$offset = 0; + //$order_text = 'Gaid-> GA1.2.1747854879.1682254516 <-Gaid + //YandexId-> 1682254516819066352 <-YandexId + //clino :g-de-in-2 + //startdate :2023-08-06 + //adultnum :4 + //Reiseroute Klasse :4 sterne hotel + //tourname :Rundreisen Nordindien 3 Wochen + //tages :21 + //Reiseroutennummer :14083 + //Geschlecht : + //Name :Firestone + //nationality :?sterreich + //E-Mail :AnaAnaki@hotmail.com + //Telefon :+4369918253609 + //来源页面 :https://www.chinarundreisen.com/indien/top-indien-reiseziele/ + // + //from:android + //Mozilla/5.0 (Linux; Android 9; SM-G950F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36 X-Middleton/1'; + + // 匹配clientId的正则表达式 + $yarndexPat = "/YandexId->(.+?)<-YandexId/"; + // 检查文本是否匹配正则表达式 + if (preg_match($yarndexPat, $order_text, $yandexMatches)) { + $client_id = trim($yandexMatches[1]); + } else { + $gaPat = "/Gaid->(.+?)<-Gaid/"; + if (preg_match($gaPat, $order_text, $gaMatches)) { + $client_id = trim($gaMatches[1]); + } else { + $client_id = "-- Match not found --"; + } + } + // echo $client_id; + + $query_string = " + * | select time_local,http_referer,request_uri,http_user_agent,http_x_forwarded_for, + remote_addr,request_method,request_time,status,body_bytes_sent,upstream_response_time from log where + request_uri like '/io/?event=pageview%' + and (remote_addr='$ip' OR http_x_forwarded_for like '%$ip%' OR request_uri like '%$client_id%') + ORDER BY __time__ DESC + "; // 同时使用IP和用户ID + $from = time() - 604800 * 2; //往前 604800(7天), 1296000(15天) + $to = time(); + $request = new Aliyun_Log_Models_GetLogsRequest('globalhoghlights', $this->logstore[$sitecode], $from, $to, '', $query_string, 100, $offset, true); + try { + $LogData = new StdClass; + $LogData->wl_sitecode = $sitecode; + $LogData->wl_COLI_SN = $COLI_SN; //订单SN + $response = $this->Log_Client->getLogs($request); + foreach ($response->getLogs() as $log) { + foreach ($log->getContents() as $key => $value) { + $LogData->$key = $value; + } + + // 调整数据: http_referer -> request_uri, request_uri.ref -> http_referer + if (isset($LogData->http_referer) && isset($LogData->request_uri)) { + $request_uri = $LogData->request_uri; + $http_referer = $LogData->http_referer; + + // http_referer -> request_uri + $LogData->request_uri = $LogData->http_referer; + // request_uri.ref -> http_referer + $query_string_tmp = urldecode($request_uri); + parse_str($query_string_tmp, $params); + if (isset($params['ref'])) { + $LogData->http_referer = $params['ref']; + } else { + $LogData->http_referer = '(not set)'; + } + + } + + print_r($LogData); + // $this->wwwlogs_model->add('wwwlogs', $LogData); + } + } catch (Aliyun_Log_Exception $ex) { + print_r($ex); + } catch (Exception $ex) { + print_r($ex); + } + } + } \ No newline at end of file