note 51385 added to function.md5-file
| From: | bubba at revbubba dot com | Date: | Tue, 29 Mar 2005 12:56:44 +0000 |
| Subject: | note 51385 added to function.md5-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87140@lists.php.net to get a copy of this message | ||
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. ;)
----
Manual Page -- http://www.php.net/manual/en/function.md5-file.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51385
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51385&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51385&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51385&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51385&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51385&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51385&report=yes
Search -- http://master.php.net/manage/user-notes.php