|
<?php
/**
* 调用方式:xxx.php?id=xxx
* 宜昌综合,3xgd.php?id=1
* 宜昌生活,3xgd.php?id=2
* 宜昌公共,3xgd.php?id=11
*/
$channel = empty($_GET['id']) ? '1' : trim($_GET['id']);
$cachefile = $_SERVER["DOCUMENT_ROOT"].'/Cache/3xgd/';
if(!is_dir($cachefile))mkdir($cachefile, 0777, true);
$cachefile .= $channel;
if(file_exists($cachefile)&&filemtime($cachefile)>time()-3000){
$playurl = file_get_contents($cachefile);
}else{
$json_content = '{"info": "\u0000"}';
$json_key = json_decode($json_content,true);
$content = _getInfo('', 0);
preg_match("|js_decrpyt\('(.*?)'|i",$content, $encrypt_data);
preg_match("|set\-cookie: acw_tc=(.*?);|i",$content, $js_cookie);
$getjsinfo = _getInfo($js_cookie[1], 1);
preg_match("|var key = '(.*?)';|i",$getjsinfo, $js_key);
preg_match("|var iv = '(.*?)';|i",$getjsinfo, $js_iv);
$encrypt_key = $js_key[1].$json_key['info'];
$encrypt_iv = base64_decode($js_iv[1]);
$encrypt_data = $encrypt_data[1];
$decrypt_data = openssl_decrypt($encrypt_data, 'aes-128-cbc', $encrypt_key, OPENSSL_ZERO_PADDING, $encrypt_iv);
$playurl = str_replace($json_key['info'], "", $decrypt_data);
file_put_contents($cachefile,$playurl);
}
header("Location: ".str_replace("waplive.", "applive.", $playurl));
function _getInfo($cookie, $mode){
$url = $mode==0 ? "http://m.3xgd.com/live/tv/channelid/{$channel}.html" : "http://m.3xgd.com/live/geturl";
$referer = $mode==0 ? "http://m.3xgd.com/" : "http://m.3xgd.com/live/tv/channelid/1.html";
if($mode==0){
$header = array("Connection: keep-alive",'Cache-Control: max-age=0','Upgrade-Insecure-Requests: 1',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6',
);
} else {
$header = array('Connection: keep-alive','Accept: */*','Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6','Cookie: acw_tc='.$cookie);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; Android 10; 360safe Plus Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko)');
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
?>
连id都不用http://gnp638pw06.xg3.1134184.xyz/22.php
|
|