v2.9.17-beta1

1. 缓存东南亚 season

警告:此beta版未经过实际测试
pull/10/head
david082321 4 years ago
parent dc537f5278
commit 92f6673991

Binary file not shown.

@ -8,9 +8,9 @@ $refresh_cache = 0;
// 判断登录状态
if ($member_type > 0) {
// pass
}else if (ACCESS_KEY == "") {
} else if (ACCESS_KEY == "") {
$member_type = 0; //未登录
}else{
} else {
// 判断大会员
$sqlco = "SELECT `due_date` FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
@ -29,10 +29,10 @@ $db_user=DB_USER;
$db_pass=DB_PASS;
$db_name=DB_NAME;
$dbh='mysql:host='.$db_host.';'.'dbname='.$db_name;
try{
try {
$dbh = new PDO($dbh,$db_user,$db_pass);
//echo '连接成功';
}catch(PDOException $e) {
} catch(PDOException $e) {
//pass
}
@ -73,7 +73,7 @@ function write_cache() {
if ($code == "0") {
$a = explode('mid=', $output);
$out = $a[0];
for($j=1; $j<count($a)-1; $j++) {
for ($j=1; $j<count($a)-1; $j++) {
//echo $a[$j];
$b = explode('orderid=', $a[$j]);
$out = $out.'orderid='.$b[1];
@ -86,11 +86,11 @@ function write_cache() {
}
$dbh -> exec($sql);
// 缓存地区错误
}else if (in_array(AREA, $SERVER_AREA)) {
} else if (in_array(AREA, $SERVER_AREA)) {
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('9999999999','".AREA."','".$member_type."','".CID."','".EP_ID."','$output')";
if ($code == "-10403") {// 10403 地区错误
$dbh -> exec($sql);
}else if ($code == "-404" && AREA == "th") {// 404 泰版地区错误
} else if ($code == "-404" && AREA == "th") {// 404 泰版地区错误
$dbh -> exec($sql);
}
}

@ -0,0 +1,67 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
// 参数
$refresh_cache_season = 0;
//pdo连接数据库
$db_host=DB_HOST;
$db_user=DB_USER;
$db_pass=DB_PASS;
$db_name=DB_NAME;
$dbh='mysql:host='.$db_host.';'.'dbname='.$db_name;
try {
$dbh = new PDO($dbh,$db_user,$db_pass);
//echo '连接成功';
} catch(PDOException $e) {
//pass
}
// 获取缓存
function get_cache_season() {
global $dbh;
global $member_type;
global $refresh_cache_season;
$ts = time();
$sqlco = "SELECT * FROM `cache` WHERE `area` = 'season' AND `type` = '0' AND `cid` = '0' AND `ep_id` = '".SS_ID."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$cache = $vnum['cache'];
$add_time = $vnum['add_time'];
$cache = str_replace("u0026","&",$cache);
if ($cache != "") {
if( (int)$add_time + CACHE_TIME_SEASON >= $ts) {
return $cache;
}else{
// 准备刷新缓存
$refresh_cache_season = 1;
return "";
}
}
return "";
}
// 写入缓存
function write_cache_season() {
global $dbh;
global $output;
global $refresh_cache_season;
$ts = time();
$array = json_decode($output, true);
$code = $array['code'];
if ($code == "0") {
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('$ts','season','0','0','".SS_ID."','$output')";
// 刷新缓存
if ($refresh_cache_season == 1) {
$sql = "UPDATE `cache` SET `add_time` = '$ts', `cache` = '$output' WHERE `area` = '".AREA."' AND `type` = '".$member_type."' AND `cid` = '".CID."' AND `ep_id` = '".EP_ID."';";
}
$dbh -> exec($sql);
// 缓存 404 错误
} else if ($code == "-404") {
$ts = $ts + CACHE_TIME_SEASON_404;
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('$ts','season','0','0','".SS_ID."','$output')";
$dbh -> exec($sql);
}
}
?>

@ -23,11 +23,14 @@ $cid_list = array();
// 缓存
define('SAVE_CACHE', 0); //开启缓存须配置MySQL。0 否, 1 是
define('CACHE_TIME', 10000); //缓存时长目前最长可到14400秒
define('CACHE_TIME', 60*60*3); //缓存时长目前最长可到14400秒
define('DB_HOST', 'localhost');
define('DB_USER', '这里改成登录的用户名'); //登录的用户名
define('DB_PASS', '登录的密码'); //登录的密码
define('DB_NAME', '数据库名称'); //数据库名称
// 缓存泰国 season
define('CACHE_TIME_SEASON', 60*60*24); //泰国 season 的缓存时长(秒)
define('CACHE_TIME_SEASON_404', 60*60*24*3); //泰国 season (返回404时的)缓存时长(秒)
// 服务器所在的地区
/*
@ -71,6 +74,7 @@ define('APPSEC', '560c52ccd288fed045859ed18bffd973');
define('ACCESS_KEY', @$_GET['access_key']);
define('CID', @$_GET['cid']);
define('EP_ID', @$_GET['ep_id']);
define('SS_ID', @$_GET['season_id']);
define('BILIROAMING_VERSION', @$_SERVER['HTTP_X_FROM_BILIROAMING']);
if (@$_GET['area'] == '' && BILIROAMING_VERSION == '') {
define('AREA', 'noarea');

@ -62,6 +62,8 @@ if (BILIROAMING_VERSION == "" && BILIROAMING == 1 && $path != "/pgc/player/web/p
$playurl = 0;
if ($path != "/intl/gateway/v2/app/search/type" && $path != "/intl/gateway/v2/app/subtitle" && $path != "/intl/gateway/v2/ogv/view/app/season") {
$playurl = 1;
} else if ($path == "/intl/gateway/v2/ogv/view/app/season") {
$playurl = 2;
}
// 鉴权
if ($playurl == 1) { //playurl
@ -73,13 +75,20 @@ if ($playurl == 1) { //playurl
if (ACCESS_KEY != "" && $playurl == 1) {
//include("resign.php");
}
// 获取缓存
// 获取缓存 (playurl)
if (SAVE_CACHE == 1 && $playurl == 1) {
include ("cache.php");
$cache = get_cache();
if ($cache != "") {
exit($cache);
}
// 获取缓存 (东南亚season)
} else if (SAVE_CACHE == 1 && $playurl == 2) {
include ("cache_season.php");
$cache = get_cache_season();
if ($cache != "") {
exit($cache);
}
}
// 指定ip回源
if (IP_RESOLVE == 1) {
@ -90,14 +99,16 @@ if (IP_RESOLVE == 1) {
$url = $host.$path."?".$query;
if (IP_RESOLVE == 1) {
$output = get_webpage($url,$host,$ip);
}else {
} else {
$output = get_webpage($url);
}
$output = str_replace("\u0026","&",$output);
print($output);
// 写入缓存
if (SAVE_CACHE == 1 && $playurl == 1) {
write_cache();
write_cache(); // 写入playurl
} else if (SAVE_CACHE == 1 && $playurl == 2) {
write_cache_season(); //写入东南亚season
}
function get_webpage($url,$host="",$ip="") {

Loading…
Cancel
Save