nexus_trans('claim.th_claim_at'), 'last_settle_at' => nexus_trans('claim.th_last_settle'), 'seed_time' => nexus_trans('claim.th_seed_time_this_month'), 'uploaded' => nexus_trans('claim.th_uploaded_this_month'), ]; $orderAllowed = [ 'asc' => nexus_trans('nexus.asc'), 'desc' => nexus_trans('nexus.desc'), ]; $torrentId = $uid = 0; $actionTh = $actionTd = ''; $sort = $_GET['sort'] ?? 'created_at'; if (!isset($sortAllowed[$sort])) { $sort = "created_at"; } $order = $_GET['order'] ?? 'asc'; if (!isset($orderAllowed[$order])) { $order = "asc"; } if (!empty($_GET['torrent_id'])) { $torrentId = $_GET['torrent_id']; int_check($torrentId,true); $torrent = \App\Models\Torrent::query()->where('id', $torrentId)->first(\App\Models\Torrent::$commentFields); if (!$torrent) { stderr("Error", "Invalid torrent_id: $torrentId"); } stdhead(nexus_trans('claim.title_for_torrent')); $query = \App\Models\Claim::query()->where('torrent_id', $torrentId); $pagerParam = "?torrent_id=$torrentId&sort=$sort&order=$order"; print("

".nexus_trans('claim.title_for_torrent') . " ".htmlspecialchars($torrent['name'])."

"); } elseif (!empty($_GET['uid'])) { $uid = $_GET['uid']; int_check($uid,true); $user = \App\Models\User::query()->where('id', $uid)->first(\App\Models\User::$commonFields); if (!$user) { stderr("Error", "Invalid uid: $uid"); } stdhead(nexus_trans('claim.title_for_user')); $query = \App\Models\Claim::query()->where('uid', $uid); $pagerParam = "?uid=$uid&sort=$sort&order=$order"; print("

".nexus_trans('claim.title_for_user') . " ".htmlspecialchars($user->username)."

"); if ($uid == $CURUSER['id']) { $actionTh = sprintf("%s", nexus_trans("claim.th_action")); } } else { stderr("Invalid parameters", "Require torrent_id or uid"); } begin_main_frame(); $textSelectOnePlease = nexus_trans('nexus.select_one_please'); $sortOptions = $orderOptions = ''; foreach ($sortAllowed as $name => $text) { $sortOptions .= sprintf( '', $name, isset($_GET['sort']) && $_GET['sort'] == $name ? ' selected' : '', $text ); } foreach ($orderAllowed as $name => $text) { $orderOptions .= sprintf( '', $name, isset($_GET['order']) && $_GET['order'] == $name ? ' selected' : '', $text ); } $resetText = nexus_trans('label.reset'); $submitText = nexus_trans('label.submit'); $sortText = nexus_trans('nexus.sort'); $orderText = nexus_trans('nexus.order'); $filterForm = <<
{$sortText}:    {$orderText}:   
FORM; $resetJs = <<count(); list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $total, "$pagerParam&"); $query = (clone $query)->with(['user', 'torrent', 'snatch'])->offset($offset)->limit($pageSize); if ($sort == 'seed_time') { $query->join("snatched", "claims.snatched_id", "=", "snatched.id") ->orderByRaw("(snatched.seedtime - claims.seed_time_begin) $order"); } elseif ($sort == 'uploaded') { $query->join("snatched", "claims.snatched_id", "=", "snatched.id") ->orderByRaw("(snatched.uploaded - claims.uploaded_begin) $order"); } else { $query->orderBy($sort, $order); } $list = $query->selectRaw("claims.*")->get(); print($filterForm); print(""); print(" ".$actionTh." "); $now = \Carbon\Carbon::now(); $seedTimeRequiredHours = \App\Models\Claim::getConfigStandardSeedTimeHours(); $uploadedRequiredTimes = \App\Models\Claim::getConfigStandardUploadedTimes(); $claimRep = new \App\Repositories\ClaimRepository(); $torrentTool = new \Nexus\Torrent\Torrent(); $torrentIdList = $list->pluck('torrent_id')->toArray(); $leechingSeedingStatus = $torrentTool->listLeechingSeedingStatus($CURUSER['id'], $torrentIdList); foreach ($list as $row) { if ( bcsub($row->snatch->seedtime, $row->seed_time_begin) >= $seedTimeRequiredHours * 3600 || bcsub($row->snatch->uploaded, $row->uploaded_begin) >= $uploadedRequiredTimes * $row->torrent->size ) { $reached = 'Yes'; } else { $reached = 'No'; } $actionTd = ''; if ($actionTh) { $actionTd = sprintf('', $claimRep->buildActionButtons($row->torrent_id, $row, 1)); } $torrentName = $row->torrent->name; $torrentId = $row->torrent_id; if (isset($leechingSeedingStatus[$torrentId])) { $torrentName .= $torrentTool->renderProgressBar($leechingSeedingStatus[$torrentId]['active_status'], $leechingSeedingStatus[$torrentId]['progress']); } print(" ".$actionTd." "); } print("
".nexus_trans('claim.th_id')." ".nexus_trans('claim.th_username')." ".nexus_trans('claim.th_torrent_name')." ".nexus_trans('claim.th_torrent_size')." ".nexus_trans('claim.th_torrent_ttl')." ".nexus_trans('claim.th_claim_at')." ".nexus_trans('claim.th_last_settle')." ".nexus_trans('claim.th_seed_time_this_month')." ".nexus_trans('claim.th_uploaded_this_month')." ".nexus_trans('claim.th_reached_or_not')."
%s
" . $row->id . " " . $row->user->username . " " . $torrentName . " " . mksize($row->torrent->size) . " " . mkprettytime($row->torrent->added->diffInSeconds($now, true)) . " " . format_datetime($row->created_at) . " " . format_datetime($row->last_settle_at) . " " . mkprettytime($row->snatch->seedtime - $row->seed_time_begin) . " " . mksize($row->snatch->uploaded - $row->uploaded_begin) . " " . $reached . "
"); print($pagerbottom); end_main_frame(); stdfoot();