read())) { $file_path = $dir_path.'/'.$file; if(is_file($file_path) && $file != 'checksum.json' && !preg_match("/~$/", $file) && !preg_match("/^\./", $file)) { if(is_readable($file_path)) { $file_arr[$file] = sha1_file($file_path); } else { echo $file_path." is not readable.\nPlease make sure you have privelege to build.\nAborting...\n"; exit(); } } else if (is_dir($file_path) && !preg_match("/^\./", $file)) { if($file != '.' && $file != '..' ) { //echo "Scanning directory: ".$file_path."\n"; build_checksum($file_path); } } else { } } $file_json_string = json_encode($file_arr); $file_json_name = $dir_path."/checksum.json"; $file_json_handle = fopen($file_json_name, "w"); if(!file_json_handle) { echo "Error creating file checksum.json\nPlease execute this script again.\nAborting...\n "; exit(); } fwrite($file_json_handle, $file_json_string); fclose($file_json_handle); //echo "Succesfully created checksums of files in directory: ".$dir_path."\n"; return TRUE; }