v2.9.11
1.  代码规范化
pull/6/head^2
david082321 4 years ago
parent c26b759e88
commit 7a538102fc

Binary file not shown.

Binary file not shown.

@ -1,66 +1,61 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
if (ACCESS_KEY != ""){ // access_key 存在
if (BLOCK_TYPE == "blacklist"){ // 黑名单鉴权
$url = "https://black.qimo.ink/?access_key=".ACCESS_KEY;
$out = get_webpage($url);
// 如果是黑名单
if ($out=="ban" || $baned == 1){
if (REPLACE_TYPE=="hlw" || REPLACE_TYPE=="tom" || REPLACE_TYPE=="xyy"){ // 替换成葫芦娃、猫和老鼠、喜羊羊
include ("replace.php");
replace();
}else {
exit(BLOCK_RETURN);
}
}
}else if (BLOCK_TYPE == "whitelist"){ // 白名单鉴权
if (SAVE_CACHE==1){ // 是否开启缓存
$uid = get_uid_fromsql(); // 从数据库获取
}else{
$uid = get_uid(); // 从API获取
}
// 是否在白名单内
if (!in_array($uid, $WHITELIST) || $baned == 1) {
if (REPLACE_TYPE=="hlw" || REPLACE_TYPE=="tom" || REPLACE_TYPE=="xyy" || REPLACE_TYPE=="404"){ // 替换成葫芦娃、猫和老鼠、喜羊羊、肥肠抱歉
include ("replace.php");
replace();
}else {
exit(BLOCK_RETURN);
}
}
}
if (ACCESS_KEY != "") { // access_key 存在
if (BLOCK_TYPE == "blacklist") { // 黑名单鉴权
$url = "https://black.qimo.ink/?access_key=".ACCESS_KEY;
$out = get_webpage($url);
// 如果是黑名单
if ($out == "ban" || $baned == 1) {
if (REPLACE_TYPE == "hlw" || REPLACE_TYPE == "tom" || REPLACE_TYPE == "xyy") { // 替换成葫芦娃、猫和老鼠、喜羊羊
include ("replace.php");
replace();
}else {
exit(BLOCK_RETURN);
}
}
}else if (BLOCK_TYPE == "whitelist") { // 白名单鉴权
if (SAVE_CACHE == 1) { // 是否开启缓存
$uid = get_uid_fromsql(); // 从数据库获取
}else{
$uid = get_uid(); // 从API获取
}
// 是否在白名单内
if (!in_array($uid, $WHITELIST) || $baned == 1) {
if (REPLACE_TYPE == "hlw" || REPLACE_TYPE == "tom" || REPLACE_TYPE == "xyy" || REPLACE_TYPE == "404") { // 替换成葫芦娃、猫和老鼠、喜羊羊、肥肠抱歉
include ("replace.php");
replace();
}else {
exit(BLOCK_RETURN);
}
}
}
}else{ // access_key 不存在
if (BLOCK_TYPE == "whitelist" || NEED_LOGIN == 1){ // 白名单模式 或 黑名单模式+需要登录
exit(BLOCK_RETURN);
}
if (BLOCK_TYPE == "whitelist" || NEED_LOGIN == 1) { // 白名单模式 或 黑名单模式+需要登录
exit(BLOCK_RETURN);
}
}
function get_uid(){
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$url = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$output = get_webpage($url);
$array = json_decode($output, true);
$code = $array['code'];
if ($code=="0"){
$uid = $array['data']['mid'];
}else{
$uid = "0";
}
return $uid;
function get_uid() {
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$url = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$output = get_webpage($url);
$array = json_decode($output, true);
$code = $array['code'];
if ($code=="0") {
$uid = $array['data']['mid'];
}else{
$uid = "0";
}
return $uid;
}
function get_uid_fromsql(){
global $dbh;
$sqlco = "SELECT `uid` FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$uid = $vnum['uid'];
return $uid;
function get_uid_fromsql() {
global $dbh;
$sqlco = "SELECT `uid` FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$uid = $vnum['uid'];
return $uid;
}
?>

@ -1,26 +1,24 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
// 参数
$refresh_cache = 0;
// 判断登录状态
if (ACCESS_KEY ==""){
define('TYPE', 0); //未登录
if (ACCESS_KEY == "") {
define('TYPE', 0); //未登录
}else{
// 判断大会员
$sqlco = "SELECT `due_date` FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$due = $vnum['due_date'];
if ((int)$due > time()*1000 ){
define('TYPE', 2); // 大会员
}else{
define('TYPE', 1); // 不是大会员
}
// 判断大会员
$sqlco = "SELECT `due_date` FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$due = $vnum['due_date'];
if ((int)$due > time()*1000 ) {
define('TYPE', 2); // 大会员
}else{
define('TYPE', 1); // 不是大会员
}
}
//pdo连接数据库
@ -32,66 +30,65 @@ $dbh='mysql:host='.$db_host.';'.'dbname='.$db_name;
try{
$dbh = new PDO($dbh,$db_user,$db_pass);
//echo '连接成功';
}catch(PDOException $e){
}catch(PDOException $e) {
//pass
}
// 获取缓存
function get_cache(){
global $dbh;
global $refresh_cache;
$ts = time();
$sqlco = "SELECT * FROM `cache` WHERE `area` = '".AREA."' AND `type` = '".TYPE."' AND `cid` = '".CID."' AND `ep_id` = '".EP_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>=$ts){
return $cache;
}else{
// 准备刷新缓存
$refresh_cache = 1;
return "";
}
}
return "";
function get_cache() {
global $dbh;
global $refresh_cache;
$ts = time();
$sqlco = "SELECT * FROM `cache` WHERE `area` = '".AREA."' AND `type` = '".TYPE."' AND `cid` = '".CID."' AND `ep_id` = '".EP_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 >= $ts) {
return $cache;
}else{
// 准备刷新缓存
$refresh_cache = 1;
return "";
}
}
return "";
}
// 写入缓存
function write_cache(){
global $dbh;
global $SERVER_AREA;
global $output;
global $refresh_cache;
$ts = time();
$array = json_decode($output, true);
$code = $array['code'];
if ($code == "0"){
$a = explode('mid=', $output);
$out = $a[0];
for($j=1; $j<count($a)-1; $j++){
//echo $a[$j];
$b = explode('orderid=', $a[$j]);
$out = $out.'orderid='.$b[1];
}
$output = $out.$a[count($a)-1];
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('$ts','".AREA."','".TYPE."','".CID."','".EP_ID."','$output')";
// 刷新缓存
if ($refresh_cache==1){
$sql = "UPDATE `cache` SET `add_time` = '$ts', `cache` = '$output' WHERE `area` = '".AREA."' AND `type` = '".TYPE."' AND `cid` = '".CID."' AND `ep_id` = '".EP_ID."';";
}
$dbh -> exec($sql);
// 缓存地区错误
}else if (in_array(AREA, $SERVER_AREA)){
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('9999999999','".AREA."','".TYPE."','".CID."','".EP_ID."','$output')";
if ($code == "-10403"){// 10403 地区错误
$dbh -> exec($sql);
}else if ($code == "-404" && AREA == "th"){// 404 泰版地区错误
$dbh -> exec($sql);
}
}
function write_cache() {
global $dbh;
global $SERVER_AREA;
global $output;
global $refresh_cache;
$ts = time();
$array = json_decode($output, true);
$code = $array['code'];
if ($code == "0") {
$a = explode('mid=', $output);
$out = $a[0];
for($j=1; $j<count($a)-1; $j++) {
//echo $a[$j];
$b = explode('orderid=', $a[$j]);
$out = $out.'orderid='.$b[1];
}
$output = $out.$a[count($a)-1];
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('$ts','".AREA."','".TYPE."','".CID."','".EP_ID."','$output')";
// 刷新缓存
if ($refresh_cache == 1) {
$sql = "UPDATE `cache` SET `add_time` = '$ts', `cache` = '$output' WHERE `area` = '".AREA."' AND `type` = '".TYPE."' AND `cid` = '".CID."' AND `ep_id` = '".EP_ID."';";
}
$dbh -> exec($sql);
// 缓存地区错误
}else if (in_array(AREA, $SERVER_AREA)) {
$sql ="INSERT INTO `cache` (`add_time`,`area`,`type`,`cid`,`ep_id`,`cache`) VALUES ('9999999999','".AREA."','".TYPE."','".CID."','".EP_ID."','$output')";
if ($code == "-10403") {// 10403 地区错误
$dbh -> exec($sql);
}else if ($code == "-404" && AREA == "th") {// 404 泰版地区错误
$dbh -> exec($sql);
}
}
}
?>

@ -25,14 +25,14 @@ define('DB_PASS', '登录的密码'); //登录的密码
define('DB_NAME', '数据库名称'); //数据库名称
// 服务器所在的地区
/*
可不填,填写后可以锁区,及缓存-10403。
若要填写,请正确填写,以确保数据库写入正确。
下方为填写例子
$SERVER_AREA = array('cn');
$SERVER_AREA = array('hk','tw');
$SERVER_AREA = array('th');
*/
/*
可不填,填写后可以锁区,及缓存-10403。
若要填写,请正确填写,以确保数据库写入正确。
下方为填写例子
$SERVER_AREA = array('cn');
$SERVER_AREA = array('hk','tw');
$SERVER_AREA = array('th');
*/
$SERVER_AREA = array(); // 空白,不锁区
// API相关
@ -66,25 +66,25 @@ define('APPSEC', '560c52ccd288fed045859ed18bffd973');
define('ACCESS_KEY', @$_GET['access_key']);
define('CID', @$_GET['cid']);
define('EP_ID', @$_GET['ep_id']);
if (@$_GET['area']==''){
define('AREA', 'noarea');
if (@$_GET['area']=='') {
define('AREA', 'noarea');
}else{
define('AREA', @$_GET['area']);
define('AREA', @$_GET['area']);
}
if (@$_GET['ts']==''){
define('TS', time());
if (@$_GET['ts']=='') {
define('TS', time());
}else{
define('TS', @$_GET['ts']);
define('TS', @$_GET['ts']);
}
$baned = 0;
if (in_array(EP_ID, $epid_list) && BAN_EP == 1) {
$baned = 1;
$baned = 1;
}
if (in_array(CID, $cid_list) && BAN_CID == 1) {
$baned = 1;
$baned = 1;
}
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
if(!defined('SYSTEM')) {
exit(BLOCK_RETURN);
}
?>

@ -7,100 +7,104 @@ header('Content-Type: application/json; charset=utf-8');
// 加载配置
include ("config.php");
// 缓存用
if (SAVE_CACHE==1) {
include ("log.php");
if (SAVE_CACHE == 1) {
include ("log.php");
}
// 判断要转发的host
$path = explode('/index.php', $_SERVER['PHP_SELF'])[0];
if ($path=="/intl/gateway/v2/ogv/playurl") {
$host = CUSTOM_HOST_TH;
} elseif ($path=="/intl/gateway/v2/app/search/type" || $path=="/intl/gateway/v2/app/subtitle") {
$host = CUSTOM_HOST_SUB;
} elseif ($path=="/pgc/player/api/playurl" || $path=="/pgc/player/web/playurl") {
if (AREA=="cn") {
$host = CUSTOM_HOST_CN;
} else if (AREA=="hk") {
$host = CUSTOM_HOST_HK;
} else if (AREA=="tw") {
$host = CUSTOM_HOST_TW;
} else {
$host = CUSTOM_HOST_DEFAULT;
}
} elseif (WEB_ON == 1) {
// web脚本
$host = CUSTOM_HOST_DEFAULT;
$path = "/pgc/player/web/playurl";
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
// Web接口
if (WEB_ON == 1 && $path == "/") {
$host = CUSTOM_HOST_DEFAULT;
$path = "/pgc/player/web/playurl";
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
}
if ($path == "/intl/gateway/v2/ogv/playurl") {
$host = CUSTOM_HOST_TH;
} elseif ($path == "/intl/gateway/v2/app/search/type" || $path == "/intl/gateway/v2/app/subtitle") {
$host = CUSTOM_HOST_SUB;
} elseif ($path == "/pgc/player/api/playurl" || $path == "/pgc/player/web/playurl") {
if (AREA=="cn") {
$host = CUSTOM_HOST_CN;
} else if (AREA=="hk") {
$host = CUSTOM_HOST_HK;
} else if (AREA=="tw") {
$host = CUSTOM_HOST_TW;
} else {
// Web接口
$host = CUSTOM_HOST_DEFAULT;
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
}
} else {
// 欢迎语
exit(WELCOME);
// 欢迎语
exit(WELCOME);
}
// 判断服务器锁区 及 web接口
if ($path=="/intl/gateway/v2/ogv/playurl" || $path=="/pgc/player/api/playurl") {
if ( LOCK_AREA=="1" && !empty($SERVER_AREA) && !in_array(AREA, $SERVER_AREA)) {
exit(BLOCK_RETURN);
}
}elseif ($path=="/pgc/player/web/playurl") {
if(WEB_ON == 0){
exit(BLOCK_RETURN);
}
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
if ($path == "/intl/gateway/v2/ogv/playurl" || $path == "/pgc/player/api/playurl") {
if (LOCK_AREA == "1" && !empty($SERVER_AREA) && !in_array(AREA, $SERVER_AREA)) {
exit(BLOCK_RETURN);
}
}elseif ($path == "/pgc/player/web/playurl") {
if(WEB_ON == 0) {
exit(BLOCK_RETURN);
}
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
}
// 模块请求都会带上X-From-Biliroaming的请求头为了防止被盗用可以加上请求头判断WEB接口暂不限制
$headerStringValue = $_SERVER['HTTP_X_FROM_BILIROAMING'];
if ($headerStringValue=="" && BILIROAMING==1 && $path!="/pgc/player/web/playurl") {
exit(BLOCK_RETURN);
if ($headerStringValue == "" && BILIROAMING == 1 && $path != "/pgc/player/web/playurl") {
exit(BLOCK_RETURN);
}
// 判断 playurl
$playurl = 0;
if ($path!="/intl/gateway/v2/app/search/type" && $path!="/intl/gateway/v2/app/subtitle"){
$playurl = 1;
if ($path != "/intl/gateway/v2/app/search/type" && $path != "/intl/gateway/v2/app/subtitle") {
$playurl = 1;
}
// 鉴权
if ($playurl==1){
include ("auth.php");
if ($playurl == 1) {
include ("auth.php");
}
// 获取缓存
if (SAVE_CACHE==1 && $playurl==1) {
include ("cache.php");
$cache = get_cache();
if ($cache != "") {
exit($cache);
}
if (SAVE_CACHE == 1 && $playurl == 1) {
include ("cache.php");
$cache = get_cache();
if ($cache != "") {
exit($cache);
}
}
// 指定ip回源
if (IP_RESOLVE==1) {
$host = $hosts[array_rand($hosts)];
$ip = $ips[array_rand($ips)];
if (IP_RESOLVE == 1) {
$host = $hosts[array_rand($hosts)];
$ip = $ips[array_rand($ips)];
}
// 转发到指定服务器
$url = $host.$path."?".$_SERVER['QUERY_STRING'];
if (IP_RESOLVE==1) {
$output = get_webpage($url,$host,$ip);
if (IP_RESOLVE == 1) {
$output = get_webpage($url,$host,$ip);
}else {
$output = get_webpage($url);
$output = get_webpage($url);
}
print($output);
// 写入缓存
if (SAVE_CACHE==1 && $playurl==1) {
write_cache();
if (SAVE_CACHE == 1 && $playurl == 1) {
write_cache();
}
function get_webpage($url,$host="",$ip=""){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
if (IP_RESOLVE==1) { // 指定ip回源
curl_setopt($ch,CURLOPT_RESOLVE,[$host.":443:".$ip]);
}
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'User-Agent: '.@$_SERVER["HTTP_USER_AGENT"]
));
$output = curl_exec($ch);
curl_close($ch);
return $output;
function get_webpage($url,$host="",$ip="") {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
if (IP_RESOLVE == 1) { // 指定ip回源
curl_setopt($ch,CURLOPT_RESOLVE,[$host.":443:".$ip]);
}
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'User-Agent: '.@$_SERVER["HTTP_USER_AGENT"]
));
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
?>

@ -1,8 +1,6 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
//pdo连接数据库
$db_host=DB_HOST;
$db_user=DB_USER;
@ -12,39 +10,39 @@ $dbh='mysql:host='.$db_host.';'.'dbname='.$db_name;
try{
$dbh = new PDO($dbh,$db_user,$db_pass);
//echo '连接成功';
}catch(PDOException $e){
}catch(PDOException $e) {
//pass
}
// 判断登录状态
if (ACCESS_KEY !=""){
$sqlco = "SELECT `uid` as num FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$uid = $vnum['num'];
if ($uid == "" || $uid == "0"){
$out = get_userinfo();
$uid = $out[0];
$due = $out[1];
if ($uid != "0"){
$sql = " INSERT INTO `keys` (`add_time`,`uid`,`access_key`,`due_date`) VALUES (now(),'$uid','".ACCESS_KEY."','$due')";
$dbh -> exec($sql);
}
}
if (ACCESS_KEY != "") {
$sqlco = "SELECT `uid` as num FROM `keys` WHERE `access_key` = '".ACCESS_KEY."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
$uid = $vnum['num'];
if ($uid == "" || $uid == "0") {
$out = get_userinfo();
$uid = $out[0];
$due = $out[1];
if ($uid != "0") {
$sql = " INSERT INTO `keys` (`add_time`,`uid`,`access_key`,`due_date`) VALUES (now(),'$uid','".ACCESS_KEY."','$due')";
$dbh -> exec($sql);
}
}
}
function get_userinfo(){
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$url = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$output = get_webpage($url);
$array = json_decode($output, true);
$code = $array['code'];
if ($code == "0"){
$out[0] = $array['data']['mid'];
$out[1] = $array['data']['vip']['due_date'];
}else{
$out[0] = "0";
$out[1] = "0";
}
return $out;
function get_userinfo() {
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$url = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$output = get_webpage($url);
$array = json_decode($output, true);
$code = $array['code'];
if ($code == "0") {
$out[0] = $array['data']['mid'];
$out[1] = $array['data']['vip']['due_date'];
}else{
$out[0] = "0";
$out[1] = "0";
}
return $out;
}
?>

@ -1,97 +1,93 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
function replace(){
global $host;
global $path;
// 判断来源
if ($path=="/intl/gateway/v2/ogv/playurl"){
$type = "intl";
}elseif ($path=="/pgc/player/api/playurl"){
$type = "main";
}elseif ($path!="/intl/gateway/v2/app/search/type" && $path!="/intl/gateway/v2/app/subtitle"){
$type = "web";
}
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
if (REPLACE_TYPE=="hlw"){
$url = 'https://black.qimo.ink/hlw.php?type='.$type;
}else if (REPLACE_TYPE=="tom"){
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}else if (REPLACE_TYPE=="xyy"){
$url = 'https://bili.tuturu.top/xyyjson.php?type='.$type;
}else{
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}
$output = get_webpage($url);
function replace() {
global $host;
global $path;
// 判断来源
if ($path == "/intl/gateway/v2/ogv/playurl") {
$type = "intl";
}elseif ($path == "/pgc/player/api/playurl") {
$type = "main";
}elseif ($path != "/intl/gateway/v2/app/search/type" && $path != "/intl/gateway/v2/app/subtitle") {
$type = "web";
}
if (REPLACE_TYPE == "hlw") {
$url = 'https://black.qimo.ink/hlw.php?type='.$type;
}else if (REPLACE_TYPE == "tom") {
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}else if (REPLACE_TYPE == "xyy") {
$url = 'https://bili.tuturu.top/xyyjson.php?type='.$type;
}else{
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}
$output = get_webpage($url);
// 分析 output
$array = json_decode($output, true);
$timelength = $array['timelength'];
$base_url = $array['v_base_url'];
$bandwidth = $array['v_bandwidth'];
$backup_url = $array['v_backup_url'];
$a_base_url = $array['a_base_url'];
$a_bandwidth = $array['a_bandwidth'];
$a_backup_url = $array['a_backup_url'];
// 分析 output
$array = json_decode($output, true);
$timelength = $array['timelength'];
$base_url = $array['v_base_url'];
$bandwidth = $array['v_bandwidth'];
$backup_url = $array['v_backup_url'];
$a_base_url = $array['a_base_url'];
$a_bandwidth = $array['a_bandwidth'];
$a_backup_url = $array['a_backup_url'];
if ($type=="web"){
exit($output);
}
if ($type == "web") {
exit($output);
}
// 转发到指定服务器
$url = $host.$path."?".$_SERVER['QUERY_STRING'];
$output2 = get_webpage($url);
if ($type=="intl"){
$array2 = json_decode($output2, true);
$array2['data']['video_info']['timelength'] = $timelength;
// 转发到指定服务器
$url = $host.$path."?".$_SERVER['QUERY_STRING'];
$output2 = get_webpage($url);
if ($type == "intl") {
$array2 = json_decode($output2, true);
$array2['data']['video_info']['timelength'] = $timelength;
// 替换视频
// 好像是count不到正确数量不晓得有没有人会改的
//$v_count = count($array2['data']['video_info']['stream_list']);
for($j=0 ; $j<5; $j++){
$array2['data']['video_info']['stream_list'][$j]['dash_video']['base_url'] = $base_url;
$array2['data']['video_info']['stream_list'][$j]['dash_video']['backup_url'] = $backup_url;
$array2['data']['video_info']['stream_list'][$j]['dash_video']['bandwidth'] = $bandwidth;
}
// 替换视频
// 好像是count不到正确数量不晓得有没有人会改的
//$v_count = count($array2['data']['video_info']['stream_list']);
for($j=0;$j<5;$j++) {
$array2['data']['video_info']['stream_list'][$j]['dash_video']['base_url'] = $base_url;
$array2['data']['video_info']['stream_list'][$j]['dash_video']['backup_url'] = $backup_url;
$array2['data']['video_info']['stream_list'][$j]['dash_video']['bandwidth'] = $bandwidth;
}
// 替换音频
//$a_count = count($array2['data']['video_info']['dash_audio']);
for($j=0 ; $j<3 ; $j++){
$array2['data']['video_info']['dash_audio'][$j]['base_url'] = $a_base_url;
$array2['data']['video_info']['dash_audio'][$j]['backup_url'] = $a_backup_url;
$array2['data']['video_info']['dash_audio'][$j]['bandwidth'] = $a_bandwidth;
}
}elseif ($type=="main"){
$array2 = json_decode($output2, true);
$array2['timelength'] = $timelength;
// 替换音频
//$a_count = count($array2['data']['video_info']['dash_audio']);
for($j=0;$j<3;$j++) {
$array2['data']['video_info']['dash_audio'][$j]['base_url'] = $a_base_url;
$array2['data']['video_info']['dash_audio'][$j]['backup_url'] = $a_backup_url;
$array2['data']['video_info']['dash_audio'][$j]['bandwidth'] = $a_bandwidth;
}
}elseif ($type == "main") {
$array2 = json_decode($output2, true);
$array2['timelength'] = $timelength;
// 替换视频
$video = $array2['dash']['video'];
$count3 = count($video);
for($j=0 ; $j<$count3; $j++){
$array2['dash']['video'][$j]['base_url'] = $base_url;
$array2['dash']['video'][$j]['backup_url'] = $backup_url;
$array2['dash']['video'][$j]['bandwidth'] = $bandwidth;
}
// 替换视频
$video = $array2['dash']['video'];
$count3 = count($video);
for($j=0;$j<$count3;$j++) {
$array2['dash']['video'][$j]['base_url'] = $base_url;
$array2['dash']['video'][$j]['backup_url'] = $backup_url;
$array2['dash']['video'][$j]['bandwidth'] = $bandwidth;
}
// 替换音频
$audio = $array2['dash']['audio'];
$count4 = count($audio);
for($j=0 ; $j<$count4 ; $j++){
$array2['dash']['audio'][$j]['base_url'] = $a_base_url;
$array2['dash']['audio'][$j]['backup_url'] = $a_backup_url;
$array2['dash']['audio'][$j]['bandwidth'] = $a_bandwidth;
}
}
// 替换音频
$audio = $array2['dash']['audio'];
$count4 = count($audio);
for($j=0;$j<$count4;$j++) {
$array2['dash']['audio'][$j]['base_url'] = $a_base_url;
$array2['dash']['audio'][$j]['backup_url'] = $a_backup_url;
$array2['dash']['audio'][$j]['bandwidth'] = $a_bandwidth;
}
}
// 发送内容
$output3 = json_encode($array2);
$output3 = str_replace("\/","/",$output3);
print($output3);
exit();
// 发送内容
$output3 = json_encode($array2);
$output3 = str_replace("\/","/",$output3);
exit($output3);
}
?>
Loading…
Cancel
Save