diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php
index a91a9dc8..7d629dd5 100644
--- a/app/Console/Commands/Test.php
+++ b/app/Console/Commands/Test.php
@@ -86,9 +86,7 @@ class Test extends Command
*/
public function handle()
{
- $role = Role::query()->first();
- $r = $role->permissions()->createMany([['permission' => 'sss']]);
- dd($r);
+
}
diff --git a/app/Filament/Resources/Torrent/TagResource.php b/app/Filament/Resources/Torrent/TagResource.php
index 43f66759..bd008994 100644
--- a/app/Filament/Resources/Torrent/TagResource.php
+++ b/app/Filament/Resources/Torrent/TagResource.php
@@ -44,7 +44,7 @@ class TagResource extends Resource
Forms\Components\TextInput::make('margin')->required()->label(__('label.tag.margin')),
Forms\Components\TextInput::make('padding')->required()->label(__('label.tag.padding')),
Forms\Components\TextInput::make('border_radius')->required()->label(__('label.tag.border_radius')),
- Forms\Components\TextInput::make('priority')->integer()->label(__('label.priority')),
+ Forms\Components\TextInput::make('priority')->integer()->required()->label(__('label.priority'))->default(0),
]);
}
diff --git a/app/Filament/Resources/Torrent/TagResource/Pages/CreateTag.php b/app/Filament/Resources/Torrent/TagResource/Pages/CreateTag.php
index ff583cc6..e607498e 100644
--- a/app/Filament/Resources/Torrent/TagResource/Pages/CreateTag.php
+++ b/app/Filament/Resources/Torrent/TagResource/Pages/CreateTag.php
@@ -10,4 +10,8 @@ class CreateTag extends CreateRecord
{
protected static string $resource = TagResource::class;
+ protected function getRedirectUrl(): string
+ {
+ return $this->getResource()::getUrl('index');
+ }
}
diff --git a/app/Models/SearchBox.php b/app/Models/SearchBox.php
index 692197d9..2fab2971 100644
--- a/app/Models/SearchBox.php
+++ b/app/Models/SearchBox.php
@@ -9,9 +9,28 @@ class SearchBox extends NexusModel
protected $fillable = [
'name', 'catsperrow', 'catpadding', 'showsubcat',
'showsource', 'showmedium', 'showcodec', 'showstandard', 'showprocessing', 'showteam', 'showaudiocodec',
- 'custom_fields', 'custom_fields_display_name', 'custom_fields_display'
+ 'custom_fields', 'custom_fields_display_name', 'custom_fields_display', 'extra'
];
+ protected $casts = [
+ 'extra' => 'object'
+ ];
+
+ const EXTRA_DISPLAY_COVER_ON_TORRENT_LIST = 'display_cover_on_torrent_list';
+
+ public static array $extras = [
+ self::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST => ['text' => 'Display cover on torrent list'],
+ ];
+
+ public static function listExtraText(): array
+ {
+ $result = [];
+ foreach (self::$extras as $extra => $info) {
+ $result[$extra] = nexus_trans("searchbox.extras.$extra");
+ }
+ return $result;
+ }
+
public function categories(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Category::class, 'mode');
diff --git a/app/Repositories/SeedBoxRepository.php b/app/Repositories/SeedBoxRepository.php
index ead82f04..a29a8d7f 100644
--- a/app/Repositories/SeedBoxRepository.php
+++ b/app/Repositories/SeedBoxRepository.php
@@ -130,13 +130,18 @@ class SeedBoxRepository extends BaseRepository
});
}
- public function renderIcon($ip, $uid): string
+ public function renderIcon($ipArr, $uid): string
{
- $result = '';
- if ((isIPV4($ip) || isIPV6($ip)) && get_setting('seed_box.enabled') == 'yes' && isIPSeedBox($ip, $uid)) {
- $result = '
';
+ static $enableSeedBox;
+ if ($enableSeedBox === null) {
+ $enableSeedBox = get_setting('seed_box.enabled') == 'yes';
}
- return $result;
+ foreach (Arr::wrap($ipArr) as $ip) {
+ if ((isIPV4($ip) || isIPV6($ip)) && $enableSeedBox && isIPSeedBox($ip, $uid)) {
+ return '
';
+ }
+ }
+ return '';
}
private function clearCache()
diff --git a/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php b/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php
new file mode 100644
index 00000000..7ea19c5d
--- /dev/null
+++ b/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php
@@ -0,0 +1,32 @@
+text('extra')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('searchbox', function (Blueprint $table) {
+ $table->dropColumn('extra');
+ });
+ }
+};
diff --git a/database/seeders/SearchboxTableSeeder.php b/database/seeders/SearchboxTableSeeder.php
index 7dc83e23..7ebeff19 100644
--- a/database/seeders/SearchboxTableSeeder.php
+++ b/database/seeders/SearchboxTableSeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Models\SearchBox;
use Illuminate\Database\Seeder;
class SearchboxTableSeeder extends Seeder
@@ -14,12 +15,12 @@ class SearchboxTableSeeder extends Seeder
*/
public function run()
{
-
+
\DB::table('searchbox')->delete();
-
+
\DB::table('searchbox')->insert(array (
- 0 =>
+ 0 =>
array (
'id' => 4,
'name' => 'chd',
@@ -36,9 +37,12 @@ class SearchboxTableSeeder extends Seeder
'custom_fields' => '',
'custom_fields_display_name' => '',
'custom_fields_display' => '',
+ 'extra' => json_encode([
+ SearchBox::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST => 1,
+ ])
),
));
-
-
+
+
}
-}
\ No newline at end of file
+}
diff --git a/include/functions.php b/include/functions.php
index 5f64dc26..76759136 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -3291,7 +3291,7 @@ function get_torrent_bookmark_state($userid, $torrentid, $text = false)
return $act;
}
-function torrenttable($rows, $variant = "torrent") {
+function torrenttable($rows, $variant = "torrent", $searchBoxId = 0) {
global $Cache;
global $lang_functions;
global $CURUSER, $waitsystem;
@@ -3302,7 +3302,13 @@ function torrenttable($rows, $variant = "torrent") {
$torrent = new Nexus\Torrent\Torrent();
$torrentRep = new \App\Repositories\TorrentRepository();
$imdb = new \Nexus\Imdb\Imdb();
- $torrentIdArr = array_column($rows, 'id');
+ $torrentIdArr = $ownerIdArr = [];
+ foreach($rows as $row) {
+ $torrentIdArr[] = $row['id'];
+ $ownerIdArr[] = $row['owner'];
+ }
+ unset($row);
+
$torrentSeedingLeechingStatus = $torrent->listLeechingSeedingStatus($CURUSER['id'], $torrentIdArr);
$tagRep = new \App\Repositories\TagRepository();
$tagCollection = $tagRep->createBasicQuery()->get();
@@ -3310,6 +3316,25 @@ function torrenttable($rows, $variant = "torrent") {
$torrentTagCollection = \App\Models\TorrentTag::query()->whereIn('torrent_id', $torrentIdArr)->orderByRaw("field(tag_id,$tagIdStr)")->get();
$tagKeyById = $tagCollection->keyBy('id');
$torrentTagResult = $torrentTagCollection->groupBy('torrent_id');
+ $showCover = false;
+ if ($searchBoxId) {
+ $searchBoxExtra = get_searchbox_value($searchBoxId, "extra");
+ if (!empty($searchBoxExtra[\App\Models\SearchBox::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST])) {
+ $showCover = true;
+ }
+ }
+ //seedBoxIcon
+ $showSeedBoxIcon = get_setting('seed_box.enabled') == 'yes';
+ if ($showSeedBoxIcon) {
+ $seedBoxRep = new \App\Repositories\SeedBoxRepository();
+ $ownerPeerInfo = \App\Models\Peer::query()
+ ->whereIn('torrent', $torrentIdArr)
+ ->whereIn('userid', array_unique($ownerIdArr))
+ ->where('seeder', 'yes')
+ ->get(['torrent', 'ipv4', 'ipv6'])
+ ->keyBy('torrent');
+ }
+
$last_browse = $CURUSER['last_browse'];
// if ($variant == "torrent"){
@@ -3489,20 +3514,23 @@ foreach ($rows as $row)
$hrImg = get_hr_img($row);
//cover
- $coverSrc = '';
- if ($imdb_id = parse_imdb_id($row["url"])) {
- try {
- if ($imdb->getCacheStatus($imdb_id) == 1) {
- $coverSrc = $imdb->getMovie($imdb_id)->photo(false);
+ $coverSrc = $tdCover = '';
+ if ($showCover) {
+ if ($imdb_id = parse_imdb_id($row["url"])) {
+ try {
+ if ($imdb->getCacheStatus($imdb_id) == 1) {
+ $coverSrc = $imdb->getMovie($imdb_id)->photo(false);
+ }
+ } catch (\Exception $exception) {
+ do_log("torrent: {$row['id']} get cover from imdb error: ".$exception->getMessage() . "\n[stacktrace]\n" . $exception->getTraceAsString(), 'error');
}
- } catch (\Exception $exception) {
- do_log("torrent: {$row['id']} get cover from imdb error: ".$exception->getMessage() . "\n[stacktrace]\n" . $exception->getTraceAsString(), 'error');
}
+ if (empty($coverSrc) && !empty($row['cover'])) {
+ $coverSrc = $row['cover'];
+ }
+ $tdCover = sprintf('
| ".$stickyicon."".htmlspecialchars($dispname)."");
$picked_torrent = "";
if ($CURUSER['appendpicked'] != 'no'){
@@ -3519,7 +3547,13 @@ foreach ($rows as $row)
$banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : "");
$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
$approvalStatusIcon = $torrentRep->renderApprovalStatus($row['approval_status']);
- $titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $approvalStatusIcon;
+ if ($showSeedBoxIcon && $ownerPeerInfo->has($row['id'])) {
+ $ownerPeer = $ownerPeerInfo->get($row['id']);
+ $seedBoxIcon = $seedBoxRep->renderIcon([$ownerPeer->ipv4, $ownerPeer->ipv6], $row['owner']);
+ } else {
+ $seedBoxIcon = '';
+ }
+ $titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $seedBoxIcon . $approvalStatusIcon;
$titleSuffix = apply_filter('torrent_title_suffix', $titleSuffix, $row);
print($titleSuffix);
//$tags = torrentTags($row['tags'], 'span');
@@ -4707,6 +4741,9 @@ function get_searchbox_value($mode = 1, $item = 'showsubcat'){
$rows = array();
$res = sql_query("SELECT * FROM searchbox ORDER BY id ASC");
while ($row = mysql_fetch_array($res)) {
+ if (isset($row['extra'])) {
+ $row['extra'] = json_decode($row['extra'], true);
+ }
$rows[$row['id']] = $row;
}
$Cache->cache_value('searchbox_content', $rows, 100500);
diff --git a/lang/chs/lang_catmanage.php b/lang/chs/lang_catmanage.php
index b7667522..71464b67 100644
--- a/lang/chs/lang_catmanage.php
+++ b/lang/chs/lang_catmanage.php
@@ -80,6 +80,7 @@ $lang_catmanage = array
'row_custom_field_display_name' => '自定义字段展示名称',
'row_custom_field_display' => '自定义字段展示',
'row_custom_field_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>',
+ 'row_searchbox_extras' => '其他',
);
?>
diff --git a/lang/cht/lang_catmanage.php b/lang/cht/lang_catmanage.php
index 9c88ada3..141aaf9c 100644
--- a/lang/cht/lang_catmanage.php
+++ b/lang/cht/lang_catmanage.php
@@ -80,6 +80,7 @@ $lang_catmanage = array
'row_custom_field_display_name' => '自定義字段展示名稱',
'row_custom_field_display' => '自定義字段展示',
'row_custom_field_display_help' => '使用特殊的標簽代表字段的名稱和值,如某字段其 Name 為 artist,則它的名稱為:<%artist.label%>,它的值為:<%artist.value%>',
+ 'row_searchbox_extras' => '其他',
);
?>
diff --git a/lang/en/lang_catmanage.php b/lang/en/lang_catmanage.php
index 598edd68..a834ac63 100644
--- a/lang/en/lang_catmanage.php
+++ b/lang/en/lang_catmanage.php
@@ -80,6 +80,7 @@ $lang_catmanage = array
'row_custom_field_display_name' => 'Custom field display name',
'row_custom_field_display' => 'Custom field display',
'row_custom_field_display_help' => "Use 'specific label' to represent custom field's label and value,such as one custom field's name is 'artist', then it's label:<%artist.label%>,it's value:<%artist.value%>", + 'row_searchbox_extras' => 'Extras', ); ?> diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 497faaad..0f454cc7 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -9,6 +9,7 @@ use App\Models\Exam; use App\Models\ExamUser; use App\Models\HitAndRun; use App\Models\Icon; +use App\Models\SearchBox; use App\Models\Setting; use App\Models\Tag; use App\Models\Torrent; @@ -243,8 +244,14 @@ class Update extends Install NexusDB::cache_del('nexus_is_ip_seed_box'); /** - * @since 1.7.23 + * @since 1.7.24 */ + if (!NexusDB::hasColumn('searchbox', 'extra')) { + $this->runMigrate('database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php'); + SearchBox::query()->update(['extra' => [ + SearchBox::EXTRA_DISPLAY_COVER_ON_TORRENT_LIST => 1, + ]]); + } } diff --git a/public/catmanage.php b/public/catmanage.php index c6bdd483..d0db9a55 100644 --- a/public/catmanage.php +++ b/public/catmanage.php @@ -217,6 +217,9 @@ function print_category_editor($type, $row='') $showaudiocodec = $row['showaudiocodec']; $catsperrow = $row['catsperrow']; $catpadding = $row['catpadding']; + if (!empty($row['extra'])) { + $row['extra'] = json_decode($row['extra'], true); + } } else { @@ -233,6 +236,17 @@ function print_category_editor($type, $row='') } tr($lang_catmanage['row_searchbox_name']."*", " " . $lang_catmanage['text_searchbox_name_note'], 1); tr($lang_catmanage['row_show_sub_category'], " " . $lang_catmanage['text_sources'] . " " . $lang_catmanage['text_media'] . " " . $lang_catmanage['text_codecs'] . " " . $lang_catmanage['text_standards'] . " " . $lang_catmanage['text_processings'] . " " . $lang_catmanage['text_teams'] . " " . $lang_catmanage['text_audio_codecs']." ".$lang_catmanage['text_show_sub_category_note'], 1); + + //extra + $extraCheckbox = ""; + foreach (\App\Models\SearchBox::listExtraText() as $name => $text) { + $extraCheckbox .= sprintf( + '', + $name, !empty($row['extra'][$name]) ? ' checked' : '', $text + ); + } + tr($lang_catmanage['row_searchbox_extras'], $extraCheckbox, 1); + tr($lang_catmanage['row_items_per_row']."*", " " . $lang_catmanage['text_items_per_row_note'], 1); tr($lang_catmanage['row_padding_between_items']."*", " " . $lang_catmanage['text_padding_between_items_note'], 1); $field = new \Nexus\Field\Field(); @@ -715,6 +729,8 @@ elseif($action == 'submit') $updateset[] = "custom_fields=" . sqlesc(implode(',', $_POST['custom_fields'] ?? [])); $updateset[] = "custom_fields_display_name=" . sqlesc($_POST['custom_fields_display_name'] ?? ''); $updateset[] = "custom_fields_display=" . sqlesc($_POST['custom_fields_display'] ?? ''); + $updateset[] = "extra=" . sqlesc(json_encode($_POST['extra'] ?? [])); + if ($showsource || $showmedium || $showcodec || $showstandard || $showprocessing || $showteam || $showaudiocodec) $updateset[] = "showsubcat=1"; else diff --git a/public/details.php b/public/details.php index 0c09e93f..60151f82 100644 --- a/public/details.php +++ b/public/details.php @@ -221,7 +221,13 @@ JS; tr($lang_details['torrent_dl_url'],sprintf('%s',$lang_details['torrent_dl_url_notice'], getSchemeAndHttpHost(), $CURUSER['id'], $torrentRep->encryptDownHash($row['id'], $CURUSER), $lang_details['torrent_dl_url_text']),1); // ---------------- start subtitle block -------------------// - $r = sql_query("SELECT subs.*, language.flagpic, language.lang_name FROM subs LEFT JOIN language ON subs.lang_id=language.id WHERE torrent_id = " . sqlesc($row["id"]). " ORDER BY subs.lang_id ASC") or sqlerr(__FILE__, __LINE__); + $subTorrentIdArr = [$row['id']]; + $otherCopiesIdArr = []; + if ($imdb_id) { + $otherCopiesIdArr = \App\Models\Torrent::query()->where('url', $imdb_id)->where('id', '!=', $row['id'])->pluck('id')->toArray(); + $subTorrentIdArr = array_merge($subTorrentIdArr, $otherCopiesIdArr); + } + $r = sql_query("SELECT subs.*, language.flagpic, language.lang_name FROM subs LEFT JOIN language ON subs.lang_id=language.id WHERE torrent_id in(" . implode(',', $subTorrentIdArr). ") ORDER BY subs.lang_id ASC") or sqlerr(__FILE__, __LINE__); print(" | |
| ".$lang_details['row_subtitles']." | "); print("");
print(" |