资源分享

腾讯视频解析源码

腾讯视频解析源码

(.*)#',$content,$names);
preg_match('#"drm":(0|1|2),#iU',$content,$isdrm);
$cid = empty($id[1])? 0 :$id[1];
$vid = $id[2];
$drm = $isdrm[1];//是否付费
} elseif (strstr($url,"y.qq.com")==true) {
//腾讯音乐MV
$content = GlobalBase::curl($url);
preg_match('#mvvid":"(\w+)","#',$content,$id);
$vid = $id[1];
$ids['type'] = 'mv';
$ids['vid'] = $vid;
echo json_encode(Vqq::get_mv_info($ids));exit;
} else {
//腾讯VID模式
$vid = $url;
}

$ids['vid'] = !empty($vid) ? $vid : exit('解析错误');
$ids['cid'] = !empty($cid) ? $cid : '';
$ids['drm'] = !empty($drm) ? $drm : 0 ;
$ids['ctime'] = date('Y-m-d h:i:s', time());
$ids['name'] = isset($names[1]) ? $names[1] : '';
$ids['rnd'] = !empty($url['rnd']) ? $url['rnd'] : time();
$ids['img'] = !empty($url['img']) ? $url['img'] : "https://shp.qpic.cn/qqvideo_ori/0/{$vid}_496_280/0";
$ids["guid"] = self::createGUID(); // md5(Ckey7::getEncryptVer7());
$ids["pid"] = md5(time());
$ids['appver'] = !empty($url['appver']) ? $url['appver'] : "3.4.31";
$ids['sdtfrom'] = !empty($url['sdtfrom']) ? $url['sdtfrom'] : "v1010";
$ids['platform'] = !empty($url['platform']) ? $url['platform'] : "10901";
$ids["tm"] = time();
$ids['hd'] = isset($url['hd'])?$url['hd']:'3';
$ids['flowid'] = !empty($url['flowid']) ? $url['flowid'] : $ids["pid"] . "_" . $ids['platform'];
$ckey7 = Ckey7::index($ids["vid"],$ids["tm"],$ids["platform"],$ids["sdtfrom"],$ids['appver']);
$ids["encryptVer"] = $ckey7["encryptVer"];
$ids['cKey'] = $ckey7["ckey"];
$ids['pageUrl'] = $url;
$ids['url'] = $url;
$ids['poster'] = $ids['img'];
$ids['osname'] = strpos($_SERVER["HTTP_USER_AGENT"],"Windows") ? 'windows' : 'mac' ;
$ids['osver'] = "windows" == $ids['osname'] ? "6.1" : "10.12.3";
$ids['dltype'] = !empty($url['dltype']) ? $url['dltype'] : 1;
$ids['pversion'] = 3 == $ids['dltype'] ? "safarihls" : "html5hd";
$ids['link'] = !empty($url['link']) ? $url['link']:"1";
$ids['pvid'] = intval(50000000 * (0 + mt_rand()/mt_getrandmax()*(1-0)));
$d = isset($ids['cover']) ? "https://v.qq.com/x/cover/" .$ids['cover']. "/" .$ids['vid']. ".html" : "https://v.qq.com/x/page/" .$ids['vid']. ".html";

$h = array();
array_push($h,GlobalBase::is_https()."btrace.video.qq.com/kvcollect?BossId=3098&Pwd=390647416&oper=1&main_type=&uin=0&host=v.qq.com&url=" . urlencode($d) . "&_dc=" . GlobalBase::random());
array_push($h,GlobalBase::is_https()."btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid=" .$ids["guid"]. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1920*1080*1&testid=&osver=" .$ids['osname']. "+" .$ids['osver']. "&playerver=" .$ids['appver']. "&playertype=1&uip=&confid=&cdnip=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=&p2pver=&url=" .urlencode($d). "&refer=http%3A%2F%2Fv.qq.com%2F&ua=" . urlencode($_SERVER['HTTP_USER_AGENT']) . "&ptag=&flowid=" .$ids['pid']. "_" .$ids['platform']. "&platform=" .$ids['platform']. "&dltype=" .$ids['dltype']. "&vid=" .$ids['vid']. "&fmt=&rate=&clip=&status=&type=&duration=&data=%7B%22code%22%3A%22%22%2C%22stime%22%3A" .GlobalBase::getMillisecond(). "%7D&step=0&seq=0");
array_push($h,GlobalBase::is_https()."btrace.video.qq.com/kvcollect?BossId=4564&Pwd=213967996&loginid=&loginex=&logintype=&guid=" .$ids['guid']. "&online=1&resolution=1920*1080*1&osver=" .$ids['osname']. "+" .$ids['osver']. "&playerver=" .$ids['appver']. "&playertype=1&flowid=" .$ids['pid']. "_" .$ids['platform']. "&platform=" .$ids['platform']. "&vid=" .$ids['vid']. "&url=" . urlencode($d) . "&refer=http%3A%2F%2Fv.qq.com%2F&ua=" . urlencode($_SERVER['HTTP_USER_AGENT']) . "&ptag=&data=%7B%22name%22%3A%22H5PlayerAd%22%2C%22ptime%22%3A0%2C%22stime%22%3A" .GlobalBase::getMillisecond(). "%2C%22etime%22%3A" . (GlobalBase::getMillisecond() + 33) . "%2C%22url%22%3A%22%2F%2Fca.gtimg.com%2Fadplugin%2Fjs%2Fadplayer.js%3F_ts%3D20170414%22%7D&step=61");

self::report_urls($h,$ids);

return $ids;
}

public static function get_video($ids)
{
if (!empty($ids['music'])&&$ids['music'] == 'mv') {
$ids['drm'] = 1;
}
if (1 == $ids['drm']) {
$data = Vqq::get_pc_data($ids);
if (empty($data['data']['url'])) {
$arr = array(
'code' => 302,
'msg' => '视频正在加载···请稍后···',
'url' => '../yun/?url='.$ids['url']
);
$data = $arr;

}
} else {
if (GlobalBase::is_ipad()) {
$data = Vqq::get_pc_data($ids);
} else {
$data = Vqq::get_pc_data($ids);
}
}
return $data;
}

