Merge pull request #3 from david082321/main

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

@ -0,0 +1,8 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule pgc/player/api/playurl pgc/player/api/playurl/index.php
RewriteRule pgc/player/web/playurl pgc/player/web/playurl/index.php
RewriteRule intl/gateway/v2/ogv/playurl intl/gateway/v2/ogv/playurl/index.php
RewriteRule intl/gateway/v2/app/search/type intl/gateway/v2/app/search/type/index.php
RewriteRule intl/gateway/v2/app/subtitle intl/gateway/v2/app/subtitle/index.php
</IfModule>

@ -1,4 +1,7 @@
<?php
if (@$_GET['type']=="web"){
exit('{"code":-10403,"message":"抱歉您所在地区不可观看!"}');
}
// 必须要用户更改UPOS的默认设置改成不替换
exit('{"timelength":16740,"v_base_url":"https://s1.hdslb.com/bfs/static/player/media/error.mp4","v_bandwidth":172775,"v_backup_url":["https://s2.hdslb.com/bfs/static/player/media/error.mp4"],"a_base_url":"https://s1.hdslb.com/bfs/static/player/media/error.mp4","a_bandwidth":172775,"a_backup_url":["https://s2.hdslb.com/bfs/static/player/media/error.mp4"]}');
?>

@ -6,7 +6,7 @@
## 下载:
* [下载(GitHub) v2.9.6](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.9.6.zip)
* [下载(GitHub) v2.9.8](https://github.com/david082321/BiliRoaming-PHP-Server/raw/main/Server_v2.9.8.zip)
## 用法:
@ -64,6 +64,20 @@
* 导入 cache.sql
## (非必要步骤) 支持网页版油猴脚本
* [油猴脚本地址](https://github.com/ipcjs/bilibili-helper/blob/user.js/packages/unblock-area-limit/README.md)
* 配置 config.php 的 WEB_ON
* 脚本的 代理服务器->自定义 输入以下内容 ( example.com 请改成你的服务器地址)
#####    https://example.com/
* (可选步骤) 配置上面的禁用 301 转址。然后脚本的 代理服务器->自定义 改成
#####    https://example.com
--------
# 文件功能介绍

Binary file not shown.

Binary file not shown.

@ -3,8 +3,8 @@
define('BLOCK_TYPE','blacklist'); // 封锁类型none 不封锁, blacklist 黑名单, whitelist 本地白名单
define('REPLACE_TYPE', "tom"); // 是否替换视频(仅黑/白名单时生效)。hlw 葫芦娃, tom 猫和老鼠, xyy 喜羊羊
define('NEED_LOGIN', 0); //是否要登录用户才能用。0 否, 1 是
define('BILIROAMING', 1); //是否要用哔哩漫游才能使用。0 否, 1 是
define('WEB_ON', 0);//是否开启web接口 0 否, 1 是 目前Web接口不受哔哩漫游请求头影响待更新
define('BILIROAMING', 1); //是否要用哔哩漫游才能使用。0 否, 1 是
define('WEB_ON', 0);//是否开启web接口 0 否, 1 是 目前Web接口不受哔哩漫游请求头影响,且无法服务器锁区(待更新)
define('LOCK_AREA', 0); //服务器锁区,须设置$SERVER_AREA。0 否, 1 是
$WHITELIST = array('1', '2', '3'); // 本地白名单,填写 uid可自行添加、删除注意使用英文,和'
@ -58,16 +58,24 @@ $hosts=array("workers.dev","workers.dev");
// 其他
define('WELCOME', 'Success!'); //首页欢迎语
define('BLOCK_RETURN', '{"code":-10403,"message":"已被封锁"}'); //封锁返回内容
define('BLOCK_RETURN', '{"code":-10403,"message":"抱歉您已被封锁"}'); //封锁返回内容
// 参数,不懂就别改
define('APPKEY', '1d8b6e7d45233436');
define('APPSEC', '560c52ccd288fed045859ed18bffd973');
define('ACCESS_KEY', @$_GET['access_key']);
define('AREA', @$_GET['area']);
define('CID', @$_GET['cid']);
define('EP_ID', @$_GET['ep_id']);
define('TS', @$_GET['ts']);
if (@$_GET['area']==""){
define('AREA', 'noarea');
}else{
define('AREA', @$_GET['area']);
}
if (@$_GET['ts']==""){
define('TS', time());
}else{
define('TS', @$_GET['ts']);
}
$baned = 0;
if (in_array(EP_ID, $epid_list) && BAN_EP == 1) {
$baned = 1;

@ -1,7 +1,7 @@
<?php
// 防止外部破解
define('SYSTEM', TRUE);
define('VERSION', '2.9.4');
define('VERSION', '2.9.9');
// 加上json的Header
header('Content-Type: application/json; charset=utf-8');
// 加载配置
@ -14,12 +14,9 @@ if (SAVE_CACHE==1) {
$path = explode('/index.php', $_SERVER['PHP_SELF'])[0];
if ($path=="/intl/gateway/v2/ogv/playurl") {
$host = CUSTOM_HOST_TH;
lock_area();
} elseif ($path=="/intl/gateway/v2/app/search/type") {
} elseif ($path=="/intl/gateway/v2/app/search/type" || $path=="/intl/gateway/v2/app/subtitle") {
$host = CUSTOM_HOST_SUB;
} elseif ($path=="/intl/gateway/v2/app/subtitle") {
$host = CUSTOM_HOST_SUB;
} elseif ($path=="/pgc/player/api/playurl") {
} elseif ($path=="/pgc/player/api/playurl" || $path=="/pgc/player/web/playurl") {
if (AREA=="cn") {
$host = CUSTOM_HOST_CN;
} else if (AREA=="hk") {
@ -29,41 +26,34 @@ if ($path=="/intl/gateway/v2/ogv/playurl") {
} else {
$host = CUSTOM_HOST_DEFAULT;
}
lock_area();
} elseif (WEB_ON == 1) {
$host = CUSTOM_HOST_DEFAULT;
$path = "/pgc/player/web/playurl";
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
} else {
// 欢迎语
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);
}else 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;
exit(BLOCK_RETURN);
}
header("Access-Control-Allow-Origin: https://www.bilibili.com");
header("Access-Control-Allow-Credentials: true");
// lock_area(); //网页脚本目前未实现区域判断走默认api
}else {
// 欢迎语
exit(WELCOME);
}
// 模块请求都会带上X-From-Biliroaming的请求头为了防止被盗用可以加上请求头判断WEB接口暂不限制
$headerStringValue = $_SERVER['HTTP_X_FROM_BILIROAMING'];
if ($headerStringValue=="" && BILIROAMING==1 && $path!="/pgc/player/web/playurl") {
exit(BLOCK_RETURN);
}
// 服务器锁区
function lock_area() {
if ( LOCK_AREA=="1" ) {
if ( !empty($SERVER_AREA) && !in_array(AREA, $SERVER_AREA)) {
exit(BLOCK_RETURN);
}
}
}
// 鉴权
if ($path=="/intl/gateway/v2/ogv/playurl" || $path=="/pgc/player/api/playurl"){
if ($path!="/intl/gateway/v2/app/search/type" && $path!="/intl/gateway/v2/app/subtitle"){
include ("auth.php");
}
// 获取缓存
@ -88,7 +78,7 @@ if (IP_RESOLVE==1) {
}
print($output);
// 写入缓存
if (SAVE_CACHE==1 && $path!="/pgc/player/web/playurl") { //屏蔽web缓存
if (SAVE_CACHE==1) {
write_cache();
}

@ -5,18 +5,31 @@ if(!defined('SYSTEM')){
}
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';
$url = 'https://black.qimo.ink/hlw.php?type='.$type;
}else if (REPLACE_TYPE=="tom"){
$url = 'https://black.qimo.ink/TandJ.php';
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}else if (REPLACE_TYPE=="xyy"){
$url = 'https://bili.tuturu.top/xyyjson.php';
$url = 'https://bili.tuturu.top/xyyjson.php?type='.$type;
}else if (REPLACE_TYPE=="404"){
$url = 'https://'.$_SERVER['HTTP_HOST'].'/404.php';
$url = 'https://'.$_SERVER['HTTP_HOST'].'/404.php?type='.$type;
}else{
$url = 'https://black.qimo.ink/TandJ.php';
$url = 'https://black.qimo.ink/TandJ.php?type='.$type;
}
$output = get_webpage($url);
// 分析 output
$array = json_decode($output, true);
$timelength = $array['timelength'];
@ -26,21 +39,15 @@ function replace(){
$a_base_url = $array['a_base_url'];
$a_bandwidth = $array['a_bandwidth'];
$a_backup_url = $array['a_backup_url'];
global $host;
global $path;
// 判断来源
if ($path=="/intl/gateway/v2/ogv/playurl"){
$type = "intl";
}elseif ($path=="/pgc/player/api/playurl"){
$type = "main";
if ($type=="web"){
exit($output);
}
// 转发到指定服务器
$url = "https://".$host.$path."?".$_SERVER['QUERY_STRING'];
$url = $host.$path."?".$_SERVER['QUERY_STRING'];
$output2 = get_webpage($url);
if ($type=="intl"){
// 替换成hop
$array2 = json_decode($output2, true);
$array2['data']['video_info']['timelength'] = $timelength;
@ -60,8 +67,7 @@ function replace(){
$array2['data']['video_info']['dash_audio'][$j]['backup_url'] = $a_backup_url;
$array2['data']['video_info']['dash_audio'][$j]['bandwidth'] = $a_bandwidth;
}
}else{
// 替换成hop
}elseif ($type=="main"){
$array2 = json_decode($output2, true);
$array2['timelength'] = $timelength;

Loading…
Cancel
Save