1.5 修复旧版本升级错误的提示,自动更新数据表结构

This commit is contained in:
Kokororin 2016-11-10 11:26:52 +08:00
parent a0ffc19ee1
commit e06456b29d
7 changed files with 275 additions and 246 deletions

17
Access_Bootstrap.php Normal file
View File

@ -0,0 +1,17 @@
<?php
define('__ACCESS_PLUGIN_ROOT__', __DIR__);
if (function_exists('spl_autoload_register')) {
spl_autoload_register(function ($className) {
$filePath = __ACCESS_PLUGIN_ROOT__ . '/' . $className . '.php';
if (file_exists($filePath)) {
require_once $filePath;
} else {
throw new Typecho_Plugin_Exception($filePath . ' is not existed');
}
});
} else {
foreach (glob(__ACCESS_PLUGIN_ROOT__ . '/Access_*.php') as $filePath) {
require_once $filePath;
}
}

View File

@ -1,13 +1,18 @@
<?php
class Access_Extend
if (!defined('__ACCESS_PLUGIN_ROOT__')) {
throw new Exception('Boostrap file not found');
}
class Access_Core
{
protected $db;
protected $prefix;
protected $table;
protected $config;
public $config;
protected $request;
protected $pageSize;
protected $isDrop;
public $parser;
public $action;
public $title;
public $logs = array();
@ -26,6 +31,7 @@ class Access_Extend
if ($this->pageSize == null || $this->isDrop == null) {
throw new Typecho_Plugin_Exception('请先设置插件!');
}
$this->parser = new Access_Parser();
switch ($this->request->get('action')) {
case 'logs':
default:
@ -42,146 +48,11 @@ class Access_Extend
}
}
public $spiderArray = array(
"TencentTraveler",
"Baiduspider",
"BaiduGame",
"Googlebot",
"msnbot",
"Sosospider+",
"Sogou web spider",
"ia_archiver",
"Yahoo! Slurp",
"YoudaoBot",
"Yahoo Slurp",
"MSNBot",
"Java (Often spam bot)",
"BaiDuSpider",
"Voila",
"Yandex bot",
"BSpider",
"twiceler",
"Sogou Spider",
"Speedy Spider",
"Google AdSense",
"Heritrix",
"Python-urllib",
"Alexa (IA Archiver)",
"Ask",
"Exabot",
"Custo",
"OutfoxBot/YodaoBot",
"yacy",
"SurveyBot",
"legs",
"lwp-trivial",
"Nutch",
"StackRambler",
"The web archive (IA Archiver)",
"Perl tool",
"MJ12bot",
"Netcraft",
"MSIECrawler",
"WGet tools",
"larbin",
"Fish search",
"crawler",
"bingbot",
);
public function parseUA($ua)
{
$os = null;
if ($this->isSpider($ua)) {
$os = '爬虫';
} elseif (preg_match('/Windows NT 6.0/i', $ua)) {
$os = "Windows Vista";
} elseif (preg_match('/Windows NT 6.1/i', $ua)) {
$os = "Windows 7";
} elseif (preg_match('/Windows NT 6.2/i', $ua)) {
$os = "Windows 8";
} elseif (preg_match('/Windows NT 6.3/i', $ua)) {
$os = "Windows 8.1";
} elseif (preg_match('/Windows NT 10.0/i', $ua)) {
$os = "Windows 10";
} elseif (preg_match('/Windows NT 5.1/i', $ua)) {
$os = "Windows XP";
} elseif (preg_match('/Windows NT 5.2/i', $ua) && preg_match('/Win64/i', $ua)) {
$os = "Windows XP 64 bit";
} elseif (preg_match('/Android ([0-9.]+)/i', $ua, $matches)) {
$os = "Android " . $matches[1];
} elseif (preg_match('/iPhone OS ([_0-9]+)/i', $ua, $matches)) {
$os = 'iPhone ' . $matches[1];
} elseif (preg_match('/Ubuntu/i', $ua, $matches)) {
$os = 'Ubuntu ';
} elseif (preg_match('/Mac OS X ([0-9_]+)/i', $ua, $matches)) {
$os = 'Mac OS X ' . $matches[1];
} elseif (preg_match('/Linux/i', $ua, $matches)) {
$os = 'Linux';
} else {
$os = '未知';
}
if ($this->isSpider($ua)) {
$browser = '爬虫';
} elseif (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Camino ' . $matches[2];
} elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '搜狗浏览器 2' . $matches[1];
} elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '360浏览器 ' . $matches[1];
} elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Maxthon ' . $matches[2];
} elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Chrome ' . $matches[1];
} elseif (preg_match('#XiaoMi/MiuiBrowser/([0-9.]+)#i', $ua, $matches)) {
$browser = '小米浏览器 ' . $matches[1];
} elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Safari ' . $matches[1];
} elseif (preg_match('#opera mini#i', $ua)) {
preg_match('#Opera/([a-zA-Z0-9.]+)#i', $ua, $matches);
$browser = 'Opera Mini ' . $matches[1];
} elseif (preg_match('#Opera.([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Opera ' . $matches[1];
} elseif (preg_match('#TencentTraveler ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '腾讯TT浏览器 ' . $matches[1];
} elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'UCWEB ' . $matches[1];
} elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Internet Explorer ' . $matches[1];
} elseif (preg_match('#Trident#', $ua, $matches)) {
$browser = 'Internet Explorer 11';
} elseif (preg_match('#Edge/12.0#i', $ua, $matches)) {
//win10中spartan浏览器
$browser = 'Spartan';
} elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Firefox ' . $matches[2];
} else {
$browser = '未知';
}
return $os . " / " . $browser;
}
public function isSpider($ua)
{
$ua = strtolower($ua);
if (!empty($ua)) {
foreach ($this->spiderArray as $val) {
$str = strtolower($val);
if (strpos($ua, $str) !== false) {
return true;
}
}
} else {
return false;
}
}
protected function getWhere($type)
{
$where_str = '';
foreach ($this->spiderArray as $value) {
$where_str .= "ua {1} LIKE " . "'%{$value}%' {2} ";
foreach ($this->parser->bots as $value) {
$where_str .= "replace(LOWER(`ua`), ' ', '') {1} LIKE " . "'%{$this->parser->filter($value)}%' {2} ";
}
$where_str = rtrim($where_str, '{2} ');
switch ($type) {
@ -212,9 +83,13 @@ class Access_Extend
$this->logs['list'] = $this->db->fetchAll("SELECT * FROM {$this->table} {$where} ORDER BY id DESC LIMIT {$this->pageSize} OFFSET {$offset}");
$this->logs['rows'] = count($this->db->fetchAll("SELECT * FROM {$this->table} {$where}"));
include_once dirname(__FILE__) . '/lib/Page.php';
$pager = new Page($this->pageSize, $this->logs['rows'], $p, 10);
$this->logs['page'] = $pager->show();
$page = new Access_Page($this->pageSize, $this->logs['rows'], $p, 10, array(
'panel' => Access_Plugin::$panel,
'action' => 'logs',
'type' => $type,
));
$this->logs['page'] = $page->show();
}
protected function parseReferer()
@ -273,7 +148,7 @@ class Access_Extend
protected function buildObject($array, $quote)
{
$obj = json_encode($array);
$obj = Json::encode($array);
$obj = str_replace("\"", "'", $obj);
if ($quote) {
return $obj;

View File

@ -1,5 +1,9 @@
<?php
class Page
if (!defined('__ACCESS_PLUGIN_ROOT__')) {
throw new Exception('Boostrap file not found');
}
class Access_Page
{
private $each_disNums; //每页显示的条目数
private $nums; //总条目数
@ -7,6 +11,7 @@ class Page
private $sub_pages; //每次显示的页数
private $pageNums; //总页数
private $page_array = array(); //用来构造分页的数组
private $otherParams = array();
/**
*
* __construct是SubPages的构造函数用来在创建类的时候自动运行.
@ -21,42 +26,27 @@ class Page
* @subPage_type=2的时候为经典分页样式
* example 当前第1/453 [首页] [上页] 1 2 3 4 5 6 7 8 9 10 [下页] [尾页]
*/
public function __construct($each_disNums, $nums, $current_page, $sub_pages)
public function __construct($each_disNums, $nums, $current_page, $sub_pages, $otherParams)
{
$this->each_disNums = intval($each_disNums);
$this->nums = intval($nums);
if (!$current_page)
{
if (!$current_page) {
$this->current_page = 1;
}
else
{
} else {
$this->current_page = intval($current_page);
}
$this->sub_pages = intval($sub_pages);
$this->pageNums = ceil($nums / $each_disNums);
$this->otherParams = $otherParams;
}
/*
__destruct析构函数当类不在使用的时候调用该函数用来释放资源。
*/
public function __destruct()
{
unset($each_disNums);
unset($nums);
unset($current_page);
unset($sub_pages);
unset($pageNums);
unset($page_array);
}
/*
用来给建立分页的数组初始化的函数。
*/
public function initArray()
{
for ($i = 0; $i < $this->sub_pages; $i++)
{
for ($i = 0; $i < $this->sub_pages; $i++) {
$this->page_array[$i] = $i;
}
return $this->page_array;
@ -67,35 +57,23 @@ class Page
*/
public function construct_num_Page()
{
if ($this->pageNums < $this->sub_pages)
{
if ($this->pageNums < $this->sub_pages) {
$current_array = array();
for ($i = 0; $i < $this->pageNums; $i++)
{
for ($i = 0; $i < $this->pageNums; $i++) {
$current_array[$i] = $i + 1;
}
}
else
{
} else {
$current_array = $this->initArray();
if ($this->current_page <= 3)
{
for ($i = 0; $i < count($current_array); $i++)
{
if ($this->current_page <= 3) {
for ($i = 0; $i < count($current_array); $i++) {
$current_array[$i] = $i + 1;
}
}
elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1)
{
for ($i = 0; $i < count($current_array); $i++)
{
} elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1) {
for ($i = 0; $i < count($current_array); $i++) {
$current_array[$i] = ($this->pageNums) - ($this->sub_pages) + 1 + $i;
}
}
else
{
for ($i = 0; $i < count($current_array); $i++)
{
} else {
for ($i = 0; $i < count($current_array); $i++) {
$current_array[$i] = $this->current_page - 2 + $i;
}
}
@ -109,40 +87,30 @@ class Page
public function show()
{
$str = "";
if ($this->current_page > 1)
{
if ($this->current_page > 1) {
$firstPageUrl = $this->buildUrl(1);
$prevPageUrl = $this->buildUrl($this->current_page - 1);
$str .= '<li><a href="' . $prevPageUrl . '">&laquo;</a></li>';
}
else
{
} else {
$str .= '';
}
$a = $this->construct_num_Page();
for ($i = 0; $i < count($a); $i++)
{
for ($i = 0; $i < count($a); $i++) {
$s = $a[$i];
if ($s == $this->current_page)
{
if ($s == $this->current_page) {
$url = Typecho_Request::getInstance()->getRequestUrl();
$str .= '<li class="current"><a href="' . $url . '">' . $s . '</a></li>';
}
else
{
} else {
$url = $this->buildUrl($s);
$str .= '<li><a href="' . $url . '">' . $s . '</a></li>';
}
}
if ($this->current_page < $this->pageNums)
{
if ($this->current_page < $this->pageNums) {
$lastPageUrl = $this->buildUrl($this->pageNums);
$nextPageUrl = $this->buildUrl($this->current_page + 1);
$str .= '<li><a href="' . $nextPageUrl . '">&raquo;</a></li>';
}
else
{
} else {
$str .= '';
}
return $str;
@ -150,7 +118,11 @@ class Page
private function buildUrl($page)
{
$url = Typecho_Common::url('extending.php?' . http_build_query(array('panel' => Access_Plugin::$panel, 'action' => 'logs', 'page' => $page)), Typecho_Widget::widget('Widget_Options')->adminUrl);
$url = Typecho_Common::url('extending.php?' . http_build_query(array_merge($this->otherParams,
array(
'page' => $page,
))),
Typecho_Widget::widget('Widget_Options')->adminUrl);
return $url;
}

155
Access_Parser.php Normal file
View File

@ -0,0 +1,155 @@
<?php
if (!defined('__ACCESS_PLUGIN_ROOT__')) {
throw new Exception('Boostrap file not found');
}
class Access_Parser
{
public $bots = array(
'TencentTraveler',
'Baiduspider',
'BaiduGame',
'Googlebot',
'msnbot',
'Sosospider+',
'Sogou web spider',
'ia_archiver',
'Yahoo! Slurp',
'YoudaoBot',
'Yahoo Slurp',
'MSNBot',
'Java (Often spam bot)',
'BaiDuSpider',
'Voila',
'Yandex bot',
'BSpider',
'twiceler',
'Sogou Spider',
'Speedy Spider',
'Google AdSense',
'Heritrix',
'Python-urllib',
'Alexa (IA Archiver)',
'Ask',
'Exabot',
'Custo',
'OutfoxBot/YodaoBot',
'yacy',
'SurveyBot',
'legs',
'lwp-trivial',
'Nutch',
'StackRambler',
'The web archive (IA Archiver)',
'Perl tool',
'MJ12bot',
'Netcraft',
'MSIECrawler',
'WGet tools',
'larbin',
'Fish search',
'crawler',
'bingbot',
);
protected $currentBot = null;
public function getBrowser($ua)
{
$os = null;
if ($this->isBot($ua)) {
return $this->currentBot;
} elseif (preg_match('/Windows NT 6.0/i', $ua)) {
$os = 'Windows Vista';
} elseif (preg_match('/Windows NT 6.1/i', $ua)) {
$os = 'Windows 7';
} elseif (preg_match('/Windows NT 6.2/i', $ua)) {
$os = 'Windows 8';
} elseif (preg_match('/Windows NT 6.3/i', $ua)) {
$os = 'Windows 8.1';
} elseif (preg_match('/Windows NT 10.0/i', $ua)) {
$os = 'Windows 10';
} elseif (preg_match('/Windows NT 5.1/i', $ua)) {
$os = 'Windows XP';
} elseif (preg_match('/Windows NT 5.2/i', $ua) && preg_match('/Win64/i', $ua)) {
$os = 'Windows XP 64 bit';
} elseif (preg_match('/Android ([0-9.]+)/i', $ua, $matches)) {
$os = 'Android ' . $matches[1];
} elseif (preg_match('/iPhone OS ([_0-9]+)/i', $ua, $matches)) {
$os = 'iPhone ' . $matches[1];
} elseif (preg_match('/Ubuntu/i', $ua, $matches)) {
$os = 'Ubuntu ';
} elseif (preg_match('/Mac OS X ([0-9_]+)/i', $ua, $matches)) {
$os = 'Mac OS X ' . $matches[1];
} elseif (preg_match('/Linux/i', $ua, $matches)) {
$os = 'Linux';
} else {
$os = '未知';
}
if ($this->isBot($ua)) {
return $this->currentBot;
} elseif (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Camino ' . $matches[2];
} elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '搜狗浏览器 2' . $matches[1];
} elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '360浏览器 ' . $matches[1];
} elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Maxthon ' . $matches[2];
} elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Chrome ' . $matches[1];
} elseif (preg_match('#XiaoMi/MiuiBrowser/([0-9.]+)#i', $ua, $matches)) {
$browser = '小米浏览器 ' . $matches[1];
} elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Safari ' . $matches[1];
} elseif (preg_match('#opera mini#i', $ua)) {
preg_match('#Opera/([a-zA-Z0-9.]+)#i', $ua, $matches);
$browser = 'Opera Mini ' . $matches[1];
} elseif (preg_match('#Opera.([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Opera ' . $matches[1];
} elseif (preg_match('#TencentTraveler ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = '腾讯TT浏览器 ' . $matches[1];
} elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'UCWEB ' . $matches[1];
} elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Internet Explorer ' . $matches[1];
} elseif (preg_match('#Trident#', $ua, $matches)) {
$browser = 'Internet Explorer 11';
} elseif (preg_match('#Edge/12.0#i', $ua, $matches)) {
//win10中spartan浏览器
$browser = 'Spartan';
} elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$browser = 'Firefox ' . $matches[2];
} else {
$browser = '未知';
}
return $os . ' / ' . $browser;
}
public function isBot($ua)
{
$ua = $this->filter($ua);
if (!empty($ua)) {
foreach ($this->bots as $val) {
$str = $this->filter($val);
if (strpos($ua, $str) !== false) {
$this->currentBot = $str;
return true;
}
}
} else {
return false;
}
}
public function filter($str)
{
return $this->removeSpace(strtolower($str));
}
protected function removeSpace($str)
{
return preg_replace('/\s+/', '', $str);
}
}

View File

@ -4,7 +4,7 @@
*
* @package Access
* @author Kokororin
* @version 1.4
* @version 1.5
* @link https://kotori.love
*/
class Access_Plugin implements Typecho_Plugin_Interface
@ -16,7 +16,7 @@ class Access_Plugin implements Typecho_Plugin_Interface
Helper::addPanel(1, self::$panel, 'Access控制台', 'Access插件控制台', 'subscriber');
Helper::addRoute("access_ip", "/access/ip.json", "Access_Action", 'ip');
Helper::addRoute("access_delete_logs", "/access/log/delete", "Access_Action", 'deleteLogs');
Typecho_Plugin::factory('Widget_Archive')->header = array('Access_Plugin', 'start');
Typecho_Plugin::factory('Widget_Archive')->beforeRender = array('Access_Plugin', 'start');
Typecho_Plugin::factory('admin/footer.php')->end = array('Access_Plugin', 'adminFooter');
return _t($msg);
}
@ -95,6 +95,10 @@ class Access_Plugin implements Typecho_Plugin_Interface
if (('Mysql' == $type && $code == (1050 || '42S01'))) {
$script = 'SELECT * from `' . $prefix . 'access`';
$installDb->query($script, Typecho_Db::READ);
if (!array_key_exists('referer', $installDb->fetchRow($installDb->select()->from('table.access')))) {
$installDb->query('ALTER TABLE `' . $prefix . 'access` ADD `referer` varchar(255) NULL AFTER `ip`, ADD `referer_domain` varchar(100) NULL AFTER `referer`;');
return '数据表结构已更新,插件启用成功,' . $configLink;
}
return '数据表已存在,插件启用成功,' . $configLink;
} else {
throw new Typecho_Plugin_Exception('数据表建立失败,插件启用失败。错误号:' . $code);
@ -102,11 +106,11 @@ class Access_Plugin implements Typecho_Plugin_Interface
}
}
public static function start()
public static function start($archive)
{
require_once __DIR__ . '/Access.php';
$extend = new Access_Extend();
if ($extend->isAdmin()) {
require_once __DIR__ . '/Access_Bootstrap.php';
$access = new Access_Core();
if ($access->isAdmin()) {
return;
}
$config = Typecho_Widget::widget('Widget_Options')->plugin('Access');

View File

@ -10,6 +10,7 @@
* 查看来源页和来源域名排名
* 修复Referer记录错误的bug
* 添加删除日志的功能
* 修复旧版本升级错误的提示,自动更新数据表结构
### 使用须知

View File

@ -2,25 +2,25 @@
include_once 'common.php';
include 'header.php';
include 'menu.php';
require dirname(__FILE__) . '/../Access.php';
$extend = new Access_Extend();
require_once __DIR__ . '/../Access_Bootstrap.php';
$access = new Access_Core();
?>
<link rel="stylesheet" href="<?php $options->pluginUrl('Access/lib/sweetalert/sweetalert.css')?>">
<div class="main">
<div class="body container">
<div class="typecho-page-title">
<h2><?php echo $extend->title;?></h2>
<h2><?php echo $access->title;?></h2>
</div>
<div class="row typecho-page-main" role="main">
<div class="col-mb-12">
<ul class="typecho-option-tabs fix-tabs clearfix">
<li<?=($extend->action == 'overview' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=overview'); ?>"><?php _e('访问概览'); ?></a></li>
<li<?=($extend->action == 'logs' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=logs'); ?>"><?php _e('访问日志'); ?></a></li>
<li<?=($access->action == 'overview' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=overview'); ?>"><?php _e('访问概览'); ?></a></li>
<li<?=($access->action == 'logs' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=logs'); ?>"><?php _e('访问日志'); ?></a></li>
<li><a href="<?php $options->adminUrl('options-plugin.php?config=Access') ?>"><?php _e('插件设置'); ?></a></li>
</ul>
</div>
<?php if($extend->action == 'logs'):?>
<?php if($access->action == 'logs'):?>
<div class="col-mb-12 typecho-list">
<div class="typecho-list-operate clearfix">
@ -41,12 +41,11 @@ $extend = new Access_Extend();
<?php if(isset($request->page)): ?>
<input type="hidden" value="<?php echo $request->get('page'); ?>" name="page" />
<?php endif; ?>
<select name="type">
<select data-action="filter" name="type">
<option <?php if($request->type == 1): ?> selected="true"<?php endif; ?>value="1"><?php _e('默认(仅人类)'); ?></option>
<option <?php if($request->type == 2): ?> selected="true"<?php endif; ?>value="2"><?php _e('仅爬虫'); ?></option>
<option <?php if($request->type == 3): ?> selected="true"<?php endif; ?>value="3"><?php _e('所有'); ?></option>
</select>
<button type="submit" class="btn btn-s"><?php _e('筛选'); ?></button>
</div>
</form>
</div><!-- end .typecho-list-operate -->
@ -73,12 +72,12 @@ $extend = new Access_Extend();
</tr>
</thead>
<tbody>
<?php if(!empty($extend->logs['list'])): ?>
<?php foreach ($extend->logs['list'] as $log): ?>
<?php if(!empty($access->logs['list'])): ?>
<?php foreach ($access->logs['list'] as $log): ?>
<tr id="<?php echo $log['id']; ?>" data-id="<?php echo $log['id']; ?>">
<td><input type="checkbox" data-id="<?php echo $log['id']; ?>" value="<?php echo $log['id']; ?>" name="id[]"/></td>
<td><a target="_blank" href="<?php echo str_replace("%23", "#", $log['url']); ?>"><?php echo urldecode(str_replace("%23", "#", $log['url'])); ?></a></td>
<td><a data-action="ua" href="#" title="<?php echo $log['ua'];?>"><?php echo $extend->parseUA($log['ua']); ?></a></td>
<td><a data-action="ua" href="#" title="<?php echo $log['ua'];?>"><?php echo $access->parser->getBrowser($log['ua']); ?></a></td>
<td><a data-action="ip" data-ip="<?php echo $log['ip']; ?>" href="#"><?php echo $log['ip']; ?></a></td>
<td><a target="_blank" data-action="referer" href="<?php echo $log['referer']; ?>"><?php echo $log['referer']; ?></a></td>
<td><?php echo date('Y-m-d H:i:s',$log['date']); ?></td>
@ -108,16 +107,16 @@ $extend = new Access_Extend();
</div>
<?php if($extend->logs['rows'] > 1): ?>
<?php if($access->logs['rows'] > 1): ?>
<ul class="typecho-pager">
<?php echo $extend->logs['page']; ?>
<?php echo $access->logs['page']; ?>
</ul>
<?php endif; ?>
</form>
</div><!-- end .typecho-list-operate -->
</div><!-- end .typecho-list -->
<?php elseif($extend->action == 'overview'):?>
<?php elseif($access->action == 'overview'):?>
@ -144,21 +143,21 @@ $extend = new Access_Extend();
<tbody>
<tr>
<td>今日</td>
<td><?php echo $extend->overview['pv']['today']['total'];?></td>
<td><?php echo $extend->overview['uv']['today']['total'];?></td>
<td><?php echo $extend->overview['ip']['today']['total'];?></td>
<td><?php echo $access->overview['pv']['today']['total'];?></td>
<td><?php echo $access->overview['uv']['today']['total'];?></td>
<td><?php echo $access->overview['ip']['today']['total'];?></td>
</tr>
<tr>
<td>昨日</td>
<td><?php echo $extend->overview['pv']['yesterday']['total'];?></td>
<td><?php echo $extend->overview['uv']['yesterday']['total'];?></td>
<td><?php echo $extend->overview['ip']['yesterday']['total'];?></td>
<td><?php echo $access->overview['pv']['yesterday']['total'];?></td>
<td><?php echo $access->overview['uv']['yesterday']['total'];?></td>
<td><?php echo $access->overview['ip']['yesterday']['total'];?></td>
</tr>
<tr>
<td>总计</td>
<td><?php echo $extend->overview['pv']['all']['total'];?></td>
<td><?php echo $extend->overview['uv']['all']['total'];?></td>
<td><?php echo $extend->overview['ip']['all']['total'];?></td>
<td><?php echo $access->overview['pv']['all']['total'];?></td>
<td><?php echo $access->overview['uv']['all']['total'];?></td>
<td><?php echo $access->overview['ip']['all']['total'];?></td>
</tr>
</tbody>
</table>
@ -181,7 +180,7 @@ $extend = new Access_Extend();
</tr>
</thead>
<tbody>
<?php foreach ($extend->referer['domain'] as $key => $value):?>
<?php foreach ($access->referer['domain'] as $key => $value):?>
<tr>
<td><?php echo $key +1 ?></td>
<td><?php echo $value['count']?></td>
@ -209,7 +208,7 @@ $extend = new Access_Extend();
</tr>
</thead>
<tbody>
<?php foreach ($extend->referer['url'] as $key => $value):?>
<?php foreach ($access->referer['url'] as $key => $value):?>
<tr>
<td><?php echo $key +1 ?></td>
<td><?php echo $value['count']?></td>
@ -340,17 +339,21 @@ $(document).ready(function() {
var t = $(this);
t.parents('.dropdown-menu').hide().prev().removeClass('active');
});
$('form select[data-action="filter"]').change(function() {
$(this).parents('form').submit();
});
});
</script>
<script src="<?php $options->pluginUrl('Access/lib/sweetalert/sweetalert.min.js')?>"></script>
<?php if($extend->action == 'overview'):?>
<?php if($access->action == 'overview'):?>
<script src="<?php $options->pluginUrl('Access/lib/highcharts/js/highcharts.js')?>"></script>
<script src="<?php $options->pluginUrl('Access/lib/highcharts/js/modules/exporting.js')?>"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#chart').highcharts({
title: {
text: '<?php echo $extend->overview['chart']['title']['text'];?>',
text: '<?php echo $access->overview['chart']['title']['text'];?>',
x: -20 //center
},
subtitle: {
@ -358,7 +361,7 @@ $(document).ready(function() {
x: -20
},
xAxis: {
categories: <?php echo $extend->overview['chart']['xAxis']['categories'];?>
categories: <?php echo $access->overview['chart']['xAxis']['categories'];?>
},
yAxis: {
title: {
@ -373,28 +376,30 @@ $(document).ready(function() {
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
}
},
series: [{
name: 'PV',
data: <?php echo $extend->overview['chart']['series']['pv'];?>
data: <?php echo $access->overview['chart']['series']['pv'];?>
}, {
name: 'UV',
data: <?php echo $extend->overview['chart']['series']['uv'];?>
data: <?php echo $access->overview['chart']['series']['uv'];?>
}, {
name: 'IP',
data: <?php echo $extend->overview['chart']['series']['ip'];?>
data: <?php echo $access->overview['chart']['series']['ip'];?>
}]
});
});
</script>
<?php endif;?>
<?php if (Typecho_Widget::widget('Widget_Options')->plugin('Access') == 1):?>
<?php if ($access->config->cancanAnalytize == 1):?>
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);