重新初始化

This commit is contained in:
2020-02-17 20:47:06 +08:00
parent 5c320206fb
commit 58d999ed73
4016 changed files with 1271 additions and 302396 deletions

View File

@@ -1,20 +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\controller\admin;
use app\controller\Admin;
class Action extends Admin{
/**
* @title 系统首页
*/
public function index(){
}
}

View File

@@ -1,181 +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\controller\admin;
use app\controller\Admin;
use app\model\AdPlace;
use app\model\Ad as AdModel;
class Ad extends Admin{
/**
* @title 广告位列表
*/
public function index(AdPlace $adp){
if ($this->request->isAjax()) {
$param = $this->request->param();
$res = $adp->paginate($this->request->pageConfig);
$data = $res->append(['show_type_text', 'status_text'])->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加广告位
*/
public function add(AdPlace $adp){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $adp->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/ad/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'show_type' => $adp->show_type,
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑广告位
*/
public function edit(AdPlace $adp){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $adp->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/ad/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $adp->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'show_type' => $adp->show_type,
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除广告位
*/
public function del(AdPlace $adp){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $adp->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
/**
* @title 广告列表
*/
public function lists(AdModel $ad){
if ($this->request->isAjax()) {
$res = $ad->paginate($this->request->pageConfig);
$data = $res->append(['cover','status_text'])->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加广告
*/
public function addad(AdModel $ad){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $ad->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/ad/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑广告
*/
public function editad(AdModel $ad){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $ad->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/ad/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $ad->where('id', $this->request->param('id'))->find();
$this->data['template'] = "addad";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除广告
*/
public function delad(AdModel $ad){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $ad->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,28 +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\controller\admin;
use app\controller\Admin;
class Addons extends Admin{
/**
* @title 系统首页
*/
public function index(){
}
/**
* @title 钩子列表
*/
public function hooks(){
}
}

View File

@@ -1,21 +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\controller\admin;
use app\controller\Admin;
class Attribute extends Admin{
/**
* @title 系统首页
*/
public function index(){
}
}

View File

@@ -1,105 +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\controller\admin;
use app\controller\Admin;
use app\Model\Category as CategoryModel;
class Category extends Admin{
/**
* @title 栏目列表
*/
public function index(CategoryModel $category){
if($this->request->isAjax()){
$tree = $this->request->param('tree', 0);
$map = array();
$res = $category->where($map)->order('sort asc, id asc')->select();
$list = $res->toArray();
if($tree){
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
}
$this->data['data'] = $list;
return $this->data;
}
}
/**
* @title 添加栏目
*/
public function add(CategoryModel $category){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $category->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/category/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑栏目
*/
public function edit(CategoryModel $category){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $category->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/category/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $category->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除栏目
*/
public function del(CategoryModel $category){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $category->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,114 +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\controller\admin;
use app\controller\Admin;
use app\Model\Channel as ChannelModel;
class Channel extends Admin{
/**
* @title 频道列表
*/
public function index(ChannelModel $channel){
if($this->request->isAjax()){
$tree = $this->request->param('tree', 0);
$type = $this->request->param('type', 0);
$map = array();
if($type){
$map['type'] = $type;
}
$res = $channel->where($map)->order('sort asc, id asc')->select();
$list = $res->toArray();
if($tree){
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
}
$this->data['data'] = $list;
return $this->data;
}else{
$this->data['data'] = array(
'type' => $this->request->param('type', 0),
);
return $this->data;
}
}
/**
* @title 添加频道
*/
public function add(ChannelModel $channel){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $channel->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/channel/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑频道
*/
public function edit(ChannelModel $channel){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $channel->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/channel/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $channel->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除频道
*/
public function del(ChannelModel $channel){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $channel->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,98 +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\controller\admin;
use app\controller\Admin;
use think\facade\Db;
use app\model\Client as ClientModel;
class Client extends Admin{
/**
* @title 系统首页
*/
public function index(ClientModel $client){
if ($this->request->isAjax()) {
$param = $this->request->param();
$res = $client->paginate($this->request->pageConfig);
$data = $res->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加客户端
*/
public function add(ClientModel $client){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $client->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/client/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑客户端
*/
public function edit(ClientModel $client){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $client->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/client/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $client->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除客户端
*/
public function del(ClientModel $client){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $client->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,240 +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\controller\admin;
use app\controller\Admin;
use app\model\Config as ConfigModel;
use think\facade\Cache;
class Config extends Admin {
/**
* @title 系统首页
*/
public function index(ConfigModel $config) {
if($this->request->isAjax()){
$param = $this->request->param();
$group = input('group', 0, 'trim');
$name = input('name', '', 'trim');
$system_config = Cache::get('system_config');
/* 查询条件初始化 */
$map = array('status' => 1);
if ($group) {
$map['group'] = $group;
}
if ($name) {
$map['name'] = array('like', '%' . $name . '%');
}
$res = $config->where($map)->order('id desc')->paginate($this->request->pageConfig);
$data = $res->append(['type_text','group_text'])->toArray();
$this->data['data'] = $data;
return $this->data;
}else{
$data = array(
'group_id' => $this->request->get('group', 0),
);
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 系统首页
*/
public function group(ConfigModel $config) {
if ($this->request->isAjax()) {
$data = $this->request->param();
$result = $config->updateConfig($data);
if (false !== $result) {
$this->data['code'] = 0;
$this->data['msg'] = "更新成功!";
}else{
$this->data['code'] = 1;
$this->data['msg'] = $config->error;
}
return $this->data;
} else {
$id = $this->request->param('id', 1);
$res = $config->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
$list = $res->toArray();
$this->data['data'] = array('list' => $list, 'id' => $id);
return $this->data;
}
}
/**
* @title 新增配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function add(ConfigModel $config) {
if ($this->request->isPost()) {
$config = model('Config');
$data = $this->request->post();
if ($data) {
$id = $config->validate(true)->save($data);
if ($id) {
cache('db_config_data', null);
//记录行为
action_log('update_config', 'config', $id, session('user_auth.uid'));
return $this->success('新增成功', url('index'));
} else {
return $this->error('新增失败');
}
} else {
return $this->error($config->getError());
}
} else {
$this->data['data'] = array('info' => array());
$this->data['template'] = "edit";
return $this->data;
}
}
/**
* @title 编辑配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function edit(ConfigModel $config) {
if ($this->request->isPost()) {
$config = model('Config');
$data = $this->request->post();
if ($data) {
$result = $config->validate('Config.edit')->save($data, array('id' => $data['id']));
if (false !== $result) {
cache('db_config_data', null);
//记录行为
action_log('update_config', 'config', $data['id'], session('user_auth.uid'));
return $this->success('更新成功', Cookie('__forward__'));
} else {
return $this->error($config->getError(), '');
}
} else {
return $this->error($config->getError());
}
} else {
$id = $this->request->param('id', 0);
if (!$id) {
$this->data['msg'] = "非法操作!";
return $this->data;
}
$info = array();
/* 获取数据 */
$info = $config->field(true)->find($id);
if (false === $info) {
return $this->error('获取配置信息错误');
}
$this->data['data'] = array(
'info' => $info,
);
return $this->data;
}
}
/**
* @title 批量保存配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function save($config) {
if ($config && is_array($config)) {
$Config = db('Config');
foreach ($config as $name => $value) {
$map = array('name' => $name);
$Config->where($map)->setField('value', $value);
}
}
cache('db_config_data', null);
return $this->success('保存成功!');
}
/**
* @title 删除配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function del() {
$id = array_unique((array) input('id', 0));
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Config')->where($map)->delete()) {
cache('DB_CONFIG_DATA', null);
//记录行为
action_log('update_config', 'config', $id, session('user_auth.uid'));
return $this->success('删除成功');
} else {
return $this->error('删除失败!');
}
}
/**
* @title 配置排序
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} elseif (input('group')) {
$map['group'] = input('group');
}
$list = db('Config')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('配置排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
$ids = explode(',', $ids);
foreach ($ids as $key => $value) {
$res = db('Config')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
return $this->success('排序成功!', Cookie('__forward__'));
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}
}
/**
* @title 主题选择
*/
public function themes(ConfigModel $config) {
if ($this->request->isPost()) {
$result = $config->where('name', $name . '_themes')->setField('value', $id);
if (false !== $result) {
\think\Cache::clear();
return $this->success('设置成功!');
}else{
return $this->error('设置失败!');
}
}else{
$list = $config->getThemesList();
$this->data['data'] = array(
'pc' => $this->data['config']['pc_themes'],
'mobile' => $this->data['config']['mobile_themes'],
'list' => $list,
);
return $this->data;
}
}
}

View File

@@ -1,38 +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\controller\admin;
use app\controller\Admin;
/**
*
*/
class Content extends Admin{
/**
* @title 内容列表页
*/
public function index(){
}
/**
* @title 内容添加
*/
public function add(){
if ($this->request->isAjax()) {
$result = false;
if (false !== $result) {
return $this->success();
}else{
return $this->error();
}
}
}
}

View File

@@ -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\controller\admin;
use app\controller\Admin;
use think\facade\Db;
class Database extends Admin{
/**
* @title 数据备份
*/
public function export(){
$list = Db::query('SHOW TABLE STATUS');
$list = array_map('array_change_key_case', $list);
$this->data['data'] = array(
'list' => $list
);
return $this->data;
}
/**
* @title 数据导入
*/
public function import(){
//列出备份文件列表
$path = app()->getRuntimePath() . 'backup';
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
$path = realpath($path);
$flag = \FilesystemIterator::KEY_AS_FILENAME;
$glob = new \FilesystemIterator($path, $flag);
$list = array();
foreach ($glob as $name => $file) {
if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) {
$name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
$date = "{$name[0]}-{$name[1]}-{$name[2]}";
$time = "{$name[3]}:{$name[4]}:{$name[5]}";
$part = $name[6];
if (isset($list["{$date} {$time}"])) {
$info = $list["{$date} {$time}"];
$info['part'] = max($info['part'], $part);
$info['size'] = $info['size'] + $file->getSize();
} else {
$info['part'] = $part;
$info['size'] = $file->getSize();
}
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
$info['time'] = strtotime("{$date} {$time}");
$list["{$date} {$time}"] = $info;
}
}
$this->data['data'] = array(
'list' => $list
);
return $this->data;
}
}

View File

@@ -1,96 +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\controller\admin;
use app\controller\Admin;
use app\model\Form as FormModel;
class Form extends Admin{
/**
* @title 系统首页
*/
public function index(FormModel $form){
if ($this->request->isAjax()) {
$res = $form->paginate($this->request->pageConfig);
$data = $res->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加客户端
*/
public function add(FormModel $form){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $form->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/form/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑客户端
*/
public function edit(FormModel $form){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $form->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/form/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $form->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除客户端
*/
public function del(FormModel $form){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $form->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,32 +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\controller\admin;
use app\controller\Admin;
class Group extends Admin{
/**
* @title 系统首页
*/
public function index(){
if ($this->request->isAjax()) {
# code...
}
}
/**
* @title 权限列表
*/
public function access(){
if ($this->request->isAjax()) {
# code...
}
}
}

View File

@@ -9,8 +9,6 @@
namespace app\controller\admin;
use app\controller\Admin;
use app\model\Menu;
use think\facade\Session;
/**
* @title 后端公共模块
@@ -18,75 +16,26 @@ use think\facade\Session;
class Index extends Admin {
/**
* @title 系统首页
* @title 后台首页
* @return html [description]
*/
public function index(Menu $menu) {
$this->data['data'] = array('menu' => $menu->getAuthMenuList($this->request));
return $this->data;
public function index() {
return $this->fetch();
}
/**
* @title 系统首页
*/
public function dashboard() {
}
/**
* @title 更新缓存
*/
public function clear() {
if ($this->request->isAjax()) {
$root = app()->getRootPath() . 'runtime/';
$this->delDirAndFile($root);
return $this->success('更新成功!');
}
}
/** 递归删除文件
* @param $dirName
* @param bool $subdir
*/
protected function delDirAndFile($dirName) {
$list = glob($dirName . '*');
foreach ($list as $file) {
if (is_dir($file)) {
$this->delDirAndFile($file . '/');
} else {
@unlink($file);
}
}
@rmdir($dirName);
}
/**
* @title 后台登录
* @return html [description]
*/
public function login(\app\model\Member $member) {
if ($this->request->isAjax()) {
$username = $this->request->param('username', '');
$password = $this->request->param('password', '');
$user = $member->login($username, $password);
if ($user) {
Session::set('user', $user);
$this->data['url'] = "/admin/index/index.html";
$this->data['msg'] = "登录成功!";
} else {
Session::set('user', null);
$this->data['code'] = 1;
$this->data['msg'] = "登录失败!";
}
return $this->data;
}
public function login() {
return $this->fetch();
}
/**
* @title 后台
* @title 后台退
* @return html [description]
*/
public function logout() {
Session::set('user', null);
$this->data['code'] = 0;
$this->data['msg'] = "成功退出!";
return $this->data;
return $this->fetch();
}
}
}

View File

@@ -1,96 +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\controller\admin;
use app\controller\Admin;
use app\model\Link as LinkModel;
class Link extends Admin{
/**
* @title 友链列表
*/
public function index(LinkModel $link){
if ($this->request->isAjax()) {
$res = $link->paginate($this->request->pageConfig);
$data = $res->toArray();
$this->data['data'] = $data;
return $this->data;
}
}
/**
* @title 添加友链
*/
public function add(LinkModel $link){
if ($this->request->isPost()) {
$data = $this->request->post();
$result = $link->save($data);
if (false !== $result) {
return $this->success('成功添加', url('/admin/link/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 编辑友链
*/
public function edit(LinkModel $link){
if ($this->request->isPost()) {
$data = $this->request->post();
if (!isset($data['id']) || !$data['id']) {
return $this->error('非法操作!');
}
$result = $link->exists(true)->save($data);
if (false !== $result) {
return $this->success('修改成功', url('/admin/link/index'));
}else{
return $this->error($this->model->getError());
}
}else{
$info = $link->where('id', $this->request->param('id'))->find();
$this->data['template'] = "add";
$this->data['data'] = array(
'info' => $info
);
return $this->data;
}
}
/**
* @title 删除友链
*/
public function del(LinkModel $link){
$ids = $this->request->param('ids', 0);
if(!$ids){
return $this->error('非法操作!');
}else{
$ids = \explode(",", $ids);
}
$result = $link->where('id', 'IN', $ids)->delete();
if(false !== $result){
return $this->success('删除成功!');
}else{
return $this->error('删除失败!');
}
}
}

View File

@@ -1,89 +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\controller\admin;
use app\controller\Admin;
use app\Model\Menu as MenuModel;
class Menu extends Admin{
/**
* @title 系统首页
*/
public function index(){
if($this->request->isAjax()){
$tree = $this->request->param('tree', 0);
$menu = new MenuModel();
$map = array();
$res = $menu->where($map)->order('sort asc, id asc')->select();
$list = $res->toArray();
if($tree){
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
}
$this->data['data'] = $list;
return $this->data;
}
}
/**
* @title 编辑菜单
*/
public function edit(){
$menu = new MenuModel();
if($this->request->isAjax()){
$data = $this->request->post();
$result = $menu->where('id', $data['id'])->save($data);
if (false !== $result) {
$this->data['code'] = 0;
$this->data['msg'] = '更新成功!';
}else{
$this->data['code'] = 1;
$this->data['msg'] = '更新失败!';
}
return $this->data;
}else{
$id = $this->request->param('id', 0);
if (!$id) {
return $this->error('非法操作!');
}
$info = $menu->where('id', $id)->find();
$this->data['data'] = array('info'=>$info);
return $this->data;
}
}
/**
* @title 添加菜单
*/
public function add(){
if($this->request->isAjax()){
return $this->data;
}else{
$this->data['template'] = 'edit';
return $this->data;
}
}
/**
* @title 移除菜单
*/
public function remove(){
if($this->request->isAjax()){
return $this->data;
}
}
}

View File

@@ -1,21 +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\controller\admin;
use app\controller\Admin;
class Model extends Admin{
/**
* @title 系统首页
*/
public function index(){
}
}

View File

@@ -1,42 +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\controller\admin;
use app\controller\Admin;
use app\model\Rewrite;
use app\model\SeoRule;
class Seo extends Admin{
/**
* @title 系统首页
*/
public function index(SeoRule $seo){
if($this->request->isAjax()){
//读取规则列表
$map = array('status' => array('=', 0));
$res = $seo->where($map)->order('sort asc')->paginate($this->request->pageConfig);
$this->data['data'] = $res->toArray();
return $this->data;
}
}
/**
* @title 重写规则
*/
public function rewrite(Rewrite $rewrite){
$this->data['data'] = array(
'list' => array()
);
return $this->data;
}
}

View File

@@ -1,43 +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\controller\admin;
use app\controller\Admin;
class User extends Admin{
/**
* @title 系统首页
*/
public function index(){
if ($this->request->isAjax()) {
return $this->data;
}
}
/**
* @title 个人资料
*/
public function profile(){
}
/**
* @title 检测密码正确性
*/
public function checkPassword(){
return true;
}
/**
* @title 修改密码
*/
public function resetpwd(){
}
}