public static function get_pc_data($ids)
{
$ids['guid'] = self::createGUID();
$ids['platform'] = '10201';
$ids['sdtfrom'] = 'v1010';
$ids['d'] = '';
$ids['ua'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4';
$ids['flowid'] = $ids["pid"] . "_" . $ids['platform'];
$ckey7 = Ckey7::index($ids["vid"],$ids["tm"],$ids["platform"],$ids["sdtfrom"],'3.5.41');
$ids["encryptVer"] = $ckey7["encryptVer"];
$ids['cKey'] = $ckey7["ckey"];
$ids['cookie'] = COOKIE_VQQ;
self::getPushGuid($ids);

$vinfoparam = array(
'charge' => 0,
'defaultfmt' => 'auto',
'otype' => 'json',
'guid' => $ids['guid'],
'flowid' => $ids['flowid'],
'platform' => $ids['platform'],
'sdtfrom' => $ids['sdtfrom'],
'defnpayver' => 1,
'appVer' => '3.5.41',
'host' => 'film.qq.com',
'refer' => 'http://film.qq.com/film_index_prevue/index.html?firstVid=' . $ids['vid'],
'ehost' => 'http://film.qq.com/film_index_prevue/index.html',
'sphttps' => 1,
'tm' => time(),
'spwm' => 4,
'vid' => $ids['vid'],
'defn' => GlobalBase::is_ipad() ? 'mp4' : 'fhd',
'fhdswitch' => 0,
'show1080p' => 0,
'isHLS' => 1,
'dtype' => 3,
'defsrc' => 1,
'encryptVer' => $ids['encryptVer'],
'cKey' => $ids['cKey']
);

$d['buid'] = 'vinfoad';
$d['vinfoparam'] = http_build_query($vinfoparam);

$ids['data'] = json_encode($d);
$api = "https://vd.l.qq.com/proxyhttp";

$data = self::curl($api,$ids);

preg_match('#QZOutputJson=(.*);"}#',str_replace("\\","",$data),$body);

if (isset($body[1])) {
$data = json_decode($body[1],true);
$ids['name'] = isset($data['vl']['vi'][0]['ti']) ? $data['vl']['vi'][0]['ti'] : $ids['name'];
if ($data['vl']['vi'][0]['drm'] ==1 && $data['s'] == 'f') {
$data = Vqq::getdrm($ids);
if (!empty($data['data']['url'])) {
$videoinfo = $data;
} else {
$videoinfo['code'] = 302;
$videoinfo['msg'] = $ids['name'] . ' - 视频正在加载···请稍后···';
$videoinfo['url'] = '../yun/?url='.$ids['url'];
}
} else {
if ($data['dltype'] == 3) {
$e = $data['vl']['vi'][0]['ul']['ui'][0]['url'].$data['vl']['vi'][0]['ul']['ui'][0]['hls']['pt'];
$e = str_replace('ltsdl.qq.com', 'stsws.qq.com', $e);
$ids['d'] = $e;
self::getPushGuid($ids);
} else if ($data['dltype'] == 1) {
$e = $data['vl']['vi'][0]['ul']['ui'][0]['url'].$data['vl']['vi'][0]['fn'].'?sdtfrom=' .$ids['sdtfrom']. '&guid=' .$ids['guid']. '&vkey=' .$data['vl']['vi'][0]['fvkey']. '&platform=2';
$ids['d'] = $e;
self::getPushGuid($ids);
}
if (!empty($e)) {
$videoinfo['code'] = 200;
$videoinfo['play'] = 'hls';
if (GlobalBase::is_ipad()) {
$videoinfo['type'] = 'qq';
}
$videoinfo['msg'] = $ids['name'] . ' - 解析完成 - 腾讯视频';
$videoinfo['data']['url'] = $e;
} else {
$videoinfo['code'] = 302;
$videoinfo['url'] = '../yun/?url='.$ids['url'];
}

}
} else {
$videoinfo['code'] = 302;
$videoinfo['msg'] = $ids['name'] . ' - 视频正在加载···请稍后···';
$videoinfo['url'] = '../yun/?url='.$ids['url'];
}

return $videoinfo;
}

public static function get_mp4_data($ids)
{
$ids['platform'] = 11;
$ids['appver'] = '3.2.19.333';
$parmas = array(
'otype' => 'json',
'platform' => $ids['platform'],
'vid' => $ids['vid'],
'defnpayver' => 1,
'appver' => $ids['appver'],
'defn' => 'fhd'
);
self::getPushGuid($ids);

$api = 'http://vv.video.qq.com/getinfo?'. http_build_query($parmas);

$data = self::curl($api,$ids);
preg_match('#QZOutputJson=(.*);#',str_replace("\\","",$data),$body);
$data = json_decode($body[1],true);

$fi = $data['fl']['fi'];
$video = $data['vl']['vi'][0];
$ci = $video['cl']['ci'];
$ids['fn'] = $video['fn'];
$ids['title'] = $video['ti'];
$ids['td'] = (float)($video['td']);
$ids['fvkey'] = $video['fvkey'];
$ids['drm'] = $video['drm'];

$cdn_url_1 = $cdn_url_2 = $cdn_url_3 = '';
foreach ($video['ul']['ui'] as $key => $value) {
$cdn_url = $value['url'];
if ($cdn_url == 'http://video.dispatch.tc.qq.com/') {
$cdn_url_3 = $cdn_url;
} elseif ($cdn_url_2 == '') {
$cdn_url_2 = $cdn_url;
} elseif ($cdn_url_1 == '') {
$cdn_url_1 = $cdn_url;
}
$dt = $value['dt'];
if ($dt == 1) {
$type_name = 'flv';
} elseif ($dt == 2) {
$type_name = 'mp4';
}
$_num_clips = $video['cl']['fc'];
}

foreach ($fi as $k => $v) {
$fmt_id = $v['id'];
$fmt_name = $v['name'];
$fmt_cname = $v['cname'];
$size = $v['fs'];

$fns = explode('.',$ids['fn']);
$fmt_id_num = $fmt_id;
$fmt_id_prefix = '';
$num_clips = 0;

if ($fmt_id_num > 100000) {
$fmt_id_prefix = 'm';
} elseif ($fmt_id_num > 10000) {
$fmt_id_prefix = 'p';
$num_clips = !empty($_num_clips) ? $_num_clips : 1;
}
if (isset($fmt_id_prefix)) {
$fmt_id_name = $fmt_id_prefix . ($fmt_id_num % 10000);
$fns[1] = $fmt_id_name;

}

if ($num_clips == 0) {
# code...
} else {
for ($i=1; $i < ($num_clips+1) ; $i++) { $filename = $fns[0].'.'.$fns[1].'.'.$i.'.'.$fns[2]; $vip = self::qq_get_final_url($cdn_url, $ids['vid'], $fmt_id, $filename, $ids['fvkey'], '11'); $cd[$i]['file'] = $vip; $ids['d'] = $vip; self::getPushGuid($ids); $cd[$i]['duration'] = $ci[$i-1]['cd']; $cd[$i]['bytesTotal'] = (string)$ci[$i-1]['cs']; } $cc[$k]['video'] = $cd; $cc[$k]['type'] = 'mp4'; $cc[$k]['weight'] = $fmt_name == 'shd' ? 10 : 0 ; $cc[$k]['definition'] = $fmt_cname; } } $videoinfo['flashplayer'] = true; $videoinfo['poster'] = $ids['poster']; $videoinfo['video'] = $cc; print_r(json_encode($videoinfo));exit; } public static function getinfo($ids){ $e = self::qq_data(["sd", "hd", "shd"], (!empty($ids['hd']) ? $ids['hd'] : 3)); $api = GlobalBase::is_https().'vv.video.qq.com/geth5info?'; $ids['defn'] = $e; $__a['defn'] = $e; $__a['vid'] = $ids['vid']; $__a['charge'] = 0; $__a['defaultfmt'] = "auto"; $__a['otype'] = "json"; $__a['guid'] = $ids['guid']; $__a['flowid'] = $ids['flowid']; $__a['platform'] = $ids['platform']; $__a['sdtfrom'] = $ids['sdtfrom']; $__a['defnpayver'] = 1; $__a['appVer'] = $ids['appver']; $__a['host'] = 'v.qq.com'; $__a['ehost'] = $ids['pageUrl']; $__a['sphttps'] = GlobalBase::is_https() == 'https://' ? 1 : 0 ; $__a['tm'] = $ids['rnd']; $__a['spwm'] = 4; $__a['encryptVer'] = $ids['encryptVer']; $__a['cKey'] = $ids['cKey']; $_api1 = $api . http_build_query($__a); //$ids['cookie'] = COOKIE_VQQ; $_b = self::curl($_api1,$ids); preg_match('#QZOutputJson=(.*);#',str_replace("\\","",$_b),$__b); $__b_a = json_decode($__b[1],true); if (!empty($__b_a['msg'])) { "IP limit" == $__b_a['msg'] ? Vqq::getfile($ids) : $GLOBALS['ipc']['data']['error'] = "视频链接错误!"; } else { if ($__b_a['vl']['vi'][0]['lnk'] && $__b_a['vl']['vi'][0]['lnk'] != $ids['vid']) { $ids['vid'] = $__b_a['vl']['vi'][0]['lnk']; $_key = Ckey7::index($ids["vid"],$ids["tm"],$ids["platform"],$ids["sdtfrom"],$ids["appver"]); $ids['cKey'] = $_key['ckey']; //print_r($ids);exit; } $_b_e = !empty($__b_a['ip']) ? $__b_a['ip'] : "" ; $_b_m = !empty($__b_a['vl']['vi'][0]['fvkey']) ? $__b_a['vl']['vi'][0]['fvkey'] : "" ; $_b_f = !empty($__b_a['vl']['vi'][0]['fn']) ? $__b_a['vl']['vi'][0]['fn'] : "" ; $_b_d = !empty($__b_a['vl']['vi'][0]['ul']['ui'][0]['vt']) ? $__b_a['vl']['vi'][0]['ul']['ui'][0]['vt'] : "" ; $_b_c = !empty($ids['cdn']) ? $ids['cdn'] : (!empty($__b_a['vl']['vi'][0]['ul']['ui'][0]['url']) ? $__b_a['vl']['vi'][0]['ul']['ui'][0]['url'] : ""); "fhd" == $__b_a['fl']['fi'][count($__b_a['fl']['fi']) - 1]['name'] && array_pop($__b_a['fl']['fi']); $_b_l = !empty(self::qq_data($__b_a['fl']['fi'], $ids['hd'], "id")) ? self::qq_data($__b_a['fl']['fi'], $ids['hd'], "id") : ""; $_b_h = !empty(self::qq_data($__b_a['fl']['fi'], $ids['hd'], "name")) ? self::qq_data($__b_a['fl']['fi'], $ids['hd'], "name") : ""; $_b_p = !empty(self::qq_data($__b_a['fl']['fi'], $ids['hd'], "br")) ? self::qq_data($__b_a['fl']['fi'], $ids['hd'], "br") : ""; $_b_n = ""; switch (substr($_b_l,0,2)) { case '10': $_b_n = "p" . substr($_b_l,2); break; case '11': $_b_n = "p" . substr($_b_l,1); break; default: $_b_n = $_b_l; break; } $_b_t = !empty($__b_a['vl']['vi'][0]['cl']['fc']) ? $__b_a['vl']['vi'][0]['cl']['fc'] : ""; $_b_u = !empty($__b_a['vl']['vi'][0]['td']) ? $__b_a['vl']['vi'][0]['td'] : ""; $_b_r = isset($__b_a['vl']['vi'][0]['drm']) ? $__b_a['vl']['vi'][0]['drm'] : $ids['drm']; $ids['format'] = $_b_l; $ids['fc'] = isset($__b_a['vl']['vi'][0]['cl']['fc']) ? $__b_a['vl']['vi'][0]['cl']['fc'] : ""; $ids['fp'] = $_b_n; $ids['vt'] = $_b_d; $ids['vu'] = $_b_c; $ids['drm'] = $_b_r; $ids['fmt'] = $_b_h; $ids['dur'] = $_b_u; $ids['segs'] = isset($__b_a['vl']['vi'][0]['cl']['ci']) ? $__b_a['vl']['vi'][0]['cl']['ci'] : ""; $ids['uip'] = isset($_b_e) ? $_b_e : ""; $ids['dltype'] = isset($__b_a['dltype']) ? $__b_a['dltype'] : ""; $ids['br'] = isset($_b_p) ? $_b_p : ""; $ids['cover'] = !empty($ids['cover']) ? $ids['cover'] : ""; $ids['title'] = isset($__b_a['vl']['vi'][0]['ti']) ? $__b_a['vl']['vi'][0]['ti'] : ""; $ids['fvkey'] = $_b_m; $_tmp_b_b = explode('.',$_b_f); $_b_b = !empty($_tmp_b_b[2]) ? $ids['vid'] . "." . $_b_n . ".1.mp4" : $_b_f ; $_b_q = $ids['vu'] . $_b_b . "?sdtfrom=v1010&guid=" . $ids['guid'] . "&vkey=" . $_b_m; $_b_k = []; $_b_qq = ""; $GLOBALS['ipc']['data']['title'] = $ids['title']; $GLOBALS['ipc']['data']['image'] = $ids['img']; $GLOBALS['ipc']['data']['duration'] = $ids['dur']; $GLOBALS['ipc']['report'] = []; if (!empty($ids['music'])&&$ids['music'] == 'mv') { $ids['drm'] = 1; } if (1 == $ids['drm']) { $_D_data = Vqq::get_pc_data($ids); if (empty($_D_data['data']['url'])) { $data = Vqq::getdrm($ids); $_D_data['code'] = 200; $_D_data['play'] = 'ajax'; $_D_data['type'] = 'qq'; $_D_data['data'] = $data['data']; if (!empty($data['video']['file'])) { //$_D_data['code'] = 200; //$_D_data['play'] = 'h5mp4'; $_D_data['data'] = $data['data']; } } } else { if (GlobalBase::is_ipad()) { $_D_data = Vqq::get_pc_data($ids); } else { $_D_data = Vqq::get_pc_data($ids); } } //第三部分上报地址 array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=3487&Pwd=745225177&itype=0&idx=1&ptag=&qtag=x&refer=http%3A%2F%2Fv.qq.com%2F&url=" . urlencode($ids['url']) . "&type=2&_=" . ceil(1000 * GlobalBase::random())); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&seq=1&loginid=&loginex=&logintype=0&guid=" .$ids['guid']. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1920*1080*1&testid=&osver=" .$ids['osname']. "+" .$ids['osver']. "&playerver=" .$ids['appver']. "&playertype=1&uip=&confid=&cdnip=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=&p2pver=&url=" . urlencode($ids['url']) . "&refer=http%3A%2F%2Fv.qq.com%2F&ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ptag=&flowid=" .$ids['pid']. "_" .$ids['platform']. "&platform=" .$ids['platform']. "&dltype=" .$ids['dltype']. "&vid=" .$ids['vid']. "&fmt=&rate=&clip=&status=&type=&duration=&data=%7B%22stime%22%3A" . (GlobalBase::getMillisecond() - 5000 - ceil(25 * GlobalBase::random())) . "%2C%22etime%22%3A" .GlobalBase::getMillisecond(). "%2C%22code%22%3A%22%22%7D&step=5"); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=3721&Pwd=1636975887&version=" .$ids['appver']. "&uid=" .$ids['guid']. "&pid=" .$ids['pid']. "&vid=" .$ids['vid']. "&player_type=" .$ids['pversion']. "&video_type=1&platform=" .$ids['platform']. "&url=" . urlencode($ids['url']) . "&filename=txplayer.js&sub_version=58.0.300" . ceil(GlobalBase::random() * 10) . "." . ceil(GlobalBase::random() * 10) . "&_dc=" . GlobalBase::random() . "&browser=chrome&osname=" .$ids['osname']. "&osver=" .$ids['osver']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&hh_ref=" . urlencode($ids['pageUrl'])); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4564&Pwd=213967996&flowid=" .$ids['pid']. "_" .$ids['platform']. "&data=%7B%22stime%22%3A" .GlobalBase::getMillisecond(). "%2C%22etime%22%3A" . (GlobalBase::getMillisecond() + 800 + ceil(100 * GlobalBase::random())) . "%2C%22code%22%3A%22%22%2C%22ip%22%3A%22" .$ids['uip']. "%22%2C%22url%22%3A%22" .urlencode($api). "&step=15"); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid=" .$ids['guid']. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1920*1080*1&testid=&osver=" .$ids['osname']. "+" .$ids['osver']. "&playerver=" .$ids['appver']. "&playertype=1&uip=" .$ids['uip']. "&confid=&cdnip=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=&p2pver=&url=" . urlencode($ids['pageUrl']) . "&refer=http%3A%2F%2Fv.qq.com%2F&ua=" . urlencode($ids['pageUrl']) . "&ptag=&flowid=" .$ids['pid']. "_" .$ids['platform']."&platform=" .$ids['platform']. "&dltype=" .$ids['dltype']. "&vid=" .$ids['vid']. "&fmt=" .$ids['format']. "&rate=" .$ids['br']. "&clip=" .$_b_t. "&status=2&type=1036&duration=" .$ids['dur']. "&data=%7B%22ip%22%3A%22" .$ids['uip']. "%22%2C%22stime%22%3A" .GlobalBase::getMillisecond(). "%2C%22etime%22%3A" . (GlobalBase::getMillisecond() + 800 + ceil(100 * GlobalBase::random())) . "%2C%22code%22%3A%22%22%7D&step=15&seq=2"); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=" .$ids['cover']. "&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&vt=&type=&url=" . urlencode($ids['pageUrl']) . "&bi=&bt=&version=" .$ids['appver']. "&platform=" .$ids['platform']. "&format=&defn=&ctime=" . urlencode($ids['ctime']) . "&ptag=&isvip=0&tpid=2&pversion=" .$ids['pversion']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=&iformat=&hh_ref=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&v_idx=0&rcd_info=&vurl=&step=3&val=1&idx=0&isfocustab=1&isvisible=1"); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=" .$ids['cover']. "&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&vt=0&type=1036&url=" .urlencode($ids['pageUrl']). "&bi=" .$_b_qq. "&bt=" .intval($ids['dur'],10). "&version=" .$ids['appver']. "&platform=" .$ids['platform']. "&format=" .$ids['format']. "&defn=" .$ids['fmt']. "&ctime=" .urlencode($ids['ctime']). "&ptag=&isvip=0&tpid=2&pversion=" .$ids['pversion']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=" .$ids['fvkey']. "&iformat=" .$ids['format']. "&hh_ref=" .urlencode($ids['pageUrl']). "&v_idx=0&rcd_info=&vurl=" .urlencode($_b_q). "&step=1011&val1=1&val2=0&val=5" . ceil(100 * GlobalBase::random())); array_push($_D_data['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=" .$ids['cover']. "&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&vt=" .$ids['vt']. "&type=1036&url=" .urlencode($ids['pageUrl']). "&bi=1&bt=" .intval($ids['dur'],10). "&version=" .$ids['appver']. "&platform=" .$ids['platform']. "&format=" .$ids['format']. "&defn=" .$ids['fmt']. "&ctime=" .urlencode($ids['ctime']). "&ptag=&isvip=0&tpid=2&pversion=" .$ids['pversion']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=" . ceil(10000000000 * GlobalBase::random()) . "&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=" .$ids['fvkey']. "&iformat=" .$ids['format']. "&hh_ref=" .urlencode($ids['pageUrl']). "&v_idx=0&rcd_info=&vurl=" .urlencode($_b_q). "&step=4&val=8&val1=1&idx=0&diagonal=1273&isfocustab=1&isvisible=1"); self::report_urls($_D_data['report'],$ids); return $_D_data; } } public static function get_mv_info($ids) { $vid = $ids['vid']; $api = "https://u.y.qq.com/cgi-bin/musicu.fcg?data=%7B%22getMvInfo%22%3A%7B%22module%22%3A%22MvService.MvInfoProServer%22%2C%22method%22%3A%22GetMvInfoList%22%2C%22param%22%3A%7B%22vidlist%22%3A%5B%22".$vid."%22%5D%7D%7D%7D&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq&needNewCode=0"; $_b = self::curl($api); $_b = json_decode($_b,true); $_b_a = $_b['getMvInfo']['data']['mvlist'][0]; $ids['poster'] = $_b_a['cover_pic']; $ids['desc'] = $_b_a['desc']; $ids['duration'] = $_b_a['duration']; $ids['fileid'] = $_b_a['fileid']; $ids['mvid'] = $_b_a['mvid']; $ids['name'] = $_b_a['name']; $ids['pay'] = $_b_a['pay']; $ids['size'] = $_b_a['filesize']['mp4']; if (!empty($vid)&&!empty($ids['fileid'])) { $api_1 = "https://u.y.qq.com/cgi-bin/musicu.fcg?data=%7B%22getMvUrl%22%3A%7B%22module%22%3A%22Mv.MvDownloadUrlServer%22%2C%22method%22%3A%22GetMvUrls%22%2C%22param%22%3A%7B%22fileid%22%3A%5B%22".$ids['fileid']."%22%5D%2C%22filetype%22%3A%5B-1%5D%7D%7D%7D&g_tk=5381&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=GB2312¬ice=0&platform=yqq&needNewCode=0"; $_c = self::curl($api_1); $_c = json_decode($_c,true); $_c_a = $_c['getMvUrl']['data']['data'][$ids['fileid']]; if (!empty($_c_a)) { foreach ($_c_a as $k => $v) {
$key = $v['filetype'];
if ($ids['size'][$k] == 0) {
continue;
}
switch ($key) {
case '0':$def = "流畅";break;
case '10':$def = "标清";break;
case '20':$def = "高清";break;
case '30':$def = "超清";break;
case '40':$def = "1080P";break;
}
$dom = $v['url'][mt_rand(0,count($v['url'])-1)];

$vurl = $dom.$v['cn'].'?vkey='.$v['vkey'].'&ocid=317202348';

if (GlobalBase::is_ipad()) {
if($key==20){
$true_url = $vurl;
$videoinfo['code'] = 200;
$videoinfo["data"]["url"] = $true_url;
return $videoinfo;
exit;
}
}else{
if ($key == '40' && $vurl != '') {
$fdata[0]['url'] = $vurl;
$fdata[0]['def'] = '蓝光';
}
if ($key == '30' && $vurl != '') {
$fdata[1]['url'] = $vurl;
$fdata[1]['def'] = '超清';
}
if ($key == '20' && $vurl != '') {
$fdata[2]['url'] = $vurl;
$fdata[2]['def'] = '高清';
}
if ($key == '10' && $vurl != '') {
$fdata[3]['url'] = $vurl;
$fdata[3]['def'] = '流畅';
}
if ($key == '0' && $vurl != '') {
$fdata[4]['url'] = $vurl;
$fdata[4]['def'] = '流畅';
}
}
}
for ($i=0; $i <= 10 ; $i++) { if ($fdata[$i] == '') {continue;} $key_arrays[]=$fdata[$i]; } $videoinfo['code'] = 200; $videoinfo["poster"] = $ids['poster']; $videoinfo["title"] = $ids['name']; $videoinfo['play'] = 'h5mp4'; $videoinfo["data"]["url"] = $key_arrays[0]['url']; return $videoinfo; } } } public static function proxy_http($ids){ $ehost = !empty($ids["cid"]) ? "https://v.qq.com/x/cover/".$ids["cid"]."/".$ids["vid"].".html": "https://v.qq.com/x/page/".$ids["vid"].".html"; $params["buid"] = "onlyvinfo"; $vinfoparam["charge"] = 0; $vinfoparam["defaultfmt"] = "auto"; $vinfoparam["otype"] = "ojson"; $vinfoparam["guid"] = self::createGUID();//设备ID,限速和检测多设备登录使用 $vinfoparam["pid"] = $ids['pid']; $vinfoparam["flowid"] = $ids['flowid'];//播放id $vinfoparam["platform"] = 10201;//10303 10201 $vinfoparam["sdtfrom"] = "v1010";//v5000 v1010 $vinfoparam["defnpayver"] = 1; $vinfoparam["appVer"] = "3.5.35"; $vinfoparam["host"] = "v.qq.com"; $vinfoparam["refer"] = $ehost; $vinfoparam["ehost"] = $ehost; $vinfoparam["sphttps"] = 1; preg_match("#(.*)#",file_get_contents("https://vv.video.qq.com/checktime"),$val);
$ip = $val[1];
$vinfoparam["tm"] = time();
$vinfoparam["spwm"] = 4;//4为 m3u8
$vinfoparam["unid"] = md5($vinfoparam["pid"]);
$vinfoparam["vid"] = $ids["vid"];
$vinfoparam["defn"] = 'mp4';// $ids["defn"];
$vinfoparam["fhdswitch"] = 1;
$vinfoparam["show1080p"] = 1;
$vinfoparam["isHLS"] = 1;
$vinfoparam["onlyGetinfo"] = true;
$vinfoparam["dtype"] = 3;// 3为 m3u8
$vinfoparam["sphls"] = 1;
$vinfoparam["defsrc"] = 2;
$ckey7 = Ckey7::index($vinfoparam["vid"],$vinfoparam["tm"],$vinfoparam["platform"],$vinfoparam["sdtfrom"],$vinfoparam["appVer"]);
$vinfoparam["encryptVer"] = $ckey7["encryptVer"];
$vinfoparam["cKey"] = $ckey7["ckey"];
$vinfoparam["fp2p"] = 1;
$vinfoparam['d'] = '';

self::getPushGuid($vinfoparam);

$params["vinfoparam"] = http_build_query($vinfoparam);

$api = "https://vd.l.qq.com/proxyhttp?buid=onlyvinfo&vinfoparam=".urlencode(http_build_query($vinfoparam));
//$ids['cookie'] = COOKIE_VQQ;
$content = self::curl($api,$ids);

preg_match('#"vinfo":\"(.*)"}#',str_replace("\\","",$content),$body);

$data = json_decode($body[1],true);

$vi = $data["vl"]["vi"][0];
$ui = $vi["ul"]["ui"];
$title = $vi["ti"];//视频标题
$img = "http://puui.qpic.cn/vpic/0/".$vinfoparam["vid"].".png/0";
$videoinfo["poster"]= $img;

$m3u8 = $ui[0]["url"].$ui[0]["hls"]["pt"];

$videoinfo["video"]["file"] = $m3u8;
$videoinfo["video"]["type"] = "video/m3u8";

$vinfoparam["d"] = $m3u8;//要上报的播放地址
$vinfoparam["cid"] = $ids["cid"];
self::getPushGuid($vinfoparam);

return $videoinfo;
}

