From 112900891f633dad5da1831b3ad2b77cd6d643b0 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Fri, 10 Jan 2020 22:37:05 +0800 Subject: [PATCH] fix(Config): Fix JSON type config return False After add config key type and convert method, some key in database don't convert to correct value. --- CHANGELOG.md | 2 ++ application/Components/Site.php | 1 - .../Models/Form/Auth/UserRegisterForm.php | 21 +++++++---------- .../Models/Form/Torrent/DownloadForm.php | 6 ++--- migration/ridpt.sql | 23 ++++++++++--------- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d50af..beb6863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - **composer:** bump adhocore/cli (6647c9d) ### Docs +- **README:** fix typo of start command (657c71a) +- **Redis:** Fix phpdoc for Redis Component (70ac399) - **Sponsor:** Add Sponsor `MeiHeZi` (ae612e0) ### Feat diff --git a/application/Components/Site.php b/application/Components/Site.php index 6e62b09..9fea385 100644 --- a/application/Components/Site.php +++ b/application/Components/Site.php @@ -12,7 +12,6 @@ use App\Libraries\Mailer; use App\Libraries\Constant; -use Rid\Http\View; use Rid\Base\Component; use Rid\Utils\ClassValueCacheUtils; diff --git a/application/Models/Form/Auth/UserRegisterForm.php b/application/Models/Form/Auth/UserRegisterForm.php index be67cbd..f75ea87 100644 --- a/application/Models/Form/Auth/UserRegisterForm.php +++ b/application/Models/Form/Auth/UserRegisterForm.php @@ -186,22 +186,17 @@ protected function isValidEmail() { $email = $this->getInput('email'); $email_suffix = substr($email, strpos($email, '@')); // Will get `@test.com` as example + if (config('register.check_email_blacklist') && - config('register.email_black_list')) { - $email_black_list = explode(',', config('register.email_black_list')); - if (in_array($email_suffix, $email_black_list)) { - $this->buildCallbackFailMsg('ValidEmail', "The email suffix `$email_suffix` is not allowed."); - return; - } + in_array($email_suffix, config('register.email_black_list'))) { + $this->buildCallbackFailMsg('ValidEmail', "The email suffix `$email_suffix` is not allowed."); + return; } if (config('register.check_email_whitelist') && - config('register.email_white_list')) { - $email_white_list = explode(',', config('register.email_white_list')); - if (!in_array($email_suffix, $email_white_list)) { - $this->buildCallbackFailMsg('ValidEmail', "The email suffix `$email_suffix` is not allowed."); - return; - } + !in_array($email_suffix, config('register.email_white_list'))) { + $this->buildCallbackFailMsg('ValidEmail', "The email suffix `$email_suffix` is not allowed."); + return; } // Check $email is in blacklist or not @@ -282,7 +277,7 @@ public function flush() } // Insert into `users` table and get insert id - app()->pdo->createCommand("INSERT INTO `users` (`username`, `password`, `email`, `status`, `class`, `passkey`, `invite_by`, `create_at`, `register_ip`, `uploadpos`, `downloadpos`, `uploaded`, `downloaded`, `seedtime`, `leechtime`, `bonus_other`,`invites`) + app()->pdo->createCommand("INSERT INTO `users` (`username`, `password`, `email`, `status`, `class`, `passkey`, `invite_by`, `create_at`, `register_ip`, `uploadpos`, `downloadpos`, `uploaded`, `downloaded`, `seedtime`, `leechtime`, `bonus_other`,`invites`) VALUES (:name, :passhash, :email, :status, :class, :passkey, :invite_by, CURRENT_TIMESTAMP, INET6_ATON(:ip), :uploadpos, :downloadpos, :uploaded, :downloaded, :seedtime, :leechtime, :bonus, :invites)")->bindParams(array( 'name' => $this->username, 'passhash' => password_hash($this->password, PASSWORD_DEFAULT), 'email' => $this->email, 'status' => $this->status, 'class' => $this->class, 'passkey' => $this->passkey, diff --git a/application/Models/Form/Torrent/DownloadForm.php b/application/Models/Form/Torrent/DownloadForm.php index 9902b7a..b50c0b9 100644 --- a/application/Models/Form/Torrent/DownloadForm.php +++ b/application/Models/Form/Torrent/DownloadForm.php @@ -63,10 +63,10 @@ public function getSendFileContent() * @see https://web.archive.org/web/20190724110959/https://blog.rhilip.info/archives/1108/ * which discuss about multitracker behaviour on common bittorrent client ( Chinese Version ) */ - if ($multi_trackers = config('base.site_multi_tracker_url')) { + $multi_trackers_list = config('base.site_multi_tracker_url'); + if (!empty($multi_trackers)) { // Add our main tracker into multi_tracker_list to avoid lost.... - $multi_trackers = config('base.site_tracker_url') . ',' . $multi_trackers; - $multi_trackers_list = explode(',', $multi_trackers); + array_unshift($multi_trackers_list, config('base.site_tracker_url')); $multi_trackers_list = array_unique($multi_trackers_list); // use array_unique to remove dupe tracker $dict["announce-list"] = []; diff --git a/migration/ridpt.sql b/migration/ridpt.sql index adf13e4..60adc34 100644 --- a/migration/ridpt.sql +++ b/migration/ridpt.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 --- Generation Time: Sep 13, 2019 at 04:39 PM +-- Generation Time: Jan 10, 2020 at 10:28 PM -- Server version: 8.0.17 -- PHP Version: 7.3.7 @@ -772,6 +772,7 @@ INSERT INTO `site_config` (`name`, `type`, `value`) VALUES ('authority.manage_links', 'int', '80'), ('authority.manage_news', 'int', '80'), ('authority.manage_subtitles', 'int', '80'), +('authority.manage_torrents', 'int', '80'), ('authority.pass_invite_interval_check', 'int', '60'), ('authority.pass_tracker_upspeed_check', 'int', '60'), ('authority.see_anonymous_info', 'int', '60'), @@ -800,7 +801,7 @@ INSERT INTO `site_config` (`name`, `type`, `value`) VALUES ('base.site_generator', 'string', 'RidPT'), ('base.site_keywords', 'string', 'RidPT,Private Tracker'), ('base.site_multi_tracker_behaviour', 'string', 'union'), -('base.site_multi_tracker_url', 'json', ''), +('base.site_multi_tracker_url', 'json', '[]'), ('base.site_name', 'string', 'RidPT'), ('base.site_tracker_url', 'string', 'ridpt.top/tracker'), ('base.site_url', 'string', 'ridpt.top'), @@ -824,15 +825,15 @@ INSERT INTO `site_config` (`name`, `type`, `value`) VALUES ('invite.recycle_invite_lifetime', 'int', '86400'), ('invite.recycle_return_invite', 'int', '1'), ('invite.timeout', 'int', '259200'), -('register.by_green', 'int', '0'), -('register.by_invite', 'int', '1'), -('register.by_open', 'int', '1'), -('register.check_email_blacklist', 'int', '1'), -('register.check_email_whitelist', 'int', '1'), -('register.check_max_ip', 'int', '1'), -('register.check_max_user', 'int', '1'), -('register.email_black_list', 'json', '@test.com'), -('register.email_white_list', 'json', '@gmail.com'), +('register.by_green', 'bool', '0'), +('register.by_invite', 'bool', '1'), +('register.by_open', 'bool', '1'), +('register.check_email_blacklist', 'bool', '1'), +('register.check_email_whitelist', 'bool', '1'), +('register.check_max_ip', 'bool', '1'), +('register.check_max_user', 'bool', '1'), +('register.email_black_list', 'json', '[\"@test.com\"]'), +('register.email_white_list', 'json', '[\"@gmail.com\"]'), ('register.per_ip_user', 'int', '5'), ('register.user_confirm_way', 'string', 'auto'), ('register.user_default_bonus', 'int', '0'),