|
|
|
<?php
|
|
|
|
// 防止外部破解
|
|
|
|
if(!defined('SYSTEM')) {exit(BLOCK_RETURN);}
|
|
|
|
|
|
|
|
function get_webpage($url,$host="",$ip="") {
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
if (PROXY_ON == 1) { // 指定代理
|
|
|
|
curl_setopt($ch, CURLOPT_PROXYTYPE, PROXY_TYPE);
|
|
|
|
curl_setopt($ch, CURLOPT_PROXY, PROXY_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_SSL_VERIFYPEER, false);
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
|
|
"User-Agent: ".@$_SERVER["HTTP_USER_AGENT"]
|
|
|
|
));
|
|
|
|
$output = curl_exec($ch);
|
|
|
|
curl_close($ch);
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_host($type,$cache_type) {
|
|
|
|
switch ($type) {
|
|
|
|
case 1: // playurl
|
|
|
|
switch (AREA) {
|
|
|
|
case "cn":
|
|
|
|
$host = CUSTOM_HOST_CN;
|
|
|
|
break;
|
|
|
|
case "tw":
|
|
|
|
$host = CUSTOM_HOST_TW;
|
|
|
|
break;
|
|
|
|
case "hk":
|
|
|
|
$host = CUSTOM_HOST_HK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$host = CUSTOM_HOST_DEFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0: // search
|
|
|
|
if ($cache_type == "app"){
|
|
|
|
switch (AREA) {
|
|
|
|
case "cn":
|
|
|
|
$host = CUSTOM_HOST_CN_SEARCH;
|
|
|
|
break;
|
|
|
|
case "tw":
|
|
|
|
$host = CUSTOM_HOST_TW_SEARCH;
|
|
|
|
break;
|
|
|
|
case "hk":
|
|
|
|
$host = CUSTOM_HOST_HK_SEARCH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$host = CUSTOM_HOST_DEFAULT_SEARCH;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (AREA) {
|
|
|
|
case "cn":
|
|
|
|
$host = CUSTOM_HOST_CN_WEB_SEARCH;
|
|
|
|
break;
|
|
|
|
case "tw":
|
|
|
|
$host = CUSTOM_HOST_TW_WEB_SEARCH;
|
|
|
|
break;
|
|
|
|
case "hk":
|
|
|
|
$host = CUSTOM_HOST_HK_WEB_SEARCH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$host = CUSTOM_HOST_DEFAULT_WEB_SEARCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
return $host;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
?>
|