Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_checksum()

Description

Return a checksum for the given file path.

Parameters

ColumnTypeDefaultDescription
$path string Path to file
$forcefull bool false Force use of whole file and ignore $file_checksums_50k setting

Return

string|false Return the checksum value, false otherwise.

Location

include/file_functions.php lines 93 to 114

Definition

 
function get_checksum($path$forcefull false)
    {
    
debug("get_checksum( \$path = {$path} );");
    global 
$file_checksums_50k;
    if (!
is_readable($path))
        {
        return 
false;    
        }

    
# Generate the ID
    
if ($file_checksums_50k && !$forcefull)
        {
        
# Fetch the string used to generate the unique ID
        
$use=filesize_unlimited($path) . "_" file_get_contents($path,false,null,0,50000);
        
$checksum=md5($use);
        }
    else
        {
        
$checksum=md5_file($path);
        }
    return 
$checksum;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 22nd August 2024 16:45 Europe/London time.