diff --git a/composer.json b/composer.json index 14767b76..b0f43514 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "require": { "php": "^7.2|^8", "swiftmailer/swiftmailer": "^6.2", - "guzzlehttp/guzzle": "~6.0" + "guzzlehttp/guzzle": "~6.0", + "imdbphp/imdbphp": "^6.4" } } diff --git a/composer.lock b/composer.lock index 3f9bd563..73b4f52d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5e27df0bf1d474656f062b3f264353ee", + "content-hash": "add117e8cfda2fcb53a82b4804c76fd4", "packages": [ { "name": "doctrine/lexer", @@ -72,20 +72,6 @@ "parser", "php" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" - } - ], "time": "2020-05-25T17:44:05+00:00" }, { @@ -150,12 +136,6 @@ "validation", "validator" ], - "funding": [ - { - "url": "https://github.com/egulias", - "type": "github" - } - ], "time": "2020-12-29T14:50:06+00:00" }, { @@ -365,6 +345,53 @@ ], "time": "2020-09-30T07:37:11+00:00" }, + { + "name": "imdbphp/imdbphp", + "version": "v6.4.2", + "source": { + "type": "git", + "url": "https://github.com/tboothman/imdbphp.git", + "reference": "35a1c0240e30c16fae68b2f69682da679cc2aa21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tboothman/imdbphp/zipball/35a1c0240e30c16fae68b2f69682da679cc2aa21", + "reference": "35a1c0240e30c16fae68b2f69682da679cc2aa21", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-curl": "*", + "ext-dom": "*", + "ext-json": "*", + "php": ">=5.6", + "psr/log": "~1.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "cache/array-adapter": "^1.0", + "mockery/mockery": "1.3.3", + "phpstan/phpstan": "^0.9.2", + "phpunit/phpunit": "5.4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Imdb\\": "src/Imdb" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "description": "Library for retrieving film and tv information from IMDb", + "time": "2020-11-08T18:20:39+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -421,6 +448,113 @@ ], "time": "2016-08-06T14:39:51+00:00" }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" + }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-10-23T01:57:42+00:00" + }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -532,16 +666,6 @@ "mail", "mailer" ], - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer", - "type": "tidelift" - } - ], "time": "2021-01-12T09:35:59+00:00" }, { @@ -611,20 +735,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-01-07T16:49:33+00:00" }, { @@ -701,20 +811,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-01-07T16:49:33+00:00" }, { @@ -788,20 +884,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-01-07T17:09:11+00:00" }, { @@ -871,20 +953,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-01-07T16:49:33+00:00" }, { @@ -950,20 +1018,6 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-01-07T16:49:33+00:00" } ], @@ -976,6 +1030,5 @@ "platform": { "php": "^7.2|^8" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } diff --git a/nexus/Imdb/Imdb.php b/nexus/Imdb/Imdb.php new file mode 100644 index 00000000..421c20d2 --- /dev/null +++ b/nexus/Imdb/Imdb.php @@ -0,0 +1,150 @@ +cachedir = ROOT_PATH . 'imdb/cache'; + $config->photodir = ROOT_PATH . 'imdb/pic_imdb'; + $config->photoroot = 'pic_imdb'; + $this->config = $config; + } + + public function renderDetailsPageDescription($torrentId, $imdbId) + { + $movie = new Title($imdbId, $this->config); + $country = $movie->country (); + $director = $movie->director(); + $creator = $movie->creator(); // For TV series + $write = $movie->writing(); + $produce = $movie->producer(); + $cast = $movie->cast(); +// $plot = $movie->plot (); + $plot_outline = $movie->plotoutline(); + $compose = $movie->composer(); + $gen = $movie->genres(); + //$comment = $movie->comment(); + $similiar_movies = $movie->similiar_movies(); + + if (($photo_url = $movie->photo_localurl() ) != FALSE) + $smallth = "\"poster\""; + else + $smallth = "\"no"; + + $autodata = 'https://www.imdb.com/title/tt'.$thenumbers."
------------------------------------------------------------------------------------------------------------------------------------
\n"; + $autodata .= "".$lang_details['text_information']."
\n"; + $autodata .= "------------------------------------------------------------------------------------------------------------------------------------

\n"; + $autodata .= "". $lang_details['text_title']."" . "".$movie->title ()."
\n"; + $autodata .= "".$lang_details['text_also_known_as'].""; + + $temp = ""; + foreach ($movie->alsoknow() as $ak) + { +// $temp .= $ak["title"].$ak["year"]. ($ak["country"] != "" ? " (".$ak["country"].")" : "") . ($ak["comment"] != "" ? " (" . $ak["comment"] . ")" : "") . ", "; + $temp .= $ak["title"] . ", "; + } + $autodata .= rtrim(trim($temp), ","); + $runtimes = str_replace(" min",$lang_details['text_mins'], $movie->runtime_all()); + $autodata .= "
\n".$lang_details['text_year']."" . "".$movie->year ()."
\n"; + $autodata .= "".$lang_details['text_runtime']."".$runtimes."
\n"; + $autodata .= "".$lang_details['text_votes']."" . "".$movie->votes ()."
\n"; + $autodata .= "".$lang_details['text_rating']."" . "".$movie->rating ()."
\n"; + $autodata .= "".$lang_details['text_language']."" . "".$movie->language ()."
\n"; + $autodata .= "".$lang_details['text_country'].""; + + $temp = ""; + for ($i = 0; $i < count ($country); $i++) + { + $temp .="$country[$i], "; + } + $autodata .= rtrim(trim($temp), ","); + + $autodata .= "
\n".$lang_details['text_all_genres'].""; + $temp = ""; + for ($i = 0; $i < count($gen); $i++) + { + $temp .= "$gen[$i], "; + } + $autodata .= rtrim(trim($temp), ","); + + $autodata .= "
\n".$lang_details['text_tagline']."" . "".$movie->tagline ()."
\n"; + if ($director){ + $autodata .= "".$lang_details['text_director'].""; + $temp = ""; + for ($i = 0; $i < count ($director); $i++) + { + $temp .= "" . $director[$i]["name"] . ", "; + } + $autodata .= rtrim(trim($temp), ","); + } + elseif ($creator) + $autodata .= "".$lang_details['text_creator']."".$creator; + + $autodata .= "
\n".$lang_details['text_written_by'].""; + $temp = ""; + for ($i = 0; $i < count ($write); $i++) + { + $temp .= "" . "".$write[$i]["name"]."" . ", "; + } + $autodata .= rtrim(trim($temp), ","); + + $autodata .= "
\n".$lang_details['text_produced_by'].""; + $temp = ""; + for ($i = 0; $i < count ($produce); $i++) + { + $temp .= "" . "".$produce[$i]["name"]."" . ", "; + } + $autodata .= rtrim(trim($temp), ","); + + $autodata .= "
\n".$lang_details['text_music'].""; + $temp = ""; + for ($i = 0; $i < count($compose); $i++) + { + $temp .= "" . "".$compose[$i]["name"]."" . ", "; + } + $autodata .= rtrim(trim($temp), ","); + + $autodata .= "

\n\n------------------------------------------------------------------------------------------------------------------------------------
\n"; + $autodata .= "".$lang_details['text_plot_outline']."
\n"; + $autodata .= "------------------------------------------------------------------------------------------------------------------------------------
"; + +// if(count($plot) == 0) +// { +// $autodata .= "
\n".$plot_outline; +// } +// else +// { +// for ($i = 0; $i < count ($plot); $i++) +// { +// $autodata .= "
\n. "; +// $autodata .= $plot[$i]; +// } +// } + if (!empty($plot_outline)) { + $autodata .= "
\n".$plot_outline; + } + + + $autodata .= "

\n\n------------------------------------------------------------------------------------------------------------------------------------
\n"; + $autodata .= "".$lang_details['text_cast']."
\n"; + $autodata .= "------------------------------------------------------------------------------------------------------------------------------------

\n"; + + for ($i = 0; $i < count ($cast); $i++) + { +// if ($i > 9) +// { +// break; +// } + $autodata .= ". " . "" . $cast[$i]["name"] . " " .$lang_details['text_as']."" . "".$cast[$i]["role"]."" . "
\n"; + } + + } +} \ No newline at end of file diff --git a/nexus/PTGen/PTGen.php b/nexus/PTGen/PTGen.php index 6aa2c3eb..1cd088f9 100644 --- a/nexus/PTGen/PTGen.php +++ b/nexus/PTGen/PTGen.php @@ -14,14 +14,6 @@ class PTGen { private $apiPoint; - const FORMAT_HTML = 1; - const FORMAT_JSON = 2; - - private static $formatText = [ - self::FORMAT_HTML => 'HTML', - self::FORMAT_JSON => 'json', - ]; - const SITE_DOUBAN = 'douban'; const SITE_IMDB = 'imdb'; const SITE_BANGUMI = 'bangumi'; @@ -57,24 +49,39 @@ class PTGen $this->apiPoint = $apiPoint; } - public function generate(string $url): array + public function generate(string $url, bool $withoutCache = false): array + { + $parsed = $this->parse($url); + $targetUrl = sprintf('%s/?site=%s&sid=%s', trim($this->apiPoint, '/'), $parsed['site'] , $parsed['id']); + return $this->request($targetUrl, $withoutCache); + } + + public function parse(string $url): array { foreach (self::$validSites as $site => $info) { if (preg_match($info['url_pattern'], $url, $matches)) { - $targetUrl = sprintf('%s/?site=%s&sid=%s', trim($this->apiPoint, '/'), $site , $matches[1]); - return $this->request($targetUrl); + return [ + 'site' => $site, + 'url' => $matches[0], + 'id' => $matches[1] + ]; } } throw new PTGenException("invalid url: $url"); } - private function buildDetailsPageTableRow($ptGenArr, $site) + private function buildDetailsPageTableRow($torrentId, $ptGenArr, $site) { global $lang_details; $ptGenFormatted = $ptGenArr['format']; $prefix = sprintf("[img]%s[/img]\n", $ptGenArr['poster']); $ptGenFormatted = mb_substr($ptGenFormatted, mb_strlen($prefix, 'utf-8') + 1); $ptGenFormatted = format_comment($ptGenFormatted); + $ptGenFormatted .= sprintf( + '%s%s%s%s', + $lang_details['text_information_updated_at'], date('Y-m-d H:i:s', intval($ptGenArr['generate_at'] / 1000)), $lang_details['text_might_be_outdated'], + $torrentId, $site, $lang_details['text_here_to_update'] + ); $titleShowOrHide = $lang_details['title_show_or_hide'] ?? ''; $id = 'pt-gen-' . $site; $html = <<get_value($cacheKey); - if ($cache) { - do_log("$logPrefix, from cache"); - return $cache; + $cacheKey = $this->getApiPointResultCacheKey($url); + if (!$withoutCache) { + $cache = $Cache->get_value($cacheKey); + if ($cache) { + do_log("$logPrefix, from cache"); + return $cache; + } } $http = new Client(); $response = $http->get($url, ['timeout' => 10]); @@ -136,9 +145,21 @@ HTML; throw new PTGenException($msg); } $Cache->cache_value($cacheKey, $bodyArr, 24 * 3600); + do_log("$logPrefix, success get from api point"); return $bodyArr; } + public function deleteApiPointResultCache($url) + { + global $Cache; + $Cache->delete_value($this->getApiPointResultCacheKey($url)); + } + + private function getApiPointResultCacheKey($url) + { + return __METHOD__ . "_$url"; + } + public function renderUploadPageFormInput($ptGen = '') { global $lang_functions; @@ -153,7 +174,7 @@ HTML; return $html; } - public function renderDetailsPageDescription(array $torrentPtGenArr): array + public function renderDetailsPageDescription($torrentId, array $torrentPtGenArr): array { $html = ''; $jsonArr = []; @@ -169,14 +190,14 @@ HTML; 'link' => $link, 'data' => $data, ]; - $html .= $this->buildDetailsPageTableRow($data, $site); + $html .= $this->buildDetailsPageTableRow($torrentId, $data, $site); } else { $ptGenArr = $this->generate($torrentPtGenArr[$site]['link']); $jsonArr[$site] = [ 'link' => $link, 'data' => $ptGenArr, ]; - $html .= $this->buildDetailsPageTableRow($ptGenArr, $site); + $html .= $this->buildDetailsPageTableRow($torrentId, $ptGenArr, $site); if (!$update) { $update = true; } diff --git a/public/details.php b/public/details.php index cfb5804f..87097f75 100644 --- a/public/details.php +++ b/public/details.php @@ -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 ""; stdhead($lang_details['head_comments_for_torrent']."\"" . $row["name"] . "\""); print("

".$lang_details['text_comments_for']."" . htmlspecialchars($row["name"]) . "

\n"); } + if (!empty($torrentUpdate)) { + sql_query("UPDATE torrents SET " . join(",", $torrentUpdate) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__); + } // -----------------COMMENT SECTION ---------------------// if ($CURUSER['showcomment'] != 'no'){ diff --git a/public/retriver.php b/public/retriver.php index f8918c79..aa8ce165 100644 --- a/public/retriver.php +++ b/public/retriver.php @@ -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!"); diff --git a/public/takeedit.php b/public/takeedit.php index ac7c4830..e7e9a54a 100644 --- a/public/takeedit.php +++ b/public/takeedit.php @@ -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__); diff --git a/public/takeupload.php b/public/takeupload.php index 88df698a..2ba58cc6 100644 --- a/public/takeupload.php +++ b/public/takeupload.php @@ -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']);