public function readFile($path = null, $md5 = null)
    {
        //====================================================================//
        // Safety Checks
        if (empty($path)) {
            return Splash::log()->err("ErrFileFileMissing", __FUNCTION__);
        }
        if (empty(dirname($path))) {
            return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
        }
        if (empty($md5)) {
            return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__);
        }

        //====================================================================//
        // Check if folder exists
        if (!is_dir(dirname($path))) {
            return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path));
        }
        //====================================================================//
        // Check if file exists
        if (!is_file($path) || !is_readable($path)) {
            return Splash::log()->war("ErrFileReadable", __FUNCTION__, $path);
        }
        //====================================================================//
        // Check File CheckSum => No Diff with Previous Error for Higher Safety Level
        if (md5_file($path) != $md5) {
            return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path);
        }

        //====================================================================//
        // Open File
        $filehandle = fopen($path, "rb");
        if (false == $filehandle) {
            return Splash::log()->err("ErrFileRead", __FUNCTION__, $path);
        }

        //====================================================================//
        // Fill file Informations
        $infos = array();
        $infos["filename"] = basename($path);
        $infos["raw"] = base64_encode((string) fread($filehandle, (int) filesize($path)));
        fclose($filehandle);
        $infos["md5"] = md5_file($path);
        $infos["size"] = filesize($path);
        Splash::log()->deb("MsgFileRead", __FUNCTION__, basename($path));

        return $infos;
    }
public function readFile($path = null, $md5 = null)
    {
        //====================================================================//
        // Safety Checks
        if (empty($path)) {
            return Splash::log()->err("ErrFileFileMissing", __FUNCTION__);
        }
        if (empty(dirname($path))) {
            return Splash::log()->err("ErrFileDirMissing", __FUNCTION__);
        }
        if (empty($md5)) {
            return Splash::log()->err("ErrFileMd5Missing", __FUNCTION__);
        }

        //====================================================================//
        // Check if folder exists
        if (!is_dir(dirname($path))) {
            return Splash::log()->war("ErrFileDirNoExists", __FUNCTION__, dirname($path));
        }
        //====================================================================//
        // Check if file exists
        if (!is_file($path) || !is_readable($path)) {
            return Splash::log()->war("ErrFileReadable", __FUNCTION__, $path);
        }
        //====================================================================//
        // Check File CheckSum => No Diff with Previous Error for Higher Safety Level
        if (md5_file($path) != $md5) {
            return Splash::log()->war("ErrFileNoExists", __FUNCTION__, $path);
        }

        //====================================================================//
        // Open File
        $filehandle = fopen($path, "rb");
        if (false == $filehandle) {
            return Splash::log()->err("ErrFileRead", __FUNCTION__, $path);
        }

        //====================================================================//
        // Fill file Informations
        $infos = array();
        $infos["filename"] = basename($path);
        $infos["raw"] = base64_encode((string) fread($filehandle, (int) filesize($path)));
        fclose($filehandle);
        $infos["md5"] = md5_file($path);
        $infos["size"] = filesize($path);
        Splash::log()->deb("MsgFileRead", __FUNCTION__, basename($path));

        return $infos;
    }
public function readFile ( $ path = null , $ md5 = null ) { //====================================================================// // Safety Checks if ( empty ( $ path ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" , __FUNCTION__ ) ; } if ( empty ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> err ( "ErrFileDirMissing" , __FUNCTION__ ) ; } if ( empty ( $ md5 ) ) { return Splash :: log ( ) -> err ( "ErrFileMd5Missing" , __FUNCTION__ ) ; } //====================================================================// // Check if folder exists if ( ! is_dir ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> war ( "ErrFileDirNoExists" , __FUNCTION__ , dirname ( $ path ) ) ; } //====================================================================// // Check if file exists if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { return Splash :: log ( ) -> war ( "ErrFileReadable" , __FUNCTION__ , $ path ) ; } //====================================================================// // Check File CheckSum => No Diff with Previous Error for Higher Safety Level if ( md5_file ( $ path ) != $ md5 ) { return Splash :: log ( ) -> war ( "ErrFileNoExists" , __FUNCTION__ , $ path ) ; } //====================================================================// // Open File $ filehandle = fopen ( $ path , "rb" ) ; if ( false == $ filehandle ) { return Splash :: log ( ) -> err ( "ErrFileRead" , __FUNCTION__ , $ path ) ; } //====================================================================// // Fill file Informations $ infos = array ( ) ; $ infos [ "filename" ] = basename ( $ path ) ; $ infos [ "raw" ] = base64_encode ( ( string ) fread ( $ filehandle , ( int ) filesize ( $ path ) ) ) ; fclose ( $ filehandle ) ; $ infos [ "md5" ] = md5_file ( $ path ) ; $ infos [ "size" ] = filesize ( $ path ) ; Splash :: log ( ) -> deb ( "MsgFileRead" , __FUNCTION__ , basename ( $ path ) ) ; return $ infos ; }
Read a file from local filesystem

@param string $path Full Path to Local File
@param string $md5  Local File Checksum

@return array|bool $file       0 if not found, else file contents array

File Information Array Structure
$infos["filename"]  =>  File Name
$infos["raw"]       =>  Raw File Contents
$infos["md5"]       =>  File MD5 Checksum
$infos["size"]      =>  File Size in bytes

@remark      For all file access functions, File Checksumm is used to ensure
the server who send request was allowed by local server to read
the specified file.
Read a file from local filesystem