mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
improve approval notify + add approval_status filter
This commit is contained in:
@@ -11,9 +11,16 @@ header("Pragma: no-cache" );
|
||||
|
||||
$torrentRep = new \App\Repositories\TorrentRepository();
|
||||
|
||||
$id = intval($_GET['userid'] ?? 0);
|
||||
$type = $_GET['type'];
|
||||
if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete')))
|
||||
die;
|
||||
if(get_user_class() < $torrenthistory_class && $id != $CURUSER["id"])
|
||||
permissiondenied();
|
||||
|
||||
function maketable($res, $mode = 'seeding')
|
||||
{
|
||||
global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions;
|
||||
global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions, $id;
|
||||
global $torrentRep;
|
||||
switch ($mode)
|
||||
{
|
||||
@@ -94,11 +101,31 @@ function maketable($res, $mode = 'seeding')
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
$results = $torrentIdArr = [];
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
$results[] = $row;
|
||||
$torrentIdArr[] = $row['torrent'];
|
||||
}
|
||||
if ($mode == 'uploaded') {
|
||||
//get seedtime, uploaded from snatch
|
||||
$seedTimeAndUploaded = \App\Models\Snatch::query()
|
||||
->where('userid', $id)
|
||||
->whereIn('torrentid', $torrentIdArr)
|
||||
->select(['seedtime', 'uploaded', 'torrentid'])
|
||||
->get()
|
||||
->keyBy('torrentid');
|
||||
}
|
||||
|
||||
$ret = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"800\"><tr><td class=\"colhead\" style=\"padding: 0px\">".$lang_getusertorrentlistajax['col_type']."</td><td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_name']."</td>".
|
||||
($showsize ? "<td class=\"colhead\" align=\"center\"><img class=\"size\" src=\"pic/trans.gif\" alt=\"size\" title=\"".$lang_getusertorrentlistajax['title_size']."\" /></td>" : "").($showsenum ? "<td class=\"colhead\" align=\"center\"><img class=\"seeders\" src=\"pic/trans.gif\" alt=\"seeders\" title=\"".$lang_getusertorrentlistajax['title_seeders']."\" /></td>" : "").($showlenum ? "<td class=\"colhead\" align=\"center\"><img class=\"leechers\" src=\"pic/trans.gif\" alt=\"leechers\" title=\"".$lang_getusertorrentlistajax['title_leechers']."\" /></td>" : "").($showuploaded ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_uploaded']."</td>" : "") . ($showdownloaded ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_downloaded']."</td>" : "").($showratio ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_ratio']."</td>" : "").($showsetime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_se_time']."</td>" : "").($showletime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_le_time']."</td>" : "").($showcotime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_time_completed']."</td>" : "").($showanonymous ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_anonymous']."</td>" : "")."</tr>\n";
|
||||
$total_size = 0;
|
||||
while ($arr = mysql_fetch_assoc($res))
|
||||
foreach ($results as $arr)
|
||||
{
|
||||
if ($mode == 'uploaded') {
|
||||
$seedTimeAndUploadedData = $seedTimeAndUploaded->get($arr['torrent']);
|
||||
$arr['seedtime'] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData->seedtime : 0;
|
||||
$arr['uploaded'] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData->uploaded : 0;
|
||||
}
|
||||
$catimage = htmlspecialchars($arr["image"]);
|
||||
$catname = htmlspecialchars($arr["catname"]);
|
||||
|
||||
@@ -178,18 +205,12 @@ function maketable($res, $mode = 'seeding')
|
||||
return [$ret, $total_size];
|
||||
}
|
||||
|
||||
$id = intval($_GET['userid'] ?? 0);
|
||||
$type = $_GET['type'];
|
||||
if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete')))
|
||||
die;
|
||||
if(get_user_class() < $torrenthistory_class && $id != $CURUSER["id"])
|
||||
permissiondenied();
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'uploaded':
|
||||
{
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr FROM torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
$count = mysql_num_rows($res);
|
||||
if ($count > 0)
|
||||
{
|
||||
|
||||
@@ -808,7 +808,19 @@ if (isset($searchstr))
|
||||
|
||||
//approval status
|
||||
$approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible');
|
||||
if ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) {
|
||||
$approvalStatusIconEnabled = get_setting('torrent.approval_status_icon_enabled');
|
||||
$approvalStatus = null;
|
||||
$showApprovalStatusFilter = false;
|
||||
//when enable approval status icon, all user can use this filter, otherwise only staff member can use
|
||||
if ($approvalStatusIconEnabled == 'yes' || get_user_class() >= $staffmem_class) {
|
||||
$showApprovalStatusFilter = true;
|
||||
}
|
||||
//when user can use approval status filter, and pass `approval_status` parameter, will affect
|
||||
//OR if [not approval can not be view] and not staff member, force to view approval allowed
|
||||
if ($showApprovalStatusFilter && isset($_REQUEST['approval_status']) && is_numeric($_REQUEST['approval_status'])) {
|
||||
$approvalStatus = intval($_REQUEST['approval_status']);
|
||||
$wherea[] = "torrents.approval_status = $approvalStatus";
|
||||
} elseif ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) {
|
||||
$wherea[] = "torrents.approval_status = " . \App\Models\Torrent::APPROVAL_STATUS_ALLOW;
|
||||
}
|
||||
|
||||
@@ -1029,6 +1041,30 @@ if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showin
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showApprovalStatusFilter) {?>
|
||||
<tr>
|
||||
<td class="bottom" style="padding: 1px;padding-left: 10px">
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bottom" style="padding: 1px;padding-left: 10px">
|
||||
<font class="medium"><?php echo $lang_torrents['text_approval_status'] ?></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bottom" style="padding: 1px;padding-left: 10px">
|
||||
<select class="med" name="approval_status" style="width: 100px;">
|
||||
<option value="0"><?php echo $lang_torrents['select_all'] ?></option>
|
||||
<?php
|
||||
foreach (\App\Models\Torrent::listApprovalStatus(true) as $key => $value) {
|
||||
printf('<option value="%s"%s>%s</option>', $key, isset($approvalStatus) && $approvalStatus == $key ? ' selected' : '', $value);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user