Beispiel #1
0
 public function runRepublishing()
 {
     $this->initRepublishing();
     FWLanguage::init();
     $langIds = array_keys(FWLanguage::getLanguageArray());
     foreach ($langIds as $id) {
         $this->createRSS($id);
     }
 }
 /**
  * add and modify language values
  *
  * @global  array
  * @global  ADONewConnection
  * @return  boolean     True on success, false on failure
  */
 function modifyLanguage()
 {
     global $_ARRAYLANG, $_CONFIG, $objDatabase;
     $langRemovalStatus = isset($_POST['removeLangVersion']) ? contrexx_input2raw($_POST['removeLangVersion']) : false;
     if (!empty($_POST['submit']) and isset($_POST['addLanguage']) && $_POST['addLanguage'] == "true") {
         //-----------------------------------------------
         // Add new language with all variables
         //-----------------------------------------------
         if (!empty($_POST['newLangName']) and !empty($_POST['newLangShortname'])) {
             $newLangShortname = addslashes(strip_tags($_POST['newLangShortname']));
             $newLangName = addslashes(strip_tags($_POST['newLangName']));
             $newLangCharset = addslashes(strip_tags($_POST['newLangCharset']));
             $objResult = $objDatabase->Execute("SELECT lang FROM " . DBPREFIX . "languages WHERE lang='" . $newLangShortname . "'");
             if ($objResult !== false) {
                 if ($objResult->RecordCount() >= 1) {
                     $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
                     return false;
                 } else {
                     $objDatabase->Execute("INSERT INTO " . DBPREFIX . "languages SET lang='" . $newLangShortname . "',\n                                                                           name='" . $newLangName . "',\n                                                                           charset='" . $newLangCharset . "',\n                                                                           is_default='false'");
                     $newLanguageId = $objDatabase->Insert_ID();
                     if (!empty($newLanguageId)) {
                         $objResult = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "languages WHERE is_default='true'", 1);
                         if ($objResult !== false && !$objResult->EOF) {
                             $defaultLanguage = $objResult->fields['id'];
                             $objResult = $objDatabase->Execute("SELECT varid,content,module FROM " . DBPREFIX . "language_variable_content WHERE 1 AND lang=" . $defaultLanguage);
                             if ($objResult !== false) {
                                 while (!$objResult->EOF) {
                                     $arrayLanguageContent[$objResult->fields['varid']] = stripslashes($objResult->fields['content']);
                                     $arrayLanguageModule[$objResult->fields['varid']] = $objResult->fields['module'];
                                     $objResult->MoveNext();
                                 }
                                 foreach ($arrayLanguageContent as $varid => $content) {
                                     $LanguageModule = $arrayLanguageModule[$varid];
                                     $objDatabase->Execute("INSERT INTO " . DBPREFIX . "language_variable_content SET varid=" . $varid . ", content='" . addslashes($content) . "', module=" . $LanguageModule . ", lang=" . $newLanguageId . ", status=0");
                                 }
                                 $this->strOkMessage = $_ARRAYLANG['TXT_NEW_LANGUAGE_ADDED_SUCCESSFUL'];
                                 return true;
                             }
                         }
                     } else {
                         $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
                         return false;
                     }
                 }
             }
         }
     } elseif (!empty($_POST['submit']) and $_POST['modLanguage'] == "true") {
         $eventArgs = array('langRemovalStatus' => $langRemovalStatus);
         $frontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages());
         $postLangIds = array_keys($_POST['langActiveStatus']);
         foreach (array_keys(\FWLanguage::getLanguageArray()) as $langId) {
             $isLangInPost = in_array($langId, $postLangIds);
             $isLangInFrontend = in_array($langId, $frontendLangIds);
             if ($isLangInPost == $isLangInFrontend) {
                 continue;
             }
             $eventArgs['langData'][] = array('langId' => $langId, 'status' => $isLangInPost && !$isLangInFrontend);
         }
         //Trigger the event 'languageStatusUpdate'
         //if the language is activated/deactivated for frontend
         if (!empty($eventArgs)) {
             $evm = \Cx\Core\Core\Controller\Cx::instanciate()->getEvents();
             $evm->triggerEvent('languageStatusUpdate', array($eventArgs, new \Cx\Core\Model\RecursiveArrayAccess(array())));
         }
         //-----------------------------------------------
         // Update languages
         //-----------------------------------------------
         foreach ($_POST['langName'] as $id => $name) {
             $active = 0;
             if (isset($_POST['langActiveStatus'][$id]) && $_POST['langActiveStatus'][$id] == 1) {
                 $languageCode = \FWLanguage::getLanguageCodeById($id);
                 $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
                 $alias = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => $languageCode), true);
                 if (count($alias)) {
                     if (is_array($alias)) {
                         $alias = $alias[0];
                     }
                     $id = $alias->getNode()->getId();
                     $config = \Env::get('config');
                     $link = 'http://' . $config['domainUrl'] . ASCMS_PATH_OFFSET . '/' . $alias->getSlug();
                     $lang = \Env::get('lang');
                     $this->strErrMessage = $lang['TXT_CORE_REMOVE_ALIAS_TO_ACTIVATE_LANGUAGE'] . ':<br />
                         <a href="index.php?cmd=Alias&act=modify&id=' . $id . '" target="_blank">' . $link . '</a>';
                     return false;
                 }
                 $active = 1;
             }
             $status = "false";
             if ($_POST['langDefaultStatus'] == $id) {
                 $status = "true";
             }
             $adminstatus = 0;
             if (isset($_POST['langAdminStatus'][$id]) && $_POST['langAdminStatus'][$id] == 1) {
                 $adminstatus = 1;
             }
             $fallBack = isset($_POST['fallBack'][$id]) && $_POST['fallBack'][$id] != "" ? intval($_POST['fallBack'][$id]) : 'NULL';
             $objDatabase->Execute("UPDATE " . DBPREFIX . "languages SET \n                                        name='" . $name . "',\n                                        frontend=" . $active . ",\n                                        is_default='" . $status . "',\n                                        backend='" . $adminstatus . "',\n                                        fallback=" . $fallBack . "\n                                        WHERE id=" . $id);
         }
         $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL'];
         \FWLanguage::init();
         return true;
     }
     return false;
 }
