Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Config): Fix JSON type config return False
Browse files Browse the repository at this point in the history
After add config key type and convert method, some key in database don't convert to correct value.
  • Loading branch information
Rhilip committed Jan 10, 2020
1 parent 323c8ec commit 1129008
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion application/Components/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use App\Libraries\Mailer;
use App\Libraries\Constant;

use Rid\Http\View;
use Rid\Base\Component;
use Rid\Utils\ClassValueCacheUtils;

Expand Down
21 changes: 8 additions & 13 deletions application/Models/Form/Auth/UserRegisterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions application/Models/Form/Torrent/DownloadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = [];
Expand Down
23 changes: 12 additions & 11 deletions migration/ridpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down

0 comments on commit 1129008

Please sign in to comment.