mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
[admin] torrent add more bulk action
This commit is contained in:
@@ -3049,18 +3049,21 @@ function loggedinorreturn($mainpage = false) {
|
||||
}
|
||||
|
||||
function deletetorrent($id) {
|
||||
$id = intval($id);
|
||||
$idArr = \Illuminate\Support\Arr::wrap($id);
|
||||
$idStr = implode(', ', $idArr ?: [0]);
|
||||
$torrent_dir = get_setting('main.torrent_dir');
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM torrents WHERE id = $id");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM snatched WHERE torrentid = $id");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM torrents WHERE id in ($idStr)");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM snatched WHERE torrentid in ($idStr)");
|
||||
foreach(array("peers", "files", "comments") as $x) {
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM $x WHERE torrent = $id");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM $x WHERE torrent in ($idStr)");
|
||||
}
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM hit_and_runs WHERE torrent_id = $id");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM claims WHERE torrent_id = $id");
|
||||
do_action("torrent_delete", $id);
|
||||
do_log("delete torrent: $id", "error");
|
||||
unlink(getFullDirectory("$torrent_dir/$id.torrent"));
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM hit_and_runs WHERE torrent_id in ($idStr)");
|
||||
\Nexus\Database\NexusDB::statement("DELETE FROM claims WHERE torrent_id in ($idStr)");
|
||||
foreach ($idArr as $_id) {
|
||||
do_action("torrent_delete", $_id);
|
||||
do_log("delete torrent: $_id", "error");
|
||||
unlink(getFullDirectory("$torrent_dir/$_id.torrent"));
|
||||
}
|
||||
}
|
||||
|
||||
function pager($rpp, $count, $href, $opts = array(), $pagename = "page") {
|
||||
@@ -5790,6 +5793,8 @@ function build_medal_image(\Illuminate\Support\Collection $medals, $maxHeight =
|
||||
|
||||
function insert_torrent_tags($torrentId, $tagIdArr, $sync = false)
|
||||
{
|
||||
$specialTags = \App\Models\Tag::listSpecial();
|
||||
$canSetSpecialTag = user_can('torrent-set-special-tag');
|
||||
$dateTimeStringNow = date('Y-m-d H:i:s');
|
||||
if ($sync) {
|
||||
sql_query("delete from torrent_tags where torrent_id = $torrentId");
|
||||
@@ -5800,6 +5805,10 @@ function insert_torrent_tags($torrentId, $tagIdArr, $sync = false)
|
||||
$insertTagsSql = 'insert into torrent_tags (`torrent_id`, `tag_id`, `created_at`, `updated_at`) values ';
|
||||
$values = [];
|
||||
foreach ($tagIdArr as $tagId) {
|
||||
if (in_array($tagId, $specialTags) && !$canSetSpecialTag) {
|
||||
do_log("special tag: $tagId, and user no permission");
|
||||
continue;
|
||||
}
|
||||
$values[] = sprintf("(%s, %s, '%s', '%s')", $torrentId, $tagId, $dateTimeStringNow, $dateTimeStringNow);
|
||||
}
|
||||
$insertTagsSql .= implode(', ', $values);
|
||||
|
||||
@@ -942,9 +942,20 @@ function getDataTraffic(array $torrent, array $queries, array $user, $peer, $sna
|
||||
$log .= ", isIPSeedBox && isSeedBoxNoPromotion, increment for user = real";
|
||||
}
|
||||
$maxUploadedTimes = get_setting('seed_box.max_uploaded');
|
||||
if (!empty($snatch) && isset($torrent['size']) && $snatch['uploaded'] >= $torrent['size'] * $maxUploadedTimes) {
|
||||
$log .= ", snatchUploaded >= torrentSize * times($maxUploadedTimes), uploadedIncrementForUser = 0";
|
||||
$uploadedIncrementForUser = 0;
|
||||
$maxUploadedDurationSeconds = get_setting('seed_box.max_uploaded_duration', 0) * 3600;
|
||||
$torrentTTL = time() - strtotime($torrent['added']);
|
||||
$timeRangeValid = ($maxUploadedDurationSeconds == 0) || ($torrentTTL < $maxUploadedDurationSeconds);
|
||||
$log .= ", maxUploadedTimes: $maxUploadedTimes, maxUploadedDurationSeconds: $maxUploadedDurationSeconds, timeRangeValid: $timeRangeValid";
|
||||
if ($maxUploadedTimes > 0 && $timeRangeValid) {
|
||||
$log .= ", [LIMIT_UPLOADED]";
|
||||
if (!empty($snatch) && isset($torrent['size']) && $snatch['uploaded'] >= $torrent['size'] * $maxUploadedTimes) {
|
||||
$log .= ", snatchUploaded({$snatch['uploaded']}) >= torrentSize({$torrent['size']}) * times($maxUploadedTimes), uploadedIncrementForUser = 0";
|
||||
$uploadedIncrementForUser = 0;
|
||||
} else {
|
||||
$log .= ", snatchUploaded({$snatch['uploaded']}) < torrentSize({$torrent['size']}) * times($maxUploadedTimes), uploadedIncrementForUser do not change to 0";
|
||||
}
|
||||
} else {
|
||||
$log .= ", [NOT_LIMIT_UPLOADED]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user