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());
|
|
|
|
|
loggedinorreturn();
|
|
|
|
|
|
|
|
|
|
function bark($msg) {
|
|
|
|
|
global $lang_takeedit;
|
|
|
|
|
genbark($msg, $lang_takeedit['std_edit_failed']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mkglobal("id:name:descr:type")){
|
|
|
|
|
global $lang_takeedit;
|
|
|
|
|
bark($lang_takeedit['std_missing_form_data']);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 01:31:21 +08:00
|
|
|
$id = intval($id ?? 0);
|
2020-12-26 01:42:23 +08:00
|
|
|
if (!$id)
|
|
|
|
|
die();
|
|
|
|
|
|
|
|
|
|
|
2022-04-15 03:09:12 +08:00
|
|
|
$res = sql_query("SELECT category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen FROM torrents WHERE id = ".mysql_real_escape_string($id));
|
2020-12-26 01:42:23 +08:00
|
|
|
$row = mysql_fetch_array($res);
|
|
|
|
|
$torrentAddedTimeString = $row['added'];
|
|
|
|
|
if (!$row)
|
|
|
|
|
die();
|
|
|
|
|
|
|
|
|
|
if ($CURUSER["id"] != $row["owner"] && get_user_class() < $torrentmanage_class)
|
|
|
|
|
bark($lang_takeedit['std_not_owner']);
|
|
|
|
|
$oldcatmode = get_single_value("categories","mode","WHERE id=".sqlesc($row['category']));
|
|
|
|
|
$updateset = array();
|
|
|
|
|
|
|
|
|
|
//$fname = $row["filename"];
|
|
|
|
|
//preg_match('/^(.+)\.torrent$/si', $fname, $matches);
|
|
|
|
|
//$shortfname = $matches[1];
|
|
|
|
|
//$dname = $row["save_as"];
|
|
|
|
|
|
2020-12-29 21:49:37 +08:00
|
|
|
$url = parse_imdb_id($_POST['url'] ?? '');
|
2021-01-18 00:41:35 +08:00
|
|
|
/**
|
|
|
|
|
* add PT-Gen
|
|
|
|
|
* @since 1.6
|
|
|
|
|
*/
|
|
|
|
|
if (!empty($_POST['pt_gen'])) {
|
|
|
|
|
$postPtGen = $_POST['pt_gen'];
|
2022-04-15 03:09:12 +08:00
|
|
|
$existsPtGenInfo = json_decode($row['pt_gen'], true) ?? [];
|
|
|
|
|
$ptGen = new \Nexus\PTGen\PTGen();
|
|
|
|
|
if ($postPtGen != $ptGen->getLink($existsPtGenInfo)) {
|
|
|
|
|
$updateset[] = "pt_gen = " . sqlesc($postPtGen);
|
2021-01-18 00:41:35 +08:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$updateset[] = "pt_gen = ''";
|
|
|
|
|
}
|
2020-12-26 01:42:23 +08:00
|
|
|
|
2021-03-18 20:32:35 +08:00
|
|
|
$updateset[] = "technical_info = " . sqlesc($_POST['technical_info'] ?? '');
|
|
|
|
|
|
2021-06-21 02:01:26 +08:00
|
|
|
/**
|
|
|
|
|
* hr
|
|
|
|
|
* @since 1.6.0-beta12
|
|
|
|
|
*/
|
|
|
|
|
if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']])) {
|
|
|
|
|
$updateset[] = "hr = " . sqlesc($_POST['hr']);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-20 18:22:19 +08:00
|
|
|
|
2020-12-26 01:42:23 +08:00
|
|
|
if ($enablenfo_main=='yes'){
|
|
|
|
|
$nfoaction = $_POST['nfoaction'];
|
|
|
|
|
if ($nfoaction == "update")
|
|
|
|
|
{
|
|
|
|
|
$nfofile = $_FILES['nfo'];
|
|
|
|
|
if (!$nfofile) die("No data " . var_dump($_FILES));
|
|
|
|
|
if ($nfofile['size'] > 65535)
|
|
|
|
|
bark($lang_takeedit['std_nfo_too_big']);
|
|
|
|
|
$nfofilename = $nfofile['tmp_name'];
|
|
|
|
|
if (@is_uploaded_file($nfofilename) && @filesize($nfofilename) > 0)
|
|
|
|
|
$updateset[] = "nfo = " . sqlesc(str_replace("\x0d\x0d\x0a", "\x0d\x0a", file_get_contents($nfofilename)));
|
|
|
|
|
$Cache->delete_value('nfo_block_torrent_id_'.$id);
|
|
|
|
|
}
|
|
|
|
|
elseif ($nfoaction == "remove"){
|
|
|
|
|
$updateset[] = "nfo = ''";
|
|
|
|
|
$Cache->delete_value('nfo_block_torrent_id_'.$id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 01:31:21 +08:00
|
|
|
$catid = intval($type ?? 0);
|
2020-12-26 01:42:23 +08:00
|
|
|
if (!is_valid_id($catid))
|
|
|
|
|
bark($lang_takeedit['std_missing_form_data']);
|
|
|
|
|
if (!$name || !$descr)
|
|
|
|
|
bark($lang_takeedit['std_missing_form_data']);
|
|
|
|
|
$newcatmode = get_single_value("categories","mode","WHERE id=".sqlesc($catid));
|
|
|
|
|
if ($enablespecial == 'yes' && get_user_class() >= $movetorrent_class)
|
|
|
|
|
$allowmove = true; //enable moving torrent to other section
|
|
|
|
|
else $allowmove = false;
|
|
|
|
|
if ($oldcatmode != $newcatmode && !$allowmove)
|
|
|
|
|
bark($lang_takeedit['std_cannot_move_torrent']);
|
2020-12-29 21:49:37 +08:00
|
|
|
$updateset[] = "anonymous = '" . (!empty($_POST["anonymous"]) ? "yes" : "no") . "'";
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "name = " . sqlesc($name);
|
|
|
|
|
$updateset[] = "descr = " . sqlesc($descr);
|
|
|
|
|
$updateset[] = "url = " . sqlesc($url);
|
|
|
|
|
$updateset[] = "small_descr = " . sqlesc($_POST["small_descr"]);
|
|
|
|
|
//$updateset[] = "ori_descr = " . sqlesc($descr);
|
|
|
|
|
$updateset[] = "category = " . sqlesc($catid);
|
2021-01-06 01:31:21 +08:00
|
|
|
$updateset[] = "source = " . sqlesc(intval($_POST["source_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "medium = " . sqlesc(intval($_POST["medium_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "codec = " . sqlesc(intval($_POST["codec_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "standard = " . sqlesc(intval($_POST["standard_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "processing = " . sqlesc(intval($_POST["processing_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "team = " . sqlesc(intval($_POST["team_sel"] ?? 0));
|
|
|
|
|
$updateset[] = "audiocodec = " . sqlesc(intval($_POST["audiocodec_sel"] ?? 0));
|
2020-12-26 01:42:23 +08:00
|
|
|
|
|
|
|
|
if (get_user_class() >= $torrentmanage_class) {
|
2020-12-29 21:49:37 +08:00
|
|
|
if (!empty($_POST["banned"])) {
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "banned = 'yes'";
|
|
|
|
|
$_POST["visible"] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$updateset[] = "banned = 'no'";
|
|
|
|
|
}
|
2020-12-29 21:49:37 +08:00
|
|
|
$updateset[] = "visible = '" . (!empty($_POST["visible"]) ? "yes" : "no") . "'";
|
2020-12-26 01:42:23 +08:00
|
|
|
if(get_user_class()>=$torrentonpromotion_class)
|
|
|
|
|
{
|
|
|
|
|
if(!isset($_POST["sel_spstate"]) || $_POST["sel_spstate"] == 1)
|
|
|
|
|
$updateset[] = "sp_state = 1";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 2)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 2";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 3)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 3";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 4)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 4";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 5)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 5";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 6)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 6";
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_spstate"] ?? 0) == 7)
|
2020-12-26 01:42:23 +08:00
|
|
|
$updateset[] = "sp_state = 7";
|
|
|
|
|
|
|
|
|
|
//promotion expiration type
|
|
|
|
|
if(!isset($_POST["promotion_time_type"]) || $_POST["promotion_time_type"] == 0) {
|
|
|
|
|
$updateset[] = "promotion_time_type = 0";
|
2021-03-18 20:32:35 +08:00
|
|
|
$updateset[] = "promotion_until = null";
|
2020-12-26 01:42:23 +08:00
|
|
|
} elseif ($_POST["promotion_time_type"] == 1) {
|
|
|
|
|
$updateset[] = "promotion_time_type = 1";
|
2021-03-18 20:32:35 +08:00
|
|
|
$updateset[] = "promotion_until = null";
|
2020-12-26 01:42:23 +08:00
|
|
|
} elseif ($_POST["promotion_time_type"] == 2) {
|
|
|
|
|
if ($_POST["promotionuntil"] && strtotime($torrentAddedTimeString) <= strtotime($_POST["promotionuntil"])) {
|
|
|
|
|
$updateset[] = "promotion_time_type = 2";
|
|
|
|
|
$updateset[] = "promotion_until = ".sqlesc($_POST["promotionuntil"]);
|
|
|
|
|
} else {
|
|
|
|
|
$updateset[] = "promotion_time_type = 0";
|
2021-03-18 20:32:35 +08:00
|
|
|
$updateset[] = "promotion_until = null";
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-01 01:28:46 +08:00
|
|
|
if(get_user_class()>=$torrentsticky_class && isset($_POST['sel_posstate']) && isset(\App\Models\Torrent::$posStates[$_POST['sel_posstate']]))
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
2021-06-01 01:28:46 +08:00
|
|
|
$updateset[] = "pos_state = '" . $_POST['sel_posstate'] . "'";
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pick_info = "";
|
2020-12-29 21:49:37 +08:00
|
|
|
$place_info = "";
|
2022-04-18 22:45:44 +08:00
|
|
|
if(get_user_class()>=$torrentmanage_class && ($CURUSER['picker'] == 'yes' || get_user_class() >= \App\Models\User::CLASS_SYSOP))
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
2022-04-18 22:45:44 +08:00
|
|
|
$doRecommend = false;
|
2021-01-06 01:39:45 +08:00
|
|
|
if(intval($_POST["sel_recmovie"] ?? 0) == 0)
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
|
|
|
|
if($row["picktype"] != 'normal')
|
|
|
|
|
$pick_info = ", recomendation canceled!";
|
|
|
|
|
$updateset[] = "picktype = 'normal'";
|
2021-03-18 20:32:35 +08:00
|
|
|
$updateset[] = "picktime = null";
|
2022-04-18 22:45:44 +08:00
|
|
|
$doRecommend = true;
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_recmovie"] ?? 0) == 1)
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
|
|
|
|
if($row["picktype"] != 'hot')
|
|
|
|
|
$pick_info = ", recommend as hot movie";
|
|
|
|
|
$updateset[] = "picktype = 'hot'";
|
|
|
|
|
$updateset[] = "picktime = ". sqlesc(date("Y-m-d H:i:s"));
|
2022-04-18 22:45:44 +08:00
|
|
|
$doRecommend = true;
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_recmovie"] ?? 0) == 2)
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
|
|
|
|
if($row["picktype"] != 'classic')
|
|
|
|
|
$pick_info = ", recommend as classic movie";
|
|
|
|
|
$updateset[] = "picktype = 'classic'";
|
|
|
|
|
$updateset[] = "picktime = ". sqlesc(date("Y-m-d H:i:s"));
|
2022-04-18 22:45:44 +08:00
|
|
|
$doRecommend = true;
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2021-01-06 01:39:45 +08:00
|
|
|
elseif(intval($_POST["sel_recmovie"] ?? 0) == 3)
|
2020-12-26 01:42:23 +08:00
|
|
|
{
|
|
|
|
|
if($row["picktype"] != 'recommended')
|
|
|
|
|
$pick_info = ", recommend as recommended movie";
|
|
|
|
|
$updateset[] = "picktype = 'recommended'";
|
|
|
|
|
$updateset[] = "picktime = ". sqlesc(date("Y-m-d H:i:s"));
|
2022-04-18 22:45:44 +08:00
|
|
|
$doRecommend = true;
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2022-04-18 22:45:44 +08:00
|
|
|
if ($doRecommend) {
|
|
|
|
|
\Nexus\Database\NexusDB::cache_del("hot_resources");
|
|
|
|
|
\Nexus\Database\NexusDB::cache_del("classic_resources");
|
|
|
|
|
}
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2021-01-15 22:13:46 +08:00
|
|
|
|
|
|
|
|
|
2020-12-26 01:42:23 +08:00
|
|
|
sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
2022-03-08 15:08:56 +08:00
|
|
|
|
|
|
|
|
$dateTimeStringNow = date("Y-m-d H:i:s");
|
|
|
|
|
|
2021-03-04 02:27:39 +08:00
|
|
|
/**
|
|
|
|
|
* add custom fields
|
|
|
|
|
* @since v1.6
|
|
|
|
|
*/
|
|
|
|
|
if (!empty($_POST['custom_fields'])) {
|
2021-06-08 10:42:39 +08:00
|
|
|
\Nexus\Database\NexusDB::delete('torrents_custom_field_values', "torrent_id = $id");
|
2021-03-04 02:27:39 +08:00
|
|
|
foreach ($_POST['custom_fields'] as $customField => $customValue) {
|
|
|
|
|
foreach ((array)$customValue as $value) {
|
|
|
|
|
$customData = [
|
|
|
|
|
'torrent_id' => $id,
|
|
|
|
|
'custom_field_id' => $customField,
|
|
|
|
|
'custom_field_value' => $value,
|
2022-03-08 15:08:56 +08:00
|
|
|
'created_at' => $dateTimeStringNow,
|
|
|
|
|
'updated_at' => $dateTimeStringNow,
|
2021-03-04 02:27:39 +08:00
|
|
|
];
|
2021-06-08 10:42:39 +08:00
|
|
|
\Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData);
|
2021-03-04 02:27:39 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-26 01:42:23 +08:00
|
|
|
|
2022-03-08 15:08:56 +08:00
|
|
|
/**
|
|
|
|
|
* handle tags
|
|
|
|
|
*
|
|
|
|
|
* @since v1.6
|
|
|
|
|
*/
|
2022-03-10 19:31:59 +08:00
|
|
|
$tagIdArr = array_filter($_POST['tags'] ?? []);
|
2022-03-18 21:50:42 +08:00
|
|
|
insert_torrent_tags($id, $tagIdArr, true);
|
2022-03-08 15:08:56 +08:00
|
|
|
|
2020-12-26 01:42:23 +08:00
|
|
|
if($CURUSER["id"] == $row["owner"])
|
|
|
|
|
{
|
|
|
|
|
if ($row["anonymous"]=='yes')
|
|
|
|
|
{
|
|
|
|
|
write_log("Torrent $id ($name) was edited by Anonymous" . $pick_info . $place_info);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-03-31 03:17:33 +08:00
|
|
|
write_log("Torrent $id ($name) was edited by {$CURUSER['username']}" . $pick_info . $place_info);
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-03-31 03:17:33 +08:00
|
|
|
write_log("Torrent $id ($name) was edited by {$CURUSER['username']}, Mod Edit" . $pick_info . $place_info);
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
2022-03-26 16:09:39 +08:00
|
|
|
|
|
|
|
|
$searchRep = new \App\Repositories\SearchRepository();
|
|
|
|
|
$searchRep->updateTorrent($id);
|
|
|
|
|
|
2020-12-26 01:42:23 +08:00
|
|
|
$returl = "details.php?id=$id&edited=1";
|
|
|
|
|
if (isset($_POST["returnto"]))
|
|
|
|
|
$returl = $_POST["returnto"];
|
|
|
|
|
header("Refresh: 0; url=$returl");
|