简化一些代码

This commit is contained in:
kokororin 2018-01-26 17:20:26 +08:00
parent 7adc9de42c
commit dd3ee029c7
2 changed files with 7 additions and 13 deletions

View File

@ -231,11 +231,9 @@ class Access_Core
->from('table.access_log'))[0]['count'];
# 分类型绘制24小时访问图
$this->overview['chart']['xAxis']['categories'] = json_encode(array(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
));
$this->overview['chart']['xAxis']['categories'] = Json::encode(range(0, 23));
foreach (array('ip', 'uv', 'pv') as $type) {
$this->overview['chart']['series'][$type] = json_encode($this->overview[$type]['today']['hours']);
$this->overview['chart']['series'][$type] = Json::encode($this->overview[$type]['today']['hours']);
}
$this->overview['chart']['title']['text'] = _t('%s 统计', date("Y-m-d"));
}

View File

@ -1,17 +1,14 @@
<?php
require_once __DIR__ . '/Access_Bootstrap.php';
class Access_Action implements Widget_Interface_Do
class Access_Action extends Typecho_Widget implements Widget_Interface_Do
{
private $response;
private $request;
private $access;
public function __construct()
public function __construct($request, $response, $params = null)
{
$this->response = Typecho_Response::getInstance();
$this->request = Typecho_Request::getInstance();
parent::__construct($request, $response, $params);
$this->access = new Access_Core();
}
@ -33,7 +30,6 @@ class Access_Action implements Widget_Interface_Do
public function ip()
{
$this->response->setContentType('application/json');
$ip = $this->request->get('ip');
try {
$this->checkAuth();
@ -64,7 +60,7 @@ class Access_Action implements Widget_Interface_Do
);
}
}
exit(Json::encode($response));
$this->response->throwJson($response);
}
public function deleteLogs()