关于curl函数使用问题

上次这个问题没人帮我解决,,,我又重新修改了一下代码。。。。。

然而还是不行

上次的问题地址

大神帮我看看哪里有问题

 <?php



function curl($url,$cookie,$httpheader,$referer="http://icecms.cn",$follow=1,$header=1){
        //$ch = curl_init("http://tool.yswl.pw/ua");
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36');
        curl_setopt($ch, CURLOPT_REFERER, $referer);       //伪装REFERER
        curl_setopt($ch, CURLOPT_HEADER, $header);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,$follow);//跟随重定向
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
        /*curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理认证模式
        curl_setopt($ch, CURLOPT_PROXY, "203.195.162.96"); //代理服务器地址
        curl_setopt($ch, CURLOPT_PROXYPORT, 80); //代理服务器端口
        curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //使用http代理模式*/
        $result=curl_exec($ch);
        curl_close($ch);
        return $result;
    }


    $httpheader = array( 
        'CLIENT-IP:113.105.123.123', 
        'X-FORWARDED-FOR:113.105.123.123', 
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    ); 

    $cookie_file = dirname(__FILE__)."/cookie.txt";
    //首次访问
    $url="http://icsr.cn/a.asp?icecms";
    $contents1=curl($url,$cookie_file,$httpheader);
    //带上首次访问得到的cookie访问跳转的链接
    preg_match('/href="(.*)"/isU',$body,$inarr1);
    echo $tourl="http://icsr.cn".$inarr1[1];
    $contents2=curl($tourl,$cookie_file,$httpheader);
    //获取重定向 的地址
    //preg_match_all( "/Location:(.*?)rn/" , implode( "rn" , $contents2 ),  $cookies );
    //echo $url2=$cookies[1];
//  $contents3=curl($url2,$cookie_file,$httpheader);





    $fp = @fopen("Log.html", "w"); //记录捕获到的页面源码
    fwrite($fp,$contents1); 
    fclose($fp);

    $fp = @fopen("Log1.html", "w"); //记录捕获到的页面源码
    fwrite($fp,$contents2); 
    fclose($fp);

//  $fp = @fopen("Log2.html", "w"); //记录捕获到的页面源码
//  fwrite($fp,$contents3); 
//  fclose($fp);
?>


就是打算用监控宝监控这个程序,模拟着一天24小时不停地有人访问这个上面那个网址。。。

http://www.jb51.net/article/34745.htm

http://www.jb51.net/article/34745.htm

不是我想要的答案。。。。。。