Parse to get cool video real download address of the PHP source code

Source: Internet
Author: User
Tags mixed php source code strlen

The code is as follows:


<?php


//--Call Method/demo.php?url=http://v.youku.com/v_show/id_xmzkyoda2ntey.html


Echo getyoukuflv ($_get[' url '));





function getyoukuflv ($url) {


Preg_match ("#id_ (. *?). html# ", $url, $out);


$id = $out [1];


$content =get_curl_contents (' http://v.youku.com/player/getPlayList/VideoIDS/'. $id);


$data =json_decode ($content);


foreach ($data->data[0]->streamfileids as $k => $v) {


$sid =getsid ();


$fileid =getfileid ($v, $data->data[0]->seed);


$one = ($data->data[0]->segs-> $k);


if ($k = = ' flv ' | | | $k = = ' mp4 ') return "http://f.youku.com/player/getflvpath/sid/{$sid}_00/st/{$k}/fileid/{$fileid} ? k={$one [0]->k}];


continue;


}


}


function get_curl_contents ($url, $second = 5) {


if (!function_exists (' Curl_init ')) die (' PHP.ini not open php_curl.dll ');


$c = Curl_init ();


curl_setopt ($c, Curlopt_url, $url);


$UserAgent =$_server[' http_user_agent '];


curl_setopt ($c, curlopt_useragent, $UserAgent);


curl_setopt ($c, curlopt_header,0);


curl_setopt ($c, Curlopt_timeout, $second);


curl_setopt ($c, Curlopt_returntransfer, true);


$cnt = curl_exec ($c);


$cnt =mb_check_encoding ($cnt, ' Utf-8 ')? Iconv (' GBK ', ' Utf-8//ignore ', $cnt): $cnt; Character encoding Conversion


curl_close ($c);


return $cnt;


}


function GetSID () {


$sid = time (). (Rand (0,9000) +10000);


return $sid;


}


function Getkey ($key 1, $key 2) {


$a = Hexdec ($key 1);


$b = $a ^ 0xa55aa5a5;


$b = Dechex ($b);


return $key 2. $b;


}


function Getfileid ($fileId, $seed) {


$mixed = getmixstring ($seed);


$ids = Explode ("*", $fileId);


unset ($ids [Count ($ids)-1]);


$realId = "";


for ($i =0; $i < count ($ids); + + $i) {


$idx = $ids [$i];


$realId. = substr ($mixed, $IDX, 1);


}


return $realId;


}


function getmixstring ($seed) {


$mixed = "";


$source = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/:._-1234567890";


$len = strlen ($source);


for ($i =0; $i < $len; + + $i) {


$seed = ($seed * 211 + 30031)% 65536;


$index = ($seed/65536 * strlen ($source));


$c = substr ($source, $index, 1);


$mixed. = $c;


$source = Str_replace ($c, "", $source);


}


return $mixed;


}


?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.