2020-12-26 01:42:23 +08:00
|
|
|
<?php
|
2021-01-13 19:32:26 +08:00
|
|
|
require_once("../include/bittorrent.php");
|
2020-12-26 01:42:23 +08:00
|
|
|
dbconn();
|
|
|
|
|
require_once(get_langfile_path());
|
2025-04-21 11:57:24 +07:00
|
|
|
//require_once(get_langfile_path("",true));
|
2020-12-26 01:42:23 +08:00
|
|
|
loggedinorreturn();
|
2022-09-08 21:48:15 +08:00
|
|
|
user_can('torrent-delete', true);
|
2020-12-26 01:42:23 +08:00
|
|
|
function bark($msg) {
|
|
|
|
|
global $lang_delete;
|
|
|
|
|
stdhead();
|
|
|
|
|
stdmsg($lang_delete['std_delete_failed'], $msg);
|
|
|
|
|
stdfoot();
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mkglobal("id"))
|
|
|
|
|
bark($lang_delete['std_missing_form_date']);
|
|
|
|
|
|
2021-01-06 02:19:03 +08:00
|
|
|
$id = intval($id ?? 0);
|
2020-12-26 01:42:23 +08:00
|
|
|
if (!$id)
|
|
|
|
|
die();
|
|
|
|
|
|
|
|
|
|
$res = sql_query("SELECT name,owner,seeders,anonymous FROM torrents WHERE id = ".sqlesc($id));
|
|
|
|
|
$row = mysql_fetch_array($res);
|
|
|
|
|
if (!$row)
|
|
|
|
|
die();
|
|
|
|
|
|
2022-08-20 19:11:28 +08:00
|
|
|
if ($CURUSER["id"] != $row["owner"] && !user_can('torrentmanage'))
|
2020-12-26 01:42:23 +08:00
|
|
|
bark($lang_delete['std_not_owner']);
|
|
|
|
|
|
2021-01-06 02:19:03 +08:00
|
|
|
$rt = intval($_POST["reasontype"] ?? 0);
|
2020-12-26 01:42:23 +08:00
|
|
|
|
|
|
|
|
if (!is_int($rt) || $rt < 1 || $rt > 5)
|
|
|
|
|
bark($lang_delete['std_invalid_reason']."$rt.");
|
|
|
|
|
|
|
|
|
|
$reason = $_POST["reason"];
|
|
|
|
|
|
|
|
|
|
if ($rt == 1)
|
|
|
|
|
$reasonstr = "Dead: 0 seeders, 0 leechers = 0 peers total";
|
|
|
|
|
elseif ($rt == 2)
|
|
|
|
|
$reasonstr = "Dupe" . ($reason[0] ? (": " . trim($reason[0])) : "!");
|
|
|
|
|
elseif ($rt == 3)
|
|
|
|
|
$reasonstr = "Nuked" . ($reason[1] ? (": " . trim($reason[1])) : "!");
|
|
|
|
|
elseif ($rt == 4)
|
|
|
|
|
{
|
|
|
|
|
if (!$reason[2])
|
|
|
|
|
bark($lang_delete['std_describe_violated_rule']);
|
|
|
|
|
$reasonstr = $SITENAME." rules broken: " . trim($reason[2]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!$reason[3])
|
|
|
|
|
bark($lang_delete['std_enter_reason']);
|
|
|
|
|
$reasonstr = trim($reason[3]);
|
|
|
|
|
}
|
2022-03-26 16:09:39 +08:00
|
|
|
$searchRep = new \App\Repositories\SearchRepository();
|
|
|
|
|
$deleteEsResult = $searchRep->deleteTorrent($id);
|
|
|
|
|
if ($deleteEsResult === false) {
|
|
|
|
|
bark('Delete es fail.');
|
|
|
|
|
}
|
2020-12-26 01:42:23 +08:00
|
|
|
deletetorrent($id);
|
|
|
|
|
|
|
|
|
|
if ($row['anonymous'] == 'yes' && $CURUSER["id"] == $row["owner"]) {
|
2021-05-14 11:04:03 +08:00
|
|
|
write_log("Torrent $id ({$row['name']}) was deleted by its anonymous uploader ($reasonstr)",'normal');
|
2020-12-26 01:42:23 +08:00
|
|
|
} else {
|
2021-05-14 11:04:03 +08:00
|
|
|
write_log("Torrent $id ({$row['name']}) was deleted by {$CURUSER['username']} ($reasonstr)",'normal');
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===remove karma
|
|
|
|
|
KPS("-",$uploadtorrent_bonus,$row["owner"]);
|
|
|
|
|
|
|
|
|
|
//Send pm to torrent uploader
|
2024-11-18 22:20:31 +08:00
|
|
|
if ($CURUSER["id"] != $row["owner"] && \App\Models\User::exists($row["owner"])){
|
2025-05-26 15:10:31 +07:00
|
|
|
$dt = date("Y-m-d H:i:s");
|
2025-04-21 02:53:56 +07:00
|
|
|
$locale = get_user_locale($row["owner"]);
|
2025-05-26 15:10:31 +07:00
|
|
|
$subject = nexus_trans("torrent.msg_torrent_deleted", [], $locale);
|
|
|
|
|
$msg = nexus_trans("torrent.msg_the_torrent_you_uploaded", [], $locale).$row['name'].nexus_trans("torrent.msg_was_deleted_by", [], $locale)."[url=userdetails.php?id=".$CURUSER['id']."]".$CURUSER['username']."[/url]".nexus_trans("torrent.msg_reason_is", [], $locale).$reasonstr;
|
|
|
|
|
\App\Models\Message::add([
|
|
|
|
|
'sender' => 0,
|
|
|
|
|
'receiver' => $row['owner'],
|
|
|
|
|
'subject' => $subject,
|
|
|
|
|
'msg' => $msg,
|
|
|
|
|
'added' => $dt,
|
|
|
|
|
]);
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
stdhead($lang_delete['head_torrent_deleted']);
|
|
|
|
|
|
|
|
|
|
if (isset($_POST["returnto"]))
|
|
|
|
|
$ret = "<a href=\"" . htmlspecialchars($_POST["returnto"]) . "\">".$lang_delete['text_go_back']."</a>";
|
|
|
|
|
else
|
|
|
|
|
$ret = "<a href=\"index.php\">".$lang_delete['text_back_to_index']."</a>";
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<h1><?php echo $lang_delete['text_torrent_deleted'] ?></h1>
|
|
|
|
|
<p><?php echo $ret ?></p>
|
|
|
|
|
<?php
|
|
|
|
|
stdfoot();
|