diff --git a/app/Filament/Resources/User/ClaimResource.php b/app/Filament/Resources/User/ClaimResource.php index 33633c6c..6559b76f 100644 --- a/app/Filament/Resources/User/ClaimResource.php +++ b/app/Filament/Resources/User/ClaimResource.php @@ -75,6 +75,16 @@ class ClaimResource extends Resource return $query->when($data['uid'], fn (Builder $query, $uid) => $query->where("uid", $uid)); }) , + Tables\Filters\Filter::make('torrent_id') + ->form([ + Forms\Components\TextInput::make('torrent_id') + ->label(__('claim.fields.torrent_id')) + ->placeholder(__('claim.fields.torrent_id')) + , + ])->query(function (Builder $query, array $data) { + return $query->when($data['torrent_id'], fn (Builder $query, $value) => $query->where("torrent_id", $value)); + }) + , ]) ->actions([ // Tables\Actions\EditAction::make(), diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index a36faa4c..9f792ef1 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -5,8 +5,6 @@ namespace App\Models; use App\Repositories\TagRepository; use Carbon\Carbon; use Illuminate\Database\Eloquent\Casts\Attribute; -use JeroenG\Explorer\Application\Explored; -use Laravel\Scout\Searchable; class Torrent extends NexusModel { diff --git a/include/constants.php b/include/constants.php index 3dc834db..f92778d0 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ ] []: '.$lang_functions['text_attended'].'', $attendance->points, $CURUSER['attendance_card']); }else{ printf(' %s', $lang_functions['text_attendance']);}?> - : []: + = \App\Models\User::CLASS_ADMINISTRATOR) printf('[%s]', nexus_env('FILAMENT_PATH', 'nexusphp'), $lang_functions['text_management_system'])?>
@@ -2648,27 +2648,47 @@ else { H&R: %s]', (new \App\Repositories\HitAndRunRepository())->getStatusStats($CURUSER['id']))?> %s]', $CURUSER['id'], (new \App\Repositories\ClaimRepository())->getStats($CURUSER['id']))?> - = \App\Models\User::CLASS_ADMINISTRATOR) printf('[%s]', nexus_env('FILAMENT_PATH', 'nexusphp'), $lang_functions['text_management_system'])?> -
+ +
+
+
+
+ : + +
+
+ : + 'width: 108px'])?> +
+
+
+
+
+ + get_value('staff_report_count'); - if ($totalreports == ""){ - $totalreports = get_row_count("reports"); - $Cache->cache_value('staff_report_count', $totalreports, 900); - } - $totalcheaters = $Cache->get_value('staff_cheater_count'); - if ($totalcheaters == ""){ - $totalcheaters = get_row_count("cheaters"); - $Cache->cache_value('staff_cheater_count', $totalcheaters, 900); - } - print( - "\"cheaterbox\" ".$totalcheaters - ." \"reportbox\" ".$totalreports - ); - } +if (user_can('staffmem')) { + $totalreports = $Cache->get_value('staff_report_count'); + if ($totalreports == ""){ + $totalreports = get_row_count("reports"); + $Cache->cache_value('staff_report_count', $totalreports, 900); + } + $totalcheaters = $Cache->get_value('staff_cheater_count'); + if ($totalcheaters == ""){ + $totalcheaters = get_row_count("cheaters"); + $Cache->cache_value('staff_cheater_count', $totalcheaters, 900); + } + print( + "\"cheaterbox\" ".$totalcheaters + ." \"reportbox\" ".$totalreports + ); +} +print(" \"Buddylist\""); +print(" \"RSS\""); +print '
'; +//echo $lang_functions['text_the_time_is_now'].$datum['hours'].":".$datum['minutes'] . '
'; // $cacheKey = "staff_message_count_" . $CURUSER['id']; // $totalsm = $Cache->get_value($cacheKey); $totalsm = \App\Repositories\MessageRepository::getStaffMessageCountCache($CURUSER['id'], 'total'); @@ -2683,8 +2703,7 @@ else { print("".$inboxpic." ".($messages ? $messages." (".$unread.$lang_functions['text_message_new'].")" : "0")); print(" \"sentbox\" ".($outmessages ? $outmessages : "0")); - print(" \"Buddylist\""); - print(" \"RSS\""); + ?>
@@ -3544,7 +3563,7 @@ foreach ($rows as $row) } $stickyicon = apply_filter('sticky_icon', $stickyicon, $row); $sp_torrent = get_torrent_promotion_append($row['sp_state'],"",true,$row["added"], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false); - $hrImg = get_hr_img($row, $searchBoxId); + $hrImg = get_hr_img($row, $row['search_box_id']); //cover $coverSrc = $tdCover = ''; @@ -4730,7 +4749,7 @@ function get_hr_img(array $torrent, $searchBoxId) if ($mode == \App\Models\HitAndRun::MODE_GLOBAL || ($mode == \App\Models\HitAndRun::MODE_MANUAL && isset($torrent['hr']) && $torrent['hr'] == \App\Models\Torrent::HR_YES)) { $result = 'H&R'; } - do_log("mode: $mode, result: $result"); + do_log("searchBoxId: $searchBoxId, mode: $mode, result: $result"); return $result; } @@ -6073,4 +6092,17 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options ]; } + +function build_search_area($searchArea, array $options = []) +{ + $result = sprintf(''; + return $result; +} ?> diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index 082dc32f..e5faaa57 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -87,7 +87,7 @@ $lang_functions = array 'title_torrents_seeding' => "当前做种", 'title_torrents_leeching' => "当前下载", 'text_connectable' => "可连接:", - 'text_the_time_is_now' => "当前时间:", + 'text_the_time_is_now' => "时间: ", 'text_message_new' => " 新", 'title_sentbox' => "发件箱", 'title_inbox' => "收件箱", diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php index 96ff35d5..f7429a4a 100644 --- a/lang/cht/lang_functions.php +++ b/lang/cht/lang_functions.php @@ -87,7 +87,7 @@ $lang_functions = array 'title_torrents_seeding' => "當前做種", 'title_torrents_leeching' => "當前下載", 'text_connectable' => "可連接:", - 'text_the_time_is_now' => "當前時間:", + 'text_the_time_is_now' => "時間: ", 'text_message_new' => " 新", 'title_sentbox' => "發件箱", 'title_inbox' => "收件箱", diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index bc4fbe54..229d4047 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -83,11 +83,11 @@ $lang_functions = array 'text_ratio' => "Ratio:", 'text_uploaded' => "Uploaded:", 'text_downloaded' => "Downloaded:", - 'text_active_torrents' => "Active Torrents: ", + 'text_active_torrents' => "Active: ", 'title_torrents_seeding' => "Torrents Seeding", 'title_torrents_leeching' => "Torrents Leeching", 'text_connectable' => "Connectable: ", - 'text_the_time_is_now' => "The time is now: ", + 'text_the_time_is_now' => "Time: ", 'text_message_new' => " New", 'title_sentbox' => "sentbox", 'title_inbox' => "inbox", @@ -322,7 +322,7 @@ $lang_functions = array 'text_invalid' => 'Invalid', 'text_technical_info' => 'MediaInfo', 'text_technical_info_help_text' => 'MediaInfo comes from software MediaInfo,open file, click the view menu > text > right click in the box > select all > copy > past into this box.', - 'text_management_system' => 'Management system', + 'text_management_system' => 'Management', 'text_seed_points' => 'Seed points', 'spoiler_expand_collapse' => 'Click to expand/collapse', 'spoiler_default_title' => 'Collapse content', diff --git a/public/search.php b/public/search.php new file mode 100644 index 00000000..a3f7d7e0 --- /dev/null +++ b/public/search.php @@ -0,0 +1,125 @@ +join($tableCategory, "$tableTorrent.category", "=", "$tableCategory.id"); + if (get_setting('main.spsct') == 'yes' && !user_can('view_special_torrent')) { + $torrentQuery->where("$tableCategory.mode", get_setting('main.browsecat')); + } + if ($searchArea == \App\Repositories\SearchRepository::SEARCH_AREA_TITLE) { + foreach ($searchArr as $queryString) { + $q = "%{$queryString}%"; + $torrentQuery->where(function (\Illuminate\Database\Query\Builder $query) use ($q, $tableTorrent) { + return $query->where("$tableTorrent.name", 'like', $q)->orWhere("$tableTorrent.small_descr", "like", $q); + }); + } + } elseif ($searchArea == \App\Repositories\SearchRepository::SEARCH_AREA_DESC) { + foreach ($searchArr as $queryString) { + $q = "%{$queryString}%"; + $torrentQuery->where("$tableTorrent.descr", "like", $q); + } + } elseif ($searchArea == \App\Repositories\SearchRepository::SEARCH_AREA_OWNER) { + $torrentQuery->join($tableUser, "$tableTorrent.owner", "=", "$tableUser.id"); + foreach ($searchArr as $queryString) { + $q = "%{$queryString}%"; + $torrentQuery->where("$tableUser.username", "like", $q); + } + } elseif ($searchArea == \App\Repositories\SearchRepository::SEARCH_AREA_IMDB) { + foreach ($searchArr as $queryString) { + $q = "%{$queryString}%"; + $torrentQuery->where("$tableTorrent.url", "like", $q); + } + } else { + foreach ($searchArr as $queryString) { + $q = "%{$queryString}%"; + $torrentQuery->where("$tableTorrent.name", "like", $q); + } + write_log("User " . $CURUSER["username"] . "," . $CURUSER["ip"] . " is hacking search_area field in" . $_SERVER['SCRIPT_NAME'], 'mod'); + } + if ($approvalStatus !== null) { + $torrentQuery->where("$tableTorrent.approval_status", $approvalStatus); + } + $torrentQuery->where("$tableTorrent.visible", 'yes'); + + $count = $torrentQuery->count(); +} + +if ($CURUSER["torrentsperpage"]) + $torrentsperpage = (int)$CURUSER["torrentsperpage"]; +elseif ($torrentsperpage_main) + $torrentsperpage = $torrentsperpage_main; +else $torrentsperpage = 50; + +// sorting by MarkoStamcar +$column = 'id'; +$ascdesc = 'desc'; +$addparam = "?search=$search&"; +if (isset($_GET['sort']) && $_GET['sort'] && isset($_GET['type']) && $_GET['type']) { + + switch($_GET['sort']) { + case '1': $column = "name"; break; + case '2': $column = "numfiles"; break; + case '3': $column = "comments"; break; + case '4': $column = "added"; break; + case '5': $column = "size"; break; + case '6': $column = "times_completed"; break; + case '7': $column = "seeders"; break; + case '8': $column = "leechers"; break; + case '9': $column = "owner"; break; + default: $column = "id"; break; + } + + switch($_GET['type']) { + case 'asc': $ascdesc = "ASC"; $linkascdesc = "asc"; break; + case 'desc': $ascdesc = "DESC"; $linkascdesc = "desc"; break; + default: $ascdesc = "DESC"; $linkascdesc = "desc"; break; + } + + $addparam .= "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&"; + +} + +list($pagertop, $pagerbottom, $limit, $offset, $size, $page) = pager($torrentsperpage, $count, $addparam); + +stdhead(nexus_trans('search.global_search')); +print("
"); +if ($search && $count > 0) { + $fieldsStr = implode(', ', \App\Models\Torrent::getFieldsForList(true)); + $rows = $torrentQuery->selectRaw("$fieldsStr, categories.mode as search_box_id") + ->forPage($page + 1, $torrentsperpage) + ->orderBy("$tableTorrent.$column", $ascdesc) + ->get() + ->toArray(); + print($pagertop); + torrenttable(json_decode(json_encode($rows), true)); + print($pagerbottom); +} else { + stdmsg($lang_torrents['std_search_results_for'] . $search . "\"",$lang_torrents['std_try_again']); +} +print("
"); +stdfoot(); + + + diff --git a/public/torrents.php b/public/torrents.php index 4ab1e8b7..491fe460 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -913,11 +913,11 @@ if ($count) list($pagertop, $pagerbottom, $limit, $offset, $size, $page) = pager($torrentsperpage, $count, "?" . $addparam); $fieldsStr = implode(', ', \App\Models\Torrent::getFieldsForList(true)); - if ($allsec == 1 || $enablespecial != 'yes') { - $query = "SELECT $fieldsStr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." $tagFilter $where $orderby $limit"; - } else { - $query = "SELECT $fieldsStr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $tagFilter $where $orderby $limit"; - } +// if ($allsec == 1 || $enablespecial != 'yes') { +// $query = "SELECT $fieldsStr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." $tagFilter $where $orderby $limit"; +// } else { + $query = "SELECT $fieldsStr, categories.mode as search_box_id FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $tagFilter $where $orderby $limit"; +// } do_log("[TORRENT_LIST_SQL] $query", 'debug'); if (!$elasticsearchEnabled) { $res = sql_query($query); diff --git a/resources/lang/en/claim.php b/resources/lang/en/claim.php index a0f3d0e9..b2caf10b 100644 --- a/resources/lang/en/claim.php +++ b/resources/lang/en/claim.php @@ -31,4 +31,7 @@ return [ 'remove_claim_confirm' => 'Confirm to give up the claim?', 'already_claimed' => 'Claimed', 'not_claim_yet' => 'Unclaimed', + 'fields' => [ + 'torrent_id' => 'Torrent ID', + ], ]; diff --git a/resources/lang/en/search.php b/resources/lang/en/search.php new file mode 100644 index 00000000..7eb78151 --- /dev/null +++ b/resources/lang/en/search.php @@ -0,0 +1,13 @@ + 'Global Search', + 'search_keyword' => 'Keyword', + 'search_area' => 'Range', + 'search_area_options' => [ + '0' => 'Title', + '1' => 'Description', + '3' => 'Uploader', + '4' => 'IMDB URL' + ], +]; diff --git a/resources/lang/en/searchbox.php b/resources/lang/en/searchbox.php index 0fb6d6eb..c4396836 100644 --- a/resources/lang/en/searchbox.php +++ b/resources/lang/en/searchbox.php @@ -14,7 +14,7 @@ return [ \App\Models\SearchBox::EXTRA_DISPLAY_SEED_BOX_ICON_ON_TORRENT_LIST => 'Display seed box icon on torrent list', ], 'sections' => [ - 'browse' => 'Torrents section', - 'special' => 'Special section', + 'browse' => 'Torrents', + 'special' => 'Special', ], ]; diff --git a/resources/lang/zh_CN/claim.php b/resources/lang/zh_CN/claim.php index 1f510b5a..075539a7 100644 --- a/resources/lang/zh_CN/claim.php +++ b/resources/lang/zh_CN/claim.php @@ -31,4 +31,8 @@ return [ 'remove_claim_confirm' => '确认要放弃认领?', 'already_claimed' => '已认领', 'not_claim_yet' => '未认领', + + 'fields' => [ + 'torrent_id' => '种子 ID', + ], ]; diff --git a/resources/lang/zh_CN/search.php b/resources/lang/zh_CN/search.php new file mode 100644 index 00000000..edac195d --- /dev/null +++ b/resources/lang/zh_CN/search.php @@ -0,0 +1,13 @@ + '全站搜索', + 'search_keyword' => '关键字', + 'search_area' => '范围', + 'search_area_options' => [ + '0' => '标题', + '1' => '简介', + '3' => '发布者', + '4' => 'IMDB链接' + ], +]; diff --git a/resources/lang/zh_TW/claim.php b/resources/lang/zh_TW/claim.php index 473e4650..9fe68ede 100644 --- a/resources/lang/zh_TW/claim.php +++ b/resources/lang/zh_TW/claim.php @@ -30,4 +30,7 @@ return [ 'remove_claim_confirm' => '確認要放棄認領?', 'already_claimed' => '已認領', 'not_claim_yet' => '未認領', + 'fields' => [ + 'torrent_id' => '種子 ID', + ], ]; diff --git a/resources/lang/zh_TW/search.php b/resources/lang/zh_TW/search.php new file mode 100644 index 00000000..0862f011 --- /dev/null +++ b/resources/lang/zh_TW/search.php @@ -0,0 +1,13 @@ + '全站搜索', + 'search_keyword' => '關鍵字', + 'search_area' => '範圍', + 'search_area_options' => [ + '0' => '標題', + '1' => '簡介', + '3' => '發布者', + '4' => 'IMDB鏈接' + ], +];