From 37920145b0ad11bbef17493bb0b37480178b19c5 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sat, 4 Mar 2023 13:26:20 +0800 Subject: [PATCH] torrent keyword search remove or --- .../HitAndRunResource/Pages/ViewHitAndRun.php | 13 +++++--- ...ex_to_last_action_field_of_peers_table.php | 32 +++++++++++++++++++ include/globalfunctions.php | 5 +-- lang/chs/lang_settings.php | 8 ++--- lang/cht/lang_settings.php | 8 ++--- lang/en/lang_settings.php | 8 ++--- nexus/Install/settings.default.php | 10 +++--- public/getrss.php | 3 +- public/scrape.php | 18 +++++------ public/torrentrss.php | 2 +- public/torrents.php | 7 ++-- public/usercp.php | 4 +-- routes/third-party.php | 3 ++ 13 files changed, 81 insertions(+), 40 deletions(-) create mode 100644 database/migrations/2023_03_04_031319_add_index_to_last_action_field_of_peers_table.php create mode 100644 routes/third-party.php diff --git a/app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php b/app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php index 5aa26b40..5937a28e 100644 --- a/app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php +++ b/app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php @@ -80,8 +80,9 @@ class ViewHitAndRun extends ViewRecord protected function getActions(): array { - return [ - Actions\Action::make('Pardon') + $actions = []; + if (in_array($this->record->status, HitAndRun::CAN_PARDON_STATUS)) { + $actions[] = Actions\Action::make('Pardon') ->requiresConfirmation() ->action(function () { $hitAndRunRep = new HitAndRunRepository(); @@ -93,10 +94,12 @@ class ViewHitAndRun extends ViewRecord $this->notify('danger', $exception->getMessage()); } }) - ->label(__('admin.resources.hit_and_run.action_pardon')), + ->label(__('admin.resources.hit_and_run.action_pardon')) + ; + } + $actions[] = Actions\DeleteAction::make(); - Actions\DeleteAction::make(), - ]; + return $actions; } } diff --git a/database/migrations/2023_03_04_031319_add_index_to_last_action_field_of_peers_table.php b/database/migrations/2023_03_04_031319_add_index_to_last_action_field_of_peers_table.php new file mode 100644 index 00000000..68850daa --- /dev/null +++ b/database/migrations/2023_03_04_031319_add_index_to_last_action_field_of_peers_table.php @@ -0,0 +1,32 @@ +index('last_action'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('peers', function (Blueprint $table) { + $table->dropIndex('peers_last_action_index'); + }); + } +}; diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 7b76b4b9..82c2a5be 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -97,9 +97,10 @@ function hash_pad($hash) { } function hash_where($name, $hash) { - $shhash = preg_replace('/ *$/s', "", $hash); +// $shhash = preg_replace('/ *$/s', "", $hash); // return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")"; - return sprintf("$name in (%s, %s)", sqlesc($hash), sqlesc($shhash)); +// return sprintf("$name in (%s, %s)", sqlesc($hash), sqlesc($shhash)); + return "$name = " . sqlesc($hash); } //no need any more... diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index da328edf..45ecc1dd 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -451,13 +451,13 @@ $lang_settings = array 'row_cleanup_interval' => "自动清理间隔", 'text_cleanup_interval_note_one' => "每XXX秒时间做自动清理工作(用户升级、降级、添加做种魔力值等)。", 'text_priority_one' => "优先级1:", - 'text_priority_one_note' => "更新同伴状态;添加做种魔力值。默认'900',即15分钟。", + 'text_priority_one_note' => "更新同伴状态;添加做种魔力值。默认'3600',即60分钟。", 'text_priority_two' => "优先级2:", - 'text_priority_two_note' => "更新种子可见性。默认'1800',即30分钟。", + 'text_priority_two_note' => "更新种子可见性。默认'5400',即90分钟。", 'text_priority_three' => "优先级3:", - 'text_priority_three_note' => "更新种子做种数、下载数、评论数;更新论坛帖子/主题数;删除过期的候选;种子促销到期;自动挑选热门种子。默认'3600',即60分钟。", + 'text_priority_three_note' => "更新种子做种数、下载数、评论数;更新论坛帖子/主题数;删除过期的候选;种子促销到期;自动挑选热门种子。默认'7200',即2小时。", 'text_priority_four' => "优先级4:", - 'text_priority_four_note' => "删除未通过验证的账号,过期的登录尝试记录,过期的邀请码和图片验证码;清理用户账号(删除不活跃账号,账号升级、降级、禁用);发送上传的图片;更新用户总做种和下载时间。默认'43200',即24小时。", + 'text_priority_four_note' => "删除未通过验证的账号,过期的登录尝试记录,过期的邀请码和图片验证码;清理用户账号(删除不活跃账号,账号升级、降级、禁用);发送上传的图片;更新用户总做种和下载时间。默认'86400',即24小时。", 'text_priority_five' => "优先级5:", 'text_priority_five_note' => "删除种子文件不存在的种子;锁定论坛的古老主题;删除古老的举报信息。默认'1296000',即15天。", 'text_cleanup_interval_note_two' => "注意不要改变时间递增的排序。", diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index fcce624c..21979107 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -452,13 +452,13 @@ $lang_settings = array 'row_cleanup_interval' => "自動清理間隔", 'text_cleanup_interval_note_one' => "每XXX秒時間做自動清理工作(用戶升級、降級、添加做種魔力值等)。", 'text_priority_one' => "優先級1:", - 'text_priority_one_note' => "更新同伴狀態;添加做種魔力值。預設'900',即15分鐘。", + 'text_priority_one_note' => "更新同伴狀態;添加做種魔力值。預設'3600',即60分鐘。", 'text_priority_two' => "優先級2:", - 'text_priority_two_note' => "更新種子可見性。預設'1800',即30分鐘。", + 'text_priority_two_note' => "更新種子可見性。預設'5400',即90分鐘。", 'text_priority_three' => "優先級3:", - 'text_priority_three_note' => "更新種子做種數、下載數、評論數;更新論壇帖子/主題數;移除過期的候選;種子促銷到期;自動挑揀熱門種子。預設'3600',即60分鐘。", + 'text_priority_three_note' => "更新種子做種數、下載數、評論數;更新論壇帖子/主題數;移除過期的候選;種子促銷到期;自動挑揀熱門種子。預設'7200',即2小時。", 'text_priority_four' => "優先級4:", - 'text_priority_four_note' => "移除未通過驗證的賬號,過期的登入嘗試記錄,過期的邀請碼和圖片驗證碼;清理用戶賬號(移除不活躍賬號,賬號升級、降級、禁用);傳送上傳的圖片;更新用戶總做種和下載時間。預設'43200',即24小時。", + 'text_priority_four_note' => "移除未通過驗證的賬號,過期的登入嘗試記錄,過期的邀請碼和圖片驗證碼;清理用戶賬號(移除不活躍賬號,賬號升級、降級、禁用);傳送上傳的圖片;更新用戶總做種和下載時間。預設'86400',即24小時。", 'text_priority_five' => "優先級5:", 'text_priority_five_note' => "移除種子檔案不存在的種子;鎖定論壇的古老主題;移除古老的舉報資訊。預設'1296000',即15天。", 'text_cleanup_interval_note_two' => "注意不要改變時間遞增的排序。", diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php index e05104eb..874de49b 100644 --- a/lang/en/lang_settings.php +++ b/lang/en/lang_settings.php @@ -451,13 +451,13 @@ $lang_settings = array 'row_cleanup_interval' => "Auto Cleanup Interval", 'text_cleanup_interval_note_one' => "Do cleanup (user promotion, demotion, adding seeding bonus, etc.) every XXX seconds.", 'text_priority_one' => "Priority 1: ", - 'text_priority_one_note' => "Update peer status; Calculate seeding bonus. Default '900', i.e. 15 mins.", + 'text_priority_one_note' => "Update peer status; Calculate seeding bonus. Default '3600', i.e. 60 minutes.", 'text_priority_two' => "Priority 2: ", - 'text_priority_two_note' => "Update torrents' visibility. Default '1800', i.e. 30 mins.", + 'text_priority_two_note' => "Update torrents' visibility. Default '5400', i.e. 90 minutes.", 'text_priority_three' => "Priority 3: ", - 'text_priority_three_note' => "Update count of seeders, leechers, comments for torrents; Update forum post/topic count; Delete offers that are timeout; Expire torrent promotion; Automatically pick hot torrents. Default '3600', i.e. 60 mins.", + 'text_priority_three_note' => "Update count of seeders, leechers, comments for torrents; Update forum post/topic count; Delete offers that are timeout; Expire torrent promotion; Automatically pick hot torrents. Default '7200', i.e. 2 hours.", 'text_priority_four' => "Priority 4: ", - 'text_priority_four_note' => "Delete unconfirmed accounts, old login attempts, invite codes and regimage codes; Clean up user accounts (delete inactive ones, do account promotion and demotion, banning, etc.); Post uploaded image; Update total seeding and leeching time of users. Default '43200', i.e. 24 hours.", + 'text_priority_four_note' => "Delete unconfirmed accounts, old login attempts, invite codes and regimage codes; Clean up user accounts (delete inactive ones, do account promotion and demotion, banning, etc.); Post uploaded image; Update total seeding and leeching time of users. Default '86400', i.e. 24 hours.", 'text_priority_five' => "Priority 5: ", 'text_priority_five_note' => "Delete torrents that doesn't exist any more; Lock very old forum topics; Delete very old report items. Default '1296000', i.e. 15 days.", 'text_cleanup_interval_note_two' => "NOTE: Do NOT change the ascendant order of the times!", diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php index 7757ab53..78e34aa3 100644 --- a/nexus/Install/settings.default.php +++ b/nexus/Install/settings.default.php @@ -39,11 +39,11 @@ return array ( 'PAYPALACCOUNT' => '', 'SLOGAN' => 'The Ultimate File Sharing Experience', 'icplicense' => '', - 'autoclean_interval_one' => '900', - 'autoclean_interval_two' => '1800', - 'autoclean_interval_three' => '3600', - 'autoclean_interval_four' => '43200', - 'autoclean_interval_five' => '648000', + 'autoclean_interval_one' => '3600', + 'autoclean_interval_two' => '5400', + 'autoclean_interval_three' => '7200', + 'autoclean_interval_four' => '86400', + 'autoclean_interval_five' => '1296000', 'reportemail' => 'nobody@gmail.com', 'invitesystem' => 'no', 'registration' => 'yes', diff --git a/public/getrss.php b/public/getrss.php index a0ddd55f..3c15d7ae 100644 --- a/public/getrss.php +++ b/public/getrss.php @@ -154,7 +154,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $query[] = "search=".rawurlencode($searchstr); if ($_POST["search_mode"]){ $search_mode = intval($_POST["search_mode"] ?? 0); - if (!in_array($search_mode,array(0,1,2))) + if (!in_array($search_mode,array(0,2))) { $search_mode = 0; } @@ -367,7 +367,6 @@ if (get_setting('main.spsct') == 'yes') { diff --git a/public/scrape.php b/public/scrape.php index 2dc70b69..547abcdd 100644 --- a/public/scrape.php +++ b/public/scrape.php @@ -7,6 +7,14 @@ dbconn_announce(); // BLOCK ACCESS WITH WEB BROWSERS AND CHEATS! block_browser(); +$cacheKey = md5($_SERVER["QUERY_STRING"]); +$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey); +if ($cacheData) { + do_log("[SCRAPE_FROM_CACHE]: " . $_SERVER["QUERY_STRING"]); + benc_resp($cacheData); + exit(0); +} + preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_array); $fields = "info_hash, times_completed, seeders, leechers"; @@ -18,14 +26,6 @@ else { $query = "SELECT $fields FROM torrents WHERE " . hash_where_arr('info_hash', $info_hash_array[1]); } -$cacheKey = md5($query); -$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey); -if ($cacheData) { - do_log("[SCRAPE_FROM_CACHE]: " . json_encode($info_hash_array[1])); - benc_resp($cacheData); - exit(0); -} - $res = sql_query($query); if (mysql_num_rows($res) < 1){ @@ -42,5 +42,5 @@ while ($row = mysql_fetch_assoc($res)) { } $d = ['files' => $torrent_details]; -\Nexus\Database\NexusDB::cache_put($cacheKey, $d, 900); +\Nexus\Database\NexusDB::cache_put($cacheKey, $d, 1200); benc_resp($d); diff --git a/public/torrentrss.php b/public/torrentrss.php index d6f5d12e..0a982c5c 100644 --- a/public/torrentrss.php +++ b/public/torrentrss.php @@ -42,7 +42,7 @@ if (empty($searchstr)) unset($searchstr); if (isset($searchstr)){ $search_mode = intval($_GET["search_mode"] ?? 0); - if (!in_array($search_mode,array(0,1,2))) + if (!in_array($search_mode,array(0,2))) { $search_mode = 0; } diff --git a/public/torrents.php b/public/torrents.php index b14e38c7..d8276748 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -695,7 +695,11 @@ if (isset($searchstr)) $notnewword="notnewword=1&"; } $search_mode = intval($_GET["search_mode"] ?? 0); - if (!in_array($search_mode,array(0,1,2))) + /** + * Deprecated search mode: 1(OR) + * @since 1.8 + */ + if (!in_array($search_mode,array(0,2))) { $search_mode = 0; write_log("User " . $CURUSER["username"] . "," . $CURUSER["ip"] . " is hacking search_mode field in" . $_SERVER['SCRIPT_NAME'], 'mod'); @@ -1189,7 +1193,6 @@ if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showin diff --git a/public/usercp.php b/public/usercp.php index 9553ff29..71c295af 100644 --- a/public/usercp.php +++ b/public/usercp.php @@ -5,10 +5,10 @@ require_once(get_langfile_path()); loggedinorreturn(); function bark($msg) { - //stdhead(); + stdhead(); global $lang_usercp; stdmsg($lang_usercp['std_sorry'], $msg); - //stdfoot(); + stdfoot(); exit; } function usercpmenu ($selected = "home") { diff --git a/routes/third-party.php b/routes/third-party.php new file mode 100644 index 00000000..eb70c138 --- /dev/null +++ b/routes/third-party.php @@ -0,0 +1,3 @@ +