function removeMd5MatchingFiles($deleteNot = array()) { $md5_string = array(); if (file_exists(clean_path(getcwd() . '/files.md5'))) { require clean_path(getcwd() . '/files.md5'); } $modulesAll = getAllModules(); foreach ($modulesAll as $mod) { $allModFiles = array(); if (is_dir('modules/' . $mod)) { $allModFiles = findAllFiles('modules/' . $mod, $allModFiles); foreach ($allModFiles as $file) { if (file_exists($file) && !in_array(basename($file), $deleteNot)) { if (isset($md5_string['./' . $file])) { $fileContents = file_get_contents($file); if (md5($fileContents) == $md5_string['./' . $file]) { unlink($file); } } } } } } }
/** * Get all the customized modules. Compare the file md5s with the base md5s * If a file has been modified then put the module in the list of customized * modules. Show the list in the preflight check UI. */ function getAllCustomizedModules() { require_once 'files.md5'; $return_array = array(); $modules = getAllModules(); foreach ($modules as $mod) { //find all files in each module if the files have been modified //as compared to the base version then add the module to the //customized modules array $modFiles = findAllFiles(clean_path(getcwd()) . "/modules/{$mod}", array()); foreach ($modFiles as $file) { $fileContents = file_get_contents($file); $file = str_replace(clean_path(getcwd()), '', $file); if ($md5_string['./' . $file]) { if (md5($fileContents) != $md5_string['./' . $file]) { //A file has been customized in the module. Put the module into the // customized modules array. echo 'Changed File' . $file; $return_array[$mod]; break; } } else { // This is a new file in user's version and indicates that module has been //customized. Put the module in the customized array. echo 'New File' . $file; $return_array[$mod]; break; } } } //foreach return $return_array; }