Calculating MD5 Checksums

Hash Files

To automatically calculate and store the files' MD5 checksum values, so you can verify their integrity, please follow these steps:

  • Go to "Control Panel » System configuration » Metadata » Fieldsets » Create new"
  • Set the "Fieldset name" (Something like "Info", it doesn't really matter)
  • Tick the "Generic fieldset" checkbox. (So that all files show this fieldset)
  • Click "Save" to add the fieldset.
  • Click "Manage Fields > Create new"
  • Type "Checksum" for the "Field name" and click "Save"
  • By holding the mouse cursor over the newly created field name you can find out its ID, from the link's URL (......&fid=X)
  • Create the text file "/path-to-WebFileShare/customizables/events/upload.php" and paste the following code inside:
 
  • Replace the "XXXX" with the ID of your "Checksum" metadata field on the first line of the script file.

The "upload.php" script will execute each time a user uploads a file, and it will calculate the file's hash and store it in the file's "Hash" metadata field.

Being a metadata field, you can also display it as a column in the file list view.

Please note that with this method, PHP reads the entire file's contents into memory. This can be slow and might not even work for files larger than PHP's configured "memory_limit" value.

A solution available for Unix type of servers is to replace the line "

$hash = md5(file_get_contents($data['full_path']));

", with the following one:

$hash = exec("md5sum "".escapeshellcmd($data['full_path']).""");

 

 

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
Forcing certain file types to download
Viewed 1740 times since Thu, Mar 6, 2014
Custom file actions
Viewed 1579 times since Wed, Mar 5, 2014
Translating Web File Share
Viewed 19206 times since Wed, Mar 5, 2014
Adding custom functionality
Viewed 1580 times since Thu, Mar 6, 2014
Custom "Open with" actions
Viewed 1270 times since Wed, Nov 22, 2017
Hiding options from the "Open with..." menu
Viewed 1385 times since Thu, Mar 6, 2014
Adding links to the menu
Viewed 1611 times since Thu, Mar 6, 2014
External Login Form
Viewed 1545 times since Wed, Nov 22, 2017
Custom even scripts
Viewed 1485 times since Wed, Nov 22, 2017
Automatic Login
Viewed 1267 times since Wed, Nov 22, 2017
MENU