diff --git a/LICENSE.txt b/LICENSE.txt index 574a39c..af94c0b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -30,3 +30,8 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +勾股CMS遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2021 by gouguCMS (https://www.gougucms.com) +All rights reserved。 diff --git a/README.md b/README.md index 02b59a7..672efc4 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,23 @@ # 勾股CMS -## 链接 +[](https://gitee.com/gougucms/gougucms/) +[](https://gitee.com/gougucms/gougucms/) +[](https://gitee.com/gougucms/gougucms/stargazers) +[](https://gitee.com/gougucms/gougucms/members) + +### 链接 - 勾股CMS:https://www.gougucms.com - gitee:https://gitee.com/gougucms/gougucms.git -## 相关链接 +### 相关链接 - [开源项目系列之勾股CMS](https://www.gougucms.com) - [开源项目系列之勾股博客](https://blog.gougucms.com) ### 介绍 -1. 勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能极速后台开发框架。 -2. 系统后台各管理模块,一目了然,操作简单;通用型的后台权限管理框架,前后台用户的操作记录覆盖跟踪,紧随潮流、极低门槛、开箱即用。 -3. 系统易于功能扩展,代码维护,方便二次开发,帮助开发者简单高效降低二次开发的成本,满足专注业务深度开发的需求。 +- 勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能极速后台开发框架。 +- 系统后台各管理模块,一目了然,操作简单;通用型的后台权限管理框架,前后台用户的操作记录覆盖跟踪,紧随潮流、极低门槛、开箱即用。 +- 系统易于功能扩展,代码维护,方便二次开发,帮助开发者简单高效降低二次开发的成本,满足专注业务深度开发的需求。 +- 可去前台版权,真正意义的永久免费,可商用的后台系统。 ### 目录结构 @@ -77,14 +83,16 @@ www 系统部署目录(或者子目录) ### 安装教程 -1. 勾股CMS推荐你使用阿里云和腾讯云服务器 +一、勾股CMS推荐你使用阿里云和腾讯云服务器。 阿里云服务器官方长期折扣优惠地址: (https://www.aliyun.com/activity/daily/bestoffer?userCode=dmrcx154) 腾讯云服务器官方长期折扣优惠地址: (https://curl.qcloud.com/PPEgI0oV) -2. 服务器运行环境要求 +二、服务器运行环境要求。 + +~~~ PHP >= 7.1 Mysql >= 5.5.0 (需支持innodb引擎) Apache 或 Nginx @@ -92,41 +100,56 @@ www 系统部署目录(或者子目录) MBstring PHP Extension CURL PHP Extension Composer (用于管理第三方扩展包) +~~~ -3. 完整包安装 +三、系统安装 - 前往官网下载页面 (https://www.gougucms.com/) 下载完整包解压到你的项目目录 - 添加站点并绑定域名到项目中的public目录为运行目录 - 访问 http://www.yoursite.com/install/index 进行安装 +**方式一:完整包安装** -4. 命令行安装 + 第一步:前往官网下载页面 (https://www.gougucms.com) 下载完整包解压到你的项目目录 - 强烈建议使用命令行安装,因为采用命令行安装的方式可以和勾股CMS随时保持更新同步。使用命令行安装请提前准备好Git、Composer、Linux下勾股CMS的安装请使用以下命令进行安装。 - - 克隆勾股CMS到你本地 + 第二步:添加虚拟主机并绑定到项目的public目录 + + 第三步:访问 http://www.yoursite.com/install/index 进行安装 + + +**方式二:命令行安装(推荐)** + +推荐使用命令行安装,因为采用命令行安装的方式可以和勾股CMS随时保持更新同步。使用命令行安装请提前准备好Git、Composer。 + +Linux下,勾股CMS的安装请使用以下命令进行安装。 + +第一步:克隆勾股CMS到你本地 git clone https://gitee.com/gougucms/gougucms.git - - 进入目录 + +第二步:进入目录 cd gougucms - 下载PHP依赖包(composer的版本最好是2.0.8版本,否则可能下载PHP依赖包失败,composer降级:composer self-update 2.0.8) +第三步:下载PHP依赖包 composer install + +注意:composer的版本最好是2.0.8版本,否则可能下载PHP依赖包失败,composer降级:composer self-update 2.0.8 +第四步:添加虚拟主机并绑定到项目的public目录 - 添加虚拟主机并绑定到项目的public目录 - - 访问 http://www.yoursite.com/install/index 进行安装 +第五步:访问 http://www.yoursite.com/install/index 进行安装 ### 常见问题 1. 安装失败,可能存在php配置文件禁止了putenv 和 proc_open函数。解决方法,查找php.ini文件位置,打开php.ini,搜索 disable_functions 项,看是否禁用了putenv 和 proc_open函数。如果在禁用列表里,移除putenv proc_open然后退出,重启php即可。 -2. 如果安装后打开页面提示404错误,请检查服务器伪静态配置,宝塔伪静态请配置使用thinkphp规则 -3. 如果提示当前权限不足,无法写入配置文件config/database.php,请检查database.php是否可读,还有可能是当前安装程序无法访问父目录,请检查PHP的open_basedir配置 -4. 如果composer install失败,请尝试在命令行进行切换配置到国内源,命令如下composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ -5. 如果composer install失败,请尝试composer降级:composer self-update 2.0.8 -6. 访问 http://www.yoursite.com/install/index,请注意查看伪静态请配置是否设置了thinkphp规则 -7. 遇到问题请到QQ群:24641076 反馈 + +2. 如果安装后打开页面提示404错误,请检查服务器伪静态配置,如果是宝塔面板,网站伪静态请配置使用thinkphp规则。 + +3. 如果提示当前权限不足,无法写入配置文件config/database.php,请检查database.php是否可读,还有可能是当前安装程序无法访问父目录,请检查PHP的open_basedir配置。 + +4. 如果composer install失败,请尝试在命令行进行切换配置到国内源,命令如下composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/。 + +5. 如果composer install失败,请尝试composer降级:composer self-update 2.0.8。 + +6. 访问 http://www.yoursite.com/install/index ,请注意查看伪静态请配置是否设置了thinkphp规则。 + +7. 遇到问题请到QQ群:24641076 反馈。 ### 截图预览  diff --git a/app/admin/BaseController.php b/app/admin/BaseController.php index c8bda54..1170d13 100644 --- a/app/admin/BaseController.php +++ b/app/admin/BaseController.php @@ -1,10 +1,17 @@ app = $app; + $this->app = $app; $this->request = $this->app->request; // 控制器初始化 @@ -55,11 +62,11 @@ abstract class BaseController $this->param = $this->request->param(); } - // - // 以下为新增,为了使用旧版的 success error redirect 跳转 start - // - - /** + // + // 以下为新增,为了使用旧版的 success error redirect 跳转 start + // + + /** * 操作成功跳转的快捷方法 * @access protected * @param mixed $msg 提示信息 @@ -79,14 +86,14 @@ abstract class BaseController $result = [ 'code' => 1, - 'msg' => $msg, + 'msg' => $msg, 'data' => $data, - 'url' => $url, + 'url' => $url, 'wait' => $wait, ]; $type = $this->getResponseType(); - if ($type == 'html'){ + if ($type == 'html') { $response = view($this->app->config->get('app.dispatch_success_tmpl'), $result); } else if ($type == 'json') { $response = json($result); @@ -114,14 +121,14 @@ abstract class BaseController $result = [ 'code' => 0, - 'msg' => $msg, + 'msg' => $msg, 'data' => $data, - 'url' => $url, + 'url' => $url, 'wait' => $wait, ]; $type = $this->getResponseType(); - if ($type == 'html'){ + if ($type == 'html') { $response = view($this->app->config->get('app.dispatch_error_tmpl'), $result); } else if ($type == 'json') { $response = json($result); @@ -143,7 +150,7 @@ abstract class BaseController $response = Response::create($url, 'redirect'); if (is_integer($params)) { - $code = $params; + $code = $params; $params = []; } @@ -161,8 +168,8 @@ abstract class BaseController { return $this->request->isJson() || $this->request->isAjax() ? 'json' : 'html'; } - - // - // 以上为新增,为了使用旧版的 success error redirect 跳转 end - // + + // + // 以上为新增,为了使用旧版的 success error redirect 跳转 end + // } diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index e8acbd6..08bdea3 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -1,4 +1,10 @@ last_login_time = empty($item->last_login_time) ? '-' : date('Y-m-d H:i', $item->last_login_time); }); return table_assign(1, '', $admin); - } - else{ + } else { return view(); - } + } } //添加 @@ -254,9 +259,8 @@ class Admin extends BaseController $content->offsetSet($k, $data); } return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } } diff --git a/app/admin/controller/Api.php b/app/admin/controller/Api.php index 3a43f2c..5828213 100644 --- a/app/admin/controller/Api.php +++ b/app/admin/controller/Api.php @@ -1,4 +1,10 @@ where('name', 'email') - ->find(); + ->where('name', 'email') + ->find(); $config = unserialize($email_config['content']); $content = $config['template']; //所有项目必须填写 @@ -224,7 +231,7 @@ class Api extends BaseController return to_assign(0, '请完善邮件配置信息!'); } - $send = send_email($sender, '测试邮件',$content); + $send = send_email($sender, '测试邮件', $content); if ($send) { return to_assign(1, '邮件发送成功!'); } else { @@ -240,7 +247,7 @@ class Api extends BaseController ->order('id desc') ->limit(10) ->select()->toArray(); - $res['data']=$content; + $res['data'] = $content; return table_assign(1, '', $res); } @@ -252,10 +259,10 @@ class Api extends BaseController ->order('id desc') ->limit(10) ->select()->toArray(); - foreach($list as $key=>$val){ - $list[$key]['last_login_time']=date('Y-m-d :h:m:s',$val['last_login_time']); + foreach ($list as $key => $val) { + $list[$key]['last_login_time'] = date('Y-m-d :h:m:s', $val['last_login_time']); } - $res['data']=$list; + $res['data'] = $list; return table_assign(1, '', $res); } @@ -270,26 +277,26 @@ class Api extends BaseController ->order('a.id desc') ->limit(10) ->select()->toArray(); - foreach($list as $key=>$val){ - $list[$key]['create_time']=date('Y-m-d :H:i',$val['create_time']); - } - $res['data']=$list; - return table_assign(1, '', $res); + foreach ($list as $key => $val) { + $list[$key]['create_time'] = date('Y-m-d :H:i', $val['create_time']); + } + $res['data'] = $list; + return table_assign(1, '', $res); } //系统操作日志 public function log_list() - { - return view('admin/log_list'); + { + return view('admin/log_list'); } - - //获取系统操作日志 + + //获取系统操作日志 public function get_log_list() - { - $param=get_params(); + { + $param = get_params(); $log = new AdminLog(); $content = $log->get_log_list($param); - return table_assign(1,'',$content); - } + return table_assign(1, '', $content); + } } diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index b1ee95d..116c0b3 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -1,4 +1,10 @@ =', 0]; - $rows = empty($param['limit']) ? get_config(app.page_size) : $param['limit']; - $content = Db::name('config') + $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $content = Db::name('Config') ->where($where) ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } //添加 @@ -33,7 +38,7 @@ class Conf extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); if ($id > 0) { - $config = Db::name('config')->where(['id' => $id])->find(); + $config = Db::name('Config')->where(['id' => $id])->find(); View::assign('config', $config); } View::assign('id', $id); @@ -54,12 +59,18 @@ class Conf extends BaseController if (!empty($param['id']) && $param['id'] > 0) { $param['update_time'] = time(); $res = Db::name('config')->strict(false)->field(true)->update($param); - if($res) add_log('edit',$param['id'],$param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); } else { $param['create_time'] = time(); - $insertId = Db::name('config')->strict(false)->field(true)->insertGetId($param); - if($insertId) add_log('add',$insertId,$param); + $insertId = Db::name('Config')->strict(false)->field(true)->insertGetId($param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); } } @@ -71,8 +82,8 @@ class Conf extends BaseController $data['status'] = '-1'; $data['id'] = $id; $data['update_time'] = time(); - if (Db::name('config')->update($data) !== false) { - add_log('delete',$id,$data); + if (Db::name('Config')->update($data) !== false) { + add_log('delete', $id, $data); return to_assign(1, "删除成功"); } else { return to_assign(0, "删除失败"); @@ -83,12 +94,12 @@ class Conf extends BaseController public function edit() { $id = empty(get_params('id')) ? 0 : get_params('id'); - $conf = Db::name('config')->where('id',$id)->find(); - $config=[]; - if($conf['content']){ + $conf = Db::name('Config')->where('id', $id)->find(); + $config = []; + if ($conf['content']) { $config = unserialize($conf['content']); } - return view($conf['name'], ['id'=>$id,'config' => $config]); + return view($conf['name'], ['id' => $id, 'config' => $config]); } //提交添加 public function conf_submit() @@ -98,10 +109,12 @@ class Conf extends BaseController $data['content'] = serialize($param); $data['update_time'] = time(); $data['id'] = $param['id']; - $res = Db::name('config')->strict(false)->field(true)->update($data); - $conf = Db::name('config')->where('id',$param['id'])->find(); + $res = Db::name('Config')->strict(false)->field(true)->update($data); + $conf = Db::name('Config')->where('id', $param['id'])->find(); clear_cache('system_config' . $conf['name']); - if($res) add_log('edit',$param['id'],$param); + if ($res) { + add_log('edit', $param['id'], $param); + } return to_assign(); } } diff --git a/app/admin/controller/Database.php b/app/admin/controller/Database.php index 660a335..100a7d1 100644 --- a/app/admin/controller/Database.php +++ b/app/admin/controller/Database.php @@ -1,4 +1,10 @@ config=array( - 'path' => './backup/', // 数据库备份路径 - 'part' => 20971520, // 数据库备份卷大小 - 'compress' => 0, // 数据库备份文件是否启用压缩 0不压缩 1 压缩 - 'level' => 9 // 数据库备份文件压缩级别 1普通 4 一般 9最高 + $this->config = array( + 'path' => './backup/', // 数据库备份路径 + 'part' => 20971520, // 数据库备份卷大小 + 'compress' => 0, // 数据库备份文件是否启用压缩 0不压缩 1 压缩 + 'level' => 9, // 数据库备份文件压缩级别 1普通 4 一般 9最高 ); $this->db = new Backup($this->config); } @@ -36,9 +43,9 @@ class Database extends BaseController $list[$k]['data_length'] = format_bytes($v['data_length']); } // 提示信息 - $dataTips = '数据库中共有 ' . count($list) . ' 张表,共计 ' . format_bytes($total) .'大小。'; - $data['data']=$list; - return table_assign(1, $dataTips,$data); + $dataTips = '数据库中共有 ' . count($list) . ' 张表,共计 ' . format_bytes($total) . '大小。'; + $data['data'] = $list; + return table_assign(1, $dataTips, $data); } return view(); } @@ -60,12 +67,13 @@ class Database extends BaseController } // 优化 - public function optimize() { + public function optimize() + { $tables = get_params('id'); if (empty($tables)) { - return to_assign(1,'请选择要优化的表!'); + return to_assign(1, '请选择要优化的表!'); } - $tables = explode(',',$tables); + $tables = explode(',', $tables); if ($this->db->optimize($tables)) { add_log('edit'); return to_assign(1, '数据表优化成功!'); @@ -75,12 +83,13 @@ class Database extends BaseController } // 修复 - public function repair() { + public function repair() + { $tables = get_params('id'); if (empty($tables)) { - return to_assign(0,'请选择要修复的表!'); + return to_assign(0, '请选择要修复的表!'); } - $tables = explode(',',$tables); + $tables = explode(',', $tables); if ($this->db->repair($tables)) { add_log('edit'); return to_assign(1, '数据表修复成功!'); @@ -89,24 +98,22 @@ class Database extends BaseController } } - // =========================== - // 还原列表 public function backuplist() { // 数据信息 - $list = $this->db->fileList(); + $list = $this->db->fileList(); $listNew = []; - $indx=0; + $indx = 0; foreach ($list as $k => $v) { $listNew[$indx]['time'] = $k; $listNew[$indx]['data'][] = $v; $indx++; - // $listNew[$k]['list'] = $list[$k]; + // $listNew[$k]['list'] = $list[$k]; } $list = $listNew; - array_multisort(array_column($list, 'time'), SORT_DESC, $list); - return view('',['list' => $list]); + array_multisort(array_column($list, 'time'), SORT_DESC, $list); + return view('', ['list' => $list]); } // 执行还原数据库操作 @@ -115,7 +122,7 @@ class Database extends BaseController $list = $this->db->getFile('timeverif', $id); $this->db->setFile($list)->import(1); add_log('save'); - return to_assign(1,'还原成功!'); + return to_assign(1, '还原成功!'); } // 下载 @@ -123,31 +130,31 @@ class Database extends BaseController { $file_name = $name; //得到文件名 header("Content-type:text/html;charset=utf-8"); - $file_name = iconv("utf-8","gb2312",$file_name); // 转换编码 - $file_sub_path = $this->config['path']; //确保文件在这个路径下面,换成你文件所在的路径 + $file_name = iconv("utf-8", "gb2312", $file_name); // 转换编码 + $file_sub_path = $this->config['path']; //确保文件在这个路径下面,换成你文件所在的路径 $file_path = $file_sub_path . $file_name; # 将反斜杠 替换成正斜杠 - $file_path = str_replace('\\','/',$file_path); - if(!file_exists($file_path)){ - $this->error($file_path);exit; //如果提示这个错误,很可能你的路径不对,可以打印$file_sub_path查看 + $file_path = str_replace('\\', '/', $file_path); + if (!file_exists($file_path)) { + $this->error($file_path);exit; //如果提示这个错误,很可能你的路径不对,可以打印$file_sub_path查看 } - $fp = fopen($file_path,"r"); // 以可读的方式打开这个文件 - # 如果出现图片无法打开,可以在这个位置添加函数 - ob_clean(); # 清空擦掉,输出缓冲区。 + $fp = fopen($file_path, "r"); // 以可读的方式打开这个文件 + # 如果出现图片无法打开,可以在这个位置添加函数 + ob_clean(); # 清空擦掉,输出缓冲区。 $file_size = filesize($file_path); //下载文件需要用到的头 Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); - Header("Accept-Length:".$file_size); - Header("Content-Disposition: attachment; filename = ". $file_name); + Header("Accept-Length:" . $file_size); + Header("Content-Disposition: attachment; filename = " . $file_name); $buffer = 1024000; $file_count = 0; - while(!feof($fp) && $file_count<$file_size){ - $file_con = fread($fp,$buffer); + while (!feof($fp) && $file_count < $file_size) { + $file_con = fread($fp, $buffer); $file_count += $buffer; echo $file_con; } - fclose($fp); //关闭这个打开的文件 + fclose($fp); //关闭这个打开的文件 } // 删除sql文件 @@ -160,15 +167,15 @@ class Database extends BaseController $this->db->delFile($v); } add_log('delete'); - return to_assign(1,"删除成功!"); + return to_assign(1, "删除成功!"); } if ($this->db->delFile($id)) { add_log('delete'); - return to_assign(1,"删除成功!"); + return to_assign(1, "删除成功!"); } else { return to_assign(0, "备份文件删除失败,请检查文件权限!"); } } } -} \ No newline at end of file +} diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 3e0e1ff..fae0e84 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -1,4 +1,10 @@ where('status','1')->count(); - $userCount=Db::name('user')->where('status','1')->count(); - $articleCount=Db::name('article')->where('status','1')->count(); - $install=false; + $adminCount = Db::name('Admin')->where('status', '1')->count(); + $userCount = Db::name('User')->where('status', '1')->count(); + $articleCount = Db::name('Article')->where('status', '1')->count(); + $install = false; if (file_exists(CMS_ROOT . 'app/install')) { - $install=true; + $install = true; } View::assign('adminCount', $adminCount); View::assign('userCount', $userCount); @@ -36,5 +42,5 @@ class Index extends BaseController { echo '错误'; } - + } diff --git a/app/admin/controller/Keywords.php b/app/admin/controller/Keywords.php index 775c5fb..eb5aec2 100644 --- a/app/admin/controller/Keywords.php +++ b/app/admin/controller/Keywords.php @@ -1,4 +1,10 @@ =', 0]; $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; @@ -26,10 +32,9 @@ class Keywords extends BaseController ->where($where) ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } //添加 @@ -58,7 +63,10 @@ class Keywords extends BaseController } $param['update_time'] = time(); $res = Db::name('Keywords')->strict(false)->field(true)->update($param); - if($res) add_log('edit',$param['id'],$param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); } else { try { @@ -69,7 +77,10 @@ class Keywords extends BaseController } $param['create_time'] = time(); $insertId = Db::name('Keywords')->strict(false)->field(true)->insertGetId($param); - if($insertId) add_log('add',$insertId,$param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); } } @@ -82,7 +93,7 @@ class Keywords extends BaseController $data['id'] = $id; $data['update_time'] = time(); if (Db::name('Keywords')->update($data) !== false) { - add_log('delete',$id,$data); + add_log('delete', $id, $data); return to_assign(1, "删除成功"); } else { return to_assign(0, "删除失败"); diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 59248f9..d7e9753 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -1,4 +1,10 @@ getError()); } - $admin = Db::name('admin')->where(['username' => $param['username']])->find(); + $admin = Db::name('Admin')->where(['username' => $param['username']])->find(); if (empty($admin)) { return to_assign(0, '用户名或密码错误'); } @@ -53,8 +59,8 @@ class Login $token = make_token(); set_cache($token, $admin, 7200); $admin['token'] = $token; - add_log('login',$admin['id'],$data); - return to_assign(1, '登录成功', ['uid'=>$admin['id']]); + add_log('login', $admin['id'], $data); + return to_assign(1, '登录成功', ['uid' => $admin['id']]); } //退出登录 diff --git a/app/admin/controller/Menu.php b/app/admin/controller/Menu.php index 54204c5..577a243 100644 --- a/app/admin/controller/Menu.php +++ b/app/admin/controller/Menu.php @@ -1,4 +1,9 @@ isAjax()) { $menu = Db::name('AdminMenu')->order('sort asc')->select(); return to_assign(0, '', $menu); - } - else{ + } else { return view(); - } + } } //添加菜单页面 diff --git a/app/admin/controller/Nav.php b/app/admin/controller/Nav.php index 9e1c351..28741cb 100644 --- a/app/admin/controller/Nav.php +++ b/app/admin/controller/Nav.php @@ -1,4 +1,9 @@ order('create_time asc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $nav); - } - else{ + } else { return view(); - } + } } //添加 @@ -38,7 +42,7 @@ class Nav extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); if ($id > 0) { - $nav = Db::name('nav')->where(['id' => $id])->find(); + $nav = Db::name('Nav')->where(['id' => $id])->find(); View::assign('nav', $nav); } View::assign('id', $id); @@ -63,7 +67,7 @@ class Nav extends BaseController ->update($param); // 删除导航缓存 clear_cache('homeNav'); - add_log('edit',$param['id'], $param); + add_log('edit', $param['id'], $param); return to_assign(); } else { try { @@ -75,7 +79,7 @@ class Nav extends BaseController $nid = NavList::strict(false)->field(true)->insertGetId($param); // 删除导航缓存 clear_cache('homeNav'); - add_log('add',$nid, $param); + add_log('add', $nid, $param); return to_assign(); } } @@ -95,7 +99,7 @@ class Nav extends BaseController return to_assign(1, '删除成功'); // 删除导航缓存 clear_cache('homeNav'); - add_log('delete',$id, []); + add_log('delete', $id, []); } else { return to_assign(0, '删除失败'); } @@ -108,16 +112,15 @@ class Nav extends BaseController if (request()->isAjax()) { $id = $param['id']; $navInfoList = Db::name('NavInfo') - ->where(['nav_id' => $id]) - ->order('sort asc') - ->select(); + ->where(['nav_id' => $id]) + ->order('sort asc') + ->select(); return to_assign(0, '', $navInfoList); - } - else{ + } else { return view('', [ 'nav_id' => $param['id'], ]); - } + } } @@ -152,7 +155,7 @@ class Nav extends BaseController NavInfo::strict(false)->field(true)->update($param); // 删除导航缓存 clear_cache('homeNav'); - add_log('edit',$param['id'], $param); + add_log('edit', $param['id'], $param); return to_assign(); } else { try { diff --git a/app/admin/controller/Role.php b/app/admin/controller/Role.php index 7aeda89..e2ad112 100644 --- a/app/admin/controller/Role.php +++ b/app/admin/controller/Role.php @@ -1,4 +1,10 @@ order('create_time asc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $group); - } - else{ + } else { return view(); - } + } } //添加&编辑 @@ -36,7 +41,7 @@ class Role extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); if ($id > 0) { - $role = Db::name('admin_group')->where(['id' => $id])->find(); + $role = Db::name('AdminGroup')->where(['id' => $id])->find(); View::assign('role', $role); } View::assign('id', $id); @@ -62,14 +67,14 @@ class Role extends BaseController } /* if (!empty($param['rules'])) { - $param['rules'] = implode(',', $param['rules']); + $param['rules'] = implode(',', $param['rules']); } if (!empty($param['menus'])) { - $param['menus'] = implode(',', $param['menus']); + $param['menus'] = implode(',', $param['menus']); } - */ - Db::name('admin_group')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); - add_log('edit',$param['id'],$param); + */ + Db::name('AdminGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); } else { try { validate(GroupCheck::class)->scene('add')->check($param); @@ -79,14 +84,14 @@ class Role extends BaseController } /* if (!empty($param['rules'])) { - $param['rules'] = implode(',', $param['rules']); + $param['rules'] = implode(',', $param['rules']); } if (!empty($param['menus'])) { - $param['menus'] = implode(',', $param['menus']); + $param['menus'] = implode(',', $param['menus']); } - */ - $gid = Db::name('admin_group')->strict(false)->field(true)->insertGetId($param); - add_log('add',$gid,$param); + */ + $gid = Db::name('AdminGroup')->strict(false)->field(true)->insertGetId($param); + add_log('add', $gid, $param); } //清除菜单\权限缓存 clear_cache('adminMenu'); @@ -103,7 +108,7 @@ class Role extends BaseController return to_assign(0, "该组是系统所有者,无法删除"); } if (Db::name('AdminGroup')->delete($id) !== false) { - add_log('delete',$id,[]); + add_log('delete', $id, []); return to_assign(1, "删除角色成功"); } else { return to_assign(0, "删除失败"); diff --git a/app/admin/controller/Rule.php b/app/admin/controller/Rule.php index fbbad36..552ddcb 100644 --- a/app/admin/controller/Rule.php +++ b/app/admin/controller/Rule.php @@ -1,4 +1,10 @@ isAjax()) { $rule = Db::name('adminRule')->order('create_time asc')->select(); return to_assign(0, '', $rule); - } - else{ + } else { return view(); } } diff --git a/app/admin/controller/Search.php b/app/admin/controller/Search.php index 5781cd7..f388bae 100644 --- a/app/admin/controller/Search.php +++ b/app/admin/controller/Search.php @@ -1,4 +1,10 @@ order('id desc') ->where($where) ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } //删除 diff --git a/app/admin/controller/Sitemap.php b/app/admin/controller/Sitemap.php index 4999384..c10f373 100644 --- a/app/admin/controller/Sitemap.php +++ b/app/admin/controller/Sitemap.php @@ -1,4 +1,10 @@ order('sort desc, id desc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $SitemapCate); - } - else{ + } else { return view(); - } + } } //添加 @@ -60,7 +65,10 @@ class Sitemap extends BaseController } $param['update_time'] = time(); $res = SitemapCate::where('id', $param['id'])->strict(false)->field(true)->update($param); - if($res) add_log('edit', $param['id'], $param); + if ($res) { + add_log('edit', $param['id'], $param); + } + // 删除菜单缓存 clear_cache('homeSitemap'); return to_assign(); @@ -73,7 +81,10 @@ class Sitemap extends BaseController } $param['create_time'] = time(); $sid = SitemapCate::strict(false)->field(true)->insertGetId($param); - if($sid) add_log('add', $sid, $param); + if ($sid) { + add_log('add', $sid, $param); + } + // 删除菜单缓存 clear_cache('homeSitemap'); return to_assign(); @@ -85,8 +96,8 @@ class Sitemap extends BaseController public function delete() { $id = get_params("id"); - $where[] = ['sitemap_cate_id','=',$id]; - $where[] = ['status','>=',0]; + $where[] = ['sitemap_cate_id', '=', $id]; + $where[] = ['status', '>=', 0]; $count = Db::name('Sitemap')->where($where)->count(); if ($count > 0) { return to_assign(0, '该分类下还有数据,无法删除'); @@ -106,21 +117,20 @@ class Sitemap extends BaseController public function sitemap_info() { $param = get_params(); - if (request()->isAjax()) { + if (request()->isAjax()) { $where = array(); - $where[] = ['sitemap_cate_id','=',$param['id']]; - $where[] = ['status','>=',0]; + $where[] = ['sitemap_cate_id', '=', $param['id']]; + $where[] = ['status', '>=', 0]; $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; $sitemap = SitemapInfo::where($where) ->order('sort desc, id desc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $sitemap); - } - else{ + } else { return view('', [ 'sitemap_cate_id' => $param['id'], ]); - } + } } //添加网站地图 @@ -152,7 +162,10 @@ class Sitemap extends BaseController $param['update_time'] = time(); $param['name'] = htmlspecialchars($param['name']); $res = SitemapInfo::where(['id' => $param['id']])->strict(false)->field(true)->update($param); - if($res) add_log('edit',$param['id'],$param); + if ($res) { + add_log('edit', $param['id'], $param); + } + // 删除导航缓存 clear_cache('homeSitemap'); return to_assign(); @@ -166,7 +179,10 @@ class Sitemap extends BaseController $param['name'] = htmlspecialchars($param['name']); $param['create_time'] = time(); $sid = SitemapInfo::strict(false)->field(true)->insertGetId($param); - if($sid) add_log('add', $sid, $param); + if ($sid) { + add_log('add', $sid, $param); + } + // 删除导航缓存 clear_cache('homeSitemap'); return to_assign(); diff --git a/app/admin/controller/Slide.php b/app/admin/controller/Slide.php index 40a847e..bd827d2 100644 --- a/app/admin/controller/Slide.php +++ b/app/admin/controller/Slide.php @@ -1,4 +1,10 @@ order('create_time asc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $slide); - } - else{ + } else { return view(); - } + } } //添加 @@ -37,7 +42,7 @@ class Slide extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); if ($id > 0) { - $slide = Db::name('slide')->where(['id' => $id])->find(); + $slide = Db::name('Slide')->where(['id' => $id])->find(); View::assign('slide', $slide); } View::assign('id', $id); @@ -58,7 +63,10 @@ class Slide extends BaseController } $param['update_time'] = time(); $res = SlideList::where('id', $param['id'])->strict(false)->field(true)->update($param); - if($res) add_log('edit', $param['id'], $param); + if ($res) { + add_log('edit', $param['id'], $param); + } + clear_cache('homeSlide'); return to_assign(); } else { @@ -70,7 +78,10 @@ class Slide extends BaseController } $param['create_time'] = time(); $sid = SlideList::strict(false)->field(true)->insertGetId($param); - if($sid) add_log('add', $sid, $param); + if ($sid) { + add_log('add', $sid, $param); + } + // 删除banner缓存 clear_cache('homeSlide'); return to_assign(); @@ -86,7 +97,7 @@ class Slide extends BaseController 'slide_id' => $id, ])->count(); if ($count > 0) { - return to_assign(0, '该组下还有幻灯片,无法删除'); + return to_assign(0, '该组下还有Banner,无法删除'); } if (Db::name('Slide')->delete($id) !== false) { add_log('delete', $id); @@ -103,21 +114,20 @@ class Slide extends BaseController $param = get_params(); if (request()->isAjax()) { $where = array(); - $where[] = ['s.slide_id','=',$param['id']]; + $where[] = ['s.slide_id', '=', $param['id']]; $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; $slideInfoList = SlideInfo::where($where) ->alias('s') - ->join('file f', 's.img=f.id', 'LEFT') + ->join('File f', 's.img=f.id', 'LEFT') ->field('s.*,f.filepath') ->order('s.sort desc, s.id desc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $slideInfoList); - } - else{ + } else { return view('', [ 'slide_id' => $param['id'], ]); - } + } } //幻灯片列表 @@ -125,12 +135,12 @@ class Slide extends BaseController { $param = get_params(); $where = array(); - $where[] = ['s.slide_id','=',$param['id']]; + $where[] = ['s.slide_id', '=', $param['id']]; $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; $slideInfoList = SlideInfo::where($where) - ->alias('s') - ->join('file f', 's.img=f.id', 'LEFT') - ->field('s.*,f.filepath') + ->alias('s') + ->join('File f', 's.img=f.id', 'LEFT') + ->field('s.*,f.filepath') ->order('s.sort desc, s.id desc') ->paginate($rows, false, ['query' => $param]); return table_assign(1, '', $slideInfoList); @@ -165,7 +175,10 @@ class Slide extends BaseController } $param['update_time'] = time(); $res = SlideInfo::where(['id' => $param['id']])->strict(false)->field(true)->update($param); - if($res) add_log('edit',$param['id'],$param); + if ($res) { + add_log('edit', $param['id'], $param); + } + // 删除缓存 clear_cache('homeSlide'); return to_assign(); @@ -178,7 +191,10 @@ class Slide extends BaseController } $param['create_time'] = time(); $sid = SlideInfo::strict(false)->field(true)->insertGetId($param); - if($sid) add_log('add', $sid, $param); + if ($sid) { + add_log('add', $sid, $param); + } + // 删除缓存 clear_cache('homeSlide'); return to_assign(); @@ -192,7 +208,7 @@ class Slide extends BaseController if (Db::name('SlideInfo')->delete($id) !== false) { add_log('delete', $id); clear_cache('homeSlide'); - return to_assign(1, "删除成功"); + return to_assign(1, "删除成功"); } else { return to_assign(0, "删除失败"); } diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index e5e3080..74f2253 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -1,4 +1,10 @@ 0 && $end_time > 0) { if ($start_time === $end_time) { $where['register_time'] = array('eq', $start_time); @@ -34,7 +40,7 @@ class User extends BaseController } elseif ($start_time == 0 && $end_time > 0) { $where['register_time'] = array('elt', $end_time); } - + $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; $content = UserList::where($where) ->order('id desc') @@ -43,17 +49,16 @@ class User extends BaseController $item->register_time = empty($item->register_time) ? '-' : date('Y-m-d H:i', $item->register_time); }); return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } //编辑 public function edit() { $id = empty(get_params('id')) ? 0 : get_params('id'); - $user = Db::name('user')->where(['id' => $id])->find(); + $user = Db::name('User')->where(['id' => $id])->find(); View::assign('user', $user); return view(); } @@ -64,13 +69,13 @@ class User extends BaseController if (request()->isAjax()) { $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { - $res = Db::name('user')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); - if($res){ - add_log('edit', $param['id'], $param); - return to_assign(); - }else{ - return to_assign(0, '提交失败:' . $e->getMessage()); - } + $res = Db::name('User')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + return to_assign(); + } else { + return to_assign(0, '提交失败:' . $e->getMessage()); + } } } } @@ -79,7 +84,7 @@ class User extends BaseController public function view() { $id = empty(get_params('id')) ? 0 : get_params('id'); - $user = Db::name('user')->where(['id' => $id])->find(); + $user = Db::name('User')->where(['id' => $id])->find(); add_log('view', get_params('id')); View::assign('user', $user); return view(); @@ -90,7 +95,7 @@ class User extends BaseController $id = get_params("id"); $data['status'] = get_params("status"); $data['id'] = $id; - if (Db::name('user')->update($data) !== false) { + if (Db::name('User')->update($data) !== false) { add_log('edit', $id); return to_assign(1, "操作成功"); } else { @@ -98,21 +103,22 @@ class User extends BaseController } } + //日志 public function log() { if (request()->isAjax()) { $param = get_params(); $where = array(); if (!empty($param['keywords'])) { - $where[] = ['nickname|title','like', '%' . $param['keywords'] . '%']; + $where[] = ['nickname|title', 'like', '%' . $param['keywords'] . '%']; } $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; - $content = DB::name('user_log') + $content = DB::name('UserLog') ->field("id,uid,nickname,title,content,ip,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time") ->order('create_time desc') ->where($where) ->paginate($rows, false, ['query' => $param]); - + $content->toArray(); foreach ($content as $k => $v) { $data = $v; @@ -128,47 +134,46 @@ class User extends BaseController $content->offsetSet($k, $data); } return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } + //记录 public function record() { if (request()->isAjax()) { $param = get_params(); $where = array(); if (!empty($param['keywords'])) { - $where[] = ['nickname|title','like', '%' . $param['keywords'] . '%']; + $where[] = ['nickname|title', 'like', '%' . $param['keywords'] . '%']; } $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; - $content = DB::name('user_log') + $content = DB::name('UserLog') ->field("id,uid,nickname,title,content,ip,param,create_time") ->order('create_time desc') ->where($where) ->paginate($rows, false, ['query' => $param]); - + $content->toArray(); foreach ($content as $k => $v) { $data = $v; $param_array = json_decode($v['param'], true); $name = ''; if (!empty($param_array['name'])) { - $name = ':'. $param_array['name']; + $name = ':' . $param_array['name']; } if (!empty($param_array['title'])) { - $name = ':'. $param_array['title']; + $name = ':' . $param_array['title']; } $data['content'] = $v['content'] . $name; $data['times'] = time_trans($v['create_time']); $content->offsetSet($k, $data); } return table_assign(1, '', $content); - } - else{ + } else { return view(); - } + } } } diff --git a/app/admin/middleware/Auth.php b/app/admin/middleware/Auth.php index eed6676..abebf3c 100644 --- a/app/admin/middleware/Auth.php +++ b/app/admin/middleware/Auth.php @@ -1,4 +1,10 @@ ext(), '', $request->pathInfo()); $action = explode('/', $pathInfo)[0]; //var_dump($pathInfo);exit; - if($pathInfo == '' || $action == '' ){ - redirect('/admin/index/index.html')->send(); - exit; - } + if ($pathInfo == '' || $action == '') { + redirect('/admin/index/index.html')->send(); + exit; + } //验证用户登录 if ($action !== 'login') { $session_admin = get_config('app.session_admin'); if (!Session::has($session_admin)) { - if($request->isAjax()){ - return to_assign(404, '请先登录'); - } - else{ - redirect('/admin/login/index.html')->send(); - exit; - } + if ($request->isAjax()) { + return to_assign(404, '请先登录'); + } else { + redirect('/admin/login/index.html')->send(); + exit; + } } // 验证用户访问权限 if ($action !== 'index' && $action !== 'api') { if (!$this->checkAuth($controller, $pathInfo, $action, Session::get($session_admin)['id'])) { - if($request->isAjax()){ + if ($request->isAjax()) { return to_assign(202, '你没有权限,请联系超级管理员!'); - } - else{ + } else { echo '