XMLファイルでいっぱいのディレクトリがあります。これらのファイルのそれぞれについて、RIPEで検索します。検索ごとに、返されたHTMLコードを介していくつかの正規表現検索を実行します。しかし、2、3回ループすると、file_get_contentsはデータの返送を停止し、その後のすべての操作は空の文字列に対して実行されます。
これらのページの読み込みに時間がかかるため、PHPがタイムアウトする可能性があると思いました。しかし、スクリプトの実行は完全に停止しませんか?代わりに、コンテンツはありませんが、すべてのループが終了してHTMLコードを出力します。
私はまた、PHPとの2番目の取引である種の最大の要求があるかもしれないと推測しています。
ここの誰かがこれに光を当てることができますか?
ありがとう
編集:私のタイトルを説明するために、私の友人と私は同時にスクリプトを実行していました。そのため、PHPは、データの返送を停止する前にさまざまな数のループを管理しているように見えるため、1分あたりに送信できるリクエストの数に制限を設定していると思います。
編集:いくつかのコードを追加しました:(問題の説明のため、必要ないと思いました)
<?php
set_time_limit(0);
include "pagebase.php";
$page = new pagebase();
$page->jQuery = true;
$page->formatDoc = false;
$page->addScript("javascript.js");
$page->addStylesheet("../codeclean.css");
$page->addStylesheet("stylesheet.css");
$page->title = "...";
$directory_path = "xml_documents";
$directory = scandir($directory_path);
$files = array();
foreach($directory as $string)
{
if(preg_match("/.*\.xml/", $string, $result) > 0)
array_push($files, $result[0]);
}
$content =
"
<table cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td colspan=\"7\">
<center><h2>...</h2></center>
</td>
</tr>
<tr>
<td class=\"header_cell\">Case ID</td>
<td class=\"header_cell\">Description (From RIPE)</td>
<td class=\"header_cell\">IP</td>
<td class=\"header_cell\">Fil</td>
<td class=\"header_cell\">Time</td>
<td class=\"header_cell\">Type</td>
</tr>
";
foreach($files as $index => $file)
{
$xml = simplexml_load_file("$directory_path/$file");
$id = trim($xml->Case->ID);
$ip = trim($xml->Source->IP_Address);
$title = trim($xml->Content->Item->Title);
$time = trim($xml->Source->TimeStamp);
$type = trim($xml->Source->Type);
$desc_result = array();
$info_result = array();
$RIPE_result = file_get_contents("http://www.db.ripe.net/whois?searchtext=$ip");
preg_match("/(?<=descr:)(\s*)(.*)/", $RIPE_result, $desc_result);
preg_match_all("/<pre>.*<\/pre>/sm", $RIPE_result, $info_result);
$info_result[0] = implode("", $info_result[0]);
if(count($desc_result) < 1) $desc_result[0] = "<font style=\"color:red\">No description found</font>";
else $desc_result[0] = trim($desc_result[0]);
$content .=
"
<tr id=\"info_row_$index\">
<td class=\"info_cell\">$id</td>
<td class=\"info_cell\">$desc_result[0]</td>
<td class=\"info_cell\">$ip</td>
<td class=\"info_cell\">$title</td>
<td class=\"info_cell\">$time</td>
<td class=\"info_cell\">$type</td>
</tr>
<tr id=\"expanded_row_$index\">
<td class=\"expanded_cell\" colspan=\"7\">
<div id=\"content_container_$index\">
<input type=\"button\" class=\"pastey_button\" rel=\"$index\" value=\"Get info\" />
<div id=\"RIPE_$index\">$info_result[0]</div>
</div>
</td>
</tr>
";
}
$content .=
"
<tr>
<td colspan=\"6\">Vi har totalt ".count($files)." henvendelser.</td>
</tr>
</table>
";
$page->body = $content;
$page->drawPage();
?>
インラインcode
ブロックのテスト