v2.7
1. 加上替换成猫和老鼠
1.1 添加 tom.php 文件
1.2 config.php 弃用参数 REPLACE_HLW、添加参数 REPLACE_TYPE
1.3 修改 blacklist.php 及 whitelist.php

2. 指定ip回源
2.1 config.php 添加参数 IP_RESOLVE
2.2 config.php 添加Array $ips 及 $hosts
2.3 修改 index.php
pull/2/head
david082321 4 years ago
parent 841d344fed
commit a8387b4e54

@ -6,14 +6,14 @@
## 下载:
* [下载(GitHub) v2.6](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.6.zip)
* [下载(GitHub) v2.7](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.7.zip)
## 用法:
* 直接放到网站根目录,例如 wwwroot 或 public_html 或 private_html
* 默认为「黑名单-葫芦娃」模式,若要切换到其他模式,请看底下说明。
* 默认为「黑名单-猫和老鼠」模式,若要切换到其他模式,请看底下说明。
## 示例:
@ -26,7 +26,7 @@
## (非必要步骤) 切换到其他模式
* 默认为「黑名单-葫芦娃」模式,若您想使用「黑名单」或是「本地白名单」或是「无任何限制」等其他模式,请手动修改 config.php
* 默认为「黑名单-猫和老鼠」模式,若您想使用「黑名单」或是「黑名单-葫芦娃」或是「本地白名单」或是「无任何限制」等其他模式,请手动修改 config.php
* 每行后面都有注释提供参考

Binary file not shown.

Binary file not shown.

@ -18,10 +18,13 @@ if ($access_key != ""){
curl_close($ch);
// 如果是黑名单
if ($out=="ban"){
if (REPLACE_HLW==1){
if (REPLACE_TYPE=="hlw"){ // 替换成葫芦娃
include ("hlw.php");
hlw();
}else{
}elseif (REPLACE_TYPE=="tom"){ // 替换成猫和老鼠
include ("tom.php");
tom();
}else {
exit(BLOCK_RETURN);
}
}

@ -1,18 +1,14 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
}
if(!defined('SYSTEM')){header('HTTP/1.1 404 Not Found');}// 防止外部破解,不可以改
// 封锁
define('BLOCK_TYPE','blacklist'); // 封锁类型none 不封锁, blacklist 黑名单, whitelist 本地白名单
define('REPLACE_HLW', 1); // 是否替换成葫芦娃(仅黑/白名单时生效)。0 否, 1 是
define('REPLACE_TYPE', "tom"); // 是否替换视频(仅黑/白名单时生效)。hlw 葫芦娃, tom 猫和老鼠
define('NEED_LOGIN', 0); //是否要登录用户才能用。0 否, 1 是
define('BILIROAMING', 1); //是否要用哔哩漫游才能使用。0 否, 1 是
define('LOCK_AREA', 0); //服务器锁区,须设置$SERVER_AREA。0 否, 1 是
$WHITELIST = array('1', '2', '3'); // 本地白名单,填写 uid可自行添加、删除注意使用英文,和'
// 缓存
define('SAVE_CACHE', 0); //开启缓存须配置MySQL。0 否, 1 是
define('CACHE_TIME', 7200); //缓存时长(秒)
@ -45,6 +41,11 @@ define('CUSTOM_HOST_SUB', 'app.global.bilibili.com'); //泰区 搜索字幕用ap
//$tw_sum = array_rand($tw_api);//计数
//define('CUSTOM_HOST_TW', $tw_api[$tw_sum]); //随机调用
// 指定ip回源
define('IP_RESOLVE', 0); // 开启功能。0 否, 1 是
$ips=array("172.0.0.1","192.168.0.1","1.2.3.4");
$hosts=array("workers.dev","workers.dev");
// 其他
define('WELCOME', 'Success!'); //首页欢迎语
define('BLOCK_RETURN', '{"code":-10403,"message":"你已被封锁"}'); //封锁返回内容

@ -51,12 +51,25 @@ if (SAVE_CACHE==1){
}
}
$url = "https://".$link.$path."?".$_SERVER['QUERY_STRING'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RESOLVE,[$link.":443:".$ip]);
// 指定ip回源
if (IP_RESOLVE==1){
$host = $links[array_rand($hosts)];
$ip = $ips[array_rand($ips)];
}
// 转发到指定服务器
$url = "https://".$host.$path."?".$_SERVER['QUERY_STRING'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
if (IP_RESOLVE==1){curl_setopt($ch,CURLOPT_RESOLVE,[$host.":443:".$ip]);} // 指定ip回源
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'User-Agent: '.@$_SERVER["HTTP_USER_AGENT"]
));

@ -0,0 +1,116 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}
function tom(){
$url = "https://black.qimo.ink/TandJ.php";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
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);
// 分析 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 (SAVE_CACHE==1){
include ("cache.php");
$output2 = get_cache();
}else{
$output2 = "";
}
if ($output2 == ""){
global $host;
global $path;
// 判断来源
if ($path=="/intl/gateway/v2/ogv/playurl"){
$type = "intl";
}elseif ($path=="/pgc/player/api/playurl"){
$type = "main";
}
// 转发到指定服务器
$url = "https://".$host.$path."?".$_SERVER['QUERY_STRING'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'User-Agent: '.@$_SERVER["HTTP_USER_AGENT"]
));
$output2 = curl_exec($ch);
curl_close($ch);
// 写入缓存
if (SAVE_CACHE==1){
$output = $output2;
write_cache();
}
}
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;
}
// 替换音频
//$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;
}
}else{
// 替换成葫芦娃
$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;
}
// 替换音频
$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;
}
}
// 发送内容
header('Content-Type: application/json; charset=utf-8');
$output3 = json_encode($array2);
$output3 = str_replace("\/","/",$output3);
print($output3);
exit();
}
?>

@ -17,9 +17,12 @@ if ($access_key != ""){ // access_key 是否存在
if (in_array($uid, $WHITELIST)) {
// pass
}else{
if (REPLACE_HLW==1){
if (REPLACE_TYPE=="hlw"){ // 替换成葫芦娃
include ("hlw.php");
hlw(); // 替换成葫芦娃
hlw();
}elseif (REPLACE_TYPE=="tom"){ // 替换成猫和老鼠
include ("tom.php");
tom();
}else{
exit(BLOCK_RETURN);
}

Loading…
Cancel
Save