1、内核更新

2、后台bug修复(获取参数的bug)
This commit is contained in:
2016-07-04 00:14:28 +08:00
parent cf7f98f04c
commit 2da74dbc1e
31 changed files with 171 additions and 138 deletions

View File

@@ -63,7 +63,7 @@ class Ad extends Admin {
public function edit($id = null){
$place = model('AdPlace');
if (IS_POST) {
$data = input('post.','');
$data = $this->request->post();
if ($data) {
$result = $place->save($data,array('id'=>$data['id']));
if ($result) {
@@ -122,7 +122,7 @@ class Ad extends Admin {
public function addad($id){
$ad = model('ad');
if (IS_POST) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
$result = $ad->save($data);
if ($result) {
@@ -148,7 +148,7 @@ class Ad extends Admin {
public function editad($id = null){
$ad = model('ad');
if (IS_POST) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
$result = $ad->save($data,array('id'=>$data['id']));
if ($result) {

View File

@@ -69,7 +69,7 @@ class Attribute extends Admin {
* @author colin <colin@tensent.cn>
*/
public function add(){
$model_id = input('get.model_id','','trim,intval');
$model_id = input('model_id','','trim,intval');
if(IS_POST){
$result = $this->model->change();
if ($result) {
@@ -104,7 +104,7 @@ class Attribute extends Admin {
return $this->error($this->model->getError(),'');
}
}else{
$id = input('get.id','','trim,intval');
$id = input('id','','trim,intval');
$info = db('Attribute')->find($id);
$data = array(
'info' => $info,

View File

@@ -17,7 +17,7 @@ class Channel extends Admin{
}
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));
@@ -50,7 +50,7 @@ class Channel extends Admin{
public function add() {
if (IS_POST) {
$Channel = model('Channel');
$data = input('post.');
$data = $this->request->post();
if ($data) {
$id = $Channel->save($data);
if ($id) {
@@ -64,7 +64,7 @@ class Channel extends Admin{
$this->error($Channel->getError());
}
} else {
$pid = input('get.pid', 0);
$pid = input('pid', 0);
//获取父导航
if (!empty($pid)) {
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
@@ -86,7 +86,7 @@ class Channel extends Admin{
public function edit($id = 0) {
if (IS_POST) {
$Channel = model('Channel');
$data = input('post.');
$data = $this->request->post();
if ($data) {
if (false !== $Channel->save($data,array('id'=>$data['id']))) {
//记录行为
@@ -107,7 +107,7 @@ class Channel extends Admin{
return $this->error('获取配置信息错误');
}
$pid = input('get.pid', 0);
$pid = input('pid', 0);
//获取父导航
if (!empty($pid)) {
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
@@ -148,8 +148,8 @@ class Channel extends Admin{
*/
public function sort() {
if (IS_GET) {
$ids = input('get.ids');
$pid = input('get.pid');
$ids = input('ids');
$pid = input('pid');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {

View File

@@ -77,10 +77,10 @@ class Config extends Admin{
*/
public function add() {
if (IS_POST) {
$Config = model('Config');
$data = input('post.');
$config = model('Config');
$data = $this->request->post();
if ($data) {
$id = $Config->validate(true)->save($data);
$id = $config->validate(true)->save($data);
if ($id) {
cache('db_config_data', null);
//记录行为
@@ -92,7 +92,7 @@ class Config extends Admin{
}
}
else {
return $this->error($Config->getError());
return $this->error($config->getError());
}
}
else {
@@ -109,20 +109,20 @@ class Config extends Admin{
*/
public function edit($id = 0) {
if (IS_POST) {
$Config = model('Config');
$data = input('post.');
$config = model('Config');
$data = $this->request->post();
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) {
cache('db_config_data', null);
//记录行为
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
return $this->success('更新成功', Cookie('__forward__'));
} else {
return $this->error($Config->getError(), '');
return $this->error($config->getError(), '');
}
}else {
return $this->error($Config->getError());
return $this->error($config->getError());
}
}else{
$info = array();
@@ -181,7 +181,7 @@ class Config extends Admin{
*/
public function sort() {
if (IS_GET) {
$ids = input('get.ids');
$ids = input('ids');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {

View File

@@ -145,7 +145,7 @@ class Content extends Admin{
* @author molong <ycgpp@126.com>
*/
public function del(){
$id = input('get.id','','trim');
$id = input('id','','trim');
$ids = input('post.ids',array());
array_push($ids, $id);
if (empty($ids)) {

View File

@@ -56,7 +56,7 @@ class Link extends Admin{
//修改
public function edit(){
$link = model('Link');
$id = input('get.id','','trim,intval');
$id = input('id','','trim,intval');
if(IS_POST){
$data = input('post.');
if ($data) {

View File

@@ -226,8 +226,8 @@ class Menu extends Admin{
*/
public function sort(){
if(IS_GET){
$ids = input('get.ids');
$pid = input('get.pid');
$ids = input('ids');
$pid = input('pid');
//获取排序的数据
$map = array('status'=>array('gt',-1));

View File

@@ -148,7 +148,7 @@ class Model extends Admin{
* @author colin <colin@tensent.cn>
*/
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('参数不正确!');
$data['status'] = input('get.status');

View File

@@ -49,7 +49,7 @@ class Seo extends Admin{
public function add(){
if (IS_POST) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
$result = model('SeoRule')->save($data);
if ($result) {
@@ -72,7 +72,7 @@ class Seo extends Admin{
public function edit($id = null){
if (IS_POST) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
$result = model('SeoRule')->save($data,array('id'=>$data['id']));
if (false !== $result) {

View File

@@ -172,7 +172,7 @@ class User extends Admin{
*/
private function getUserinfo($uid = null,$pass = null,$errormsg = null){
$user = model('User');
$uid = $uid ? $uid : input('get.id');
$uid = $uid ? $uid : input('id');
//如果无UID则修改当前用户
$uid = $uid ? $uid : session('user_auth.uid');
$map['uid'] = $uid;

View File

@@ -9,6 +9,8 @@ return [
'app_namespace' => 'app',
// 应用调试模式
'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 应用模式状态
'app_status' => '',
// 是否支持多模块
@@ -95,7 +97,7 @@ return [
'var_method' => '_method',
// +----------------------------------------------------------------------
// | 模板引擎设置
// | 模板设置
// +----------------------------------------------------------------------
'template' => [
@@ -134,24 +136,26 @@ return [
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
'exception_handle' => '',
// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
'log' => [
// 日志记录方式,支持 file sae
// 日志记录方式,内置 file sae 支持扩展
'type' => 'File',
// 日志保存目录
'path' => LOG_PATH,
],
// +----------------------------------------------------------------------
// | Trace设置
// | Trace设置 开启 app_trace 后 有效
// +----------------------------------------------------------------------
'trace' => [
// 支持Html Socket Console 设为false则不显示
'type' => false,
// 内置Html Socket Console 支持扩展
'type' => 'Html',
],
// +----------------------------------------------------------------------
@@ -245,6 +249,7 @@ return [
// 自动写入时间戳字段
'auto_timestamp' => false,
],
//分页配置
'paginate' => [
'type' => 'bootstrap',

View File

@@ -207,6 +207,6 @@ class Database{
* 析构方法,用于关闭文件资源
*/
public function __destruct(){
$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
//$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
}
}

View File

@@ -155,7 +155,9 @@ class App
Hook::listen('app_end', $response);
// Trace调试注入
Debug::inject($response);
if (Config::get('app_trace')) {
Debug::inject($response);
}
return $response;
}

View File

@@ -88,7 +88,7 @@ class Cookie
array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
$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']) {
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'];
$name = $prefix . $name;
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
unset($_COOKIE[$name]);
@@ -169,7 +169,7 @@ class Cookie
foreach ($_COOKIE as $key => $val) {
if (0 === strpos($key, $prefix)) {
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]);
}

View File

@@ -186,40 +186,33 @@ class Debug
public static function inject(Response $response)
{
$config = Config::get('trace');
$type = isset($config['type']) ? $config['type'] : 'Html';
$config = Config::get('trace');
$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) {
$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 ($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);
if ($response instanceof Redirect) {
//TODO 记录
} else {
$output = $trace->output($response, 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);
}
}
}

View File

@@ -63,7 +63,7 @@ class Error
if (error_reporting() & $errno) {
// 将错误信息托管至 think\exception\ErrorException
throw $exception;
}else{
} else {
self::getExceptionHandler()->report($exception);
}
}
@@ -98,24 +98,20 @@ class Error
/**
* Get an instance of the exception handler.
*
* @return \think\exception\Handle
* @return Handle
*/
public static function getExceptionHandler()
{
static $handle;
if (!$handle) {
if ($class = Config::get('exception_handle')) {
if (class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) {
$handle = new $class;
}
}
if (!$handle) {
$handle = new Handle();
// 异常处理handle
$class = Config::get('exception_handle');
if ($class && class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) {
$handle = new $class;
} else {
$handle = new Handle;
}
}
return $handle;
}
}

View File

@@ -10,12 +10,13 @@
// +----------------------------------------------------------------------
namespace think;
use think\exception\ClassNotFoundException;
/**
* Class Log
* @package think
*
*
* @method void log($msg) static
* @method void error($msg) static
* @method void info($msg) static
@@ -48,13 +49,13 @@ class Log
* 日志初始化
* @param array $config
*/
public static function init($config = [])
public static function init($config = [])
{
$type = isset($config['type']) ? $config['type'] : 'File';
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
self::$config = $config;
unset($config['type']);
if(class_exists($class)) {
if (class_exists($class)) {
self::$driver = new $class($config);
} else {
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');
}
/**
* 获取日志信息
* @param string $type 信息类型
@@ -110,7 +111,6 @@ class Log
*/
public static function check($config)
{
if (self::$key && !empty($config['allow_key']) && !in_array(self::$key, $config['allow_key'])) {
return false;
}

View File

@@ -258,6 +258,10 @@ class Url
// 生成路由映射并缓存
private static function getRouteAlias()
{
static $item = [];
if (!empty($item)) {
return $item;
}
if ($item = Cache::get('think_route_map')) {
return $item;
}

View File

@@ -101,7 +101,7 @@ class File
$content = file_get_contents($filename);
if (false !== $content) {
$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);
return false;

View File

@@ -65,7 +65,7 @@ class Lite
if (is_file($filename)) {
// 判断是否过期
$mtime = filemtime($filename);
if ($mtime < time()) {
if ($mtime < $_SERVER['REQUEST_TIME']) {
// 清除已经过期的文件
unlink($filename);
return false;
@@ -97,7 +97,7 @@ class Lite
$ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
// 通过设置修改时间实现有效期
if ($ret) {
touch($filename, time() + $expire);
touch($filename, $_SERVER['REQUEST_TIME'] + $expire);
}
return $ret;
}

View File

@@ -23,6 +23,8 @@ class Memcached
'expire' => 0,
'timeout' => 0, // 超时时间(单位:毫秒)
'prefix' => '',
'username' => '', //账号
'password' => '', //密码
];
/**
@@ -55,6 +57,10 @@ class Memcached
$servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
}
$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'];
}
$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)) {
return true;
}

View File

@@ -56,7 +56,7 @@ class Sqlite implements CacheInterface
public function get($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);
if (sqlite_num_rows($result)) {
$content = sqlite_fetch_single($result);
@@ -84,7 +84,7 @@ class Sqlite implements CacheInterface
if (is_null($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')) {
//数据压缩
$value = gzcompress($value, 3);

View File

@@ -390,7 +390,11 @@ class Query
if (isset($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();
if (isset($cache)) {
// 缓存数据
@@ -430,6 +434,10 @@ class Query
$field = $key . ',' . $field;
}
$pdo = $this->field($field)->fetchPdo(true)->select();
if (is_string($pdo)) {
// 返回SQL语句
return $pdo;
}
if (1 == $pdo->columnCount()) {
$result = $pdo->fetchAll(PDO::FETCH_COLUMN);
} else {

View File

@@ -15,6 +15,8 @@ use think\Cache;
use think\Config;
use think\Db;
use think\Debug;
use think\Request;
use think\Response;
/**
* 浏览器调试输出
@@ -36,11 +38,20 @@ class Console
/**
* 调试输出接口
* @access public
* @param array $log 日志信息
* @param Response $response Response对象
* @param array $log 日志信息
* @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;
$reqs = number_format(1 / $runtime, 2);
@@ -49,13 +60,13 @@ class Console
if (isset($_SERVER['HTTP_HOST'])) {
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
$uri = 'cmd:' . implode(' ', $_SERVER['argv']);
}
// 页面Trace信息
$base = [
'请求信息' => 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 ',
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
'配置加载' => count(Config::get()),

View File

@@ -15,6 +15,8 @@ use think\Cache;
use think\Config;
use think\Db;
use think\Debug;
use think\Request;
use think\Response;
/**
* 页面Trace调试
@@ -36,12 +38,20 @@ class Html
/**
* 调试输出接口
* @access public
* @param array $log 日志信息
* @param Response $response Response对象
* @param array $log 日志信息
* @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;
$reqs = number_format(1 / $runtime, 2);
@@ -51,11 +61,11 @@ class Html
if (isset($_SERVER['HTTP_HOST'])) {
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
$uri = 'cmd:' . implode(' ', $_SERVER['argv']);
}
$base = [
'请求信息' => 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 ',
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',
'配置加载' => count(Config::get()),

View File

@@ -11,6 +11,8 @@
namespace think\debug;
use think\Response;
/**
* github: https://github.com/luofei614/SocketLog
* @author luofei614<weibo.com/luofei614>
@@ -20,24 +22,22 @@ class Socket
public $port = 1116; //SocketLog 服务的http的端口号
protected $config = [
'enable' => true, //是否记录日志的开关
// socket服务器地址
'host' => 'localhost',
//是否显示利于优化的参数,如果允许时间,消耗内存等
'optimize' => false,
// 是否显示加载的文件列表
'show_included_files' => false,
'error_handler' => false,
//日志强制记录到配置的client_id
// 日志强制记录到配置的client_id
'force_client_ids' => [],
//限制允许读取日志的client_id
// 限制允许读取日志的client_id
'allow_client_ids' => [],
];
protected $css = [
'sql' => 'color:#009bb4;',
'sql_warn' => 'color:#009bb4;font-size:14px;',
'error_handler' => 'color:#f4006b;font-size:14px;',
'page' => 'color:#40e2ff;background:#171717;',
'big' => 'font-size:20px;color:red;',
'sql' => 'color:#009bb4;',
'sql_warn' => 'color:#009bb4;font-size:14px;',
'error' => 'color:#f4006b;font-size:14px;',
'page' => 'color:#40e2ff;background:#171717;',
'big' => 'font-size:20px;color:red;',
];
protected $allowForceClientIds = []; //配置强制推送且被授权的client_id
@@ -57,25 +57,26 @@ class Socket
/**
* 调试输出接口
* @access public
* @param array $logs 日志信息
* @param Response $response Response对象
* @param array $log 日志信息
* @return bool
*/
public function output(array $logs = [])
public function output(Response $response, array $log = [])
{
if (!$this->check()) {
return false;
}
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
$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_str = " [内存消耗:{$memory_use}kb]";
$file_load = " [文件加载:" . count(get_included_files()) . "]";
$memory_str = ' [内存消耗:' . $memory_use . 'kb]';
$file_load = ' [文件加载:' . count(get_included_files()) . ']';
if (isset($_SERVER['HTTP_HOST'])) {
$current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
$current_uri = 'cmd:' . implode(' ', $_SERVER['argv']);
}
// 基本信息
$trace[] = [
@@ -84,7 +85,7 @@ class Socket
'css' => $this->css['page'],
];
foreach ($logs as $type => $val) {
foreach ($log as $type => $val) {
$trace[] = [
'type' => 'groupCollapsed',
'msg' => '[ ' . $type . ' ]',
@@ -110,7 +111,7 @@ class Socket
if ($this->config['show_included_files']) {
$trace[] = [
'type' => 'groupCollapsed',
'msg' => 'included_files',
'msg' => '[ file ]',
'css' => '',
];
$trace[] = [
@@ -171,9 +172,6 @@ class Socket
protected function check()
{
if (!$this->config['enable']) {
return false;
}
$tabid = $this->getClientArg('tabid');
//是否记录日志的检查
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 $address - 地址
* @return bool

View File

@@ -45,7 +45,7 @@ class File
//检测日志文件大小,超过配置大小则备份日志文件重新生成
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));
}
// 获取基本信息

View File

@@ -197,7 +197,7 @@ class Relation
if (!empty($range)) {
// 查询关联数据
$data = $this->eagerlyManyToMany($model, [
'pivot.' . $foreignKey => [
'pivot.' . $localKey => [
'in',
$range,
],
@@ -277,7 +277,7 @@ class Relation
if (isset($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])) {
@@ -317,7 +317,7 @@ class 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);
$data[$set->$foreignKey][] = $set;
$data[$pivot[$localKey]][] = $set;
}
return $data;
}

View File

@@ -62,7 +62,7 @@ class File
if (!file_exists($cacheFile)) {
return false;
}
if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) {
// 缓存是否在有效期
return false;
}

View File

@@ -44,7 +44,7 @@ class Sae
public function write($cacheFile, $content)
{
// 添加写入时间
$content = time() . $content;
$content = $_SERVER['REQUEST_TIME'] . $content;
if (!$this->mc->set($cacheFile, $content, MEMCACHE_COMPRESSED, 0)) {
throw new Exception('sae mc write error:' . $cacheFile);
} else {
@@ -76,7 +76,7 @@ class Sae
public function check($cacheFile, $cacheTime)
{
$mtime = $this->get($cacheFile, 'mtime');
if (0 != $cacheTime && time() > $mtime + $cacheTime) {
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > $mtime + $cacheTime) {
// 缓存是否在有效期
return false;
}

View File

@@ -11,7 +11,7 @@
namespace {%namespace%};
class {%className%} extends {%extend%}
class {%className%} {%extend%}
{
{%content%}
}