diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php
index 06db28f..3e9b65f 100644
--- a/app/admin/controller/Index.php
+++ b/app/admin/controller/Index.php
@@ -60,7 +60,12 @@ class Index extends AdminController
{
//版本检测
$verCheck = Api::urlPost($this->sys['upcheck_url'],['pn'=>$this->pn,'ver'=>$this->sys_version]);
- $versions = $verCheck->code ? "有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}" : $verCheck->msg;
+ if($verCheck->code !== -1){
+ $versions = $verCheck->code ? "有{$verCheck->up_num}个版本需更新,当前可更新至{$verCheck->version}" : $verCheck->msg;
+ View::assign('versions',$versions);
+ }else{
+ View::assign('versions','版本检测暂时不可服务');
+ }
//评论、帖子状态
$comm = Db::name('comment')->field('id')->where(['delete_time'=>0,'status'=>0])->select();
@@ -92,7 +97,7 @@ class Index extends AdminController
}
- View::assign(['versions'=>$versions,'comms'=>$comms,'forums'=>$forums,'monthTime'=>$monthTime,'monthUserCount'=>Cache::get('monthUserCount')]);
+ View::assign(['comms'=>$comms,'forums'=>$forums,'monthTime'=>$monthTime,'monthUserCount'=>Cache::get('monthUserCount')]);
return View::fetch();
}
diff --git a/app/admin/controller/Set.php b/app/admin/controller/Set.php
index 0682683..a9632fb 100644
--- a/app/admin/controller/Set.php
+++ b/app/admin/controller/Set.php
@@ -11,6 +11,7 @@ use think\facade\Config;
use think\exception\ValidateException;
use taoler\com\Files;
use taoler\com\Api;
+use app\common\lib\SetConf;
class Set extends AdminController
{
@@ -66,6 +67,31 @@ class Set extends AdminController
}
}
}
+ /**配置设置
+ * parem $id
+ */
+ public function config()
+ {
+ $conf = Config::get('taoler.config');
+ if(Request::isPost()){
+ $data = Request::param();
+ foreach($conf as $c=>$f){
+
+ if(array_key_exists($c,$data)){
+ $conf[$c] = (int) $data[$c];
+ }else{
+ $conf[$c] = 0;
+ }
+ }
+
+ $setConf = new SetConf;
+ $value = [
+ 'config'=>$conf
+ ];
+ $upRes = $setConf->setConfig('taoler',$value);
+ return $upRes;
+ }
+ }
//上传logo
public function upload()
diff --git a/app/admin/view/set/system/website.html b/app/admin/view/set/system/website.html
index 8e03c77..60aba3d 100644
--- a/app/admin/view/set/system/website.html
+++ b/app/admin/view/set/system/website.html
@@ -11,6 +11,7 @@
+
+
@@ -219,6 +244,15 @@
}
}
});
+
+ form.on('submit(set_system_config)', function(data){
+ console.log(data);
+ var field = data.field;
+ $.post("{:url('admin/set/config')}",field);
+
+ layer.msg(JSON.stringify(data.field));
+ return false;
+ });
});
diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php
index 53a97dc..4ae6189 100644
--- a/app/common/controller/BaseController.php
+++ b/app/common/controller/BaseController.php
@@ -23,7 +23,7 @@ class BaseController extends BaseCtrl
$this->showSystem();
//显示分类导航
$this->showNav();
- $this->showUser();
+ $this->showUser($this->uid);
}
@@ -63,9 +63,8 @@ class BaseController extends BaseCtrl
}
//显示当前登录用户
- protected function showUser()
+ protected function showUser($id)
{
- $id = $this->uid;
$user = Cache::get('user'.$id);
if(!$user){
//1.查询用户
@@ -75,6 +74,7 @@ class BaseController extends BaseCtrl
//2.将User变量赋给模板 公共模板nav.html
View::assign('user',$user);
+ return $user;
}
//显示网站设置
diff --git a/app/common/lib/SetConf.php b/app/common/lib/SetConf.php
index 2893e66..4a13d48 100644
--- a/app/common/lib/SetConf.php
+++ b/app/common/lib/SetConf.php
@@ -19,14 +19,35 @@ class SetConf
{
if (is_array($data)){
$fileurl = app()->getConfigPath() . $file.".php";
- //var_dump( $fileurl);
$string = file_get_contents($fileurl); //加载配置文件
foreach ($data as $key => $value) {
- $pats = '/\'' . $key . '\'(.*?)\',/';
- $reps = "'". $key. "'". " => " . "'".$value ."',";
- $string = preg_replace($pats, $reps, $string); // 正则查找然后替换
+ if(is_array($value)){//二维数组
+ foreach ($value as $k => $v) {
+ if(is_int($v)){//数字类型
+ $pats = '/\'' . $k . '\'(.*?),/';
+ $reps = "'". $k. "'". " => " . $v .",";
+ //halt($reps);
+ }else{//字符类型
+ $pats = '/\'' . $k . '\'(.*?)\',/';
+ $reps = "'". $k. "'". " => " . "'".$v ."',";
+ }
+
+ $string = preg_replace($pats, $reps, $string); // 正则查找然后替换
+ }
+
+ }else{//一维数组
+
+ if(is_int($value)){//数字类型
+ $pats = '/\'' . $key . '\'(.*?),/';
+ $reps = "'". $key. "'". " => " . "".$value .",";
+ }else{//字符类型
+ $pats = '/\'' . $key . '\'(.*?)\',/';
+ $reps = "'". $key. "'". " => " . "'".$value ."',";
+ }
+
+ $string = preg_replace($pats, $reps, $string); // 正则查找然后替换
+ }
}
-
try {
file_put_contents($fileurl, $string); // 写入配置文件
}
diff --git a/app/common/model/Article.php b/app/common/model/Article.php
index f7506c6..77611c4 100644
--- a/app/common/model/Article.php
+++ b/app/common/model/Article.php
@@ -96,7 +96,7 @@ class Article extends Model
{
$artTop = Cache::get('arttop');
if (!$artTop) {
- $artTop = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,pv,jie,upzip,has_img,has_video,has_audio')->where(['is_top' => 1, 'status' => 1, 'delete_time' => 0])->with([
+ $artTop = $this::field('id,title,title_color,cate_id,user_id,create_time,is_top,pv,jie,upzip,has_img,has_video,has_audio')->where(['is_top' => 1, 'status' => 1])->with([
'cate' => function ($query) {
$query->where('delete_time', 0)->field('id,catename,ename');
},
diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php
index ffdb25e..eb0318a 100644
--- a/app/index/controller/Article.php
+++ b/app/index/controller/Article.php
@@ -130,7 +130,7 @@ class Article extends BaseController
$data = Request::only(['content','article_id','user_id']);
$sendId = $data['user_id'];
if(empty($data['content'])){
- return json(['code'=>0, 'msg'=>'评论不能为空!']);
+ return json(['code'=>0, 'msg'=>'评论不能为空!']);
}
//用户留言存入数据库
@@ -150,7 +150,7 @@ class Article extends BaseController
}
$data = ['title'=>$title,'content'=>'评论通知','link'=>$link,'user_id'=>$sendId,'type'=>2]; //type=2为评论留言
Message::sendMsg($sendId,$receveId,$data);
-
+ if(Config::get('taoler.config.email_notice')) mailto($this->showUser(1)['email'],'评论审核通知','Hi亲爱的管理员:用户'.$this->showUser($this->uid)['name'].'刚刚对 '.$title.' 发表了评论,请尽快处理。');
$res = ['code'=>0, 'msg'=>'留言成功'];
} else {
$res = ['code'=>-1, 'msg'=>'留言失败'];
@@ -184,6 +184,7 @@ class Article extends BaseController
$link = (string)url('article/detail', ['id' => $aid]);
//清除文章tag缓存
Cache::tag('tagArtDetail')->clear();
+ if(Config::get('taoler.config.email_notice')) mailto($this->showUser(1)['email'],'发帖审核通知','Hi亲爱的管理员:用户'.$this->showUser($this->uid)['name'].'刚刚发表了 '.$data['title'].' 新的帖子,请尽快处理。');
$res = Msgres::success('add_success', $link);
} else {
$res = Msgres::error('add_error');
diff --git a/app/index/controller/Login.php b/app/index/controller/Login.php
index b84e0ff..ec4f49a 100644
--- a/app/index/controller/Login.php
+++ b/app/index/controller/Login.php
@@ -11,6 +11,7 @@ use think\facade\Session;
use think\facade\Cookie;
use think\facade\Cache;
use think\facade\View;
+use think\facade\Config;
use app\common\model\User;
class Login extends BaseController
@@ -105,6 +106,7 @@ class Login extends BaseController
if ($result == 1) {
$res = ['code'=>0,'msg'=>'注册成功','url'=>(string) url('login/index')];
+ if(Config::get('taoler.config.email_notice')) mailto($this->showUser(1)['email'],'注册新用户通知','Hi亲爱的管理员:新用户 '.$data['name'].' 刚刚注册了新的账号,请尽快处理。');
}else {
$res = ['code'=>-1,'msg'=>$result];
}
diff --git a/config/taoler.php b/config/taoler.php
index c99da76..e01681c 100644
--- a/config/taoler.php
+++ b/config/taoler.php
@@ -7,9 +7,16 @@ return [
//应用名,此项不可更改
'appname' => 'TaoLer',
//版本配置
- 'version' => '1.7.21',
+ 'version' => '1.7.22',
//加盐
'salt' => 'taoler',
//数据库备份目录
- 'databasebackdir' => app()->getRootPath() .'data/'
+ 'databasebackdir' => app()->getRootPath() .'data/',
+ //配置
+ 'config' =>[
+ 'area_show' => 1,
+ 'email_notice' => 1,
+ ]
+
+
];
\ No newline at end of file
diff --git a/extend/taoler/com/Api.php b/extend/taoler/com/Api.php
index c9c9853..10400b5 100644
--- a/extend/taoler/com/Api.php
+++ b/extend/taoler/com/Api.php
@@ -16,7 +16,7 @@ class Api
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 设置超时限制 防止死循环
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 设置超时限制 防止死循环
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$res = curl_exec($ch);
diff --git a/view/taoler/index/article/cate.html b/view/taoler/index/article/cate.html
index 32a9c56..57d8db4 100644
--- a/view/taoler/index/article/cate.html
+++ b/view/taoler/index/article/cate.html
@@ -24,7 +24,7 @@