|
- <?php
- //ANONYMOUS("N","ANONYMOUS","匿名"),
- //STB("O","STB","运营版机顶盒"),
- //GESTB("Q","GESTB","通用版机顶盒"),
- //MT("R","MT","移动应用"),
- //WEIXIN("K","WEIXIN","微信应用"),
- //WEB("V","WEB","网页应用"),
- //PLUGIN("P","PLUGIN","插件应用"),
- //SHOW_MANAGE("L","SHOW_MANAGE","秀场管理");
- function currentTimeMillis() {
- list($t1, $t2) = explode(' ', microtime());
- return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
- }
- function base64UrlEncode($input){
- return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
- }
- function base64UrlDecode($input){
- $remainder = strlen($input) % 4;
- if ($remainder) {
- $addlen = 4 - $remainder;
- $input .= str_repeat('=', $addlen);
- }
- return base64_decode(strtr($input, '-_', '+/'));
- }
- function getRandomString($length){
- $tostr = "";
- $pattern = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ";
- $n = strlen($pattern);
- for($i=0;$i< $length;$i++) {
- $tostr .= $pattern{mt_rand(0, $n - 1)};
- }
- return $tostr;
- }
- function pareNToken($acc_token){
- $resp = array();
- $clientIp = "";
- $CODE_MAP = array();
- $acinfo = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0,-,_,@,.";
- $CODE_ARRAY = explode(",", $acinfo);
- for($i=0;$i < count($CODE_ARRAY);$i++){
- $CODE_MAP[$CODE_ARRAY[$i]] = $i;
- }
- $s = base64UrlDecode($acc_token);
- $code = substr($s, 0, 1);
- $token = substr($s, 1);
- $token_lenth = strlen($token);
- $accountLength = intval(substr($token, 0, 2));
- $encryptAccount = substr($token, 2, 2 + $accountLength);
- $keys = substr($token, $token_lenth - $accountLength);
- $version_tm = substr($token, $token_lenth - 13);
- $encryptLoginIp = substr($token, 2 + $accountLength, -13);
- for ($i = 0; $i < strlen($encryptLoginIp); $i++) {
- if (is_numeric($encryptLoginIp[$i])) {
- $clientIp .= $encryptLoginIp[$i];
- } else {
- $clientIp .= ".";
- }
- }
- $accountStr = "";
- for ($i = 0; $i < strlen($encryptAccount); $i++) {
- $a = $encryptAccount[$i];
- if (isset($CODE_MAP[$a]) && isset($keys[$i]) && isset($CODE_MAP[$keys[$i]])){
- $aIndex = $CODE_MAP[$a];
- $keyValue = $CODE_MAP[$keys[$i]];
- $bIndex = $aIndex + $keyValue;
- if($bIndex >= count($CODE_MAP)){
- $bIndex = $bIndex - count($CODE_MAP);
- }
- $accountStr .= $CODE_ARRAY[$bIndex];
- } else {
- $accountStr .= $a;
- }
- }
- $softwareVersion = substr($accountStr, strrpos($accountStr, "@") + 1);
- $accountStr = substr($accountStr, 0, strrpos($accountStr, "@"));
- $softwareCode = substr($accountStr, strrpos($accountStr, "@") + 1);
- $accountStr = substr($accountStr, 0, strrpos($accountStr, "@"));
- $resp['client_ip'] = $clientIp;
- $resp['version'] = $version_tm;
- $resp['account'] = $accountStr;
- $resp['software_code'] = $softwareCode;
- $resp['software_version'] = $softwareVersion;
- $resp['token'] = $acc_token;
- return $resp;
- }
- function getNToken($clientIp = "127.0.0.1", $account = "132020005012", $softwareCode = "SUNTV", $softwareVersion = "0.4.89", $prefix = "O"){
- $ipbuf = array();
- $CODE_MAP = array();
- $acinfo = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0,-,_,@,.";
- $CODE_ARRAY = explode(",", $acinfo);
- for($i=0;$i < count($CODE_ARRAY);$i++){
- $CODE_MAP[$CODE_ARRAY[$i]] = $i;
- }
- $accountStr = $account."@".$softwareCode."@".$softwareVersion;
- for($i=0;$i < strlen($clientIp);$i++){
- if ("." == $clientIp[$i]){
- $ipbuf[]= chr(rand(97, 122));
- } else {
- $ipbuf[] = $clientIp[$i];
- }
- }
- $tm = currentTimeMillis();
- $clientIp = join("", $ipbuf);
- $suffix = $clientIp.$tm;
- $accountLength = strlen($accountStr);
- if($accountLength > strlen($suffix)){
- $cLength = $accountLength - strlen($suffix);
- $suffix = getRandomString($cLength) . $suffix;
- }
- $tokenbuf = "";
- if($accountLength < 10){
- $tokenbuf = $prefix."0".$accountLength;
- } else {
- $tokenbuf = $prefix.$accountLength;
- }
- $keys = substr($suffix, strlen($suffix) - $accountLength);
- for ($i = 0; $i < strlen($accountStr); $i++) {
- $a = $accountStr[$i];
- if (isset($CODE_MAP[$a]) && isset($keys[$i]) && isset($CODE_MAP[$keys[$i]])){
- $aIndex = $CODE_MAP[$a];
- $keyValue = $CODE_MAP[$keys[$i]];
- $bIndex = 0;
- if($aIndex >= $keyValue){
- $bIndex = $aIndex - $keyValue;
- } else {
- $bIndex = count($CODE_ARRAY) + $aIndex - $keyValue;
- }
- $tokenbuf .= $CODE_ARRAY[$bIndex];
- } else {
- $tokenbuf .= $a;
- }
- }
- $tokenbuf .= $suffix;
- return base64UrlEncode($tokenbuf);
- }
- function userip()
- {
- $ip=false;
- if(!empty($_SERVER["HTTP_CLIENT_IP"])){
- $ip = $_SERVER["HTTP_CLIENT_IP"];
- }
- if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
- if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
- for ($i = 0; $i < count($ips); $i++) {
- if (!eregi ("^(10│172.16│192.168).", $ips[$i])) {
- $ip = $ips[$i];
- break;
- }
- }
- }
- return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
- }
- $uidlist = ["142029001763","142029001915","142029001916","142029001976"];
- $rand_keys = array_rand($uidlist);
- $access_token = getNToken(userip(), $uidlist[$rand_keys]);
- $stype = empty($_GET['type']) ? "ipsd" : trim($_GET['type']);
- $channel = empty($_GET['channel']) ? "CCTV1HD" : trim($_GET['channel']);
- $strUrl = sprintf("http://stream.suntv.tvmining.com/approve/live?channel=%s&type=%s&access_token=%s", $channel, $stype, $access_token);
- echo $strUrl;
复制代码懂的人一看即止。不多说了。 以上代码保存成tvm.php 调用方式 tvm.php?channel=CCTV1HD
把他原文中的代码所缺的函数补了下,现在能直接获取到地址了,但是这个获取到的地址不能打开,不知道要怎么用,有懂的大神能指点一二吗?还是说这个代码本身就只是片段,不完整?
请不要胡乱输入以及粘贴、复制等方式灌水
请尊重作者、并共同维护网站的正常阅读,否则账户将会被限制发帖、回帖,站内短信以及阅读权限等都会受到影响,谢谢。
具体限制方式:https://www.right.com.cn/forum/thread-8307840-1-1.html
|
|