mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
add claim to userdetails page
This commit is contained in:
+6
-20
@@ -28,25 +28,6 @@ if (!empty($_GET['torrent_id'])) {
|
||||
print("<h1 align=center>".nexus_trans('claim.title_for_user') . "<a href=userdetails.php?id=" . htmlspecialchars($uid) . "><b> ".htmlspecialchars($user->username)."</b></a></h1>");
|
||||
if ($uid == $CURUSER['id']) {
|
||||
$actionTh = sprintf("<td class='colhead' align='center'>%s</td>", nexus_trans("claim.th_action"));
|
||||
$actionTd = "<td class='rowfollow nowrap' align='center'><input class='claim-remove' type='button' value='Remove' data-id='%s'></td>";
|
||||
$confirmMsg = nexus_trans('claim.confirm_give_up');
|
||||
$removeJs = <<<JS
|
||||
jQuery("#claim-table").on("click", '.claim-remove', function () {
|
||||
if (!window.confirm('$confirmMsg')) {
|
||||
return
|
||||
}
|
||||
let params = {action: "removeClaim", params: {id: jQuery(this).attr("data-id")}}
|
||||
jQuery.post('ajax.php', params, function (response) {
|
||||
console.log(response)
|
||||
if (response.ret == 0) {
|
||||
location.reload()
|
||||
} else {
|
||||
window.alert(response.msg)
|
||||
}
|
||||
}, 'json')
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($removeJs, 'footer', false);
|
||||
}
|
||||
} else {
|
||||
stderr("Invalid parameters", "Require torrent_id or uid");
|
||||
@@ -73,6 +54,7 @@ print("<tr>
|
||||
$now = \Carbon\Carbon::now();
|
||||
$seedTimeRequiredHours = \App\Models\Claim::getConfigStandardSeedTimeHours();
|
||||
$uploadedRequiredTimes = \App\Models\Claim::getConfigStandardUploadedTimes();
|
||||
$claimRep = new \App\Repositories\ClaimRepository();
|
||||
foreach ($list as $row) {
|
||||
if (
|
||||
bcsub($row->snatch->seedtime, $row->seed_time_begin) >= $seedTimeRequiredHours * 3600
|
||||
@@ -82,6 +64,10 @@ foreach ($list as $row) {
|
||||
} else {
|
||||
$reached = 'No';
|
||||
}
|
||||
$actionTd = '';
|
||||
if ($actionTh) {
|
||||
$actionTd = sprintf('<td class="rowfollow nowrap" align="center">%s</td>', $claimRep->buildActionButtons($row->torrent_id, $row, 1));
|
||||
}
|
||||
print("<tr>
|
||||
<td class='rowfollow nowrap' align='center'>" . $row->id . "</td>
|
||||
<td class='rowfollow' align='left'><a href='userdetails.php?id=" . $row->uid . "'>" . $row->user->username . "</a></td>
|
||||
@@ -93,7 +79,7 @@ foreach ($list as $row) {
|
||||
<td class='rowfollow nowrap' align='center'>" . mkprettytime($row->snatch->seedtime - $row->seed_time_begin) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mksize($row->snatch->uploaded - $row->uploaded_begin) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . $reached . "</td>
|
||||
".sprintf($actionTd, $row->id)."
|
||||
".$actionTd."
|
||||
</tr>");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ header("Pragma: no-cache" );
|
||||
//header("Content-Type: text/xml; charset=utf-8");
|
||||
|
||||
$torrentRep = new \App\Repositories\TorrentRepository();
|
||||
|
||||
$claimRep = new \App\Repositories\ClaimRepository();
|
||||
$id = intval($_GET['userid'] ?? 0);
|
||||
$type = $_GET['type'];
|
||||
if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete')))
|
||||
@@ -21,7 +21,8 @@ if(!user_can('torrenthistory') && $id != $CURUSER["id"])
|
||||
function maketable($res, $mode = 'seeding')
|
||||
{
|
||||
global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions, $id;
|
||||
global $torrentRep;
|
||||
global $torrentRep, $claimRep;
|
||||
$showActionClaim = false;
|
||||
switch ($mode)
|
||||
{
|
||||
case 'uploaded': {
|
||||
@@ -82,6 +83,7 @@ function maketable($res, $mode = 'seeding')
|
||||
$showanonymous = false;
|
||||
$showtotalsize = false;
|
||||
$columncount = 8;
|
||||
$showActionClaim = true;
|
||||
break;
|
||||
}
|
||||
case 'incomplete': {
|
||||
@@ -115,10 +117,21 @@ function maketable($res, $mode = 'seeding')
|
||||
->get()
|
||||
->keyBy('torrentid');
|
||||
}
|
||||
if ($showActionClaim) {
|
||||
$claimData = \App\Models\Claim::query()
|
||||
->where('uid', $CURUSER['id'])
|
||||
->whereIn('torrent_id', $torrentIdArr)
|
||||
->get()
|
||||
->keyBy('torrent_id');
|
||||
}
|
||||
|
||||
$ret = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td class=\"colhead\" style=\"padding: 0px\">".$lang_getusertorrentlistajax['col_type']."</td><td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_name']."</td><td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_added']."</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;
|
||||
($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>" : "");
|
||||
if ($showActionClaim) {
|
||||
$ret .= sprintf('<td class="colhead" align="center">%s</td>', $lang_functions['std_action']);
|
||||
}
|
||||
$ret .= "</tr>";
|
||||
$total_size = 0;
|
||||
foreach ($results as $arr)
|
||||
{
|
||||
if ($mode == 'uploaded') {
|
||||
@@ -199,6 +212,11 @@ function maketable($res, $mode = 'seeding')
|
||||
$ret .= "<td class=\"rowfollow\" align=\"center\">"."". str_replace(" ", "<br />", gettime($arr['completedat'],false)). "</td>";
|
||||
if ($showanonymous)
|
||||
$ret .= "<td class=\"rowfollow\" align=\"center\">".$arr['anonymous']."</td>";
|
||||
if ($showActionClaim) {
|
||||
$claim = $claimData->get($arr['torrent']);
|
||||
$claimButton = $claimRep->buildActionButtons($arr['torrent'], $claim);
|
||||
$ret .= sprintf('<td class="rowfollow" align="center">%s</td>', $claimButton);
|
||||
}
|
||||
$ret .="</tr>\n";
|
||||
|
||||
}
|
||||
@@ -255,7 +273,7 @@ switch ($type)
|
||||
// Incomplete torrents
|
||||
case 'incomplete':
|
||||
{
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.id DESC") or sqlerr();
|
||||
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.id DESC") or sqlerr();
|
||||
$fields = "torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime,snatched.seedtime,snatched.uploaded";
|
||||
$tableWhere = "torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id";
|
||||
$order = "snatched.id DESC";
|
||||
|
||||
Vendored
+43
@@ -103,4 +103,47 @@ jQuery(document).ready(function () {
|
||||
imgList.forEach(img => io.observe(img))
|
||||
}
|
||||
|
||||
//claim
|
||||
jQuery("body").on("click", "[data-claim_id]", function () {
|
||||
let _this = jQuery(this)
|
||||
let box = _this.closest('td')
|
||||
let claimId = _this.attr("data-claim_id")
|
||||
let torrentId = _this.attr("data-torrent_id")
|
||||
let action = _this.attr("data-action")
|
||||
let reload = _this.attr("data-reload")
|
||||
let confirmText = _this.attr("data-confirm")
|
||||
let showStyle = "width: max-content;display: flex;align-items: center";
|
||||
let hideStyle = "width: max-content;display: none;align-items: center";
|
||||
let params = {}
|
||||
if (claimId > 0) {
|
||||
params.id = claimId
|
||||
} else {
|
||||
params.torrent_id = torrentId
|
||||
}
|
||||
let modalConfig = {title: "Info", btn: ['OK', 'Cancel'], btnAlign: 'c'}
|
||||
layer.confirm(confirmText, modalConfig, function (confirmIndex) {
|
||||
jQuery.post("ajax.php", {"action": action, params: params}, function (response) {
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg, modalConfig)
|
||||
return
|
||||
}
|
||||
if (reload > 0) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
if (claimId > 0) {
|
||||
//do remove, show add
|
||||
box.find("[data-action=addClaim]").attr("style", showStyle).attr("data-claim_id", 0)
|
||||
box.find("[data-action=removeClaim]").attr("style", hideStyle)
|
||||
} else {
|
||||
//do add, show remove, update claim_id
|
||||
box.find("[data-action=addClaim]").attr("style", hideStyle)
|
||||
box.find("[data-action=removeClaim]").attr("style", showStyle).attr("data-claim_id", response.data.id)
|
||||
}
|
||||
layer.close(confirmIndex)
|
||||
}, "json")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user