if ($patchFile->exists()) { $patch = $patchFile->readContent("array"); if (!$automnePatch->checkPatch($patch)) { report('Error : Patch does not match current version ...', true); } else { verbose('-> Patch version match.'); } //read install param file and do maximum check on it before starting the installation process verbose('Read install file...'); $installFile = new CMS_file(PATH_TMP_FS . "/install"); if ($installFile->exists()) { $install = $installFile->readContent("array"); } else { report('Error : File ' . PATH_TMP_FS . '/install does not exists ... This file is not a valid Automne patch.', true); } $installError = $automnePatch->checkInstall($install, $errorsInfos); if ($installError) { report('Error : Invalid install file :'); $stopProcess = $automnePatch->canCorrectErrors($errorsInfos) ? false : true; report($installError, $stopProcess); if (!$force) { //if process continue, then we can correct patch errors. //save errors infos CMS_session::setSessionVar('patchErrors', $errorsInfos); //go to errors correction page $send = ' <div id="correctUpdateErrors"></div> <script type="text/javascript"> Ext.getCmp(\'serverWindow\').correctUpdateErrors(); </script>'; $content .= $send;
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; }