示例#1
0
                //go to errors correction page
                $send = '
				<div id="correctUpdateErrors"></div>
				<script type="text/javascript">
					Ext.getCmp(\'serverWindow\').correctUpdateErrors();
				</script>';
                $content .= $send;
                echo $content;
                exit;
            }
        } else {
            verbose('-> Install file is correct.');
        }
        //start Installation process
        report('Start applying patch file...');
        $automnePatch->doInstall($install);
        $installError = false;
        $return = $automnePatch->getReturn();
        foreach ($return as $line) {
            switch ($line['type']) {
                case 'verbose':
                    verbose($line['text']);
                    break;
                case 'report':
                    switch ($line['error']) {
                        case 0:
                            report($line['text'], false);
                            break;
                        case 1:
                            report($line['text'], true);
                            $installError = true;
示例#2
0
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;
}