public static function getdrm($ids)
{
$qv = self::getCtk($ids['vid'],11001,'v1010');
$api = GlobalBase::is_https()."h5vv.video.qq.com/getinfo?charge=0&defaultfmt=auto&otype=json&guid=" . $ids['guid'] . "&flowid=" . $ids['pid'] . "_11001&platform=11001&sdtfrom=v1010&defnpayver=0&appVer=3.3.390&host=m.v.qq.com&ehost=https%3A%2F%2Fm.v.qq.com%2Fplay.html%3Fvid%3D" . $ids['vid'] . "&sphttps=1&_rnd=" . $ids['rnd'] . "&spwm=4&vid=" . $ids['vid'] . "&defn=mp4&fhdswitch=0&show1080p=1&isHLS=0&fmt=auto&defsrc=1&dtype=1&clip=4&sphls=0&_qv_rmt=" . $qv['t1'] . "&_qv_rmt2=" . $qv['t2'];
$data = self::curl($api,COOKIE_VQQ);
preg_match('#QZOutputJson=(.*);#',str_replace("\\","",$data),$json);
if (!empty($json[1])) {

$__tmp_get = json_decode($json[1],true);
$ids['fvkey'] = $__tmp_get['vl']['vi'][0]['fvkey'];
//print_r($__tmp_get);exit;
$__tmp_url = $__tmp_get['vl']['vi'][0]['ul']['ui'][0]['url'] . $__tmp_get['vl']['vi'][0]['fn'] . "?vkey=" . substr($ids['fvkey'],0, 64) . "&sdtfrom=v1010&guid=" . $ids['guid'];

$filename = $__tmp_get['vl']['vi'][0]['ul']['ui'][0]['fn'];

$params = 'http://vv.video.qq.com/getkey?format=2&otype=json&vt=150&vid='.$ids['vid'].'&ran=0\%2E9477521511726081\\&charge=0&filename='.$ids['vid'].'.mp4&platform=11';
$content = self::curl($params,'');
preg_match('#QZOutputJson=(.*);#',str_replace("\\","",$content),$body);
$d = json_decode($body[1],true);
$key = $d['key'];

$_cc['poster'] = $GLOBALS['ipc']['data']['image'];
$_cc['video']['file'] = !empty($GLOBALS['ipc']['data']['mp4']) ? $GLOBALS['ipc']['data']['mp4']['url'] : $GLOBALS['ipc']['data']['segs']['url'];
$_cc['video']['type'] = 'video/mp4';

$_cc['data']['vid'] = $ids['vid'];
$_cc['data']['platform'] = '11001';
$_cc['data']['sdtfrom'] = 'v1010';
$_cc['data']['ckey'] = $key;
$_cc['data']['_rnd'] = $ids['rnd'];
$_cc['data']['guid'] = $ids['guid'];
return $_cc;
}

}
public static function getidx($ids){
if (1 == $ids['drm'] || $ids['ua']) {
$ids['fc'] = 1;
$_c_e = [];
$_c_e[0] = $ids['segs'][0];
$ids['format'] = 2;
} else {
$_c_e = $ids['segs'];
}
$_c_g = (2 == $ids['format']) ? 0 : 1;
$_tmp_data['buid'] = 'onlyvkey';
$_tmp['otype'] = "ojson";
$_tmp['vid'] = $ids['vid'];
$_tmp['format'] = $ids['format'];
$_tmp['idx'] = $_c_g;
$_tmp['vt'] = $ids['vt'];
$_tmp['sdtfrom'] = $ids['sdtfrom'];
$_tmp['platform'] = $ids['platform'];
$_tmp['guid'] = $ids['guid'];
$_tmp['flowid'] = $ids['pid'] . "_" . $ids['format'];
$_tmp['charge'] = 0;
$_tmp['linkver'] = 2;
$_tmp['lnk'] = $ids['vid'];
$_tmp['tm'] = $ids['rnd'];
$_tmp['refer'] = "https://v.qq.com/x/page/" . $ids['vid'] . ".html";
$_tmp['ehost'] = "https://v.qq.com/x/page/" . $ids['vid'] . ".html";
$_tmp['appVer'] = $ids['appver'];
$_tmp['host'] = "v.qq.com";
$_tmp['sphttps'] = 1;
$_tmp['encryptVer'] = $ids['encryptVer'];
$_tmp['cKey'] = $ids['cKey'];
$_tmp_data['vkeyparam'] = http_build_query($_tmp);

$_c_api = "https://vd.l.qq.com/proxyhttp?".http_build_query($_tmp_data);
$_c_tmp_data = self::curl($_c_api,COOKIE_VQQ);

$_c_tmp_a_data = json_decode($_c_tmp_data,true);

if (!empty($_c_tmp_a_data['vkey'])) {

$__data = $_c_tmp_a_data['vkey'];
$__data = json_decode($__data,true);
$__b = $__data['vl']['vi'][0]['cl']['ci'];
$__c='';$__l='';
foreach ($__b as $key => $value) {
//print_r($value);exit;
if ($ids['ua']) {
$__c = $ids['vid'] . ".mp4";
$GLOBALS['ipc']['data']['mp4']['url'] = $ids['vu'] . $__c . "?sdtfrom=" . $ids['sdtfrom'] . "&guid=" . $ids['guid'] . "&vkey=" . $__data['vl']['vi'][0]['cl']['ci'][0]['key'];
$GLOBALS['ipc']['data']['mp4']['duration'] = $ids['dur'];
$GLOBALS['ipc']['data']['mp4']['size'] = "";
} else {
if (2 == $ids['format']) {
$__c = $ids['vid'] . ".mp4";
$GLOBALS['ipc']['data']['segs']['url'] = $ids['vu'] . $__c . "?sdtfrom=" . $ids['sdtfrom'] . "&guid=" . $ids['guid'] . "&vkey=" . $__data['vl']['vi'][0]['cl']['ci'][0]['key'];
$GLOBALS['ipc']['data']['segs']['duration'] = $ids['dur'];
$GLOBALS['ipc']['data']['segs']['size'] = "";
} else {
if (0 == $ids['fc']) {
$__c = $ids['vid'] . "." . $ids['fp'] . "." . $value['idx'] . ".mp4";
$GLOBALS['ipc']['data']['segs']['url'] = $ids['vu'] . $__c . "?sdtfrom=" . $ids['sdtfrom'] . "&guid=" . $ids['guid'] . "&vkey=" . $__data['vl']['vi'][0]['cl']['ci'][0]['key'];
$GLOBALS['ipc']['data']['segs']['duration'] = $ids['dur'];
$GLOBALS['ipc']['data']['segs']['size'] = "";
} else {
$__c = $ids['vid'] . "." . $ids['fp'] . "." . $value['idx'] . ".mp4";
$GLOBALS['ipc']['data']['segs'][$value['idx'] - 1]['url'] = $ids['vu'] . $__c . "?sdtfrom=" . $ids['sdtfrom'] . "&guid=" . $ids['guid'] . "&vkey=" . $value['key'];
$GLOBALS['ipc']['data']['segs'][$value['idx'] - 1]['duration'] = $ids['segs'][$key]['cd'];
$GLOBALS['ipc']['data']['segs'][$value['idx'] - 1]['size'] = $ids['segs'][$key]['cs'];
}
}

}
}
}

array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=3699&Pwd=1439649858&type=10&pageType=4&usertype=0&playertype=" . $ids['pversion'] . "&ua=" . urlencode($_SERVER['HTTP_USER_AGENT']) . "&url=" . urlencode($ids['pageUrl']) . "&timeType=2&time=" . (18E3 + intval(500 * GlobalBase::random(),10)) . "&_=" . intval(500 * GlobalBase::random()));
array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid={$ids['vid']}&coverid={$ids['cover']}&pid={$ids['pid']}&guid={$ids['guid']}&vt={$ids['vt']}&type=1036&url=" . urlencode($ids['pageUrl']) . "&bi=&bt=&version={$ids['appver']}&platform={$ids['platform']}&format=" . $ids['format'] . "&defn=" . $ids['fmt'] . "&ctime=" . urlencode($ids['ctime']) . "&ptag=&isvip=0&tpid=10&pversion=" . $ids['pversion'] . "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid={$ids['pvid']}&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=" .$__data['key']. "&iformat=" . $ids['format'] . "&hh_ref=" .urlencode($ids['pageUrl']). "&v_idx=0&rcd_info=&vurl=&step=6&val=" . (14E3 + intval(1E3 * GlobalBase::random())) . "&val1=1&idx=0&diagonal=1273&isfocustab=1&isvisible=1");
array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid=" .$ids['guid']. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1920*1080*1&testid=&osver=" .$ids['osname']. "+" .$ids['osver']. "&playerver=" .$ids['appver']. "&playertype=1&uip=" .$ids['uip']. "&confid=&cdnip=&cdnid=" .$ids['vt']. "&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=&p2pver=&url=" .urlencode($ids['pageUrl']). "&refer=&ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ptag=&flowid=" .$ids['pid']. "_" .$ids['platform']. "&platform=" .$ids['platform']. "&dltype=" .$ids['dltype']. "&vid=" .$ids['vid']. "&fmt=" .$ids['format']. "&rate=" .$ids['br']. "&clip=" .$ids['fc']. "&status=2&type=1036&duration=" .$ids['dur']. "&data=%7B%22stime%22%3A" . (GlobalBase::getMillisecond() + intval(1E3 * GlobalBase::random())) . "%2C%22etime%22%3A" . (GlobalBase::getMillisecond() + 1E3 + intval(200 * GlobalBase::random())) . "%2C%22bufferduration%22%3A%22%22%2C%22vt%22%3A" .$ids['vt']. "%2C%22url%22%3A%22%22%2C%22urlindex%22%3A0%2C%22code%22%3A%22%22%7D&step=30&seq=3");
array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=3699&Pwd=1439649858&type=10&pageType=4&usertype=0&playertype=" .$ids['pversion']. "&ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&url=" .urlencode($ids['pageUrl']). "&timeType=1&time=" . (3E3 + intval(500 * GlobalBase::random())) . "&_=" . intval(500 * GlobalBase::random()));
array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=" .$ids['cover']. "&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&vt=" .$ids['vt']. "&type=1036&url=" .urlencode($ids['pageUrl']). "&bi=&bt=" .intval($ids['dur']). "&version=" .$ids['appver']. "&platform=" .$ids['platform']. "&format=" .$ids['format']. "&defn=" .$ids['fmt']. "&ctime=" .urlencode($ids['ctime']). "&ptag=&isvip=0&tpid=10&pversion=" .$ids['pversion']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=" .$ids['pvid']. "&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=" .$__data['key']. "&iformat=" .$ids['format']. "&hh_ref=" .urlencode($ids['pageUrl']). "&v_idx=0&rcd_info=&vurl=&step=35&val=" . (14E3 + intval(1E3 * GlobalBase::random())) . "&val1=&val2=0");
array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=3699&Pwd=1439649858&type=10&pageType=4&usertype=0&playertype=" .$ids['pversion']. "&ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&url=" .urlencode($ids['pageUrl']). "&timeType=3&time=" . (500 + intval(500 * GlobalBase::random())) ."&_=" . intval(500 * GlobalBase::random()));

