4

这是我与该问题相关的代码:

$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 而不是域,例如:

http://188.72.216.143/~waffle/udp.php

在其中,脚本再次加载一点,然后停止。

任何帮助将不胜感激,如果您需要更多信息,请询问。

编辑:它似乎适用于某些 IP,但不适用于其他 IP

4

1 回答 1

10

我认为md5_file这只适用于本地文件。该文档当然没有提及请求或任何内容。如果您手动获取文件,您可以使用它md5来计算文档的哈希值。试一试。

<?php

    $contents = file_get_contents('http://stackoverflow.com');
    $md5file = md5($contents);

    echo $md5file;

?>
于 2010-05-02T18:25:18.777 回答