From 69fdce9fcd5c084d0a985a8c6e4d5889f600d23e Mon Sep 17 00:00:00 2001 From: Rhilip Date: Wed, 11 Sep 2019 20:30:34 +0800 Subject: [PATCH] fix(fix): Fix torrent can't upload after last commits 1. mv 'src\private' to 'private' , 'src\runtime' to 'var' 2. Remove Site->ruleCanUsedTeam() function 3. Fix namespace error of App\Models\Api\v1\Form\TorrentsForm 4. Fix logo image lost.. --- README.md | 2 +- bin/rid-httpd | 2 +- framework/Http/Application.php | 9 ++++---- {src/private => private}/subs/.gitignore | 0 {src/private => private}/torrents/.gitignore | 0 src/Components/Site.php | 7 ------ src/Controllers/Api/v1/TorrentController.php | 2 +- .../Api/v1/{form => Form}/TorrentsForm.php | 0 src/Models/Form/Torrents/UploadForm.php | 22 +++++++++---------- templates/torrent/details.php | 2 +- templates/torrents/upload.php | 6 +++-- {src/runtime => var/logs}/.gitignore | 0 12 files changed, 24 insertions(+), 28 deletions(-) rename {src/private => private}/subs/.gitignore (100%) rename {src/private => private}/torrents/.gitignore (100%) rename src/Models/Api/v1/{form => Form}/TorrentsForm.php (100%) rename {src/runtime => var/logs}/.gitignore (100%) diff --git a/README.md b/README.md index 38b673d..4c2db43 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

-
+
A Private Torrent framework Project.
GitHub Releases used-Swoole-blue diff --git a/bin/rid-httpd b/bin/rid-httpd index 0c76f52..2ca2a73 100644 --- a/bin/rid-httpd +++ b/bin/rid-httpd @@ -56,7 +56,7 @@ $dotenv->load(); // $dotenv->overload(); /* * -------------------------------------------------------------------------- - * FIXME Start Console Application + * Start Console Application * -------------------------------------------------------------------------- */ $config = require RIDPT_ROOT . '/config/httpd.php'; diff --git a/framework/Http/Application.php b/framework/Http/Application.php index 0cb1d69..0a3eb3a 100644 --- a/framework/Http/Application.php +++ b/framework/Http/Application.php @@ -3,6 +3,7 @@ namespace Rid\Http; use Rid\Base\Component; +use Swoole\Http\Server; /** * Appē±» @@ -191,7 +192,7 @@ public function end($content = '') } /** - * @return \Swoole\Http\Server + * @return Server */ public function getServ() { @@ -199,14 +200,14 @@ public function getServ() } /** - * @param \Swoole\Http\Server $serv + * @param Server $serv */ - public function setServ(\Swoole\Http\Server $serv): void + public function setServ(Server $serv): void { $this->_serv = $serv; } - public function getWorkerId():int + public function getWorkerId(): int { return $this->_worker ?? -1; } diff --git a/src/private/subs/.gitignore b/private/subs/.gitignore similarity index 100% rename from src/private/subs/.gitignore rename to private/subs/.gitignore diff --git a/src/private/torrents/.gitignore b/private/torrents/.gitignore similarity index 100% rename from src/private/torrents/.gitignore rename to private/torrents/.gitignore diff --git a/src/Components/Site.php b/src/Components/Site.php index a490bb6..7f546a0 100644 --- a/src/Components/Site.php +++ b/src/Components/Site.php @@ -189,13 +189,6 @@ public function ruleTeam(): array return $data ?: []; } - public function ruleCanUsedTeam(): array - { - return array_filter($this->ruleTeam(), function ($team) { - return app()->auth->getCurUser()->getClass() >= $team['class_require']; - }); - } - /** * @return array like [ => , => ] */ diff --git a/src/Controllers/Api/v1/TorrentController.php b/src/Controllers/Api/v1/TorrentController.php index 0fc6ca2..d65ee23 100644 --- a/src/Controllers/Api/v1/TorrentController.php +++ b/src/Controllers/Api/v1/TorrentController.php @@ -8,7 +8,7 @@ namespace App\Controllers\Api\v1; -use App\Models\api\v1\Form\TorrentsForm; +use App\Models\Api\v1\Form\TorrentsForm; class TorrentController extends ApiController { diff --git a/src/Models/Api/v1/form/TorrentsForm.php b/src/Models/Api/v1/Form/TorrentsForm.php similarity index 100% rename from src/Models/Api/v1/form/TorrentsForm.php rename to src/Models/Api/v1/Form/TorrentsForm.php diff --git a/src/Models/Form/Torrents/UploadForm.php b/src/Models/Form/Torrents/UploadForm.php index 1504dc0..4056206 100644 --- a/src/Models/Form/Torrents/UploadForm.php +++ b/src/Models/Form/Torrents/UploadForm.php @@ -113,13 +113,13 @@ public static function inputRules(): array // Add Quality Valid foreach (app()->site->getQualityTableList() as $quality => $title) { - $quality_id_list = []; + $quality_id_list = [0]; // IF enabled this quality field , then load it value list from setting // Else we just allow the default value 0 to prevent cheating if (config('torrent_upload.enable_quality_' . $quality)) { - $quality_id_list = array_map(function ($cat) { - return $cat['id']; - }, app()->site->ruleQuality($quality)); + foreach (app()->site->ruleQuality($quality) as $cat) { + $quality_id_list[] = $cat['id']; + } } $rules[$quality] = [ @@ -129,11 +129,13 @@ public static function inputRules(): array } // Add Team id Valid - $team_id_list = []; + $team_id_list = [0]; if (config('torrent_upload.enable_teams')) { - $team_id_list = array_map(function ($team) { - return $team['id']; - }, app()->site->ruleCanUsedTeam()); + foreach (app()->site->ruleTeam() as $team) { + if (app()->auth->getCurUser()->getClass() >= $team['class_require']) { + $team_id_list[] = $team['id']; + } + } } $rules['team'] = [ @@ -373,9 +375,7 @@ private function getTags(): array $tags_list = array_slice($tags_list, 0, 10); // Get first 10 tags if (!config('torrent_upload.allow_new_custom_tags')) { - $rule_pinned_tags = array_map(function ($tag_row) { - return $tag_row['tag']; - }, app()->site->rulePinnedTags()); + $rule_pinned_tags = array_keys(app()->site->rulePinnedTags()); $tags_list = array_intersect($rule_pinned_tags, $tags_list); } } diff --git a/templates/torrent/details.php b/templates/torrent/details.php index 0c4be83..e6aae73 100644 --- a/templates/torrent/details.php +++ b/templates/torrent/details.php @@ -84,7 +84,7 @@ getIncomplete() ?> / getDownloaded() ?> -

Info Hash:getInfoHash() ?>
+
Info Hash:getInfoHash() ?>
diff --git a/templates/torrents/upload.php b/templates/torrents/upload.php index 0685183..1b7cdbf 100644 --- a/templates/torrents/upload.php +++ b/templates/torrents/upload.php @@ -96,8 +96,10 @@
diff --git a/src/runtime/.gitignore b/var/logs/.gitignore similarity index 100% rename from src/runtime/.gitignore rename to var/logs/.gitignore