array_push($GLOBALS['ipc']['report'],"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=" .$ids['cover']. "&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&vt=" .$ids['vt']. "&type=1036&url=" . urlencode($ids['pageUrl']) . "&bi=&bt=" . intval($ids['dur']) . "&version=" .$ids['appver']. "&platform=" .$ids['platform']. "&format=" .$ids['format']. "&defn=" .$ids['fmt']. "&ctime=" .urlencode($ids['ctime']). "&ptag=&isvip=0&tpid=10&pversion=" .$ids['pversion']. "&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=" .$ids['pvid']. "&hc_ssid=&hc_qq=&hh_ua=" .urlencode($_SERVER['HTTP_USER_AGENT']). "&ckey=" .$__data['key']. "&iformat=" .$ids['format']. "&hh_ref=" .urlencode($ids['pageUrl']). "&v_idx=0&rcd_info=&vurl=&step=30&val=" . (14E3 + intval(1E3 * GlobalBase::random())) . "&val1=0&val2=1");

$_cc['poster'] = $GLOBALS['ipc']['data']['image'];
$_cc['video']['file'] = !empty($GLOBALS['ipc']['data']['mp4']) ? $GLOBALS['ipc']['data']['mp4']['url'] : $GLOBALS['ipc']['data']['segs'][0]['url'];
$_cc['video']['type'] = 'video/mp4';