Beispiel #3
0
function executeContrexxUpdate()
{
    global $_CORELANG, $_CONFIG, $objDatabase, $objUpdate, $_DBCONFIG;
    /**
     * These are the modules which MUST have new template in order for Cloudrexx
     * to work correctly. CSS definitions for these modules will get updated too.
     */
    $viewUpdateTable = array('newsletter' => array('version' => '3.1.0.0', 'dependencies' => array('forms')), 'calendar' => array('version' => '3.1.0.0', 'dependencies' => array()), 'shop' => array('version' => '3.0.0.0', 'dependencies' => array('forms')), 'voting' => array('version' => '2.1.0.0', 'dependencies' => array()), 'access' => array('version' => '2.0.0.0', 'dependencies' => array('forms', 'captcha', 'uploader')), 'podcast' => array('version' => '2.0.0.0', 'dependencies' => array()), 'login' => array('version' => '3.0.2.0', 'dependencies' => array('forms', 'captcha')), 'media1' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media2' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media3' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media4' => array('version' => '3.0.0.0', 'dependencies' => array()));
    $_SESSION['contrexx_update']['copyFilesFinished'] = !empty($_SESSION['contrexx_update']['copyFilesFinished']) ? $_SESSION['contrexx_update']['copyFilesFinished'] : false;
    // Copy cx files to the root directory
    if (!$_SESSION['contrexx_update']['copyFilesFinished']) {
        if (!loadMd5SumOfOriginalCxFiles()) {
            return false;
        }
        $copyFilesStatus = copyCxFilesToRoot(dirname(__FILE__) . '/cx_files', ASCMS_PATH . ASCMS_PATH_OFFSET);
        if ($copyFilesStatus !== true) {
            if ($copyFilesStatus === 'timeout') {
                setUpdateMsg(1, 'timeout');
            }
            return false;
        }
        if (extension_loaded('apc') && ini_get('apc.enabled')) {
            apc_clear_cache();
        }
        $_SESSION['contrexx_update']['copyFilesFinished'] = true;
        // log modified files
        DBG::msg('MODIFIED FILES:');
        if (isset($_SESSION['contrexx_update']['modified_files'])) {
            DBG::dump($_SESSION['contrexx_update']['modified_files']);
        }
        // we need to stop the script here to force a reinitialization of the update system
        // this is required so that the new constants from config/set_constants.php are loaded
        //setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED'], 'title');
        //setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED_TIME_MSG'].'<br />', 'msg');
        //setUpdateMsg('Installation der neuen Dateien abgeschlossen.<br /><br />', 'msg');
        //setUpdateMsg('<input type="submit" value="'.$_CORELANG['TXT_CONTINUE_UPDATE'].'" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
        setUpdateMsg(1, 'timeout');
        return false;
    }
    unset($_SESSION['contrexx_update']['copiedCxFilesIndex']);
    /**
     * This needs to be initialized before loading config/doctrine.php
     * Because we overwrite the Gedmo model (so we need to load our model
     * before doctrine loads the Gedmo one)
     */
    require_once ASCMS_CORE_PATH . '/ClassLoader/ClassLoader.class.php';
    $cl = new \Cx\Core\ClassLoader\ClassLoader(ASCMS_DOCUMENT_ROOT, true);
    Env::set('ClassLoader', $cl);
    FWLanguage::init();
    if (!isset($_SESSION['contrexx_update']['update'])) {
        $_SESSION['contrexx_update']['update'] = array();
    }
    if (!isset($_SESSION['contrexx_update']['update']['done'])) {
        $_SESSION['contrexx_update']['update']['done'] = array();
    }
    /////////////////////
    // UTF-8 MIGRATION //
    /////////////////////
    if (!(include_once dirname(__FILE__) . '/components/core/core.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/core.php'));
        return false;
    }
    if (!(include_once dirname(__FILE__) . '/components/core/utf8.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/utf8.php'));
        return false;
    }
    if (!in_array('utf8', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _utf8Update();
        if ($result === 'timeout') {
            setUpdateMsg(1, 'timeout');
            return false;
        } elseif (!$result) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UTF_CONVERSION']), 'title');
            }
            return false;
        }
        if ($result === 'charset_changed') {
            // write new charset/collation definition to config file
            if (!_writeNewConfigurationFile()) {
                return false;
            }
        }
        $_SESSION['contrexx_update']['update']['done'][] = 'utf8';
        // _utf8Update() might have changed the charset/collation and migrated some tables,
        // therefore, we will force a reinitialization of the update system
        // to ensure that all db-connections are using the proper charset/collation
        \DBG::msg('Changed collation to: ' . $_DBCONFIG['collation']);
        \DBG::msg('Force reinitialization of update...');
        setUpdateMsg(1, 'timeout');
        return false;
    }
    /////////////////////
    /////////////////////////////
    // Session Table MIGRATION //
    /////////////////////////////
    $isSessionVariableTableExists = \Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'session_variable');
    if ($isSessionVariableTableExists) {
        createOrAlterSessionVariableTable();
    }
    if (!$isSessionVariableTableExists && $objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        if (!migrateSessionTable()) {
            setUpdateMsg('Error in updating session table', 'error');
            return false;
        }
        setUpdateMsg(1, 'timeout');
        return false;
    }
    // Load Doctrine (this must be done after the UTF-8 Migration, because we'll need $_DBCONFIG['charset'] to be set)
    $incDoctrineStatus = (require_once UPDATE_PATH . '/config/doctrine.php');
    Env::set('incDoctrineStatus', $incDoctrineStatus);
    $userData = array('id' => $_SESSION['contrexx_update']['user_id'], 'name' => $_SESSION['contrexx_update']['username']);
    $loggableListener = \Env::get('loggableListener');
    $loggableListener->setUsername(json_encode($userData));
    /////////////////////
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        //////////////////////////////
        // BEGIN: CONTENT MIGRATION //
        //////////////////////////////
        DBG::msg('Installed version: ' . $_CONFIG['coreCmsVersion']);
        Env::get('ClassLoader')->loadFile(dirname(__FILE__) . '/ContentMigration.class.php');
        $contentMigration = new \Cx\Update\Cx_3_0_4\ContentMigration();
        // Migrate statistics - this must be done before migrating to the new content architecture
        if (empty($_SESSION['contrexx_update']['content_stats'])) {
            DBG::msg('Migrate stats');
            if ($contentMigration->migrateStatistics()) {
                $_SESSION['contrexx_update']['content_stats'] = true;
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            } else {
                return false;
            }
        }
        // Check if there are content of inactive languages.
        // If true then ask if the update system can remove them.
        if (empty($_SESSION['contrexx_update']['inactive_content_languages_checked'])) {
            DBG::msg('Check inactive content languages');
            $arrMigrateLangIds = $contentMigration->getActiveContentLanguageIds();
            if (!isset($_POST['skipMigrateLangIds'])) {
                $result = $contentMigration->getInactiveContentLanguageCheckboxes();
                if (!empty($result)) {
                    setUpdateMsg('Inhaltsseiten von inaktiven Sprache(n) gefunden', 'title');
                    setUpdateMsg('
                        Folgende Sprache(n) sind inaktiv, aber enthalten Inhaltsseiten:<br />
                        ' . $result . '<br />
                        Wählen Sie die inaktiven Sprachen, dessen Inhaltseiten Sie migrieren möchten.<br />
                        Klicken Sie anschliessend auf <b>Update fortsetzen...</b>.<br /><br />
                        <div class="message-alert">
                        <b>Achtung:</b><br />
                        Die Inhaltsseiten der inaktive Sprache(n), welche Sie nicht ausgewählt haben, werden gelöscht.
                        </div>
                    ', 'msg');
                    setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" /><input type="hidden" name="skipMigrateLangIds" id="skipMigrateLangIds" />', 'button');
                    return false;
                }
            } else {
                if (!empty($_POST['migrateLangIds'])) {
                    if (is_array($_POST['migrateLangIds'])) {
                        $_POST['migrateLangIds'] = array_filter($_POST['migrateLangIds'], 'intval');
                        if (!empty($_POST['migrateLangIds'])) {
                            $arrMigrateLangIds = array_merge($arrMigrateLangIds, $_POST['migrateLangIds']);
                        }
                    } else {
                        if (intval($_POST['migrateLangIds'])) {
                            $arrMigrateLangIds[] = intval($_POST['migrateLangIds']);
                        }
                    }
                }
            }
            $_SESSION['contrexx_update']['migrate_lang_ids'] = $arrMigrateLangIds;
            $_SESSION['contrexx_update']['inactive_content_languages_checked'] = true;
        }
        if (empty($_SESSION['contrexx_update']['migrate_lang_ids'])) {
            $_SESSION['contrexx_update']['migrate_lang_ids'] = $contentMigration->getActiveContentLanguageIds();
        }
        $contentMigration->arrMigrateLangIds = ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['migrate_lang_ids']);
        $contentMigration->migrateLangIds = implode(',', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['migrate_lang_ids']));
        // Migrate content
        if (empty($_SESSION['contrexx_update']['content_migrated'])) {
            DBG::msg('Migrate content');
            $status = $contentMigration->migrate();
            if ($status === true) {
                $_SESSION['contrexx_update']['content_migrated'] = true;
                // log migrated nodes
                DBG::msg('NODES: catId -> nodeId');
                DBG::dump(ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['nodes']));
                unset($_SESSION['contrexx_update']['nodes']);
                // log migrated pages
                DBG::msg('PAGES: catId -> pageId');
                DBG::dump(ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['pages']));
                unset($_SESSION['contrexx_update']['pages']);
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            } else {
                if ($status === 'timeout') {
                    setUpdateMsg(1, 'timeout');
                    return false;
                } else {
                    return false;
                }
            }
        }
        // Page grouping
        if (empty($_SESSION['contrexx_update']['pages_grouped'])) {
            DBG::msg('Group pages');
            $pageGrouping = $contentMigration->pageGrouping();
            if ($pageGrouping === true) {
                $_SESSION['contrexx_update']['pages_grouped'] = true;
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            } else {
                if ($pageGrouping === 'timeout') {
                    setUpdateMsg(1, 'timeout');
                    return false;
                } else {
                    if ($pageGrouping === false) {
                        return false;
                    } else {
                        if (!empty($pageGrouping)) {
                            $arrDialogData = array('similarPages' => $contentMigration->similarPages);
                            setUpdateMsg('Inhaltsseiten gruppieren', 'title');
                            setUpdateMsg($pageGrouping, 'msg');
                            setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_NEXT'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
                            setUpdateMsg($arrDialogData, 'dialog');
                            return false;
                        }
                    }
                }
            }
        }
        // Migrate aliases
        if (empty($_SESSION['contrexx_update']['aliases_migrated'])) {
            DBG::msg('Migrate aliases');
            if ($contentMigration->migrateAliases()) {
                $_SESSION['contrexx_update']['aliases_migrated'] = true;
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            } else {
                return false;
            }
        }
        // Migrate blocks
        if (empty($_SESSION['contrexx_update']['blocks_migrated'])) {
            DBG::msg('Migrate blocks');
            if ($contentMigration->migrateBlocks()) {
                $_SESSION['contrexx_update']['blocks_migrated'] = true;
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            } else {
                return false;
            }
        }
        // Drop old tables
        if (empty($_SESSION['contrexx_update']['old_tables_dropped'])) {
            DBG::msg('Drop old tables');
            if ($contentMigration->dropOldTables()) {
                $_SESSION['contrexx_update']['old_tables_dropped'] = true;
                if (!checkMemoryLimit() || !checkTimeoutLimit()) {
                    return false;
                }
            }
        }
        ////////////////////////////
        // END: CONTENT MIGRATION //
        ////////////////////////////
    } else {
        ///////////////////////////////////////////
        // BEGIN: UPDATE FOR CONTREXX 3 OR NEWER //
        ///////////////////////////////////////////
        $result = _updateModuleRepository();
        if ($result === false) {
            DBG::msg('unable to update module repository');
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_REPOSITORY']), 'title');
            }
            return false;
        } else {
            try {
                \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'log_entry`
                    SET `object_class` = \'Cx\\\\Core\\\\ContentManager\\\\Model\\\\Entity\\\\Page\'
                    WHERE object_class = \'Cx\\\\Model\\\\ContentManager\\\\Page\'');
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
            // before an update of module page can be done, the db changes have to be done
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_page', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'node_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'nodeIdShadowed' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'node_id'), 'lang' => array('type' => 'INT(11)', 'after' => 'nodeIdShadowed'), 'type' => array('type' => 'VARCHAR(16)', 'after' => 'lang'), 'caching' => array('type' => 'TINYINT(1)', 'after' => 'type'), 'updatedAt' => array('type' => 'timestamp', 'after' => 'caching', 'notnull' => false), 'updatedBy' => array('type' => 'CHAR(40)', 'after' => 'updatedAt'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'updatedBy'), 'linkTarget' => array('type' => 'VARCHAR(16)', 'notnull' => false, 'after' => 'title'), 'contentTitle' => array('type' => 'VARCHAR(255)', 'after' => 'linkTarget'), 'slug' => array('type' => 'VARCHAR(255)', 'after' => 'contentTitle'), 'content' => array('type' => 'longtext', 'after' => 'slug'), 'sourceMode' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'customContent' => array('type' => 'VARCHAR(64)', 'notnull' => false, 'after' => 'sourceMode'), 'useCustomContentForAllChannels' => array('type' => 'INT(2)', 'after' => 'customContent', 'notnull' => false), 'cssName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useCustomContentForAllChannels'), 'cssNavName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'cssName'), 'skin' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'cssNavName'), 'useSkinForAllChannels' => array('type' => 'INT(2)', 'after' => 'skin', 'notnull' => false), 'metatitle' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useSkinForAllChannels'), 'metadesc' => array('type' => 'text', 'after' => 'metatitle'), 'metakeys' => array('type' => 'text', 'after' => 'metadesc'), 'metarobots' => array('type' => 'VARCHAR(7)', 'notnull' => false, 'after' => 'metakeys'), 'start' => array('type' => 'timestamp', 'after' => 'metarobots', 'notnull' => false), 'end' => array('type' => 'timestamp', 'after' => 'start', 'notnull' => false), 'editingStatus' => array('type' => 'VARCHAR(16)', 'after' => 'end'), 'protection' => array('type' => 'INT(11)', 'after' => 'editingStatus'), 'frontendAccessId' => array('type' => 'INT(11)', 'after' => 'protection'), 'backendAccessId' => array('type' => 'INT(11)', 'after' => 'frontendAccessId'), 'display' => array('type' => 'TINYINT(1)', 'after' => 'backendAccessId'), 'active' => array('type' => 'TINYINT(1)', 'after' => 'display'), 'target' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'active'), 'module' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'target'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'module')), array('node_id' => array('fields' => array('node_id', 'lang'), 'type' => 'UNIQUE'), 'IDX_D8E86F54460D9FD7' => array('fields' => array('node_id'))), 'InnoDB', '', array('node_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'SET NULL', 'onUpdate' => 'NO ACTION')));
            if (_convertThemes2Component() === false) {
                if (empty($objUpdate->arrStatusMsg['title'])) {
                    DBG::msg('unable to convert themes to component');
                    setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_CONVERT_TEMPLATES']), 'title');
                }
                return false;
            }
            if (_updateModulePages($viewUpdateTable) === false) {
                if (empty($objUpdate->arrStatusMsg['title'])) {
                    DBG::msg('unable to update module templates');
                    setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_TEMPLATES']), 'title');
                }
                return false;
            }
            /* else {
                   if (!in_array('moduleStyles', $_SESSION['contrexx_update']['update']['done'])) {
                       if (_updateCssDefinitions($viewUpdateTable, $objUpdate) === false) {
                           if (empty($objUpdate->arrStatusMsg['title'])) {
                               setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_TEMPLATES']), 'title');
                           }
                           return false;
                       }
                       $_SESSION['contrexx_update']['update']['done'][] = 'moduleStyles';
                   }
               }*/
        }
        // we are updating from 3.0.0 rc1, rc2, stable or 3.0.0.1
        if (!(include_once dirname(__FILE__) . '/update3.php')) {
            setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/update3.php'));
            return false;
        }
        if (!createHtAccess()) {
            $webServerSoftware = !empty($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'apache') ? 'apache' : (stristr($_SERVER['SERVER_SOFTWARE'], 'iis') ? 'iis' : '');
            $file = $webServerSoftware == 'iis' ? 'web.config' : '.htaccess';
            setUpdateMsg('Die Datei \'' . $file . '\' konnte nicht erstellt/aktualisiert werden.');
            return false;
        }
        // Update configuration.php
        if (!_writeNewConfigurationFile()) {
            return false;
        }
        $arrUpdate = $objUpdate->getLoadedVersionInfo();
        $_CONFIG['coreCmsVersion'] = $arrUpdate['cmsVersion'];
        $lupd = new License();
        try {
            $lupd->update(false);
        } catch (\Cx\Lib\UpdateException $e) {
            setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_LICENSE_DATA']), 'title');
            return false;
        }
        return true;
        /////////////////////////////////////////
        // END: UPDATE FOR CONTREXX 3 OR NEWER //
        /////////////////////////////////////////
    }
    ///////////////////////////////////////////
    // CONTINUE UPDATE FOR NON CX 3 VERSIONS //
    ///////////////////////////////////////////
    $arrDirs = array('core_module', 'module');
    $updateStatus = true;
    if (!(include_once dirname(__FILE__) . '/components/core/backendAreas.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/backendAreas.php'));
        return false;
    } elseif (!(include_once dirname(__FILE__) . '/components/core/modules.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/modules.php'));
        return false;
    } elseif (!(include_once dirname(__FILE__) . '/components/core/settings.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/settings.php'));
        return false;
    }
    if (!in_array('coreUpdate', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _coreUpdate();
        if ($result === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_CORE_SYSTEM']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'coreUpdate';
        }
    }
    $missedModules = array();
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        $missedModules = getMissedModules();
        $conflictedModules = getConflictedModules($missedModules);
        if (!empty($conflictedModules)) {
            $conflictedModulesList = '';
            foreach ($conflictedModules as $moduleName => $moduleTables) {
                $conflictedModulesList = '<li><strong>' . $moduleName . ':</strong> ' . implode(', ', $moduleTables) . '</li>';
            }
            setUpdateMsg($_CORELANG['TXT_CONFLICTED_MODULES_TITLE'], 'title');
            setUpdateMsg($_CORELANG['TXT_CONFLICTED_MODULES_DESCRIPTION'] . '<ul>' . $conflictedModulesList . '</ul>', 'msg');
            setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_TRY_AGAIN'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
            return false;
        }
    }
    foreach ($arrDirs as $dir) {
        $dh = opendir(dirname(__FILE__) . '/components/' . $dir);
        if ($dh) {
            while (($file = readdir($dh)) !== false) {
                if (!in_array($file, ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
                    $fileInfo = pathinfo(dirname(__FILE__) . '/components/' . $dir . '/' . $file);
                    if ($fileInfo['extension'] == 'php') {
                        DBG::msg("--------- updating {$file} ------");
                        if (!(include_once dirname(__FILE__) . '/components/' . $dir . '/' . $file)) {
                            setUpdateMsg($_CORELANG['TXT_UPDATE_ERROR'], 'title');
                            setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/' . $dir . '/' . $file));
                            return false;
                        }
                        if (!in_array($fileInfo['filename'], $missedModules)) {
                            $function = '_' . $fileInfo['filename'] . 'Update';
                            if (function_exists($function)) {
                                $result = $function();
                                if ($result === false) {
                                    if (empty($objUpdate->arrStatusMsg['title'])) {
                                        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $file), 'title');
                                    }
                                    return false;
                                } elseif ($result === 'timeout') {
                                    setUpdateMsg(1, 'timeout');
                                    return false;
                                }
                            } else {
                                setUpdateMsg($_CORELANG['TXT_UPDATE_ERROR'], 'title');
                                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UPDATE_COMPONENT_CORRUPT'], '.' . $fileInfo['filename'], $file));
                                return false;
                            }
                        } else {
                            $function = '_' . $fileInfo['filename'] . 'Install';
                            if (function_exists($function)) {
                                $result = $function();
                                if ($result === false) {
                                    if (empty($objUpdate->arrStatusMsg['title'])) {
                                        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $file), 'title');
                                    }
                                    return false;
                                } elseif ($result === 'timeout') {
                                    setUpdateMsg(1, 'timeout');
                                    return false;
                                } else {
                                    // fetch module info from components/core/module.php
                                    $arrModule = getModuleInfo($fileInfo['filename']);
                                    if ($arrModule) {
                                        try {
                                            \Cx\Lib\UpdateUtil::sql("INSERT INTO " . DBPREFIX . "modules ( `id` , `name` , `description_variable` , `status` , `is_required` , `is_core` , `distributor` ) VALUES ( " . $arrModule['id'] . " , '" . $arrModule['name'] . "', '" . $arrModule['description_variable'] . "', '" . $arrModule['status'] . "', '" . $arrModule['is_required'] . "', '" . $arrModule['is_core'] . "', 'Comvation AG') ON DUPLICATE KEY UPDATE `id` = `id`");
                                        } catch (\Cx\Lib\UpdateException $e) {
                                            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
                                        }
                                    } else {
                                        DBG::msg('unable to register module ' . $fileInfo['filename']);
                                    }
                                }
                            } else {
                                setUpdateMsg($_CORELANG['TXT_UPDATE_ERROR'], 'title');
                                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UPDATE_COMPONENT_CORRUPT'], '.' . $fileInfo['filename'], $file));
                                return false;
                            }
                        }
                    }
                    $_SESSION['contrexx_update']['update']['done'][] = $file;
                    setUpdateMsg(1, 'timeout');
                    return false;
                }
            }
        } else {
            setUpdateMsg($_CORELANG['TXT_UPDATE_ERROR'], 'title');
            setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_DIR_COMPONENTS'], dirname(__FILE__) . '/components/' . $dir));
            return false;
        }
        closedir($dh);
    }
    if (!in_array('coreSettings', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _updateSettings();
        if ($result === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_BASIC_CONFIGURATION']), 'title');
            }
            return false;
        } else {
            // update configuration.php (migrate to new format)
            if (!_writeNewConfigurationFile()) {
                return false;
            }
            $_SESSION['contrexx_update']['update']['done'][] = 'coreSettings';
            // till this point the file config/version.php was still loaded upon a request,
            // therefore we must force a new page request here, to ensure that the file config/version.php
            // will not be loaded anylonger. This is essential here, otherwise the old values of config/version.php
            // would screw up the update process
            setUpdateMsg(1, 'timeout');
            return false;
        }
    }
    if (!in_array('coreModules', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _updateModules();
        if ($result === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULES']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'coreModules';
        }
    }
    if (!in_array('coreBackendAreas', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _updateBackendAreas();
        if ($result === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_SECURITY_SYSTEM']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'coreBackendAreas';
        }
    }
    if (!in_array('coreModuleRepository', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _updateModuleRepository();
        if ($result === false) {
            DBG::msg('unable to update module repository');
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_REPOSITORY']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'coreModuleRepository';
        }
    }
    if (!in_array('convertTemplates', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _convertThemes2Component();
        if ($result === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                DBG::msg('unable to convert themes to component');
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_CONVERT_TEMPLATES']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'convertTemplates';
        }
    }
    if (!in_array('moduleTemplates', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        if (_updateModulePages($viewUpdateTable) === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                DBG::msg('unable to update module templates');
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_TEMPLATES']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'moduleTemplates';
        }
    }
    if (!in_array('moduleStyles', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        if (_updateCssDefinitions($viewUpdateTable, $objUpdate) === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_MODULE_TEMPLATES']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'moduleStyles';
        }
    }
    if (!in_array('navigations', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        if (_updateNavigations() === false) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_NAVIGATIONS']), 'title');
            }
            return false;
        } else {
            $_SESSION['contrexx_update']['update']['done'][] = 'navigations';
        }
    }
    if (!createHtAccess()) {
        $webServerSoftware = !empty($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'apache') ? 'apache' : (stristr($_SERVER['SERVER_SOFTWARE'], 'iis') ? 'iis' : '');
        $file = $webServerSoftware == 'iis' ? 'web.config' : '.htaccess';
        setUpdateMsg('Die Datei \'' . $file . '\' konnte nicht erstellt/aktualisiert werden.');
        return false;
    }
    if (file_exists(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php')) {
        \DBG::msg('/cadmin/index.php still exists...');
        // move cadmin index.php if its customized
        if (!loadMd5SumOfOriginalCxFiles()) {
            return false;
        }
        if (!verifyMd5SumOfFile(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php', '', false)) {
            \DBG::msg('...and it\'s customized, so let\'s move it to customizing directory');
            // changes, backup modified file
            if (!backupModifiedFile(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php')) {
                setUpdateMsg('Die Datei \'' . ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php\' konnte nicht kopiert werden.');
                return false;
            }
        } else {
            \DBG::msg('...but it\'s not customized');
        }
        // no non-backupped changes, can delete
        try {
            \DBG::msg('So let\'s remove it...');
            $cadminIndex = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php');
            $cadminIndex->delete();
        } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
            setUpdateMsg('Die Datei \'' . ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php\' konnte nicht gelöscht werden.');
            return false;
        }
    }
    $arrUpdate = $objUpdate->getLoadedVersionInfo();
    $_CONFIG['coreCmsVersion'] = $arrUpdate['cmsVersion'];
    if (!in_array('coreLicense', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $lupd = new License();
        try {
            $result = $lupd->update();
        } catch (\Cx\Lib\UpdateException $e) {
            setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_LICENSE_DATA']), 'title');
            return false;
        }
        // ignore error to allow offline installations
        /*if ($result === false) {
              if (empty($objUpdate->arrStatusMsg['title'])) {
                  setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UPDATE_LICENSE_DATA']), 'title');
              }
              return false;
          } else {*/
        $_SESSION['contrexx_update']['update']['done'][] = 'coreLicense';
        //}
    }
    return true;
}