|
看兰州php 求解答 @ 根据大佬帖子修改的 好像验证ip之类的
<?php
error_reporting(0);
date_default_timezone_set("PRC");
$ts = $_GET['ts']??'';
if ($ts){
$decodedUts = urldecode($ts);
$data = get_curl($decodedUts);
header('Content-Type: video/MP2T');
header("Content-Disposition: inline; filename={$ts}.ts");
} else {
$https = isset($_SERVER['HTTPS'])?'https':'http';//当前请求的主机使用的协议。
$http_host = $_SERVER['HTTP_HOST'];//当前请求的主机名。
$requestUri = $_SERVER['REQUEST_URI'];//获取当前请求的 URI
$decodedUri = urldecode($requestUri);//URL解码
$Uripath = explode('?',$decodedUri)[0];//strstr($decodedUri,'?',true);
$urlp = "{$https}://{$http_host}{$Uripath}?ts=";
$url = 'http://liveplus.lzr.com.cn/wlpd/HD/live.m3u8';
$m3u8 = get_curl($url);
$urlpath = dirname($url).'/';
$m3u8s = explode("\n",trim($m3u8));
$data = '';
foreach($m3u8s as $m3u8l){
if (stripos($m3u8l,'.ts')!==false){
$data .= $urlp.urlencode($urlpath.$m3u8l).PHP_EOL;
} else {
$data .= $m3u8l.PHP_EOL;
}
}
header("Content-Type: application/vnd.apple.mpegurl");
header("Content-Disposition: inline; filename=index.m3u8");
}
echo $data;
exit;
function get_curl($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, 'https://lanzhoubcnew.zainanjing365.com/share/live/detailTv?resourceId=14&appscheme=gdmm-ailanzhou');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
|
|