$_cc["report"] = $GLOBALS['ipc']['report'];
//print_r(json_encode($_cc));
return $_cc;

}
public static function getproxyhttp($ids){
$__e = $ids['ua'] ? ["hd"] : ["sd", "hd", "shd"];
$__b = [];
$__g = '';
foreach ($__e as $k => $v) {
$__m['buid'] = 'onlyvinfo';
$__tmp['charge'] = 0;
$__tmp['guid'] = $ids['guid'];
$__tmp['defaultfmt'] = "auto";
$__tmp['otype'] = "ojson";
$__tmp['platform'] = $ids['platform'];
$__tmp['sdtfrom'] = $ids['sdtfrom'];
$__tmp['defnpayver'] = 1;
$__tmp['appVer'] = $ids['appver'];
$__tmp['host'] = "v.qq.com";
$__tmp['refer'] = $ids['pageUrl'];
$__tmp['ehost'] = $ids['pageUrl'];
$__tmp['sphttps'] = 1;
$__tmp['tm'] = $ids['rnd'];
$__tmp['encryptVer'] =$ids['encryptVer'];
$__tmp['cKey'] = $ids['cKey'];
$__tmp['spwm'] = 4;
$__tmp['vid'] = $ids['vid'];
$__tmp['defn'] = $v;
$__tmp['fhdswitch'] = 1;
$__tmp['show1080p'] = 1;
$__tmp['isHLS'] = 1;
$__tmp['onlyGetinfo'] = !0;
$__tmp['dtype'] = 3;
$__tmp['sphls'] = 1;
$__tmp['defsrc'] = 2;
$__m['vinfoparam'] = http_build_query($__tmp);
$_api = "https://vd.l.qq.com/proxyhttp?".http_build_query($__m);
$_c_tmp_data = self::curl($_api,COOKIE_VQQ);

print_r($_c_tmp_data);exit;
$_c_tmp_a_data = json_decode($_c_tmp_data,true);
if ($_c_tmp_a_data['vinfo'] && ($b = json_decode($_c_tmp_a_data['vinfo'],true))){
$d = !empty($b['vl']['vi'][0]['ul']['ui'][0]) ? $b['vl']['vi'][0]['ul']['ui'][0]: "";
if ($d['hls']) {
$c = !empty($d['hls']['pt']) ? $d['hls']['pt'] : '';
} else{
$c = "";
}
$GLOBALS['ipc']['data']['player'] = "dplayer";
if ($c) {
$_cc_d = $d['url'] . $c;
$GLOBALS['ipc']['data']['segs'][$k]['url'] = $_cc_d;
$GLOBALS['ipc']['data']['playtype'] = "hls";
$GLOBALS['ipc']['data']['m3u8'] = $GLOBALS['ipc']['data']['segs'];
} else {
if (!empty($b['vl']['vi'][0]['fvkey'])) {
$_tmp_c = explode('.',$b['vl']['vi'][0]['fn']);
$_tmp_d = $d['url'] . (3 == count($_tmp_c) ? $_tmp_c[0] . "." . $_tmp_c[1] . ".1.mp4" : $b['vl']['vi'][0]['fn']) . "?sdtfrom=" . $ids['sdtfrom'] . "&guid=" . $ids['guid'] . "&vkey=" . $b['vl']['vi'][0]['fvkey'];
$GLOBALS['ipc']['data']['segs'][$k]['url'] = $d;
$GLOBALS['ipc']['data']['segs'][$k]['duration'] = $b['vl']['vi'][0]['td'];
$GLOBALS['ipc']['data']['m3u8'] = $GLOBALS['ipc']['data']['segs'];
}
}
}
}
}

