Subrion - open source content management system Copyright (C) 2015 Intelliants, LLC This file is part of Subrion. Subrion is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Subrion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Subrion. If not, see .
コード例 #1
0
ファイル: ia.system.php プロジェクト: TalehFarzaliey/subrion
 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
 case 'finish':
     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);
         //