1、内核更新
2、后台bug修复(获取参数的bug)
This commit is contained in:
@@ -63,7 +63,7 @@ class Ad extends Admin {
|
|||||||
public function edit($id = null){
|
public function edit($id = null){
|
||||||
$place = model('AdPlace');
|
$place = model('AdPlace');
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$data = input('post.','');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = $place->save($data,array('id'=>$data['id']));
|
$result = $place->save($data,array('id'=>$data['id']));
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -122,7 +122,7 @@ class Ad extends Admin {
|
|||||||
public function addad($id){
|
public function addad($id){
|
||||||
$ad = model('ad');
|
$ad = model('ad');
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = $ad->save($data);
|
$result = $ad->save($data);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -148,7 +148,7 @@ class Ad extends Admin {
|
|||||||
public function editad($id = null){
|
public function editad($id = null){
|
||||||
$ad = model('ad');
|
$ad = model('ad');
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = $ad->save($data,array('id'=>$data['id']));
|
$result = $ad->save($data,array('id'=>$data['id']));
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Attribute extends Admin {
|
|||||||
* @author colin <colin@tensent.cn>
|
* @author colin <colin@tensent.cn>
|
||||||
*/
|
*/
|
||||||
public function add(){
|
public function add(){
|
||||||
$model_id = input('get.model_id','','trim,intval');
|
$model_id = input('model_id','','trim,intval');
|
||||||
if(IS_POST){
|
if(IS_POST){
|
||||||
$result = $this->model->change();
|
$result = $this->model->change();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -104,7 +104,7 @@ class Attribute extends Admin {
|
|||||||
return $this->error($this->model->getError(),'');
|
return $this->error($this->model->getError(),'');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$id = input('get.id','','trim,intval');
|
$id = input('id','','trim,intval');
|
||||||
$info = db('Attribute')->find($id);
|
$info = db('Attribute')->find($id);
|
||||||
$data = array(
|
$data = array(
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Channel extends Admin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index(){
|
public function index(){
|
||||||
$pid = input('get.pid', 0);
|
$pid = input('pid', 0);
|
||||||
/* 获取频道列表 */
|
/* 获取频道列表 */
|
||||||
//$map = array('status' => array('gt', -1), 'pid'=>$pid);
|
//$map = array('status' => array('gt', -1), 'pid'=>$pid);
|
||||||
$map = array('status' => array('gt', -1));
|
$map = array('status' => array('gt', -1));
|
||||||
@@ -50,7 +50,7 @@ class Channel extends Admin{
|
|||||||
public function add() {
|
public function add() {
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$Channel = model('Channel');
|
$Channel = model('Channel');
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$id = $Channel->save($data);
|
$id = $Channel->save($data);
|
||||||
if ($id) {
|
if ($id) {
|
||||||
@@ -64,7 +64,7 @@ class Channel extends Admin{
|
|||||||
$this->error($Channel->getError());
|
$this->error($Channel->getError());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pid = input('get.pid', 0);
|
$pid = input('pid', 0);
|
||||||
//获取父导航
|
//获取父导航
|
||||||
if (!empty($pid)) {
|
if (!empty($pid)) {
|
||||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||||
@@ -86,7 +86,7 @@ class Channel extends Admin{
|
|||||||
public function edit($id = 0) {
|
public function edit($id = 0) {
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$Channel = model('Channel');
|
$Channel = model('Channel');
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
if (false !== $Channel->save($data,array('id'=>$data['id']))) {
|
if (false !== $Channel->save($data,array('id'=>$data['id']))) {
|
||||||
//记录行为
|
//记录行为
|
||||||
@@ -107,7 +107,7 @@ class Channel extends Admin{
|
|||||||
return $this->error('获取配置信息错误');
|
return $this->error('获取配置信息错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pid = input('get.pid', 0);
|
$pid = input('pid', 0);
|
||||||
//获取父导航
|
//获取父导航
|
||||||
if (!empty($pid)) {
|
if (!empty($pid)) {
|
||||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||||
@@ -148,8 +148,8 @@ class Channel extends Admin{
|
|||||||
*/
|
*/
|
||||||
public function sort() {
|
public function sort() {
|
||||||
if (IS_GET) {
|
if (IS_GET) {
|
||||||
$ids = input('get.ids');
|
$ids = input('ids');
|
||||||
$pid = input('get.pid');
|
$pid = input('pid');
|
||||||
//获取排序的数据
|
//获取排序的数据
|
||||||
$map = array('status' => array('gt', -1));
|
$map = array('status' => array('gt', -1));
|
||||||
if (!empty($ids)) {
|
if (!empty($ids)) {
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ class Config extends Admin{
|
|||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$Config = model('Config');
|
$config = model('Config');
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$id = $Config->validate(true)->save($data);
|
$id = $config->validate(true)->save($data);
|
||||||
if ($id) {
|
if ($id) {
|
||||||
cache('db_config_data', null);
|
cache('db_config_data', null);
|
||||||
//记录行为
|
//记录行为
|
||||||
@@ -92,7 +92,7 @@ class Config extends Admin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $this->error($Config->getError());
|
return $this->error($config->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -109,20 +109,20 @@ class Config extends Admin{
|
|||||||
*/
|
*/
|
||||||
public function edit($id = 0) {
|
public function edit($id = 0) {
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$Config = model('Config');
|
$config = model('Config');
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = $Config->validate('Config.edit')->save($data,array('id'=>$data['id']));
|
$result = $config->validate('Config.edit')->save($data,array('id'=>$data['id']));
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
cache('db_config_data', null);
|
cache('db_config_data', null);
|
||||||
//记录行为
|
//记录行为
|
||||||
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
|
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
|
||||||
return $this->success('更新成功', Cookie('__forward__'));
|
return $this->success('更新成功', Cookie('__forward__'));
|
||||||
} else {
|
} else {
|
||||||
return $this->error($Config->getError(), '');
|
return $this->error($config->getError(), '');
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
return $this->error($Config->getError());
|
return $this->error($config->getError());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$info = array();
|
$info = array();
|
||||||
@@ -181,7 +181,7 @@ class Config extends Admin{
|
|||||||
*/
|
*/
|
||||||
public function sort() {
|
public function sort() {
|
||||||
if (IS_GET) {
|
if (IS_GET) {
|
||||||
$ids = input('get.ids');
|
$ids = input('ids');
|
||||||
//获取排序的数据
|
//获取排序的数据
|
||||||
$map = array('status' => array('gt', -1));
|
$map = array('status' => array('gt', -1));
|
||||||
if (!empty($ids)) {
|
if (!empty($ids)) {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class Content extends Admin{
|
|||||||
* @author molong <ycgpp@126.com>
|
* @author molong <ycgpp@126.com>
|
||||||
*/
|
*/
|
||||||
public function del(){
|
public function del(){
|
||||||
$id = input('get.id','','trim');
|
$id = input('id','','trim');
|
||||||
$ids = input('post.ids',array());
|
$ids = input('post.ids',array());
|
||||||
array_push($ids, $id);
|
array_push($ids, $id);
|
||||||
if (empty($ids)) {
|
if (empty($ids)) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Link extends Admin{
|
|||||||
//修改
|
//修改
|
||||||
public function edit(){
|
public function edit(){
|
||||||
$link = model('Link');
|
$link = model('Link');
|
||||||
$id = input('get.id','','trim,intval');
|
$id = input('id','','trim,intval');
|
||||||
if(IS_POST){
|
if(IS_POST){
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
if ($data) {
|
if ($data) {
|
||||||
|
|||||||
@@ -226,8 +226,8 @@ class Menu extends Admin{
|
|||||||
*/
|
*/
|
||||||
public function sort(){
|
public function sort(){
|
||||||
if(IS_GET){
|
if(IS_GET){
|
||||||
$ids = input('get.ids');
|
$ids = input('ids');
|
||||||
$pid = input('get.pid');
|
$pid = input('pid');
|
||||||
|
|
||||||
//获取排序的数据
|
//获取排序的数据
|
||||||
$map = array('status'=>array('gt',-1));
|
$map = array('status'=>array('gt',-1));
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class Model extends Admin{
|
|||||||
* @author colin <colin@tensent.cn>
|
* @author colin <colin@tensent.cn>
|
||||||
*/
|
*/
|
||||||
public function status(){
|
public function status(){
|
||||||
$map['id'] = input('post.ids/a') ? input('post.ids/a') : input('get.ids/a');
|
$map['id'] = $this->request->param('ids');
|
||||||
if(null == $map['id'])return $this->error('参数不正确!');
|
if(null == $map['id'])return $this->error('参数不正确!');
|
||||||
|
|
||||||
$data['status'] = input('get.status');
|
$data['status'] = input('get.status');
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Seo extends Admin{
|
|||||||
|
|
||||||
public function add(){
|
public function add(){
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = model('SeoRule')->save($data);
|
$result = model('SeoRule')->save($data);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -72,7 +72,7 @@ class Seo extends Admin{
|
|||||||
|
|
||||||
public function edit($id = null){
|
public function edit($id = null){
|
||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$data = input('post.');
|
$data = $this->request->post();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$result = model('SeoRule')->save($data,array('id'=>$data['id']));
|
$result = model('SeoRule')->save($data,array('id'=>$data['id']));
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class User extends Admin{
|
|||||||
*/
|
*/
|
||||||
private function getUserinfo($uid = null,$pass = null,$errormsg = null){
|
private function getUserinfo($uid = null,$pass = null,$errormsg = null){
|
||||||
$user = model('User');
|
$user = model('User');
|
||||||
$uid = $uid ? $uid : input('get.id');
|
$uid = $uid ? $uid : input('id');
|
||||||
//如果无UID则修改当前用户
|
//如果无UID则修改当前用户
|
||||||
$uid = $uid ? $uid : session('user_auth.uid');
|
$uid = $uid ? $uid : session('user_auth.uid');
|
||||||
$map['uid'] = $uid;
|
$map['uid'] = $uid;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ return [
|
|||||||
'app_namespace' => 'app',
|
'app_namespace' => 'app',
|
||||||
// 应用调试模式
|
// 应用调试模式
|
||||||
'app_debug' => true,
|
'app_debug' => true,
|
||||||
|
// 应用Trace
|
||||||
|
'app_trace' => false,
|
||||||
// 应用模式状态
|
// 应用模式状态
|
||||||
'app_status' => '',
|
'app_status' => '',
|
||||||
// 是否支持多模块
|
// 是否支持多模块
|
||||||
@@ -95,7 +97,7 @@ return [
|
|||||||
'var_method' => '_method',
|
'var_method' => '_method',
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 模板引擎设置
|
// | 模板设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'template' => [
|
'template' => [
|
||||||
@@ -134,24 +136,26 @@ return [
|
|||||||
'error_message' => '页面错误!请稍后再试~',
|
'error_message' => '页面错误!请稍后再试~',
|
||||||
// 显示错误信息
|
// 显示错误信息
|
||||||
'show_error_msg' => false,
|
'show_error_msg' => false,
|
||||||
|
// 异常处理handle类 留空使用 \think\exception\Handle
|
||||||
|
'exception_handle' => '',
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 日志设置
|
// | 日志设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'log' => [
|
'log' => [
|
||||||
// 日志记录方式,支持 file sae
|
// 日志记录方式,内置 file sae 支持扩展
|
||||||
'type' => 'File',
|
'type' => 'File',
|
||||||
// 日志保存目录
|
// 日志保存目录
|
||||||
'path' => LOG_PATH,
|
'path' => LOG_PATH,
|
||||||
],
|
],
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Trace设置
|
// | Trace设置 开启 app_trace 后 有效
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
'trace' => [
|
'trace' => [
|
||||||
// 支持Html Socket Console 设为false则不显示
|
// 内置Html Socket Console 支持扩展
|
||||||
'type' => false,
|
'type' => 'Html',
|
||||||
],
|
],
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
@@ -245,6 +249,7 @@ return [
|
|||||||
// 自动写入时间戳字段
|
// 自动写入时间戳字段
|
||||||
'auto_timestamp' => false,
|
'auto_timestamp' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
//分页配置
|
//分页配置
|
||||||
'paginate' => [
|
'paginate' => [
|
||||||
'type' => 'bootstrap',
|
'type' => 'bootstrap',
|
||||||
|
|||||||
@@ -207,6 +207,6 @@ class Database{
|
|||||||
* 析构方法,用于关闭文件资源
|
* 析构方法,用于关闭文件资源
|
||||||
*/
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
|
//$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,9 @@ class App
|
|||||||
Hook::listen('app_end', $response);
|
Hook::listen('app_end', $response);
|
||||||
|
|
||||||
// Trace调试注入
|
// Trace调试注入
|
||||||
Debug::inject($response);
|
if (Config::get('app_trace')) {
|
||||||
|
Debug::inject($response);
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class Cookie
|
|||||||
array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
|
array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
|
||||||
$value = 'think:' . json_encode($value);
|
$value = 'think:' . json_encode($value);
|
||||||
}
|
}
|
||||||
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
|
$expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0;
|
||||||
if ($config['setcookie']) {
|
if ($config['setcookie']) {
|
||||||
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ class Cookie
|
|||||||
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
||||||
$name = $prefix . $name;
|
$name = $prefix . $name;
|
||||||
if ($config['setcookie']) {
|
if ($config['setcookie']) {
|
||||||
setcookie($name, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
setcookie($name, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||||
}
|
}
|
||||||
// 删除指定cookie
|
// 删除指定cookie
|
||||||
unset($_COOKIE[$name]);
|
unset($_COOKIE[$name]);
|
||||||
@@ -169,7 +169,7 @@ class Cookie
|
|||||||
foreach ($_COOKIE as $key => $val) {
|
foreach ($_COOKIE as $key => $val) {
|
||||||
if (0 === strpos($key, $prefix)) {
|
if (0 === strpos($key, $prefix)) {
|
||||||
if ($config['setcookie']) {
|
if ($config['setcookie']) {
|
||||||
setcookie($key, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
setcookie($key, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||||
}
|
}
|
||||||
unset($_COOKIE[$key]);
|
unset($_COOKIE[$key]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,40 +186,33 @@ class Debug
|
|||||||
|
|
||||||
public static function inject(Response $response)
|
public static function inject(Response $response)
|
||||||
{
|
{
|
||||||
$config = Config::get('trace');
|
$config = Config::get('trace');
|
||||||
$type = isset($config['type']) ? $config['type'] : 'Html';
|
$type = isset($config['type']) ? $config['type'] : 'Html';
|
||||||
|
$request = Request::instance();
|
||||||
|
$accept = $request->header('accept');
|
||||||
|
$contentType = $response->getHeader('Content-Type');
|
||||||
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\' . ucwords($type);
|
||||||
|
unset($config['type']);
|
||||||
|
if (class_exists($class)) {
|
||||||
|
$trace = new $class($config);
|
||||||
|
} else {
|
||||||
|
throw new ClassNotFoundException('class not exists:' . $class, $class);
|
||||||
|
}
|
||||||
|
|
||||||
if (false !== $type) {
|
if ($response instanceof Redirect) {
|
||||||
$request = Request::instance();
|
//TODO 记录
|
||||||
$accept = $request->header('accept');
|
} else {
|
||||||
$contentType = $response->getHeader('Content-Type');
|
$output = $trace->output($response, Log::getLog());
|
||||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\' . ucwords($type);
|
if (is_string($output)) {
|
||||||
unset($config['type']);
|
// trace调试信息注入
|
||||||
if (class_exists($class)) {
|
$content = $response->getContent();
|
||||||
$trace = new $class($config);
|
$pos = strripos($content, '</body>');
|
||||||
} else {
|
if (false !== $pos) {
|
||||||
throw new ClassNotFoundException('class not exists:' . $class, $class);
|
$content = substr($content, 0, $pos) . $output . substr($content, $pos);
|
||||||
}
|
} else {
|
||||||
|
$content = $content . $output;
|
||||||
if ($response instanceof Redirect) {
|
|
||||||
//TODO 记录
|
|
||||||
} elseif (strpos($accept, 'application/json') === 0 || $request->isAjax()) {
|
|
||||||
//TODO 记录
|
|
||||||
} elseif (!empty($contentType) && strpos($contentType, 'html') === false) {
|
|
||||||
//TODO 记录
|
|
||||||
} else {
|
|
||||||
$output = $trace->output(Log::getLog());
|
|
||||||
if (is_string($output)) {
|
|
||||||
// trace调试信息注入
|
|
||||||
$content = $response->getContent();
|
|
||||||
$pos = strripos($content, '</body>');
|
|
||||||
if (false !== $pos) {
|
|
||||||
$content = substr($content, 0, $pos) . $output . substr($content, $pos);
|
|
||||||
} else {
|
|
||||||
$content = $content . $output;
|
|
||||||
}
|
|
||||||
$response->content($content);
|
|
||||||
}
|
}
|
||||||
|
$response->content($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class Error
|
|||||||
if (error_reporting() & $errno) {
|
if (error_reporting() & $errno) {
|
||||||
// 将错误信息托管至 think\exception\ErrorException
|
// 将错误信息托管至 think\exception\ErrorException
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}else{
|
} else {
|
||||||
self::getExceptionHandler()->report($exception);
|
self::getExceptionHandler()->report($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,24 +98,20 @@ class Error
|
|||||||
/**
|
/**
|
||||||
* Get an instance of the exception handler.
|
* Get an instance of the exception handler.
|
||||||
*
|
*
|
||||||
* @return \think\exception\Handle
|
* @return Handle
|
||||||
*/
|
*/
|
||||||
public static function getExceptionHandler()
|
public static function getExceptionHandler()
|
||||||
{
|
{
|
||||||
static $handle;
|
static $handle;
|
||||||
|
|
||||||
if (!$handle) {
|
if (!$handle) {
|
||||||
|
// 异常处理handle
|
||||||
if ($class = Config::get('exception_handle')) {
|
$class = Config::get('exception_handle');
|
||||||
if (class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) {
|
if ($class && class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) {
|
||||||
$handle = new $class;
|
$handle = new $class;
|
||||||
}
|
} else {
|
||||||
}
|
$handle = new Handle;
|
||||||
if (!$handle) {
|
|
||||||
$handle = new Handle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $handle;
|
return $handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
use think\exception\ClassNotFoundException;
|
use think\exception\ClassNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Log
|
* Class Log
|
||||||
* @package think
|
* @package think
|
||||||
*
|
*
|
||||||
* @method void log($msg) static
|
* @method void log($msg) static
|
||||||
* @method void error($msg) static
|
* @method void error($msg) static
|
||||||
* @method void info($msg) static
|
* @method void info($msg) static
|
||||||
@@ -48,13 +49,13 @@ class Log
|
|||||||
* 日志初始化
|
* 日志初始化
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public static function init($config = [])
|
public static function init($config = [])
|
||||||
{
|
{
|
||||||
$type = isset($config['type']) ? $config['type'] : 'File';
|
$type = isset($config['type']) ? $config['type'] : 'File';
|
||||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
||||||
self::$config = $config;
|
self::$config = $config;
|
||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
if(class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
self::$driver = new $class($config);
|
self::$driver = new $class($config);
|
||||||
} else {
|
} else {
|
||||||
throw new ClassNotFoundException('class not exists:' . $class, $class);
|
throw new ClassNotFoundException('class not exists:' . $class, $class);
|
||||||
@@ -62,7 +63,7 @@ class Log
|
|||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
App::$debug && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
|
App::$debug && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取日志信息
|
* 获取日志信息
|
||||||
* @param string $type 信息类型
|
* @param string $type 信息类型
|
||||||
@@ -110,7 +111,6 @@ class Log
|
|||||||
*/
|
*/
|
||||||
public static function check($config)
|
public static function check($config)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (self::$key && !empty($config['allow_key']) && !in_array(self::$key, $config['allow_key'])) {
|
if (self::$key && !empty($config['allow_key']) && !in_array(self::$key, $config['allow_key'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,10 @@ class Url
|
|||||||
// 生成路由映射并缓存
|
// 生成路由映射并缓存
|
||||||
private static function getRouteAlias()
|
private static function getRouteAlias()
|
||||||
{
|
{
|
||||||
|
static $item = [];
|
||||||
|
if (!empty($item)) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
if ($item = Cache::get('think_route_map')) {
|
if ($item = Cache::get('think_route_map')) {
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|||||||
2
core/library/think/cache/driver/File.php
vendored
2
core/library/think/cache/driver/File.php
vendored
@@ -101,7 +101,7 @@ class File
|
|||||||
$content = file_get_contents($filename);
|
$content = file_get_contents($filename);
|
||||||
if (false !== $content) {
|
if (false !== $content) {
|
||||||
$expire = (int) substr($content, 8, 12);
|
$expire = (int) substr($content, 8, 12);
|
||||||
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire) {
|
||||||
//缓存过期删除缓存文件
|
//缓存过期删除缓存文件
|
||||||
$this->unlink($filename);
|
$this->unlink($filename);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
4
core/library/think/cache/driver/Lite.php
vendored
4
core/library/think/cache/driver/Lite.php
vendored
@@ -65,7 +65,7 @@ class Lite
|
|||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
// 判断是否过期
|
// 判断是否过期
|
||||||
$mtime = filemtime($filename);
|
$mtime = filemtime($filename);
|
||||||
if ($mtime < time()) {
|
if ($mtime < $_SERVER['REQUEST_TIME']) {
|
||||||
// 清除已经过期的文件
|
// 清除已经过期的文件
|
||||||
unlink($filename);
|
unlink($filename);
|
||||||
return false;
|
return false;
|
||||||
@@ -97,7 +97,7 @@ class Lite
|
|||||||
$ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
|
$ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
|
||||||
// 通过设置修改时间实现有效期
|
// 通过设置修改时间实现有效期
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
touch($filename, time() + $expire);
|
touch($filename, $_SERVER['REQUEST_TIME'] + $expire);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class Memcached
|
|||||||
'expire' => 0,
|
'expire' => 0,
|
||||||
'timeout' => 0, // 超时时间(单位:毫秒)
|
'timeout' => 0, // 超时时间(单位:毫秒)
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
|
'username' => '', //账号
|
||||||
|
'password' => '', //密码
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +57,10 @@ class Memcached
|
|||||||
$servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
|
$servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
|
||||||
}
|
}
|
||||||
$this->handler->addServers($servers);
|
$this->handler->addServers($servers);
|
||||||
|
if('' != $this->options['username']){
|
||||||
|
$this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
|
||||||
|
$this->handler->setSaslAuthData($this->options['username'], $this->options['password']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +88,7 @@ class Memcached
|
|||||||
$expire = $this->options['expire'];
|
$expire = $this->options['expire'];
|
||||||
}
|
}
|
||||||
$name = $this->options['prefix'] . $name;
|
$name = $this->options['prefix'] . $name;
|
||||||
$expire = 0 == $expire ? 0 : time() + $expire;
|
$expire = 0 == $expire ? 0 : $_SERVER['REQUEST_TIME'] + $expire;
|
||||||
if ($this->handler->set($name, $value, $expire)) {
|
if ($this->handler->set($name, $value, $expire)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
4
core/library/think/cache/driver/Sqlite.php
vendored
4
core/library/think/cache/driver/Sqlite.php
vendored
@@ -56,7 +56,7 @@ class Sqlite implements CacheInterface
|
|||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
$name = $this->options['prefix'] . sqlite_escape_string($name);
|
$name = $this->options['prefix'] . sqlite_escape_string($name);
|
||||||
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1';
|
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . $_SERVER['REQUEST_TIME'] . ') LIMIT 1';
|
||||||
$result = sqlite_query($this->handler, $sql);
|
$result = sqlite_query($this->handler, $sql);
|
||||||
if (sqlite_num_rows($result)) {
|
if (sqlite_num_rows($result)) {
|
||||||
$content = sqlite_fetch_single($result);
|
$content = sqlite_fetch_single($result);
|
||||||
@@ -84,7 +84,7 @@ class Sqlite implements CacheInterface
|
|||||||
if (is_null($expire)) {
|
if (is_null($expire)) {
|
||||||
$expire = $this->options['expire'];
|
$expire = $this->options['expire'];
|
||||||
}
|
}
|
||||||
$expire = (0 == $expire) ? 0 : (time() + $expire); //缓存有效期为0表示永久缓存
|
$expire = (0 == $expire) ? 0 : ($_SERVER['REQUEST_TIME'] + $expire); //缓存有效期为0表示永久缓存
|
||||||
if (function_exists('gzcompress')) {
|
if (function_exists('gzcompress')) {
|
||||||
//数据压缩
|
//数据压缩
|
||||||
$value = gzcompress($value, 3);
|
$value = gzcompress($value, 3);
|
||||||
|
|||||||
@@ -390,7 +390,11 @@ class Query
|
|||||||
if (isset($this->options['field'])) {
|
if (isset($this->options['field'])) {
|
||||||
unset($this->options['field']);
|
unset($this->options['field']);
|
||||||
}
|
}
|
||||||
$pdo = $this->field($field)->fetchPdo(true)->find();
|
$pdo = $this->field($field)->fetchPdo(true)->find();
|
||||||
|
if (is_string($pdo)) {
|
||||||
|
// 返回SQL语句
|
||||||
|
return $pdo;
|
||||||
|
}
|
||||||
$result = $pdo->fetchColumn();
|
$result = $pdo->fetchColumn();
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
// 缓存数据
|
// 缓存数据
|
||||||
@@ -430,6 +434,10 @@ class Query
|
|||||||
$field = $key . ',' . $field;
|
$field = $key . ',' . $field;
|
||||||
}
|
}
|
||||||
$pdo = $this->field($field)->fetchPdo(true)->select();
|
$pdo = $this->field($field)->fetchPdo(true)->select();
|
||||||
|
if (is_string($pdo)) {
|
||||||
|
// 返回SQL语句
|
||||||
|
return $pdo;
|
||||||
|
}
|
||||||
if (1 == $pdo->columnCount()) {
|
if (1 == $pdo->columnCount()) {
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_COLUMN);
|
$result = $pdo->fetchAll(PDO::FETCH_COLUMN);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ use think\Cache;
|
|||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Debug;
|
use think\Debug;
|
||||||
|
use think\Request;
|
||||||
|
use think\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浏览器调试输出
|
* 浏览器调试输出
|
||||||
@@ -36,11 +38,20 @@ class Console
|
|||||||
/**
|
/**
|
||||||
* 调试输出接口
|
* 调试输出接口
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $log 日志信息
|
* @param Response $response Response对象
|
||||||
|
* @param array $log 日志信息
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function output(array $log = [])
|
public function output(Response $response, array $log = [])
|
||||||
{
|
{
|
||||||
|
$request = Request::instance();
|
||||||
|
$contentType = $response->getHeader('Content-Type');
|
||||||
|
$accept = $request->header('accept');
|
||||||
|
if (strpos($accept, 'application/json') === 0 || $request->isAjax()) {
|
||||||
|
return false;
|
||||||
|
} elseif (!empty($contentType) && strpos($contentType, 'html') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 获取基本信息
|
// 获取基本信息
|
||||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||||
$reqs = number_format(1 / $runtime, 2);
|
$reqs = number_format(1 / $runtime, 2);
|
||||||
@@ -49,13 +60,13 @@ class Console
|
|||||||
if (isset($_SERVER['HTTP_HOST'])) {
|
if (isset($_SERVER['HTTP_HOST'])) {
|
||||||
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
} else {
|
} else {
|
||||||
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
|
$uri = 'cmd:' . implode(' ', $_SERVER['argv']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面Trace信息
|
// 页面Trace信息
|
||||||
$base = [
|
$base = [
|
||||||
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
|
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
|
||||||
'运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()),
|
'运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()),
|
||||||
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
|
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
|
||||||
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
|
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
|
||||||
'配置加载' => count(Config::get()),
|
'配置加载' => count(Config::get()),
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ use think\Cache;
|
|||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Debug;
|
use think\Debug;
|
||||||
|
use think\Request;
|
||||||
|
use think\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面Trace调试
|
* 页面Trace调试
|
||||||
@@ -36,12 +38,20 @@ class Html
|
|||||||
/**
|
/**
|
||||||
* 调试输出接口
|
* 调试输出接口
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $log 日志信息
|
* @param Response $response Response对象
|
||||||
|
* @param array $log 日志信息
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function output(array $log = [])
|
public function output(Response $response, array $log = [])
|
||||||
{
|
{
|
||||||
|
$request = Request::instance();
|
||||||
|
$contentType = $response->getHeader('Content-Type');
|
||||||
|
$accept = $request->header('accept');
|
||||||
|
if (strpos($accept, 'application/json') === 0 || $request->isAjax()) {
|
||||||
|
return false;
|
||||||
|
} elseif (!empty($contentType) && strpos($contentType, 'html') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 获取基本信息
|
// 获取基本信息
|
||||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||||
$reqs = number_format(1 / $runtime, 2);
|
$reqs = number_format(1 / $runtime, 2);
|
||||||
@@ -51,11 +61,11 @@ class Html
|
|||||||
if (isset($_SERVER['HTTP_HOST'])) {
|
if (isset($_SERVER['HTTP_HOST'])) {
|
||||||
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
} else {
|
} else {
|
||||||
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
|
$uri = 'cmd:' . implode(' ', $_SERVER['argv']);
|
||||||
}
|
}
|
||||||
$base = [
|
$base = [
|
||||||
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
|
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
|
||||||
'运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()),
|
'运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()),
|
||||||
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
|
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
|
||||||
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
|
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
|
||||||
'配置加载' => count(Config::get()),
|
'配置加载' => count(Config::get()),
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think\debug;
|
namespace think\debug;
|
||||||
|
|
||||||
|
use think\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* github: https://github.com/luofei614/SocketLog
|
* github: https://github.com/luofei614/SocketLog
|
||||||
* @author luofei614<weibo.com/luofei614>
|
* @author luofei614<weibo.com/luofei614>
|
||||||
@@ -20,24 +22,22 @@ class Socket
|
|||||||
public $port = 1116; //SocketLog 服务的http的端口号
|
public $port = 1116; //SocketLog 服务的http的端口号
|
||||||
|
|
||||||
protected $config = [
|
protected $config = [
|
||||||
'enable' => true, //是否记录日志的开关
|
// socket服务器地址
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
//是否显示利于优化的参数,如果允许时间,消耗内存等
|
// 是否显示加载的文件列表
|
||||||
'optimize' => false,
|
|
||||||
'show_included_files' => false,
|
'show_included_files' => false,
|
||||||
'error_handler' => false,
|
// 日志强制记录到配置的client_id
|
||||||
//日志强制记录到配置的client_id
|
|
||||||
'force_client_ids' => [],
|
'force_client_ids' => [],
|
||||||
//限制允许读取日志的client_id
|
// 限制允许读取日志的client_id
|
||||||
'allow_client_ids' => [],
|
'allow_client_ids' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $css = [
|
protected $css = [
|
||||||
'sql' => 'color:#009bb4;',
|
'sql' => 'color:#009bb4;',
|
||||||
'sql_warn' => 'color:#009bb4;font-size:14px;',
|
'sql_warn' => 'color:#009bb4;font-size:14px;',
|
||||||
'error_handler' => 'color:#f4006b;font-size:14px;',
|
'error' => 'color:#f4006b;font-size:14px;',
|
||||||
'page' => 'color:#40e2ff;background:#171717;',
|
'page' => 'color:#40e2ff;background:#171717;',
|
||||||
'big' => 'font-size:20px;color:red;',
|
'big' => 'font-size:20px;color:red;',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowForceClientIds = []; //配置强制推送且被授权的client_id
|
protected $allowForceClientIds = []; //配置强制推送且被授权的client_id
|
||||||
@@ -57,25 +57,26 @@ class Socket
|
|||||||
/**
|
/**
|
||||||
* 调试输出接口
|
* 调试输出接口
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $logs 日志信息
|
* @param Response $response Response对象
|
||||||
|
* @param array $log 日志信息
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function output(array $logs = [])
|
public function output(Response $response, array $log = [])
|
||||||
{
|
{
|
||||||
if (!$this->check()) {
|
if (!$this->check()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||||
$reqs = number_format(1 / number_format($runtime, 8), 2);
|
$reqs = number_format(1 / number_format($runtime, 8), 2);
|
||||||
$time_str = " [运行时间:{$runtime}s][吞吐率:{$reqs}req/s]";
|
$time_str = ' [运行时间:' . number_format($runtime, 6) . 's][吞吐率:' . $reqs . 'req/s]';
|
||||||
$memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
$memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||||
$memory_str = " [内存消耗:{$memory_use}kb]";
|
$memory_str = ' [内存消耗:' . $memory_use . 'kb]';
|
||||||
$file_load = " [文件加载:" . count(get_included_files()) . "]";
|
$file_load = ' [文件加载:' . count(get_included_files()) . ']';
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_HOST'])) {
|
if (isset($_SERVER['HTTP_HOST'])) {
|
||||||
$current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
$current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
} else {
|
} else {
|
||||||
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
|
$current_uri = 'cmd:' . implode(' ', $_SERVER['argv']);
|
||||||
}
|
}
|
||||||
// 基本信息
|
// 基本信息
|
||||||
$trace[] = [
|
$trace[] = [
|
||||||
@@ -84,7 +85,7 @@ class Socket
|
|||||||
'css' => $this->css['page'],
|
'css' => $this->css['page'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($logs as $type => $val) {
|
foreach ($log as $type => $val) {
|
||||||
$trace[] = [
|
$trace[] = [
|
||||||
'type' => 'groupCollapsed',
|
'type' => 'groupCollapsed',
|
||||||
'msg' => '[ ' . $type . ' ]',
|
'msg' => '[ ' . $type . ' ]',
|
||||||
@@ -110,7 +111,7 @@ class Socket
|
|||||||
if ($this->config['show_included_files']) {
|
if ($this->config['show_included_files']) {
|
||||||
$trace[] = [
|
$trace[] = [
|
||||||
'type' => 'groupCollapsed',
|
'type' => 'groupCollapsed',
|
||||||
'msg' => 'included_files',
|
'msg' => '[ file ]',
|
||||||
'css' => '',
|
'css' => '',
|
||||||
];
|
];
|
||||||
$trace[] = [
|
$trace[] = [
|
||||||
@@ -171,9 +172,6 @@ class Socket
|
|||||||
|
|
||||||
protected function check()
|
protected function check()
|
||||||
{
|
{
|
||||||
if (!$this->config['enable']) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$tabid = $this->getClientArg('tabid');
|
$tabid = $this->getClientArg('tabid');
|
||||||
//是否记录日志的检查
|
//是否记录日志的检查
|
||||||
if (!$tabid && !$this->config['force_client_ids']) {
|
if (!$tabid && !$this->config['force_client_ids']) {
|
||||||
@@ -225,7 +223,7 @@ class Socket
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $host - $host of socket server
|
* @param string $host - $host of socket server
|
||||||
* @param string $message - 发送的消息
|
* @param string $message - 发送的消息
|
||||||
* @param string $address - 地址
|
* @param string $address - 地址
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class File
|
|||||||
|
|
||||||
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
||||||
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
||||||
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
|
rename($destination, dirname($destination) . DS . $_SERVER['REQUEST_TIME'] . '-' . basename($destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取基本信息
|
// 获取基本信息
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class Relation
|
|||||||
if (!empty($range)) {
|
if (!empty($range)) {
|
||||||
// 查询关联数据
|
// 查询关联数据
|
||||||
$data = $this->eagerlyManyToMany($model, [
|
$data = $this->eagerlyManyToMany($model, [
|
||||||
'pivot.' . $foreignKey => [
|
'pivot.' . $localKey => [
|
||||||
'in',
|
'in',
|
||||||
$range,
|
$range,
|
||||||
],
|
],
|
||||||
@@ -277,7 +277,7 @@ class Relation
|
|||||||
if (isset($result->$pk)) {
|
if (isset($result->$pk)) {
|
||||||
$pk = $result->$pk;
|
$pk = $result->$pk;
|
||||||
// 查询管理数据
|
// 查询管理数据
|
||||||
$data = $this->eagerlyManyToMany($model, ['pivot.' . $foreignKey => $pk], $relation, $subRelation);
|
$data = $this->eagerlyManyToMany($model, ['pivot.' . $localKey => $pk], $relation, $subRelation);
|
||||||
|
|
||||||
// 关联数据封装
|
// 关联数据封装
|
||||||
if (!isset($data[$pk])) {
|
if (!isset($data[$pk])) {
|
||||||
@@ -317,7 +317,7 @@ class Relation
|
|||||||
// 设置关联模型属性
|
// 设置关联模型属性
|
||||||
$list[$relation] = [];
|
$list[$relation] = [];
|
||||||
}
|
}
|
||||||
$result->setAttr($relation, new $model($list[$relation]));
|
$result->setAttr($relation, (new $model($list[$relation]))->isUpdate(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,7 +374,7 @@ class Relation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$set->pivot = new Pivot($pivot, $this->middle);
|
$set->pivot = new Pivot($pivot, $this->middle);
|
||||||
$data[$set->$foreignKey][] = $set;
|
$data[$pivot[$localKey]][] = $set;
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class File
|
|||||||
if (!file_exists($cacheFile)) {
|
if (!file_exists($cacheFile)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
|
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) {
|
||||||
// 缓存是否在有效期
|
// 缓存是否在有效期
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class Sae
|
|||||||
public function write($cacheFile, $content)
|
public function write($cacheFile, $content)
|
||||||
{
|
{
|
||||||
// 添加写入时间
|
// 添加写入时间
|
||||||
$content = time() . $content;
|
$content = $_SERVER['REQUEST_TIME'] . $content;
|
||||||
if (!$this->mc->set($cacheFile, $content, MEMCACHE_COMPRESSED, 0)) {
|
if (!$this->mc->set($cacheFile, $content, MEMCACHE_COMPRESSED, 0)) {
|
||||||
throw new Exception('sae mc write error:' . $cacheFile);
|
throw new Exception('sae mc write error:' . $cacheFile);
|
||||||
} else {
|
} else {
|
||||||
@@ -76,7 +76,7 @@ class Sae
|
|||||||
public function check($cacheFile, $cacheTime)
|
public function check($cacheFile, $cacheTime)
|
||||||
{
|
{
|
||||||
$mtime = $this->get($cacheFile, 'mtime');
|
$mtime = $this->get($cacheFile, 'mtime');
|
||||||
if (0 != $cacheTime && time() > $mtime + $cacheTime) {
|
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > $mtime + $cacheTime) {
|
||||||
// 缓存是否在有效期
|
// 缓存是否在有效期
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace {%namespace%};
|
namespace {%namespace%};
|
||||||
|
|
||||||
class {%className%} extends {%extend%}
|
class {%className%} {%extend%}
|
||||||
{
|
{
|
||||||
|
{%content%}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user