public static function get_pc_app_v2000($ids)
{
$parse['appVer'] = '50170918';
$parse['incver'] = '50170918';
$parse['cKey'] = 'g1MOUcBnhugLEC5QZX_EaD2nG0HFoqsf-f_lhKRr3IaPGR7Ru4KfBOOvPCzVa0S1UzoEgh45AvRLoPCpR24DOrh3JON1Aa01wksTCDsH4gUJAKovp5atFM7vSF3u5QPXLb_yra-fveuYMKm6XGstzuaOPNDp8hIwNeQgWyVQO1V-vGc4dFp5c6Y14ruOwPwGD4ie4__lWpQY6KhqRAcJTvprw6v-LBO8DOp2DQ';
$parse['drm'] = 9;
$parse['otype'] = 'json';
$parse['encryptVer'] = '5.3';
$parse['newplatform'] = '10204';
$parse['defnpayver'] = 2;
$parse['fhdswitch'] = 0;
$parse['sb'] = 0;
$parse['dlna'] = 0;
$parse['h265'] = 0;
$parse['ocx'] = 0;
$parse['device'] = 26;
$parse['hevclv'] = 26;
$parse['lsky'] = '';
$parse['sdtfrom'] = 'v2000';
$parse['dtype'] = 3;
$parse['platform'] = 10204;
$parse['sphls'] = 1;
$parse['spwm'] = 2;
$parse['defn'] = 'fhd';
$parse['defsrc'] = 3;
$parse['vid'] = 'z0026n8dlhy';
$parse['cid'] = '639agzdh10yu2q2';
$parse['guid'] = '{36D7032B-2557-FBC6-9BF7-3312F21A9ABF}';
$parse['banDc'] = 0;
$parse['dka'] = '';
$parse['pcba'] = 'jPOMweBn7DyijzYsO0XRsY3epxT6tqkCzgZiy8B8qpFzVaoO';
$parse['uin'] = 0;
$parse['klong'] = 1;

$ids['data'] = json_encode($parse);
$api = "https://vd.l.qq.com/proxyhttp";

$data = self::curl($api,$ids);

print_r($data);exit;
}

public static function get_report_urls($params){
$guid = $params["guid"];
$appver = $params["appVer"];
$tm = $params["tm"];
$url = urlencode($params["ehost"]);
$refer = $url;
$ua = urlencode("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36");
$platform = $params["platform"];
$dltype = $params["dtype"];
$vid = $params["vid"];
$cid = $params["cid"];
$pid = $params["pid"];
$unid = $params["unid"];
$flowid = $params["flowid"];
$time = number_format(microtime(true),3,'','');
preg_match("#(.*)#",file_get_contents("https://vv.video.qq.com/checktime"),$val);
$ip = $val[1];
$vip = 0;
$vurl = urlencode($params["vurl"]);;
$data = urlencode('{"code":"","stime":'.$time.'}');
$report_urls = array();

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid={$guid}&longitude=&latitude=&vip={$vip}&online=1&p2p=0&downloadkit=0&resolution=1024*378*2&testid=&osver=windows+10.0&playerver=&playertype=1&uip=&confid=&cdnip=&cdnid=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver={$appver}&p2pver=&url={$url}&refer={$refer}&ua={$ua}&ptag=m_v_qq_com&flowid={$flowid}&platform={$platform}&dltype={$dltype}&vid={$vid}&fmt=&rate=&clip=&status=&type=&duration=&data={$data}&step=0&seq=0";

$data = urlencode('{"stime":'.($time+1123).',"etime":'.($time+12300).',"code":""}');
$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid={$guid}&longitude=&latitude=&vip={$vip}&online=1&p2p=0&downloadkit=0&resolution=1024*378*2&testid=&osver=windows+10.0&playerver=&playertype=1&uip=&confid=&cdnip=&cdnid=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver={$appver}&p2pver=&url={$url}&refer={$refer}&ua={$ua}&ptag=m_v_qq_com&flowid={$flowid}&platform={$platform}&dltype={$dltype}&vid={$vid}&fmt=&rate=&clip=&status=&type=&duration=&data={$data}&step=5&seq=1";

$ctime = date("Y-m-d",time())."+".urlencode(date("H:i:s",time()));
$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=3717&Pwd=1055758521&version={$appver}&uid={$guid}&pid={$pid}&vid={$vid}&player_type=chromehls&video_type=1&platform={$platform}&usr_action=switch-definition&usr_action_detail=&url={$url}";

$encryptVer = $params["encryptVer"];
$cKey = $params["cKey"];
$params["ehost"] = urlencode($params["ehost"]);
$_url = "//vd.l.qq.com/proxyhttp/vinfoad&".http_build_query($params);

$data = urlencode('{"stime":'.($time+21230).',"etime":'.($time+31236).',"code":"","ip":"'.$ip.'","url":'.$_url.'}');
$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4564&Pwd=213967996&flowid={$flowid}&data={$data}&step=15";

$data = urlencode('{"ip":"'.$ip.'","stime":'.($time+46543).',"etime":'.($time+57654).',"code":""}');

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid={$guid}&longitude=&latitude=&vip={$vip}&online=1&p2p=0&downloadkit=0&resolution=1024*378*2&testid=6&osver=windows+10.0&playerver=&playertype=1&uip={$ip}&confid=&cdnip=&cdnid=2802&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver={$appver}&p2pver=&url={$url}&refer={$refer}&ua={$ua}&ptag=m_v_qq_com&flowid={$flowid}&platform={$platform}&dltype={$dltype}&vid={$vid}&fmt=321002&rate=107&clip=15&status=2&type=1037&duration=4217.04&data=;{$data}&step=15&seq=2";
$dip = parse_url($params["vurl"])["host"];
$fne = str_replace(".m3u8?ver=4","",basename($params["vurl"]));
$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=2594&Pwd=0&gid={$guid}&plt={$platform}&uin=&vid={$vid}&cts=1517882842887&sdt=undefined&fne={$fne}&dip={$dip}&cdn=2803&vky=";

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid={$vid}&coverid={$cid}&pid={$pid}&guid={$guid}&cmid={$guid}&unid={$unid}&vt=2803&type=1036&url={$url}&bi=2&bt=2175&version={$appver}&platform={$platform}&format=321002&defn=hd&ctime={$ctime}&ptag=%7Cx&isvip={$vip}&tpid=2&pversion=chromehls&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=5787605343&hc_ssid=&hc_qq=&ua={$ua}&hh_ua={$ua}&ckey=&iformat=321002&hh_ref={$refer}&vurl={$vurl}&v_idx=1&rcd_info=&extrainfo=&step=4&val=1&val1=1&idx=3&diagonal=768&isfocustab=1&isvisible=1&cpay=0&tpay=0&dltype=3";

$data = urlencode('{"reason":"","auto":1,"format":321002,"pstime":54,"petime":54,"lstime":1517882842958,"letime":1517882843004,"url":"'.$vurl.'","urlindex":0,"vt":2803,"code":""}');

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid={$guid}&longitude=&latitude=&vip=0&online=1&p2p=1&downloadkit=0&resolution=1326*733*2&testid=6&osver=windows+6.1&playerver=&playertype=1&uip={$ip}&confid=&cdnip=&cdnid=2803&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver={$appver}&p2pver=&url={$url}&refer=https%3A%2F%2Fv.qq.com%2Ftv%2F&ua={$ua}&ptag=film_qq_com%7Ctv_hot_show%3Aitem&flowid={$flowid}&platform={$platform}&dltype=$dltype}&vid={$vid}&fmt=321002&rate=66&clip=11&status=2&type=1036&duration=3216.12&data={$data}&step=45&seq=6";

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid={$guid}&longitude=&latitude=&vip=0&online=1&p2p=1&downloadkit=0&resolution=1326*733*2&testid=6&osver=windows+6.1&playerver=&playertype=1&uip={$ip}&confid=&cdnip=&cdnid=2803&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver={$appver}&p2pver=&url={$url}&refer=https%3A%2F%2Fv.qq.com%2Ftv%2F&ua={$ua}&flowid={$flowid}&platform={$platform}&dltype={$dltype}&vid={$vid}&fmt=321002&rate=66&clip=11&status=2&type=1036&duration=3216.12&data=%7B%22type%22%3A2%2C%22stime%22%3A1517882842958%2C%22etime%22%3A1517882843004%2C%22bufferduration%22%3A%22%22%2C%22url%22%3A%22%22%2C%22urlindex%22%3A0%2C%22vt%22%3A2803%2C%22code%22%3A%22%22%7D&step=31&seq=7";

