cURL 从另一个页面显示


cURL Display from another page

我运行的是PHP 5.4。

这是我的设置:

../检查器.php

../索引.php

从应征入伍.php我使用 cronjob 每 5 分钟左右运行一次,但我希望 cURL 的回显显示在 index.php 上。如何在索引.php接收回声?

也可以让cURL将来自检查器的结果存储在ehm.结果的文件中.php.php并让index.php grab/iframe从结果中获取.php但我不知道如何。

cronCheckUrls.php

<?
//Set name of text file
$file = "urlUpResults.txt";
//Create blank file/delete contents of existing file before run rest of script
file_put_contents($file, " ");
//Build array of sites to check
$sitesArray = array("http://www.minecraft.net", "http://www.4stats.tk", "http://www.google.com", "http://www.stackoverflow.com", "http://www.brokentestwebsite.com");

foreach ($sitesArray as $value) { 
if (TPBUC($value))
    $upStatus = "<p>" . $value . " is up.</p>";
 else
    $upStatus = "<p>" . $value . " is down.</p>";
    file_put_contents($file, $upStatus, FILE_APPEND);
}

//cURL function
        function TPBUC($url){
             $agent = "Mozilla/5.0 (compatible; TPBUC/1.0;)";$ch=curl_init();
             curl_setopt ($ch, CURLOPT_URL,$url );
             curl_setopt($ch, CURLOPT_USERAGENT, $agent);
             curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt ($ch,CURLOPT_VERBOSE,false);
             curl_setopt($ch, CURLOPT_TIMEOUT, 5);
             curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
             curl_setopt($ch,CURLOPT_SSLVERSION,3);
             curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
             $page=curl_exec($ch);
             $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             curl_close($ch);
             if($httpcode>=200 && $httpcode<400) return true;
             else return false;
      }
?>

索引.php

<?
$file = "urlUpResults.txt";
echo "<h1>UpCheck results:<h1><br>" . file_get_contents($file);
?>