mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
new feature: claim
This commit is contained in:
@@ -47,3 +47,17 @@ function getPtGen($params)
|
||||
}
|
||||
}
|
||||
|
||||
function addClaim($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\ClaimRepository();
|
||||
return $rep->store($CURUSER['id'], $params['torrent_id']);
|
||||
}
|
||||
|
||||
function removeClaim($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\ClaimRepository();
|
||||
return $rep->delete($params['id'], $CURUSER['id']);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
require "../include/bittorrent.php";
|
||||
dbconn();
|
||||
loggedinorreturn();
|
||||
$torrentId = $uid = 0;
|
||||
$actionTh = $actionTd = '';
|
||||
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";
|
||||
print("<h1 align=center>".nexus_trans('claim.title_for_torrent') . "<a href=details.php?id=" . htmlspecialchars($torrentId) . "><b> ".htmlspecialchars($torrent['name'])."</b></a></h1>");
|
||||
} 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";
|
||||
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");
|
||||
}
|
||||
|
||||
begin_main_frame();
|
||||
$total = (clone $query)->count();
|
||||
list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $total, $pagerParam);
|
||||
$list = (clone $query)->with(['user', 'torrent', 'snatch'])->get();
|
||||
print("<table id='claim-table' width='100%'>");
|
||||
print("<tr>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_id')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_username')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_torrent_name')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_torrent_size')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_torrent_ttl')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_claim_at')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_last_settle')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_seed_time_this_month')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_uploaded_this_month')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_reached_or_not')."</td>
|
||||
".$actionTh."
|
||||
</tr>");
|
||||
$now = \Carbon\Carbon::now();
|
||||
$seedTimeRequiredHours = \App\Models\Claim::getConfigStandardSeedTimeHours();
|
||||
$uploadedRequiredTimes = \App\Models\Claim::getConfigStandardUploadedTimes();
|
||||
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';
|
||||
}
|
||||
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>
|
||||
<td class='rowfollow' align='left'><a href='details.php?id=" . $row->torrent_id . "'>" . $row->torrent->name . "</a></td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mksize($row->torrent->size) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mkprettytime($row->torrent->added->diffInSeconds($now)) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->created_at) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->last_settle_at) . "</td>
|
||||
<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)."
|
||||
</tr>");
|
||||
}
|
||||
|
||||
print("</table>");
|
||||
print($pagerbottom);
|
||||
end_main_frame();
|
||||
stdfoot();
|
||||
|
||||
|
||||
+46
-1
@@ -132,7 +132,52 @@ if (!$row) {
|
||||
$download = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" /> <b><font class=\"small\">".$lang_details['text_download_torrent']."</font></b></a> | ";
|
||||
else $download = "";
|
||||
|
||||
tr($lang_details['row_action'], $download. ($owned == 1 ? "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" /> <b><font class=\"small\">".$lang_details['text_edit_torrent'] . "</font></b></a> | " : ""). (get_user_class() >= $askreseed_class && $row['seeders'] == 0 ? "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\"> <b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a> | " : "") . "<a title=\"".$lang_details['title_report_torrent']."\" href=\"report.php?torrent=$id\"><img class=\"dt_report\" src=\"pic/trans.gif\" alt=\"report\" /> <b><font class=\"small\">".$lang_details['text_report_torrent']."</font></b></a>", 1);
|
||||
tr(
|
||||
$lang_details['row_action'],
|
||||
$download.($owned == 1 ? "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" /> <b><font class=\"small\">".$lang_details['text_edit_torrent'] . "</font></b></a> | " : "")
|
||||
.(get_user_class() >= $askreseed_class && $row['seeders'] == 0 ? "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\"> <b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a> | " : "")
|
||||
."<a title=\"".$lang_details['title_report_torrent']."\" href=\"report.php?torrent=$id\"><img class=\"dt_report\" src=\"pic/trans.gif\" alt=\"report\" /> <b><font class=\"small\">".$lang_details['text_report_torrent']."</font></b></a>"
|
||||
, 1
|
||||
);
|
||||
|
||||
// ------------- start claim block ------------------//
|
||||
$claimTorrentTTL = \App\Models\Claim::getConfigTorrentTTL();
|
||||
if (\Carbon\Carbon::parse($row['added'])->addDays($claimTorrentTTL)->lte(\Carbon\Carbon::now())) {
|
||||
$baseClaimQuery = \App\Models\Claim::query()->where('torrent_id', $id);
|
||||
$claimCounts = (clone $baseClaimQuery)->count();
|
||||
$isClaimed = (clone $baseClaimQuery)->where('uid', $CURUSER['id'])->exists();
|
||||
if ($isClaimed) {
|
||||
$inputValue = $lang_details['claim_already'];
|
||||
$disabled = ' disabled';
|
||||
} else {
|
||||
$inputValue = $lang_details['claim_now'];
|
||||
$disabled = '';
|
||||
$claimJs = <<<JS
|
||||
jQuery('#add-claim').on('click', function () {
|
||||
if (!window.confirm('{$lang_details['claim_confirm']}')) {
|
||||
return
|
||||
}
|
||||
let params = {action: "addClaim", params: {"torrent_id": jQuery(this).attr('data-torrent_id')}}
|
||||
jQuery.post("ajax.php", params, function (response) {
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
alert(response.msg)
|
||||
} else {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($claimJs, 'footer', false);
|
||||
}
|
||||
$maxUserCounts = get_setting('torrent.claim_torrent_user_counts_up_limit', \App\Models\Claim::USER_UP_LIMIT);
|
||||
$y = sprintf('<input type="button" value="%s" id="add-claim" data-torrent_id="%s"%s>', $inputValue, $id, $disabled);
|
||||
$y .= sprintf(' ' . $lang_details['claim_info'], $claimCounts, bcsub($maxUserCounts, $claimCounts));
|
||||
$y .= sprintf(' <b><a href="claim.php?torrent_id=%s">'.$lang_details['claim_detail'].'</a></b>', $id);
|
||||
tr($lang_details['claim_label'], $y, 1);
|
||||
}
|
||||
// ------------- end claim block ------------------//
|
||||
|
||||
tr($lang_details['torrent_dl_url'],sprintf('<a title="%s" href="%s/download.php?downhash=%s|%s">%s</a>',$lang_details['torrent_dl_url_notice'], getSchemeAndHttpHost(), $CURUSER['id'], $torrentRep->encryptDownHash($row['id'], $CURUSER), $lang_details['torrent_dl_url_text']),1);
|
||||
|
||||
// ---------------- start subtitle block -------------------//
|
||||
|
||||
+13
-1
@@ -150,7 +150,8 @@ elseif($action == 'savesettings_torrent') // save account
|
||||
'expirefree','expiretwoup','expiretwoupfree','expiretwouphalfleech', 'expirenormal','hotdays','hotseeder','halfleechbecome','freebecome',
|
||||
'twoupbecome','twoupfreebecome', 'twouphalfleechbecome','normalbecome','uploaderdouble','deldeadtorrent', 'randomthirtypercentdown',
|
||||
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
|
||||
'download_support_passkey'
|
||||
'download_support_passkey', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus',
|
||||
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded'
|
||||
);
|
||||
GetVar($validConfig);
|
||||
$TORRENT = [];
|
||||
@@ -663,6 +664,17 @@ elseif ($action == 'torrentsettings')
|
||||
<li>".$lang_settings['text_normal_will_become']."<select name=normalbecome>".promotion_selection((isset($TORRENT['normalbecome']) ? $TORRENT['normalbecome'] : 1), 0)."</select>".$lang_settings['text_after']."<input type='text' style=\"width: 50px\" name=expirenormal value='".(isset($TORRENT["expirenormal"]) ? $TORRENT["expirenormal"] : 0 )."'>".$lang_settings['text_normal_timeout_default']."</li>
|
||||
|
||||
</ul>".$lang_settings['text_promotion_timeout_note_two'], 1);
|
||||
|
||||
tr($lang_settings['claim_label'], "<ul>
|
||||
<li>".sprintf($lang_settings['claim_torrent_ttl'], sprintf('<input type="number" name="claim_torrent_ttl" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_ttl'] ?? \App\Models\Claim::TORRENT_TTL))."</li>
|
||||
<li>".sprintf($lang_settings['claim_torrent_user_counts_up_limit'], sprintf('<input type="number" name="claim_torrent_user_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_torrent_user_counts_up_limit'] ?? \App\Models\Claim::USER_UP_LIMIT))."</li>
|
||||
<li>".sprintf($lang_settings['claim_user_torrent_counts_up_limit'], sprintf('<input type="number" name="claim_user_torrent_counts_up_limit" value="%s" style="width: 50px"/>', $TORRENT['claim_user_torrent_counts_up_limit'] ?? \App\Models\Claim::TORRENT_UP_LIMIT))."</li>
|
||||
<li>".sprintf($lang_settings['claim_remove_deduct_user_bonus'], sprintf('<input type="number" name="claim_remove_deduct_user_bonus" value="%s" style="width: 50px"/>', $TORRENT['claim_remove_deduct_user_bonus'] ?? \App\Models\Claim::REMOVE_DEDUCT))."</li>
|
||||
<li>".sprintf($lang_settings['claim_give_up_deduct_user_bonus'], sprintf('<input type="number" name="claim_give_up_deduct_user_bonus" value="%s" style="width: 50px"/>', $TORRENT['claim_give_up_deduct_user_bonus'] ?? \App\Models\Claim::GIVE_UP_DEDUCT))."</li>
|
||||
<li>".sprintf($lang_settings['claim_bonus_multiplier'], sprintf('<input type="number" name="claim_bonus_multiplier" value="%s" style="width: 50px"/>', $TORRENT['claim_bonus_multiplier'] ?? \App\Models\Claim::BONUS_MULTIPLIER))."</li>
|
||||
<li>".sprintf($lang_settings['claim_reach_standard'], sprintf('<input type="number" name="claim_reach_standard_seed_time" value="%s" style="width: 50px"/>', $TORRENT['claim_reach_standard_seed_time'] ?? \App\Models\Claim::STANDARD_SEED_TIME_HOURS), sprintf('<input type="number" name="claim_reach_standard_uploaded" value="%s" style="width: 50px"/>', $TORRENT['claim_reach_standard_uploaded'] ?? \App\Models\Claim::STANDARD_UPLOADED_TIMES))."</li>
|
||||
</ul>", 1);
|
||||
|
||||
tr($lang_settings['row_auto_pick_hot'], $lang_settings['text_torrents_uploaded_within']."<input type='text' style=\"width: 50px\" name=hotdays value='".(isset($TORRENT["hotdays"]) ? $TORRENT["hotdays"] : 7 )."'>".$lang_settings['text_days_with_more_than']."<input type='text' style=\"width: 50px\" name=hotseeder value='".(isset($TORRENT["hotseeder"]) ? $TORRENT["hotseeder"] : 10 )."'>".$lang_settings['text_be_picked_as_hot']."<br />".$lang_settings['text_auto_pick_hot_default'], 1);
|
||||
tr($lang_settings['row_uploader_get_double'], $lang_settings['text_torrent_uploader_gets']."<input type='text' style=\"width: 50px\" name=uploaderdouble value='".(isset($TORRENT["uploaderdouble"]) ? $TORRENT["uploaderdouble"] : 1 )."'>".$lang_settings['text_times_uploading_credit'].$lang_settings['text_uploader_get_double_default'], 1);
|
||||
tr($lang_settings['row_delete_dead_torrents'], $lang_settings['text_torrents_being_dead_for']."<input type='text' style=\"width: 50px\" name=deldeadtorrent value='".(isset($TORRENT["deldeadtorrent"]) ? $TORRENT["deldeadtorrent"] : 0 )."'>".$lang_settings['text_days_be_deleted']."<br />".$lang_settings['row_delete_dead_torrents_note'], 1);
|
||||
|
||||
Reference in New Issue
Block a user