$keyID = str_replace(".ts",".hls",$fne);
$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=3646&Pwd=1408787169&osVer=windows%206.1&serial=8&platform=={$platform}&appVer={$appver}&p2pVer=5.0.43&guid={$guid}&qq=&wx=&clientTime=1517882863&taskType=0&step=3&tryTimes=0&url=&svrType=17&svrIP=webrtcpunch.video.qq.com&svrPort=0&errCode=28001&svrRetCode=1000&connectElapse=0&firstRecvElapse=0&totalRecvElapse=0&keyID={$keyID}&deviceModel=chrome%2063.0.3239.132";

$report_urls[count($report_urls)] = "//btrace.video.qq.com/kvcollect?BossId=1002&Pwd=6677243&op=show&site=http:///www.imedia.com";

for ($i = 0; $i < count($report_urls); $i++){ self::post_qq($report_urls[$i],$params); } } public static function report_urls($arr,$ids){ //上报参数 for ($i = 0; $i < count($arr); $i++){ self::post_qq($arr[$i],$ids); } } public static function curl($url,$ids) { $params["ua"] = !empty($ids['ua']) ? $ids['ua'] : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"; if (isset($ids['data'])) { $params['fields'] = $ids['data']; } $params["ip"] = "14.21.99.47";//伪装为固定IP,否则会报异地登录,会封号,不要更改 //$params["proxy"] = PROXY;//代理地址 $params["cookie"] = isset($ids['cookie']) ? $ids['cookie'] : ''; return GlobalBase::curl($url,$params); } public static function qq_get_final_url($url, $vid, $fmt_id, $filename, $fvkey, $platform){ $params = array('appver' => '3.2.19.333', 'otype'=>'json','platform' => $platform,'filename'=>$filename,'vid'=>$vid,'format'=>$fmt_id);
$content = self::curl('http://vv.video.qq.com/getkey?' . http_build_query($params),'');
//"http://video.dispatch.tc.qq.com/u0027iss7rq.p209.1.mp4?vkey=81A6A39A5C9EEDB5CC4243A6A0194E600DC9DE740C83A95F0AE8AF07EBA5F951BB3D43D5FEDA311458C8664D267379B4049A84041DB67E41046147948145FBC46BDDB67B0F77F321B28F58729FADD6872D838B705BF1EED8B2805FB75F5C939F3CBE5AF87D6395A5"

preg_match('#QZOutputJson=(.*);#',str_replace("\\","",$content),$body);
$d = json_decode($body[1],true);
$key = $d['key'];

$url = $url.$filename.'?vkey='.$key;

return $url;
}

public static function qq_data($b, $a, $c='') {
switch ($a) {
case '1':
$a = count($b);
$b = 3 < $a ? $b[$a-3] : $b['0']; break; case '3': $b = $b[count($b) - 1]; break; default: $a = count($b); $b = 2 < $a ? $b[$a-2] : $b['0']; break; } return $d = $c ? $b[$c] : $b; } public static function getPushGuid($ids) { $e = Array(); $ctime = date('Y-m-d h:i:s', time()); if ($ids['d'] == '') { array_push($e,"//tj.video.qq.com/fcgi-bin/set_cookie?" . http_build_query(array( 'lv_irt_id' => '',
'dm' => 'v.qq.com',
'ua' => $ids['ua'],
'r' => '',
'vid' => $ids['vid'],
'sr' => '1600x900',
'ul' => 'zh-CN',
'tv' => '0.0.7',
'pt' => '腾讯视频',
'guid' => $ids['guid'],
'url' => 'http://film.qq.com/film_index_prevue/index.html?firstVid=' . $ids['vid'],
'from' => 'http://film.qq.com/film_index_prevue/index.html?firstVid=' . $ids['vid'],
'playing_url' => ''
)));
array_push($e,"//btrace.video.qq.com/kvcollect?" . http_build_query(array(
'BossId' => '3717',
'Pwd' => '1055758521',
'version' => '3.3.367',
'uid' => isset($ids['uid'])?$ids['uid']:'',
'pid' => $ids['pid'],
'vid' => $ids['vid'],
'player_type' => 'h5',
'video_type' => 1,
'platform' => $ids['platform'],
'usr_action' => 'pause',
'usr_action_detail' => '',
'url' => 'http://film.qq.com/film_index_prevue/index.html?firstVid=' . $ids['vid'],
'vid' => $ids['vid'],
'ptag' => 'v.qq.com#v.play.adaptor#2',
'mreferrer' => 'https://v.qq.com/',
'start' => 0
)));
array_push($e,"//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid=" .$ids['guid']. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1280*720*1.5&testid=&osver=windows+10.0&playerver=&playertype=1&uip=&confid=&cdnip=&cdnid=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=3.3.367&p2pver=&url=https%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Flqp2m6v1m450l3n.html&refer=&ua=Mozilla%2F5.0+(Windows+NT+10.0%3B+WOW64)+AppleWebKit%2F537.36+(KHTML++like+Gecko)+Chrome%2F55.0.2883.87+Safari%2F537.36&ptag=&flowid=" .$ids['flowid']. "&platform=" .$ids['platform']. "&dltype=1&vid=" .$ids['vid']. "&fmt=&rate=&clip=&status=&type=&duration=&data=%7B%22code%22%3A%22%22%2C%22stime%22%3A1508894110924%7D&step=0&seq=0");
array_push($e,"//btrace.video.qq.com/kvcollect?BossId=4501&Pwd=142347456&loginid=&loginex=&logintype=0&guid=" .$ids['guid']. "&longitude=&latitude=&vip=0&online=1&p2p=0&downloadkit=0&resolution=1280*720*1.5&testid=&osver=windows+10.0&playerver=&playertype=1&uip=&confid=&cdnip=&cdnid=&cdnuip=&freetype=&sstrength=&network=&speed=&device=&appver=3.3.367&p2pver=&url=https%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Flqp2m6v1m450l3n.html&refer=&ua=Mozilla%2F5.0+(Windows+NT+10.0%3B+WOW64)+AppleWebKit%2F537.36+(KHTML++like+Gecko)+Chrome%2F55.0.2883.87+Safari%2F537.36&ptag=&flowid=" .$ids['flowid']. "&platform=" .$ids['platform']. "&dltype=1&vid=" .$ids['vid']. "&fmt=&rate=&clip=&status=&type=&duration=&data=%7B%22stime%22%3A1508894111146%2C%22etime%22%3A1508894111834%2C%22code%22%3A%22%22%7D&step=5&seq=1");
array_push($e,"//btrace.video.qq.com/kvcollect?BossId=4298&Pwd=686148428&uin=&vid=" .$ids['vid']. "&coverid=&pid=" .$ids['pid']. "&guid=" .$ids['guid']. "&unid=&vt=&type=&url=https%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Flqp2m6v1m450l3n.html&bi=&bt=&version=3.3.367&platform=" .$ids['platform']. "&format=&defn=&ctime=" . $ctime . "&ptag=&isvip=0&tpid=1&pversion=chromehls&hc_uin=&hc_main_login=&hc_vuserid=&hc_openid=&hc_appid=&hc_pvid=494205040&hc_ssid=&hc_qq=&hh_ua=Mozilla%2F5.0+(Windows+NT+10.0%3B+WOW64)+AppleWebKit%2F537.36+(KHTML++like+Gecko)+Chrome%2F55.0.2883.87+Safari%2F537.36&ckey=&iformat=&hh_ref=https%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Flqp2m6v1m450l3n.html&vurl=&v_idx=0&rcd_info=&extrainfo=&step=3&val=1&idx=0&diagonal=1009&isfocustab=1&isvisible=1");
}else{
array_push($e,"//btrace.video.qq.com/kvcollect?" . http_build_query(array(
'BossId' => '2865',
'Pwd' => '1698957057',
'_dc' => 0,
'version' => 'TenPlayerHTML5V2.0',
'vid' => $ids['vid'],
'rid' => self::createGUID(),
'pid' => self::createGUID(),
'url' => 'http://film.qq.com/film_index_prevue/index.html?firstVid=' . $ids['vid'],
'platform' => $ids['platform'],
'pfversion' => '9.1',
'vt' => 203,
'tpid' => 9,
'vurl' => $ids['d'],
'bt' => 5905,
'step' => 3,
'ctime' => $ctime,
'val' => 1,
'isshortvd' => 0,
'opensource' => 0,
'cmid' => self::createGUID(),
'ua' => $ids['ua']
)));
}
for ($i = 0; $i < count($e); $i++){ self::post_qq($e[$i],$ids); } } public static function createGUID() { $guid = md5(time() . mt_rand(0,1000)); return $guid; } public static function hexToString($a) { for ($b = "", $c = "0x" == substr($a,0, 2) ? 2 : 0; $c < strlen($a); $c .= 2) $b .= chr(intval(substr($a, $c, 2), 16)); return $b; } public static function post_qq($url,$ids) { $ids['ua'] = isset($ids['ua']) ? $ids['ua'] : 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'; $curl = curl_init(); $header = array('CLIENT-IP:0.0.0.0','X-FORWARDED-FOR:0.0.0.0',); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST,0); curl_setopt($curl, CURLOPT_HEADER, 0); //0表示不输出Header,1表示输出 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_USERAGENT, $ids['ua']); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($curl, CURLOPT_REFERER,$ids['url']); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $html = curl_exec($curl); curl_close($curl); return $html; } public static function getCtk($vid, $platform = 10201, $sdtfrom = "v1010") { $token = "#\$#@#*ad"; $tm = $_SERVER['REQUEST_TIME']; $key = md5($platform.$vid.$tm.$token."1".$sdtfrom); $da = self::tempcalc(pack("H*", $key), $token); $ab = self::urlenc($da, 1, $tm); return array("t1" => self::u1($ab, 0), "t2" => self::u1($ab, 1));
}

private static function u1($a, $b) {
$c = array();
$len = strlen($a);
for ($d=$b;$d < $len;$d+=2) { $c[] = $a[$d]; } return join('', $c); } private static function tempcalc($a, $b) { $c = array(); for ($d = 0; $d < strlen($a); $d++) { $c[] = chr(ord($a[$d]) ^ ord($b[$d % 4])); } return join('', $c); } private static function urlenc($a, $b, $d) { $l = array(); $len = strlen($a); $o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; for ($m=0;$m < $len;) { $arr = array($len > $m ? ord($a[$m++]) : 0, $len > $m ? ord($a[$m++]) : 0, $len > $m ? ord($a[$m++]) : 0);
if (15 == $m) {
$l[]= "A";
$l[]= $b;
$l[]= $d;
}
$h = $arr[0] >> 2;
$i = (3 & $arr[0]) << 4 | $arr[1] >> 4;
$j = (15 & $arr[1]) << 2 | $arr[2] >> 6;
$k = ($len - 1) & $arr[2];
if (empty($arr[1])) $j = $k = $len;
else if (empty($arr[2])) $k = $len;
$l[] = $o[$h].$o[$i].$o[$j].$o[$k];
}
return join('', $l);
}
}

