mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
improve PTGen
This commit is contained in:
@@ -331,4 +331,18 @@ class RedisCache {
|
||||
{
|
||||
return is_numeric($value) ? $value : unserialize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the redis client
|
||||
*
|
||||
* @date 2021/1/15
|
||||
* @return Redis
|
||||
*/
|
||||
public function getRedis()
|
||||
{
|
||||
if ($this->getIsEnabled()) {
|
||||
return $this->redis;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
"require": {
|
||||
"php": "^7.2|^8",
|
||||
"swiftmailer/swiftmailer": "^6.2",
|
||||
"guzzlehttp/guzzle": "^7.2"
|
||||
"guzzlehttp/guzzle": "~6.0"
|
||||
}
|
||||
}
|
||||
|
||||
195
composer.lock
generated
195
composer.lock
generated
@@ -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": "1f39d5c11cefe6eb838c17586c056ce7",
|
||||
"content-hash": "5e27df0bf1d474656f062b3f264353ee",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
@@ -72,6 +72,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -136,20 +150,26 @@
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/egulias",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-29T14:50:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.2.0",
|
||||
"version": "6.5.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79"
|
||||
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0aa74dfb41ae110835923ef10a9d803a22d50e79",
|
||||
"reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
||||
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@@ -160,29 +180,23 @@
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.4",
|
||||
"guzzlehttp/psr7": "^1.7",
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-client": "^1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-client-implementation": "1.0"
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.6.1",
|
||||
"php": ">=5.5",
|
||||
"symfony/polyfill-intl-idn": "^1.17.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"php-http/client-integration-tests": "^3.0",
|
||||
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
||||
"psr/log": "^1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Required for CURL handler support",
|
||||
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.1-dev"
|
||||
"dev-master": "6.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -202,11 +216,6 @@
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com",
|
||||
"homepage": "https://sagikazarmark.hu"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
@@ -217,12 +226,10 @@
|
||||
"framework",
|
||||
"http",
|
||||
"http client",
|
||||
"psr-18",
|
||||
"psr-7",
|
||||
"rest",
|
||||
"web service"
|
||||
],
|
||||
"time": "2020-10-10T11:47:56+00:00"
|
||||
"time": "2020-06-16T21:01:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
@@ -358,61 +365,6 @@
|
||||
],
|
||||
"time": "2020-09-30T07:37:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-client",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-client.git",
|
||||
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
|
||||
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0 || ^8.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Client\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP clients",
|
||||
"homepage": "https://github.com/php-fig/http-client",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-client",
|
||||
"psr",
|
||||
"psr-18"
|
||||
],
|
||||
"time": "2020-06-29T06:28:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
@@ -580,6 +532,16 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -649,6 +611,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -725,6 +701,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -798,6 +788,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -867,6 +871,20 @@
|
||||
"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"
|
||||
},
|
||||
{
|
||||
@@ -932,6 +950,20 @@
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -944,5 +976,6 @@
|
||||
"platform": {
|
||||
"php": "^7.2|^8"
|
||||
},
|
||||
"platform-dev": []
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
||||
@@ -2594,7 +2594,7 @@ function stdfoot() {
|
||||
if ($enablesqldebug_tweak == 'yes' && get_user_class() >= $sqldebug_tweak) {
|
||||
print("<div id=\"sql_debug\">SQL query list: <ul>");
|
||||
foreach($query_name as $query) {
|
||||
print(sprintf('<li>%s [%s ms]</li>', htmlspecialchars($query['query']), $query['time'] * 1000));
|
||||
print(sprintf('<li>%s [%s]</li>', htmlspecialchars($query['query']), $query['time']));
|
||||
}
|
||||
print("</ul>");
|
||||
print("Redis key read: <ul>");
|
||||
|
||||
@@ -70,9 +70,10 @@ function sql_query($query)
|
||||
$begin = microtime(true);
|
||||
global $query_name;
|
||||
$result = mysql_query($query);
|
||||
$end = microtime(true);
|
||||
$query_name[] = [
|
||||
'query' => $query,
|
||||
'time' => microtime(true) - $begin,
|
||||
'time' => sprintf('%.3f ms', ($end - $begin) * 1000),
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -288,6 +288,12 @@ $lang_functions = array
|
||||
'text_thirty_percent_down' => "30%",
|
||||
'text_please_download_something_within' => "请在",
|
||||
'text_inactive_account_be_deleted' => "内做些下载。没有流量的用户会被删除账号。",
|
||||
'row_pt_gen_douban_url' => "PT-Gen douban 链接",
|
||||
'text_pt_gen_douban_url_note' => "(来自 <strong><a href=\"https://www.douban.com/\">douban</a></strong> 的链接。如电影 <b>Transformers</b> 的链接是<b> https://movie.douban.com/subject/1794171/</b>)",
|
||||
'row_pt_gen_imdb_url' => "PT-Gen imdb 链接",
|
||||
'text_pt_gen_imdb_url_note' => "(来自 <strong><a href=\"https://www.imdb.com//\">imdb</a></strong> 的链接。如电影 <b>Transformers</b> 的链接是<b> https://www.imdb.com/title/tt0418279/</b>)",
|
||||
'row_pt_gen_bangumi_url' => "PT-Gen bangumi 链接",
|
||||
'text_pt_gen_bangumi_url_note' => "(来自 <strong><a href=\"https://bangumi.tv/\">bangumi</a></strong> 的链接。如动画 <b>星际牛仔</b> 的链接是<b> https://bangumi.tv/subject/253/</b>)",
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -393,6 +393,8 @@ $lang_settings = array
|
||||
'text_show_classic_note' => "默认'否'。在首页显示经典资源。只有指定的总版主或以上等级能够挑选热门资源。",
|
||||
'row_enable_imdb_system' => "开启IMDb系统",
|
||||
'text_imdb_system_note' => "默认'是'。全局IMDb系统设定。",
|
||||
'row_enable_pt_gen_system' => '开启 PT-Gen 系统',
|
||||
'text_enable_pt_gen_system_note' => "默认'是'。全局 PT-Gen 系统设定。",
|
||||
'row_enable_school_system' => "开启学校系统",
|
||||
'text_school_system_note' => "默认'否'。如果对这项功能不清楚,<font class=striking><b>不要</b></font>开启它。",
|
||||
'row_restrict_email_domain' => "限制邮箱域",
|
||||
|
||||
@@ -288,6 +288,11 @@ $lang_functions = array
|
||||
'text_thirty_percent_down' => "30%",
|
||||
'text_please_download_something_within' => "請在",
|
||||
'text_inactive_account_be_deleted' => "內做些下載。沒有流量的用戶會被移除賬號。",
|
||||
'text_pt_gen_douban_url_note' => "(來自 <strong><a href=\"https://www.douban.com/\">douban</a></strong> 的鏈接。如電影 <b>Transformers</b> 的鏈接是<b> https://movie.douban.com/subject/1794171/</b>)",
|
||||
'row_pt_gen_imdb_url' => "PT-Gen imdb 鏈接",
|
||||
'text_pt_gen_imdb_url_note' => "(來自 <strong><a href=\"https://www.imdb.com//\">imdb</a></strong> 的鏈接。如電影 <b>Transformers</b> 的鏈接是<b> https://www.imdb.com/title/tt0418279/</b>)",
|
||||
'row_pt_gen_bangumi_url' => "PT-Gen bangumi 鏈接",
|
||||
'text_pt_gen_bangumi_url_note' => "(來自 <strong><a href=\"https://bangumi.tv/\">bangumi</a></strong> 的鏈接。如動畫 <b>星際牛仔</b> 的鏈接是<b> https://bangumi.tv/subject/253/</b>)",
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -393,7 +393,9 @@ $lang_settings = array
|
||||
'row_show_classic' => "察看經典資源",
|
||||
'text_show_classic_note' => "預設'否'。在首頁察看經典資源。只有指定的總版主或以上等級能夠挑揀熱門資源。",
|
||||
'row_enable_imdb_system' => "開啟IMDb系統",
|
||||
'text_imdb_system_note' => "預設'是'。全域IMDb系統設定。",
|
||||
'text_enable_pt_gen_system_note' => "預設'是'。全域IMDb系統設定。",
|
||||
'row_enable_pt_gen_system' => '開啟 PT-Gen 系統',
|
||||
'text_enable_pt_gen_note' => "默認'是'。全局 PT-Gen 系統設定。",
|
||||
'row_enable_school_system' => "開啟學校系統",
|
||||
'text_school_system_note' => "預設'否'。如果對這項功能不清楚,<font class=striking><b>不要</b></font>開啟它。",
|
||||
'row_restrict_email_domain' => "限制郵箱域",
|
||||
|
||||
@@ -288,6 +288,12 @@ $lang_functions = array
|
||||
'text_thirty_percent_down' => "30%",
|
||||
'text_please_download_something_within' => "Please download something within ",
|
||||
'text_inactive_account_be_deleted' => ". Inactive accounts (with no transfer amount) will be deleted.",
|
||||
'row_pt_gen_douban_url' => "PT-Gen douban link",
|
||||
'text_pt_gen_douban_url_note' => "(URL taken from <strong><a href=\"https://www.douban.com/\">douban</a></strong>. e.g. for movie <b>Transformers</b> the URL is <b> https://movie.douban.com/subject/1794171//</b>)",
|
||||
'row_pt_gen_imdb_url' => "PT-Gen imdb link",
|
||||
'text_pt_gen_imdb_url_note' => "(URL taken from <strong><a href=\"https://www.imdb.com/\">imdb</a></strong>. e.g. for movie <b>Transformers</b> the URL is <b> https://www.imdb.com/title/tt0418279/</b>)",
|
||||
'row_pt_gen_bangumi_url' => "PT-Gen bangumi link",
|
||||
'text_pt_gen_bangumi_url_note' => "(URL taken from <strong><a href=\"https://bangumi.tv/\">bangumi</a></strong>. e.g. for animation <b>Cowboy Bebop</b> the URL is <b>https://bangumi.tv/subject/253/</b>)",
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -393,6 +393,8 @@ $lang_settings = array
|
||||
'text_show_classic_note' => "Default 'no'. Show classic resources on main page. Only designated moderators or above can pick classic resources.",
|
||||
'row_enable_imdb_system' => "Enable IMDb system",
|
||||
'text_imdb_system_note' => "Default 'yes'. System-wide IMDb info setting.",
|
||||
'text_enable_pt_gen_system_note' => 'Enable PT-Gen system',
|
||||
'text_enable_pt_gen_note' => "Default 'yes'. System-wide PT-Gen info setting.",
|
||||
'row_enable_school_system' => "Enable school system",
|
||||
'text_school_system_note' => "Default 'no'. <font class=striking><b>DO NOT</b></font> enable this unless you know what you are doing!",
|
||||
'row_restrict_email_domain' => "Restrict Email Domain",
|
||||
|
||||
@@ -14,19 +14,30 @@ 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';
|
||||
|
||||
private static $validSites = [
|
||||
self::SITE_DOUBAN => [
|
||||
'url_pattern' => '/(?:https?:\/\/)?(?:(?:movie|www)\.)?douban\.com\/(?:subject|movie)\/(\d+)\/?/',
|
||||
],
|
||||
self::SITE_IMDB => [
|
||||
'url_pattern' => '/(?:https?:\/\/)?(?:www\.)?imdb\.com\/title\/(tt\d+)\/?/',
|
||||
'home_page' => 'https://www.imdb.com/',
|
||||
],
|
||||
self::SITE_DOUBAN => [
|
||||
'url_pattern' => '/(?:https?:\/\/)?(?:(?:movie|www)\.)?douban\.com\/(?:subject|movie)\/(\d+)\/?/',
|
||||
'home_page' => 'https://www.douban.com/',
|
||||
],
|
||||
self::SITE_BANGUMI => [
|
||||
'url_pattern' => '/(?:https?:\/\/)?(?:bgm\.tv|bangumi\.tv|chii\.in)\/subject\/(\d+)\/?/',
|
||||
'home_page' => 'https://bangumi.tv/',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -46,27 +57,61 @@ class PTGen
|
||||
$this->apiPoint = $apiPoint;
|
||||
}
|
||||
|
||||
public function generateDouban(string $url): string
|
||||
public function generate(string $url): array
|
||||
{
|
||||
return $this->request($url, self::SITE_DOUBAN);
|
||||
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);
|
||||
}
|
||||
}
|
||||
throw new PTGenException("invalid url: $url");
|
||||
}
|
||||
|
||||
public function generateImdb(string $url): string
|
||||
private function buildDetailsPageTableRow($ptGenArr, $site)
|
||||
{
|
||||
return $this->request($url, self::SITE_IMDB);
|
||||
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);
|
||||
$titleShowOrHide = $lang_details['title_show_or_hide'] ?? '';
|
||||
$id = 'pt-gen-' . $site;
|
||||
$html = <<<HTML
|
||||
<tr>
|
||||
<td class="rowhead">
|
||||
<a href="javascript: klappe_ext('{$id}')">
|
||||
<span class="nowrap">
|
||||
<img id="pic{$id}" class="minus" src="pic/trans.gif" alt="Show/Hide" title="{$titleShowOrHide}" />
|
||||
PT-Gen-{$site}
|
||||
</span>
|
||||
</a>
|
||||
<div id="poster{$id}">
|
||||
<img src="{$ptGenArr['poster']}" width="105" onclick="Preview(this);" alt="poster" />
|
||||
</div>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
<div id="k{$id}">
|
||||
{$ptGenFormatted}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
HTML;
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function generateBangumi(string $url): string
|
||||
private function request(string $url): array
|
||||
{
|
||||
return $this->request($url, self::SITE_BANGUMI);
|
||||
}
|
||||
|
||||
private function request(string $url, string $site): string
|
||||
{
|
||||
$url = $this->buildUrl($url, $site);
|
||||
global $Cache;
|
||||
$logPrefix = "url: $url";
|
||||
$cacheKey = __METHOD__ . ":$url";
|
||||
$cache = $Cache->get_value($cacheKey);
|
||||
if ($cache) {
|
||||
do_log("$logPrefix, from cache");
|
||||
return $cache;
|
||||
}
|
||||
$http = new Client();
|
||||
$response = $http->get($url, ['timeout' => 5]);
|
||||
$response = $http->get($url, ['timeout' => 10]);
|
||||
$statusCode = $response->getStatusCode();
|
||||
if ($statusCode != 200) {
|
||||
$msg = "api point response http status code: $statusCode";
|
||||
@@ -90,20 +135,53 @@ class PTGen
|
||||
do_log("$logPrefix, response: $bodyString");
|
||||
throw new PTGenException($msg);
|
||||
}
|
||||
|
||||
return $bodyString;
|
||||
$Cache->cache_value($cacheKey, $bodyArr, 24 * 3600);
|
||||
return $bodyArr;
|
||||
}
|
||||
|
||||
private function buildUrl(string $url, string $site): string
|
||||
public function renderUploadPageFormInput($ptGen = '')
|
||||
{
|
||||
if (!isset(self::$validSites[$site])) {
|
||||
throw new PTGenException("not support site: $site, only support: " . implode(", ", array_keys(self::$validSites)));
|
||||
global $lang_functions;
|
||||
$html = '';
|
||||
$ptGen = (array)json_decode($ptGen, true);
|
||||
foreach (self::$validSites as $site => $info) {
|
||||
$value = $ptGen[$site]['link'] ?? '';
|
||||
$x = $lang_functions["row_pt_gen_{$site}_url"];
|
||||
$y = "<input type=\"text\" style=\"width: 650px;\" name=\"pt_gen[{$site}][link]\" value=\"{$value}\" /><br /><font class=\"medium\">".$lang_functions["text_pt_gen_{$site}_url_note"]."</font>";
|
||||
$html .= tr($x, $y, 1);
|
||||
}
|
||||
$siteInfo = self::$validSites[$site];
|
||||
$isUrlValid = preg_match($siteInfo['url_pattern'], $url, $matches);
|
||||
if (!$isUrlValid) {
|
||||
throw new PTGenException("invalid url: $url");
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderDetailsPageDescription(array $torrentPtGenArr): array
|
||||
{
|
||||
$html = '';
|
||||
$jsonArr = [];
|
||||
$update = false;
|
||||
foreach (self::$validSites as $site => $info) {
|
||||
if (empty($torrentPtGenArr[$site]['link'])) {
|
||||
continue;
|
||||
}
|
||||
$link = $torrentPtGenArr[$site]['link'];
|
||||
$data = $torrentPtGenArr[$site]['data'] ?? [];
|
||||
if (!empty($data)) {
|
||||
$jsonArr[$site] = [
|
||||
'link' => $link,
|
||||
'data' => $data,
|
||||
];
|
||||
$html .= $this->buildDetailsPageTableRow($data, $site);
|
||||
} else {
|
||||
$ptGenArr = $this->generate($torrentPtGenArr[$site]['link']);
|
||||
$jsonArr[$site] = [
|
||||
'link' => $link,
|
||||
'data' => $ptGenArr,
|
||||
];
|
||||
$html .= $this->buildDetailsPageTableRow($ptGenArr, $site);
|
||||
if (!$update) {
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sprintf('%s/?site=%s&sid=%s', trim($this->apiPoint, '/'), $site , $matches[1]);
|
||||
return ['json_arr' => $jsonArr, 'html' => $html, 'update' => $update];
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ stdhead($lang_bitbucketupload['head_avatar_upload']);
|
||||
<table border=1 cellspacing=0 cellpadding=5>
|
||||
<?php
|
||||
|
||||
if(!is_writable("$bitbucket"))
|
||||
if(!is_writable(ROOT_PATH . "$bitbucket"))
|
||||
print("<tr><td align=left colspan=2>".$lang_bitbucketupload['text_upload_directory_unwritable']."</tr></td>");
|
||||
print("<tr><td align=left colspan=2>".$lang_bitbucketupload['text_disclaimer']."$scaleh".$lang_bitbucketupload['text_disclaimer_two']."$scalew".$lang_bitbucketupload['text_disclaimer_three'].number_format($maxfilesize).$lang_bitbucketupload['text_disclaimer_four']);
|
||||
?>
|
||||
|
||||
@@ -13,7 +13,7 @@ int_check($id);
|
||||
if (!isset($id) || !$id)
|
||||
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, 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")
|
||||
$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);
|
||||
|
||||
@@ -394,6 +394,14 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($row['pt_gen'])) {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
$ptGenResult = $ptGen->renderDetailsPageDescription(json_decode($row['pt_gen'], true));
|
||||
if ($ptGenResult['update']) {
|
||||
//@todo do some update
|
||||
}
|
||||
echo $ptGenResult['html'];
|
||||
}
|
||||
if ($imdb_id)
|
||||
{
|
||||
$where_area = " url = " . sqlesc((int)$imdb_id) ." AND torrents.id != ".sqlesc($id);
|
||||
|
||||
@@ -35,7 +35,7 @@ $showstandard = (get_searchbox_value($sectionmode, 'showstandard') || ($allowmov
|
||||
$showprocessing = (get_searchbox_value($sectionmode, 'showprocessing') || ($allowmove && get_searchbox_value($othermode, 'showprocessing'))); //whether show processings or not
|
||||
$showteam = (get_searchbox_value($sectionmode, 'showteam') || ($allowmove && get_searchbox_value($othermode, 'showteam'))); //whether show teams or not
|
||||
$showaudiocodec = (get_searchbox_value($sectionmode, 'showaudiocodec') || ($allowmove && get_searchbox_value($othermode, 'showaudiocodec'))); //whether show audio codecs or not
|
||||
|
||||
$settingMain = get_setting('main');
|
||||
stdhead($lang_edit['head_edit_torrent'] . "\"". $row["name"] . "\"");
|
||||
|
||||
if (!isset($CURUSER) || ($CURUSER["id"] != $row["owner"] && get_user_class() < $torrentmanage_class)) {
|
||||
@@ -54,6 +54,10 @@ else {
|
||||
tr($lang_edit['row_small_description'], "<input type=\"text\" style=\"width: 650px;\" name=\"small_descr\" value=\"" . htmlspecialchars($row["small_descr"]) . "\" />", 1);
|
||||
|
||||
get_external_tr($row["url"]);
|
||||
if ($settingMain['enable_pt_gen_system'] == 'yes') {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
echo $ptGen->renderUploadPageFormInput($row['pt_gen']);
|
||||
}
|
||||
|
||||
if ($enablenfo_main=='yes')
|
||||
tr($lang_edit['row_nfo_file'], "<font class=\"medium\"><input type=\"radio\" name=\"nfoaction\" value=\"keep\" checked=\"checked\" />".$lang_edit['radio_keep_current'].
|
||||
|
||||
@@ -49,7 +49,17 @@ $notice = "<h1 align=\"center\"><a class=\"faqlink\" href=\"settings.php\">".$la
|
||||
if ($action == 'savesettings_main') // save main
|
||||
{
|
||||
stdhead($lang_settings['head_save_main_settings']);
|
||||
$validConfig = array('site_online','max_torrent_size','announce_interval', 'annintertwoage', 'annintertwo', 'anninterthreeage', 'anninterthree', 'signup_timeout','minoffervotes','offervotetimeout','offeruptimeout','maxsubsize','postsperpage', 'topicsperpage', 'torrentsperpage', 'maxnewsnum','max_dead_torrent_time','maxusers','torrent_dir', 'iniupload','SITEEMAIL', 'ACCOUNTANTID', 'ALIPAYACCOUNT', 'PAYPALACCOUNT', 'SLOGAN', 'icplicense', 'autoclean_interval_one', 'autoclean_interval_two', 'autoclean_interval_three','autoclean_interval_four', 'autoclean_interval_five','reportemail','invitesystem','registration','showhotmovies','showclassicmovies','showimdbinfo', 'enablenfo', 'enableschool','restrictemail','showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket', 'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem','maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start','startsubid', 'logo', 'use_cron_trigger_cleanup', 'showlastxforumposts');
|
||||
$validConfig = array(
|
||||
'site_online','max_torrent_size','announce_interval', 'annintertwoage', 'annintertwo', 'anninterthreeage', 'anninterthree', 'signup_timeout',
|
||||
'minoffervotes','offervotetimeout','offeruptimeout','maxsubsize','postsperpage', 'topicsperpage', 'torrentsperpage', 'maxnewsnum',
|
||||
'max_dead_torrent_time','maxusers','torrent_dir', 'iniupload','SITEEMAIL', 'ACCOUNTANTID', 'ALIPAYACCOUNT', 'PAYPALACCOUNT', 'SLOGAN',
|
||||
'icplicense', 'autoclean_interval_one', 'autoclean_interval_two', 'autoclean_interval_three','autoclean_interval_four', 'autoclean_interval_five',
|
||||
'reportemail','invitesystem','registration','showhotmovies','showclassicmovies','showimdbinfo', 'enable_pt_gen_system', 'enablenfo', 'enableschool','restrictemail',
|
||||
'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket',
|
||||
'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem',
|
||||
'maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start',
|
||||
'startsubid', 'logo', 'use_cron_trigger_cleanup', 'showlastxforumposts'
|
||||
);
|
||||
GetVar($validConfig);
|
||||
$MAIN = [];
|
||||
foreach($validConfig as $config) {
|
||||
@@ -580,6 +590,7 @@ elseif ($action == 'mainsettings') // main settings
|
||||
yesorno($lang_settings['row_show_hot'],'showhotmovies', $MAIN['showhotmovies'], $lang_settings['text_show_hot_note']);
|
||||
yesorno($lang_settings['row_show_classic'],'showclassicmovies', $MAIN['showclassicmovies'], $lang_settings['text_show_classic_note']);
|
||||
yesorno($lang_settings['row_enable_imdb_system'],'showimdbinfo', $MAIN['showimdbinfo'], $lang_settings['text_imdb_system_note']);
|
||||
yesorno($lang_settings['row_enable_pt_gen_system'],'enable_pt_gen_system', $MAIN['enable_pt_gen_system'], $lang_settings['text_enable_pt_gen_system_note']);
|
||||
yesorno($lang_settings['row_enable_nfo'],'enablenfo', $MAIN['enablenfo'], $lang_settings['text_enable_nfo_note']);
|
||||
yesorno($lang_settings['row_enable_school_system'],'enableschool', $MAIN['enableschool'], $lang_settings['text_school_system_note']);
|
||||
yesorno($lang_settings['row_restrict_email_domain'],'restrictemail', $MAIN['restrictemail'], $lang_settings['text_restrict_email_domain_note']);
|
||||
|
||||
@@ -167,6 +167,15 @@ if(get_user_class()>=$torrentmanage_class && $CURUSER['picker'] == 'yes')
|
||||
$updateset[] = "picktime = ". sqlesc(date("Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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__);
|
||||
|
||||
if($CURUSER["id"] == $row["owner"])
|
||||
|
||||
@@ -329,8 +329,14 @@ foreach ($promotionrules_torrent as $rule)
|
||||
}
|
||||
}
|
||||
|
||||
$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) 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). ")");
|
||||
/**
|
||||
* add PT-Gen
|
||||
* @since 1.6
|
||||
*/
|
||||
$ptGen = sqlesc(json_encode($_POST['pt_gen'] ?? []));
|
||||
|
||||
$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)");
|
||||
if (!$ret) {
|
||||
if (mysql_errno() == 1062)
|
||||
bark($lang_takeupload['std_torrent_existed']);
|
||||
@@ -345,7 +351,7 @@ foreach ($filelist as $file) {
|
||||
}
|
||||
|
||||
//move_uploaded_file($tmpname, "$torrent_dir/$id.torrent");
|
||||
$fp = fopen("$torrent_dir/$id.torrent", "w");
|
||||
$fp = fopen(ROOT_PATH . "$torrent_dir/$id.torrent", "w");
|
||||
if ($fp)
|
||||
{
|
||||
@fwrite($fp, benc($dict), strlen(benc($dict)));
|
||||
|
||||
@@ -29,6 +29,8 @@ $showprocessing = (($allowtorrents && get_searchbox_value($brsectiontype, 'showp
|
||||
$showteam = (($allowtorrents && get_searchbox_value($brsectiontype, 'showteam')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showteam'))); //whether show teams or not
|
||||
$showaudiocodec = (($allowtorrents && get_searchbox_value($brsectiontype, 'showaudiocodec')) || ($allowspecial && get_searchbox_value($spsectiontype, 'showaudiocodec'))); //whether show languages or not
|
||||
|
||||
$settingMain = get_setting('main');
|
||||
|
||||
stdhead($lang_upload['head_upload']);
|
||||
?>
|
||||
<form id="compose" enctype="multipart/form-data" action="takeupload.php" method="post" name="upload">
|
||||
@@ -40,7 +42,7 @@ stdhead($lang_upload['head_upload']);
|
||||
<td class='colhead' colspan='2' align='center'>
|
||||
<?php echo $lang_upload['text_tracker_url'] ?>: <b><?php echo get_protocol_prefix() . $announce_urls[0]?></b>
|
||||
<?php
|
||||
if(!is_writable($torrent_dir))
|
||||
if(!is_writable(ROOT_PATH . $torrent_dir))
|
||||
print("<br /><br /><b>ATTENTION</b>: Torrent directory isn't writable. Please contact the administrator about this problem!");
|
||||
if(!$max_torrent_size)
|
||||
print("<br /><br /><b>ATTENTION</b>: Max. Torrent Size not set. Please contact the administrator about this problem!");
|
||||
@@ -57,8 +59,11 @@ stdhead($lang_upload['head_upload']);
|
||||
tr($lang_upload['row_torrent_name'], "<input type=\"text\" style=\"width: 650px;\" id=\"name\" name=\"name\" /><br /><font class=\"medium\">".$lang_upload['text_torrent_name_note']."</font>", 1);
|
||||
if ($smalldescription_main == 'yes')
|
||||
tr($lang_upload['row_small_description'], "<input type=\"text\" style=\"width: 650px;\" name=\"small_descr\" /><br /><font class=\"medium\">".$lang_upload['text_small_description_note']."</font>", 1);
|
||||
|
||||
get_external_tr();
|
||||
if ($settingMain['enable_pt_gen_system'] == 'yes') {
|
||||
$ptGen = new \Nexus\PTGen\PTGen();
|
||||
echo $ptGen->renderUploadPageFormInput("");
|
||||
}
|
||||
if ($enablenfo_main=='yes')
|
||||
tr($lang_upload['row_nfo_file'], "<input type=\"file\" class=\"file\" name=\"nfo\" /><br /><font class=\"medium\">".$lang_upload['text_only_viewed_by'].get_user_class_name($viewnfo_class,false,true,true).$lang_upload['text_or_above']."</font>", 1);
|
||||
print("<tr><td class=\"rowhead\" style='padding: 3px' valign=\"top\">".$lang_upload['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
|
||||
|
||||
Reference in New Issue
Block a user