diff --git a/.env.example b/.env.example index ec8a3085..154f51e7 100644 --- a/.env.example +++ b/.env.example @@ -45,10 +45,10 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -REDIS_HOST= +REDIS_HOST=127.0.0.1 REDIS_PASSWORD= -REDIS_PORT= -REDIS_DB= +REDIS_PORT=6379 +REDIS_DB=0 USE_CRON_TRIGGER_CLEANUP=true @@ -62,7 +62,6 @@ GOOGLE_DRIVE_REFRESH_TOKEN= GOOGLE_DRIVE_FOLDER_ID= GEOIP2_DATABASE= -EXAM_PROGRESS_UPDATE_PROBABILITY=20 TRACKER_API_LOCAL_HOST= diff --git a/app/Repositories/ClaimRepository.php b/app/Repositories/ClaimRepository.php index 5a549947..a058a0ca 100644 --- a/app/Repositories/ClaimRepository.php +++ b/app/Repositories/ClaimRepository.php @@ -304,4 +304,20 @@ class ClaimRepository extends BaseRepository 'msg' => implode("\n\n", $msg), ]; } + + public function buildActionButtons($torrentId, $claimData, $reload = 0): string + { + $buttonHtml = ''; + $addButton = sprintf($buttonHtml, 'addClaim', $reload, nexus_trans('claim.add_claim_confirm'), $claimData ? $claimData->id : 0, $torrentId, '%s', 'edit', nexus_trans('claim.add_claim')); + $removeButton = sprintf($buttonHtml, 'removeClaim', $reload, nexus_trans('claim.remove_claim_confirm'), $claimData ? $claimData->id : 0, $torrentId, '%s', 'delete', nexus_trans('claim.remove_claim')); + + if ($claimData) { + //Only show remove + return sprintf($addButton, 'none') . sprintf($removeButton, 'flex'); + } else { + //Only show add + return sprintf($addButton, 'flex') . sprintf($removeButton, 'none'); + } + + } } diff --git a/public/claim.php b/public/claim.php index 9161020c..62fafcfb 100644 --- a/public/claim.php +++ b/public/claim.php @@ -28,25 +28,6 @@ if (!empty($_GET['torrent_id'])) { print("
| ".$lang_getusertorrentlistajax['col_type']." | ".$lang_getusertorrentlistajax['col_name']." | ".$lang_getusertorrentlistajax['col_added']." | ". - ($showsize ? "![]() | " : "").($showsenum ? "![]() | " : "").($showlenum ? "![]() | " : "").($showuploaded ? "".$lang_getusertorrentlistajax['col_uploaded']." | " : "") . ($showdownloaded ? "".$lang_getusertorrentlistajax['col_downloaded']." | " : "").($showratio ? "".$lang_getusertorrentlistajax['col_ratio']." | " : "").($showsetime ? "".$lang_getusertorrentlistajax['col_se_time']." | " : "").($showletime ? "".$lang_getusertorrentlistajax['col_le_time']." | " : "").($showcotime ? "".$lang_getusertorrentlistajax['col_time_completed']." | " : "").($showanonymous ? "".$lang_getusertorrentlistajax['col_anonymous']." | " : "")."![]() | " : "").($showsenum ? "![]() | " : "").($showlenum ? "![]() | " : "").($showuploaded ? "".$lang_getusertorrentlistajax['col_uploaded']." | " : "") . ($showdownloaded ? "".$lang_getusertorrentlistajax['col_downloaded']." | " : "").($showratio ? "".$lang_getusertorrentlistajax['col_ratio']." | " : "").($showsetime ? "".$lang_getusertorrentlistajax['col_se_time']." | " : "").($showletime ? "".$lang_getusertorrentlistajax['col_le_time']." | " : "").($showcotime ? "".$lang_getusertorrentlistajax['col_time_completed']." | " : "").($showanonymous ? "".$lang_getusertorrentlistajax['col_anonymous']." | " : ""); + if ($showActionClaim) { + $ret .= sprintf('%s | ', $lang_functions['std_action']); + } + $ret .= ""; + $total_size = 0; foreach ($results as $arr) { if ($mode == 'uploaded') { @@ -199,6 +212,11 @@ function maketable($res, $mode = 'seeding') $ret .= ""."". str_replace(" ", " ", gettime($arr['completedat'],false)). " | ";
if ($showanonymous)
$ret .= "".$arr['anonymous']." | "; + if ($showActionClaim) { + $claim = $claimData->get($arr['torrent']); + $claimButton = $claimRep->buildActionButtons($arr['torrent'], $claim); + $ret .= sprintf('%s | ', $claimButton); + } $ret .="\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"; diff --git a/public/js/nexus.js b/public/js/nexus.js index b0dbe244..453bd826 100644 --- a/public/js/nexus.js +++ b/public/js/nexus.js @@ -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") + }) + }) + }) diff --git a/resources/lang/en/claim.php b/resources/lang/en/claim.php index a33dc293..9a465baa 100644 --- a/resources/lang/en/claim.php +++ b/resources/lang/en/claim.php @@ -25,4 +25,8 @@ return [ 'claim_unreached_summary' => 'Deduct bonus every unreached torrent::deduct_per_torrent, total deduct: :deduct_total', 'confirm_give_up' => 'Are you sure you want to give up claiming this torrent?', + 'add_claim' => 'Claim', + 'add_claim_confirm' => 'Confirm to claim?', + 'remove_claim' => 'Give up', + 'remove_claim_confirm' => 'Confirm to give up the claim?', ]; diff --git a/resources/lang/zh_CN/claim.php b/resources/lang/zh_CN/claim.php index 484af200..925b306e 100644 --- a/resources/lang/zh_CN/claim.php +++ b/resources/lang/zh_CN/claim.php @@ -25,4 +25,8 @@ return [ 'claim_unreached_summary' => '未达标每个种子扣除魔力::deduct_per_torrent,总扣除魔力::deduct_total', 'confirm_give_up' => '确定要放弃认领此种子吗?', + 'add_claim' => '认领', + 'add_claim_confirm' => '确认要认领?', + 'remove_claim' => '放弃', + 'remove_claim_confirm' => '确认要放弃认领?', ]; diff --git a/resources/lang/zh_TW/claim.php b/resources/lang/zh_TW/claim.php index 0b5ec93a..bfc9d19b 100644 --- a/resources/lang/zh_TW/claim.php +++ b/resources/lang/zh_TW/claim.php @@ -22,4 +22,10 @@ return [ 'claim_unreached_remain_counts' => '未達標保留數::counts', 'claim_unreached_remove_counts' => '未達標刪除數::counts', 'claim_unreached_summary' => '未達標每個種子扣除魔力::deduct_per_torrent,總扣除魔力::deduct_total', + + 'confirm_give_up' => '確定要放棄認領此種子嗎?', + 'add_claim' => '認領', + 'add_claim_confirm' => '確認要認領?', + 'remove_claim' => '放棄', + 'remove_claim_confirm' => '確認要放棄認領?', ];