mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 05:52:43 +08:00
[更新]代码远程更新
This commit is contained in:
parent
18f50d55d0
commit
c8b39d66bd
26
README.md
26
README.md
@ -33,6 +33,32 @@ PHP 开发技术交流( QQ 群 513350915)
|
||||
* Gitee仓库地址:https://gitee.com/zoujingli/Think.Admin
|
||||
* GitHub仓库地址:https://github.com/zoujingli/ThinkAdmin
|
||||
|
||||
框架指令
|
||||
--
|
||||
* 执行 `build.cmd` 可更新 `Composer` 插件,会删除并替换 `vendor` 目录
|
||||
* 执行 `php think run` 启用本地开发环境,访问 `http://127.0.0.1:8000`
|
||||
|
||||
* 线上代码更新
|
||||
>* 执行 `php think xsync:admin` 从线上服务更新 `admin` 模块的所有文件(注意文件安全)
|
||||
>* 执行 `php think xsync:wechat` 从线上服务更新 `wehcat` 模块的所有文件(注意文件安全)
|
||||
>* 执行 `php think xysnc:service` 从线上服务更新 `service` 模块的所有文件(注意文件安全)
|
||||
>* 执行 `php think xysnc:plugs` 从线上服务更新 `plugs` 静态插件的部分文件(注意文件安全)
|
||||
>* 执行 `php think xysnc:config` 从线上服务更新 `config` 项目配置的部分文件(注意文件安全)
|
||||
|
||||
* 微信资料管理
|
||||
>* 执行 `php think xfans:all` 更新已经对接的公众号粉丝全部列表
|
||||
>* 执行 `php think xfans:black` 更新已经对接的公众号黑名单列表
|
||||
>* 执行 `php think xfans:list` 更新已经对接的公众号粉丝列表
|
||||
>* 执行 `php think xfans:tags` 更新已经对接的公众号煯标签列表
|
||||
>* 执行 `php think xclean:session` 清理无效的会话文件
|
||||
>* 执行 `php think xclean:store` 清理无效的订单信息及定时任务
|
||||
|
||||
* 守护进程管理
|
||||
>* 执行 `php think xtask:reset` 重启消息任务守护进程
|
||||
>* 执行 `php think xtask:start` 启动消息任务守护进程
|
||||
>* 执行 `php think xtask:state` 查询消息任务守护进程
|
||||
>* 执行 `php think xtask:stop` 暂停消息任务守护进程
|
||||
|
||||
特别感谢
|
||||
--
|
||||
|名称|版本|描述|链接|
|
||||
|
@ -1,153 +1,154 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
* Class Auth
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 默认数据模型
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemAuth';
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统权限管理';
|
||||
$this->_query($this->table)->dateBetween('create_at')->like('title,desc')->equal('status')->order('sort asc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限授权节点
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->title = '权限授权配置';
|
||||
$auth = $this->request->post('id', '0');
|
||||
switch (strtolower($this->request->post('action'))) {
|
||||
case 'get': // 获取权限配置
|
||||
$nodes = \app\admin\service\Auth::get();
|
||||
$checked = Db::name('SystemAuthNode')->where(['auth' => $auth])->column('node');
|
||||
foreach ($nodes as &$node) $node['checked'] = in_array($node['node'], $checked);
|
||||
$data = $this->_apply_filter(\library\tools\Data::arr2tree($nodes, 'node', 'pnode', '_sub_'));
|
||||
return $this->success('获取权限配置成功!', $data);
|
||||
case 'save': // 保存权限配置
|
||||
list($post, $data) = [$this->request->post(), []];
|
||||
foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) $data[] = ['auth' => $auth, 'node' => $node];
|
||||
Db::name('SystemAuthNode')->where(['auth' => $auth])->delete();
|
||||
Db::name('SystemAuthNode')->insertAll($data);
|
||||
return $this->success('权限授权配置更新成功!');
|
||||
default:
|
||||
return $this->_form($this->table, 'apply');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点数据拼装
|
||||
* @param array $nodes
|
||||
* @param integer $level
|
||||
* @return array
|
||||
*/
|
||||
private function _apply_filter($nodes, $level = 1)
|
||||
{
|
||||
foreach ($nodes as $key => $node) if (!empty($node['_sub_']) && is_array($node['_sub_'])) {
|
||||
$node[$key]['_sub_'] = $this->_apply_filter($node['_sub_'], $level + 1);
|
||||
}
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限添加
|
||||
* @return array|string
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限编辑
|
||||
* @return array|string
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限禁用
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限恢复
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除结果处理
|
||||
* @param boolean $result
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
protected function _del_delete_result($result)
|
||||
{
|
||||
if ($result) {
|
||||
$where = ['auth' => $this->request->post('id')];
|
||||
Db::name('SystemAuthNode')->where($where)->delete();
|
||||
$this->success("权限删除成功!", '');
|
||||
} else {
|
||||
$this->error("权限删除失败,请稍候再试!");
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 权限管理
|
||||
* Class Auth
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 默认数据模型
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemAuth';
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统权限管理';
|
||||
$this->_query($this->table)->dateBetween('create_at')->like('title,desc')->equal('status')->order('sort asc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限授权节点
|
||||
* @return mixed
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->title = '权限授权配置';
|
||||
$auth = $this->request->post('id', '0');
|
||||
switch (strtolower($this->request->post('action'))) {
|
||||
case 'get': // 获取权限配置
|
||||
$nodes = \app\admin\service\Auth::get();
|
||||
$checked = Db::name('SystemAuthNode')->where(['auth' => $auth])->column('node');
|
||||
foreach ($nodes as &$node) $node['checked'] = in_array($node['node'], $checked);
|
||||
$data = $this->_apply_filter(\library\tools\Data::arr2tree($nodes, 'node', 'pnode', '_sub_'));
|
||||
return $this->success('获取权限配置成功!', $data);
|
||||
case 'save': // 保存权限配置
|
||||
list($post, $data) = [$this->request->post(), []];
|
||||
foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) $data[] = ['auth' => $auth, 'node' => $node];
|
||||
Db::name('SystemAuthNode')->where(['auth' => $auth])->delete();
|
||||
Db::name('SystemAuthNode')->insertAll($data);
|
||||
return $this->success('权限授权配置更新成功!');
|
||||
default:
|
||||
return $this->_form($this->table, 'apply');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点数据拼装
|
||||
* @param array $nodes
|
||||
* @param integer $level
|
||||
* @return array
|
||||
*/
|
||||
private function _apply_filter($nodes, $level = 1)
|
||||
{
|
||||
foreach ($nodes as $key => $node) if (!empty($node['_sub_']) && is_array($node['_sub_'])) {
|
||||
$node[$key]['_sub_'] = $this->_apply_filter($node['_sub_'], $level + 1);
|
||||
}
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限添加
|
||||
* @return array|string
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限编辑
|
||||
* @return array|string
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限禁用
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限恢复
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除结果处理
|
||||
* @param boolean $result
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
protected function _del_delete_result($result)
|
||||
{
|
||||
if ($result) {
|
||||
$where = ['auth' => $this->request->post('id')];
|
||||
Db::name('SystemAuthNode')->where($where)->delete();
|
||||
$this->success("权限删除成功!", '');
|
||||
} else {
|
||||
$this->error("权限删除失败,请稍候再试!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,109 +1,109 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
* Class Config
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
/**
|
||||
* 默认数据模型
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'SystemConfig';
|
||||
|
||||
/**
|
||||
* 系统参数配置
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '系统参数配置';
|
||||
if ($this->request->isGet()) return $this->fetch();
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
$this->success('系统参数配置保存成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件存储配置
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function file()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
$this->fetch('file', [
|
||||
'title' => '文件存储配置',
|
||||
'point' => [
|
||||
'oss-cn-hangzhou.aliyuncs.com' => '华东 1 杭州',
|
||||
'oss-cn-shanghai.aliyuncs.com' => '华东 2 上海',
|
||||
'oss-cn-qingdao.aliyuncs.com' => '华北 1 青岛',
|
||||
'oss-cn-beijing.aliyuncs.com' => '华北 2 北京',
|
||||
'oss-cn-zhangjiakou.aliyuncs.com' => '华北 3 张家口',
|
||||
'oss-cn-huhehaote.aliyuncs.com' => '华北 5 呼和浩特',
|
||||
'oss-cn-shenzhen.aliyuncs.com' => '华南 1 深圳',
|
||||
'oss-cn-hongkong.aliyuncs.com' => '香港 1',
|
||||
'oss-us-west-1.aliyuncs.com' => '美国西部 1 硅谷',
|
||||
'oss-us-east-1.aliyuncs.com' => '美国东部 1 弗吉尼亚',
|
||||
'oss-ap-southeast-1.aliyuncs.com' => '亚太东南 1 新加坡',
|
||||
'oss-ap-southeast-2.aliyuncs.com' => '亚太东南 2 悉尼',
|
||||
'oss-ap-southeast-3.aliyuncs.com' => '亚太东南 3 吉隆坡',
|
||||
'oss-ap-southeast-5.aliyuncs.com' => '亚太东南 5 雅加达',
|
||||
'oss-ap-northeast-1.aliyuncs.com' => '亚太东北 1 日本',
|
||||
'oss-ap-south-1.aliyuncs.com' => '亚太南部 1 孟买',
|
||||
'oss-eu-central-1.aliyuncs.com' => '欧洲中部 1 法兰克福',
|
||||
'oss-eu-west-1.aliyuncs.com' => '英国 1 伦敦',
|
||||
'oss-me-east-1.aliyuncs.com' => '中东东部 1 迪拜',
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
if (isset($post['storage_type']) && $post['storage_type'] === 'local') {
|
||||
$exts = array_unique(explode(',', $post['storage_local_exts']));
|
||||
if (in_array('php', $exts)) $this->error('禁止上传可执行文件到本地服务器!');
|
||||
$post['storage_local_exts'] = join(',', $exts);
|
||||
}
|
||||
foreach ($post as $key => $value) sysconf($key, $value);
|
||||
if (isset($post['storage_type']) && $post['storage_type'] === 'oss') {
|
||||
try {
|
||||
$local = sysconf('storage_oss_domain');
|
||||
$bucket = $this->request->post('storage_oss_bucket');
|
||||
$domain = \library\File::instance('oss')->setBucket($bucket);
|
||||
if (empty($local) || stripos($local, '.aliyuncs.com') !== false) {
|
||||
sysconf('storage_oss_domain', $domain);
|
||||
}
|
||||
$this->success('阿里云OSS存储动态配置成功!');
|
||||
} catch (\think\exception\HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("阿里云OSS存储配置失效,{$e->getMessage()}");
|
||||
}
|
||||
} else {
|
||||
$this->success('文件存储配置保存成功!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
* Class Config
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
/**
|
||||
* 默认数据模型
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'SystemConfig';
|
||||
|
||||
/**
|
||||
* 系统参数配置
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '系统参数配置';
|
||||
if ($this->request->isGet()) return $this->fetch();
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
$this->success('系统参数配置保存成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件存储配置
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function file()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
$this->fetch('file', [
|
||||
'title' => '文件存储配置',
|
||||
'point' => [
|
||||
'oss-cn-hangzhou.aliyuncs.com' => '华东 1 杭州',
|
||||
'oss-cn-shanghai.aliyuncs.com' => '华东 2 上海',
|
||||
'oss-cn-qingdao.aliyuncs.com' => '华北 1 青岛',
|
||||
'oss-cn-beijing.aliyuncs.com' => '华北 2 北京',
|
||||
'oss-cn-zhangjiakou.aliyuncs.com' => '华北 3 张家口',
|
||||
'oss-cn-huhehaote.aliyuncs.com' => '华北 5 呼和浩特',
|
||||
'oss-cn-shenzhen.aliyuncs.com' => '华南 1 深圳',
|
||||
'oss-cn-hongkong.aliyuncs.com' => '香港 1',
|
||||
'oss-us-west-1.aliyuncs.com' => '美国西部 1 硅谷',
|
||||
'oss-us-east-1.aliyuncs.com' => '美国东部 1 弗吉尼亚',
|
||||
'oss-ap-southeast-1.aliyuncs.com' => '亚太东南 1 新加坡',
|
||||
'oss-ap-southeast-2.aliyuncs.com' => '亚太东南 2 悉尼',
|
||||
'oss-ap-southeast-3.aliyuncs.com' => '亚太东南 3 吉隆坡',
|
||||
'oss-ap-southeast-5.aliyuncs.com' => '亚太东南 5 雅加达',
|
||||
'oss-ap-northeast-1.aliyuncs.com' => '亚太东北 1 日本',
|
||||
'oss-ap-south-1.aliyuncs.com' => '亚太南部 1 孟买',
|
||||
'oss-eu-central-1.aliyuncs.com' => '欧洲中部 1 法兰克福',
|
||||
'oss-eu-west-1.aliyuncs.com' => '英国 1 伦敦',
|
||||
'oss-me-east-1.aliyuncs.com' => '中东东部 1 迪拜',
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
if (isset($post['storage_type']) && $post['storage_type'] === 'local') {
|
||||
$exts = array_unique(explode(',', $post['storage_local_exts']));
|
||||
if (in_array('php', $exts)) $this->error('禁止上传可执行文件到本地服务器!');
|
||||
$post['storage_local_exts'] = join(',', $exts);
|
||||
}
|
||||
foreach ($post as $key => $value) sysconf($key, $value);
|
||||
if (isset($post['storage_type']) && $post['storage_type'] === 'oss') {
|
||||
try {
|
||||
$local = sysconf('storage_oss_domain');
|
||||
$bucket = $this->request->post('storage_oss_bucket');
|
||||
$domain = \library\File::instance('oss')->setBucket($bucket);
|
||||
if (empty($local) || stripos($local, '.aliyuncs.com') !== false) {
|
||||
sysconf('storage_oss_domain', $domain);
|
||||
}
|
||||
$this->success('阿里云OSS存储动态配置成功!');
|
||||
} catch (\think\exception\HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("阿里云OSS存储配置失效,{$e->getMessage()}");
|
||||
}
|
||||
} else {
|
||||
$this->success('文件存储配置保存成功!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,167 +1,168 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Console;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 后台入口管理
|
||||
* Class Index
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 显示后台首页
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统管理后台';
|
||||
$this->menus = \app\admin\service\Auth::getAuthMenu();
|
||||
if (empty($this->menus) && !session('user.id')) {
|
||||
$this->redirect('@admin/login');
|
||||
} else {
|
||||
$this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台环境信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function main()
|
||||
{
|
||||
$this->title = '后台首页';
|
||||
$this->think_ver = \think\App::VERSION;
|
||||
$this->mysql_ver = Db::query('select version() as ver')[0]['ver'];
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理系统运行缓存
|
||||
*/
|
||||
public function clearRuntime()
|
||||
{
|
||||
if (!\app\admin\service\Auth::isLogin()) {
|
||||
$this->error('需要登录才能操作哦!');
|
||||
}
|
||||
$this->list = [
|
||||
[
|
||||
'title' => 'Clean up running cached files',
|
||||
'message' => nl2br(Console::call('clear')->fetch()),
|
||||
], [
|
||||
'title' => 'Clean up invalid session files',
|
||||
'message' => nl2br(Console::call('xclean:session')->fetch()),
|
||||
],
|
||||
];
|
||||
$this->fetch('admin@index/command');
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩发布系统
|
||||
*/
|
||||
public function buildOptimize()
|
||||
{
|
||||
if (!\app\admin\service\Auth::isLogin()) {
|
||||
$this->error('需要登录才能操作哦!');
|
||||
}
|
||||
$this->list = [
|
||||
[
|
||||
'title' => 'Build route cache',
|
||||
'message' => nl2br(Console::call('optimize:route')->fetch()),
|
||||
], [
|
||||
'title' => 'Build database schema cache',
|
||||
'message' => nl2br(Console::call('optimize:schema')->fetch()),
|
||||
], [
|
||||
'title' => 'Optimizes PSR0 and PSR4 packages',
|
||||
'message' => nl2br(Console::call('optimize:autoload')->fetch()),
|
||||
], [
|
||||
'title' => 'Build config and common file cache',
|
||||
'message' => nl2br(Console::call('optimize:config')->fetch()),
|
||||
],
|
||||
];
|
||||
$this->fetch('admin@index/command');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param integer $id
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function pass($id)
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if (intval($id) !== intval(session('user.id'))) {
|
||||
$this->error('只能修改当前用户的密码!');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->verify = true;
|
||||
$this->_form('SystemUser', 'admin@user/pass', 'id', [], ['id' => $id]);
|
||||
} else {
|
||||
$data = $this->_input([
|
||||
'password' => $this->request->post('password'),
|
||||
'repassword' => $this->request->post('repassword'),
|
||||
'oldpassword' => $this->request->post('oldpassword'),
|
||||
], [
|
||||
'oldpassword' => 'require',
|
||||
'password' => 'require|min:4',
|
||||
'repassword' => 'require|confirm:password',
|
||||
], [
|
||||
'oldpassword.require' => '旧密码不能为空!',
|
||||
'password.require' => '登录密码不能为空!',
|
||||
'password.min' => '登录密码长度不能少于4位有效字符!',
|
||||
'repassword.require' => '重复密码不能为空!',
|
||||
'repassword.confirm' => '重复密码与登录密码不匹配,请重新输入!',
|
||||
]);
|
||||
$user = Db::name('SystemUser')->where(['id' => $id])->find();
|
||||
if (md5($data['oldpassword']) !== $user['password']) {
|
||||
$this->error('旧密码验证失败,请重新输入!');
|
||||
}
|
||||
$result = \app\admin\service\Auth::checkPassword($data['password']);
|
||||
if (empty($result['code'])) $this->error($result['msg']);
|
||||
if (Data::save('SystemUser', ['id' => $user['id'], 'password' => md5($data['password'])])) {
|
||||
$this->success('密码修改成功,下次请使用新密码登录!', '');
|
||||
} else {
|
||||
$this->error('密码修改失败,请稍候再试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户资料
|
||||
* @param integer $id 会员ID
|
||||
*/
|
||||
public function info($id = 0)
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if (intval($id) === intval(session('user.id'))) {
|
||||
$this->_form('SystemUser', 'user/form', 'id', [], ['id' => $id]);
|
||||
} else {
|
||||
$this->error('只能修改登录用户的资料!');
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Console;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 后台入口管理
|
||||
* Class Index
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 显示后台首页
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统管理后台';
|
||||
$this->menus = \app\admin\service\Auth::getAuthMenu();
|
||||
if (empty($this->menus) && !session('user.id')) {
|
||||
$this->redirect('@admin/login');
|
||||
} else {
|
||||
$this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台环境信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function main()
|
||||
{
|
||||
$this->title = '后台首页';
|
||||
$this->think_ver = \think\App::VERSION;
|
||||
$this->mysql_ver = Db::query('select version() as ver')[0]['ver'];
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理系统运行缓存
|
||||
*/
|
||||
public function clearRuntime()
|
||||
{
|
||||
if (!\app\admin\service\Auth::isLogin()) {
|
||||
$this->error('需要登录才能操作哦!');
|
||||
}
|
||||
$this->list = [
|
||||
[
|
||||
'title' => 'Clean up running cached files',
|
||||
'message' => nl2br(Console::call('clear')->fetch()),
|
||||
], [
|
||||
'title' => 'Clean up invalid session files',
|
||||
'message' => nl2br(Console::call('xclean:session')->fetch()),
|
||||
],
|
||||
];
|
||||
$this->fetch('admin@index/command');
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩发布系统
|
||||
*/
|
||||
public function buildOptimize()
|
||||
{
|
||||
if (!\app\admin\service\Auth::isLogin()) {
|
||||
$this->error('需要登录才能操作哦!');
|
||||
}
|
||||
$this->list = [
|
||||
[
|
||||
'title' => 'Build route cache',
|
||||
'message' => nl2br(Console::call('optimize:route')->fetch()),
|
||||
], [
|
||||
'title' => 'Build database schema cache',
|
||||
'message' => nl2br(Console::call('optimize:schema')->fetch()),
|
||||
], [
|
||||
'title' => 'Optimizes PSR0 and PSR4 packages',
|
||||
'message' => nl2br(Console::call('optimize:autoload')->fetch()),
|
||||
], [
|
||||
'title' => 'Build config and common file cache',
|
||||
'message' => nl2br(Console::call('optimize:config')->fetch()),
|
||||
],
|
||||
];
|
||||
$this->fetch('admin@index/command');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param integer $id
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function pass($id)
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if (intval($id) !== intval(session('user.id'))) {
|
||||
$this->error('只能修改当前用户的密码!');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->verify = true;
|
||||
$this->_form('SystemUser', 'admin@user/pass', 'id', [], ['id' => $id]);
|
||||
} else {
|
||||
$data = $this->_input([
|
||||
'password' => $this->request->post('password'),
|
||||
'repassword' => $this->request->post('repassword'),
|
||||
'oldpassword' => $this->request->post('oldpassword'),
|
||||
], [
|
||||
'oldpassword' => 'require',
|
||||
'password' => 'require|min:4',
|
||||
'repassword' => 'require|confirm:password',
|
||||
], [
|
||||
'oldpassword.require' => '旧密码不能为空!',
|
||||
'password.require' => '登录密码不能为空!',
|
||||
'password.min' => '登录密码长度不能少于4位有效字符!',
|
||||
'repassword.require' => '重复密码不能为空!',
|
||||
'repassword.confirm' => '重复密码与登录密码不匹配,请重新输入!',
|
||||
]);
|
||||
$user = Db::name('SystemUser')->where(['id' => $id])->find();
|
||||
if (md5($data['oldpassword']) !== $user['password']) {
|
||||
$this->error('旧密码验证失败,请重新输入!');
|
||||
}
|
||||
$result = \app\admin\service\Auth::checkPassword($data['password']);
|
||||
if (empty($result['code'])) $this->error($result['msg']);
|
||||
if (Data::save('SystemUser', ['id' => $user['id'], 'password' => md5($data['password'])])) {
|
||||
$this->success('密码修改成功,下次请使用新密码登录!', '');
|
||||
} else {
|
||||
$this->error('密码修改失败,请稍候再试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户资料
|
||||
* @param integer $id 会员ID
|
||||
*/
|
||||
public function info($id = 0)
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if (intval($id) === intval(session('user.id'))) {
|
||||
$this->_form('SystemUser', 'user/form', 'id', [], ['id' => $id]);
|
||||
} else {
|
||||
$this->error('只能修改登录用户的资料!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,70 +1,70 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
|
||||
/**
|
||||
* 系统日志管理
|
||||
* Class Log
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Log extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 指定当前数据表
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemLog';
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统操作日志';
|
||||
$this->_query($this->table)->like('action,node,content,username,geoip')->dateBetween('create_at')->order('id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
$ip = new \Ip2Region();
|
||||
foreach ($data as &$vo) {
|
||||
$result = $ip->btreeSearch($vo['geoip']);
|
||||
$vo['isp'] = isset($result['region']) ? $result['region'] : '';
|
||||
$vo['isp'] = str_replace(['内网IP', '0', '|'], '', $vo['isp']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志删除操作
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
|
||||
/**
|
||||
* 系统日志管理
|
||||
* Class Log
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Log extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 指定当前数据表
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemLog';
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统操作日志';
|
||||
$this->_query($this->table)->like('action,node,content,username,geoip')->dateBetween('create_at')->order('id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
$ip = new \Ip2Region();
|
||||
foreach ($data as &$vo) {
|
||||
$result = $ip->btreeSearch($vo['geoip']);
|
||||
$vo['isp'] = isset($result['region']) ? $result['region'] : '';
|
||||
$vo['isp'] = str_replace(['内网IP', '0', '|'], '', $vo['isp']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志删除操作
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
}
|
@ -1,113 +1,113 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 用户登录管理
|
||||
* Class Login
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
/**
|
||||
* 设置页面标题
|
||||
* @var string
|
||||
*/
|
||||
public $title = '管理登录';
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
session('loginskey', $this->skey = session('loginskey') ? session('loginskey') : uniqid());
|
||||
$this->fetch();
|
||||
} else {
|
||||
$data = $this->_input([
|
||||
'username' => $this->request->post('username'),
|
||||
'password' => $this->request->post('password'),
|
||||
], [
|
||||
'username' => 'require|min:4',
|
||||
'password' => 'require|min:4',
|
||||
], [
|
||||
'username.require' => '登录账号不能为空!',
|
||||
'password.require' => '登录密码不能为空!',
|
||||
'username.min' => '登录账号长度不能少于4位有效字符!',
|
||||
'password.min' => '登录密码长度不能少于4位有效字符!',
|
||||
]);
|
||||
// 用户信息验证
|
||||
$map = ['is_deleted' => '0', 'username' => $data['username']];
|
||||
$user = Db::name('SystemUser')->where($map)->find();
|
||||
if (empty($user)) $this->error('登录账号或密码错误,请重新输入!');
|
||||
if (empty($user['status'])) $this->error('账号已经被禁用,请联系管理!');
|
||||
// 账号锁定消息
|
||||
$cache = cache('user_login_' . $user['username']);
|
||||
if (is_array($cache) && !empty($cache['number']) && !empty($cache['time'])) {
|
||||
if ($cache['number'] >= 10 && ($diff = $cache['time'] + 3600 - time()) > 0) {
|
||||
list($m, $s, $info) = [floor($diff / 60), floor($diff % 60), ''];
|
||||
if ($m > 0) $info = "{$m} 分";
|
||||
$this->error("<strong class='color-red'>抱歉,该账号已经被锁定!</strong><p class='nowrap'>连续 10 次登录错误,请 {$info} {$s} 秒后再登录!</p>");
|
||||
}
|
||||
}
|
||||
if (md5($user['password'] . session('loginskey')) !== $data['password']) {
|
||||
if (empty($cache) || empty($cache['time']) || empty($cache['number']) || $cache['time'] + 3600 < time()) {
|
||||
$cache = ['time' => time(), 'number' => 1, 'geoip' => $this->request->ip()];
|
||||
} elseif ($cache['number'] + 1 <= 10) {
|
||||
$cache = ['time' => time(), 'number' => $cache['number'] + 1, 'geoip' => $this->request->ip()];
|
||||
}
|
||||
cache('user_login_' . $user['username'], $cache);
|
||||
if (($diff = 10 - $cache['number']) > 0) {
|
||||
$this->error("<strong class='color-red'>登录账号或密码错误!</strong><p class='nowrap'>还有 {$diff} 次尝试机会,将锁定一小时内禁止登录!</p>");
|
||||
} else {
|
||||
_syslog('系统管理', "账号{$user['username']}连续10次登录密码错误,请注意账号安全!");
|
||||
$this->error("<strong class='color-red'>登录账号或密码错误!</strong><p class='nowrap'>尝试次数达到上限,锁定一小时内禁止登录!</p>");
|
||||
}
|
||||
}
|
||||
// 登录成功并更新账号
|
||||
cache('user_login_' . $user['username'], null);
|
||||
Db::name('SystemUser')->where(['id' => $user['id']])->update([
|
||||
'login_at' => Db::raw('now()'),
|
||||
'login_ip' => $this->request->ip(),
|
||||
'login_num' => Db::raw('login_num+1'),
|
||||
]);
|
||||
session('user', $user);
|
||||
session('loginskey', null);
|
||||
empty($user['authorize']) || \app\admin\service\Auth::applyNode();
|
||||
_syslog('系统管理', '用户登录系统成功');
|
||||
$this->success('登录成功,正在进入系统...', url('@admin'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public function out()
|
||||
{
|
||||
if ($_SESSION) $_SESSION = [];
|
||||
[session_unset(), session_destroy()];
|
||||
$this->success('退出登录成功!', url('@admin/login'));
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 用户登录管理
|
||||
* Class Login
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
/**
|
||||
* 设置页面标题
|
||||
* @var string
|
||||
*/
|
||||
public $title = '管理登录';
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
session('loginskey', $this->skey = session('loginskey') ? session('loginskey') : uniqid());
|
||||
$this->fetch();
|
||||
} else {
|
||||
$data = $this->_input([
|
||||
'username' => $this->request->post('username'),
|
||||
'password' => $this->request->post('password'),
|
||||
], [
|
||||
'username' => 'require|min:4',
|
||||
'password' => 'require|min:4',
|
||||
], [
|
||||
'username.require' => '登录账号不能为空!',
|
||||
'password.require' => '登录密码不能为空!',
|
||||
'username.min' => '登录账号长度不能少于4位有效字符!',
|
||||
'password.min' => '登录密码长度不能少于4位有效字符!',
|
||||
]);
|
||||
// 用户信息验证
|
||||
$map = ['is_deleted' => '0', 'username' => $data['username']];
|
||||
$user = Db::name('SystemUser')->where($map)->find();
|
||||
if (empty($user)) $this->error('登录账号或密码错误,请重新输入!');
|
||||
if (empty($user['status'])) $this->error('账号已经被禁用,请联系管理!');
|
||||
// 账号锁定消息
|
||||
$cache = cache('user_login_' . $user['username']);
|
||||
if (is_array($cache) && !empty($cache['number']) && !empty($cache['time'])) {
|
||||
if ($cache['number'] >= 10 && ($diff = $cache['time'] + 3600 - time()) > 0) {
|
||||
list($m, $s, $info) = [floor($diff / 60), floor($diff % 60), ''];
|
||||
if ($m > 0) $info = "{$m} 分";
|
||||
$this->error("<strong class='color-red'>抱歉,该账号已经被锁定!</strong><p class='nowrap'>连续 10 次登录错误,请 {$info} {$s} 秒后再登录!</p>");
|
||||
}
|
||||
}
|
||||
if (md5($user['password'] . session('loginskey')) !== $data['password']) {
|
||||
if (empty($cache) || empty($cache['time']) || empty($cache['number']) || $cache['time'] + 3600 < time()) {
|
||||
$cache = ['time' => time(), 'number' => 1, 'geoip' => $this->request->ip()];
|
||||
} elseif ($cache['number'] + 1 <= 10) {
|
||||
$cache = ['time' => time(), 'number' => $cache['number'] + 1, 'geoip' => $this->request->ip()];
|
||||
}
|
||||
cache('user_login_' . $user['username'], $cache);
|
||||
if (($diff = 10 - $cache['number']) > 0) {
|
||||
$this->error("<strong class='color-red'>登录账号或密码错误!</strong><p class='nowrap'>还有 {$diff} 次尝试机会,将锁定一小时内禁止登录!</p>");
|
||||
} else {
|
||||
_syslog('系统管理', "账号{$user['username']}连续10次登录密码错误,请注意账号安全!");
|
||||
$this->error("<strong class='color-red'>登录账号或密码错误!</strong><p class='nowrap'>尝试次数达到上限,锁定一小时内禁止登录!</p>");
|
||||
}
|
||||
}
|
||||
// 登录成功并更新账号
|
||||
cache('user_login_' . $user['username'], null);
|
||||
Db::name('SystemUser')->where(['id' => $user['id']])->update([
|
||||
'login_at' => Db::raw('now()'),
|
||||
'login_ip' => $this->request->ip(),
|
||||
'login_num' => Db::raw('login_num+1'),
|
||||
]);
|
||||
session('user', $user);
|
||||
session('loginskey', null);
|
||||
empty($user['authorize']) || \app\admin\service\Auth::applyNode();
|
||||
_syslog('系统管理', '用户登录系统成功');
|
||||
$this->success('登录成功,正在进入系统...', url('@admin'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public function out()
|
||||
{
|
||||
if ($_SESSION) $_SESSION = [];
|
||||
[session_unset(), session_destroy()];
|
||||
$this->success('退出登录成功!', url('@admin/login'));
|
||||
}
|
||||
|
||||
}
|
@ -1,133 +1,134 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统菜单管理
|
||||
* Class Menu
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 当前操作数据库
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'SystemMenu';
|
||||
|
||||
/**
|
||||
* 系统菜单显示
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统菜单管理';
|
||||
$this->_page($this->table, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
if ($vo['url'] !== '#') {
|
||||
$vo['url'] = url($vo['url']) . (empty($vo['params']) ? '' : "?{$vo['params']}");
|
||||
}
|
||||
$vo['ids'] = join(',', Data::getArrSubIds($data, $vo['id']));
|
||||
}
|
||||
$data = Data::arr2table($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据
|
||||
* @param array $vo
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _form_filter(&$vo)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
// 上级菜单处理
|
||||
$_menus = Db::name($this->table)->where(['status' => '1'])->order('sort asc,id asc')->select();
|
||||
$_menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
|
||||
$menus = Data::arr2table($_menus);
|
||||
foreach ($menus as $key => &$menu) if (substr_count($menu['path'], '-') > 3) unset($menus[$key]); # 移除三级以下的菜单
|
||||
elseif (isset($vo['pid']) && $vo['pid'] !== '' && $cur = "-{$vo['pid']}-{$vo['id']}")
|
||||
if (stripos("{$menu['path']}-", "{$cur}-") !== false || $menu['path'] === $cur) unset($menus[$key]); # 移除与自己相关联的菜单
|
||||
// 选择自己的上级菜单
|
||||
if (!isset($vo['pid']) && $this->request->get('pid', '0')) $vo['pid'] = $this->request->get('pid', '0');
|
||||
// 读取系统功能节点
|
||||
$nodes = \app\admin\service\Auth::get();
|
||||
foreach ($nodes as $key => $node) {
|
||||
if (empty($node['is_menu'])) unset($nodes[$key]);
|
||||
unset($nodes[$key]['pnode'], $nodes[$key]['is_login'], $nodes[$key]['is_menu'], $nodes[$key]['is_auth']);
|
||||
}
|
||||
list($this->menus, $this->nodes) = [$menus, array_values($nodes)];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用菜单
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用菜单
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统菜单管理
|
||||
* Class Menu
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 当前操作数据库
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'SystemMenu';
|
||||
|
||||
/**
|
||||
* 系统菜单显示
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统菜单管理';
|
||||
$this->_page($this->table, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
if ($vo['url'] !== '#') {
|
||||
$vo['url'] = url($vo['url']) . (empty($vo['params']) ? '' : "?{$vo['params']}");
|
||||
}
|
||||
$vo['ids'] = join(',', Data::getArrSubIds($data, $vo['id']));
|
||||
}
|
||||
$data = Data::arr2table($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $vo
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _form_filter(&$vo)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
// 上级菜单处理
|
||||
$_menus = Db::name($this->table)->where(['status' => '1'])->order('sort asc,id asc')->select();
|
||||
$_menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
|
||||
$menus = Data::arr2table($_menus);
|
||||
foreach ($menus as $key => &$menu) if (substr_count($menu['path'], '-') > 3) unset($menus[$key]); # 移除三级以下的菜单
|
||||
elseif (isset($vo['pid']) && $vo['pid'] !== '' && $cur = "-{$vo['pid']}-{$vo['id']}")
|
||||
if (stripos("{$menu['path']}-", "{$cur}-") !== false || $menu['path'] === $cur) unset($menus[$key]); # 移除与自己相关联的菜单
|
||||
// 选择自己的上级菜单
|
||||
if (!isset($vo['pid']) && $this->request->get('pid', '0')) $vo['pid'] = $this->request->get('pid', '0');
|
||||
// 读取系统功能节点
|
||||
$nodes = \app\admin\service\Auth::get();
|
||||
foreach ($nodes as $key => $node) {
|
||||
if (empty($node['is_menu'])) unset($nodes[$key]);
|
||||
unset($nodes[$key]['pnode'], $nodes[$key]['is_login'], $nodes[$key]['is_menu'], $nodes[$key]['is_auth']);
|
||||
}
|
||||
list($this->menus, $this->nodes) = [$menus, array_values($nodes)];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用菜单
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用菜单
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
@ -33,7 +33,7 @@ class Node extends Controller
|
||||
|
||||
/**
|
||||
* 显示节点列表
|
||||
* @return mixed
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -51,6 +51,7 @@ class Node extends Controller
|
||||
|
||||
/**
|
||||
* 清理无效的节点数据
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
@ -1,163 +1,163 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统用户管理控制器
|
||||
* Class User
|
||||
* @package app\admin\controller
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2017/02/15 18:12
|
||||
*/
|
||||
class User extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 指定当前数据表
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemUser';
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统用户管理';
|
||||
$this->_query($this->table)->where(['is_deleted' => '0'])->like('username,phone,mail')->dateBetween('login_at')->equal('status')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权管理
|
||||
* @return mixed
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户添加
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户编辑
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户密码修改
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function pass()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
$this->verify = false;
|
||||
$this->_form($this->table, 'pass');
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
if ($post['password'] !== $post['repassword']) {
|
||||
$this->error('两次输入的密码不一致!');
|
||||
}
|
||||
$result = \app\admin\service\Auth::checkPassword($post['password']);
|
||||
if (empty($result['code'])) $this->error($result['msg']);
|
||||
$data = ['id' => $post['id'], 'password' => md5($post['password'])];
|
||||
if (Data::save($this->table, $data, 'id')) {
|
||||
$this->success('密码修改成功,下次请使用新密码登录!', '');
|
||||
} else {
|
||||
$this->error('密码修改失败,请稍候再试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据默认处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function _form_filter(&$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : '';
|
||||
if (isset($data['id'])) unset($data['username']);
|
||||
elseif (Db::name($this->table)->where(['username' => $data['username']])->count() > 0) {
|
||||
$this->error('用户账号已经存在,请使用其它账号!');
|
||||
}
|
||||
} else {
|
||||
$data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');
|
||||
$this->assign('authorizes', Db::name('SystemAuth')->where(['status' => '1'])->select());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if (in_array('10000', explode(',', $this->request->post('id')))) {
|
||||
$this->error('系统超级账号禁止删除!');
|
||||
}
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户禁用
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
if (in_array('10000', explode(',', $this->request->post('id')))) {
|
||||
$this->error('系统超级账号禁止操作!');
|
||||
}
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户禁用
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use library\Controller;
|
||||
use library\tools\Data;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统用户管理控制器
|
||||
* Class User
|
||||
* @package app\admin\controller
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2017/02/15 18:12
|
||||
*/
|
||||
class User extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 指定当前数据表
|
||||
* @var string
|
||||
*/
|
||||
public $table = 'SystemUser';
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统用户管理';
|
||||
$this->_query($this->table)->where(['is_deleted' => '0'])->like('username,phone,mail')->dateBetween('login_at')->equal('status')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权管理
|
||||
* @return mixed
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户添加
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户编辑
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户密码修改
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function pass()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
if ($this->request->isGet()) {
|
||||
$this->verify = false;
|
||||
$this->_form($this->table, 'pass');
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
if ($post['password'] !== $post['repassword']) {
|
||||
$this->error('两次输入的密码不一致!');
|
||||
}
|
||||
$result = \app\admin\service\Auth::checkPassword($post['password']);
|
||||
if (empty($result['code'])) $this->error($result['msg']);
|
||||
$data = ['id' => $post['id'], 'password' => md5($post['password'])];
|
||||
if (Data::save($this->table, $data, 'id')) {
|
||||
$this->success('密码修改成功,下次请使用新密码登录!', '');
|
||||
} else {
|
||||
$this->error('密码修改失败,请稍候再试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据默认处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function _form_filter(&$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : '';
|
||||
if (isset($data['id'])) unset($data['username']);
|
||||
elseif (Db::name($this->table)->where(['username' => $data['username']])->count() > 0) {
|
||||
$this->error('用户账号已经存在,请使用其它账号!');
|
||||
}
|
||||
} else {
|
||||
$data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');
|
||||
$this->assign('authorizes', Db::name('SystemAuth')->where(['status' => '1'])->select());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if (in_array('10000', explode(',', $this->request->post('id')))) {
|
||||
$this->error('系统超级账号禁止删除!');
|
||||
}
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户禁用
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
if (in_array('10000', explode(',', $this->request->post('id')))) {
|
||||
$this->error('系统超级账号禁止操作!');
|
||||
}
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户禁用
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\queue;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\service;
|
||||
@ -30,7 +30,7 @@ class Auth
|
||||
* 权限检查中间件入口
|
||||
* @param \think\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed|\think\response\Json|\think\response\Redirect
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
@ -72,18 +72,19 @@ class Auth
|
||||
* 获取系统代码节点
|
||||
* @param array $nodes
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function get($nodes = [])
|
||||
{
|
||||
$ignore = self::getIgnore();
|
||||
list($ignore, $map) = [self::getIgnore(), Node::getClassTreeNode(env('app_path'))];
|
||||
$alias = Db::name('SystemNode')->column('node,is_menu,is_auth,is_login,title');
|
||||
foreach (Node::getTree(env('app_path')) as $thr) {
|
||||
foreach (Node::getMethodTreeNode(env('app_path')) as $thr => $title) {
|
||||
foreach ($ignore as $str) if (stripos($thr, $str) === 0) continue 2;
|
||||
$tmp = explode('/', $thr);
|
||||
list($one, $two) = ["{$tmp[0]}", "{$tmp[0]}/{$tmp[1]}"];
|
||||
$nodes[$one] = array_merge(isset($alias[$one]) ? $alias[$one] : ['node' => $one, 'title' => '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => '']);
|
||||
$nodes[$two] = array_merge(isset($alias[$two]) ? $alias[$two] : ['node' => $two, 'title' => '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $one]);
|
||||
$nodes[$thr] = array_merge(isset($alias[$thr]) ? $alias[$thr] : ['node' => $thr, 'title' => '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $two]);
|
||||
$nodes[$two] = array_merge(isset($alias[$two]) ? $alias[$two] : ['node' => $two, 'title' => isset($map[$two]) ? $map[$two] : '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $one]);
|
||||
$nodes[$thr] = array_merge(isset($alias[$thr]) ? $alias[$thr] : ['node' => $thr, 'title' => $title, 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $two]);
|
||||
}
|
||||
foreach ($nodes as &$node) list($node['is_auth'], $node['is_menu'], $node['is_login']) = [intval($node['is_auth']), intval($node['is_menu']), empty($node['is_auth']) ? intval($node['is_login']) : 1];
|
||||
return $nodes;
|
||||
@ -124,7 +125,7 @@ class Auth
|
||||
|
||||
/**
|
||||
* 应用用户权限节点
|
||||
* @return bool
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
@ -153,6 +154,7 @@ class Auth
|
||||
/**
|
||||
* 获取授权后的菜单
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
if (!function_exists('auth')) {
|
||||
|
@ -16,13 +16,13 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="max-width:200px">framework 版本</td>
|
||||
<td style="max-width:200px">应用组件版本</td>
|
||||
<td>{:sysconf('app_version')}</td>
|
||||
<td style="max-width:200px">产品名称</td>
|
||||
<td>framework</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ThinkPHP 版本</td>
|
||||
<td>ThinkAdmin 版本</td>
|
||||
<td>{$think_ver}</td>
|
||||
<td>在线体验</td>
|
||||
<td>
|
||||
@ -44,8 +44,8 @@
|
||||
<td>{:php_sapi_name()}</td>
|
||||
<td>项目地址</td>
|
||||
<td>
|
||||
<a target="_blank" href="https://github.com/zoujingli/ThinkAdmin">
|
||||
https://github.com/zoujingli/ThinkAdmin
|
||||
<a target="_blank" href="https://github.com/zoujingli/framework">
|
||||
https://github.com/zoujingli/framework
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -54,8 +54,8 @@
|
||||
<td>{$mysql_ver}</td>
|
||||
<td>BUG反馈</td>
|
||||
<td>
|
||||
<a target="_blank" href="https://github.com/zoujingli/ThinkAdmin/issues">
|
||||
https://github.com/zoujingli/ThinkAdmin/issues
|
||||
<a target="_blank" href="https://github.com/zoujingli/framework/issues">
|
||||
https://github.com/zoujingli/framework/issues
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -75,7 +75,7 @@
|
||||
<td>POST大小限制</td>
|
||||
<td>{:ini_get('post_max_size')}</td>
|
||||
<td>办公地址</td>
|
||||
<td>广州市天河区东圃一横路东泷商贸中心C座316</td>
|
||||
<td>广州市天河区东圃一横路东泷商贸中心G02</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\controller;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\controller;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\handler;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\handler;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\handler;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\logic;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\logic;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\command;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\command\fans;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\command\fans;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\command\fans;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\command\fans;
|
||||
|
@ -1,98 +1,98 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use library\File;
|
||||
|
||||
/**
|
||||
* 模板配置
|
||||
* Class Config
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
/**
|
||||
* 公众号授权绑定
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function options()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->thrNotify = url('@wechat/api.push', '', false, true);
|
||||
if ($this->request->isGet()) {
|
||||
$this->title = '公众号授权绑定';
|
||||
if (!($this->geoip = cache('mygeoip'))) {
|
||||
cache('mygeoip', $this->geoip = gethostbyname($this->request->host()), 360);
|
||||
}
|
||||
$code = encode(url('@admin', '', true, true) . '#' . $this->request->url());
|
||||
$this->authurl = config('wechat.service_url') . "/service/api.push/auth/{$code}";
|
||||
if ($this->request->has('appid', 'get', true) && $this->request->has('appkey', 'get', true)) {
|
||||
sysconf('wechat_type', 'thr');
|
||||
sysconf('wechat_thr_appid', input('appid'));
|
||||
sysconf('wechat_thr_appkey', input('appkey'));
|
||||
Wechat::wechat()->setApiNotifyUri($this->thrNotify);
|
||||
}
|
||||
try {
|
||||
$this->wechat = Wechat::wechat()->getConfig();
|
||||
} catch (\Exception $e) {
|
||||
$this->wechat = [];
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
if ($this->request->post('wechat_type') === 'thr') {
|
||||
Wechat::wechat()->setApiNotifyUri($this->thrNotify);
|
||||
}
|
||||
$this->success('公众号参数获取成功!', url('@admin') . '#' . url('wechat/config/options'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号支付配置
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function payment()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '公众号支付配置';
|
||||
if ($this->request->isGet()) {
|
||||
$file = File::instance('local');
|
||||
$this->wechat_mch_ssl_cer = sysconf('wechat_mch_ssl_cer');
|
||||
$this->wechat_mch_ssl_key = sysconf('wechat_mch_ssl_key');
|
||||
$this->wechat_mch_ssl_p12 = sysconf('wechat_mch_ssl_p12');
|
||||
if (!$file->has($this->wechat_mch_ssl_cer, true)) $this->wechat_mch_ssl_cer = '';
|
||||
if (!$file->has($this->wechat_mch_ssl_key, true)) $this->wechat_mch_ssl_key = '';
|
||||
if (!$file->has($this->wechat_mch_ssl_p12, true)) $this->wechat_mch_ssl_p12 = '';
|
||||
return $this->fetch();
|
||||
}
|
||||
if ($this->request->post('wechat_mch_ssl_type') === 'p12') {
|
||||
if (!($sslp12 = $this->request->post('wechat_mch_ssl_p12'))) {
|
||||
$mchid = $this->request->post('wechat_mch_id');
|
||||
$content = File::instance('local')->get($sslp12, true);
|
||||
if (!openssl_pkcs12_read($content, $certs, $mchid)) {
|
||||
$this->error('商户MCH_ID与支付P12证书不匹配!');
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
$this->success('公众号支付配置成功!');
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use library\File;
|
||||
|
||||
/**
|
||||
* 模板配置
|
||||
* Class Config
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
/**
|
||||
* 公众号授权绑定
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function options()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->thrNotify = url('@wechat/api.push', '', false, true);
|
||||
if ($this->request->isGet()) {
|
||||
$this->title = '公众号授权绑定';
|
||||
if (!($this->geoip = cache('mygeoip'))) {
|
||||
cache('mygeoip', $this->geoip = gethostbyname($this->request->host()), 360);
|
||||
}
|
||||
$code = encode(url('@admin', '', true, true) . '#' . $this->request->url());
|
||||
$this->authurl = config('wechat.service_url') . "/service/api.push/auth/{$code}";
|
||||
if ($this->request->has('appid', 'get', true) && $this->request->has('appkey', 'get', true)) {
|
||||
sysconf('wechat_type', 'thr');
|
||||
sysconf('wechat_thr_appid', input('appid'));
|
||||
sysconf('wechat_thr_appkey', input('appkey'));
|
||||
Wechat::wechat()->setApiNotifyUri($this->thrNotify);
|
||||
}
|
||||
try {
|
||||
$this->wechat = Wechat::wechat()->getConfig();
|
||||
} catch (\Exception $e) {
|
||||
$this->wechat = [];
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
if ($this->request->post('wechat_type') === 'thr') {
|
||||
Wechat::wechat()->setApiNotifyUri($this->thrNotify);
|
||||
}
|
||||
$this->success('公众号参数获取成功!', url('@admin') . '#' . url('wechat/config/options'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号支付配置
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function payment()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '公众号支付配置';
|
||||
if ($this->request->isGet()) {
|
||||
$file = File::instance('local');
|
||||
$this->wechat_mch_ssl_cer = sysconf('wechat_mch_ssl_cer');
|
||||
$this->wechat_mch_ssl_key = sysconf('wechat_mch_ssl_key');
|
||||
$this->wechat_mch_ssl_p12 = sysconf('wechat_mch_ssl_p12');
|
||||
if (!$file->has($this->wechat_mch_ssl_cer, true)) $this->wechat_mch_ssl_cer = '';
|
||||
if (!$file->has($this->wechat_mch_ssl_key, true)) $this->wechat_mch_ssl_key = '';
|
||||
if (!$file->has($this->wechat_mch_ssl_p12, true)) $this->wechat_mch_ssl_p12 = '';
|
||||
return $this->fetch();
|
||||
}
|
||||
if ($this->request->post('wechat_mch_ssl_type') === 'p12') {
|
||||
if (!($sslp12 = $this->request->post('wechat_mch_ssl_p12'))) {
|
||||
$mchid = $this->request->post('wechat_mch_id');
|
||||
$content = File::instance('local')->get($sslp12, true);
|
||||
if (!openssl_pkcs12_read($content, $certs, $mchid)) {
|
||||
$this->error('商户MCH_ID与支付P12证书不匹配!');
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
$this->success('公众号支付配置成功!');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,132 +1,132 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\admin\service\Queue;
|
||||
use app\wechat\queue\Jobs;
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 微信粉丝管理
|
||||
* Class Fans
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Fans extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatFans';
|
||||
|
||||
/**
|
||||
* 微信粉丝管理
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '微信粉丝管理';
|
||||
$this->_query($this->table)->like('nickname')->equal('subscribe,is_black')
|
||||
->dateBetween('subscribe_at')->order('subscribe_time desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信粉丝列表处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$tags = Db::name('WechatFansTags')->column('id,name');
|
||||
foreach ($data as &$user) {
|
||||
$user['tags'] = [];
|
||||
foreach (explode(',', $user['tagid_list']) as $tagid) {
|
||||
if (isset($tags[$tagid])) $user['tags'][] = $tags[$tagid];
|
||||
}
|
||||
foreach (['country', 'province', 'city', 'nickname', 'remark'] as $k) {
|
||||
if (isset($user[$k])) $user[$k] = emoji_decode($user[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量拉黑粉丝
|
||||
*/
|
||||
public function setBlack()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
try {
|
||||
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
|
||||
Wechat::WeChatUser()->batchBlackList($openids);
|
||||
Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '1']);
|
||||
}
|
||||
$this->success('拉黑粉丝信息成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*批量取消拉黑粉丝
|
||||
*/
|
||||
public function delBlack()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
try {
|
||||
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
|
||||
Wechat::WeChatUser()->batchUnblackList($openids);
|
||||
Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '0']);
|
||||
}
|
||||
$this->success('取消拉黑粉丝信息成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("取消拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步粉丝列表
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
try {
|
||||
Queue::add('同步粉丝列表', Jobs::URI, 0, [], 0);
|
||||
$this->success('创建同步粉丝任务成功,需要时间来完成。<br>请到系统任务管理查看进度!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("创建同步粉丝任务失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除粉丝
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\admin\service\Queue;
|
||||
use app\wechat\queue\Jobs;
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 微信粉丝管理
|
||||
* Class Fans
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Fans extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatFans';
|
||||
|
||||
/**
|
||||
* 微信粉丝管理
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '微信粉丝管理';
|
||||
$this->_query($this->table)->like('nickname')->equal('subscribe,is_black')
|
||||
->dateBetween('subscribe_at')->order('subscribe_time desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信粉丝列表处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$tags = Db::name('WechatFansTags')->column('id,name');
|
||||
foreach ($data as &$user) {
|
||||
$user['tags'] = [];
|
||||
foreach (explode(',', $user['tagid_list']) as $tagid) {
|
||||
if (isset($tags[$tagid])) $user['tags'][] = $tags[$tagid];
|
||||
}
|
||||
foreach (['country', 'province', 'city', 'nickname', 'remark'] as $k) {
|
||||
if (isset($user[$k])) $user[$k] = emoji_decode($user[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量拉黑粉丝
|
||||
*/
|
||||
public function setBlack()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
try {
|
||||
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
|
||||
Wechat::WeChatUser()->batchBlackList($openids);
|
||||
Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '1']);
|
||||
}
|
||||
$this->success('拉黑粉丝信息成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*批量取消拉黑粉丝
|
||||
*/
|
||||
public function delBlack()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
try {
|
||||
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
|
||||
Wechat::WeChatUser()->batchUnblackList($openids);
|
||||
Db::name('WechatFans')->whereIn('openid', $openids)->update(['is_black' => '0']);
|
||||
}
|
||||
$this->success('取消拉黑粉丝信息成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("取消拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步粉丝列表
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
try {
|
||||
Queue::add('同步粉丝列表', Jobs::URI, 0, [], 0);
|
||||
$this->success('创建同步粉丝任务成功,需要时间来完成。<br>请到系统任务管理查看进度!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("创建同步粉丝任务失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除粉丝
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
}
|
@ -1,194 +1,194 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 回复规则管理
|
||||
* Class Keys
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Keys extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatKeys';
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'text' => '文字', 'news' => '图文', 'image' => '图片', 'music' => '音乐',
|
||||
'video' => '视频', 'voice' => '语音', 'customservice' => '转客服',
|
||||
];
|
||||
|
||||
/**
|
||||
* 显示关键字列表
|
||||
* @return array|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 关键字二维码生成
|
||||
if ($this->request->get('action') === 'qrc') {
|
||||
try {
|
||||
$wechat = Wechat::WeChatQrcode();
|
||||
$result = $wechat->create($this->request->get('keys', ''));
|
||||
$this->success('生成二维码成功!', "javascript:$.previewImage('{$wechat->url($result['ticket'])}')");
|
||||
} catch (\think\exception\HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("生成二维码失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
// 关键字列表显示
|
||||
$this->title = '回复规则管理';
|
||||
return $this->_query($this->table)->like('keys,type')->equal('status')->dateBetween('create_at')->whereNotIn('keys', ['subscribe', 'default'])->order('sort asc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
try {
|
||||
foreach ($data as &$vo) {
|
||||
$vo['qrc'] = url('@wechat/keys/index') . "?action=qrc&keys={$vo['keys']}";
|
||||
$vo['type'] = isset($this->types[$vo['type']]) ? $this->types[$vo['type']] : $vo['type'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加关键字
|
||||
* @return string
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '添加关键字规则';
|
||||
return $this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑关键字
|
||||
* @return string
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑关键字规则';
|
||||
return $this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关键字
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用关键字
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用关键字
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注默认回复
|
||||
* @return array|string
|
||||
*/
|
||||
public function subscribe()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑关注回复规则';
|
||||
return $this->_form($this->table, 'form', 'keys', [], ['keys' => 'subscribe']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 无配置默认回复
|
||||
* @return array|string
|
||||
*/
|
||||
public function defaults()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑默认回复规则';
|
||||
return $this->_form($this->table, 'form', 'keys', [], ['keys' => 'default']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost() && isset($data['keys'])) {
|
||||
$db = Db::name($this->table)->where('keys', $data['keys']);
|
||||
empty($data['id']) || $db->where('id', 'neq', $data['id']);
|
||||
if ($db->count() > 0) $this->error('关键字已经存在,请使用其它关键字!');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->msgTypes = $this->types;
|
||||
$root = rtrim(dirname(request()->basefile(true)), '\\/');
|
||||
$this->defaultImage = "{$root}/static/theme/img/image.png";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑结果处理
|
||||
* @param $result
|
||||
*/
|
||||
protected function _form_result($result)
|
||||
{
|
||||
if ($result !== false) {
|
||||
list($url, $keys) = ['', $this->request->post('keys')];
|
||||
if (!in_array($keys, ['subscribe', 'default'])) {
|
||||
$url = url('@admin') . '#' . url('wechat/keys/index') . '?spm=' . $this->request->get('spm');
|
||||
}
|
||||
$this->success('恭喜, 关键字保存成功!', $url);
|
||||
}
|
||||
$this->error('关键字保存失败, 请稍候再试!');
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 回复规则管理
|
||||
* Class Keys
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Keys extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatKeys';
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'text' => '文字', 'news' => '图文', 'image' => '图片', 'music' => '音乐',
|
||||
'video' => '视频', 'voice' => '语音', 'customservice' => '转客服',
|
||||
];
|
||||
|
||||
/**
|
||||
* 显示关键字列表
|
||||
* @return array|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 关键字二维码生成
|
||||
if ($this->request->get('action') === 'qrc') {
|
||||
try {
|
||||
$wechat = Wechat::WeChatQrcode();
|
||||
$result = $wechat->create($this->request->get('keys', ''));
|
||||
$this->success('生成二维码成功!', "javascript:$.previewImage('{$wechat->url($result['ticket'])}')");
|
||||
} catch (\think\exception\HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("生成二维码失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
// 关键字列表显示
|
||||
$this->title = '回复规则管理';
|
||||
return $this->_query($this->table)->like('keys,type')->equal('status')->dateBetween('create_at')->whereNotIn('keys', ['subscribe', 'default'])->order('sort asc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
try {
|
||||
foreach ($data as &$vo) {
|
||||
$vo['qrc'] = url('@wechat/keys/index') . "?action=qrc&keys={$vo['keys']}";
|
||||
$vo['type'] = isset($this->types[$vo['type']]) ? $this->types[$vo['type']] : $vo['type'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加关键字
|
||||
* @return string
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '添加关键字规则';
|
||||
return $this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑关键字
|
||||
* @return string
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑关键字规则';
|
||||
return $this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关键字
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用关键字
|
||||
*/
|
||||
public function forbid()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '0']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用关键字
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->_save($this->table, ['status' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注默认回复
|
||||
* @return array|string
|
||||
*/
|
||||
public function subscribe()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑关注回复规则';
|
||||
return $this->_form($this->table, 'form', 'keys', [], ['keys' => 'subscribe']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 无配置默认回复
|
||||
* @return array|string
|
||||
*/
|
||||
public function defaults()
|
||||
{
|
||||
$this->applyCsrfToken();
|
||||
$this->title = '编辑默认回复规则';
|
||||
return $this->_form($this->table, 'form', 'keys', [], ['keys' => 'default']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost() && isset($data['keys'])) {
|
||||
$db = Db::name($this->table)->where('keys', $data['keys']);
|
||||
empty($data['id']) || $db->where('id', 'neq', $data['id']);
|
||||
if ($db->count() > 0) $this->error('关键字已经存在,请使用其它关键字!');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->msgTypes = $this->types;
|
||||
$root = rtrim(dirname(request()->basefile(true)), '\\/');
|
||||
$this->defaultImage = "{$root}/static/theme/img/image.png";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑结果处理
|
||||
* @param $result
|
||||
*/
|
||||
protected function _form_result($result)
|
||||
{
|
||||
if ($result !== false) {
|
||||
list($url, $keys) = ['', $this->request->post('keys')];
|
||||
if (!in_array($keys, ['subscribe', 'default'])) {
|
||||
$url = url('@admin') . '#' . url('wechat/keys/index') . '?spm=' . $this->request->get('spm');
|
||||
}
|
||||
$this->success('恭喜, 关键字保存成功!', $url);
|
||||
}
|
||||
$this->error('关键字保存失败, 请稍候再试!');
|
||||
}
|
||||
|
||||
}
|
@ -1,155 +1,155 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\admin\service\Log;
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信菜单管理
|
||||
* Class Menu
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信菜单的类型
|
||||
* @var array
|
||||
*/
|
||||
protected $menuType = [
|
||||
'click' => '匹配规则',
|
||||
'view' => '跳转网页',
|
||||
'miniprogram' => '打开小程序',
|
||||
// 'customservice' => '转多客服',
|
||||
'scancode_push' => '扫码推事件',
|
||||
'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
|
||||
'pic_sysphoto' => '弹出系统拍照发图',
|
||||
'pic_photo_or_album' => '弹出拍照或者相册发图',
|
||||
'pic_weixin' => '弹出微信相册发图器',
|
||||
'location_select' => '弹出地理位置选择器',
|
||||
];
|
||||
|
||||
/**
|
||||
* 显示菜单列表
|
||||
* @return array
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->get('output') === 'json') {
|
||||
$where = [['keys', 'notin', ['subscribe', 'default']], ['status', 'eq', '1']];
|
||||
$keys = Db::name('WechatKeys')->where($where)->order('sort asc,id desc')->select();
|
||||
$this->success('获取数据成功!', ['menudata' => sysdata('menudata'), 'keysdata' => $keys]);
|
||||
}
|
||||
$this->title = '微信菜单定制';
|
||||
$this->menuTypes = $this->menuType;
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信菜单编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post('data');
|
||||
if (empty($data)) { // 删除菜单
|
||||
try {
|
||||
Wechat::WeChatMenu()->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->error('删除取消微信菜单失败,请稍候再试!' . $e->getMessage());
|
||||
}
|
||||
$this->success('删除并取消微信菜单成功!', '');
|
||||
}
|
||||
try {
|
||||
sysdata('menudata', $this->buildMenu($menudata = json_decode($data, true)));
|
||||
Wechat::WeChatMenu()->create(['button' => sysdata('menudata')]);
|
||||
} catch (\Exception $e) {
|
||||
$this->error("微信菜单发布失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
_syslog('微信管理', '发布微信菜单成功');
|
||||
$this->success('保存发布菜单成功!', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return mixed
|
||||
*/
|
||||
private function buildMenu(array $list)
|
||||
{
|
||||
foreach ($list as &$vo) {
|
||||
unset($vo['active'], $vo['show']);
|
||||
if (empty($vo['sub_button'])) {
|
||||
$vo = $this->build_menu_item($vo);
|
||||
} else {
|
||||
$item = ['name' => $vo['name'], 'sub_button' => []];
|
||||
foreach ($vo['sub_button'] as &$sub) {
|
||||
unset($sub['active'], $sub['show']);
|
||||
array_push($item['sub_button'], $this->build_menu_item($sub));
|
||||
}
|
||||
$vo = $item;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个微信菜单数据过滤处理
|
||||
* @param array $item
|
||||
* @return array
|
||||
*/
|
||||
private function build_menu_item(array $item)
|
||||
{
|
||||
switch (strtolower($item['type'])) {
|
||||
case 'pic_weixin':
|
||||
case 'pic_sysphoto':
|
||||
case 'scancode_push':
|
||||
case 'location_select':
|
||||
case 'scancode_waitmsg':
|
||||
case 'pic_photo_or_album':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => isset($item['key']) ? $item['key'] : $item['type']];
|
||||
case 'click':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => $item['key']];
|
||||
case 'view':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'url' => $item['url']];
|
||||
case 'miniprogram':
|
||||
return [
|
||||
'name' => $item['name'], 'type' => $item['type'], 'url' => $item['url'],
|
||||
'appid' => $item['appid'], 'pagepath' => $item['pagepath'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消菜单
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
try {
|
||||
Wechat::WeChatMenu()->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->error("菜单取消失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
$this->success('菜单取消成功,重新关注可立即生效!', '');
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\admin\service\Log;
|
||||
use app\wechat\service\Wechat;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信菜单管理
|
||||
* Class Menu
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信菜单的类型
|
||||
* @var array
|
||||
*/
|
||||
protected $menuType = [
|
||||
'click' => '匹配规则',
|
||||
'view' => '跳转网页',
|
||||
'miniprogram' => '打开小程序',
|
||||
// 'customservice' => '转多客服',
|
||||
'scancode_push' => '扫码推事件',
|
||||
'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
|
||||
'pic_sysphoto' => '弹出系统拍照发图',
|
||||
'pic_photo_or_album' => '弹出拍照或者相册发图',
|
||||
'pic_weixin' => '弹出微信相册发图器',
|
||||
'location_select' => '弹出地理位置选择器',
|
||||
];
|
||||
|
||||
/**
|
||||
* 显示菜单列表
|
||||
* @return array
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->get('output') === 'json') {
|
||||
$where = [['keys', 'notin', ['subscribe', 'default']], ['status', 'eq', '1']];
|
||||
$keys = Db::name('WechatKeys')->where($where)->order('sort asc,id desc')->select();
|
||||
$this->success('获取数据成功!', ['menudata' => sysdata('menudata'), 'keysdata' => $keys]);
|
||||
}
|
||||
$this->title = '微信菜单定制';
|
||||
$this->menuTypes = $this->menuType;
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信菜单编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post('data');
|
||||
if (empty($data)) { // 删除菜单
|
||||
try {
|
||||
Wechat::WeChatMenu()->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->error('删除取消微信菜单失败,请稍候再试!' . $e->getMessage());
|
||||
}
|
||||
$this->success('删除并取消微信菜单成功!', '');
|
||||
}
|
||||
try {
|
||||
sysdata('menudata', $this->buildMenu($menudata = json_decode($data, true)));
|
||||
Wechat::WeChatMenu()->create(['button' => sysdata('menudata')]);
|
||||
} catch (\Exception $e) {
|
||||
$this->error("微信菜单发布失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
_syslog('微信管理', '发布微信菜单成功');
|
||||
$this->success('保存发布菜单成功!', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $list
|
||||
* @return mixed
|
||||
*/
|
||||
private function buildMenu(array $list)
|
||||
{
|
||||
foreach ($list as &$vo) {
|
||||
unset($vo['active'], $vo['show']);
|
||||
if (empty($vo['sub_button'])) {
|
||||
$vo = $this->build_menu_item($vo);
|
||||
} else {
|
||||
$item = ['name' => $vo['name'], 'sub_button' => []];
|
||||
foreach ($vo['sub_button'] as &$sub) {
|
||||
unset($sub['active'], $sub['show']);
|
||||
array_push($item['sub_button'], $this->build_menu_item($sub));
|
||||
}
|
||||
$vo = $item;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个微信菜单数据过滤处理
|
||||
* @param array $item
|
||||
* @return array
|
||||
*/
|
||||
private function build_menu_item(array $item)
|
||||
{
|
||||
switch (strtolower($item['type'])) {
|
||||
case 'pic_weixin':
|
||||
case 'pic_sysphoto':
|
||||
case 'scancode_push':
|
||||
case 'location_select':
|
||||
case 'scancode_waitmsg':
|
||||
case 'pic_photo_or_album':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => isset($item['key']) ? $item['key'] : $item['type']];
|
||||
case 'click':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => $item['key']];
|
||||
case 'view':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'url' => $item['url']];
|
||||
case 'miniprogram':
|
||||
return [
|
||||
'name' => $item['name'], 'type' => $item['type'], 'url' => $item['url'],
|
||||
'appid' => $item['appid'], 'pagepath' => $item['pagepath'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消菜单
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
try {
|
||||
Wechat::WeChatMenu()->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->error("菜单取消失败,请稍候再试!<br> {$e->getMessage()}");
|
||||
}
|
||||
$this->success('菜单取消成功,重新关注可立即生效!', '');
|
||||
}
|
||||
|
||||
}
|
@ -1,160 +1,160 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Media;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信图文管理
|
||||
* Class News
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class News extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置默认操作表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatNews';
|
||||
|
||||
/**
|
||||
* 图文列表
|
||||
* @return array|string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '微信图文列表';
|
||||
$db = Db::name($this->table)->where(['is_deleted' => '0']);
|
||||
return parent::_page($db->order('id desc'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文列表数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) $vo = Media::news($vo['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文选择器
|
||||
* @return string
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文列表数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _select_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) $vo = Media::news($vo['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图文
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->title = '新建图文';
|
||||
return $this->fetch('form');
|
||||
}
|
||||
$data = $this->request->post();
|
||||
if (($ids = $this->_apply_news_article($data['data'])) && !empty($ids)) {
|
||||
if (data_save($this->table, ['article_id' => $ids, 'create_by' => session('user.id')], 'id') !== false) {
|
||||
$url = url('@admin') . '#' . url('@wechat/news/index') . '?spm=' . $this->request->get('spm');
|
||||
$this->success('图文添加成功!', $url);
|
||||
}
|
||||
}
|
||||
$this->error('图文添加失败,请稍候再试!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑图文
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->get('id', '');
|
||||
if ($this->request->isGet()) {
|
||||
empty($id) && $this->error('参数错误,请稍候再试!');
|
||||
if ($this->request->get('output') === 'json') {
|
||||
$this->success('获取数据成功!', Media::news($id));
|
||||
}
|
||||
return $this->fetch('form', ['title' => '编辑图文']);
|
||||
}
|
||||
$post = $this->request->post();
|
||||
if (isset($post['data']) && ($ids = $this->_apply_news_article($post['data']))) {
|
||||
if (data_save('wechat_news', ['id' => $id, 'article_id' => $ids], 'id')) {
|
||||
$this->success('图文更新成功!', url('@admin') . '#' . url('@wechat/news/index'));
|
||||
}
|
||||
}
|
||||
$this->error('图文更新失败,请稍候再试!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文更新操作
|
||||
* @param array $data
|
||||
* @param array $ids
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
private function _apply_news_article($data, $ids = [])
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['create_at'] = date('Y-m-d H:i:s');
|
||||
if (empty($vo['digest'])) {
|
||||
$vo['digest'] = mb_substr(strip_tags(str_replace(["\s", ' '], '', $vo['content'])), 0, 120);
|
||||
}
|
||||
if (empty($vo['id'])) {
|
||||
$result = $id = Db::name('WechatNewsArticle')->insertGetId($vo);
|
||||
} else {
|
||||
$id = intval($vo['id']);
|
||||
$result = Db::name('WechatNewsArticle')->where('id', $id)->update($vo);
|
||||
}
|
||||
if ($result !== false) array_push($ids, $id);
|
||||
}
|
||||
return join(',', $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://framework.thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\Media;
|
||||
use library\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信图文管理
|
||||
* Class News
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class News extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置默认操作表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'WechatNews';
|
||||
|
||||
/**
|
||||
* 图文列表
|
||||
* @return array|string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '微信图文列表';
|
||||
$db = Db::name($this->table)->where(['is_deleted' => '0']);
|
||||
return parent::_page($db->order('id desc'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文列表数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _index_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) $vo = Media::news($vo['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文选择器
|
||||
* @return string
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文列表数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function _select_page_filter(&$data)
|
||||
{
|
||||
foreach ($data as &$vo) $vo = Media::news($vo['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图文
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->title = '新建图文';
|
||||
return $this->fetch('form');
|
||||
}
|
||||
$data = $this->request->post();
|
||||
if (($ids = $this->_apply_news_article($data['data'])) && !empty($ids)) {
|
||||
if (data_save($this->table, ['article_id' => $ids, 'create_by' => session('user.id')], 'id') !== false) {
|
||||
$url = url('@admin') . '#' . url('@wechat/news/index') . '?spm=' . $this->request->get('spm');
|
||||
$this->success('图文添加成功!', $url);
|
||||
}
|
||||
}
|
||||
$this->error('图文添加失败,请稍候再试!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑图文
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->get('id', '');
|
||||
if ($this->request->isGet()) {
|
||||
empty($id) && $this->error('参数错误,请稍候再试!');
|
||||
if ($this->request->get('output') === 'json') {
|
||||
$this->success('获取数据成功!', Media::news($id));
|
||||
}
|
||||
return $this->fetch('form', ['title' => '编辑图文']);
|
||||
}
|
||||
$post = $this->request->post();
|
||||
if (isset($post['data']) && ($ids = $this->_apply_news_article($post['data']))) {
|
||||
if (data_save('wechat_news', ['id' => $id, 'article_id' => $ids], 'id')) {
|
||||
$this->success('图文更新成功!', url('@admin') . '#' . url('@wechat/news/index'));
|
||||
}
|
||||
}
|
||||
$this->error('图文更新失败,请稍候再试!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文更新操作
|
||||
* @param array $data
|
||||
* @param array $ids
|
||||
* @return string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
private function _apply_news_article($data, $ids = [])
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['create_at'] = date('Y-m-d H:i:s');
|
||||
if (empty($vo['digest'])) {
|
||||
$vo['digest'] = mb_substr(strip_tags(str_replace(["\s", ' '], '', $vo['content'])), 0, 120);
|
||||
}
|
||||
if (empty($vo['id'])) {
|
||||
$result = $id = Db::name('WechatNewsArticle')->insertGetId($vo);
|
||||
} else {
|
||||
$id = intval($vo['id']);
|
||||
$result = Db::name('WechatNewsArticle')->where('id', $id)->update($vo);
|
||||
}
|
||||
if ($result !== false) array_push($ids, $id);
|
||||
}
|
||||
return join(',', $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\queue;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 注册系统指令
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
|
@ -7,7 +7,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// IE兼容提示
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +--------------------------------------------------------------------*/
|
||||
|
||||
::-webkit-input-placeholder{color:#aaa}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +--------------------------------------------------------------------*/
|
||||
|
||||
body,html{height:100%}
|
||||
|
2
think
2
think
@ -10,7 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/ThinkAdmin
|
||||
// | github开源项目:https://github.com/zoujingli/framework
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think;
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35::getLoader();
|
||||
return ComposerAutoloaderInita2a5ca7b097a9d41d2230b028e215f7a::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35
|
||||
class ComposerAutoloaderInita2a5ca7b097a9d41d2230b028e215f7a
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -19,15 +19,15 @@ class ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInita2a5ca7b097a9d41d2230b028e215f7a', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInita2a5ca7b097a9d41d2230b028e215f7a', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@ -48,19 +48,19 @@ class ComposerAutoloaderInit407a0fe5b8b66687453d756daf4a3b35
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire407a0fe5b8b66687453d756daf4a3b35($fileIdentifier, $file);
|
||||
composerRequirea2a5ca7b097a9d41d2230b028e215f7a($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire407a0fe5b8b66687453d756daf4a3b35($fileIdentifier, $file)
|
||||
function composerRequirea2a5ca7b097a9d41d2230b028e215f7a($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35
|
||||
class ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a
|
||||
{
|
||||
public static $files = array (
|
||||
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
|
||||
@ -346,9 +346,9 @@ class ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit407a0fe5b8b66687453d756daf4a3b35::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInita2a5ca7b097a9d41d2230b028e215f7a::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
12
vendor/composer/installed.json
vendored
12
vendor/composer/installed.json
vendored
@ -177,8 +177,8 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v3.4.23",
|
||||
"version_normalized": "3.4.23.0",
|
||||
"version": "v3.4.24",
|
||||
"version_normalized": "3.4.24.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
@ -499,12 +499,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "5d8dbc0707782c5b68ea5600f19001e128ee39c5"
|
||||
"reference": "ee43486ce1f064a0702f229b0ce3a52a8f9bb5dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/5d8dbc0707782c5b68ea5600f19001e128ee39c5",
|
||||
"reference": "5d8dbc0707782c5b68ea5600f19001e128ee39c5",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ee43486ce1f064a0702f229b0ce3a52a8f9bb5dd",
|
||||
"reference": "ee43486ce1f064a0702f229b0ce3a52a8f9bb5dd",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -523,7 +523,7 @@
|
||||
"qiniu/php-sdk": "^7.2",
|
||||
"topthink/framework": "5.1.*"
|
||||
},
|
||||
"time": "2019-04-02T08:17:16+00:00",
|
||||
"time": "2019-04-03T05:55:15+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -96,7 +96,7 @@ class Sync extends Command
|
||||
private static function removeEmptyDir($dir)
|
||||
{
|
||||
if (is_dir($dir) && count(scandir($dir)) === 2) {
|
||||
rmdir($dir);
|
||||
if (rmdir($dir)) self::removeEmptyDir(dirname($dir));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Cors
|
||||
header('Access-Control-Allow-Methods:GET,POST,OPTIONS');
|
||||
header('Access-Control-Allow-Origin:' . self::getOrigin($request));
|
||||
header('Access-Control-Allow-Headers:' . self::getAllows($request));
|
||||
header('Access-Control-Expose-Headers: User-Token-Csrf');
|
||||
header('Access-Control-Expose-Headers:User-Token-Csrf');
|
||||
header('Content-Type:text/plain charset=UTF-8');
|
||||
header('Access-Control-Max-Age:1728000');
|
||||
header('HTTP/1.0 204 No Content');
|
||||
|
@ -21,6 +21,13 @@ namespace library\tools;
|
||||
*/
|
||||
class Node
|
||||
{
|
||||
|
||||
/**
|
||||
* 控制器忽略函数
|
||||
* @var array
|
||||
*/
|
||||
protected static $ignore = ['initialize', 'success', 'error', 'redirect', 'fetch', 'assign', 'callback'];
|
||||
|
||||
/**
|
||||
* 获取当前访问节点
|
||||
* @return string
|
||||
@ -32,6 +39,57 @@ class Node
|
||||
return self::parseString("{$module}/{$controller}") . '/' . strtolower($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取方法节点列表
|
||||
* @param string $dir 控制器根路径
|
||||
* @param array $nodes 额外数据
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function getMethodTreeNode($dir, $nodes = [])
|
||||
{
|
||||
foreach (self::scanDir($dir) as $file) {
|
||||
list($matches, $filename) = [[], str_replace(DIRECTORY_SEPARATOR, '/', $file)];
|
||||
if (!preg_match('|/(\w+)/controller/(.+)|', $filename, $matches)) continue;
|
||||
if (class_exists($classname = env('app_namespace') . str_replace('/', '\\', substr($matches[0], 0, -4)))) {
|
||||
foreach ((new \ReflectionClass($classname))->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
|
||||
list($function, $comment) = [$method->getName(), $method->getDocComment()];
|
||||
if (stripos($function, '_') === 0 || in_array($function, self::$ignore)) continue;
|
||||
$controller = str_replace('/', '.', substr($matches[2], 0, -4));
|
||||
if (stripos($controller, 'api.') !== false || stripos($controller, 'wap.') !== false) continue;
|
||||
$node = self::parseString("{$matches[1]}/{$controller}") . '/' . strtolower($function);
|
||||
$nodes[$node] = preg_replace('/^\/\*\*\*(.*?)\*.*?$/', '$1', preg_replace("/\s/", '', $comment));
|
||||
if (stripos($nodes[$node], '@') !== false) $nodes[$node] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取控制器节点列表
|
||||
* @param string $dir 控制器根路径
|
||||
* @param array $nodes 额外数据
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function getClassTreeNode($dir, $nodes = [])
|
||||
{
|
||||
foreach (self::scanDir($dir) as $file) {
|
||||
list($matches, $filename) = [[], str_replace(DIRECTORY_SEPARATOR, '/', $file)];
|
||||
if (!preg_match('|/(\w+)/controller/(.+)|', $filename, $matches)) continue;
|
||||
if (class_exists($classname = env('app_namespace') . str_replace('/', '\\', substr($matches[0], 0, -4)))) {
|
||||
$controller = str_replace('/', '.', substr($matches[2], 0, -4));
|
||||
if (stripos($controller, 'api.') !== false || stripos($controller, 'wap.') !== false) continue;
|
||||
$node = self::parseString("{$matches[1]}/{$controller}");
|
||||
$comment = (new \ReflectionClass($classname))->getDocComment();
|
||||
$nodes[$node] = preg_replace('/^\/\*\*\*(.*?)\*.*?$/', '$1', preg_replace("/\s/", '', $comment));
|
||||
if (stripos($nodes[$node], '@') !== false) $nodes[$node] = '';
|
||||
}
|
||||
}
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点列表
|
||||
* @param string $dir 控制器根路径
|
||||
@ -40,16 +98,15 @@ class Node
|
||||
*/
|
||||
public static function getTree($dir, $nodes = [])
|
||||
{
|
||||
$ignore = ['initialize', 'success', 'error', 'redirect', 'fetch', 'assign', 'callback'];
|
||||
foreach (self::scanDir($dir) as $file) {
|
||||
list($matches, $filename) = [[], str_replace(DIRECTORY_SEPARATOR, '/', $file)];
|
||||
if (!preg_match('|/(\w+)/controller/(.+)|', $filename, $matches)) continue;
|
||||
$className = env('app_namespace') . str_replace('/', '\\', substr($matches[0], 0, -4));
|
||||
if (class_exists($className)) foreach (get_class_methods($className) as $funcName) {
|
||||
if (stripos($funcName, '_') === 0 || in_array($funcName, $ignore)) continue;
|
||||
$classname = env('app_namespace') . str_replace('/', '\\', substr($matches[0], 0, -4));
|
||||
if (class_exists($classname)) foreach (get_class_methods($classname) as $function) {
|
||||
if (stripos($function, '_') === 0 || in_array($function, self::$ignore)) continue;
|
||||
$controller = str_replace('/', '.', substr($matches[2], 0, -4));
|
||||
if (stripos($controller, 'api.') !== false || stripos($controller, 'wap.') !== false) continue;
|
||||
$nodes[] = self::parseString("{$matches[1]}/{$controller}") . '/' . strtolower($funcName);
|
||||
$nodes[] = self::parseString("{$matches[1]}/{$controller}") . '/' . strtolower($function);
|
||||
}
|
||||
}
|
||||
return $nodes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user