|
本帖最后由 白嫖怪 于 2022-7-7 19:10 编辑
优化代码2022.7.7
<?php
error_reporting(0);
header('Content-type:text/html;charset=utf-8');
$url=$_GET["url"];
if(!isset($url)){exit("请带参数运行!<br>例:?url=视频地址!");}
function play($pwd, $data)
{
$cipher = '';
$key[] = "";
$box[] = "";
$pwd_length = strlen($pwd);
$data_length = strlen($data);
for ($i = 0; $i < 256; $i++) {
$key[$i] = ord($pwd[$i % $pwd_length]);
$box[$i] = $i;
}
for ($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $key[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for ($a = $j = $i = 0; $i < $data_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$k = $box[(($box[$a] + $box[$j]) % 256)];
$cipher .= chr(ord($data[$i]) ^ $k);
}
return $cipher;
}
if (empty($url)) {
exit($html);
} else {
$preg = "/^http(s)?:\\/\\/.+/";
$type = '';
if(preg_match($preg,$url)){//判断是否为网址
}}
if($type == ''){
$fh = get_url("https://yueliang.cf:3211/ck/json.php?url=".$url);
$jx = json_decode($fh, true);
$type = base64_encode(play(base64_encode(play($url,Date($url))), $jx['url']));
$metareferer = $jx['metareferer'];
if($metareferer == ""){
$metareferer = "never";
}
}
if($type == ''){
exit('<html><title>ckplayerx3播放器</title><meta name="robots" content="noarchive">
<style>h1{color:#FFFFFF; text-align:center; font-family: Microsoft Jhenghei;}p{color:#CCCCCC; font-size: 1.2rem;text-align:center;font-family: Microsoft Jhenghei;}</style>
<body bgcolor="#000000"><table width="100%" height="100%" align="center"><td align="center"><h1>解析失败,请刷新重试或检查地址~</font><font size="2"></font></p></table></body><script src="https://yueliang.cf:3211/ck/jquery.min.js"></script><script>$("#my-loading", parent.document).remove();</script></html>');
}//
function get_url($url) {
$curl = curl_init();
//1.初始化,创建一个新cURL资源
$UserAgent = $_SERVER['HTTP_USER_AGENT'];
curl_setopt($curl, CURLOPT_URL, $url);
// 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
//在发起连接前等待的时间,如果设置为0,则无限等待。
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//设定是否显示头信息
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//启用时会将服务器服务器返回的"Location: "放在header中递归的返回给服务器,设置可以302跳转
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
curl_setopt($curl, CURLOPT_REFERER, $http_type. $_SERVER['SERVER_NAME'].':'. $_SERVER['SERVER_PORT']. $_SERVER['REQUEST_URI']);
//构造来路
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
//gzip压缩内容
$data = curl_exec($curl);
// 抓取URL并把它传递给浏览器
curl_close($curl);
return $data;
}
$urlhz=getExt2($jx['url']);
if($urlhz=="m3u8"){$plug="m3u8";}elseif($urlhz=="flv"){$plug="flv";}elseif($urlhz=="ts"){$plug="mpegts";}elseif($urlhz=="mp4"){$plug="";}elseif($urlhz=="php"){$plug="m3u8";}else{$plug="";}
$live = $_GET["live"];
if(!isset($live)){$live = "false";}else{$live = "true";}
function getExt2($filename) {
$date = explode('?', $filename);
$date = basename($date[0]);
$date = explode('.', $date);
return $date[1];
}
?>
<html>
<head>
<meta charset="utf-8">
<title>ckplayerx3播放器</title>
<meta name="referrer" content="no-referrer">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="https://yueliang.cf:3211/ck/ckplayer.css">
<script type="text/javascript" charset="utf-8" src="https://yueliang.cf:3211/ck/ckplayer.js"></script>
<script type="text/javascript" charset="utf-8" src="https://yueliang.cf:3211/ck/setting.js"></script>
</head>
<body style="margin:0px;padding:0px;">
<div id="ck"></div>
<script type="text/javascript">
var url="<?php echo $url;?>";
var key="<?php echo $type;?>";
var time="<?php echo time();?>";
var ok=new Ckey({
container:"#ck", //容器的ID或className
<?php
function is_mobile(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
}
$is_mobile=is_mobile();
if($is_mobile){
echo "autoplay:false,";//因部分手机浏览器不支持自动播放手机默认关闭自动播放
}else{
echo "autoplay:true,";//电脑默认自动播放
}
?>//自动播放
screenshot:true,//截图
rightBar:true,//右边控制栏
smallWindows:true,//小窗口
webFull:true,//全屏
theatre:true,//剧场模式
playbackrateOpen:true,//倍速
seek:"cookie",//指定跳转到cookie记录的时间,使用该属性必需配置属性cookie
cookie:"<?php echo md5($url);?>",//cookie名称,请在同一域中保持唯一
live:<?php echo $live;?>,//直播模式
plug:"<?php echo $plug;?>",//加载插件
video:decodeURIComponent(play(key,"<?php echo base64_encode(play($url,Date($url)));?>",1)),
});
ok.ended(function(){
window.location.reload();}
);
</script>
</body>
</html>
|
|