Merge pull request #2 from david082321/main

同步2.9.5
pull/5/head
AisukaYuki 4 years ago committed by GitHub
commit f9bb9d3ddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@
## 下载:
* [下载(GitHub) v2.9.3](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.9.3.zip)
* [下载(GitHub) v2.9.5](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.9.5.zip)
## 用法:
@ -64,3 +64,34 @@
* 导入 cache.sql
--------
# 文件功能介绍
├-intl/gateway/v2
│ ├-app
│ │ ├-search/type/index.php (转发到根目录的 index.php 处理)
│ │ └-subtitle/index.php (转发到根目录的 index.php 处理)
│ └-ogv/playurl/index.php (转发到根目录的 index.php 处理)
├-pgc/player/api/playurl/index.php (转发到根目录的 index.php 处理)
├-404.php (肥肠抱歉视频)
├-auth.php (鉴权)
├-cache.php (缓存)[仅缓存使用]
├-cache.sql (导入MySQL用的)[仅缓存使用]
├-config.php (用户设置)
├-index.php (接受上面index.php) <---
├-log.php (缓存用户)[仅缓存使用]
└-replace.php (替换视频)

Binary file not shown.

Binary file not shown.

@ -0,0 +1,68 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
if (BLOCK_TYPE=="none"){ // 无鉴权模式
// pass
}else 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" || REPLACE_TYPE=="404"){ // 替换成葫芦娃、猫和老鼠、喜羊羊、肥肠抱歉
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);
}
}
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;
}
?>

@ -1,28 +0,0 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}
if (ACCESS_KEY != ""){ // access_key 是否存在
$url = "https://black.qimo.ink/?access_key=".ACCESS_KEY;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($ch);
curl_close($ch);
// 如果是黑名单
if ($out=="ban" || $baned == 1){
if (REPLACE_TYPE=="hlw" || REPLACE_TYPE=="tom" || REPLACE_TYPE=="xyy" || REPLACE_TYPE=="404"){ // 替换成葫芦娃、猫和老鼠、喜羊羊、肥肠抱歉
include ("replace.php");
replace();
}else {
exit(BLOCK_RETURN);
}
}
}else if (NEED_LOGIN == 1){
exit(BLOCK_RETURN);
}
?>

@ -1,7 +1,6 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}

