if ($filename) { $content .= $cms_language->getMessage(MESSAGE_PAGE_TREAT_FILE) . ' : ' . $filename . '<br /><br />'; } elseif ($cms_action == 'errorsCorrected') { $content .= $cms_language->getMessage(MESSAGE_PAGE_RESUME_PATCH) . ' :<br /><br />'; } if ($filename || $cms_action == 'errorsCorrected') { // +----------------------------------------------------------------------+ // | PATCH FILE TREATMENT | // +----------------------------------------------------------------------+ $send = ''; //if it's a patch resume, no need to re-decompress the file if ($cms_action != 'errorsCorrected') { //patch uncompress report('Uncompressing patch in progress...'); $archive = new CMS_gzip_file($_SERVER['DOCUMENT_ROOT'] . $filename); if (!$archive->hasError()) { $archive->set_options(array('basedir' => PATH_TMP_FS . "/", 'overwrite' => 1, 'level' => 1, 'dontUseFilePerms' => 1, 'forceWriting' => 1)); if (is_dir(PATH_TMP_FS)) { if (method_exists($archive, 'extract_files') && $archive->extract_files()) { verbose('-> Extract ' . $filename . ' to ' . PATH_TMP_FS); } } else { report('Error : Extraction directory does not exist', true); } } else { report('Error : Unable to extract archive wanted ' . $filename . '. It is not a valid format...', true); } if (!$archive->hasError()) { verbose('-> Extraction successfull'); } else { report('Extraction error...', true);
function patch($patchFile, &$error) { $archive = new CMS_gzip_file($patchFile); if (!$archive->hasError()) { $archive->set_options(array('basedir' => PATH_TMP_FS . "/", 'overwrite' => 1, 'level' => 1, 'dontUseFilePerms' => 1, 'forceWriting' => 1)); if (is_dir(PATH_TMP_FS)) { if (!method_exists($archive, 'extract_files') || !$archive->extract_files()) { $error = 'Error : Extraction error...'; return false; } } else { $error = 'Error : Extraction directory does not exist'; return false; } } else { $error = 'Error : Unable to extract archive wanted ' . $filename . '. It is not a valid format...'; return false; } if (!$archive->hasError()) { unset($archive); } else { $error = 'Extraction error...'; return false; } //Check files content $automnePatch = new CMS_patch(); //read patch param file and check versions $patchFile = new CMS_file(PATH_TMP_FS . "/patch"); if ($patchFile->exists()) { $patch = $patchFile->readContent("array"); } else { $error = 'Error : File ' . PATH_TMP_FS . '/patch does not exists ...'; return false; } if (!$automnePatch->checkPatch($patch)) { $error = 'Error : Patch does not match current version ...'; return false; } //read install param file and do maximum check on it before starting the installation process $installFile = new CMS_file(PATH_TMP_FS . "/install"); if ($installFile->exists()) { $install = $installFile->readContent("array"); } else { $error = 'Error : File ' . PATH_TMP_FS . '/install does not exists ...'; return false; } $installError = $automnePatch->checkInstall($install, $errorsInfos); if ($installError) { $error = 'Error : Invalid install file :'; $error .= $installError; return false; } //start Installation process $automnePatch->doInstall($install); $installError = false; $return = $automnePatch->getReturn(); foreach ($return as $line) { if ($line['type'] == 'report') { $error .= $line['text']; } } if ($installError) { $error = 'Error during installation process : ' . $error; return false; } //remove temporary files !CMS_file::deltree(PATH_TMP_FS); return true; }