From 6a81dc59f1ecc9f708ae4452c591129b2bff4821 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Fri, 28 Apr 2023 14:25:45 +0800 Subject: [PATCH] fiax --- .../third_party/wwwlog/controllers/index.php | 75 +++++++++++-------- .../wwwlog/models/wwwlogs_model.php | 5 +- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/application/third_party/wwwlog/controllers/index.php b/application/third_party/wwwlog/controllers/index.php index b4e8546e..19013fe7 100644 --- a/application/third_party/wwwlog/controllers/index.php +++ b/application/third_party/wwwlog/controllers/index.php @@ -21,10 +21,15 @@ class Index extends CI_Controller , 'gl' => 'guilinchina' , 'sht' => 'shanghaihighlights' , 'gm' => 'chinarundreisen' + , 'gmhw' => 'chinarundreisen' , 'jp' => 'arachina' + , 'jphw' => 'arachina' , 'ru' => 'chinahighlights_ru' + , 'ruhw' => 'chinahighlights_ru' , 'it' => 'viaggio-in-cina' + , 'ithw' => 'viaggio-in-cina' , 'vac' => 'viaje-a-china' + , 'vachw' => 'viaje-a-china' , 'vc' => 'voyageschine' , 'vchw' => 'voyageschine', ); //站点日志存储库,每个网站对应一个 @@ -43,7 +48,13 @@ class Index extends CI_Controller $orders = $this->wwwlogs_model->get_update_list(10); if ($orders) { foreach ($orders as $item) { - $this->orders_view_path($item->COLI_SN, strtolower($item->COLI_WebCode), $item->COLI_SenderIP); + $site_code = strtolower($item->COLI_WebCode); + if (in_array($site_code, array('gm', 'gmhw', 'jp', 'jphw', 'ru', 'ruhw', 'it', 'ithw', 'vac', 'vachw', 'vc', 'vchw'))) { + print_r($item);die(); + $this->orders_view_path_int($item->COLI_SN, $site_code, $item->COLI_SenderIP); + } else { + $this->orders_view_path($item->COLI_SN, $site_code, $item->COLI_SenderIP); + } echo 'COLI_WebCode:' . $item->COLI_WebCode . ' COLI_ID:' . $item->COLI_ID . ' COLI_SenderIP:' . $item->COLI_SenderIP . '
'; } } @@ -116,38 +127,23 @@ class Index extends CI_Controller } //定时抓取订单日志 - 国际站 - public function orders_view_path_int( /*$COLI_SN, $sitecode = 'cht', $ip, $offset = 0*/) + public function orders_view_path_int($COLI_SN, $sitecode = 'cht', $ip, $offset = 0) { // 测试数据 - 2 - $COLI_SN = 1004250; - $sitecode = 'vchw'; - $ip = '2a01:cb1c:8190:df00:dc11:12fb:3ed1:1bcb'; - $offset = 0; + // $COLI_SN = 1004250; + // $sitecode = 'gmhw'; + // $ip = '2a00:6020:41c7:3900:20c1:3c5c:c854:7095'; + // $client_id = '1682234553117123196'; + // $offset = 0; $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 NOT like '%.jpg' - and request_uri NOT like '%.JPG' - and request_uri NOT like '%.png' - and request_uri NOT like '%.gif' - and request_uri NOT like '%.css' - and request_uri NOT like '%.webp' - and request_uri NOT like '%.js' - and request_uri NOT like '%.woff' - and request_uri NOT like '%.ttf' - and request_uri NOT like '%.eot' - and request_uri NOT like '%.ico' - and request_uri NOT like '/guide-use.php%' - and request_uri NOT like '/index.php%' - and request_uri NOT like '/secureforms/form_token' - and request_uri NOT like '/ip/' - and request_uri NOT like '/ajax/getads/' - and request_uri NOT like '/public/template/footer.html' - and request_uri NOT like '/public/%' - and (remote_addr='$ip' OR http_x_forwarded_for like '%$ip%') - "; //ORDER BY time_local ASC 时间精度不够,会导致相同排序错误,只能用系统默认排序 - $from = time() - 604800; //往前 604800(7天), 1296000(15天) + 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__ ASC + "; // 同时使用IP和用户ID + $from = time() - 604800 * 4; //往前 604800(7天), 1296000(15天) $to = time(); $request = new Aliyun_Log_Models_GetLogsRequest('globalhoghlights', $this->logstore[$sitecode], $from, $to, '', $query_string, 100, $offset, true); try { @@ -159,8 +155,27 @@ class Index extends CI_Controller foreach ($log->getContents() as $key => $value) { $LogData->$key = $value; } - // $this->wwwlogs_model->add('wwwlogs', $LogData); - print_r($LogData); + + // 调整数据: 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); @@ -191,4 +206,4 @@ class Index extends CI_Controller logVarDump($ex); } } -} +} \ No newline at end of file diff --git a/application/third_party/wwwlog/models/wwwlogs_model.php b/application/third_party/wwwlog/models/wwwlogs_model.php index 5d3fbd5c..1a869af6 100644 --- a/application/third_party/wwwlog/models/wwwlogs_model.php +++ b/application/third_party/wwwlog/models/wwwlogs_model.php @@ -60,11 +60,10 @@ class wwwlogs_model extends CI_Model public function get_list() { $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; - // 国际暂时不需要从这个里获取 - lmr - 移除 'gm','jp','ru','it','vac','vc' $sql .= " COLI_SN,COLI_ID, COLI_WebCode,COLI_Name, COLI_OrderDetailText, COLI_OrderStartDate,COLI_SenderIP,COLI_WebCode,COLI_ApplyDate from ConfirmLineInfo where 1=1 - and COLI_WebCode in ('cht','ah','gh','ct','yz','sht','gl') + and COLI_WebCode in ('cht','ah','gh','ct','yz','sht','gl','gm','jp','ru','it','vac','vc','gmhw','jphw','ruhw','ithw','vachw','vchw') and not exists (select top 1 1 from InfoManager.dbo.wwwlogs where wl_COLI_SN=COLI_SN ) and COLI_SenderIP is not null and DeleteFlag=0 @@ -86,4 +85,4 @@ class wwwlogs_model extends CI_Model } } -} +} \ No newline at end of file