diff --git a/app/admin/controller/system/Plugin.php b/app/admin/controller/system/Plugin.php
index 5322be6..edc10fc 100644
--- a/app/admin/controller/system/Plugin.php
+++ b/app/admin/controller/system/Plugin.php
@@ -12,8 +12,8 @@ declare (strict_types=1);
// +----------------------------------------------------------------------
namespace app\admin\controller\system;
-set_time_limit(600);
use GuzzleHttp\Exception\TransferException;
+use process\Monitor;
use support\Response;
use system\File;
use system\Http;
@@ -46,6 +46,11 @@ class Plugin extends AdminController
*/
static mixed $ServerBody = '';
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
/**
* 获取本地插件列表
* @return Response
@@ -72,8 +77,7 @@ class Plugin extends AdminController
$name = input('name');
$pluginPath = plugin_path($name);
-
- if (is_dir($pluginPath)) {
+ if (is_file($pluginPath . 'config.json')) {
return $this->error('请勿重复安装插件');
}
@@ -206,6 +210,7 @@ class Plugin extends AdminController
throw new \Exception(__('插件数据不存在'), -117);
}
+ Monitor::pause();
$pluginDir = plugin_path($name);
foreach (File::getCopyDirs($name) as $copyDir) {
copydirs($copyDir, root_path() . str_replace($pluginDir, '', $copyDir));
diff --git a/app/admin/view/index/basecfg.html b/app/admin/view/index/basecfg.html
index 023d64c..42887b3 100644
--- a/app/admin/view/index/basecfg.html
+++ b/app/admin/view/index/basecfg.html
@@ -59,6 +59,16 @@
margin-right: 5px;
}
}
+
+ @media screen and (max-width: 1024px) {
+ .layui-form-mid {
+ display: none;
+ }
+
+ .layui-form-item .layui-input-inline {
+ max-width: 180px;
+ }
+ }
diff --git a/app/admin/view/system/company/add.html b/app/admin/view/system/company/add.html
index 99b3aee..6005c85 100644
--- a/app/admin/view/system/company/add.html
+++ b/app/admin/view/system/company/add.html
@@ -61,11 +61,11 @@
diff --git a/app/common/library/DataBase.php b/app/common/library/DataBase.php
index 6384469..5970fac 100644
--- a/app/common/library/DataBase.php
+++ b/app/common/library/DataBase.php
@@ -3,6 +3,7 @@ declare (strict_types = 1);
namespace app\common\library;
+use support\Log;
use think\facade\Db;
/**
@@ -13,6 +14,7 @@ class DataBase {
/**
* 导入目录下Install.sql文件
* @param string $sqlPath
+ * @throws \Exception
*/
public static function importSql(string $sqlPath)
{
@@ -27,7 +29,9 @@ class DataBase {
}
try {
Db::getPdo()->exec($line);
- } catch (\Throwable $th) {}
+ } catch (\Throwable $th) {
+ Log::info($th->getMessage());
+ }
}
}
}
diff --git a/app/common/library/Upload.php b/app/common/library/Upload.php
index fa91f57..99c5721 100644
--- a/app/common/library/Upload.php
+++ b/app/common/library/Upload.php
@@ -36,22 +36,22 @@ class Upload
/**
* 文件类型
*/
- protected mixed $fileClass;
+ protected mixed $fileClass = '';
/**
* 文件名称
*/
- protected mixed $filename;
+ protected mixed $filename = '';
/**
* 文件保存路径
*/
- protected mixed $filepath;
+ protected mixed $filepath = '';
/**
* 文件全路径名称
*/
- protected mixed $resource;
+ protected mixed $resource = '';
/**
* 附件信息
@@ -61,7 +61,7 @@ class Upload
/**
* 图形对象实例
*/
- protected mixed $Images;
+ protected mixed $Images = '';
/**
* 错误信息
diff --git a/app/common/model/system/AdminRules.php b/app/common/model/system/AdminRules.php
index 54358a3..158fa29 100644
--- a/app/common/model/system/AdminRules.php
+++ b/app/common/model/system/AdminRules.php
@@ -146,7 +146,7 @@ class AdminRules extends Model
*/
public static function export(string $name): array
{
- $list = self::field('id,pid,title,router,icon,auth,type')->where('note', $name)->select()->toArray();
+ $list = self::field('id,pid,title,router,icon,auth,type')->where('note', $name)->order('sort asc')->select()->toArray();
return self::parseMenuChildren(list_to_tree($list));
}
diff --git a/app/functions.php b/app/functions.php
index e9dd18a..0a61c71 100644
--- a/app/functions.php
+++ b/app/functions.php
@@ -465,6 +465,9 @@ if (!function_exists('cdn_Prefix')) {
* 获取远程图片前缀
* @return string
* @throws \Psr\SimpleCache\InvalidArgumentException
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\ModelNotFoundException
*/
function cdn_Prefix()
{
@@ -696,14 +699,17 @@ if (!function_exists('system_reload')) {
*/
function system_reload(): bool
{
+ \process\Monitor::resume();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return false;
}
+
if (function_exists('posix_kill')
&& function_exists('posix_getppid')) {
posix_kill(posix_getppid(), 10);
return true;
}
+
return false;
}
}
@@ -984,13 +990,17 @@ if (!function_exists('is_today')) {
if (!function_exists('published_date')) {
/**
* 格式化时间
- *
* @param [type] $time
+ * @param bool $unix
* @return string
*/
- function published_date($time): string
+ function published_date($time, bool $unix = true): string
{
- $time = preg_replace('/\D/', '', $time);
+ if (!$unix) {
+ $time = strtotime($time);
+
+ }
+
$currentTime = time() - $time;
$published = array(
'86400' => '天',
@@ -998,6 +1008,7 @@ if (!function_exists('published_date')) {
'60' => '分钟',
'1' => '秒'
);
+
if ($currentTime == 0) {
return '1秒前';
} else if ($currentTime >= 604800 || $currentTime < 0) {
diff --git a/app/install/install.sql b/app/install/install.sql
index 920313a..66edcd4 100644
--- a/app/install/install.sql
+++ b/app/install/install.sql
@@ -11,7 +11,7 @@
Target Server Version : 50738
File Encoding : 65001
- Date: 28/11/2022 18:45:45
+ Date: 19/12/2022 19:20:36
*/
SET NAMES utf8mb4;
@@ -51,13 +51,13 @@ CREATE TABLE `__PREFIX__admin` (
INDEX `id`(`id`) USING BTREE,
INDEX `name`(`name`) USING BTREE,
INDEX `pwd`(`pwd`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '后台管理员表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '后台管理员表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of __PREFIX__admin
-- ----------------------------
-INSERT INTO `__PREFIX__admin` VALUES (1, '1', '2', '3', 'admin', 'meystack', '13682bec405cf4b9002e6e8306312ce6', 1, 'a:3:{i:0;s:12:\"测试效果\";i:1;s:15:\"隔壁帅小伙\";i:2;s:9:\"技术宅\";}', '/upload/avatars/f8e34ec67a2a0233_100x100.jpg', '海阔天空,有容乃大', 'admin@swiftadmin.net', '0310', '15188888888', '高级管理人员', 347, '河北省邯郸市', '127.0.0.1', 1669615752, '3232254977', 1, NULL, 1596682835, 1669621462, NULL);
-INSERT INTO `__PREFIX__admin` VALUES (2, '2', '4', '5,6', 'ceshi', '测试用户', '13682bec405cf4b9002e6e8306312ce6', 1, 'a:3:{i:0;s:6:\"呵呵\";i:1;s:5:\"Think\";i:2;s:12:\"铁血柔肠\";}', '/upload/avatars/a0b923820dcc509a_100x100.png', 'PHP是全世界最好的语言', 'baimei@your.com', '0310', '15188888888', '我原本以为吕布已经天下无敌了,没想到还有比吕布勇猛的,这谁的部将?', 55, '河北省邯郸市廉颇大道110号指挥中心', '127.0.0.1', 1668661258, '3232254977', 1, '违规', 1609836672, 1669619806, NULL);
+INSERT INTO `__PREFIX__admin` VALUES (1, '1', '2', '3', 'admin', 'meystack', '13682bec405cf4b9002e6e8306312ce6', 1, 'a:3:{i:0;s:12:\"测试效果\";i:1;s:15:\"隔壁帅小伙\";i:2;s:9:\"技术宅\";}', '/upload/avatars/f8e34ec67a2a0233_100x100.jpg', '海阔天空,有容乃大', 'admin@swiftadmin.net', '0310', '15188888888', '高级管理人员', 371, '河北省邯郸市', '127.0.0.1', 1671360587, '3232254977', 1, NULL, 1596682835, 1671360587, NULL);
+INSERT INTO `__PREFIX__admin` VALUES (2, '2', '4', '5,6', 'ceshi', '测试用户', '13682bec405cf4b9002e6e8306312ce6', 1, 'a:3:{i:0;s:6:\"呵呵\";i:1;s:5:\"Think\";i:2;s:12:\"铁血柔肠\";}', '/upload/avatars/a0b923820dcc509a_100x100.png', 'PHP是全世界最好的语言', 'baimei@your.com', '0310', '15188888888', '我原本以为吕布已经天下无敌了,没想到还有比吕布勇猛的,这谁的部将?', 56, '河北省邯郸市廉颇大道110号指挥中心', '127.0.0.1', 1669816238, '3232254977', 1, '违规', 1609836672, 1669816238, NULL);
-- ----------------------------
-- Table structure for __PREFIX__admin_access
@@ -77,7 +77,8 @@ CREATE TABLE `__PREFIX__admin_access` (
-- Records of __PREFIX__admin_access
-- ----------------------------
INSERT INTO `__PREFIX__admin_access` VALUES (1, '1', NULL, NULL);
-INSERT INTO `__PREFIX__admin_access` VALUES (2, '2', '85,86,87,88,89,90,91,92,93,100,101,102,103,104,105,106,107,108,109,110,111,112', '8');
+INSERT INTO `__PREFIX__admin_access` VALUES (2, '2', '5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,115,116,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,85,86,87,88,89,90,91,92,93,100,101,102,103,104,105,106,107,108,109,110,111,112', '8');
+INSERT INTO `__PREFIX__admin_access` VALUES (3, '1', NULL, NULL);
-- ----------------------------
-- Table structure for __PREFIX__admin_group
@@ -155,7 +156,7 @@ CREATE TABLE `__PREFIX__admin_notice` (
-- Records of __PREFIX__admin_notice
-- ----------------------------
INSERT INTO `__PREFIX__admin_notice` VALUES (1, 'notice', 1, '系统通知', '您有新的通知内容', 0, '10.10.11.22', 0, 0, 0, 1668249585, NULL);
-INSERT INTO `__PREFIX__admin_notice` VALUES (2, 'message', 1, '请注意查收短消息', '听说你又接了一个大项目', 2, '10.10.11.22', 0, 0, 0, 1668323353, NULL);
+INSERT INTO `__PREFIX__admin_notice` VALUES (2, 'message', 1, '请注意查收短消息', '听说你又接了一个大项目', 2, '10.10.11.22', 0, 0, 1, 1668323353, NULL);
INSERT INTO `__PREFIX__admin_notice` VALUES (3, 'todo', 1, '您有一项待办', '请完成项目的迭代工作与BUG修复', 0, '10.10.11.22', 0, 0, 0, 1668393025, NULL);
-- ----------------------------
@@ -182,7 +183,7 @@ CREATE TABLE `__PREFIX__admin_rules` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `id`(`id`) USING BTREE,
INDEX `sort`(`sort`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 117 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单权限表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 1682 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单权限表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of __PREFIX__admin_rules
@@ -354,7 +355,7 @@ CREATE TABLE `__PREFIX__company` (
-- Records of __PREFIX__company
-- ----------------------------
INSERT INTO `__PREFIX__company` VALUES (1, '北京总部技术公司', 'bj', '北京市东城区长安街880号', 10000, '权栈', 15100000001, '010-10000', 'coolsec@foxmail.com', '91130403XXA0AJ7XXM', '01', '02', 1613711884, NULL);
-INSERT INTO `__PREFIX__company` VALUES (2, '河北分公司', 'hb', '河北省邯郸市丛台区公园路880号', 56000, '权栈', 12345678901, '0310-12345678', 'coolsec@foxmail.com', 'code', NULL, NULL, 1613787702, NULL);
+INSERT INTO `__PREFIX__company` VALUES (2, '河北分公司', 'hb', '河北省邯郸市丛台区公园路880号', 56000, '权栈', 12345678901, '0310-12345678', 'coolsec@foxmail.com', 'code', ' ', ' ', 1613787702, NULL);
-- ----------------------------
-- Table structure for __PREFIX__config
@@ -396,7 +397,7 @@ INSERT INTO `__PREFIX__config` VALUES (18, 'auth_code', 0, NULL, 'string', 'wMRk
INSERT INTO `__PREFIX__config` VALUES (19, 'system_logs', 0, NULL, 'string', '0', '后台日志');
INSERT INTO `__PREFIX__config` VALUES (20, 'system_exception', 0, NULL, 'string', '0', '异常日志');
INSERT INTO `__PREFIX__config` VALUES (21, 'cache_status', 0, 'cache', 'string', '1', '缓存状态');
-INSERT INTO `__PREFIX__config` VALUES (22, 'cache_type', 0, 'cache', 'string', 'file', '缓存类型');
+INSERT INTO `__PREFIX__config` VALUES (22, 'cache_type', 0, 'cache', 'string', 'redis', '缓存类型');
INSERT INTO `__PREFIX__config` VALUES (23, 'cache_time', 0, 'cache', 'string', '6000', '缓存时间');
INSERT INTO `__PREFIX__config` VALUES (24, 'cache_host', 0, 'cache', 'string', '127.0.0.1', '服务器IP');
INSERT INTO `__PREFIX__config` VALUES (25, 'cache_port', 0, 'cache', 'string', '6379', '端口');
@@ -426,9 +427,9 @@ INSERT INTO `__PREFIX__config` VALUES (48, 'upload_water_pct', 0, 'upload', 'str
INSERT INTO `__PREFIX__config` VALUES (49, 'upload_water_img', 0, 'upload', 'string', '/', '图片水印地址');
INSERT INTO `__PREFIX__config` VALUES (50, 'upload_water_pos', 0, 'upload', 'string', '9', '水印位置');
INSERT INTO `__PREFIX__config` VALUES (51, 'play', 0, NULL, 'array', '{\"play_width\":\"960\",\"play_height\":\"450\",\"play_show\":\"0\",\"play_second\":\"10\",\"play_area\":\"大陆,香港,中国台湾,美国,韩国,日本,泰国,印度,英国,法国,俄罗斯,新加坡,其它\",\"play_year\":\"2022,2021,2020,2019,2018,2017,2016,2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999\",\"play_version\":\"高清版,剧场版,抢先版,OVA,TV,影院版\",\"play_language\":\"国语,英语,粤语,韩语,日语,法语,德语,泰语,俄语,其它\",\"play_week\":\"周一,周二,周三,周四,周五,周六,周日\",\"play_playad\":\"http:\\/\\/www.swiftadmin.net\\/api\\/show.html\",\"play_down\":\"http:\\/\\/www.swiftadmin.net\\/api\\/show.html\",\"play_downgorup\":\"http:\\/\\/down.swiftadmin.net\\/\"}', '播放器数据');
-INSERT INTO `__PREFIX__config` VALUES (52, 'cloud_status', 0, NULL, 'string', '1', '是否开启OSS上传');
-INSERT INTO `__PREFIX__config` VALUES (53, 'cloud_type', 0, NULL, 'string', 'qcloud_oss', 'OSS上传类型');
-INSERT INTO `__PREFIX__config` VALUES (54, 'aliyun_oss', 0, NULL, 'array', '{\"accessId\":\"LTAI5t**LJu61vC\",\"accessSecret\":\"knwIiD*****u61l3a8LJu6\",\"bucket\":\"bucket\",\"endpoint\":\"oss-cn-beijing.aliyuncs.com\",\"url\":\"http:\\/\\/oss-cn-beijing.aliyuncs.com\"}', '阿里云OSS');
+INSERT INTO `__PREFIX__config` VALUES (52, 'cloud_status', 0, NULL, 'string', '0', '是否开启OSS上传');
+INSERT INTO `__PREFIX__config` VALUES (53, 'cloud_type', 0, NULL, 'string', 'aliyun_oss', 'OSS上传类型');
+INSERT INTO `__PREFIX__config` VALUES (54, 'aliyun_oss', 0, NULL, 'array', '{\"accessId\":\"LTAI5tR*****nVMe1vC\",\"accessSecret\":\"knwIiD8rINV********3ysvbU0pk\",\"bucket\":\"bucket\",\"endpoint\":\"oss-cn-beijing.aliyuncs.com\",\"url\":\"http:\\/\\/oss-cn-beijing.aliyuncs.com\"}', '阿里云OSS');
INSERT INTO `__PREFIX__config` VALUES (55, 'qcloud_oss', 0, NULL, 'array', '{\"app_id\":\"1252296528\",\"secret_id\":\"LTAI5333k*****NnVMe1vC\",\"secret_key\":\"kFStrm******aJdocxsSScjRt9A\",\"bucket\":\"testpack\",\"region\":\"ap-beijing\",\"url\":\"\"}', '腾讯云OSS');
INSERT INTO `__PREFIX__config` VALUES (56, 'email', 0, NULL, 'array', '{\"smtp_debug\":\"0\",\"smtp_host\":\"smtp.163.com\",\"smtp_port\":\"587\",\"smtp_name\":\"管理员\",\"smtp_user\":\"domain@163.com\",\"smtp_pass\":\"KNWSGPUYBMFATCIZ\",\"smtp_test\":\"youremail@foxmail.com\"}', '邮箱配置');
INSERT INTO `__PREFIX__config` VALUES (57, 'qq', 0, NULL, 'array', '{\"app_id\":\"\",\"app_key\":\"\",\"callback\":\"\"}', 'QQ登录');
@@ -521,14 +522,14 @@ CREATE TABLE `__PREFIX__dictionary` (
-- ----------------------------
-- Records of __PREFIX__dictionary
-- ----------------------------
-INSERT INTO `__PREFIX__dictionary` VALUES (1, 0, '内容属性', 'content', 1, '', 1, 1659839499, 1637738903, NULL);
-INSERT INTO `__PREFIX__dictionary` VALUES (2, 1, '头条', '1', 2, '', 1, 1638093403, 1638093403, NULL);
-INSERT INTO `__PREFIX__dictionary` VALUES (3, 1, '推荐', '2', 3, '', 1, 1657367329, 1638093425, NULL);
-INSERT INTO `__PREFIX__dictionary` VALUES (4, 1, '幻灯', '3', 4, '', 1, 1661957438, 1638093430, NULL);
-INSERT INTO `__PREFIX__dictionary` VALUES (5, 1, '滚动', '4', 5, '', 1, 1638093435, 1638093435, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (1, 0, '内容属2性', 'content', 1, '', 1, 1669805492, 1637738903, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (2, 1, '头条', '1', 2, '', 1, 1669690446, 1638093403, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (3, 1, '推荐', '2', 3, '', 1, 1669690444, 1638093425, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (4, 1, '幻灯', '3', 4, '', 1, 1669690440, 1638093430, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (5, 1, '滚动', '4', 5, '', 1, 1669690442, 1638093435, NULL);
INSERT INTO `__PREFIX__dictionary` VALUES (6, 1, '图文', '5', 6, '', 1, 1638093456, 1638093456, NULL);
INSERT INTO `__PREFIX__dictionary` VALUES (7, 1, '跳转', '6', 7, '', 1, 1638093435, 1638093435, NULL);
-INSERT INTO `__PREFIX__dictionary` VALUES (8, 0, '友链类型', 'friendlink', 8, '', 1, 1638093456, 1638093456, NULL);
+INSERT INTO `__PREFIX__dictionary` VALUES (8, 0, '友链2类型', 'friendlink', 8, '', 1, 1669805499, 1638093456, NULL);
INSERT INTO `__PREFIX__dictionary` VALUES (9, 8, '资源', '1', 9, '', 1, 1638093430, 1638093430, NULL);
INSERT INTO `__PREFIX__dictionary` VALUES (10, 8, '社区', '2', 10, '', 1, 1638093435, 1638093435, NULL);
INSERT INTO `__PREFIX__dictionary` VALUES (11, 8, '合作伙伴', '3', 11, '', 1, 1659450310, 1638093456, NULL);
@@ -589,7 +590,7 @@ CREATE TABLE `__PREFIX__system_log` (
INDEX `method`(`method`) USING BTREE,
INDEX `create_time`(`create_time`) USING BTREE,
INDEX `line`(`line`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 953 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统日志表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统日志表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of __PREFIX__system_log
@@ -651,7 +652,7 @@ CREATE TABLE `__PREFIX__user` (
-- ----------------------------
-- Records of __PREFIX__user
-- ----------------------------
-INSERT INTO `__PREFIX__user` VALUES (1, 1, 'admin', '513bd12b00b512d0b879962b777b5560', 'wdONQC', NULL, NULL, '/upload/avatars/a0b923820dcc509a_100x100.png', '这个人很懒,什么都没有留下~ ', 'test@swiftadmin.net', NULL, '林自图', 0, '2022-11-04 20:04:55', '15253325632533', '河北省邯郸市中华区人民东路023号', '', 0, 100, 1983.56, '你家的宠物叫啥?', '23', 1, 1, 10001, 'NLBreFUsatIQnZVxYydOgM', NULL, NULL, NULL, NULL, NULL, NULL, 1, '127.0.0.1', 1669623633, 156, NULL, '1861775580', 1657332918, NULL);
+INSERT INTO `__PREFIX__user` VALUES (1, 1, 'aa', '513bd12b00b512d0b879962b777b5560', 'wdONQC', NULL, NULL, '/upload/avatars/a0b923820dcc509a_100x100.png', '这个人很懒,什么都没有留下~ ', 'test@swiftadmin.net', NULL, '林自图', 0, '2022-11-04 20:04:55', '15253325632533', '河北省邯郸市中华区人民东路023号', '', 0, 100, 1983.56, '你的幸运数字是?', 'aa', 1, 1, 10001, 'xDqmQGyBNUlwRXtkKPVCiM', NULL, NULL, NULL, NULL, NULL, NULL, 1, '127.0.0.1', 1670750078, 160, NULL, '1861775580', 1657332918, NULL);
INSERT INTO `__PREFIX__user` VALUES (2, 1, 'faker', '513bd12b00b512d0b879962b777b5560', 'wdONQC', NULL, NULL, '/upload/avatars/a0b923820dcc509a_100x100.png', '这个人很懒,什么都没有留下~ ', 'test@swiftadmin.net', NULL, NULL, 0, NULL, NULL, '河北省邯郸市中华区人民东路023号', NULL, 0, 100, NULL, '你家的宠物叫啥?', '23', 1, 1, 10001, 'lLtSvJGyFQCVuTdjRIhqza', NULL, NULL, NULL, NULL, NULL, NULL, 1, '23.21.25.23', 1662098397, 131, NULL, '1861775580', 1657332918, NULL);
-- ----------------------------
@@ -699,12 +700,11 @@ CREATE TABLE `__PREFIX__user_log` (
`create_time` int(11) NULL DEFAULT NULL COMMENT '登录时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `user_ip`(`login_ip`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户登录记录表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户登录记录表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of __PREFIX__user_log
-- ----------------------------
-INSERT INTO `__PREFIX__user_log` VALUES (1, 'admin', 1, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', 'Windows NT 10.0', 'Chrome/86.0.4240.198 Safari/537.36', 1, '登录成功', 1669623633);
-- ----------------------------
-- Table structure for __PREFIX__user_notice
@@ -778,4 +778,4 @@ CREATE TABLE `__PREFIX__user_validate` (
-- Records of __PREFIX__user_validate
-- ----------------------------
-SET FOREIGN_KEY_CHECKS = 1;
+SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 1fc8c24..1962259 100644
--- a/composer.json
+++ b/composer.json
@@ -49,7 +49,8 @@
"yansongda/pay": "~3.1.0",
"overtrue/wechat": "~5.0",
"ext-json": "*",
- "ext-zip": "*"
+ "ext-zip": "*",
+ "ext-posix": "*"
},
"suggest": {
"ext-event": "For better performance. "
diff --git a/process/Monitor.php b/process/Monitor.php
index 6fa3784..04ea11a 100644
--- a/process/Monitor.php
+++ b/process/Monitor.php
@@ -33,14 +33,51 @@ class Monitor
*/
protected $_extensions = [];
+ /**
+ * @var string
+ */
+ public static $lockFile = __DIR__ . '/../runtime/monitor.lock';
+
+ /**
+ * Pause monitor
+ * @return void
+ */
+ public static function pause()
+ {
+ file_put_contents(static::$lockFile, time());
+ }
+
+ /**
+ * Resume monitor
+ * @return void
+ */
+ public static function resume()
+ {
+ clearstatcache();
+ if (is_file(static::$lockFile)) {
+ unlink(static::$lockFile);
+ }
+ }
+
+ /**
+ * Whether monitor is paused
+ * @return bool
+ */
+ public static function isPaused(): bool
+ {
+ clearstatcache();
+ return file_exists(static::$lockFile);
+ }
+
/**
* FileMonitor constructor.
* @param $monitor_dir
* @param $monitor_extensions
- * @param $memory_limit
+ * @param array $options
*/
- public function __construct($monitor_dir, $monitor_extensions, $memory_limit = null)
+ public function __construct($monitor_dir, $monitor_extensions, array $options = [])
{
+ static::resume();
$this->_paths = (array)$monitor_dir;
$this->_extensions = $monitor_extensions;
if (!Worker::getAllWorkers()) {
@@ -50,23 +87,24 @@ class Monitor
if (in_array('exec', $disable_functions, true)) {
echo "\nMonitor file change turned off because exec() has been disabled by disable_functions setting in " . PHP_CONFIG_FILE_PATH . "/php.ini\n";
} else {
- if (!Worker::$daemonize) {
+ if ($options['enable_file_monitor'] ?? true) {
Timer::add(1, function () {
$this->checkAllFilesChange();
});
}
}
- $memory_limit = $this->getMemoryLimit($memory_limit);
- if ($memory_limit && DIRECTORY_SEPARATOR === '/') {
- Timer::add(60, [$this, 'checkMemory'], [$memory_limit]);
+ $memory_limit = $this->getMemoryLimit($options['memory_limit'] ?? null);
+ if (($options['enable_memory_monitor'] ?? $memory_limit) && !str_starts_with(PHP_OS, 'WIN')) {
+ Timer::add(10, [$this, 'checkMemory'], [$memory_limit]);
}
}
/**
* @param $monitor_dir
+ * @return bool
*/
- public function checkFilesChange($monitor_dir)
+ public function checkFilesChange($monitor_dir): bool
{
static $last_mtime, $too_many_files_check;
if (!$last_mtime) {
@@ -75,7 +113,7 @@ class Monitor
clearstatcache();
if (!is_dir($monitor_dir)) {
if (!is_file($monitor_dir)) {
- return;
+ return false;
}
$iterator = [new \SplFileInfo($monitor_dir)];
} else {
@@ -87,13 +125,13 @@ class Monitor
foreach ($iterator as $file) {
$count ++;
/** var SplFileInfo $file */
- if (is_dir($file)) {
+ if (is_dir($file->getRealPath())) {
continue;
}
// check mtime
if ($last_mtime < $file->getMTime() && in_array($file->getExtension(), $this->_extensions, true)) {
$var = 0;
- exec(PHP_BINARY . " -l " . $file, $out, $var);
+ exec('"'.PHP_BINARY . '" -l ' . $file, $out, $var);
if ($var) {
$last_mtime = $file->getMTime();
continue;
@@ -113,13 +151,18 @@ class Monitor
echo "Monitor: There are too many files ($count files) in $monitor_dir which makes file monitoring very slow\n";
$too_many_files_check = 1;
}
+ return false;
}
/**
* @return bool
*/
- public function checkAllFilesChange()
+ public function checkAllFilesChange(): bool
{
+ if (static::isPaused()) {
+ return false;
+ }
+
foreach ($this->_paths as $path) {
if ($this->checkFilesChange($path)) {
return true;
@@ -134,6 +177,10 @@ class Monitor
*/
public function checkMemory($memory_limit)
{
+ if (static::isPaused() || $memory_limit <= 0) {
+ return;
+ }
+
$ppid = posix_getppid();
$children_file = "/proc/$ppid/task/$ppid/children";
if (!is_file($children_file) || !($children = file_get_contents($children_file))) {
@@ -151,7 +198,7 @@ class Monitor
}
$mem = (int)($mem / 1024);
if ($mem >= $memory_limit) {
- posix_kill($pid, SIGINT);
+ \posix_kill($pid, SIGINT);
}
}
}
@@ -192,4 +239,4 @@ class Monitor
}
return $memory_limit;
}
-}
+}
\ No newline at end of file