<?
function curl_data($id,$begin,$end) {
//        $url="http://v.ku6.com/film/index_".$id.".html";
        $url="http://v.ku6.com/show/".$id.".html";
                $user_agent = $_SERVER['HTTP_USER_AGENT'];
                $ch = curl_init();
                $timeout = 5;
                curl_setopt ($ch, CURLOPT_URL, $url);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
                curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
                $file_contents = curl_exec($ch);
                curl_close($ch);
                preg_match("|{$begin}(.*){$end}|",$file_contents,$str);
                return $str[1];
}

function unicode_list($ku6){
         $arr1=array("/\\\u003a/","/\\\u002e/","/\\\u002c/","/\\\u002d/");
        $arr2 = array (":",".",",","-");
        $string=preg_replace($arr1,$arr2, $ku6);
        $string.="f4v";
        header("location:$string");
        }
if($_SERVER["QUERY_STRING"]==null){
        echo "Service Unavailable";
}else{
        $id=$_SERVER["QUERY_STRING"];
        $ku6=curl_data($id,'"f":"','f4v","');
        echo unicode_list($ku6);
}
?>