Skip to content

Commit

Permalink
Merge pull request #2227 from sspanel-uim/dev
Browse files Browse the repository at this point in the history
Dev 20231104
  • Loading branch information
M1Screw authored Nov 4, 2023
2 parents bac995e + 115ac02 commit 837a12c
Show file tree
Hide file tree
Showing 108 changed files with 776 additions and 705 deletions.
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions db/migrations/2023020100-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ public function up(): int
CREATE TABLE `config` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`item` varchar(255) DEFAULT NULL COMMENT '',
`value` varchar(2048) DEFAULT NULL COMMENT '',
`class` varchar(255) DEFAULT 'default' COMMENT '配置分类',
`item` varchar(255) DEFAULT NULL COMMENT '配置项',
`value` varchar(2048) DEFAULT NULL COMMENT '配置值',
`class` varchar(255) DEFAULT 'default' COMMENT '配置类别',
`is_public` int(11) DEFAULT 0 COMMENT '是否为公共参数',
`type` varchar(255) DEFAULT NULL COMMENT '值类型',
`type` varchar(255) DEFAULT NULL COMMENT '配置值类型',
`default` varchar(255) DEFAULT NULL COMMENT '默认值',
`mark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `detect_ban_log` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '封禁记录ID',
`user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT '用户邮箱',
`detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '本次违规次数',
`ban_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '本次封禁时长',
`start_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '统计开始时间',
`end_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '统计结束时间',
`ban_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '封禁时长',
`start_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '封禁开始时间',
`end_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '封禁结束时间',
`all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
Expand All @@ -45,14 +45,14 @@ public function up(): int
CREATE TABLE `detect_list` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '审计规则ID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '规则名称',
`text` varchar(255) NOT NULL DEFAULT '' COMMENT '规则名称',
`text` varchar(255) NOT NULL DEFAULT '' COMMENT '规则介绍',
`regex` varchar(255) NOT NULL DEFAULT '' COMMENT '正则表达式',
`type` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '规则类型',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `detect_log` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '审计记录ID',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
`list_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '规则ID',
`datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '触发时间',
Expand All @@ -65,7 +65,7 @@ public function up(): int
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `docs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '文档ID',
`date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '文档日期',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '文档标题',
`content` longtext NOT NULL DEFAULT '' COMMENT '文档内容',
Expand All @@ -75,7 +75,7 @@ public function up(): int
CREATE TABLE `email_queue` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`to_email` varchar(255) NOT NULL DEFAULT '' COMMENT '收件人邮箱',
`subject` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件标题',
`subject` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件主题',
`template` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件模板',
`array` longtext NOT NULL DEFAULT '{}' COMMENT '模板参数' CHECK (json_valid(`array`)),
`time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '添加时间',
Expand All @@ -97,7 +97,7 @@ public function up(): int
CREATE TABLE `invoice` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账单ID',
`user_id` bigint(20) unsigned DEFAULT 0 COMMENT '归属用户',
`user_id` bigint(20) unsigned DEFAULT 0 COMMENT '归属用户ID',
`order_id` bigint(20) unsigned DEFAULT 0 COMMENT '订单ID',
`content` longtext DEFAULT '{}' COMMENT '账单内容' CHECK (json_valid(`content`)),
`price` double unsigned DEFAULT 0 COMMENT '账单金额',
Expand Down Expand Up @@ -178,7 +178,7 @@ public function up(): int
CREATE TABLE `order` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单ID',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '提交用户',
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '提交用户ID',
`product_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '商品ID',
`product_type` varchar(255) NOT NULL DEFAULT '' COMMENT '商品类型',
`product_name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名称',
Expand Down Expand Up @@ -228,7 +228,7 @@ public function up(): int
`status` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT '销售状态',
`create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
`sale_count` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计销售数',
`sale_count` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计销量',
`stock` int(11) NOT NULL DEFAULT -1 COMMENT '库存',
PRIMARY KEY (`id`),
KEY `id` (`id`),
Expand All @@ -241,7 +241,7 @@ public function up(): int
`user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
`type` varchar(255) NOT NULL DEFAULT '' COMMENT '获取的订阅类型',
`request_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '请求IP',
`request_user_agent` varchar(255) NOT NULL DEFAULT '' COMMENT '请求UA信息',
`request_user_agent` varchar(255) NOT NULL DEFAULT '' COMMENT '请求UA',
`request_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '请求时间',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
Expand Down
4 changes: 2 additions & 2 deletions db/migrations/2023021600-drop_user_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public function up(): int
public function down(): int
{
DB::getPdo()->exec(
"CREATE TABLE IF NOT EXISTS `user_token` (
'CREATE TABLE IF NOT EXISTS `user_token` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`token` varchar(255) DEFAULT NULL,
`user_id` bigint(20) unsigned DEFAULT NULL,
`create_time` bigint(20) unsigned DEFAULT NULL,
`expire_time` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;'
);

return 2023020100;
Expand Down
4 changes: 2 additions & 2 deletions db/migrations/2023081800-add_user_contact_method.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function up(): int

public function down(): int
{
DB::getPdo()->exec("
DB::getPdo()->exec('
ALTER TABLE user DROP COLUMN IF EXISTS `contact_method`;
");
');

return 2023080900;
}
Expand Down
4 changes: 2 additions & 2 deletions db/migrations/2023082000-remove_user_expire_in.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
return new class() implements MigrationInterface {
public function up(): int
{
DB::getPdo()->exec("
DB::getPdo()->exec('
ALTER TABLE user DROP COLUMN IF EXISTS `expire_in`;
ALTER TABLE user DROP COLUMN IF EXISTS `telegram_id`;
");
');

return 2023082000;
}
Expand Down
4 changes: 2 additions & 2 deletions db/migrations/2023102200-add_node_dynamic_rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public function up(): int

public function down(): int
{
DB::getPdo()->exec("
DB::getPdo()->exec('
ALTER TABLE node DROP COLUMN IF EXISTS `is_dynamic_rate`;
ALTER TABLE node DROP COLUMN IF EXISTS `dynamic_rate_config`;
");
');

return 2023082000;
}
Expand Down
3 changes: 1 addition & 2 deletions phpinsights.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
NunoMaduro\PhpInsights\Domain\Insights\ForbiddenDefineFunctions::class,
NunoMaduro\PhpInsights\Domain\Insights\ForbiddenDefineGlobalConstants::class,
NunoMaduro\PhpInsights\Domain\Insights\ForbiddenGlobals::class,
PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff::class,
PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff::class,
PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff::class,
PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\GlobalKeywordSniff::class,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::class,
PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer::class,
SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff::class,
SlevomatCodingStandard\Sniffs\ControlStructures\DisallowShortTernaryOperatorSniff::class,
SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff::class,
Expand Down
32 changes: 16 additions & 16 deletions src/Command/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Command;

use App\Models\Setting;
use App\Models\Config;
use App\Services\Cron as CronService;
use App\Services\Detect;
use Exception;
Expand Down Expand Up @@ -50,38 +50,38 @@ public function boot(): void
}

// Run traffic log job
if ($minute === 0 && Setting::obtain('traffic_log')) {
if ($minute === 0 && Config::obtain('traffic_log')) {
$jobs->addTrafficLog();
}

// Run daily job
if ($hour === Setting::obtain('daily_job_hour') &&
$minute === Setting::obtain('daily_job_minute') &&
time() - Setting::obtain('last_daily_job_time') > 86399
if ($hour === Config::obtain('daily_job_hour') &&
$minute === Config::obtain('daily_job_minute') &&
time() - Config::obtain('last_daily_job_time') > 86399
) {
$jobs->cleanDb();
$jobs->resetNodeBandwidth();
$jobs->resetFreeUserTraffic();
$jobs->sendDailyTrafficReport();

if (Setting::obtain('enable_detect_inactive_user')) {
if (Config::obtain('enable_detect_inactive_user')) {
$jobs->detectInactiveUser();
}

if (Setting::obtain('telegram_diary')) {
if (Config::obtain('telegram_diary')) {
$jobs->sendTelegramDiary();
}

$jobs->resetTodayTraffic();

if (Setting::obtain('telegram_daily_job')) {
if (Config::obtain('telegram_daily_job')) {
$jobs->sendTelegramDailyJob();
}

Setting::where('item', 'last_daily_job_time')->update([
Config::where('item', 'last_daily_job_time')->update([
'value' => mktime(
Setting::obtain('daily_job_hour'),
Setting::obtain('daily_job_minute'),
Config::obtain('daily_job_hour'),
Config::obtain('daily_job_minute'),
0,
(int) date('m'),
(int) date('d'),
Expand All @@ -91,15 +91,15 @@ public function boot(): void
}

// Daily finance report
if (Setting::obtain('enable_daily_finance_mail')
if (Config::obtain('enable_daily_finance_mail')
&& $hour === 0
&& $minute === 0
) {
$jobs->sendDailyFinanceMail();
}

// Weekly finance report
if (Setting::obtain('enable_weekly_finance_mail')
if (Config::obtain('enable_weekly_finance_mail')
&& $hour === 0
&& $minute === 0
&& date('w') === '1'
Expand All @@ -108,7 +108,7 @@ public function boot(): void
}

// Monthly finance report
if (Setting::obtain('enable_monthly_finance_mail')
if (Config::obtain('enable_monthly_finance_mail')
&& $hour === 0
&& $minute === 0
&& date('d') === '01'
Expand All @@ -117,14 +117,14 @@ public function boot(): void
}

// Detect GFW
if (Setting::obtain('enable_detect_gfw') && $minute === 0
if (Config::obtain('enable_detect_gfw') && $minute === 0
) {
$detect = new Detect();
$detect->gfw();
}

// Detect ban
if (Setting::obtain('enable_detect_ban') && $minute === 0
if (Config::obtain('enable_detect_ban') && $minute === 0
) {
$detect = new Detect();
$detect->ban();
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Command;

use App\Interfaces\MigrationInterface;
use App\Models\Setting;
use App\Models\Config;
use App\Services\DB;
use function count;
use function explode;
Expand Down Expand Up @@ -36,7 +36,7 @@ public function boot(): void
if ($target === 'new') {
$current = 0;
} else {
$current = Setting::obtain('db_version');
$current = Config::obtain('db_version');
}

if ($target === 'latest') {
Expand Down
Loading

0 comments on commit 837a12c

Please sign in to comment.