mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
refactor default imdb
This commit is contained in:
+7
-4
@@ -16,7 +16,6 @@ die();
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, categories.name AS cat_name, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN sources ON torrents.source = sources.id LEFT JOIN media ON torrents.medium = media.id LEFT JOIN codecs ON torrents.codec = codecs.id LEFT JOIN standards ON torrents.standard = standards.id LEFT JOIN processings ON torrents.processing = processings.id LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN audiocodecs ON torrents.audiocodec = audiocodecs.id WHERE torrents.id = $id LIMIT 1")
|
||||
or sqlerr();
|
||||
$row = mysql_fetch_array($res);
|
||||
|
||||
if (get_user_class() >= $torrentmanage_class || $CURUSER["id"] == $row["owner"])
|
||||
$owned = 1;
|
||||
else $owned = 0;
|
||||
@@ -26,8 +25,9 @@ if (!$row)
|
||||
elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class)
|
||||
permissiondenied();
|
||||
else {
|
||||
$torrentUpdate = [];
|
||||
if (!empty($_GET["hit"])) {
|
||||
sql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
|
||||
$torrentUpdate[] = 'views = views + 1';
|
||||
}
|
||||
|
||||
if (!isset($_GET["cmtpage"])) {
|
||||
@@ -396,9 +396,9 @@ else {
|
||||
|
||||
if (!empty($row['pt_gen'])) {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenResult = $ptGen->renderDetailsPageDescription(json_decode($row['pt_gen'], true));
|
||||
$ptGenResult = $ptGen->renderDetailsPageDescription($id, json_decode($row['pt_gen'], true));
|
||||
if ($ptGenResult['update']) {
|
||||
//@todo do some update
|
||||
$torrentUpdate[] = 'pt_gen = ' . sqlesc(json_encode($ptGenResult['json_arr']));
|
||||
}
|
||||
echo $ptGenResult['html'];
|
||||
}
|
||||
@@ -567,6 +567,9 @@ echo "</script>";
|
||||
stdhead($lang_details['head_comments_for_torrent']."\"" . $row["name"] . "\"");
|
||||
print("<h1 id=\"top\">".$lang_details['text_comments_for']."<a href=\"details.php?id=".$id."\">" . htmlspecialchars($row["name"]) . "</a></h1>\n");
|
||||
}
|
||||
if (!empty($torrentUpdate)) {
|
||||
sql_query("UPDATE torrents SET " . join(",", $torrentUpdate) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// -----------------COMMENT SECTION ---------------------//
|
||||
if ($CURUSER['showcomment'] != 'no'){
|
||||
|
||||
+16
-3
@@ -8,12 +8,12 @@ permissiondenied();
|
||||
}
|
||||
$id = intval($_GET["id"] ?? 0);
|
||||
$type = intval($_GET["type"] ?? 0);
|
||||
$siteid = intval($_GET["siteid"] ?? 0); // 1 for IMDb
|
||||
$siteid = $_GET["siteid"] ?? 0; // 1 for IMDb
|
||||
|
||||
if (!isset($id) || !$id || !is_numeric($id) || !isset($type) || !$type || !is_numeric($type) || !isset($siteid) || !$siteid || !is_numeric($siteid))
|
||||
if (!isset($id) || !$id || !is_numeric($id) || !isset($type) || !$type || !is_numeric($type) || !isset($siteid) || !$siteid)
|
||||
die();
|
||||
|
||||
$r = sql_query("SELECT * from torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
$r = sql_query("SELECT id, url, pt_gen from torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
if(mysql_num_rows($r) != 1)
|
||||
die();
|
||||
|
||||
@@ -42,6 +42,19 @@ switch ($siteid)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case \Nexus\PTGen\PTGen::SITE_IMDB:
|
||||
case \Nexus\PTGen\PTGen::SITE_DOUBAN:
|
||||
case \Nexus\PTGen\PTGen::SITE_BANGUMI:
|
||||
{
|
||||
$ptGenInfo = json_decode($row['pt_gen'], true);
|
||||
$link = $ptGenInfo[$siteid]['link'];
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$result = $ptGen->generate($link, true);
|
||||
$ptGenInfo[$siteid]['data'] = $result;
|
||||
sql_query(sprintf("update torrents set pt_gen = %s where id = %s", sqlesc(json_encode($ptGenInfo)), $id)) or sqlerr(__FILE__, __LINE__);
|
||||
header("Location: " . get_protocol_prefix() . "$BASEURL/details.php?id=".htmlspecialchars($id));
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
die("Error!");
|
||||
|
||||
+17
-7
@@ -37,6 +37,23 @@ $updateset = array();
|
||||
//$dname = $row["save_as"];
|
||||
|
||||
$url = parse_imdb_id($_POST['url'] ?? '');
|
||||
/**
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
if (!empty($_POST['pt_gen'])) {
|
||||
//use PT-Gen imdb for url
|
||||
$postPtGen = $_POST['pt_gen'];
|
||||
$ptGenImdbLink = $postPtGen[\Nexus\PTGen\PTGen::SITE_IMDB]['link'] ?? '';
|
||||
if (empty($url) && !empty($ptGenImdbLink)) {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenImdbInfo = $ptGen->parse($ptGenImdbLink);
|
||||
$url = str_replace('tt', '', $ptGenImdbInfo['id']);
|
||||
}
|
||||
$updateset[] = "pt_gen = " . sqlesc(json_encode($postPtGen));
|
||||
} else {
|
||||
$updateset[] = "pt_gen = ''";
|
||||
}
|
||||
|
||||
if ($enablenfo_main=='yes'){
|
||||
$nfoaction = $_POST['nfoaction'];
|
||||
@@ -168,13 +185,6 @@ if(get_user_class()>=$torrentmanage_class && $CURUSER['picker'] == 'yes')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
if (!empty($_POST['pt_gen'])) {
|
||||
$updateset[] = "pt_gen = " . sqlesc(json_encode($_POST['pt_gen']));
|
||||
}
|
||||
|
||||
sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
|
||||
@@ -333,10 +333,17 @@ foreach ($promotionrules_torrent as $rule)
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
$ptGen = sqlesc(json_encode($_POST['pt_gen'] ?? []));
|
||||
$postPtGen = $_POST['pt_gen'] ?? [];
|
||||
$ptGenImdbLink = $postPtGen[\Nexus\PTGen\PTGen::SITE_IMDB]['link'] ?? '';
|
||||
if (empty($url) && !empty($ptGenImdbLink)) {
|
||||
//use PT-Gen imdb for url
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenImdbInfo = $ptGen->parse($ptGenImdbLink);
|
||||
$url = str_replace('tt', '', $ptGenImdbInfo['id']);
|
||||
}
|
||||
|
||||
$ret = sql_query("INSERT INTO torrents (filename, owner, visible, anonymous, name, size, numfiles, type, url, small_descr, descr, ori_descr, category, source, medium, codec, audiocodec, standard, processing, team, save_as, sp_state, added, last_action, nfo, info_hash, pt_gen) VALUES (".sqlesc($fname).", ".sqlesc($CURUSER["id"]).", 'yes', ".sqlesc($anonymous).", ".sqlesc($torrent).", ".sqlesc($totallen).", ".count($filelist).", ".sqlesc($type).", ".sqlesc($url).", ".sqlesc($small_descr).", ".sqlesc($descr).", ".sqlesc($descr).", ".sqlesc($catid).", ".sqlesc($sourceid).", ".sqlesc($mediumid).", ".sqlesc($codecid).", ".sqlesc($audiocodecid).", ".sqlesc($standardid).", ".sqlesc($processingid).", ".sqlesc($teamid).", ".sqlesc($dname).", ".sqlesc($sp_state) .
|
||||
", " . sqlesc(date("Y-m-d H:i:s")) . ", " . sqlesc(date("Y-m-d H:i:s")) . ", ".sqlesc($nfo).", " . sqlesc($infohash). ", $ptGen)");
|
||||
", " . sqlesc(date("Y-m-d H:i:s")) . ", " . sqlesc(date("Y-m-d H:i:s")) . ", ".sqlesc($nfo).", " . sqlesc($infohash). ", " . sqlesc(json_encode($postPtGen)) . ")");
|
||||
if (!$ret) {
|
||||
if (mysql_errno() == 1062)
|
||||
bark($lang_takeupload['std_torrent_existed']);
|
||||
|
||||
Reference in New Issue
Block a user