多项优化

This commit is contained in:
toogee 2020-01-08 17:37:41 +08:00
parent 03063bc9c1
commit 21456537c8
23 changed files with 1410 additions and 74 deletions

View File

@ -25,18 +25,19 @@ class Set extends AdminController
*/
public function website()
{
//$sysInfo = Db::name('system')->find(1);
$sysInfo = System::find(1);
if(Request::isAjax()){
$data = Request::param();
$result = $sysInfo->allowField(['webname','webtitle','domain','keywords','descript','copyright','blackname'])->save($data);
unset($data['file']);
//$system = System::find(1);
//$result = $system->allowField(['webname','webtitle','domain','keywords','descript','copyright','blackname'])->save($data);
$result = Db::name('system')->cache(true)->where('id', 1)->update($data);
if($result){
return json(['code'=>0,'msg'=>'更新成功']);
} else {
return json(['code'=>-1,'msg'=>'更新失败']);
}
}
$sysInfo = Db::name('system')->find(1);
$syscy = $this->check($sysInfo['base_url']);
View::assign(['sysInfo'=>$sysInfo,'syscy'=>$syscy]);
return View::fetch('set/system/website');
@ -141,7 +142,7 @@ class Set extends AdminController
curl_close($ch);
if($httpCode == '200'){
$cy = json_decode($data);
if($cy->code != 0)){
if($cy->code != 0){
$cylevel = $cy->level;
return $cylevel;
}

View File

@ -156,12 +156,12 @@ class Upgrade extends AdminController
if(!isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'))){
return json(["code"=>0,"msg"=>"获取远程文件失败"]);
}
//把远程文件放入本地
$package_file = $this->upload_dir.'tao_'.$version_num.'.zip';
if(!is_dir($this->upload_dir)){
$this->create_dirs($this->upload_dir);
}
//把远程文件放入本地
$package_file = $this->upload_dir.'tao_'.$version_num.'.zip';
$cpfile = copy($file_url,$package_file);
if(!$cpfile)
{
@ -232,6 +232,9 @@ class Upgrade extends AdminController
return json(["code"=>0,"msg"=>"版本升级不能降级!请检查..."]);
}
if(!is_dir($this->upload_dir)){
$this->create_dirs($this->upload_dir);
}
$package_file = $this->upload_dir.$name;
//$mv = $files->move('/../tmp/web/upload_dir',$version_num);
@ -252,10 +255,11 @@ class Upgrade extends AdminController
$this->save_log("备份失败!");
return json(["code"=>0,"msg"=>"备份失败"]);
}
$this->update_progress("30%");
//执行升级
$upres = $this->execute_update($package_file);
//更新版本
Db::name('system')->update(['sys_version_num'=>$version_num,'id'=>1]);
if($upres){
@ -274,7 +278,6 @@ class Upgrade extends AdminController
//解压 如何使用zip加密压缩这里解压缩的时候注意要解密
$uzip = new Uzip();
$unzip_res = $uzip->uzip($package_file,$this->upload_dir,true);
//halt($unzip_res);
if(!$unzip_res)
{
$this->save_log("解压失败");
@ -467,5 +470,26 @@ class Upgrade extends AdminController
return true;
}
//创建多文件夹
public function create_dirs($path)
{
if (!is_dir($path))
{
$directory_path = "";
$directories = explode("/",$path);
array_pop($directories);
foreach($directories as $directory)
{
$directory_path .= $directory."/";
if (!is_dir($directory_path))
{
mkdir($directory_path);
chmod($directory_path, 0777);
}
}
}
}
}

View File

@ -1,9 +1,9 @@
<?php
namespace app\admin\controller;
use app\common\controller\AdminController;
//use app\common\controller\AdminController;
class Uzip extends AdminController
class Uzip
{
/**
*header('Content-type:text/html;charset=utf-8');
@ -43,7 +43,7 @@ class Uzip extends AdminController
if(file_exists($save_path)) {
if($overwrite === true){
//echo $file_name . '<pre />';
echo $file_name . '<pre />';
$file_size = zip_entry_filesize($zip);
$file = zip_entry_read($zip, $file_size);
$fpc = file_put_contents($save_path, $file);

View File

@ -15,6 +15,12 @@ class Admin extends Model
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
//管理员关联角色
public function authGroup()
{
return $this->belongsTo('AuthGroup','auth_group_id','id');
}
//登陆校验
public function login($data)
{

View File

@ -215,7 +215,7 @@ abstract class AdminController
*
* @return void
*/
protected function create_dirs($path)
protected function create_dir($path)
{
if (!is_dir($path))
{

View File

@ -64,7 +64,7 @@ class User extends Model
{
//随机存入默认头像
$code = mt_rand('1','11');
$data['user_img'] = "./static/res/images/avatar/$code.jpg";
$data['user_img'] = "/static/res/images/avatar/$code.jpg";
$data['create_time'] = time();
$salt = substr(md5($data['create_time']),-6);
$data['password'] = substr_replace(md5($data['password']),$salt,0,6);

View File

@ -35,24 +35,53 @@ class Article extends BaseController
switch ($types) {
//查询文章,10个分1页
case 'all':
$artList = ArticleModel::withCount(['user','cate','comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(10);
$artList = ArticleModel::field('id,title,cate_id,user_id')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
break;
case 'hot':
$artList = ArticleModel::withCount(['user','cate','comments'])->where('status',1)->where($where)->where('is_hot',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(10);
$artList = ArticleModel::field('id,title,cate_id,user_id')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',1)->where($where)->where('is_hot',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
break;
case 'top':
$artList = ArticleModel::withCount(['user','cate','comments'])->where('status',1)->where($where)->where('is_top',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(10);
$artList = ArticleModel::field('id,title,cate_id,user_id')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',1)->where($where)->where('is_top',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
break;
default:
$artList = ArticleModel::withCount(['user','cate','comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(10);
$artList = ArticleModel::field('id,title,cate_id,user_id')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->withCache(30)->paginate(15);
break;
}
// 热议文章
$artHot = ArticleModel::withCount('comments')->where('status',1)->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
$artHot = ArticleModel::field('id,title')->withCount('comments')->where('status',1)->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
//分类右栏广告
$ad_cate = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',5)->whereTime('slid_over','>=',time())->select();
//通用右栏
@ -68,7 +97,14 @@ class Article extends BaseController
//获取文章ID
$id = Request::param('id');
//查询文章
$article = ArticleModel::withCount(['user','cate','comments'])->find($id);
$article = ArticleModel::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,create_time')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->find($id);
$article->inc('pv')->update();
/*
@ -87,11 +123,12 @@ class Article extends BaseController
*/
// 热议文章
$artHot = ArticleModel::withCount('comments')->where('status',1)->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
$artHot = ArticleModel::field('id,title')->withCount('comments')->where('status',1)->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
//文章广告
$ad_article = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',4)->whereTime('slid_over','>=',time())->select();
//通用右栏
$ad_comm = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',2)->whereTime('slid_over','>=',time())->select();
View::assign(['article'=>$article,'artHot'=>$artHot,'ad_art'=>$ad_article,'ad_comm'=>$ad_comm]);
return View::fetch();
}
@ -152,7 +189,7 @@ class Article extends BaseController
//echo '<script>alert("'.$res.'");location.back()</script>';
return $this->error($validate->getError());
} else {
$article = new \app\common\model\Article;
$article = new \app\common\model\Article();
$result = $article->edit($data);
if($result == 1) {
return json(['code'=>1,'msg'=>'修改成功','url'=>'/'.app('http')->getName().'/jie/'.$aid.'.html']);

View File

@ -15,31 +15,41 @@ class Index extends BaseController
{
public function index()
{
$types = input('type');
//幻灯
$sliders = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',1)->whereTime('slid_over','>=',time())->select();
//置顶文章
$artTop = Article::where(['is_top'=>1,'status'=>1,'delete_time'=>0])->with([
$artTop = Article::field('id,title,cate_id,user_id')->where(['is_top'=>1,'status'=>1,'delete_time'=>0])->with([
'cate' => function($query){
$query->where('delete_time',0);
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->with(['user'])->withCount(['comments'])->order('create_time','desc')->limit(5)->select();
])->withCount(['comments'])->order('create_time','desc')->limit(5)->withCache(30)->select();
//查询首页文章显示15条
$types = input('type');
$artList = Article::withCount(['user','cate','comments'])->where(['status'=>1,'delete_time'=>0])->order('create_time','desc')->limit(15)->select();
//首页文章显示15条
$artList = Article::field('id,title,cate_id,user_id')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
},
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where(['status'=>1,'delete_time'=>0])->order('create_time','desc')->limit(15)->withCache(30)->select();
//热议文章
$artHot = Article::withCount('comments')->field('title,comments_count')->where(['status'=>1,'delete_time'=>0])->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
$artHot = Article::field('id,title')->withCount('comments')->where(['status'=>1,'delete_time'=>0])->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select();
//首页赞助
$ad_index = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',3)->whereTime('slid_over','>=',time())->select();
$ad_index = Db::name('slider')->where(['slid_status'=>1,'delete_time'=>0,'slid_type'=>3])->whereTime('slid_over','>=',time())->select();
//首页右栏
$ad_comm = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',2)->whereTime('slid_over','>=',time())->select();
$ad_comm = Db::name('slider')->where(['slid_status'=>1,'delete_time'=>0,'slid_type'=>2])->whereTime('slid_over','>=',time())->select();
//友情链接
$friend_links = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',6)->whereTime('slid_over','>=',time())->field('slid_name,slid_href')->select();
$friend_links = Db::name('slider')->where(['slid_status'=>1,'delete_time'=>0,'slid_type'=>6])->whereTime('slid_over','>=',time())->field('slid_name,slid_href')->select();
$vs = [
'slider' => $sliders,

View File

@ -56,7 +56,7 @@ class Login extends BaseController
$user = new \app\common\model\User();
$res = $user->login($data);
if ($res == 1) {
return json(['code'=>'1','msg'=>'登陆成功','url'=>'/index/index/index']);
return json(['code'=>'1','msg'=>'登陆成功','url'=>'/']);
} else {
return json(['code'=>'0','msg'=>$res]);
}
@ -83,7 +83,7 @@ class Login extends BaseController
$result = $user->reg($data);
if ($result == 1) {
$res = ['code'=>1,'msg'=>'注册成功','url'=>'/index/login/index'];
$res = ['code'=>1,'msg'=>'注册成功','url'=>'/'];
}else {
$res = ['code'=>0,'msg'=>$result];
}

View File

@ -8,11 +8,11 @@ return [
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'taotao',
'database' => '',
// 用户名
'username' => 'root',
'username' => '',
// 密码
'password' => 'root',
'password' => '',
// 端口
'hostport' => '3306',
// 数据库连接参数

View File

@ -127,8 +127,11 @@ php;
//管理员
$table_admin = $data['DB_PREFIX'] . "admin";
$table_user = $data['DB_PREFIX'] . "user";
$sql_admin = "UPDATE $table_admin SET username = '{$username}', password = '{$pass}', status=1,create_time = '{$create_time}' WHERE id = 1";
$sql_user = "UPDATE $table_user SET name = '{$username}', password = '{$pass}', status=1, auth=1, create_time = '{$create_time}' WHERE id = 1";
$db->execute($sql_admin);
$db->execute($sql_user);
Db::getConnection()->close();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,11 +16,11 @@ return [
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'taotao',
'database' => '',
// 用户名
'username' => 'root',
'username' => '',
// 密码
'password' => 'root',
'password' => '',
// 端口
'hostport' => '3306',
// 数据库连接参数

545
data/taoler.sql Normal file

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
</head>
<body {if($Request.url=='/admin/index/index')}class="layui-layout-body"{/if}>
{block name="body"}内容{/block}
<script src="/static/res/mods/jquery.min.js" charset="utf-8"></script>
<!--script src="/static/res/mods/jquery.min.js" charset="utf-8"></script-->
<script src="/static/admin/layui/layui.js"></script>
{block name="js"}js文件{/block}
</body>

View File

@ -32,7 +32,7 @@
<div class="layui-form-item">
<label class="layui-form-label">缓存时间</label>
<div class="layui-input-inline" style="width: 80px;">
<input type="text" name="cache" lay-verify="number" value="0" class="layui-input">
<input type="text" name="cache" lay-verify="number" value="{$sysInfo.cache}" class="layui-input">
</div>
<div class="layui-input-inline layui-input-company">分钟</div>
<div class="layui-form-mid layui-word-aux">本地开发一般推荐设置为 0线上环境建议设置为 10。</div>
@ -40,7 +40,7 @@
<div class="layui-form-item">
<label class="layui-form-label">最大文件上传</label>
<div class="layui-input-inline" style="width: 80px;">
<input type="text" name="cache" lay-verify="number" value="2048" class="layui-input">
<input type="text" name="upsize" lay-verify="number" value="{$sysInfo.upsize}" class="layui-input">
</div>
<div class="layui-input-inline layui-input-company">KB</div>
<div class="layui-form-mid layui-word-aux">提示1 M = 1024 KB</div>
@ -48,7 +48,7 @@
<div class="layui-form-item">
<label class="layui-form-label">上传文件类型</label>
<div class="layui-input-block">
<input type="text" name="cache" value="png|gif|jpg|jpeg|zip|rar" class="layui-input">
<input type="text" name="uptype" value="{$sysInfo.uptype}r" class="layui-input">
</div>
</div>
@ -115,7 +115,7 @@
,url: '/admin/set/upload'
,auto: false
,exts: 'jpg|png|gif|bmp|jpeg'
,size: 100
,size: 1000
//,multiple: true
,bindAction: '#logo-upload-button'
,done: function(res){

View File

@ -16,7 +16,7 @@
<div class="layui-form-item">
<label class="layui-form-label">我的角色</label>
<div class="layui-input-inline">
<input type="text" name="auth_group_id" disabled value="{$admin.auth_group_id}" readonly class="layui-input disabled">
<input type="text" name="auth_group_id" disabled value="{$admin.authGroup.title}" readonly class="layui-input disabled">
</div>
<div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
</div>

View File

@ -79,7 +79,7 @@
,layer = layui.layer
,form = layui.form
,upload = layui.upload;
var layerload = layer.load();
//手动更新,选完文件后不自动上传
upload.render({
@ -93,7 +93,7 @@
//,multiple: true
,bindAction: '#upgrade-sys-button'
,done: function(res){
//console.log(res)
//layer.close(layerload); //关闭loading
if(res.code == 1){
layer.msg(res.msg,{
icon:6,

View File

@ -227,11 +227,8 @@
<script>
$(function() {
$('#recomment').click(function (){
var user = '{:session('user_id')}';
if (user = ''){
return false;
}
if (user) {
var uid = "{:session('user_id')}";
if (uid != '') {
$.ajax({
type:"post",
url:"{:url('article/comment')}",
@ -261,7 +258,7 @@ $(function() {
icon:5,
time:2000
},function () {
location.href = "{:url('user/login')}";
location.href = "{:url('login/index')}";
});
}

1
view/index/public/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
user-nav.html

View File

@ -16,6 +16,12 @@
<i class="layui-icon">&#xe705;</i>
我的帖子
</a>
</li>
<li class="layui-nav-item {if($Request.action=='key')}layui-this{/if}">
<a href="{:url('api/key')}">
<i class="layui-icon">&#xe670;</i>
我的授权
</a>
</li>
<!--li class="layui-nav-item {if($Request.action=='message')}layui-this{/if}">
<a href="{:url('index/user/message')}">
@ -23,12 +29,13 @@
我的消息
</a>
</li-->
<li class="layui-nav-item " >
<!--li class="layui-nav-item " >
<a href="{:url('user/home',['id'=>session('user_id')])}">
<i class="layui-icon">&#xe609;</i>
我的主页
</a>
</li>
</li-->
</ul>
<div class="site-tree-mobile layui-hide">

View File

@ -10,7 +10,7 @@
<p>4、尽管程序在发布前已经过安全测试但仍不能完全保证漏洞的存在和丢失数据的风险作者不承担商业风险。</p>
<p>5、本程序版权归开发者所有在未经过作者同意的情况下严禁转售、赠送他人。</p>
<p>6、您可以在完全遵守本许可协议的基础上免费下载安装使用商业应用请联系作者授权。</p>
<p>7、无论您是个人或组织、盈利与否、用途如何包括以学习和研究为目的均需仔细阅读本协议包括免除或者限制开发团队责任的免责条款及对您的权利限制。请您审阅并接受或不接受本服务条款。如您不同意本服务条款及/或LaySNS开发团队随时对其的修改,您应不使用或主动取消产品。否则,您的任何对产品中的相关服务的注册、登陆、下载、查看等使用行为将被视为您对本服务条款全部的完全接受,包括接受对服务条款随时所做的任何修改。</p>
<p>7、无论您是个人或组织、盈利与否、用途如何包括以学习和研究为目的均需仔细阅读本协议包括免除或者限制开发团队责任的免责条款及对您的权利限制。请您审阅并接受或不接受本服务条款。如您不同意本服务条款及/或随时对其的修改,您应不使用或主动取消产品。否则,您的任何对产品中的相关服务的注册、登陆、下载、查看等使用行为将被视为您对本服务条款全部的完全接受,包括接受对服务条款随时所做的任何修改。</p>
<p>8、本协议一旦发生变更, Tao社区开发团队将在网页上公布修改内容。修改后的服务条款一旦在网站管理后台上公布即有效代替原来的服务条款。如果您选择接受本条款即表示您同意接受协议各项条件的约束。如果您不同意本服务条款则不能获得使用本服务的权利。您若有违反本条款规定TaoLer有权随时中止或终止您对本程序的使用资格并保留追究相关法律责任的权利。</p>
<p>9、在理解、同意、并遵守本协议的全部条款后方可开始使用本程序。本许可协议条款的解释效力及纠纷的解决适用于中华人民共和国大陆法律。</p>
<p>10、您使用本系统需要遵循许可协议一旦安装表示您已接受该系统各项条款。</p>