mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
fix details page other version hr img
This commit is contained in:
@@ -141,7 +141,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
|||||||
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
|
Forms\Components\TextInput::make('hr.ignore_when_ratio_reach')->helperText(__('label.setting.hr.ignore_when_ratio_reach_help'))->label(__('label.setting.hr.ignore_when_ratio_reach'))->integer(),
|
||||||
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
|
Forms\Components\TextInput::make('hr.ban_user_when_counts_reach')->helperText(__('label.setting.hr.ban_user_when_counts_reach_help'))->label(__('label.setting.hr.ban_user_when_counts_reach'))->integer(),
|
||||||
];
|
];
|
||||||
return apply_filter("nexus_hit_and_run_setting_schema", $default);
|
return apply_filter("hit_and_run_setting_schema", $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,12 @@ class HitAndRun extends NexusModel
|
|||||||
return apply_filter("nexus_setting_get", $default, $name, ['mode' => $searchBoxId]);
|
return apply_filter("nexus_setting_get", $default, $name, ['mode' => $searchBoxId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function diffInSection(): bool
|
||||||
|
{
|
||||||
|
$enableSpecialSection = Setting::get('main.spsct') == 'yes';
|
||||||
|
return $enableSpecialSection && apply_filter("hit_and_run_diff_in_section", false);
|
||||||
|
}
|
||||||
|
|
||||||
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Torrent::class, 'torrent_id');
|
return $this->belongsTo(Torrent::class, 'torrent_id');
|
||||||
|
|||||||
@@ -92,19 +92,25 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
|
|
||||||
public function cronjobUpdateStatus($uid = null, $torrentId = null, $ignoreTime = false)
|
public function cronjobUpdateStatus($uid = null, $torrentId = null, $ignoreTime = false)
|
||||||
{
|
{
|
||||||
$enableSpecialSection = Setting::get('main.spsct') == 'yes';
|
$diffInSection = HitAndRun::diffInSection();
|
||||||
$browseMode = Setting::get('main.browsecat');
|
$browseMode = Setting::get('main.browsecat');
|
||||||
|
$setting = HitAndRun::getConfig('*', $browseMode);
|
||||||
|
$setting['diff_in_section'] = $diffInSection;
|
||||||
|
$setting['search_box_id'] = $browseMode;
|
||||||
|
$this->doCronjobUpdateStatus($setting, $uid, $torrentId, $ignoreTime);
|
||||||
|
|
||||||
$specialMode = Setting::get('main.specialcat');
|
$specialMode = Setting::get('main.specialcat');
|
||||||
$this->doCronjobUpdateStatus($browseMode, $uid, $torrentId, $ignoreTime);
|
if ($diffInSection && $browseMode != $specialMode) {
|
||||||
if ($enableSpecialSection && $browseMode != $specialMode) {
|
$setting = HitAndRun::getConfig('*', $specialMode);
|
||||||
$this->doCronjobUpdateStatus($specialMode, $uid, $torrentId, $ignoreTime, $specialMode);
|
$setting['diff_in_section'] = $diffInSection;
|
||||||
|
$setting['search_box_id'] = $specialMode;
|
||||||
|
$this->doCronjobUpdateStatus($setting, $uid, $torrentId, $ignoreTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function doCronjobUpdateStatus($searchBoxId, $uid = null, $torrentId = null, $ignoreTime = false)
|
private function doCronjobUpdateStatus(array $setting, $uid = null, $torrentId = null, $ignoreTime = false)
|
||||||
{
|
{
|
||||||
do_log("searchBoxId: $searchBoxId, uid: $uid, torrentId: $torrentId, ignoreTime: " . var_export($ignoreTime, true));
|
do_log("uid: $uid, torrentId: $torrentId, ignoreTime: " . var_export($ignoreTime, true));
|
||||||
$setting = HitAndRun::getConfig('*', $searchBoxId);
|
|
||||||
$size = 1000;
|
$size = 1000;
|
||||||
$page = 1;
|
$page = 1;
|
||||||
if (empty($setting['mode'])) {
|
if (empty($setting['mode'])) {
|
||||||
@@ -136,9 +142,12 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
if (!$ignoreTime) {
|
if (!$ignoreTime) {
|
||||||
$query->where('created_at', '<', Carbon::now()->subHours($setting['inspect_time']));
|
$query->where('created_at', '<', Carbon::now()->subHours($setting['inspect_time']));
|
||||||
}
|
}
|
||||||
$query->whereHas('torrent.basic_category', function (Builder $query) use ($searchBoxId) {
|
if ($setting['diff_in_section']) {
|
||||||
return $query->where('mode', $searchBoxId);
|
$query->whereHas('torrent.basic_category', function (Builder $query) use ($setting) {
|
||||||
});
|
return $query->where('mode', $setting['search_box_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$successCounts = 0;
|
$successCounts = 0;
|
||||||
$disabledUsers = [];
|
$disabledUsers = [];
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -181,7 +190,7 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
$requireSeedTime = bcmul($setting['seed_time_minimum'], 3600);
|
$requireSeedTime = bcmul($setting['seed_time_minimum'], 3600);
|
||||||
do_log("$currentLog, targetSeedTime: $targetSeedTime, requireSeedTime: $requireSeedTime");
|
do_log("$currentLog, targetSeedTime: $targetSeedTime, requireSeedTime: $requireSeedTime");
|
||||||
if ($targetSeedTime >= $requireSeedTime) {
|
if ($targetSeedTime >= $requireSeedTime) {
|
||||||
$result = $this->reachedBySeedTime($row, $searchBoxId);
|
$result = $this->reachedBySeedTime($row, $setting);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$successCounts++;
|
$successCounts++;
|
||||||
}
|
}
|
||||||
@@ -193,7 +202,7 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
$requireShareRatio = $setting['ignore_when_ratio_reach'];
|
$requireShareRatio = $setting['ignore_when_ratio_reach'];
|
||||||
do_log("$currentLog, targetShareRatio: $targetShareRatio, requireShareRatio: $requireShareRatio");
|
do_log("$currentLog, targetShareRatio: $targetShareRatio, requireShareRatio: $requireShareRatio");
|
||||||
if ($targetShareRatio >= $requireShareRatio) {
|
if ($targetShareRatio >= $requireShareRatio) {
|
||||||
$result = $this->reachedByShareRatio($row, $searchBoxId);
|
$result = $this->reachedByShareRatio($row, $setting);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$successCounts++;
|
$successCounts++;
|
||||||
}
|
}
|
||||||
@@ -202,7 +211,7 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
|
|
||||||
//unreached
|
//unreached
|
||||||
if ($row->created_at->addHours($setting['inspect_time'])->lte(Carbon::now())) {
|
if ($row->created_at->addHours($setting['inspect_time'])->lte(Carbon::now())) {
|
||||||
$result = $this->unreached($row, $searchBoxId, !isset($disabledUsers[$row->uid]));
|
$result = $this->unreached($row, $setting, !isset($disabledUsers[$row->uid]));
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$successCounts++;
|
$successCounts++;
|
||||||
$disabledUsers[$row->uid] = true;
|
$disabledUsers[$row->uid] = true;
|
||||||
@@ -211,7 +220,7 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
$page++;
|
$page++;
|
||||||
}
|
}
|
||||||
do_log("searchBoxId: $searchBoxId, [CRONJOB_UPDATE_HR_DONE]");
|
do_log("[CRONJOB_UPDATE_HR_DONE]");
|
||||||
return $successCounts;
|
return $successCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,15 +238,15 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reachedByShareRatio(HitAndRun $hitAndRun, $searchBoxId): bool
|
private function reachedByShareRatio(HitAndRun $hitAndRun, array $setting): bool
|
||||||
{
|
{
|
||||||
do_log(__METHOD__);
|
do_log(__METHOD__);
|
||||||
$comment = nexus_trans('hr.reached_by_share_ratio_comment', [
|
$comment = nexus_trans('hr.reached_by_share_ratio_comment', [
|
||||||
'now' => Carbon::now()->toDateTimeString(),
|
'now' => Carbon::now()->toDateTimeString(),
|
||||||
'seed_time_minimum' => HitAndRun::getConfig('seed_time_minimum', $searchBoxId),
|
'seed_time_minimum' => $setting['seed_time_minimum'],
|
||||||
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
||||||
'share_ratio' => get_hr_ratio($hitAndRun->snatch->uploaded, $hitAndRun->snatch->downloaded),
|
'share_ratio' => get_hr_ratio($hitAndRun->snatch->uploaded, $hitAndRun->snatch->downloaded),
|
||||||
'ignore_when_ratio_reach' => HitAndRun::getConfig('ignore_when_ratio_reach', $searchBoxId),
|
'ignore_when_ratio_reach' => $setting['ignore_when_ratio_reach'],
|
||||||
], $hitAndRun->user->locale);
|
], $hitAndRun->user->locale);
|
||||||
$update = [
|
$update = [
|
||||||
'comment' => $comment
|
'comment' => $comment
|
||||||
@@ -245,13 +254,13 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
|
return $this->inspectingToReached($hitAndRun, $update, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reachedBySeedTime(HitAndRun $hitAndRun, $searchBoxId): bool
|
private function reachedBySeedTime(HitAndRun $hitAndRun, array $setting): bool
|
||||||
{
|
{
|
||||||
do_log(__METHOD__);
|
do_log(__METHOD__);
|
||||||
$comment = nexus_trans('hr.reached_by_seed_time_comment', [
|
$comment = nexus_trans('hr.reached_by_seed_time_comment', [
|
||||||
'now' => Carbon::now()->toDateTimeString(),
|
'now' => Carbon::now()->toDateTimeString(),
|
||||||
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
||||||
'seed_time_minimum' => HitAndRun::getConfig('seed_time_minimum', $searchBoxId)
|
'seed_time_minimum' => $setting['seed_time_minimum'],
|
||||||
], $hitAndRun->user->locale);
|
], $hitAndRun->user->locale);
|
||||||
$update = [
|
$update = [
|
||||||
'comment' => $comment
|
'comment' => $comment
|
||||||
@@ -288,16 +297,16 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function unreached(HitAndRun $hitAndRun, $searchBoxId, $disableUser = true): bool
|
private function unreached(HitAndRun $hitAndRun, array $setting, $disableUser = true): bool
|
||||||
{
|
{
|
||||||
do_log(sprintf('hitAndRun: %s, disableUser: %s', $hitAndRun->toJson(), var_export($disableUser, true)));
|
do_log(sprintf('hitAndRun: %s, disableUser: %s', $hitAndRun->toJson(), var_export($disableUser, true)));
|
||||||
$comment = nexus_trans('hr.unreached_comment', [
|
$comment = nexus_trans('hr.unreached_comment', [
|
||||||
'now' => Carbon::now()->toDateTimeString(),
|
'now' => Carbon::now()->toDateTimeString(),
|
||||||
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
'seed_time' => bcdiv($hitAndRun->snatch->seedtime, 3600, 1),
|
||||||
'seed_time_minimum' => HitAndRun::getConfig('seed_time_minimum', $searchBoxId),
|
'seed_time_minimum' => $setting['seed_time_minimum'],
|
||||||
'share_ratio' => get_hr_ratio($hitAndRun->snatch->uploaded, $hitAndRun->snatch->downloaded),
|
'share_ratio' => get_hr_ratio($hitAndRun->snatch->uploaded, $hitAndRun->snatch->downloaded),
|
||||||
'torrent_size' => mksize($hitAndRun->torrent->size),
|
'torrent_size' => mksize($hitAndRun->torrent->size),
|
||||||
'ignore_when_ratio_reach' => HitAndRun::getConfig('ignore_when_ratio_reach', $searchBoxId)
|
'ignore_when_ratio_reach' => $setting['ignore_when_ratio_reach']
|
||||||
], $hitAndRun->user->locale);
|
], $hitAndRun->user->locale);
|
||||||
$update = [
|
$update = [
|
||||||
'status' => HitAndRun::STATUS_UNREACHED,
|
'status' => HitAndRun::STATUS_UNREACHED,
|
||||||
@@ -335,13 +344,14 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
//disable user
|
//disable user
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $hitAndRun->user;
|
$user = $hitAndRun->user;
|
||||||
$counts = $user->hitAndRuns()
|
$countsQuery = $user->hitAndRuns()->where('status', HitAndRun::STATUS_UNREACHED);
|
||||||
->where('status', HitAndRun::STATUS_UNREACHED)
|
if ($setting['diff_in_section']) {
|
||||||
->whereHas('torrent.basic_category', function (Builder $query) use ($searchBoxId) {
|
$countsQuery->whereHas('torrent.basic_category', function (Builder $query) use ($setting) {
|
||||||
return $query->where('mode', $searchBoxId);
|
return $query->where('mode', $setting['search_box_id']);
|
||||||
})
|
});
|
||||||
->count();
|
}
|
||||||
$disableCounts = HitAndRun::getConfig('ban_user_when_counts_reach', $searchBoxId);
|
$counts = $countsQuery->count();
|
||||||
|
$disableCounts = HitAndRun::getConfig('ban_user_when_counts_reach', $setting['search_box_id']);
|
||||||
do_log("user: {$user->id}, H&R counts: $counts, disableCounts: $disableCounts", 'notice');
|
do_log("user: {$user->id}, H&R counts: $counts, disableCounts: $disableCounts", 'notice');
|
||||||
if ($counts >= $disableCounts) {
|
if ($counts >= $disableCounts) {
|
||||||
do_log("[DISABLE_USER_DUE_TO_H&R_UNREACHED]", 'notice');
|
do_log("[DISABLE_USER_DUE_TO_H&R_UNREACHED]", 'notice');
|
||||||
@@ -369,8 +379,8 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
|
|
||||||
public function getStatusStats($uid, $formatted = true)
|
public function getStatusStats($uid, $formatted = true)
|
||||||
{
|
{
|
||||||
$enableSpecialSection = Setting::get('main.spsct') == 'yes';
|
$diffInSection = HitAndRun::diffInSection();
|
||||||
if ($enableSpecialSection) {
|
if ($diffInSection) {
|
||||||
$sql = "select hit_and_runs.status, categories.mode, count(*) as counts from hit_and_runs left join torrents on torrents.id = hit_and_runs.torrent_id left join categories on categories.id = torrents.category where hit_and_runs.uid = $uid group by hit_and_runs.status, categories.mode";
|
$sql = "select hit_and_runs.status, categories.mode, count(*) as counts from hit_and_runs left join torrents on torrents.id = hit_and_runs.torrent_id left join categories on categories.id = torrents.category where hit_and_runs.uid = $uid group by hit_and_runs.status, categories.mode";
|
||||||
} else {
|
} else {
|
||||||
$sql = "select hit_and_runs.status, count(*) as counts from hit_and_runs where uid = $uid group by status";
|
$sql = "select hit_and_runs.status, count(*) as counts from hit_and_runs where uid = $uid group by status";
|
||||||
@@ -379,7 +389,7 @@ class HitAndRunRepository extends BaseRepository
|
|||||||
if (!$formatted) {
|
if (!$formatted) {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
if ($enableSpecialSection) {
|
if ($diffInSection) {
|
||||||
$grouped = [];
|
$grouped = [];
|
||||||
foreach ($results as $item) {
|
foreach ($results as $item) {
|
||||||
$grouped[$item['mode']][$item['status']] = $item['counts'];
|
$grouped[$item['mode']][$item['status']] = $item['counts'];
|
||||||
|
|||||||
+2
-2
@@ -386,7 +386,7 @@ JS;
|
|||||||
{
|
{
|
||||||
// $where_area = " url = " . sqlesc((int)$imdb_id) ." AND torrents.id != ".sqlesc($id);
|
// $where_area = " url = " . sqlesc((int)$imdb_id) ." AND torrents.id != ".sqlesc($id);
|
||||||
$where_area = sprintf('torrents.id in (%s)', implode(',', $otherCopiesIdArr));
|
$where_area = sprintf('torrents.id in (%s)', implode(',', $otherCopiesIdArr));
|
||||||
$copies_res = sql_query("SELECT torrents.id, torrents.name, torrents.sp_state, torrents.size, torrents.added, torrents.seeders, torrents.leechers, torrents.hr,categories.id AS catid, categories.name AS catname, categories.image AS catimage, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name FROM torrents LEFT JOIN categories ON torrents.category=categories.id LEFT JOIN sources ON torrents.source = sources.id LEFT JOIN media ON torrents.medium = media.id LEFT JOIN codecs ON torrents.codec = codecs.id LEFT JOIN standards ON torrents.standard = standards.id LEFT JOIN processings ON torrents.processing = processings.id WHERE " . $where_area . " ORDER BY torrents.id DESC") or sqlerr(__FILE__, __LINE__);
|
$copies_res = sql_query("SELECT torrents.id, torrents.name, torrents.sp_state, torrents.size, torrents.added, torrents.seeders, torrents.leechers, torrents.hr,categories.id AS catid, categories.name AS catname, categories.image AS catimage, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, categories.mode as search_box_id FROM torrents LEFT JOIN categories ON torrents.category=categories.id LEFT JOIN sources ON torrents.source = sources.id LEFT JOIN media ON torrents.medium = media.id LEFT JOIN codecs ON torrents.codec = codecs.id LEFT JOIN standards ON torrents.standard = standards.id LEFT JOIN processings ON torrents.processing = processings.id WHERE " . $where_area . " ORDER BY torrents.id DESC") or sqlerr(__FILE__, __LINE__);
|
||||||
|
|
||||||
$copies_count = mysql_num_rows($copies_res);
|
$copies_count = mysql_num_rows($copies_res);
|
||||||
if($copies_count > 0)
|
if($copies_count > 0)
|
||||||
@@ -416,7 +416,7 @@ JS;
|
|||||||
|
|
||||||
$sphighlight = get_torrent_bg_color($copy_row['sp_state']);
|
$sphighlight = get_torrent_bg_color($copy_row['sp_state']);
|
||||||
$sp_info = get_torrent_promotion_append($copy_row['sp_state'], '', false, '', 0, '', $copy_row['__ignore_global_sp_state'] ?? false);
|
$sp_info = get_torrent_promotion_append($copy_row['sp_state'], '', false, '', 0, '', $copy_row['__ignore_global_sp_state'] ?? false);
|
||||||
$hrImg = get_hr_img($copy_row);
|
$hrImg = get_hr_img($copy_row, $copy_row['search_box_id']);
|
||||||
|
|
||||||
$s .= "<tr". $sphighlight."><td class=\"rowfollow nowrap\" valign=\"middle\" style='padding: 0px'>".return_category_image($copy_row["catid"], "torrents.php?allsec=1&")."</td><td class=\"rowfollow\" align=\"left\"><a href=\"" . htmlspecialchars(get_protocol_prefix() . $BASEURL . "/details.php?id=" . $copy_row["id"]. "&hit=1")."\">" . $dispname ."</a>". $sp_info. $hrImg ."</td>" .
|
$s .= "<tr". $sphighlight."><td class=\"rowfollow nowrap\" valign=\"middle\" style='padding: 0px'>".return_category_image($copy_row["catid"], "torrents.php?allsec=1&")."</td><td class=\"rowfollow\" align=\"left\"><a href=\"" . htmlspecialchars(get_protocol_prefix() . $BASEURL . "/details.php?id=" . $copy_row["id"]. "&hit=1")."\">" . $dispname ."</a>". $sp_info. $hrImg ."</td>" .
|
||||||
"<td class=\"rowfollow\" align=\"left\">" . rtrim(trim($other_source_info . $other_medium_info . $other_codec_info . $other_standard_info . $other_processing_info), ","). "</td>" .
|
"<td class=\"rowfollow\" align=\"left\">" . rtrim(trim($other_source_info . $other_medium_info . $other_codec_info . $other_standard_info . $other_processing_info), ","). "</td>" .
|
||||||
|
|||||||
Reference in New Issue
Block a user