内核更新,多余文件清理
This commit is contained in:
@@ -63,5 +63,8 @@
|
||||
|
||||
* 第一步、修改数据库配置文件 application/database.php
|
||||
* 第二步、通过数据库导入工具,比如phpmyadmin导入数据,数据sql文件data/sql.sql
|
||||
* 第三步、登录后台,后台地址 http://域名/admin
|
||||
|
||||
初始账号:admin,密码:admin888
|
||||
> 系统必须开启伪静态
|
||||
|
||||
初始账号:admin,密码:admin888
|
||||
@@ -1,124 +0,0 @@
|
||||
{extend name="public/base"/}
|
||||
{block name="style"}
|
||||
<!-- datepicker statr -->
|
||||
<link href="__PUBLIC__/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
|
||||
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.js"></script>
|
||||
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.zh-CN.js"></script>
|
||||
<!-- datepicker end -->
|
||||
{/block}
|
||||
{block name="body"}
|
||||
<div class="main-box clearfix">
|
||||
<header class="main-box-header clearfix">
|
||||
<div class="pull-left">
|
||||
<h2>{$meta_title}</h2>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary" href="{:url('admin/content/add?model_id='.$model_id)}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('admin/content/del?model_id='.$model_id)}" target-form="ids">删 除</button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
<div class="row">
|
||||
<form method="get">
|
||||
<div class="col-sm-12 col-md-4 pt-5">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">书名:</div>
|
||||
<input type="text" class="form-control" name="book_name" value="{$book_name|default=''}" placeholder="书名">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 pt-5">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">发布时间:</div>
|
||||
<div class="col-sm-5">
|
||||
<input type="text" class="form-control create_time" name="create_time[]" id="create_time" placeholder="开始时间" value="{$create_time[0]|default=''}" readonly>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<input type="text" class="form-control create_time" name="create_time[]" id="create_time" placeholder="结束时间" value="{$create_time[1]|default=''}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 pt-5">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">标准类型:</div>
|
||||
<select class="form-control" name="stand_class"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 pt-5">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">编号:</div>
|
||||
<input type="text" class="form-control" name="book_no" value="{$book_no|default=''}" placeholder="编号">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 pt-5">
|
||||
<button class="btn btn-primary" type="submit">搜索</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-responsive clearfix">
|
||||
|
||||
<div class="table-responsive clearfix">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
||||
{volist name="grid['grids']" id="item"}
|
||||
<th>{$item['title']}</th>
|
||||
{/volist}
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{if condition="empty($list)"}
|
||||
{php}
|
||||
$cow = count($grid['grids'])+2;
|
||||
{/php}
|
||||
<tr>
|
||||
<td colspan="{$cow}" align="center">暂无数据!</td>
|
||||
</tr>
|
||||
{else/}
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||
{volist name="grid['grids']" id="vo"}
|
||||
{if isset($vo['format'])}
|
||||
<td>{$item[$vo['field'][0]]|$vo['format']}</td>
|
||||
{else/}
|
||||
<td>{$item[$vo['field'][0]]}</td>
|
||||
{/if}
|
||||
{/volist}
|
||||
<td>
|
||||
{if isset($item['status'])}
|
||||
{if $item['status']}
|
||||
<a href="{:url('admin/content/status',array('id'=>$item['id'],'model_id'=>$model_id,'status'=>'0'))}" class="ajax-get">取消审核</a>
|
||||
{else/}
|
||||
<a href="{:url('admin/content/status',array('id'=>$item['id'],'model_id'=>$model_id,'status'=>'1'))}" class="ajax-get">审核</a>
|
||||
{/if}
|
||||
{/if}
|
||||
<a href="{:url('admin/content/edit',array('id'=>$item['id'],'model_id'=>$model_id))}" >编辑</a>
|
||||
<a href="{:url('admin/content/del',array('id'=>$item['id'],'model_id'=>$model_id))}" class="ajax-get confirm">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$page}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('.create_time').fdatepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
pickTime: true
|
||||
});
|
||||
|
||||
$('.height_btn').click(function(){
|
||||
$('.height').show();
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{/block}
|
||||
@@ -20,6 +20,9 @@
|
||||
<th>
|
||||
<span>Email</span>
|
||||
</th>
|
||||
<th>
|
||||
<span>手机号码</span>
|
||||
</th>
|
||||
<th>
|
||||
<span>创建时间</span>
|
||||
</th>
|
||||
@@ -40,6 +43,9 @@
|
||||
<td>
|
||||
<span >{$item['email']}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span >{$item['mobile']}</span>
|
||||
</td>
|
||||
<td>{$item['reg_time']|date='Y-m-d',###}</td>
|
||||
<td class="text-center">
|
||||
{if condition="$item['status']"}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace app\common\behavior;
|
||||
|
||||
class InitHook {
|
||||
|
||||
public function run(&$content){
|
||||
public function run(&$request){
|
||||
|
||||
//初始化某些配置信息
|
||||
if (cache('db_config_data')) {
|
||||
|
||||
@@ -16,8 +16,10 @@ class Fornt extends Base{
|
||||
|
||||
//判读是否为关闭网站
|
||||
if (\think\Config::get('web_site_close')) {
|
||||
return $this->fetch('common@default/public/close');exit();
|
||||
header("Content-type:text/html;charset=utf-8");
|
||||
echo $this->fetch('common@default/public/close');exit();
|
||||
}
|
||||
|
||||
//设置SEO
|
||||
$this->setSeo();
|
||||
|
||||
|
||||
20
application/common/model/MemberExtend.php
Normal file
20
application/common/model/MemberExtend.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class MemberExtend extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'uid' => 'integer',
|
||||
);
|
||||
}
|
||||
@@ -12,19 +12,14 @@ namespace app\common\model;
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends \think\model\Merge{
|
||||
class User extends Base{
|
||||
|
||||
protected $name = "Member";
|
||||
protected static $relationModel = array('MemberExtend');
|
||||
protected $createTime = 'reg_time';
|
||||
protected $updateTime = 'last_login_time';
|
||||
protected $fk = 'user_id';
|
||||
protected $mapFields = array(
|
||||
'uid' => 'Member.uid',
|
||||
'user_id' => 'MemberExtend.uid',
|
||||
);
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
'uid' => 'integer',
|
||||
);
|
||||
protected $insert = array('salt', 'password', 'status', 'reg_time');
|
||||
protected $update = array();
|
||||
@@ -54,11 +49,21 @@ class User extends \think\model\Merge{
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'mobile','title'=>'联系电话','type'=>'text','help'=>''),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
);
|
||||
|
||||
public $userextend = array(
|
||||
array('name'=>'company','title'=>'单位名称','type'=>'text','help'=>''),
|
||||
array('name'=>'company_addr','title'=>'单位地址','type'=>'text','help'=>''),
|
||||
array('name'=>'company_contact','title'=>'单位联系人','type'=>'text','help'=>''),
|
||||
array('name'=>'company_zip','title'=>'单位邮编','type'=>'text','help'=>''),
|
||||
array('name'=>'company_depart','title'=>'所属部门','type'=>'text','help'=>''),
|
||||
array('name'=>'company_post','title'=>'所属职务','type'=>'text','help'=>''),
|
||||
array('name'=>'company_type','title'=>'单位类型','type'=>'select', 'option'=>'', 'help'=>''),
|
||||
);
|
||||
|
||||
protected function setStatusAttr($value){
|
||||
return 1;
|
||||
}
|
||||
@@ -72,6 +77,11 @@ class User extends \think\model\Merge{
|
||||
*/
|
||||
public function login($username = '', $password = '', $type = 1){
|
||||
$map = array();
|
||||
if (\think\Validate::is($username,'email')) {
|
||||
$type = 2;
|
||||
}elseif (preg_match("/^1[34578]{1}\d{9}$/",$username)) {
|
||||
$type = 3;
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$map['username'] = $username;
|
||||
@@ -111,11 +121,6 @@ class User extends \think\model\Merge{
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
function register($username, $password, $repassword, $email, $isautologin = true){
|
||||
if ($password !== $repassword) {
|
||||
$this->error = "密码和确认密码不相同";
|
||||
return false;
|
||||
}
|
||||
|
||||
$data['username'] = $username;
|
||||
$data['salt'] = rand_string(6);
|
||||
$data['password'] = $password;
|
||||
@@ -123,6 +128,7 @@ class User extends \think\model\Merge{
|
||||
$result = $this->validate(true)->save($data);
|
||||
if ($result) {
|
||||
$this->data['uid'] = $result;
|
||||
$this->extend()->save($data);
|
||||
if ($isautologin) {
|
||||
$this->autoLogin($this->data);
|
||||
}
|
||||
@@ -147,8 +153,8 @@ class User extends \think\model\Merge{
|
||||
'last_login_time' => time(),
|
||||
'last_login_ip' => get_client_ip(1),
|
||||
);
|
||||
$this->db()->where(array('uid'=>$user['uid']))->update($data);
|
||||
$user = $this->db()->where(array('uid'=>$user['uid']))->find();
|
||||
$this->where(array('uid'=>$user['uid']))->update($data);
|
||||
$user = $this->where(array('uid'=>$user['uid']))->find();
|
||||
|
||||
/* 记录登录SESSION和COOKIES */
|
||||
$auth = array(
|
||||
@@ -167,7 +173,7 @@ class User extends \think\model\Merge{
|
||||
}
|
||||
|
||||
public function getInfo($uid){
|
||||
$data = $this->db()->where(array('uid'=>$uid))->find();
|
||||
$data = $this->where(array('uid'=>$uid))->find();
|
||||
if ($data) {
|
||||
return $data->toArray();
|
||||
}else{
|
||||
@@ -178,7 +184,12 @@ class User extends \think\model\Merge{
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
if ($data['uid']) {
|
||||
return $this->save($data, array('uid'=>$data['uid']));
|
||||
$result = $this->validate('member.edit')->save($data, array('uid'=>$data['uid']));
|
||||
if ($result) {
|
||||
$result = $this->extend->save($data, array('uid'=>$data['uid']));
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$this->error = "非法操作!";
|
||||
return false;
|
||||
@@ -211,6 +222,10 @@ class User extends \think\model\Merge{
|
||||
return $this->db()->where(array('uid'=>$uid))->update($data);
|
||||
}
|
||||
|
||||
public function extend(){
|
||||
return $this->hasOne('MemberExtend', 'uid');
|
||||
}
|
||||
|
||||
protected function checkPassword($username,$password){
|
||||
if (!$username || !$password) {
|
||||
return false;
|
||||
|
||||
@@ -15,17 +15,21 @@ namespace app\common\validate;
|
||||
class Member extends \think\Validate{
|
||||
|
||||
protected $rule = array(
|
||||
'username' => 'require|unique:member|/^[a-zA-Z]\w{0,39}$/',
|
||||
'email' => 'require|unique:member|email',
|
||||
'username' => 'require|unique:member|/^[a-zA-Z]\w{0,39}$/',
|
||||
'email' => 'require|unique:member|email',
|
||||
'mobile' => 'unique:member',
|
||||
'repassword'=>'require|confirm:password'
|
||||
);
|
||||
protected $message = array(
|
||||
'username.require' => '用户名必须',
|
||||
'username.unique' => '用户名已存在',
|
||||
'email.require' => '邮箱必须',
|
||||
'email.unique' => '邮箱已存在',
|
||||
'mobile.unique' => '手机号已存在',
|
||||
'repassword.require' => '确认密码和密码必须一致',
|
||||
);
|
||||
protected $scene = array(
|
||||
//'add' => 'username,email',
|
||||
'edit' => 'email,mobile',
|
||||
);
|
||||
|
||||
}
|
||||
16
application/common/view/default/public/close.html
Normal file
16
application/common/view/default/public/close.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>SentCMS网站管理系统 - PowerBy TenSent</title>
|
||||
<style>
|
||||
body{font-family: "微软雅黑","Microsoft Yahei";}
|
||||
.close{border: 5px solid #efefef; padding: 30px; width: 300px; margin: 100px auto; text-align: center;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="close">
|
||||
本站已关闭!
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -92,9 +92,14 @@ return array(
|
||||
),
|
||||
|
||||
'log' => array(
|
||||
// 日志记录方式,支持 file socket trace sae
|
||||
// 日志记录方式,支持 file sae
|
||||
'type' => 'file',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
)
|
||||
),
|
||||
// 页面Trace信息
|
||||
// 'trace' =>array(
|
||||
// //支持Html,Console 设为false则不显示
|
||||
// 'type' => false,
|
||||
// )
|
||||
);
|
||||
@@ -15,7 +15,7 @@ return array(
|
||||
// 服务器地址
|
||||
'hostname' => '127.0.0.1',
|
||||
// 数据库名
|
||||
'database' => 'nmg_www',
|
||||
'database' => 'sentcms_www',
|
||||
// 数据库用户名
|
||||
'username' => 'root',
|
||||
// 数据库密码
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\index\controller;
|
||||
use app\common\controller\Fornt;
|
||||
|
||||
class Book extends Fornt{
|
||||
|
||||
public function _initialize(){
|
||||
parent::_initialize();
|
||||
$this->book = model('Book');
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$map = $this->search();
|
||||
$order = 'id desc';
|
||||
$list = $this->book->where($map)->order($order)->paginate(10);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render()
|
||||
);
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//图书详情
|
||||
public function detail($id = 0){
|
||||
$map['id'] = $id;
|
||||
|
||||
$info = $this->book->where($map)->find();
|
||||
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//图书搜索条件组织
|
||||
protected function search(){
|
||||
$map = array();
|
||||
$data = $this->request->post();
|
||||
$data['is_show_height'] = 0;
|
||||
if (isset($data['book_name']) && $data['book_name']) {
|
||||
$map['book_name'] = array("LIKE", "%" . $data['book_name'] . "%");
|
||||
}
|
||||
if (isset($data['book_no']) && $data['book_no']) {
|
||||
$map['book_no'] = array("LIKE", "%" . $data['book_no'] . "%");
|
||||
$data['is_show_height'] = 1;
|
||||
}
|
||||
if (isset($data['stand_class']) && $data['stand_class']) {
|
||||
$map['stand_class'] = $data['stand_class'];
|
||||
$data['is_show_height'] = 1;
|
||||
}
|
||||
if (isset($data['create_time'][0]) && isset($data['create_time'][1]) && $data['create_time'][0] && $data['create_time'][1]) {
|
||||
$map['create_time'] = array('BETWEEN',$data['create_time']);
|
||||
$data['is_show_height'] = 1;
|
||||
}
|
||||
|
||||
$this->assign($data);
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\index\controller;
|
||||
use app\common\controller\Fornt;
|
||||
|
||||
class Cart extends Fornt{
|
||||
|
||||
public function _initialize(){
|
||||
$this->cart = new \com\Cart();
|
||||
}
|
||||
|
||||
//购物车
|
||||
public function index(){
|
||||
$list = $this->cart->all();
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
);
|
||||
$this->assign($data);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//加入购物车
|
||||
public function add($id, $num){
|
||||
if ($num > 0) {
|
||||
$this->cart->addItem($id, $num);
|
||||
}
|
||||
$info['code'] = 1;
|
||||
$info['num'] = $this->cart->getCount();
|
||||
return $info;
|
||||
}
|
||||
|
||||
//加入购物车
|
||||
public function del($id){
|
||||
$this->cart->delItem($id);
|
||||
$info['code'] = 1;
|
||||
$info['data'] = array('num'=>$this->cart->getCount());
|
||||
return $info;
|
||||
}
|
||||
|
||||
//购物车统计
|
||||
public function count(){
|
||||
$data = array('info'=>$this->cart->getCount());
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
@@ -51,20 +51,27 @@ class Order extends User{
|
||||
if (!$order_id) {
|
||||
$price_count = '0.00';
|
||||
$list = $this->cart->all();
|
||||
foreach ($list as $key => $value) {
|
||||
$price_count += $value['price_count'];
|
||||
if ($list) {
|
||||
foreach ($list as $key => $value) {
|
||||
$price_count += $value['price_count'];
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'price_count' => $price_count
|
||||
);
|
||||
|
||||
//生成订单
|
||||
$map['id'] = $this->order->createOrder($data);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'price_count' => $price_count
|
||||
);
|
||||
|
||||
//生成订单
|
||||
$map['id'] = $this->order->createOrder($data);
|
||||
}else{
|
||||
$map['id'] = $order_id;
|
||||
}
|
||||
|
||||
if (!isset($map['id'])) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
|
||||
$order = $this->order->where($map)->find();
|
||||
|
||||
$data = array(
|
||||
|
||||
@@ -24,8 +24,13 @@ class Profile extends User{
|
||||
}
|
||||
}else{
|
||||
$group['基础资料'] = $user->useredit;
|
||||
$group['扩展信息'] = $user->userextend;
|
||||
|
||||
$info = $user->getInfo(session('user_auth.uid'));
|
||||
$info = $user->where(array('uid'=>session('user_auth.uid')))->find();
|
||||
|
||||
if ($info->extend) {
|
||||
$info = array_merge($info->toArray(), $info->extend->toArray());
|
||||
}
|
||||
$data = array(
|
||||
'fieldGroup' => $group,
|
||||
'info' => $info
|
||||
|
||||
@@ -79,7 +79,7 @@ time { color: #777;}
|
||||
.nc-login-form dl { background-color: #FFF; width: 398px; height: 52px; margin-top: -1px; border: solid 1px #E6E6E6; position: relative; z-index: 1; overflow: hidden;}
|
||||
.nc-login-form dl.focus { border-color: #7ABD54; z-index: 3;}
|
||||
.nc-login-form dl.error { border-color: #F87622 !important; z-index: 2;}
|
||||
.nc-login-form dl dt { font-size: 14px; line-height: 20px; color: #666; width: 72px; padding: 16px 0 16px 20px; float: left;}
|
||||
.nc-login-form dl dt { font-size: 14px; line-height: 20px; color: #333333; width: 72px; padding: 16px 0 16px 20px; float: left;}
|
||||
.nc-login-form dl dd { height: 28px; float: left; padding: 12px 0;}
|
||||
.nc-login-form dl dd .text { font-family: "microsoft yahei"; font-size: 14px; line-height: 28px; width: 290px; height: 28px; padding: 0; border: none 0;}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<dl>
|
||||
<dt>账 号:</dt>
|
||||
<dd>
|
||||
<input type="text" class="text" autocomplete="off" name="username" placeholder="用户名/邮箱" id="username" >
|
||||
<input type="text" class="text" autocomplete="off" name="username" placeholder="用户名/邮箱/手机号码" id="username" >
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define('THINK_VERSION', '5.0.0 RC3');
|
||||
define('START_TIME', number_format(microtime(true), 8, '.', ''));
|
||||
define('START_MEM', memory_get_usage());
|
||||
define('THINK_VERSION', '5.0.0 RC4');
|
||||
define('THINK_START_TIME', number_format(microtime(true), 8, '.', ''));
|
||||
define('THINK_START_MEM', memory_get_usage());
|
||||
define('EXT', '.php');
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS);
|
||||
|
||||
@@ -140,7 +140,7 @@ return [
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'log' => [
|
||||
// 日志记录方式,支持 file socket sae
|
||||
// 日志记录方式,支持 file sae
|
||||
'type' => 'File',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
@@ -150,7 +150,7 @@ return [
|
||||
// | Trace设置
|
||||
// +----------------------------------------------------------------------
|
||||
'trace' => [
|
||||
//支持Html,Console 设为false则不显示
|
||||
// 支持Html Socket Console 设为false则不显示
|
||||
'type' => false,
|
||||
],
|
||||
|
||||
|
||||
374
core/helper.php
374
core/helper.php
@@ -33,9 +33,11 @@ use think\View;
|
||||
* @param string $ext 类库后缀
|
||||
* @return boolean
|
||||
*/
|
||||
function load_trait($class, $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, TRAIT_PATH, $ext);
|
||||
if (!function_exists('load_trait')) {
|
||||
function load_trait($class, $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, TRAIT_PATH, $ext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,10 +49,12 @@ function load_trait($class, $ext = EXT)
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
function exception($msg, $code = 0, $exception = '')
|
||||
{
|
||||
$e = $exception ?: '\think\Exception';
|
||||
throw new $e($msg, $code);
|
||||
if (!function_exists('exception')) {
|
||||
function exception($msg, $code = 0, $exception = '')
|
||||
{
|
||||
$e = $exception ?: '\think\Exception';
|
||||
throw new $e($msg, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,12 +64,14 @@ function exception($msg, $code = 0, $exception = '')
|
||||
* @param integer|string $dec 小数位 如果是m 表示统计内存占用
|
||||
* @return mixed
|
||||
*/
|
||||
function debug($start, $end = '', $dec = 6)
|
||||
{
|
||||
if ('' == $end) {
|
||||
Debug::remark($start);
|
||||
} else {
|
||||
return 'm' == $dec ? Debug::getRangeMem($start, $end) : Debug::getRangeTime($start, $end, $dec);
|
||||
if (!function_exists('debug')) {
|
||||
function debug($start, $end = '', $dec = 6)
|
||||
{
|
||||
if ('' == $end) {
|
||||
Debug::remark($start);
|
||||
} else {
|
||||
return 'm' == $dec ? Debug::getRangeMem($start, $end) : Debug::getRangeTime($start, $end, $dec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +82,11 @@ function debug($start, $end = '', $dec = 6)
|
||||
* @param string $lang 语言
|
||||
* @return mixed
|
||||
*/
|
||||
function lang($name, $vars = [], $lang = '')
|
||||
{
|
||||
return Lang::get($name, $vars, $lang);
|
||||
if (!function_exists('lang')) {
|
||||
function lang($name, $vars = [], $lang = '')
|
||||
{
|
||||
return Lang::get($name, $vars, $lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,12 +96,14 @@ function lang($name, $vars = [], $lang = '')
|
||||
* @param string $range 作用域
|
||||
* @return mixed
|
||||
*/
|
||||
function config($name = '', $value = null, $range = '')
|
||||
{
|
||||
if (is_null($value) && is_string($name)) {
|
||||
return Config::get($name, $range);
|
||||
} else {
|
||||
return Config::set($name, $value, $range);
|
||||
if (!function_exists('config')) {
|
||||
function config($name = '', $value = null, $range = '')
|
||||
{
|
||||
if (is_null($value) && is_string($name)) {
|
||||
return Config::get($name, $range);
|
||||
} else {
|
||||
return Config::set($name, $value, $range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,28 +114,30 @@ function config($name = '', $value = null, $range = '')
|
||||
* @param string $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
function input($key, $default = null, $filter = null)
|
||||
{
|
||||
if (0 === strpos($key, '?')) {
|
||||
$key = substr($key, 1);
|
||||
$has = true;
|
||||
}
|
||||
if ($pos = strpos($key, '.')) {
|
||||
// 指定参数来源
|
||||
$method = substr($key, 0, $pos);
|
||||
if (in_array($method, ['get', 'post', 'put', 'delete', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) {
|
||||
$key = substr($key, $pos + 1);
|
||||
if (!function_exists('input')) {
|
||||
function input($key, $default = null, $filter = null)
|
||||
{
|
||||
if (0 === strpos($key, '?')) {
|
||||
$key = substr($key, 1);
|
||||
$has = true;
|
||||
}
|
||||
if ($pos = strpos($key, '.')) {
|
||||
// 指定参数来源
|
||||
$method = substr($key, 0, $pos);
|
||||
if (in_array($method, ['get', 'post', 'put', 'delete', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) {
|
||||
$key = substr($key, $pos + 1);
|
||||
} else {
|
||||
$method = 'param';
|
||||
}
|
||||
} else {
|
||||
// 默认为自动判断
|
||||
$method = 'param';
|
||||
}
|
||||
} else {
|
||||
// 默认为自动判断
|
||||
$method = 'param';
|
||||
}
|
||||
if (isset($has)) {
|
||||
return request()->has($key, $method, $default);
|
||||
} else {
|
||||
return request()->$method($key, $default, $filter);
|
||||
if (isset($has)) {
|
||||
return request()->has($key, $method, $default);
|
||||
} else {
|
||||
return request()->$method($key, $default, $filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,9 +147,11 @@ function input($key, $default = null, $filter = null)
|
||||
* @param array $data 传人的参数
|
||||
* @return mixed
|
||||
*/
|
||||
function widget($name, $data = [])
|
||||
{
|
||||
return Loader::action($name, $data, 'widget');
|
||||
if (!function_exists('widget')) {
|
||||
function widget($name, $data = [])
|
||||
{
|
||||
return Loader::action($name, $data, 'widget');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,9 +161,11 @@ function widget($name, $data = [])
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return \think\Model
|
||||
*/
|
||||
function model($name = '', $layer = 'model', $appendSuffix = false)
|
||||
{
|
||||
return Loader::model($name, $layer, $appendSuffix);
|
||||
if (!function_exists('model')) {
|
||||
function model($name = '', $layer = 'model', $appendSuffix = false)
|
||||
{
|
||||
return Loader::model($name, $layer, $appendSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,9 +175,11 @@ function model($name = '', $layer = 'model', $appendSuffix = false)
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return \think\Validate
|
||||
*/
|
||||
function validate($name = '', $layer = 'validate', $appendSuffix = false)
|
||||
{
|
||||
return Loader::validate($name, $layer, $appendSuffix);
|
||||
if (!function_exists('validate')) {
|
||||
function validate($name = '', $layer = 'validate', $appendSuffix = false)
|
||||
{
|
||||
return Loader::validate($name, $layer, $appendSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,9 +188,11 @@ function validate($name = '', $layer = 'validate', $appendSuffix = false)
|
||||
* @param array|string $config 数据库配置参数
|
||||
* @return \think\db\Query
|
||||
*/
|
||||
function db($name = '', $config = [])
|
||||
{
|
||||
return Db::connect($config)->name($name);
|
||||
if (!function_exists('db')) {
|
||||
function db($name = '', $config = [])
|
||||
{
|
||||
return Db::connect($config)->name($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,9 +202,11 @@ function db($name = '', $config = [])
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return \think\Controller
|
||||
*/
|
||||
function controller($name, $layer = 'controller', $appendSuffix = false)
|
||||
{
|
||||
return Loader::controller($name, $layer, $appendSuffix);
|
||||
if (!function_exists('controller')) {
|
||||
function controller($name, $layer = 'controller', $appendSuffix = false)
|
||||
{
|
||||
return Loader::controller($name, $layer, $appendSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,9 +217,11 @@ function controller($name, $layer = 'controller', $appendSuffix = false)
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return mixed
|
||||
*/
|
||||
function action($url, $vars = [], $layer = 'controller', $appendSuffix = false)
|
||||
{
|
||||
return Loader::action($url, $vars, $layer, $appendSuffix);
|
||||
if (!function_exists('action')) {
|
||||
function action($url, $vars = [], $layer = 'controller', $appendSuffix = false)
|
||||
{
|
||||
return Loader::action($url, $vars, $layer, $appendSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,9 +231,11 @@ function action($url, $vars = [], $layer = 'controller', $appendSuffix = false)
|
||||
* @param string $ext 导入的文件扩展名
|
||||
* @return boolean
|
||||
*/
|
||||
function import($class, $baseUrl = '', $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, $baseUrl, $ext);
|
||||
if (!function_exists('import')) {
|
||||
function import($class, $baseUrl = '', $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, $baseUrl, $ext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,9 +244,11 @@ function import($class, $baseUrl = '', $ext = EXT)
|
||||
* @param string $ext 类库后缀
|
||||
* @return boolean
|
||||
*/
|
||||
function vendor($class, $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, VENDOR_PATH, $ext);
|
||||
if (!function_exists('vendor')) {
|
||||
function vendor($class, $ext = EXT)
|
||||
{
|
||||
return Loader::import($class, VENDOR_PATH, $ext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,9 +258,11 @@ function vendor($class, $ext = EXT)
|
||||
* @param string $label 标签 默认为空
|
||||
* @return void|string
|
||||
*/
|
||||
function dump($var, $echo = true, $label = null)
|
||||
{
|
||||
return Debug::dump($var, $echo, $label);
|
||||
if (!function_exists('dump')) {
|
||||
function dump($var, $echo = true, $label = null)
|
||||
{
|
||||
return Debug::dump($var, $echo, $label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,9 +273,11 @@ function dump($var, $echo = true, $label = null)
|
||||
* @param bool|string $domain 域名
|
||||
* @return string
|
||||
*/
|
||||
function url($url = '', $vars = '', $suffix = true, $domain = false)
|
||||
{
|
||||
return Url::build($url, $vars, $suffix, $domain);
|
||||
if (!function_exists('url')) {
|
||||
function url($url = '', $vars = '', $suffix = true, $domain = false)
|
||||
{
|
||||
return Url::build($url, $vars, $suffix, $domain);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,23 +287,25 @@ function url($url = '', $vars = '', $suffix = true, $domain = false)
|
||||
* @param string $prefix 前缀
|
||||
* @return mixed
|
||||
*/
|
||||
function session($name, $value = '', $prefix = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
// 初始化
|
||||
Session::init($name);
|
||||
} elseif (is_null($name)) {
|
||||
// 清除
|
||||
Session::clear($value);
|
||||
} elseif ('' === $value) {
|
||||
// 判断或获取
|
||||
return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除
|
||||
return Session::delete($name, $prefix);
|
||||
} else {
|
||||
// 设置
|
||||
return Session::set($name, $value, $prefix);
|
||||
if (!function_exists('session')) {
|
||||
function session($name, $value = '', $prefix = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
// 初始化
|
||||
Session::init($name);
|
||||
} elseif (is_null($name)) {
|
||||
// 清除
|
||||
Session::clear($value);
|
||||
} elseif ('' === $value) {
|
||||
// 判断或获取
|
||||
return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除
|
||||
return Session::delete($name, $prefix);
|
||||
} else {
|
||||
// 设置
|
||||
return Session::set($name, $value, $prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,23 +316,25 @@ function session($name, $value = '', $prefix = null)
|
||||
* @param mixed $option 参数
|
||||
* @return mixed
|
||||
*/
|
||||
function cookie($name, $value = '', $option = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
// 初始化
|
||||
Cookie::init($name);
|
||||
} elseif (is_null($name)) {
|
||||
// 清除
|
||||
Cookie::clear($value);
|
||||
} elseif ('' === $value) {
|
||||
// 获取
|
||||
return Cookie::get($name);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除
|
||||
return Cookie::delete($name);
|
||||
} else {
|
||||
// 设置
|
||||
return Cookie::set($name, $value, $option);
|
||||
if (!function_exists('cookie')) {
|
||||
function cookie($name, $value = '', $option = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
// 初始化
|
||||
Cookie::init($name);
|
||||
} elseif (is_null($name)) {
|
||||
// 清除
|
||||
Cookie::clear($value);
|
||||
} elseif ('' === $value) {
|
||||
// 获取
|
||||
return Cookie::get($name);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除
|
||||
return Cookie::delete($name);
|
||||
} else {
|
||||
// 设置
|
||||
return Cookie::set($name, $value, $option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,29 +345,31 @@ function cookie($name, $value = '', $option = null)
|
||||
* @param mixed $options 缓存参数
|
||||
* @return mixed
|
||||
*/
|
||||
function cache($name, $value = '', $options = null)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
// 缓存操作的同时初始化
|
||||
Cache::connect($options);
|
||||
} elseif (is_array($name)) {
|
||||
// 缓存初始化
|
||||
return Cache::connect($name);
|
||||
}
|
||||
if ('' === $value) {
|
||||
// 获取缓存
|
||||
return Cache::get($name);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除缓存
|
||||
return Cache::rm($name);
|
||||
} else {
|
||||
// 缓存数据
|
||||
if (!function_exists('cache')) {
|
||||
function cache($name, $value = '', $options = null)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间
|
||||
} else {
|
||||
$expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间
|
||||
// 缓存操作的同时初始化
|
||||
Cache::connect($options);
|
||||
} elseif (is_array($name)) {
|
||||
// 缓存初始化
|
||||
return Cache::connect($name);
|
||||
}
|
||||
if ('' === $value) {
|
||||
// 获取缓存
|
||||
return Cache::get($name);
|
||||
} elseif (is_null($value)) {
|
||||
// 删除缓存
|
||||
return Cache::rm($name);
|
||||
} else {
|
||||
// 缓存数据
|
||||
if (is_array($options)) {
|
||||
$expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间
|
||||
} else {
|
||||
$expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间
|
||||
}
|
||||
return Cache::set($name, $value, $expire);
|
||||
}
|
||||
return Cache::set($name, $value, $expire);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,12 +379,14 @@ function cache($name, $value = '', $options = null)
|
||||
* @param string $level 日志级别
|
||||
* @return void|array
|
||||
*/
|
||||
function trace($log = '[think]', $level = 'log')
|
||||
{
|
||||
if ('[think]' === $log) {
|
||||
return Log::getLog();
|
||||
} else {
|
||||
Log::record($log, $level);
|
||||
if (!function_exists('trace')) {
|
||||
function trace($log = '[think]', $level = 'log')
|
||||
{
|
||||
if ('[think]' === $log) {
|
||||
return Log::getLog();
|
||||
} else {
|
||||
Log::record($log, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,9 +394,11 @@ function trace($log = '[think]', $level = 'log')
|
||||
* 获取当前Request对象实例
|
||||
* @return Request
|
||||
*/
|
||||
function request()
|
||||
{
|
||||
return Request::instance();
|
||||
if (!function_exists('request')) {
|
||||
function request()
|
||||
{
|
||||
return Request::instance();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,9 +409,11 @@ function request()
|
||||
* @param string $type
|
||||
* @return Response
|
||||
*/
|
||||
function response($data = [], $code = 200, $header = [], $type = 'html')
|
||||
{
|
||||
return Response::create($data, $type, $code, $header);
|
||||
if (!function_exists('response')) {
|
||||
function response($data = [], $code = 200, $header = [], $type = 'html')
|
||||
{
|
||||
return Response::create($data, $type, $code, $header);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,9 +423,11 @@ function response($data = [], $code = 200, $header = [], $type = 'html')
|
||||
* @param integer $code 状态码
|
||||
* @return \think\response\View
|
||||
*/
|
||||
function view($template = '', $vars = [], $code = 200)
|
||||
{
|
||||
return Response::create($template, 'view', $code)->vars($vars);
|
||||
if (!function_exists('view')) {
|
||||
function view($template = '', $vars = [], $code = 200)
|
||||
{
|
||||
return Response::create($template, 'view', $code)->vars($vars);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -392,9 +438,11 @@ function view($template = '', $vars = [], $code = 200)
|
||||
* @param array $options 参数
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
function json($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'json', $code, $header, $options);
|
||||
if (!function_exists('json')) {
|
||||
function json($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'json', $code, $header, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,9 +453,11 @@ function json($data = [], $code = 200, $header = [], $options = [])
|
||||
* @param array $options 参数
|
||||
* @return \think\response\Jsonp
|
||||
*/
|
||||
function jsonp($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'jsonp', $code, $header, $options);
|
||||
if (!function_exists('jsonp')) {
|
||||
function jsonp($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'jsonp', $code, $header, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,9 +468,11 @@ function jsonp($data = [], $code = 200, $header = [], $options = [])
|
||||
* @param array $options 参数
|
||||
* @return \think\response\Xml
|
||||
*/
|
||||
function xml($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'xml', $code, $header, $options);
|
||||
if (!function_exists('xml')) {
|
||||
function xml($data = [], $code = 200, $header = [], $options = [])
|
||||
{
|
||||
return Response::create($data, 'xml', $code, $header, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,13 +482,15 @@ function xml($data = [], $code = 200, $header = [], $options = [])
|
||||
* @param integer $code 状态码
|
||||
* @return \think\response\Redirect
|
||||
*/
|
||||
function redirect($url = [], $params = [], $code = 302)
|
||||
{
|
||||
if (is_integer($params)) {
|
||||
$code = $params;
|
||||
$params = [];
|
||||
if (!function_exists('redirect')) {
|
||||
function redirect($url = [], $params = [], $code = 302)
|
||||
{
|
||||
if (is_integer($params)) {
|
||||
$code = $params;
|
||||
$params = [];
|
||||
}
|
||||
return Response::create($url, 'redirect', $code)->params($params);
|
||||
}
|
||||
return Response::create($url, 'redirect', $code)->params($params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,7 +499,9 @@ function redirect($url = [], $params = [], $code = 302)
|
||||
* @param string $message 错误信息
|
||||
* @param array $header 参数
|
||||
*/
|
||||
function abort($code, $message = null, $header = [])
|
||||
{
|
||||
throw new \think\exception\HttpException($code, $message, null, $header);
|
||||
if (!function_exists('abort')) {
|
||||
function abort($code, $message = null, $header = [])
|
||||
{
|
||||
throw new \think\exception\HttpException($code, $message, null, $header);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace think;
|
||||
|
||||
use think\Config;
|
||||
use think\debug\Trace;
|
||||
use think\Exception;
|
||||
use think\exception\HttpException;
|
||||
use think\exception\HttpResponseException;
|
||||
@@ -145,19 +144,18 @@ class App
|
||||
$response = $data;
|
||||
} elseif (!is_null($data)) {
|
||||
// 默认自动识别响应输出类型
|
||||
$isAjax = $request->isAjax();
|
||||
$type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
$isAjax = $request->isAjax();
|
||||
$type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
$response = Response::create($data, $type);
|
||||
} else {
|
||||
$response = Response::create();
|
||||
}
|
||||
|
||||
|
||||
// 监听app_end
|
||||
Hook::listen('app_end', $response);
|
||||
|
||||
//注入Trace
|
||||
self::$debug && Trace::inject($response);
|
||||
|
||||
// Trace调试注入
|
||||
Debug::inject($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\Config;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\Log;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
use think\response\Redirect;
|
||||
|
||||
class Debug
|
||||
{
|
||||
// 区间时间信息
|
||||
@@ -56,7 +63,7 @@ class Debug
|
||||
*/
|
||||
public static function getUseTime($dec = 6)
|
||||
{
|
||||
return number_format((microtime(true) - START_TIME), $dec);
|
||||
return number_format((microtime(true) - THINK_START_TIME), $dec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +104,7 @@ class Debug
|
||||
*/
|
||||
public static function getUseMem($dec = 2)
|
||||
{
|
||||
$size = memory_get_usage() - START_MEM;
|
||||
$size = memory_get_usage() - THINK_START_MEM;
|
||||
$a = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$pos = 0;
|
||||
while ($size >= 1024) {
|
||||
@@ -177,4 +184,43 @@ class Debug
|
||||
}
|
||||
}
|
||||
|
||||
public static function inject(Response $response)
|
||||
{
|
||||
$config = Config::get('trace');
|
||||
$type = isset($config['type']) ? $config['type'] : 'Html';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1820,7 +1820,7 @@ class Query
|
||||
if (empty($options['fetch_sql']) && !empty($options['cache'])) {
|
||||
// 判断查询缓存
|
||||
$cache = $options['cache'];
|
||||
if (true === $cache['key'] && !is_array($data)) {
|
||||
if (true === $cache['key'] && !is_null($data) && !is_array($data)) {
|
||||
$key = 'think:' . $options['table'] . '|' . $data;
|
||||
} else {
|
||||
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
|
||||
|
||||
@@ -18,6 +18,7 @@ use think\db\Builder;
|
||||
*/
|
||||
class Mysql extends Builder
|
||||
{
|
||||
protected $updateSql = 'UPDATE %TABLE% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
|
||||
|
||||
/**
|
||||
* 字段和表名处理
|
||||
|
||||
@@ -47,7 +47,7 @@ class Oracle extends Connection
|
||||
* @param string $sql sql指令
|
||||
* @param array $bind 参数绑定
|
||||
* @param boolean $getLastInsID 是否获取自增ID
|
||||
* @param string $sequence 序列名
|
||||
* @param string $sequence 序列名
|
||||
* @return integer
|
||||
* @throws \Exception
|
||||
* @throws \think\Exception
|
||||
@@ -60,16 +60,16 @@ class Oracle extends Connection
|
||||
}
|
||||
|
||||
// 根据参数绑定组装最终的SQL语句
|
||||
$this->queryStr = $this->getBindSql($sql, $bind);
|
||||
$this->queryStr = $this->getRealSql($sql, $bind);
|
||||
|
||||
$flag = false;
|
||||
if (preg_match("/^\s*(INSERT\s+INTO)\s+(\w+)\s+/i", $sql, $match)) {
|
||||
if(is_null($sequence)){
|
||||
if (is_null($sequence)) {
|
||||
$sequence = Config::get("db_sequence_prefix") . str_ireplace(Config::get("database.prefix"), "", $match[2]);
|
||||
}
|
||||
$flag = (boolean) $this->query("SELECT * FROM all_sequences WHERE sequence_name='" . strtoupper($sequence) . "'");
|
||||
$flag = (boolean) $this->query("SELECT * FROM all_sequences WHERE sequence_name='" . strtoupper($sequence) . "'");
|
||||
}
|
||||
|
||||
|
||||
//释放前次的查询结果
|
||||
if (!empty($this->PDOStatement)) {
|
||||
$this->free();
|
||||
@@ -89,7 +89,7 @@ class Oracle extends Connection
|
||||
$this->lastInsID = $this->linkID->lastInsertId();
|
||||
if ($getLastInsID) {
|
||||
return $this->lastInsID;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->numRows;
|
||||
} catch (\PDOException $e) {
|
||||
@@ -130,7 +130,7 @@ class Oracle extends Connection
|
||||
/**
|
||||
* 取得数据库的表信息(暂时实现取得用户表信息)
|
||||
* @access public
|
||||
* @param string $dbName
|
||||
* @param string $dbName
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($dbName = '')
|
||||
@@ -155,7 +155,8 @@ class Oracle extends Connection
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function supportSavepoint(){
|
||||
protected function supportSavepoint()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// | Author: yangweijie <yangweijiester@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\debug\trace;
|
||||
namespace think\debug;
|
||||
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
@@ -34,7 +34,7 @@ class Console
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志写入接口
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $log 日志信息
|
||||
* @return bool
|
||||
@@ -42,9 +42,9 @@ class Console
|
||||
public function output(array $log = [])
|
||||
{
|
||||
// 获取基本信息
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||
$reqs = number_format(1 / $runtime, 2);
|
||||
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||
$mem = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
@@ -126,12 +126,12 @@ JS;
|
||||
}
|
||||
break;
|
||||
case '错误':
|
||||
$msg = str_replace(PHP_EOL, '\n', $m);
|
||||
$msg = str_replace("\n", '\n', $m);
|
||||
$style = 'color:#F4006B;font-size:14px;';
|
||||
$line[] = "console.error(\"%c{$msg}\", \"{$style}\");";
|
||||
break;
|
||||
case 'sql':
|
||||
$msg = str_replace(PHP_EOL, '\n', $m);
|
||||
$msg = str_replace("\n", '\n', $m);
|
||||
$style = "color:#009bb4;";
|
||||
$line[] = "console.log(\"%c{$msg}\", \"{$style}\");";
|
||||
break;
|
||||
@@ -9,7 +9,7 @@
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\debug\trace;
|
||||
namespace think\debug;
|
||||
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
@@ -34,7 +34,7 @@ class Html
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志写入接口
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $log 日志信息
|
||||
* @return bool
|
||||
@@ -43,9 +43,9 @@ class Html
|
||||
{
|
||||
|
||||
// 获取基本信息
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||
$reqs = number_format(1 / $runtime, 2);
|
||||
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||
$mem = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||
|
||||
// 页面Trace信息
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
@@ -9,7 +9,7 @@
|
||||
// | Author: luofei614 <weibo.com/luofei614>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\log\driver;
|
||||
namespace think\debug;
|
||||
|
||||
/**
|
||||
* github: https://github.com/luofei614/SocketLog
|
||||
@@ -55,20 +55,20 @@ class Socket
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志写入接口
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $logs 日志信息
|
||||
* @return bool
|
||||
*/
|
||||
public function save(array $logs = [])
|
||||
public function output(array $logs = [])
|
||||
{
|
||||
if (!$this->check()) {
|
||||
return false;
|
||||
}
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
|
||||
$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]";
|
||||
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||
$memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||
$memory_str = " [内存消耗:{$memory_use}kb]";
|
||||
$file_load = " [文件加载:" . count(get_included_files()) . "]";
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think\debug;
|
||||
|
||||
use think\Config;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\Log;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
use think\response\Redirect;
|
||||
|
||||
class Trace
|
||||
{
|
||||
public static function inject(Response $response)
|
||||
{
|
||||
$config = Config::get('trace');
|
||||
|
||||
$type = isset($config['type']) ? $config['type'] : 'Html';
|
||||
|
||||
if ($type !== false) {
|
||||
$request = Request::instance();
|
||||
$accept = $request->header('accept');
|
||||
$contentType = $response->getHeader('Content-Type');
|
||||
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\trace\\' . 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());
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,10 +54,10 @@ class File
|
||||
} else {
|
||||
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
|
||||
}
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||
$reqs = number_format(1 / $runtime, 2);
|
||||
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
|
||||
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||
$memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||
$memory_str = " [内存消耗:{$memory_use}kb]";
|
||||
$file_load = " [文件加载:" . count(get_included_files()) . "]";
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ class Sae
|
||||
} else {
|
||||
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
|
||||
}
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
|
||||
$runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
|
||||
$reqs = number_format(1 / $runtime, 2);
|
||||
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
|
||||
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||
$memory_use = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
|
||||
$memory_str = " [内存消耗:{$memory_use}kb]";
|
||||
$file_load = " [文件加载:" . count(get_included_files()) . "]";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user