process() 공개 메소드

public process ( $patch, $version )
예제 #1
0
 public static function forceUpgrade($version)
 {
     iaCore::instance()->factory('util');
     $patchUrl = iaUtil::REMOTE_TOOLS_URL . 'get/patch/%s/%s/';
     $patchUrl = sprintf($patchUrl, IA_VERSION, $version);
     $filePath = IA_TMP . 'patch.iap';
     iaUtil::downloadRemoteContent($patchUrl, $filePath);
     if ($contents = file_get_contents($filePath)) {
         require_once IA_HOME . 'install/classes/ia.patch.parser.php';
         require_once IA_HOME . 'install/classes/ia.patch.applier.php';
         try {
             $iaPatchParser = new iaPatchParser($contents);
             $patch = $iaPatchParser->patch;
             $iaPatchApplier = new iaPatchApplier(IA_HOME, array('host' => INTELLI_DBHOST . ':' . INTELLI_DBPORT, 'database' => INTELLI_DBNAME, 'user' => INTELLI_DBUSER, 'password' => INTELLI_DBPASS, 'prefix' => INTELLI_DBPREFIX), true);
             $iaPatchApplier->process($patch, $version);
             $logFile = 'upgrade-log-' . $patch['info']['version_to'] . '_' . date('d-m-y-Hi') . '.txt';
             if ($fh = fopen(IA_UPLOADS . $logFile, 'wt')) {
                 fwrite($fh, $iaPatchApplier->getLog());
                 fclose($fh);
             }
             $logParams = array('type' => 'app-forced', 'from' => IA_VERSION, 'to' => $version, 'file' => $logFile);
             $iaLog = iaCore::instance()->factory('log');
             $iaLog->write(iaLog::ACTION_UPGRADE, $logParams);
             return true;
         } catch (Exception $e) {
             return $e->getMessage();
         }
     }
     return false;
 }
예제 #2
0
 require_once IA_INSTALL . 'classes/ia.patch.parser.php';
 require_once IA_INSTALL . 'classes/ia.patch.applier.php';
 $iaOutput->adminPath = iaCore::instance()->iaDb->one_bind('value', '`name` = :name', array('name' => 'admin_page'), iaCore::getConfigTable());
 $options = isset($_GET['options']) && is_array($_GET['options']) ? $_GET['options'] : array();
 try {
     $patchFileContent = @file_get_contents(IA_HOME . 'tmp' . IA_DS . 'patch.iap');
     if (false === $patchFileContent) {
         throw new Exception('Could not get downloaded patch file. Please download it again.');
     }
     $patchParser = new iaPatchParser($patchFileContent);
     $patch = $patchParser->patch;
     if ($patch['info']['version_from'] != str_replace('.', '', IA_VERSION)) {
         throw new Exception('Patch is not applicable to your version of Subrion CMS.');
     }
     $patchApplier = new iaPatchApplier(IA_HOME, array('host' => INTELLI_DBHOST . ':' . INTELLI_DBPORT, 'database' => INTELLI_DBNAME, 'user' => INTELLI_DBUSER, 'password' => INTELLI_DBPASS, 'prefix' => INTELLI_DBPREFIX), in_array('force-mode', $options));
     $patchApplier->process($patch, $_SESSION['upgrade_to']);
     $textLog = $patchApplier->getLog();
     $logFile = 'upgrade-log-' . $patch['info']['version_to'] . '_' . date('d-m-y-Hi') . '.txt';
     if ($fh = fopen(IA_HOME . 'uploads' . IA_DS . $logFile, 'wt')) {
         fwrite($fh, $textLog);
         fclose($fh);
     }
     // log this event
     $iaLog = iaHelper::loadCoreClass('log', 'core');
     $iaLog->write(iaLog::ACTION_UPGRADE, array('type' => 'app', 'from' => IA_VERSION, 'to' => $_SESSION['upgrade_to'], 'file' => $logFile));
     //
     // processing the upgrade log to show nicely
     $textLog = htmlspecialchars($textLog);
     $textLog = str_replace(array(PHP_EOL, 'INFO', 'SUCCESS', 'ERROR', 'ALERT'), array('', '<p>', '<p><span class="label label-success">SUCCESS</span>', '<p><span class="label label-danger">ERROR</span>', '<p><span class="label label-warning">ALERT</span>'), $textLog);
     //
     $iaOutput->log = $textLog;