From ddcfe3046671f958ccf1c74e8c228ca04b294224 Mon Sep 17 00:00:00 2001 From: kokororin Date: Sat, 15 Jul 2017 11:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=94=AF=E6=8C=81=E6=8C=89?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Access_Core.php | 22 +++++++-- page/console.php | 117 ++++++++++++++++++++--------------------------- 2 files changed, 67 insertions(+), 72 deletions(-) diff --git a/Access_Core.php b/Access_Core.php index 4a1f492..03ef3e6 100644 --- a/Access_Core.php +++ b/Access_Core.php @@ -66,7 +66,8 @@ class Access_Core { $type = $this->request->get('type', 1); $filter = $this->request->get('filter', 'all'); - $content = $this->request->get('content', ''); + $ip = $this->request->get('ip', ''); + $cid = $this->request->get('cid', ''); $pagenum = $this->request->get('page', 1); $offset = (max(intval($pagenum), 1) - 1) * $this->config->pageSize; $query = $this->db->select()->from('table.access_log') @@ -87,10 +88,14 @@ class Access_Core } switch ($filter) { case 'ip': - $ip = bindec(decbin(ip2long($content))); + $ip = bindec(decbin(ip2long($ip))); $query->where('ip = ?', $ip); $qcount->where('ip = ?', $ip); break; + case 'post': + $query->where('content_id = ?', $cid); + $qcount->where('content_id = ?', $cid); + break; } $list = $this->db->fetchAll($query); foreach ($list as &$row) { @@ -120,6 +125,13 @@ class Access_Core 'type' => $type, )); $this->logs['page'] = $page->show(); + + $this->logs['cidList'] = $this->db->fetchAll($this->db->select('DISTINCT content_id as cid, COUNT(1) as count, table.contents.title') + ->from('table.access_log') + ->join('table.contents', 'table.access_log.content_id = table.contents.cid') + ->where('table.access_log.content_id <> ?', null) + ->group('table.access_log.content_id') + ->order('count', Typecho_Db::SORT_DESC)); } /** @@ -372,7 +384,8 @@ class Access_Core * @return void * @throws Typecho_Plugin_Exception */ - public static function rewriteLogs() { + public static function rewriteLogs() + { $db = Typecho_Db::get(); $rows = $db->fetchAll($db->select()->from('table.access_log')); foreach ($rows as $row) { @@ -398,7 +411,8 @@ class Access_Core * @access public * @return array */ - public function parseArchive($archive) { + public function parseArchive($archive) + { // 暂定首页的meta_id为0 $content_id = null; $meta_id = null; diff --git a/page/console.php b/page/console.php index 69c6cc7..c18a6cb 100644 --- a/page/console.php +++ b/page/console.php @@ -37,7 +37,7 @@ $access = new Access_Core();