1. 黑、白名单api升级

2. 添加本地黑名单功能
pull/26/head
david082321 3 years ago
parent 9cbc8be461
commit e7c93d4117

@ -6,12 +6,13 @@ define('SYSTEM', TRUE);
define('ROOT_PATH',$_SERVER['DOCUMENT_ROOT'].'/');
// 封锁
define('BLOCK_TYPE', 'blacklist'); // 封锁类型blacklist 黑名单, whitelist 本地白名单, 不是填写前面两个就是不封锁
define('BLOCK_TYPE', 'blacklist'); // 封锁类型blacklist 在线黑名单, whitelist 在线白名单, local_blacklist 本地黑名单, local_whitelist 本地白名單, 不是填写前面几个就是不封锁
define('REPLACE_TYPE', 'tom'); // 是否替换视频(仅黑/白名单时生效)。txbb 天线宝宝, tom 猫和老鼠, xyy 喜羊羊, all 随机
define('NEED_LOGIN', 0); // 是否要登录用户才能用。0 否, 1 是
define('BILIROAMING', 1); // 是否要用哔哩漫游才能使用。0 否, 1 是
define('WEB_ON', 0); // 是否开启web接口 0 否, 1 是 目前Web接口不受哔哩漫游请求头影响且不受服务器锁区影响待更新
define('LOCK_AREA', 0); // 服务器锁区,须设置$SERVER_AREA。0 否, 1 是
$BLACKLIST = array('1', '2', '3'); // 本地黑名单,填写 uid可自行添加、删除注意使用英文,和'
$WHITELIST = array('1', '2', '3'); // 本地白名单,填写 uid可自行添加、删除注意使用英文,和'
// 封锁指定epid视频
@ -30,12 +31,12 @@ $cid_list = array();
// 缓存
define('SAVE_CACHE', 0); // 开启缓存须配置MySQL数据库。0 否, 1 是
define('CACHE_TIME', 60*60*1.95); // Playurl缓存时长目前最长可到14400秒建议7200秒以下(部分视频只有2小时)
define('CACHE_TIME_SEASON', 60*60*1); // 泰国 season 的缓存时长(秒)
define('CACHE_TIME_SEASON', 60*60*0.5); // 泰国 season 的缓存时长(秒)
// 发生错误时的缓存时长
define('CACHE_TIME_10403', 60*60*24*14); // 返回10403地区错误时的缓存时长
define('CACHE_TIME_412', 60*60*24*7); // 返回412服务器IP被风控时的缓存时长
define('CACHE_TIME_404', 60*60*24*1); // 返回404时的缓存时长
define('CACHE_TIME_OTHER', 60*60*24*1); // 返回其他错误时的缓存时长(秒)
define('CACHE_TIME_OTHER', 60*60*1); // 返回其他错误时的缓存时长(秒)
define('CACHE_TIME_USER', 60*60*24*1); //缓存用户key的时长
// MySQL数据库

@ -49,35 +49,62 @@ if (ACCESS_KEY != "" && SAVE_CACHE == 1) {
// 开始鉴权
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 == "all") { // 替换成葫芦娃、猫和老鼠、喜羊羊
include (ROOT_PATH."utils/replace_playurl.php");
replace_playurl();
} else {
// resign.php 可能会用到
$is_blacklist = false;
$is_whitelist = false;
if (BLOCK_TYPE == "blacklist" || BLOCK_TYPE == "whitelist") {
$url = "https://black.qimo.ink/status.php?access_key=".ACCESS_KEY;
$status = json_decode(get_webpage($url), true);
$code = $status['code'];
if ((string)$code == "0") {
$is_blacklist = $status['data']['is_blacklist'];
$is_whitelist = $status['data']['is_whitelist'];
//$reason = $status['data']['reason'];
}
}
$is_baned = false;
switch (BLOCK_TYPE) {
case "blacklist": // 在线黑名单
if ($is_blacklist) {
$is_baned = true;
$baned = 21;
block($baned);
}
}
} else if (BLOCK_TYPE == "whitelist") { // 白名单鉴权
// 是否在白名单内
if (!in_array($uid, $WHITELIST) || $baned == 1 || $uid == 0) {
if (REPLACE_TYPE == "hlw" || REPLACE_TYPE == "tom" || REPLACE_TYPE == "xyy" || REPLACE_TYPE == "all") { // 替换成葫芦娃、猫和老鼠、喜羊羊、肥肠抱歉
include (ROOT_PATH."utils/replace_playurl.php");
replace_playurl();
} else {
break;
case "whitelist": // 在线白名单
if (!$is_whitelist) {
$is_baned = true;
$baned = 22;
}
break;
case "local_blacklist": // 本地黑名单
if (in_array($uid, $BLACKLIST)) {
$is_baned = true;
$baned = 21;
}
break;
case "local_whitelist": // 本地白名单
if (!in_array($uid, $WHITELIST)) {
$is_baned = true;
$baned = 22;
block($baned);
}
break;
default:
// pass
}
// 开始ban
$support_replace_type = array("hlw","tom","xyy","all"); // 允许替换的类型
if ($is_baned) {
if (in_array(REPLACE_TYPE, $support_replace_type)) {
include (ROOT_PATH."utils/replace_playurl.php");
replace_playurl();
} else {
block($baned);
}
}
} else { // access_key 不存在
if (CID == "13073143" || CID == "120453316") { // 漫游测速
//pass
} else if (BLOCK_TYPE == "whitelist" || NEED_LOGIN == 1) { // 白名单模式 或 黑名单模式+需要登录
} else if (BLOCK_TYPE == "whitelist" || BLOCK_TYPE == "local_whitelist" || NEED_LOGIN == 1) { // 白名单模式 或 黑名单模式+需要登录
$baned = 23;
block($baned);
}

Loading…
Cancel
Save