Md5_file () does not work with remote content received at URL

Here is my code related 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 does not even output an error. He just stops. It loads a bit, and then it just stops.

Further down the script, I will implement it again, and it also does not work here:

 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 only checks the entire URL with a fine, until it reaches one with an IP address instead of a domain, for example:

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

In this case, again, the script then just loads the bit and then stops.

Any help would be greatly appreciated, if you need more information, just ask.

EDIT: it works with some IPs, but not with others

+4
source share
1 answer

I thought md5_file only works with local files. The documentation certainly does not mention requests or anything else. If you get the file manually, you can use md5 to calculate the hash of the document. Try to give him a whirlwind.

 <?php $contents = file_get_contents('http://stackoverflow.com'); $md5file = md5($contents); echo $md5file; ?> 
+7
source

Source: https://habr.com/ru/post/1308610/


All Articles