From 9c83c4d0cd6015e9f6f52c3394db664ef0a35267 Mon Sep 17 00:00:00 2001 From: taoser Date: Thu, 16 Mar 2023 22:33:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=B6=88=E6=81=AFtitle?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/BaseController.php | 12 ++++----- app/admin/controller/AuthGroup.php | 2 +- app/admin/controller/User.php | 20 +++++++++----- app/admin/view/forum/tagsform.html | 16 ++++++------ app/admin/view/user/useredit.html | 2 +- app/admin/view/user/userform.html | 2 +- app/common/lib/Arts.php | 22 +++++++++------- app/index/controller/Article.php | 6 ++--- app/install/data/taoler.sql | 14 +++++----- composer.lock | 14 +++++----- extend/taoler/com/Message.php | 4 +-- vendor/composer/installed.json | 24 ++++++++++------- vendor/composer/installed.php | 10 +++---- vendor/services.php | 2 +- vendor/workerman/phpsocket.io/README.md | 26 +++++++++++++++++-- vendor/workerman/phpsocket.io/composer.json | 2 +- .../phpsocket.io/src/Engine/Socket.php | 2 +- vendor/workerman/phpsocket.io/src/Socket.php | 2 +- view/taoler/index/public/header.html | 2 +- 19 files changed, 112 insertions(+), 72 deletions(-) diff --git a/app/BaseController.php b/app/BaseController.php index 41ff30f..742ff28 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -258,7 +258,7 @@ abstract class BaseController } else { $artUrl = (string) url('article_detail', ['id' => $aid]); } - +//halt($indexUrl,$artUrl); //多应用时,文章所属应用 2022.11.17 $app = app('http')->getName(); if(empty($appname)) { @@ -268,9 +268,9 @@ abstract class BaseController } // 判断index应用是否绑定域名 - $bind_index = array_search($appname,config('app.domain_bind')); + $bind_index = array_search($appname, config('app.domain_bind')); // 判断index应用是否域名映射 - $map_index = array_search($appname,config('app.app_map')); + $map_index = array_search($appname, config('app.app_map')); // article 所属应用名 $index = $map_index ?: $appname; // index应用名 @@ -293,7 +293,7 @@ abstract class BaseController if($bind_index) { // echo 111; // index或home前端(非admin应用)域名进行了绑定 - // url = $indexUrl . str_replace($admin . '/','',$artUrl); +// $url = $indexUrl . str_replace($admin . '/','',$artUrl); $url = $indexUrl . $artUrl; } else { if($bind_admin) { @@ -304,11 +304,11 @@ abstract class BaseController // echo 333; // var_dump($admin, $appname, $artUrl); // admin进行了映射 - $url = $indexUrl . str_replace($admin, $appname, $artUrl); + $url = $indexUrl . str_replace($admin, $index, $artUrl); } else { // echo 444; // admin未绑定域名 - $url = $indexUrl . str_replace($app, $appname, $artUrl); + $url = $indexUrl . str_replace($app, $index, $artUrl); } } diff --git a/app/admin/controller/AuthGroup.php b/app/admin/controller/AuthGroup.php index 69ebd4e..8b18795 100644 --- a/app/admin/controller/AuthGroup.php +++ b/app/admin/controller/AuthGroup.php @@ -27,7 +27,7 @@ class AuthGroup extends AdminController if(Request::isAjax()){ $data = Request::only(['id']); $map = array_filter($data); - $role = Db::name('auth_group')->field('id,title,limits,descr,status')->where('status',1)->where($map)->select(); + $role = Db::name('auth_group')->field('id,title,limits,descr,status')->where($map)->select(); $count = $role->count(); $res = []; if($count){ diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index a592caf..3188447 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -42,12 +42,16 @@ class User extends AdminController // if(Request::isAjax()){ $data = Request::param(); - $result = Db::name('user')->save($data); - if($result){ - $res = ['code'=>0,'msg'=>'添加成功']; - }else{ - $res = ['code'=>-1,'msg'=>'添加失败']; - } + $data['create_time'] = time(); + $salt = substr(md5($data['create_time']),-6); + // 默认手机号为密码 + $data['password'] = md5(substr_replace(md5($data['phone']),$salt,0,6)); + try { + Db::name('user')->save($data); + $res = ['code'=>0,'msg'=>'添加成功']; + } catch (\Exception $e) { + $res = ['code'=>-1, 'msg'=>$e->getMessage()]; + } return json($res); } @@ -59,6 +63,10 @@ class User extends AdminController { if(Request::isAjax()){ $data = Request::param(); + $user = Db::name('user')->field('create_time')->find($data['id']); + $salt = substr(md5($user['create_time']),-6); + // 默认手机号为密码 + $data['password'] = md5(substr_replace(md5($data['phone']),$salt,0,6)); $result = Db::name('user')->update($data); if($result){ $res = ['code'=>0,'msg'=>'编辑成功']; diff --git a/app/admin/view/forum/tagsform.html b/app/admin/view/forum/tagsform.html index bf68c54..b87f384 100644 --- a/app/admin/view/forum/tagsform.html +++ b/app/admin/view/forum/tagsform.html @@ -26,18 +26,18 @@
- -
- -
+ +
+ +
diff --git a/app/admin/view/user/useredit.html b/app/admin/view/user/useredit.html index baed14f..1fec21c 100644 --- a/app/admin/view/user/useredit.html +++ b/app/admin/view/user/useredit.html @@ -55,7 +55,7 @@ //上传头像 upload.render({ elem: '#layuiadmin-upload-useradmin' - ,url: 'uploadImg' + ,url: "{:url('user/uploadImg')}" ,data: {type:'image'} ,accept: 'images' ,method: 'get' diff --git a/app/admin/view/user/userform.html b/app/admin/view/user/userform.html index 9149994..b08a292 100644 --- a/app/admin/view/user/userform.html +++ b/app/admin/view/user/userform.html @@ -52,7 +52,7 @@ //上传头像 upload.render({ elem: '#layuiadmin-upload-useradmin' - ,url: 'uploadImg' + ,url: "{:url('user/uploadImg')}" ,data: {type:'image'} ,accept: 'images' ,method: 'get' diff --git a/app/common/lib/Arts.php b/app/common/lib/Arts.php index 6e50794..c9e0646 100644 --- a/app/common/lib/Arts.php +++ b/app/common/lib/Arts.php @@ -40,7 +40,7 @@ class Arts * @param string $appname 所属应用名 * @return string */ - public function getRouteUrl(int $aid, string $ename = '', string $appname = '') : string + protected function getRouteUrl(int $aid, string $ename = '', string $appname = '') : string { $indexUrl = $this->getIndexUrl(); if(config('taoler.url_rewrite.article_as') == '/'){ @@ -50,7 +50,7 @@ class Arts } else { $artUrl = (string) url('article_detail', ['id' => $aid]); } - +//halt($indexUrl,$artUrl); //多应用时,文章所属应用 2022.11.17 $app = app('http')->getName(); if(empty($appname)) { @@ -60,9 +60,9 @@ class Arts } // 判断index应用是否绑定域名 - $bind_index = array_search($appname,config('app.domain_bind')); + $bind_index = array_search($appname, config('app.domain_bind')); // 判断index应用是否域名映射 - $map_index = array_search($appname,config('app.app_map')); + $map_index = array_search($appname, config('app.app_map')); // article 所属应用名 $index = $map_index ?: $appname; // index应用名 @@ -83,24 +83,28 @@ class Arts $admin = $map_admin ?: 'admin'; // admin应用名 if($bind_index) { +// echo 111; // index或home前端(非admin应用)域名进行了绑定 - // url = $indexUrl . str_replace($admin . '/','',$artUrl); +// $url = $indexUrl . str_replace($admin . '/','',$artUrl); $url = $indexUrl . $artUrl; } else { if($bind_admin) { +// echo 222; // admin绑定域名 $url = $indexUrl .'/' . $index . $artUrl; } elseif ($app == 'admin' && isset($map_admin)) { +// echo 333; +// var_dump($admin, $appname, $artUrl); // admin进行了映射 - $url = $indexUrl . str_replace($admin, $appname, $artUrl); + $url = $indexUrl . str_replace($admin, $index, $artUrl); } else { - +// echo 444; // admin未绑定域名 - $url = $indexUrl . str_replace($app, $appname, $artUrl); + $url = $indexUrl . str_replace($app, $index, $artUrl); } } - +//halt($url); return $url; } diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index a83c05c..51a421e 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -220,9 +220,9 @@ class Article extends BaseController } else { $receveId = $article['user_id']; } - $data = ['title'=>$title,'content'=>'评论通知','link'=>$link,'user_id'=>$sendId,'type'=>2]; //type=2为评论留言 - Message::sendMsg($sendId,$receveId,$data); - if(Config::get('taoler.config.email_notice')) hook('mailtohook',[$this->showUser(1)['email'],'评论审核通知','Hi亲爱的管理员:
用户'.$this->showUser($this->uid)['name'].'刚刚对 '.$title.' 发表了评论,请尽快处理。']); + $data = ['title' => $article['title'], 'content' => '评论通知', 'link' => $link, 'user_id' => $sendId, 'type' => 2]; //type=2为评论留言 + Message::sendMsg($sendId, $receveId, $data); + if(Config::get('taoler.config.email_notice')) hook('mailtohook',[$this->showUser(1)['email'],'评论审核通知','Hi亲爱的管理员:
用户'.$this->showUser($this->uid)['name'].'刚刚对 ' . $article['title'] . ' 发表了评论,请尽快处理。']); $res = ['code'=>0, 'msg'=>$msg]; } else { $res = ['code'=>-1, 'msg'=>'留言失败']; diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql index 83a8076..7a6a368 100644 --- a/app/install/data/taoler.sql +++ b/app/install/data/taoler.sql @@ -479,13 +479,13 @@ INSERT INTO `tao_slider` VALUES ('2', '通用右栏底部广告', '2', '/storage -- ---------------------------- DROP TABLE IF EXISTS `tao_station`; CREATE TABLE `tao_station` ( - `id` int NOT NULL AUTO_INCREMENT, - `city_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `city_ename` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `master` tinyint(1) NOT NULL DEFAULT 0, - `create_time` datetime NOT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `ename`(`city_ename` ASC) USING BTREE COMMENT 'ename索引' + `id` int NOT NULL AUTO_INCREMENT, + `city_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `city_ename` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `master` tinyint(1) NOT NULL DEFAULT 0, + `create_time` datetime NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + INDEX `ename`(`city_ename` ASC) USING BTREE COMMENT 'ename索引' ) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- diff --git a/composer.lock b/composer.lock index 9e4e57e..62c7136 100644 --- a/composer.lock +++ b/composer.lock @@ -3272,16 +3272,16 @@ }, { "name": "workerman/phpsocket.io", - "version": "v1.1.14", + "version": "v1.1.16", "source": { "type": "git", "url": "https://github.com/walkor/phpsocket.io.git", - "reference": "a5758da4d55b4744a4cc9c956816d88ce385601e" + "reference": "f4dc14e69e9d0d8ce69c6180f93b76b7743f2304" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/a5758da4d55b4744a4cc9c956816d88ce385601e", - "reference": "a5758da4d55b4744a4cc9c956816d88ce385601e", + "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/f4dc14e69e9d0d8ce69c6180f93b76b7743f2304", + "reference": "f4dc14e69e9d0d8ce69c6180f93b76b7743f2304", "shasum": "", "mirrors": [ { @@ -3292,7 +3292,7 @@ }, "require": { "workerman/channel": ">=1.0.0", - "workerman/workerman": ">=3.5.16" + "workerman/workerman": ">=4.0.0" }, "type": "library", "autoload": { @@ -3310,7 +3310,7 @@ ], "support": { "issues": "https://github.com/walkor/phpsocket.io/issues", - "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.14" + "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.16" }, "funding": [ { @@ -3322,7 +3322,7 @@ "type": "patreon" } ], - "time": "2022-02-24T03:33:45+00:00" + "time": "2022-11-25T13:00:18+00:00" }, { "name": "workerman/workerman", diff --git a/extend/taoler/com/Message.php b/extend/taoler/com/Message.php index 3665ae5..67c1a93 100644 --- a/extend/taoler/com/Message.php +++ b/extend/taoler/com/Message.php @@ -46,8 +46,8 @@ class Message /** * 接收消息 - * @param $uid 接收消息用户ID - * @return \think\Collection + * @param $uid 接收消息用户ID + * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 52d8c00..d049223 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -3288,24 +3288,30 @@ }, { "name": "workerman/phpsocket.io", - "version": "v1.1.14", - "version_normalized": "1.1.14.0", + "version": "v1.1.16", + "version_normalized": "1.1.16.0", "source": { "type": "git", "url": "https://github.com/walkor/phpsocket.io.git", - "reference": "a5758da4d55b4744a4cc9c956816d88ce385601e" + "reference": "f4dc14e69e9d0d8ce69c6180f93b76b7743f2304" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/a5758da4d55b4744a4cc9c956816d88ce385601e", - "reference": "a5758da4d55b4744a4cc9c956816d88ce385601e", - "shasum": "" + "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/f4dc14e69e9d0d8ce69c6180f93b76b7743f2304", + "reference": "f4dc14e69e9d0d8ce69c6180f93b76b7743f2304", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "workerman/channel": ">=1.0.0", - "workerman/workerman": ">=3.5.16" + "workerman/workerman": ">=4.0.0" }, - "time": "2022-02-24T03:33:45+00:00", + "time": "2022-11-25T13:00:18+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -3323,7 +3329,7 @@ ], "support": { "issues": "https://github.com/walkor/phpsocket.io/issues", - "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.14" + "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.16" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 345b589..9041fc4 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'taoser/taoler', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '70c9f4a1c46ca50786773a38e86e10cf67fc15aa', + 'reference' => 'e3f1590beb50ab5826fd410fd37264870b5967f4', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -358,7 +358,7 @@ 'taoser/taoler' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '70c9f4a1c46ca50786773a38e86e10cf67fc15aa', + 'reference' => 'e3f1590beb50ab5826fd410fd37264870b5967f4', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -509,9 +509,9 @@ 'dev_requirement' => false, ), 'workerman/phpsocket.io' => array( - 'pretty_version' => 'v1.1.14', - 'version' => '1.1.14.0', - 'reference' => 'a5758da4d55b4744a4cc9c956816d88ce385601e', + 'pretty_version' => 'v1.1.16', + 'version' => '1.1.16.0', + 'reference' => 'f4dc14e69e9d0d8ce69c6180f93b76b7743f2304', 'type' => 'library', 'install_path' => __DIR__ . '/../workerman/phpsocket.io', 'aliases' => array(), diff --git a/vendor/services.php b/vendor/services.php index e5fd74d..07d70ec 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'taoser\\addons\\Service', diff --git a/vendor/workerman/phpsocket.io/README.md b/vendor/workerman/phpsocket.io/README.md index 86546fc..d54328f 100644 --- a/vendor/workerman/phpsocket.io/README.md +++ b/vendor/workerman/phpsocket.io/README.md @@ -2,9 +2,9 @@ A server side alternative implementation of [socket.io](https://github.com/socketio/socket.io) in PHP based on [Workerman](https://github.com/walkor/Workerman).
# Notice -Only support socket.io v1.3.0 or greater.
+Only support socket.io >= v1.3.0 and <= v2.x
This project is just translate socket.io by [workerman](https://github.com/walkor/Workerman).
-More api just see http://socket.io/docs/server-api/ +More api just see [https://socket.io/docs/v2/server-api/](https://socket.io/docs/v2/server-api/) # Install composer require workerman/phpsocket.io @@ -138,6 +138,28 @@ $io->on('connection', function ($connection) use ($io) { Worker::runAll(); ``` +## Acknowledgement callback +```php + +use Workerman\Worker; +use PHPSocketIO\SocketIO; + +require_once __DIR__ . '/vendor/autoload.php'; + +$io = new SocketIO(2021); + +$io->on('connection', function ($connection) use ($io) { + $socket->on('message with ack', function ($data, $callback) use ($socket, $io) { + // acknowledgement callback + if ($callback && is_callable($callback)) { + $callback(0); + } + }); +}); + +Worker::runAll(); +``` + # 手册 [中文手册](https://github.com/walkor/phpsocket.io/tree/master/docs/zh) diff --git a/vendor/workerman/phpsocket.io/composer.json b/vendor/workerman/phpsocket.io/composer.json index 23dcb18..5b3901d 100644 --- a/vendor/workerman/phpsocket.io/composer.json +++ b/vendor/workerman/phpsocket.io/composer.json @@ -5,7 +5,7 @@ "homepage": "http://www.workerman.net", "license" : "MIT", "require": { - "workerman/workerman" : ">=3.5.16", + "workerman/workerman" : ">=4.0.0", "workerman/channel" : ">=1.0.0" }, "autoload": { diff --git a/vendor/workerman/phpsocket.io/src/Engine/Socket.php b/vendor/workerman/phpsocket.io/src/Engine/Socket.php index 0c55e6a..b7563df 100644 --- a/vendor/workerman/phpsocket.io/src/Engine/Socket.php +++ b/vendor/workerman/phpsocket.io/src/Engine/Socket.php @@ -1,7 +1,7 @@ acks[$packet['id']]); } else { - echo ('bad ack '. packet.id); + echo ('bad ack '. $packet['id']); } } diff --git a/view/taoler/index/public/header.html b/view/taoler/index/public/header.html index ee02440..0def374 100644 --- a/view/taoler/index/public/header.html +++ b/view/taoler/index/public/header.html @@ -22,7 +22,7 @@ {/volist} {// 后台自定义头部链接} {volist name="headlinks" id="vo"} -
  • {$vo.slid_name}
  • +
  • {$vo.slid_name}
  • {/volist}