wordpress是否干扰了我的PHP脚本?

时间:2014-06-10 11:24:32

标签: php wordpress rest

为了隔离我遇到的问题,我有一个接收POST数据的脚本,计时最多50个,并将结果记录到文件中。 我正在使用Chrome Restful Client进行测试

当我在我的主机上安装了wordpress时,我发现一个神秘的GET请求导致脚本启动大约一分钟进行处理,这意味着由于某种原因我不会从原始POST请求得到回复

删除wordpress后,我不是记录神秘的GET请求,而是在大约一分钟的时间内得到以下错误,大约一分钟进入运行时。它仍然意味着我在脚本完成后没有从我的POST请求中得到响应(在此错误后请参阅我的php):

Status
500 Internal Server Error Show explanation Loading time: 45612
Request headers 
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
Content-Type: application/x-www-form-urlencoded 
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Response headers 
Date: Tue, 10 Jun 2014 10:54:36 GMT 
Server: Apache 
Connection: close
Content-Type: text/html; charset=iso-8859-1 

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 webmaster@**** and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<p>Additionally, a 500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

这是我的PHP脚本。注意,它用于在大约一分钟后记录“失火”,因为它会收到一个空白的神秘GET请求。 删除wordpress后,不再发生,而是出现上述错误!

<?php
echo "SCRIPT HAS FINISHED!";

$q = $_POST['q'];

$req=$_SERVER['REQUEST_METHOD'];
$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];

writelog("IP Logged: ".$ip);
writelog("User agent: " . $agent);
writelog("Post data: " . $q);
writelog("Request method: " . $req);

if ($q==""){
  writelog ("MISFIRE!!!");
  die;
}

writelog("*** Error check started ***");

for ($i = 1; $i <= 50; $i++) {
     writelog ($i);
     sleep(rand(2,20)); 
}

 function writelog($towrite)
{
  $tdate=date('d/m/Y H:i:s');
  $file = 'log/testlog.txt';
  $current = $towrite." --- ".$tdate."\n";
  file_put_contents($file, $current, FILE_APPEND);
} 
writelog("*** Error check ended ***");
?> 

这可能与重定向有什么关系吗?我记得在卸载wordpress之前在restful client中进行测试时,它会说它有一个301重定向从... errortest.php /到... errortest.php。

1 个答案:

答案 0 :(得分:2)

听起来你的PHP脚本超时了,你设置了最大执行时间吗?您可能需要查看PHP中的set_time_limit()函数。

相关问题