Exemple #1
0
 /**
  * Implements Singleton design pattern
  *
  * @return iMSCP_Update_Database
  */
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
/**
 * Generate database update details.
 *
 * @param $tpl iMSCP_pTemplate
 * return void
 */
function admin_generateDatabaseUpdateDetail($tpl)
{
    $dbUpdatesDetail = iMSCP_Update_Database::getInstance()->getDatabaseUpdatesDetails();
    foreach ($dbUpdatesDetail as $revision => $detail) {
        $tpl->assign(array('DB_UPDATE_REVISION' => (int) $revision, 'DB_UPDATE_DETAIL' => _admin_generateIssueTrackerLink($detail)));
        $tpl->parse('DATABASE_UPDATE', '.database_update');
    }
}
Exemple #3
0
/**
 * Generates update messages
 *
 * Generates update messages for both database updates and i-MSCP updates.
 *
 * @return void
 */
function admin_generateUpdateMessages()
{
    $cfg = iMSCP_Registry::get('config');
    if (iMSCP_Update_Database::getInstance()->isAvailableUpdate()) {
        set_page_message('<a href="database_update.php" class="link">' . tr('A database update is available') . '</a>', 'static_info');
    }
    if (!$cfg['CHECK_FOR_UPDATES']) {
        return;
    }
    $updateVersion = iMSCP_Update_Version::getInstance();
    if ($updateVersion->isAvailableUpdate()) {
        set_page_message('<a href="imscp_updates.php" class="link">' . tr('A new i-MSCP version is available') . '</a>', 'static_info');
    } elseif ($error = $updateVersion->getError()) {
        set_page_message($error, 'error');
    }
}
Exemple #4
0
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
define('IMSCP_SETUP', true);
$guiRootDir = rtrim('{GUI_ROOT_DIR}', '/');
if (strpos($guiRootDir, 'GUI_ROOT_DIR') === false) {
    require_once "{$guiRootDir}/library/imscp-lib.php";
    unset($guiRootDir);
    try {
        if (!iMSCP_Update_Database::getInstance()->applyUpdates()) {
            fwrite(STDERR, sprintf("[ERROR] %s\n", iMSCP_Update_Database::getInstance()->getError()));
            exit(1);
        }
        i18n_buildLanguageIndex();
    } catch (Exception $e) {
        fwrite(STDERR, sprintf("[ERROR] %s \n\nStack trace:\n\n%s\n", $e->getMessage(), $e->getTraceAsString()));
        exit(1);
    }
} else {
    fwrite(STDERR, '[ERROR] The GUI root directory is not defined');
    exit(1);
}
Exemple #5
0
 /**
  * Check for database update
  *
  * @return void
  */
 protected function checkForDatabaseUpdate()
 {
     $this->eventManager->registerListener(array(iMSCP_Events::onLoginScriptStart, iMSCP_Events::onBeforeSetIdentity), function ($event) {
         if (iMSCP_Update_Database::getInstance()->isAvailableUpdate()) {
             iMSCP_Registry::get('config')->MAINTENANCEMODE = true;
             /** @var $event iMSCP_Events_Event */
             if ($identity = $event->getParam('identity', null)) {
                 if ($identity->admin_type != 'admin' && (!isset($_SESSION['logged_from_type']) || $_SESSION['logged_from_type'] != 'admin')) {
                     set_page_message(tr('Only administrators can login when maintenance mode is activated.'), 'error');
                     redirectTo('index.php?admin=1');
                 }
             }
         }
     });
 }