@ -1,6 +1,4 @@
<?php
if(!defined('SYSTEM')){header('HTTP/1.1 404 Not Found');} // 防止外部破解,不可以改
// 封锁
define('BLOCK_TYPE','blacklist'); // 封锁类型none 不封锁, blacklist 黑名单, whitelist 本地白名单
define('REPLACE_TYPE', "tom"); // 是否替换视频(仅黑/白名单时生效)。hlw 葫芦娃, tom 猫和老鼠, xyy 喜羊羊
@ -11,7 +9,8 @@ $WHITELIST = array('1', '2', '3'); // 本地白名单,填写 uid可自行
// 封锁指定epid视频
define('BAN_EP', 0); //是否开启ban特定视频
$epid_list = array("369747","371362","371461","371462","371463","371596"); //巨人最终季
//$epid_list = array("369747","371362","371461","371462","371463","371596"); //示范内容:巨人最终季
$epid_list = array();
// 封锁指定cid视频
define('BAN_CID', 0); //是否开启ban特定视频
$cid_list = array();
@ -36,12 +35,12 @@ define('DB_NAME', '数据库名称'); //数据库名称
$SERVER_AREA = array(); // 空白,不锁区
// API相关
define('CUSTOM_HOST_DEFAULT', 'api.bilibili.com'); // 兼容未发送 area 参数的其他脚本
define('CUSTOM_HOST_CN', 'api.bilibili.com'); // CN 解析api
define('CUSTOM_HOST_HK', 'api.bilibili.com'); // HK 解析api
define('CUSTOM_HOST_TW', 'api.bilibili.com'); // TW 解析api
define('CUSTOM_HOST_TH', 'api.global.bilibili.com'); //泰区 解析api
define('CUSTOM_HOST_SUB', 'app.global.bilibili.com'); //泰区 搜索字幕用api
define('CUSTOM_HOST_DEFAULT', 'https://api.bilibili.com'); // 兼容未发送 area 参数的其他脚本
define('CUSTOM_HOST_CN', 'https://api.bilibili.com'); // CN 解析api
define('CUSTOM_HOST_HK', 'https://api.bilibili.com'); // HK 解析api
define('CUSTOM_HOST_TW', 'https://api.bilibili.com'); // TW 解析api
define('CUSTOM_HOST_TH', 'https://api.global.bilibili.com'); //泰区 解析api
define('CUSTOM_HOST_SUB', 'https://app.global.bilibili.com'); //泰区 搜索字幕用api
// 自定义API,避免集中请求,降低风控几率
//$hk_api = array("host1","host2","host3");//可以自定义其他反代api,例如云函数,CFW
@ -75,4 +74,8 @@ if (in_array(EP_ID, $epid_list) && BAN_EP == 1) {
if (in_array(CID, $cid_list) && BAN_CID == 1) {
$baned = 1;
}
// 防止外部破解
if(!defined('SYSTEM')){
exit(BLOCK_RETURN);
}
?>

@ -1,7 +1,9 @@
<?php
// 防止外部破解
define('SYSTEM', TRUE);
define('VERSION', '2.9.1');
define('VERSION', '2.9.4');
// 加上json的Header
header('Content-Type: application/json; charset=utf-8');
// 加载配置
include ("config.php");
// 缓存用
@ -40,14 +42,14 @@ if ($headerStringValue=="" && BILIROAMING==1) {
// 服务器锁区
function lock_area() {
if ( LOCK_AREA=="1" ) {
if ( !empty($SERVER_AREA) && !in_array(AREA, $SERVER_AREA)) {
exit(BLOCK_RETURN);
}
if ( !empty($SERVER_AREA) && !in_array(AREA, $SERVER_AREA)) {
exit(BLOCK_RETURN);
}
}
}
// 鉴权
if ($path!="/intl/gateway/v2/app/subtitle") {
include (BLOCK_TYPE.".php");
if ($path=="/intl/gateway/v2/ogv/playurl" || $path=="/pgc/player/api/playurl"){
include ("auth.php");
}
// 获取缓存
if (SAVE_CACHE==1) {
@ -63,23 +65,24 @@ if (IP_RESOLVE==1) {
$ip = $ips[array_rand($ips)];
}
// 转发到指定服务器
$url = "https://".$host.$path."?".$_SERVER['QUERY_STRING'];
if (IP_RESOLVE==0) {
$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);
}
$url = $host.$path."?".$_SERVER['QUERY_STRING'];
if (IP_RESOLVE==1) {
$output = get_webpage($url,$host,$ip);
}else {
$output = get_webpage($url);
}
print($output);
// 写入缓存
if (SAVE_CACHE==1) {
write_cache();
}
function get_webpage($url,$host="",$ip=""){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
// 指定ip回源
curl_setopt($ch,CURLOPT_RESOLVE,[$host.":443:".$ip]);
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(
@ -87,10 +90,6 @@ if (IP_RESOLVE==1) {
));
$output = curl_exec($ch);
curl_close($ch);
}
print($output);
// 写入缓存
if (SAVE_CACHE==1) {
write_cache();
return $output;
}
?>

@ -1,7 +1,6 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}
@ -37,12 +36,8 @@ if (ACCESS_KEY !=""){
function get_userinfo(){
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$testurl = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $testurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
$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"){

@ -1,3 +0,0 @@
<?php
// 无鉴权模式
?>

@ -1,7 +1,6 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}
@ -17,15 +16,7 @@ function replace(){
}else{
$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 = get_webpage($url);
// 分析 output
$array = json_decode($output, true);
$timelength = $array['timelength'];
@ -47,15 +38,7 @@ function replace(){
// 转发到指定服务器
$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);
$output2 = get_webpage($url);
if ($type=="intl"){
// 替换成hop
$array2 = json_decode($output2, true);
@ -102,7 +85,6 @@ function replace(){
}
// 发送内容
header('Content-Type: application/json; charset=utf-8');
$output3 = json_encode($array2);
$output3 = str_replace("\/","/",$output3);
print($output3);

@ -1,54 +0,0 @@
<?php
// 防止外部破解
if(!defined('SYSTEM')){
header('HTTP/1.1 404 Not Found');
exit(BLOCK_RETURN);
}
if (ACCESS_KEY != ""){ // access_key 是否存在
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{
exit(BLOCK_RETURN);
}
function get_uid(){
$sign = md5("access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS.APPSEC);
$testurl = "https://app.bilibili.com/x/v2/account/myinfo?access_key=".ACCESS_KEY."&appkey=".APPKEY."&ts=".TS."&sign=".$sign;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $testurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
$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;
}
?>
Loading…
Cancel
Save