<?
function g_s($url){
if(function_exists('file_get_contents')) {
        @$c = file_get_contents($url);
        return $c;
} elseif(function_exists('curl_init')){
                $user_agent = $_SERVER['HTTP_USER_AGENT'];
                $ch = curl_init();
                $timeout = 30;
                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);
                @$c = curl_exec($ch);
                curl_close($ch);
                return $c;
        }else{ echo '空间不支采集';}
}
$name = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["SCRIPT_NAME"];
$xml='<?xml version="1.0" encoding="gb2312" ?>';
$xml.="\n";
$xml.='<list>';
$xml.="\n";
if(isset($_GET['p'])){
        //抓取列表页开始
$p=$_GET['p'];
$str='';
for($a=4*$p;$a<=4*$p+3;$a++){
$uu='http://list.juchang.com/jcl/1-0-0-0-0-1-2-1-'.$a.'-12.html';
$str.=g_s($uu);
}
preg_match_all('#<a target="show_v" href="http://v\.ku6\.com/film/index_([0-9]+)\.html"#',$str,$ar1);
preg_match_all('|<div class="modht_ln"><h1>(.*)</h1><span>|',$str,$ar2);
$ar1=$ar1[1];
$ar2=$ar2[1];
//print_r($ar1);
//print_r($ar2);
        for($i=0;$i<47;$i++){
        $xml.='<m list_src="'.$name.'?id='.$ar1[$i].'" label="'.$ar2[$i].'" />';
        $xml.="\n";
                }
        }elseif(isset($_GET['id'])){
                //抓取电影内容页开始
                $id=$_GET['id'];
function curl_data($url,$begin,$end) {
if(function_exists('file_get_contents')) {
        @$c = file_get_contents($url);
}elseif(function_exists('curl_init')){
                $user_agent = $_SERVER['HTTP_USER_AGENT'];
                $ch = curl_init();
                $timeout = 30;
                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);
                @$c = curl_exec($ch);
                curl_close($ch);
        }else{ echo '不支持采集';}
                 preg_match("|{$begin}(.*){$end}|",$c,$str);
                return $str[1];
}

function unicode_list($ku6,$title){
         $arr1=array("/\\\u003a/","/\\\u002e/","/\\\u002c/","/\\\u002d/");

        $arr2 = array (":",".",",","-");

        $string=preg_replace($arr1,$arr2, $ku6);

        $string.="f4v";

        $string=explode(",",$string);
        $list='';

        foreach($string as $key=>$value){
        $key=$key+1;

        @$list.='<m type="2" src="'.$value.'" label="'.$title.'第'.$key.'段" />';

        $list.="\n";

                }

       return $list;

        }
                $url="http://v.ku6.com/film/index_".$id.".html";
                $ku6=curl_data($url,'"f":"','f4v","');
                $title=curl_data($url,"<title>"," - 在线观看");
                $xml.=unicode_list($ku6,$title);
        //抓取电影内容页结束

}else{
                        //生成列表页
                          for($i=0;$i<=11;$i++){
                          $s=$i+1;
                          $xml.="\n";
                          $xml.='<m list_src="'.$name.'?p='.$i.'" label="第'.$s.'页" />';
                                                                  }
                          //生成列表页结束
                        }
$xml.="\n";
$xml.='</list>';
echo $xml;
?> 