From 5a4c3f2529c6a2a465ff9949c8e66ce4a1808c0b Mon Sep 17 00:00:00 2001 From: 1099438829 <1099438829@qq.com> Date: Thu, 18 Feb 2021 16:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=A4=A7=E6=B3=A2=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .constant | 3 - .gitee/ISSUE_TEMPLATE.zh-CN.md | 13 -- .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 14 -- app/AppService.php | 2 +- app/admin/controller/Admin.php | 4 +- app/admin/controller/AdminAuth.php | 4 +- app/admin/controller/AdminLog.php | 2 +- app/admin/controller/AdminNotify.php | 2 +- app/admin/controller/AdminRole.php | 4 +- app/admin/controller/Article.php | 2 +- app/admin/controller/Category.php | 4 +- app/admin/controller/Files.php | 4 +- app/admin/controller/FriendLink.php | 2 +- app/admin/controller/Images.php | 8 +- app/admin/controller/Index.php | 2 +- app/admin/controller/Invitation.php | 2 +- app/admin/controller/Login.php | 2 +- app/admin/controller/Message.php | 2 +- app/admin/controller/Slides.php | 2 +- app/admin/controller/SystemBasic.php | 3 +- app/admin/controller/SystemConfig.php | 4 +- app/admin/controller/SystemConfigTab.php | 4 +- app/admin/controller/TemplateTrait.php | 2 +- app/admin/controller/User.php | 7 +- app/admin/model/Attachment.php | 2 +- app/admin/model/User.php | 92 +++++++++++ .../admin}/services/FormBuilderService.php | 4 +- {learn => app/admin}/services/UtilService.php | 4 +- .../admin}/subscribes/AdminSubscribe.php | 4 +- app/admin/view/user/index.html | 41 ++--- app/common.php | 4 +- .../common}/exceptions/AuthException.php | 4 +- .../interfaces/MiddlewareInterface.php | 4 +- .../middleware/AllowOriginMiddleware.php | 4 +- .../middleware/AuthTokenMiddleware.php | 10 +- {learn => app/common}/utils/Curl.php | 4 +- {learn => app/common}/utils/Json.php | 4 +- {learn => app/common}/utils/Jwt.php | 4 +- {learn => app/common}/utils/Mail.php | 4 +- {learn => app/common}/utils/Session.php | 2 +- .../common/validate}/RegisterValidates.php | 2 +- app/event.php | 15 +- app/index/controller/Base.php | 2 +- learn/basic/admin/BaseController.php | 122 -------------- learn/basic/index/BaseController.php | 122 -------------- learn/subscribes/RedisSubscribe.php | 10 -- learn/subscribes/SystemSubscribe.php | 23 --- learn/subscribes/TimerSubscribe.php | 60 ------- learn/workerman/Response.php | 101 ------------ learn/workerman/TimerService.php | 88 ---------- learn/workerman/admin/WorkerHandle.php | 128 --------------- learn/workerman/admin/WorkerService.php | 152 ------------------ learn/workerman/channel/ChannelClient.php | 73 --------- learn/workerman/channel/ChannelService.php | 140 ---------------- learn/workerman/chat/WorkerService.php | 43 ----- public/install/leapy.sql | 2 +- public/template/default/blog.html | 2 +- public/template/default/contact.html | 10 +- public/template/default/features.html | 2 +- public/template/default/footer.html | 2 +- public/template/default/index.html | 2 +- public/template/default/price.html | 2 +- public/template/default/search.html | 4 +- public/template/default/single-blog.html | 2 +- 64 files changed, 186 insertions(+), 1212 deletions(-) delete mode 100644 .constant delete mode 100644 .gitee/ISSUE_TEMPLATE.zh-CN.md delete mode 100644 .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md create mode 100644 app/admin/model/User.php rename {learn => app/admin}/services/FormBuilderService.php (94%) rename {learn => app/admin}/services/UtilService.php (96%) rename {learn => app/admin}/subscribes/AdminSubscribe.php (84%) rename {learn => app/common}/exceptions/AuthException.php (59%) rename {learn => app/common}/interfaces/MiddlewareInterface.php (70%) rename {learn => app/common}/middleware/AllowOriginMiddleware.php (91%) rename {learn => app/common}/middleware/AuthTokenMiddleware.php (86%) rename {learn => app/common}/utils/Curl.php (98%) rename {learn => app/common}/utils/Json.php (98%) rename {learn => app/common}/utils/Jwt.php (96%) rename {learn => app/common}/utils/Mail.php (96%) rename {learn => app/common}/utils/Session.php (91%) rename {learn/validates => app/common/validate}/RegisterValidates.php (96%) delete mode 100644 learn/basic/admin/BaseController.php delete mode 100644 learn/basic/index/BaseController.php delete mode 100644 learn/subscribes/RedisSubscribe.php delete mode 100644 learn/subscribes/SystemSubscribe.php delete mode 100644 learn/subscribes/TimerSubscribe.php delete mode 100644 learn/workerman/Response.php delete mode 100644 learn/workerman/TimerService.php delete mode 100644 learn/workerman/admin/WorkerHandle.php delete mode 100644 learn/workerman/admin/WorkerService.php delete mode 100644 learn/workerman/channel/ChannelClient.php delete mode 100644 learn/workerman/channel/ChannelService.php delete mode 100644 learn/workerman/chat/WorkerService.php diff --git a/.constant b/.constant deleted file mode 100644 index d919562..0000000 --- a/.constant +++ /dev/null @@ -1,3 +0,0 @@ -find(); + if (!$info) return self::setErrorInfo("登录账号不存在"); + if ($info['pwd'] != md5(md5($pwd))) return self::setErrorInfo("密码不正确!"); + if ($info['status'] == 2) return self::setErrorInfo("账号已被冻结!"); + self::setLoginInfo($info); + return true; + } + + /** + * 设置登录信息 + * @param $info + * @return bool + */ + public static function setLoginInfo($info) + { + Session::set("adminId",$info['id']); + Session::set("adminInfo",$info->toArray()); + event("AdminLog",[$info->toArray(),"admin","login","login"]); + return true; + } + + /** + * 退出登录 + */ + public static function clearLoginInfo() + { + Session::delete("adminId"); + Session::delete("adminInfo"); + Session::clear(); + return true; + } + + /** + * 是否登录 + * @return bool + */ + public static function isActive(): bool + { + return Session::has('adminId') && Session::has('adminInfo'); + } + + /** + * 列表 + * @param array $where + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function systemPage(array $where): array + { + $model = new self; + if ($where['name'] != '') $model = $model->where("username|nickname","like","%$where[name]%"); + if ($where['start_time'] != '') $model = $model->where("create_time",">",strtotime($where['start_time']." 00:00:00")); + if ($where['end_time'] != '') $model = $model->where("create_time","<", strtotime($where['end_time']." 23:59:59")); + if ($where['tel'] != '') $model = $model->where("tel|mail", "like","%$where[tel]%"); + if ($where['status'] != '') $model = $model->where("status",$where['status']); + $count = self::counts($model); + if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'],(int)$where['limit']); + $data = $model->select(); + $data = $data ? $data->toArray() : []; + return compact("data","count"); + } +} \ No newline at end of file diff --git a/learn/services/FormBuilderService.php b/app/admin/services/FormBuilderService.php similarity index 94% rename from learn/services/FormBuilderService.php rename to app/admin/services/FormBuilderService.php index 06ccdc7..351c308 100644 --- a/learn/services/FormBuilderService.php +++ b/app/admin/services/FormBuilderService.php @@ -1,14 +1,14 @@ - 登录页面 - {:system_config("title")}后台管理系统 + 用户管理 - {:system_config("title")}后台管理系统 {include file="public/header" /} @@ -76,19 +76,11 @@ pagination: true, // 是否显示分页 sortOrder: "asc", // 排序方式 queryParams: function(params) { - var add_time = new Array(); - $("input[name='add_time']").each(function(){ - add_time.push($(this).val()); - }); - var temp = { - is_read: $('#is_read option:selected').val(), - type: $('#type option:selected').val(), - add_time: add_time, - limit: params.limit, // 每页数据量 - page: (params.offset / params.limit) + 1, - }; + let temp = toArrayList($(".searchForm").serializeArray()); + temp['limit'] = params.limit; + temp['page'] = (params.offset / params.limit) + 1; return temp; - }, // 传递参数 + }, // 传递参数 sidePagination: "server", // 分页方式:client客户端分页,server服务端分页 pageNumber: 1, // 初始化加载第一页,默认第一页 pageSize: 10, // 每页的记录行数 @@ -99,7 +91,7 @@ field: 'id', title: '留言ID', }, { - field: 'name', + field: 'truename', title: '用户昵称' }, { field: 'tel', @@ -107,31 +99,28 @@ }, { field: 'email', title: '邮箱' - }, { - field: 'type', - title: '留言来源' - }, { - field: 'content', - title: '内容', }, { field: 'ip', title: 'ip', }, { - field: 'user_agent', - title: 'UserAgent', + field: 'is_admin', + title: '管理员', + formatter: function (value, row, index) { + return value?'是':'否'; + } }, { - field: 'add_time', + field: 'create_time', title: '创建时间', }, { - field: 'is_read', - title: '是否已读', + field: 'status', + title: '状态', formatter: function (value, row, index) { if (value == 0) { is_checked = ''; } else if (value == 1){ is_checked = 'checked="checked"'; } - var field = "is_read"; + var field = "status"; result = ''; return result; }, diff --git a/app/common.php b/app/common.php index fb18ec8..d59b52d 100644 --- a/app/common.php +++ b/app/common.php @@ -15,7 +15,7 @@ if (!function_exists('system_config_more')) { $systemConfig = cache('systemConfig'); if (empty($systemConfig)){ - $systemConfig = \app\admin\model\system\SystemConfig::getSystemConfigValues(); + $systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues(); cache('systemConfig',$systemConfig); } $data = []; @@ -75,7 +75,7 @@ if (!function_exists('system_config')) { $systemConfig = cache('systemConfig'); if (empty($systemConfig)){ - $systemConfig = \app\admin\model\system\SystemConfig::getSystemConfigValues(); + $systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues(); cache('systemConfig',$systemConfig); } return $systemConfig[$formName]??''; diff --git a/learn/exceptions/AuthException.php b/app/common/exceptions/AuthException.php similarity index 59% rename from learn/exceptions/AuthException.php rename to app/common/exceptions/AuthException.php index 7dec24b..b22a5e3 100644 --- a/learn/exceptions/AuthException.php +++ b/app/common/exceptions/AuthException.php @@ -1,13 +1,13 @@ [ - 'Task_1'=>[],//1秒钟执行的方法 - 'Task_5'=>[],//5秒钟执行的方法 - 'Task_10'=>[],//10秒钟执行的方法 - 'Task_30'=>[],//30秒钟执行的方法 - 'Task_60'=>[],//60秒钟执行的方法 - 'AppInit' => [], - 'HttpRun' => [], - 'HttpEnd' => [], - 'LogLevel' => [], - 'LogWrite' => [], - 'Test' => [], // 后台通知测试 'AdminLog' => [], // 操作日志记录 ], 'subscribe' => [ - \learn\subscribes\AdminSubscribe::class, // 操作记录 - \learn\subscribes\SystemSubscribe::class, // 系统通知 - \learn\subscribes\TimerSubscribe::class, // 定时器 + \app\admin\subscribes\AdminSubscribe::class, // 操作记录 ], ]; diff --git a/app/index/controller/Base.php b/app/index/controller/Base.php index 93d16fb..b2677e5 100644 --- a/app/index/controller/Base.php +++ b/app/index/controller/Base.php @@ -6,7 +6,7 @@ use app\BaseController; use think\facade\Config; use think\facade\Db; use think\facade\View; -use app\admin\model\system\SystemConfig; +use app\admin\model\SystemConfig; /** * 控制器基础类 diff --git a/learn/basic/admin/BaseController.php b/learn/basic/admin/BaseController.php deleted file mode 100644 index 48f08db..0000000 --- a/learn/basic/admin/BaseController.php +++ /dev/null @@ -1,122 +0,0 @@ -app = $app; - $this->request = app("request"); - - // 控制器初始化 - $this->initialize(); - } - - // 初始化 - protected function initialize() - {} - - /** - * 验证数据 - * @access protected - * @param array $data 数据 - * @param string|array $validate 验证器名或者验证规则数组 - * @param array $message 提示信息 - * @param bool $batch 是否批量验证 - * @return array|string|true - * @throws ValidateException - */ - protected function validate(array $data, $validate, array $message = [], bool $batch = false) - { - if (is_array($validate)) { - $v = new Validate(); - $v->rule($validate); - } else { - if (strpos($validate, '.')) { - // 支持场景 - [$validate, $scene] = explode('.', $validate); - } - $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); - $v = new $class(); - if (!empty($scene)) { - $v->scene($scene); - } - } - - $v->message($message); - - // 是否批量验证 - if ($batch || $this->batchValidate) { - $v->batch(true); - } - - return $v->failException(true)->check($data); - } - - /** - * 视图赋值 - * @param mixed ...$vars - */ - protected function assign(...$vars) - { - View::assign(...$vars); - } - - /** - * 返回视图 - * @return string - * @throws \Exception - */ - protected function fetch(string $template = '') - { - return View::fetch($template); - } - - /** - * 页面 - * @param mixed ...$args - */ - protected function redirect(...$args){ - throw new HttpResponseException(redirect(...$args)); - } -} diff --git a/learn/basic/index/BaseController.php b/learn/basic/index/BaseController.php deleted file mode 100644 index 66db635..0000000 --- a/learn/basic/index/BaseController.php +++ /dev/null @@ -1,122 +0,0 @@ -app = $app; - $this->request = app("request"); - - // 控制器初始化 - $this->initialize(); - } - - // 初始化 - protected function initialize() - {} - - /** - * 验证数据 - * @access protected - * @param array $data 数据 - * @param string|array $validate 验证器名或者验证规则数组 - * @param array $message 提示信息 - * @param bool $batch 是否批量验证 - * @return array|string|true - * @throws ValidateException - */ - protected function validate(array $data, $validate, array $message = [], bool $batch = false) - { - if (is_array($validate)) { - $v = new Validate(); - $v->rule($validate); - } else { - if (strpos($validate, '.')) { - // 支持场景 - [$validate, $scene] = explode('.', $validate); - } - $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); - $v = new $class(); - if (!empty($scene)) { - $v->scene($scene); - } - } - - $v->message($message); - - // 是否批量验证 - if ($batch || $this->batchValidate) { - $v->batch(true); - } - - return $v->failException(true)->check($data); - } - - /** - * 视图赋值 - * @param mixed ...$vars - */ - protected function assign(...$vars) - { - View::assign(...$vars); - } - - /** - * 返回视图 - * @return string - * @throws \Exception - */ - protected function fetch(string $template = '') - { - return View::fetch($template); - } - - /** - * 页面 - * @param mixed ...$args - */ - protected function redirect(...$args){ - throw new HttpResponseException(redirect(...$args)); - } -} diff --git a/learn/subscribes/RedisSubscribe.php b/learn/subscribes/RedisSubscribe.php deleted file mode 100644 index 4a03fe0..0000000 --- a/learn/subscribes/RedisSubscribe.php +++ /dev/null @@ -1,10 +0,0 @@ -send("Message",[]); - } -} \ No newline at end of file diff --git a/learn/subscribes/TimerSubscribe.php b/learn/subscribes/TimerSubscribe.php deleted file mode 100644 index 75f4031..0000000 --- a/learn/subscribes/TimerSubscribe.php +++ /dev/null @@ -1,60 +0,0 @@ -connection = $connection; - return $this; - } - - /** - * 发送请求 - * - * @param string $type - * @param array|null $data - * @param bool $close - * @param array $other - * @return bool|null - */ - public function send(string $type, ?array $data = null, bool $close = false, array $other = []) - { - $this->connection->lastMessageTime = time(); - $res = compact('type'); - - if (!is_null($data)) $res['data'] = $data; - $data = array_merge($res, $other); - - if ($close) - $data['close'] = true; - - $json = json_encode($data); - - return $close - ? ($this->connection->close($json) && true) - : $this->connection->send($json); - } - - /** - * 成功 - * - * @param string $message - * @param array|null $data - * @return bool|null - */ - public function success($type = 'success', ?array $data = null) - { - if (is_array($type)) { - $data = $type; - $type = 'success'; - } - return $this->send($type, $data); - } - - /** - * 失败 - * - * @param string $message - * @param array|null $data - * @return bool|null - */ - public function fail($type = 'error', ?array $data = null) - { - if (is_array($type)) { - $data = $type; - $type = 'error'; - } - return $this->send($type, $data); - } - - /** - * 关闭连接 - * - * @param string $type - * @param array|null $data - * @return bool|null - */ - public function close($type = 'error', ?array $data = null) - { - if (is_array($type)) { - $data = $type; - $type = 'error'; - } - return $this->send($type, $data, true); - } -} \ No newline at end of file diff --git a/learn/workerman/TimerService.php b/learn/workerman/TimerService.php deleted file mode 100644 index d159224..0000000 --- a/learn/workerman/TimerService.php +++ /dev/null @@ -1,88 +0,0 @@ - 1, - 'name' => 'timer' - ]; - - /** - * @param Worker $worker - */ - protected function init(Worker $worker = null) - { - parent::init(); // TODO: Change the autogenerated stub - $this->worker = $worker; - } - - /** - * 定时器开启 - * @throws \Exception - */ - public function onWorkerStart() - { - $last = time(); - $task = [1 => $last, 5 => $last, 10 => $last, 30 => $last, 60 => $last, 14400 => $last, 86400 => $last]; - $this->timer = Timer::add($this->interval, function () use (&$task) { - try { - $now = time(); - foreach ($task as $sec => $time) { - if ($now - $time >= $sec) { - event('Task_' . $sec); - $task[$sec] = $now; - } - } - } catch (\Exception $e) { - var_dump($e); - // 出错定时器停止 - Timer::del($this->timer); - } - }); - } -} - diff --git a/learn/workerman/admin/WorkerHandle.php b/learn/workerman/admin/WorkerHandle.php deleted file mode 100644 index 7973264..0000000 --- a/learn/workerman/admin/WorkerHandle.php +++ /dev/null @@ -1,128 +0,0 @@ -service = &$service; - } - - /** - * 后台登录 - * @param TcpConnection $connection - * @param array $res - * @param Response $response - * @return bool|null - */ - public function login(TcpConnection &$connection, array $res, Response $response) - { - if (!isset($res['data']) || !$sessionId = $res['data']) { - return $response->close([ - 'msg' => '授权失败!' - ]); - } - - MySession::setId($sessionId); - - if (!Session::has('adminId') || !Session::has('adminInfo')) { - return $response->close([ - 'msg' => '授权失败!' - ]); - } - - $connection->adminInfo = Session::get('adminInfo'); - $connection->sessionId = $sessionId; - - $this->service->setUser($connection); - - return $response->success(); - } - - /** - * 超时关闭 - * @param Worker $worker - * @param Response $response - */ - public function timeoutClose(Worker $worker,Response $response) - { - $time_now = time(); - foreach ($worker->connections as $connection) { - if ($time_now - $connection->lastMessageTime > 28) { - $response->connection($connection)->close('timeout'); - } - } - } - - /** - * 后台微信扫码登录 - * @param TcpConnection $connection - * @param array $res - * @param Response $response - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @throws \Psr\SimpleCache\InvalidArgumentException - */ - public function qrcode(TcpConnection &$connection, array $res, Response $response) - { - MySession::setId($res['token']); - // 保存缓存 - if (Cache::store('redis')->has($res['token'])) - { - $response->connection($connection)->send('qrcode',['src'=>Cache::store('redis')->get($res['token'])]); - } - else - { - $qrcode = WechatService::temporary("type=login&method=wechat&to=admin&token=$res[token]",180); - Cache::store('redis')->set($res['token'],$qrcode,180); - $response->connection($connection)->send('qrcode',['src'=>$qrcode]); - } - } - - /** - * 验证二维码是否有效 - * @param TcpConnection $connection - * @param array $res - * @param Response $response - * @throws \Psr\SimpleCache\InvalidArgumentException - */ - public function valid(TcpConnection &$connection, array $res, Response $response) - { - try { - if (Cache::store('redis')->has("info_".$res['token'])) - { - if (Admin::setLoginInfo(Cache::store('redis')->get("info_".$res['token']))) - { - $response->connection($connection)->close('valid',['status'=>200]); - Cache::store('redis')->delete($res['token']); - Cache::store('redis')->delete("info_".$res['token']); - } - } - elseif(Cache::store('redis')->has($res['token'])) $response->connection($connection)->send('valid',['status'=>300]); - else $response->connection($connection)->close('valid',['status'=>400]); - }catch (\Exception $e) - { - file_put_contents("wsLogin.log",$e->getMessage()); - $response->connection($connection)->close('valid',['status'=>200]); - } - } -} \ No newline at end of file diff --git a/learn/workerman/admin/WorkerService.php b/learn/workerman/admin/WorkerService.php deleted file mode 100644 index 383e154..0000000 --- a/learn/workerman/admin/WorkerService.php +++ /dev/null @@ -1,152 +0,0 @@ - 1, - 'name' => 'admin' - ]; - - /** - * 定时程序 - * @var null - */ - protected $time; - - /** - * @var Worker - */ - protected $worker; - - /** - * @var TcpConnection[] - */ - protected $connections = []; - - /** - * @var TcpConnection[] - */ - protected $user = []; - - /** - * @var WorkerHandle - */ - protected $handle; - - /** - * @var Response - */ - protected $response; - - public function setUser(TcpConnection $connection) - { - $this->user[$connection->adminInfo['id']] = $connection; - } - - /** - * worker constructor. - * @param Worker|null $worker - */ - protected function init(Worker $worker = null) - { - parent::init(); - $this->worker = $worker; - $this->handle = new WorkerHandle($this); - $this->response = new Response(); - } - - /** - * 连接 - * @param TcpConnection $connection - */ - public function onConnect(TcpConnection $connection) - { - $this->connections[$connection->id] = $connection; - $connection->lastMessageTime = time(); - } - - /** - * 当获取到信息 - * @param TcpConnection $connection - * @param $res - * @return bool|void|null - */ - public function onMessage(TcpConnection $connection, $res) - { - $connection->lastMessageTime = time(); - $res = json_decode($res, true); - if (!$res || !isset($res['type']) || !$res['type']) return; - if ($res['type'] == 'ping') return $this->response->connection($connection)->send('pong'); - if (!method_exists($this->handle, $res['type'])) return; - $this->handle->{$res['type']}($connection, $res + ['data' => []], $this->response->connection($connection)); - } - - /** - * 开启时 - * @param Worker $worker - * @throws \Exception - */ - public function onWorkerStart(Worker $worker) - { - // 开启订阅 - ChannelClient::connet(); - Client::on('learn', function ($eventData) use ($worker) { - if (!isset($eventData['type']) || !$eventData['type']) return; - $ids = isset($eventData['ids']) && count($eventData['ids']) ? $eventData['ids'] : array_keys($this->user); - foreach ($ids as $id) { - if (isset($this->user[$id])) - $this->response->connection($this->user[$id])->success($eventData['type'], $eventData['data'] ?? null); - } - }); - - // 超时关闭 - Timer::add(35, array($this->handle, 'timeoutClose'), array($worker,$this->response), true); - } - - /** - * 连接关闭 - * @param TcpConnection $connection - */ - public function onClose(TcpConnection $connection) - { - unset($this->connections[$connection->id]); - } -} \ No newline at end of file diff --git a/learn/workerman/channel/ChannelClient.php b/learn/workerman/channel/ChannelClient.php deleted file mode 100644 index 5ec7abe..0000000 --- a/learn/workerman/channel/ChannelClient.php +++ /dev/null @@ -1,73 +0,0 @@ -trigger('learn', $res); - } - - public function trigger(string $type, ?array $data = null) - { - Client::publish($type, $data); - } -} \ No newline at end of file diff --git a/learn/workerman/channel/ChannelService.php b/learn/workerman/channel/ChannelService.php deleted file mode 100644 index e7edafb..0000000 --- a/learn/workerman/channel/ChannelService.php +++ /dev/null @@ -1,140 +0,0 @@ - 1, - 'name' => 'ChannelServer' - ]; - - /** - * 事件 - * @var array - */ - protected $event = ['onMessage', 'onClose']; - - /** - * 实例化 - */ - public function init() - { - $this->worker->channels = array(); - $this->_worker = $this->worker; - parent::init(); - } - - /** - * onClose - * @param $connection - * @return void - */ - public function onClose($connection) - { - if(empty($connection->channels)) - { - return; - } - foreach($connection->channels as $channel) - { - unset($this->_worker->channels[$channel][$connection->id]); - if(empty($this->_worker->channels[$channel])) - { - unset($this->_worker->channels[$channel]); - } - } - } - - /** - * onMessage. - * @param TcpConnection $connection - * @param string $data - */ - public function onMessage($connection, $data) - { - if(!$data) - { - return; - } - $worker = $this->_worker; - $data = unserialize($data); - $type = $data['type']; - $channels = $data['channels']; - switch($type) - { - case 'subscribe': - foreach($channels as $channel) - { - $connection->channels[$channel] = $channel; - $worker->channels[$channel][$connection->id] = $connection; - } - break; - case 'unsubscribe': - foreach($channels as $channel) - { - if(isset($connection->channels[$channel])) - { - unset($connection->channels[$channel]); - } - if(isset($worker->channels[$channel][$connection->id])) - { - unset($worker->channels[$channel][$connection->id]); - if(empty($worker->channels[$channel])) - { - unset($worker->channels[$channel]); - } - } - } - break; - case 'publish': - foreach($channels as $channel) - { - if(empty($worker->channels[$channel])) - { - continue; - } - $buffer = serialize(array('channel'=>$channel, 'data' => $data['data']))."\n"; - foreach($worker->channels[$channel] as $connection) - { - $connection->send($buffer); - } - } - break; - } - } -} \ No newline at end of file diff --git a/learn/workerman/chat/WorkerService.php b/learn/workerman/chat/WorkerService.php deleted file mode 100644 index 3f5cc96..0000000 --- a/learn/workerman/chat/WorkerService.php +++ /dev/null @@ -1,43 +0,0 @@ - 1, - 'name' => 'chat' - ]; - -} \ No newline at end of file diff --git a/public/install/leapy.sql b/public/install/leapy.sql index fdae2f1..09c5367 100644 --- a/public/install/leapy.sql +++ b/public/install/leapy.sql @@ -305,7 +305,7 @@ CREATE TABLE `lea_system_config` ( -- ---------------------------- -- Records of lea_system_config -- ---------------------------- -INSERT INTO `lea_system_config` VALUES (1, 1, '网站标题', 'title', 'text', 'input', 0, '', '派后台管理系统', 'systemConfig(\"title\")', 90, 1, 1, '1', '1582792265', '1', '1583855342'); +INSERT INTO `lea_system_config` VALUES (1, 1, '网站标题', 'title', 'text', 'input', 0, '', '派后台管理系统', 'system_config(\"title\")', 90, 1, 1, '1', '1582792265', '1', '1583855342'); INSERT INTO `lea_system_config` VALUES (2, 1, '网站图标', 'favicon', 'file', 'input', 0, '', 'http://file.cos.leapy.cn/image/20200509/898b720200509204528197.jpg', '', 89, 1, 1, '1', '1582793160', NULL, NULL); INSERT INTO `lea_system_config` VALUES (3, 1, '站点关键词', 'keywords', 'text', 'input', 0, '', '派后台管理系统', '', 88, 1, 1, '1', '1582793221', NULL, NULL); INSERT INTO `lea_system_config` VALUES (4, 1, '站点描述', 'description', 'text', 'input', 0, '', '派后台管理系统', '', 87, 1, 1, '1', '1582793248', NULL, NULL); diff --git a/public/template/default/blog.html b/public/template/default/blog.html index 93bf259..553365d 100644 --- a/public/template/default/blog.html +++ b/public/template/default/blog.html @@ -5,7 +5,7 @@ - {$zzField['title']}_{:systemConfig("title")} + {$zzField['title']}_{:system_config("title")} diff --git a/public/template/default/contact.html b/public/template/default/contact.html index 1ff89cc..d629394 100644 --- a/public/template/default/contact.html +++ b/public/template/default/contact.html @@ -5,7 +5,7 @@ - {$zzField['title']}_{:systemConfig("title")} + {$zzField['title']}_{:system_config("title")} @@ -47,17 +47,17 @@
-
{:systemConfig("web_contact_add")}
-

联系人:{:systemConfig("author")}

+
{:system_config("web_contact_add")}
+

联系人:{:system_config("author")}

-
{:systemConfig("web_contact_tel")}
+
{:system_config("web_contact_tel")}

周一至周六 08:00--18:00

-
{:systemConfig("web_contact_qq")}@qq.com
+
{:system_config("web_contact_qq")}@qq.com

任何时间,随时恭候。

diff --git a/public/template/default/features.html b/public/template/default/features.html index 356eb74..c100f8d 100644 --- a/public/template/default/features.html +++ b/public/template/default/features.html @@ -6,7 +6,7 @@ - {$zzField['title']}_{:systemConfig("title")} + {$zzField['title']}_{:system_config("title")} diff --git a/public/template/default/footer.html b/public/template/default/footer.html index 3e843ed..61fb8b0 100644 --- a/public/template/default/footer.html +++ b/public/template/default/footer.html @@ -7,7 +7,7 @@

关于我们

{:cn_substr(html2text(get_type_content(86)),80)}...

-

{:systemConfig("copyright")}

+

{:system_config("copyright")}

diff --git a/public/template/default/index.html b/public/template/default/index.html index 1d63dc1..a8ede2a 100644 --- a/public/template/default/index.html +++ b/public/template/default/index.html @@ -6,7 +6,7 @@ - {:systemConfig("title")} + {:system_config("title")} diff --git a/public/template/default/price.html b/public/template/default/price.html index 37968af..1841b49 100644 --- a/public/template/default/price.html +++ b/public/template/default/price.html @@ -6,7 +6,7 @@ - {$zzField['title']}_{:systemConfig("title")} + {$zzField['title']}_{:system_config("title")} diff --git a/public/template/default/search.html b/public/template/default/search.html index 94ebe8e..1850e53 100644 --- a/public/template/default/search.html +++ b/public/template/default/search.html @@ -5,7 +5,7 @@ - {$zzField['title']}_{:systemConfig("title")} + {$zzField['title']}_{:system_config("title")} @@ -33,7 +33,7 @@