mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
support plugin nexusphp-hit-and-run
This commit is contained in:
+5
-4
@@ -121,7 +121,7 @@ if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL");
|
||||
$userid = intval($az['id'] ?? 0);
|
||||
unset($GLOBALS['CURUSER']);
|
||||
$CURUSER = $GLOBALS["CURUSER"] = $az;
|
||||
$isDonor = $az['donor'] == 'yes' && ($az['donoruntil'] === null || $az['donoruntil'] == '0000-00-00 00:00:00' || $az['donoruntil'] > date('Y-m-d H:i:s'));
|
||||
$isDonor = is_donor($az);
|
||||
$az['__is_donor'] = $isDonor;
|
||||
$log = "user: $userid, isDonor: $isDonor, seeder: $seeder, ip: $ip, ipv4: $ipv4, ipv6: $ipv6";
|
||||
|
||||
@@ -156,7 +156,7 @@ elseif ($az['showclienterror'] == 'yes'){
|
||||
}
|
||||
|
||||
// check torrent based on info_hash
|
||||
$checkTorrentSql = "SELECT id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, approval_status FROM torrents WHERE " . hash_where("info_hash", $info_hash);
|
||||
$checkTorrentSql = "SELECT torrents.id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, approval_status, categories.mode FROM torrents left join categories on torrents.category = categories.id WHERE " . hash_where("info_hash", $info_hash);
|
||||
if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){
|
||||
$res = sql_query($checkTorrentSql);
|
||||
$torrent = mysql_fetch_array($res);
|
||||
@@ -553,9 +553,10 @@ elseif(isset($self))
|
||||
if (!empty($snatchInfo)) {
|
||||
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." $finished_snatched WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 2");
|
||||
do_action('snatched_saved', $torrent, $snatchInfo);
|
||||
if ($event == 'completed' && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor) {
|
||||
if ($event == 'completed' && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor && isset($torrent['mode'])) {
|
||||
//think about H&R
|
||||
$hrMode = get_setting('hr.mode');
|
||||
// $hrMode = get_setting('hr.mode');
|
||||
$hrMode = \App\Models\HitAndRun::getConfig('mode', $torrent['mode']);
|
||||
if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
|
||||
$sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo['id']}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s'));
|
||||
$affectedRows = sql_query($sql);
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ if (!$row) {
|
||||
$banned_torrent = ($row["banned"] == 'yes' ? " <b>(<font class=\"striking\">".$lang_functions['text_banned']."</font>)</b>" : "");
|
||||
$sp_torrent = get_torrent_promotion_append($row['sp_state'],'word', false, '', 0, '', $row['__ignore_global_sp_state'] ?? false);
|
||||
$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
|
||||
$hrImg = get_hr_img($row);
|
||||
$hrImg = get_hr_img($row, $row['search_box_id']);
|
||||
$approvalStatusIcon = $torrentRep->renderApprovalStatus($row["approval_status"]);
|
||||
$s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? " ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon;
|
||||
print("<h1 align=\"center\" id=\"top\">".$s."</h1>\n");
|
||||
|
||||
+3
-6
@@ -17,6 +17,7 @@ if (!$row) die();
|
||||
* @since v1.6
|
||||
*/
|
||||
$customField = new \Nexus\Field\Field();
|
||||
$hitAndRunRep = new \App\Repositories\HitAndRunRepository();
|
||||
|
||||
$tagIdArr = \App\Models\TorrentTag::query()->where('torrent_id', $id)->get()->pluck('tag_id')->toArray();
|
||||
|
||||
@@ -145,10 +146,11 @@ else {
|
||||
|
||||
tr($lang_edit['row_content'],$team_select,1);
|
||||
}
|
||||
|
||||
echo $customField->renderOnUploadPage($id, $browsecatmode);
|
||||
echo $hitAndRunRep->renderOnUploadPage($row['hr'], $browsecatmode);
|
||||
if ($enablespecial) {
|
||||
$customField->renderOnUploadPage($id, $specialcatmode);
|
||||
echo $hitAndRunRep->renderOnUploadPage($row['hr'], $specialcatmode);
|
||||
}
|
||||
|
||||
tr($lang_functions['text_tags'], (new \App\Repositories\TagRepository())->renderCheckbox($tagIdArr), 1);
|
||||
@@ -201,11 +203,6 @@ else {
|
||||
}
|
||||
tr($lang_edit['row_pick'], $pickcontent, 1);
|
||||
}
|
||||
if (get_setting('hr.mode') == \App\Models\HitAndRun::MODE_MANUAL && user_can('torrent_hr')) {
|
||||
$hrRadio = sprintf('<label><input type="radio" name="hr" value="0"%s />NO</label>', (string)$row['hr'] === '0' ? ' checked' : '');
|
||||
$hrRadio .= sprintf('<label><input type="radio" name="hr" value="1"%s />YES</label>', (string)$row['hr'] === '1' ? ' checked' : '');
|
||||
tr('H&R', $hrRadio, 1);
|
||||
}
|
||||
|
||||
print("<tr><td class=\"toolbox\" colspan=\"2\" align=\"center\"><input id=\"qr\" type=\"submit\" value=\"".$lang_edit['submit_edit_it']."\" /> <input type=\"reset\" value=\"".$lang_edit['submit_revert_changes']."\" /></td></tr>\n");
|
||||
print("</table>\n");
|
||||
|
||||
+4
-3
@@ -67,7 +67,8 @@ if ($rescount) {
|
||||
|
||||
$query = (clone $baseQuery)
|
||||
->with([
|
||||
'torrent' => function ($query) {$query->select(['id', 'size', 'name']);},
|
||||
'torrent' => function ($query) {$query->select(['id', 'size', 'name', 'category']);},
|
||||
'torrent.basic_category',
|
||||
'snatch',
|
||||
'user' => function ($query) {$query->select(['id', 'lang']);},
|
||||
'user.language',
|
||||
@@ -92,9 +93,9 @@ if ($rescount) {
|
||||
<td class='rowfollow nowrap' align='center'>" . mksize($row->snatch->uploaded) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . mksize($row->snatch->downloaded) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . get_hr_ratio($row->snatch->uploaded, $row->snatch->downloaded) . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(3600 * get_setting('hr.seed_time_minimum') - $row->snatch->seedtime) : '---') . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . $row->seedTimeRequired . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->snatch->completedat) . "</td>
|
||||
<td class='rowfollow nowrap' align='center' >" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(\Carbon\Carbon::now()->diffInSeconds($row->snatch->completedat->addHours(get_setting('hr.inspect_time')))) : '---') . "</td>
|
||||
<td class='rowfollow nowrap' align='center' >" . $row->inspectTimeLeft . "</td>
|
||||
<td class='rowfollow nowrap' align='left' style='padding-left: 10px'>" . nl2br(trim($row->comment)) . "</td>
|
||||
{$columnAction}
|
||||
</tr>");
|
||||
|
||||
+8
-7
@@ -53,13 +53,6 @@ if (!empty($_POST['pt_gen'])) {
|
||||
|
||||
$updateset[] = "technical_info = " . sqlesc($_POST['technical_info'] ?? '');
|
||||
$torrentOperationLog = [];
|
||||
/**
|
||||
* hr
|
||||
* @since 1.6.0-beta12
|
||||
*/
|
||||
if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']]) && user_can('torrent_hr')) {
|
||||
$updateset[] = "hr = " . sqlesc($_POST['hr']);
|
||||
}
|
||||
|
||||
|
||||
if ($enablenfo_main=='yes'){
|
||||
@@ -215,6 +208,14 @@ $descriptionArr = format_description($descr);
|
||||
$cover = get_image_from_description($descriptionArr, true, false);
|
||||
$updateset[] = "cover = " . sqlesc($cover);
|
||||
|
||||
/**
|
||||
* hr
|
||||
* @since 1.6.0-beta12
|
||||
*/
|
||||
if (isset($_POST['hr'][$newcatmode]) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr'][$newcatmode]]) && user_can('torrent_hr')) {
|
||||
$updateset[] = "hr = " . sqlesc($_POST['hr'][$newcatmode]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id";
|
||||
do_log("[UPDATE_TORRENT]: $sql");
|
||||
$affectedRows = sql_query($sql) or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
@@ -339,8 +339,8 @@ $insert = [
|
||||
'technical_info' => $_POST['technical_info'] ?? '',
|
||||
'cover' => $cover,
|
||||
];
|
||||
if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']]) && user_can('torrent_hr')) {
|
||||
$insert['hr'] = $_POST['hr'];
|
||||
if (isset($_POST['hr'][$catmod]) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr'][$catmod]]) && user_can('torrent_hr')) {
|
||||
$insert['hr'] = $_POST['hr'][$catmod];
|
||||
}
|
||||
if(user_can('torrentsticky')) {
|
||||
if (isset($_POST['pos_state']) && isset(\App\Models\Torrent::$posStates[$_POST['pos_state']])) {
|
||||
|
||||
+3
-5
@@ -149,9 +149,12 @@ stdhead($lang_upload['head_upload']);
|
||||
tr($lang_upload['row_content'],$team_select,1);
|
||||
}
|
||||
$customField = new \Nexus\Field\Field();
|
||||
$hitAndRunRep = new \App\Repositories\HitAndRunRepository();
|
||||
echo $customField->renderOnUploadPage(0, $browsecatmode);
|
||||
echo $hitAndRunRep->renderOnUploadPage('', $browsecatmode);
|
||||
if ($enablespecial) {
|
||||
echo $customField->renderOnUploadPage(0, $specialcatmode);
|
||||
echo $hitAndRunRep->renderOnUploadPage('', $specialcatmode);
|
||||
}
|
||||
|
||||
//==== offer dropdown for offer mod from code by S4NE
|
||||
@@ -218,11 +221,6 @@ JS;
|
||||
tr($lang_upload['row_show_uploader'], "<input type=\"checkbox\" name=\"uplver\" value=\"yes\" />".$lang_upload['checkbox_hide_uploader_note'], 1);
|
||||
}
|
||||
tr($lang_functions['text_tags'], (new \App\Repositories\TagRepository())->renderCheckbox(), 1);
|
||||
if (get_setting('hr.mode') == \App\Models\HitAndRun::MODE_MANUAL && user_can('torrent_hr')) {
|
||||
$hrRadio = sprintf('<label><input type="radio" name="hr" value="0"%s />NO</label>', '');
|
||||
$hrRadio .= sprintf('<label><input type="radio" name="hr" value="1"%s />YES</label>', '');
|
||||
tr('H&R', $hrRadio, 1);
|
||||
}
|
||||
?>
|
||||
<tr><td class="toolbox" align="center" colspan="2"><b><?php echo $lang_upload['text_read_rules']?></b> <input id="qr" type="submit" class="btn" value="<?php echo $lang_upload['submit_upload']?>" /></td></tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user