1

私はPHP 5.4を実行しています。

これは私のセットアップです:

../checker.php

../index.php

conscript.php から cronjob を使用して 5 分ごとに実行しますが、cURL のエコーを index.php に表示する必要があります。index.php でエコーを受け取るにはどうすればよいですか?

また、cURL が checker.php からの結果を ehm のファイルに保存できるようにすることもできます。results.php と index.php が results.php から/iframeを取得できるようにしますが、方法がわかりません。

4

1 に答える 1

0

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;
      }

?>

index.php

<?
$file = "urlUpResults.txt";
echo "<h1>UpCheck results:<h1><br>" . file_get_contents($file);
?>
于 2013-09-28T20:08:36.493 に答える