plugin management + user tables and torrents table text column migrate

This commit is contained in:
xiaomlove
2025-01-19 14:37:00 +08:00
parent 0f88ab8d82
commit 403a9447a9
66 changed files with 1432 additions and 786 deletions
+27 -16
View File
@@ -25,7 +25,7 @@ if (!$id)
die();
$res = sql_query("SELECT id, category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen, banned FROM torrents WHERE id = ".mysql_real_escape_string($id));
$res = sql_query("SELECT id, category, owner, filename, save_as, anonymous, picktype, picktime, added, banned FROM torrents WHERE id = ".mysql_real_escape_string($id));
$row = mysql_fetch_array($res);
$torrentAddedTimeString = $row['added'];
if (!$row)
@@ -35,6 +35,7 @@ if ($CURUSER["id"] != $row["owner"] && !user_can('torrentmanage'))
bark($lang_takeedit['std_not_owner']);
$oldcatmode = get_single_value("categories","mode","WHERE id=".sqlesc($row['category']));
$updateset = array();
$extraUpdate = [];
//$fname = $row["filename"];
//preg_match('/^(.+)\.torrent$/si', $fname, $matches);
@@ -45,19 +46,23 @@ $url = parse_imdb_id($_POST['url'] ?? '');
/**
* add PT-Gen
* @since 1.6
*
* @deprecated
* @since 1.9
*/
if (!empty($_POST['pt_gen'])) {
$postPtGen = $_POST['pt_gen'];
$existsPtGenInfo = json_decode($row['pt_gen'], true) ?? [];
$ptGen = new \Nexus\PTGen\PTGen();
if ($postPtGen != $ptGen->getLink($existsPtGenInfo)) {
$updateset[] = "pt_gen = " . sqlesc($postPtGen);
}
} else {
$updateset[] = "pt_gen = ''";
}
//if (!empty($_POST['pt_gen'])) {
// $postPtGen = $_POST['pt_gen'];
// $existsPtGenInfo = json_decode($row['pt_gen'], true) ?? [];
// $ptGen = new \Nexus\PTGen\PTGen();
// if ($postPtGen != $ptGen->getLink($existsPtGenInfo)) {
// $updateset[] = "pt_gen = " . sqlesc($postPtGen);
// }
//} else {
// $updateset[] = "pt_gen = ''";
//}
$updateset[] = "technical_info = " . sqlesc($_POST['technical_info'] ?? '');
//$updateset[] = "technical_info = " . sqlesc($_POST['technical_info'] ?? '');
$extraUpdate["media_info"] = $_POST['technical_info'] ?? '';
$torrentOperationLog = [];
@@ -70,8 +75,11 @@ if ($nfoaction == "update")
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)));
if (@is_uploaded_file($nfofilename) && @filesize($nfofilename) > 0) {
// $updateset[] = "nfo = " . sqlesc(str_replace("\x0d\x0d\x0a", "\x0d\x0a", file_get_contents($nfofilename)));
$extraUpdate["nfo"] = str_replace("\x0d\x0d\x0a", "\x0d\x0a", file_get_contents($nfofilename));
}
$Cache->delete_value('nfo_block_torrent_id_'.$id);
}
elseif ($nfoaction == "remove"){
@@ -93,7 +101,8 @@ if ($oldcatmode != $newcatmode && !$allowmove)
bark($lang_takeedit['std_cannot_move_torrent']);
$updateset[] = "anonymous = '" . (!empty($_POST["anonymous"]) ? "yes" : "no") . "'";
$updateset[] = "name = " . sqlesc($name);
$updateset[] = "descr = " . sqlesc($descr);
//$updateset[] = "descr = " . sqlesc($descr);
$extraUpdate["descr"] = $descr;
$updateset[] = "url = " . sqlesc($url);
$updateset[] = "small_descr = " . sqlesc($_POST["small_descr"]);
//$updateset[] = "ori_descr = " . sqlesc($descr);
@@ -232,7 +241,9 @@ if (user_can('torrent-set-price') && $paidTorrentEnabled) {
$sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id";
do_log("[UPDATE_TORRENT]: $sql");
$affectedRows = sql_query($sql) or sqlerr(__FILE__, __LINE__);
fire_event("torrent_updated", \App\Models\Torrent::query()->find($id), $torrentOld);
$torrentInfo = \App\Models\Torrent::query()->find($id);
$torrentInfo->extra()->update($extraUpdate);
fire_event("torrent_updated", $torrentInfo, $torrentOld);
$dateTimeStringNow = date("Y-m-d H:i:s");
/**