Преглед на файлове

feat: add missing type hint

M1Screw преди 2 години
родител
ревизия
04839b08ea

+ 3 - 4
install.sh

@@ -16,12 +16,11 @@ do_install_sspanel() {
     echo "Generating config files..."
     cp config/.config.example.php config/.config.php
     cp config/appprofile.example.php config/appprofile.php
-    mv db/migrations/20000101000000_init_database.php.new db/migrations/20000101000000_init_database.php
     echo "Installing Composer..."
     wget https://getcomposer.org/installer -O composer.phar
     php composer.phar
     php composer.phar install
-    echo "Writting configuration..."
+    echo "Writing configuration..."
     sed -i -e "s/$_ENV['key']        = 'ChangeMe';/$_ENV['key']        = '$key';/g" \
     -e "s/$_ENV['appName']    = 'SSPanel-UIM';/$_ENV['appName']    = '$app_name';/g" \
     -e "s|$_ENV['baseUrl']    = 'https://example.com';|$_ENV['baseUrl']    = '$base_url';|g" \
@@ -32,7 +31,7 @@ do_install_sspanel() {
     -e "s/$_ENV['db_password']  = 'sspanel';/$_ENV['db_password']  = '$db_password';/g" \
     config/.config.php
     echo "Creating database and user..."
-    mysql -uroot -p$db_root_password \
+    mysql -uroot -p $db_root_password \
     -e "CREATE DATABASE $db_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     CREATE USER '$db_username'@'localhost';
     GRANT ALL PRIVILEGES ON $db_database.* TO '$db_username'@'localhost' IDENTIFIED BY '$db_password';
@@ -40,9 +39,9 @@ do_install_sspanel() {
     echo "Importing config to database..."
     php xcat Migration new
     php xcat Tool importAllSettings
-    wget https://cdn.jsdelivr.net/gh/sspanel-uim/qqwry.dat@latest/qqwry.dat -O storage/qqwry.dat
     current_dir=$(pwd)
     crontab -l > cron.tmp
+    echo "*/5 * * * * /usr/bin/php $current_dir/xcat Cron" >> cron.tmp
     echo "*/1 * * * * /usr/bin/php $current_dir/xcat Job CheckJob" >> cron.tmp
     echo "0 */1 * * * /usr/bin/php $current_dir/xcat Job UserJob" >> cron.tmp
     echo "0 0 * * *   /usr/bin/php -n $current_dir/xcat Job DailyJob" >> cron.tmp

+ 1 - 1
resources/views/tabler/gateway/payjs_success.tpl

@@ -11,7 +11,7 @@
                     <div class="card-main">
                         <div class="card-inner">
                             {if ($success == 1)}
-                                <p>已充值成功 {$money} 元!请进入 <a href="/user/shop">套餐购买</a> 页面来选购您的套餐。</p>
+                                <p>已充值成功 {$money} 元</p>
                             {else}
                                 <p>正在处理您的支付,请您稍等。此页面会自动刷新,或者您可以选择关闭此页面,余额将自动到账</p>
                                 <script>

+ 1 - 1
resources/views/tabler/user/index.tpl

@@ -425,7 +425,7 @@
                             </div>
                             <p class="my-3">
                                 {if time() > strtotime($user->class_expire)}
-                                    你的套餐过期了,可以前往 <a href="/user/shop">商店</a> 购买套餐
+                                    你的套餐过期了,可以前往 <a href="/user/product">商店</a> 购买套餐
                                 {else}
                                     {$diff = round((strtotime($user->class_expire) - time()) / 86400)}
                                     你的 LV. {$user->class} 套餐大约还有 {$diff} 天到期({$user->class_expire})

+ 0 - 6
resources/views/tabler/user/server.tpl

@@ -107,15 +107,9 @@
                                             <div class="card bg-primary-lt">
                                                 <div class="card-body">
                                                     <p class="text-muted">
-                                                        {if $user->use_new_shop}
                                                         <i class="ti ti-info-circle icon text-blue"></i>
                                                         你当前的账户等级小于节点等级,因此无法使用。可前往 <a
                                                             href="/user/product">商品页面</a> 订购时间流量包
-                                                        {else}
-                                                        <i class="ti ti-info-circle icon text-blue"></i>
-                                                        你当前的账户等级小于节点等级,因此无法使用。可前往 <a
-                                                            href="/user/shop">商店</a> 订购相应等级套餐
-                                                        {/if}
                                                     </p>
                                                 </div>
                                             </div>

+ 0 - 17
resources/views/tabler/user/tabler_header.tpl

@@ -189,7 +189,6 @@
                                         商店
                                     </span>
                                 </a>
-                                {if $user->use_new_shop}
                                 <div class="dropdown-menu">
                                     <div class="dropdown-menu-columns">
                                         <div class="dropdown-menu-column">
@@ -208,22 +207,6 @@
                                         </div>
                                     </div>
                                 </div>
-                                {else}
-                                <div class="dropdown-menu">
-                                    <div class="dropdown-menu-columns">
-                                        <div class="dropdown-menu-column">
-                                            <a class="dropdown-item" href="/user/shop">
-                                                <i class="ti ti-shopping-cart"></i>&nbsp;
-                                                套餐购买
-                                            </a>
-                                            <a class="dropdown-item" href="/user/code">
-                                                <i class="ti ti-checklist"></i>&nbsp;
-                                                账户充值
-                                            </a>
-                                        </div>
-                                    </div>
-                                </div>
-                                {/if}
                             </li>
                             {if $user->is_admin}
                             <li class="nav-item">

+ 0 - 1
src/Command/Tool.php

@@ -285,7 +285,6 @@ EOL;
         }
 
         if (strtolower($y) === 'y') {
-            $current_timestamp = time();
             // create admin user
             $configs = Setting::getClass('register');
             // do reg user

+ 1 - 4
src/Command/Update.php

@@ -26,7 +26,6 @@ END;
 
         $config_old = file_get_contents(BASE_PATH . '/config/.config.php');
         $config_new = file_get_contents(BASE_PATH . '/config/.config.example.php');
-
         //将旧config迁移到新config上
         $migrated = [];
         foreach ($_ENV as $key => $value_reserve) {
@@ -44,7 +43,6 @@ END;
             $config_new = str_replace($matches_new[0], $matches_old[0], $config_new);
             $migrated[] = '_ENV[\'' . $key . '\']';
         }
-
         //检查新增了哪些config
         $regex_new = '/_ENV\[\'.*?\'\]/s';
         $matches_new_all = [];
@@ -75,10 +73,9 @@ END;
             echo "新增 .config.php 配置项:" . $difference . ":" . $comment . " \n";
         }
         echo "没有任何新 .config.php 配置项需要添加。\n";
-
         file_put_contents(BASE_PATH . '/config/.config.php', $config_new);
         echo "迁移完成。\n";
-
+        // 更新 GeoLite2 数据库
         if ($_ENV['maxmind_license_key'] !== '') {
             echo "正在更新 GeoLite2 数据库...\n";
             $client = new Client([

+ 5 - 1
src/Controllers/AuthController.php

@@ -235,7 +235,6 @@ final class AuthController extends BaseController
         // do reg user
         $user = new User();
         $antiXss = new AntiXSS();
-        $current_timestamp = time();
 
         $user->user_name = $antiXss->xss_clean($name);
         $user->email = $antiXss->xss_clean($email);
@@ -344,11 +343,16 @@ final class AuthController extends BaseController
 
         $antiXss = new AntiXSS();
 
+        $tos = $request->getParam('tos') === 'true' ? 1 : 0;
         $email = strtolower(trim($antiXss->xss_clean($request->getParam('email'))));
         $name = $antiXss->xss_clean($request->getParam('name'));
         $passwd = $request->getParam('passwd');
         $repasswd = $request->getParam('repasswd');
         $code = $antiXss->xss_clean(trim($request->getParam('code')));
+        // Check TOS agreement
+        if (! $tos) {
+            return ResponseHelper::error($response, '请同意服务条款');
+        }
 
         if (Setting::obtain('enable_reg_im') === true) {
             $imtype = $antiXss->xss_clean($request->getParam('im_type'));

+ 2 - 2
src/Controllers/UserController.php

@@ -414,7 +414,7 @@ final class UserController extends BaseController
         $user->uuid = Uuid::uuid4();
         $user->passwd = Tools::genRandomChar(16);
 
-        if (! $user->save()){
+        if (! $user->save()) {
             return ResponseHelper::error($response, '目前出现一些问题,请稍后再试');
         }
 
@@ -426,7 +426,7 @@ final class UserController extends BaseController
         $user = $this->user;
         $user->api_token = Uuid::uuid4();
 
-        if (! $user->save()){
+        if (! $user->save()) {
             return ResponseHelper::error($response, '目前出现一些问题,请稍后再试');
         }
 

+ 2 - 2
src/Utils/Telegram/Commands/CheckinCommand.php

@@ -17,12 +17,12 @@ final class CheckinCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'checkin';
+    protected string $name = 'checkin';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] 每日签到.';
+    protected string $description = '[群组/私聊] 每日签到.';
 
     /**
      * {@inheritdoc}

+ 2 - 2
src/Utils/Telegram/Commands/HelpCommand.php

@@ -16,12 +16,12 @@ final class HelpCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'help';
+    protected string $name = 'help';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] 系统中可用的所有命令.';
+    protected string $description = '[群组/私聊] 系统中可用的所有命令.';
 
     public function handle(): void
     {

+ 2 - 2
src/Utils/Telegram/Commands/InfoCommand.php

@@ -21,12 +21,12 @@ final class InfoCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'info';
+    protected string $name = 'info';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组]     获取被回复消息的用户信息,管理员命令.';
+    protected string $description = '[群组]     获取被回复消息的用户信息,管理员命令.';
 
     public function handle(): void
     {

+ 2 - 2
src/Utils/Telegram/Commands/MenuCommand.php

@@ -18,12 +18,12 @@ final class MenuCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'menu';
+    protected string $name = 'menu';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[私聊]     用户主菜单、个人中心.';
+    protected string $description = '[私聊]     用户主菜单、个人中心.';
 
     /**
      * {@inheritdoc}

+ 2 - 2
src/Utils/Telegram/Commands/MyCommand.php

@@ -19,12 +19,12 @@ final class MyCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'my';
+    protected string $name = 'my';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] 我的个人信息.';
+    protected string $description = '[群组/私聊] 我的个人信息.';
 
     /**
      * {@inheritdoc}

+ 2 - 2
src/Utils/Telegram/Commands/PingCommand.php

@@ -16,12 +16,12 @@ final class PingCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'ping';
+    protected string $name = 'ping';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] 获取我或者群组的唯一 ID.';
+    protected string $description = '[群组/私聊] 获取我或者群组的唯一 ID.';
 
     public function handle(): void
     {

+ 2 - 2
src/Utils/Telegram/Commands/SetuserCommand.php

@@ -22,12 +22,12 @@ final class SetuserCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'setuser';
+    protected string $name = 'setuser';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] 修改用户数据,管理员命令.';
+    protected string $description = '[群组/私聊] 修改用户数据,管理员命令.';
 
     public function handle(): void
     {

+ 2 - 2
src/Utils/Telegram/Commands/StartCommand.php

@@ -20,12 +20,12 @@ final class StartCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'start';
+    protected string $name = 'start';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[群组/私聊] Bot 初始命令.';
+    protected string $description = '[群组/私聊] Bot 初始命令.';
 
     public function handle(): void
     {

+ 2 - 2
src/Utils/Telegram/Commands/UnbindCommand.php

@@ -17,12 +17,12 @@ final class UnbindCommand extends Command
     /**
      * @var string Command Name
      */
-    protected $name = 'unbind';
+    protected string $name = 'unbind';
 
     /**
      * @var string Command Description
      */
-    protected $description = '[私聊]     解除账户绑定.';
+    protected string $description = '[私聊]     解除账户绑定.';
 
     public function handle(): void
     {

+ 1 - 0
src/Utils/Telegram/Message.php

@@ -39,6 +39,7 @@ final class Message
      * 触发源信息 ID
      */
     private $MessageID;
+    private $User;
 
     /**
      * @throws TelegramSDKException

+ 1 - 1
update.sh

@@ -6,7 +6,7 @@ Author: M1Screw
 Github: https://github.com/sspanel-uim/SSPanel-Uim-Dev
 Usage: 
 ./update.sh dev --> Upgrade to the latest development version
-./update.sh release release_version db_version --> Upgrade to the specified release version
+./update.sh release $release_version $db_version --> Upgrade to the release version with the specified database version
 EOF
 
 [ $(id -u) != "0" ] && { echo "Error: You must be root to run this script!"; exit 1; }