md5_file() 不适用于通过 URL 获取的远程内容
这是与问题相关的代码:
$theurl = trim($_POST['url']);
$md5file = md5_file($theurl);
if ($md5file != '96a0cec80eb773687ca28840ecc67ca1') { echo 'Hash doesn\'t match. Incorrect file. Reupload it and try again';
当我运行此脚本时,它甚至不输出错误。它就停止了。它加载了一会儿,然后就停止了。
在脚本的更下方,我再次实现它,它也在这里失败:
while($row=mysql_fetch_array($execquery, MYSQL_ASSOC)){
$hash = @md5_file($row['url']);
$url = $row['url'];
mysql_query("UPDATE urls SET hash='" . $hash . "' WHERE url='" . $url . "'") or die("There was a problem: ".mysql_error());
if ($hash != '96a0cec80eb773687ca28840ecc67ca1'){
$status = 'down';
}else{
$status = 'up';
}
mysql_query("UPDATE urls SET status='" . $status . "' WHERE url='" . $url . "'") or die("There was a problem: ".mysql_error());
}
它检查所有 URL 都很好,直到它到达一个带有 IP 而不是域的 URL,例如:
http://188.72。 216.143/~waffle/udp.php
其中,脚本再次加载一段时间,然后停止。
任何帮助将不胜感激,如果您需要更多信息,请询问。
编辑:它似乎适用于某些 IP,但不适用于其他 IP
Here is my code relating to the question:
$theurl = trim($_POST['url']);
$md5file = md5_file($theurl);
if ($md5file != '96a0cec80eb773687ca28840ecc67ca1') { echo 'Hash doesn\'t match. Incorrect file. Reupload it and try again';
When I run this script, it doesn't even output an error. It just stops. It loads for a bit, and then it just stops.
Further down the script I implement it again, and it fails here, too:
while($row=mysql_fetch_array($execquery, MYSQL_ASSOC)){
$hash = @md5_file($row['url']);
$url = $row['url'];
mysql_query("UPDATE urls SET hash='" . $hash . "' WHERE url='" . $url . "'") or die("There was a problem: ".mysql_error());
if ($hash != '96a0cec80eb773687ca28840ecc67ca1'){
$status = 'down';
}else{
$status = 'up';
}
mysql_query("UPDATE urls SET status='" . $status . "' WHERE url='" . $url . "'") or die("There was a problem: ".mysql_error());
}
And it checks all the URL's just fine, until it gets to one with an IP instead of a domain, such as:
http://188.72.216.143/~waffle/udp.php
In which, again, the script then just loads for a bit, and then stops.
Any help would be much appreciated, if you need any more information just ask.
EDIT: It seems to work with SOME IP's, but not others
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为
md5_file
仅适用于本地文件。该文档当然没有提及请求或任何内容。如果您手动获取文件,则可以使用md5
计算文档的哈希值。尝试一下。I thought that
md5_file
worked only with local files. The documentation certainly doesn't mention requests or anything. If you get the file manually you can usemd5
to calculate the hash of the document. Try giving it a whirl.