note 51385 deleted from function.md5-file by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:52:59 +0000 |
| Subject: | note 51385 deleted from function.md5-file by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196692@lists.php.net to get a copy of this message | ||
Note Submitter: bubba at revbubba dot com
----
a working example of the usage of this function, to confirm a specific file has not been modified
(replace all instances of "myfile.xxx" with your filename):
<?php
$chkfilename = "myfile.xxx";
$chkmd5return = md5_file($chkfilename);
if ($chkmd5return != "myfile.xxx's md5 value") {
echo "You have replaced myfile.xxx with an unknown version of the file, please replace the
original file.";
} else {
(your code to be executed, now that it has confirmed your myfile.xxx has been unmodified)
}
?>
To find out the file's md5 value, create a new .php doc, and put this code in it:
<?php
$chkfilename = "myfile.xxx";
$chkmd5return = md5_file($chkfilename);
echo $chkmd5return;
?>
Then upload the new .php doc to your webserver and navigate to it. Be sure to delete the new .php
doc once you have plugged in the value it spits out, into the "myfile.xxx's md5
value" in the first example above.
I just thought this example might be helpful to someone somewhere... if you php.net people feel it
needs editing or deletion, I leave it to your discretion. ;)