class Ckey7{
public static function index($vid,$tm,$platform,$sdtfrom,$appVer){
$ckey = self::getCkey7($vid,$tm,$platform);
$encryptVer = self::getEncryptVer7();
$data = array(
'encryptVer' => $encryptVer,
'appVer' => $appVer,
'ckey' => $ckey,
);
return $data;
}
public static function getCkey7($vid,$tm,$platform){
return md5( self::getCkey70ToKey(self::getEncryptVer7())."{$vid}{$tm}*#06#{$platform}" );
}
public static function getEncryptVer7(){
$g = date('w',time());
$f = 0 == $g ? 7 : $g;
return "7.{$f}";
}
public static function getCkey70ToKey($v){
$t = substr($v,2);
switch($t){
case "1": return "06fc1464";
case "2": return "4244ce1b";
case "3": return "77de31c5";
case "4": return "e0149fa2";
case "5": return "60394ced";
case "6": return "2da639f0";
case "7": return "c2f0cf9f";
default: return "err";
}
}
}

class Ckey3{
public static function index($vid){
$ckey = self::getCkey($vid,$ver = '3.2.19.356', $platform = 1400603, $stdfrom = 'bcng');
$data = array(
'ckey' => $ckey,
);
return $data;
}
private $seed = 0xdead;
private $maxf = 0xffffffff;
private $token = [0xfa, 0x82, 0xde, 0xb5, 0x2d, 0x4b, 0xba, 0x31, 0x39, 0x6, 0x33, 0xee, 0xfb, 0xbf, 0xf3, 0xb6];

private static function getCkey($vid, $ver = '3.2.19.356', $platform = 1400603, $stdfrom = 'bcng') {
$token = [0xfa, 0x82, 0xde, 0xb5, 0x2d, 0x4b, 0xba, 0x31, 0x39, 0x6, 0x33, 0xee, 0xfb, 0xbf, 0xf3, 0xb6];
$out = '';$data = [];$tm = $_SERVER['REQUEST_TIME'];
$guid = '21F9945F5114779E123F0E34C7B8E54500BA5E369';
$data = self::new_pack($data, [21507, 3168485562]);
$data = self::new_pack($data, [$platform]);
$data = self::new_pack($data, [9999, $tm]);
$data = self::pack_str($data, $stdfrom);
$data = self::pack_str($data, rand());
$data = self::pack_str($data, $ver);
$data = self::pack_str($data, $vid);
$data = self::pack_str($data, $guid);
array_push($data, 0, 1, 52, 0, 1, 52, 0, 0, 0, 1, 0, 0, 0, 0);
$len = count($data);
array_unshift($data, $len & 0xff);
array_unshift($data, ($len & 0xff00) >> 8);
$enc = self::oi_symmetry_encrypt2($data, $token);
$pad = [0, 0, 0, 0, 0xff & self::rands(), 0xff & self::rands(), 0xff & self::rands(), 0xff & self::rands()];
$pad[0] = $pad[4] ^ 71 & 0xff;
$pad[1] = $pad[5] ^ -121 & 0xff;
$pad[2] = $pad[6] ^ -84 & 0xff;
$pad[3] = $pad[7] ^ -86 & 0xff;
foreach($enc as $b) $pad[] = $b;
$pad = self::new_pack($pad, [self::str_sum($data)]);
foreach($pad as $b) $out .= chr($b);
$out = base64_encode($out);
$out = str_replace('=', '', $out);
$out = str_replace('+', '_', $out);
$out = str_replace('/', '-', $out);
return urlencode($out);
}

private static function str_sum($s) {
$n = 0;
$maxf = 0xffffffff;
foreach($s as $i) {
$n = $maxf & intval($n * 131 + $i);
}
return 0x7fffffff & $n;
}

private static function pack_str($t, $d) {
$l = strlen($d);
$t[] = ($l & 0xff00) >> 8;
$t[] = $l & 0xff;
for($i=0;$i < $l;$i++) { $t[] = ord($d[$i]); } return $t; } private static function rands(){ $seed = 0xdead; $maxf = 0xffffffff; if ($seed == 0) { $seed = 123459876; } $k1 = $maxf & (-2836 * (floor($seed / 127773))); $k2 = $maxf & (16807 * (floor($seed % 127773))); $seed = $maxf & ($k1 + $k2); if ($seed < 0) { $seed += PHP_INT_MAX; } return $seed; } private static function new_pack($v, $d) { foreach($d as $s) { $k = str_split(pack("I", $s)); krsort($k); foreach($k as $c) { $v[] = ord($c); } } return $v; } private static function new_unpack($d) { $str = ''; $ret = []; foreach($d as $b) $str .= chr($b); $t = range(0, strlen($str), 4); for($i=0;$i < count($t) - 1;$i++) { $s = substr($str, $t[$i], 4); $n = unpack('N', $s)[1]; if ($n < 0){ $n += 4294967296; } $ret[] = $n; } return $ret; } private static function tea_encrypt($v, $k) { $s = (integer) 0; $maxf = 0xffffffff; $k = self::new_unpack($k); $v = self::new_unpack($v); $bjz_int = PHP_INT_MAX; for($i=0;$i < 16;$i++){ $s += 0x9e3779b9; $s &= $maxf; $v[0] += ($s + $v[1]) ^ (($v[1] >> 5) + $k[1]) ^ (($v[1] << 4) + $k[0]); $v[0] &= $maxf; $v[1] += ($s + $v[0]) ^ (($v[0] >> 5) + $k[3]) ^ (($v[0] << 4) + $k[2]); $v[1] &= $maxf; } return self::new_pack([], $v); } private static function oi_symmetry_encrypt2($raw, $key) { $data = []; $temp = [0, 0, 0, 0, 0, 0, 0, 0]; $pad_salt_body_zero_len = count($raw) + 10; $pad_len = $pad_salt_body_zero_len % 8; if ($pad_len) $pad_len = 8 - $pad_len; array_push($data, self::rands() & 0xf8 | $pad_len); while($pad_len + 2) { array_push($data, self::rands() & 0xff); $pad_len = $pad_len - 1; } foreach($raw as $rd) $data[] = $rd; array_push($data, 0, 0 ,0, 0, 0, 0, 0); $dt = array_slice($data, 0, 8); $enc = self::tea_encrypt($dt, $key); $length = count($data); $d = range(8, $length, 8); foreach($d as $i) { if ($i != $length) { $dk = array_slice($data, $i); for($j=0;$j < 8;$j++) { $dk[$j] = $dk[$j] ^ $enc[$i - 8 + $j]; } $dk = self::tea_encrypt($dk, $key); for($j=0;$j < 8;$j++) { $dk[$j] = ($dk[$j] ^ $data[$i - 8 + $j] ^ $temp[$j]); array_push($enc, $dk[$j]); $temp[$j] = $enc[$i - 8 + $j]; } } } return $enc; } } ?>

(0)

本文由 柴郡猫-cheshirex,搬瓦工VPS,bandwagonhost 作者:cheshirex 发表,转载请注明来源!

热评文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注