Ejemplo n.º 1
0
 function testGetAfterSet()
 {
     Env::set(Env::PROD);
     $this->assertEquals(Env::get(), Env::PROD);
     $this->assertTrue(Env::isProd());
     $this->assertFalse(Env::isTest());
 }
 public function preInit(\Cx\Core\Core\Controller\Cx $cx)
 {
     global $_CONFIG;
     $domainRepo = new \Cx\Core\Net\Model\Repository\DomainRepository();
     $_CONFIG['domainUrl'] = $domainRepo->getMainDomain()->getName();
     \Env::set('config', $_CONFIG);
 }
Ejemplo n.º 3
0
function MAL_EVAL($ast, $env)
{
    #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
    if (!_list_Q($ast)) {
        return eval_ast($ast, $env);
    }
    if ($ast->count() === 0) {
        return $ast;
    }
    // apply list
    $a0 = $ast[0];
    $a0v = _symbol_Q($a0) ? $a0->value : $a0;
    switch ($a0v) {
        case "def!":
            $res = MAL_EVAL($ast[2], $env);
            return $env->set($ast[1], $res);
        case "let*":
            $a1 = $ast[1];
            $let_env = new Env($env);
            for ($i = 0; $i < count($a1); $i += 2) {
                $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
            }
            return MAL_EVAL($ast[2], $let_env);
        default:
            $el = eval_ast($ast, $env);
            $f = $el[0];
            return call_user_func_array($f, array_slice($el->getArrayCopy(), 1));
    }
}
Ejemplo n.º 4
0
/**
 * Example of function that defines a setup process common to all the
 * application. May be take as a template, or used as-is. Suggestions on new
 * things to include or ways to improve it are welcome :)
 */
function bootstrap(int $env = Env::PROD)
{
    // Set the encoding of the mb_* functions
    mb_internal_encoding('UTF-8');
    // Set the same timezone as the one used by the database
    date_default_timezone_set('UTC');
    // Get rid of PHP's default custom header
    header_remove('X-Powered-By');
    // Determine the current environment
    Env::set($env);
    // Control which errors are fired depending on the environment
    if (Env::isProd()) {
        error_reporting(0);
        ini_set('display_errors', '0');
    } else {
        error_reporting(E_ALL & ~E_NOTICE);
        ini_set('display_errors', '1');
    }
    // Handling errors from exceptions
    set_exception_handler(function (\Throwable $e) {
        $data = ['title' => 'Unexpected exception', 'detail' => $e->getMessage() ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['exception' => get_class($e) . ' (' . $e->getCode() . ')', 'file' => $e->getFile() . ':' . $e->getLine(), 'trace' => $e->getTrace()];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
    // Handling errors from trigger_error and the alike
    set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) {
        $data = ['title' => 'Unexpected error', 'detail' => $errstr ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['error' => $errno, 'file' => $errfile . ':' . $errline, 'context' => $errcontext];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
}
Ejemplo n.º 5
0
function MAL_EVAL($ast, $env)
{
    #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
    if (!_list_Q($ast)) {
        return eval_ast($ast, $env);
    }
    if ($ast->count() === 0) {
        return $ast;
    }
    // apply list
    $a0 = $ast[0];
    $a0v = _symbol_Q($a0) ? $a0->value : $a0;
    switch ($a0v) {
        case "def!":
            $res = MAL_EVAL($ast[2], $env);
            return $env->set($ast[1], $res);
        case "let*":
            $a1 = $ast[1];
            $let_env = new Env($env);
            for ($i = 0; $i < count($a1); $i += 2) {
                $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
            }
            return MAL_EVAL($ast[2], $let_env);
        case "do":
            #$el = eval_ast(array_slice($ast->getArrayCopy(), 1), $env);
            $el = eval_ast($ast->slice(1), $env);
            return $el[count($el) - 1];
        case "if":
            $cond = MAL_EVAL($ast[1], $env);
            if ($cond === NULL || $cond === false) {
                if (count($ast) === 4) {
                    return MAL_EVAL($ast[3], $env);
                } else {
                    return NULL;
                }
            } else {
                return MAL_EVAL($ast[2], $env);
            }
        case "fn*":
            return function () use($env, $ast) {
                $fn_env = new Env($env, $ast[1], func_get_args());
                return MAL_EVAL($ast[2], $fn_env);
            };
        default:
            $el = eval_ast($ast, $env);
            $f = $el[0];
            return call_user_func_array($f, array_slice($el->getArrayCopy(), 1));
    }
}
Ejemplo n.º 6
0
 function handler_search(PlPage $page, PlUser $authUser, $payload, $mode = 'quick')
 {
     if (!isset($payload['quick'])) {
         $page->trigError('Malformed search query');
         return PL_BAD_REQUEST;
     }
     $query = trim($payload['quick']);
     if (@$payload['allow_special']) {
         if (starts_with($query, 'admin:')) {
             $page->jsonAssign('link_type', 'admin');
             $query = substr($query, 6);
         } else {
             if (starts_with($query, 'adm:')) {
                 $page->jsonAssign('link_type', 'admin');
                 $query = substr($query, 4);
             } else {
                 if (starts_with('admin', $query) || strpos($query, ':') !== false) {
                     $page->jsonAssign('profile_count', -1);
                     $page->jsonAssign('profiles', array());
                     return PL_JSON;
                 } else {
                     $page->jsonAssign('link_type', 'profile');
                 }
             }
         }
     }
     if (strlen($query) < 3) {
         $page->jsonAssign('profile_count', -1);
         $page->jsonAssign('profiles', array());
         return PL_JSON;
     }
     Env::set('quick', $query);
     foreach (array('with_soundex', 'exact') as $key) {
         if (isset($payload[$key])) {
             Env::set($key, $payload[$key]);
         }
     }
     require_once 'userset.inc.php';
     $view = new QuickSearchSet();
     $view->addMod('json', 'JSon', true, $payload);
     $view->apply('api/1/search', $page, 'json');
     return PL_JSON;
 }
Ejemplo n.º 7
0
 public function prepareSidebarList()
 {
     $entity = $this->entity;
     $items = $entity::all('navPositionLeft');
     $itemsByCategory = [];
     $itemsByCategory['main'] = (object) ['name' => 'Main Navigation', 'items' => []];
     Env::set('additional_nav_categores', [], -1);
     $additionalCats = Env::get('additional_nav_categores');
     foreach (Env::get('additional_nav_categores') as $identifier => $name) {
         $itemsByCategory[$identifier] = (object) ['name' => $name, 'items' => []];
     }
     $itemsByCategory['not_linked'] = (object) ['name' => 'Not Linked', 'items' => []];
     foreach ($items as $item) {
         if (!isset($item->nav) || !isset($itemsByCategory[@$item->nav])) {
             continue;
         }
         $itemsByCategory[$item->nav]->items[] = $item;
     }
     View::set('itemsByCategory', $itemsByCategory);
 }
Ejemplo n.º 8
0
 /**
  * Write all settings to the config file
  *
  */
 public static function updatePhpCache()
 {
     global $_ARRAYLANG, $_CONFIG;
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(self::getSettingsFile())) {
         \Message::add(self::getSettingsFile() . ' ' . $_ARRAYLANG['TXT_SETTINGS_ERROR_WRITABLE'], \Message::CLASS_ERROR);
         return false;
     }
     //get values from ymlsetting
     \Cx\Core\Setting\Controller\Setting::init('Config', NULL, 'Yaml');
     $ymlArray = \Cx\Core\Setting\Controller\Setting::getArray('Config', null);
     $intMaxLen = 0;
     $ymlArrayValues = array();
     foreach ($ymlArray as $key => $ymlValue) {
         $_CONFIG[$key] = $ymlValue['value'];
         $ymlArrayValues[$ymlValue['group']][$key] = $ymlValue['value'];
         // special case to add legacy domainUrl configuration option
         if ($key == 'mainDomainId') {
             $domainRepository = new \Cx\Core\Net\Model\Repository\DomainRepository();
             $objMainDomain = $domainRepository->findOneBy(array('id' => $ymlArray[$key]['value']));
             if ($objMainDomain) {
                 $domainUrl = $objMainDomain->getName();
             } else {
                 $domainUrl = $_SERVER['SERVER_NAME'];
             }
             $ymlArrayValues[$ymlValue['group']]['domainUrl'] = $domainUrl;
             if ($_CONFIG['xmlSitemapStatus'] == 'on') {
                 \Cx\Core\PageTree\XmlSitemapPageTree::write();
             }
         }
         $intMaxLen = strlen($key) > $intMaxLen ? strlen($key) : $intMaxLen;
     }
     $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
     //needed for formatted output
     // update environment
     \Env::set('config', $_CONFIG);
     $strHeader = "<?php\n";
     $strHeader .= "/**\n";
     $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
     $strHeader .= "* Do not try to edit it manually!\n";
     $strHeader .= "*/\n\n";
     $strFooter = "?>";
     //Write values
     $data = $strHeader;
     $strBody = '';
     foreach ($ymlArrayValues as $group => $sectionValues) {
         $strBody .= "/**\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "* " . ucfirst($group) . "\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "*/\n";
         foreach ($sectionValues as $sectionName => $sectionNameValue) {
             $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $sectionName . '\']');
             $strBody .= "= ";
             $strBody .= (self::isANumber($sectionNameValue) ? $sectionNameValue : '"' . str_replace('"', '\\"', $sectionNameValue) . '"') . ";\n";
         }
         $strBody .= "\n";
     }
     $data .= $strBody;
     $data .= $strFooter;
     try {
         $objFile = new \Cx\Lib\FileSystem\File(self::getSettingsFile());
         $objFile->write($data);
         return true;
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
         \DBG::msg($e->getMessage());
     }
     return false;
 }
Ejemplo n.º 9
0
<?php

namespace Fierce;

try {
    Env::get('_test_foo');
    $this->assert(false, 'Exception accessing unknown Env value');
} catch (\Exception $e) {
    $this->assert(true, 'Exception accessing unknown Env value');
}
Env::set('_test_foo', 'bar');
$this->assertEqual(Env::get('_test_foo'), 'bar', 'Read Env value');
Env::set('_test_foo', 'a', 10);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Apply higher priority value');
Env::set('_test_foo', 'b', -5);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Ignore low priority value');
Env::push('_test_foo', 'c');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Push env value');
Env::push('_test_foo', 'd');
$this->assertEqual(Env::get('_test_foo'), 'd', 'Push another env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Pop env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'a', 'Pop another env value');
try {
    Env::pop('_test_foo');
    $this->assert(false, 'Exception popping too many times');
} catch (\Exception $e) {
    $this->assert(true, 'Exception popping too many times');
}
try {
Ejemplo n.º 10
0
function MAL_EVAL($ast, $env)
{
    while (true) {
        #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        // apply list
        $ast = macroexpand($ast, $env);
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        if ($ast->count() === 0) {
            return $ast;
        }
        $a0 = $ast[0];
        $a0v = _symbol_Q($a0) ? $a0->value : $a0;
        switch ($a0v) {
            case "def!":
                $res = MAL_EVAL($ast[2], $env);
                return $env->set($ast[1], $res);
            case "let*":
                $a1 = $ast[1];
                $let_env = new Env($env);
                for ($i = 0; $i < count($a1); $i += 2) {
                    $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
                }
                $ast = $ast[2];
                $env = $let_env;
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "quote":
                return $ast[1];
            case "quasiquote":
                $ast = quasiquote($ast[1]);
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "defmacro!":
                $func = MAL_EVAL($ast[2], $env);
                $func->ismacro = true;
                return $env->set($ast[1], $func);
            case "macroexpand":
                return macroexpand($ast[1], $env);
            case "php*":
                $res = eval($ast[1]);
                switch (gettype($res)) {
                    case "array":
                        if ($res !== array_values($res)) {
                            $new_res = _hash_map();
                            $new_res->exchangeArray($res);
                            return $new_res;
                        } else {
                            return call_user_func_array('_list', $res);
                        }
                    default:
                        return $res;
                }
            case "try*":
                $a1 = $ast[1];
                $a2 = $ast[2];
                if ($a2[0]->value === "catch*") {
                    try {
                        return MAL_EVAL($a1, $env);
                    } catch (Error $e) {
                        $catch_env = new Env($env, array($a2[1]), array($e->obj));
                        return MAL_EVAL($a2[2], $catch_env);
                    } catch (Exception $e) {
                        $catch_env = new Env($env, array($a2[1]), array($e->getMessage()));
                        return MAL_EVAL($a2[2], $catch_env);
                    }
                } else {
                    return MAL_EVAL($a1, $env);
                }
            case "do":
                eval_ast($ast->slice(1, -1), $env);
                $ast = $ast[count($ast) - 1];
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "if":
                $cond = MAL_EVAL($ast[1], $env);
                if ($cond === NULL || $cond === false) {
                    if (count($ast) === 4) {
                        $ast = $ast[3];
                    } else {
                        $ast = NULL;
                    }
                } else {
                    $ast = $ast[2];
                }
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "fn*":
                return _function('MAL_EVAL', 'native', $ast[2], $env, $ast[1]);
            default:
                $el = eval_ast($ast, $env);
                $f = $el[0];
                $args = array_slice($el->getArrayCopy(), 1);
                if ($f->type === 'native') {
                    $ast = $f->ast;
                    $env = $f->gen_env($args);
                    // Continue loop (TCO)
                } else {
                    return $f->apply($args);
                }
        }
    }
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
0
 /**
  * Returns the doctrine entity manager
  * @return \Doctrine\ORM\EntityManager 
  */
 public function getEntityManager()
 {
     if ($this->em) {
         return $this->em;
     }
     global $objCache;
     $config = new \Doctrine\ORM\Configuration();
     $userCacheEngine = $objCache->getUserCacheEngine();
     if (!$objCache->getUserCacheActive()) {
         $userCacheEngine = \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_OFF;
     }
     $arrayCache = new \Doctrine\Common\Cache\ArrayCache();
     switch ($userCacheEngine) {
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_APC:
             $cache = new \Doctrine\Common\Cache\ApcCache();
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_MEMCACHE:
             $memcache = $objCache->getMemcache();
             if ($memcache instanceof \Memcache) {
                 $cache = new \Doctrine\Common\Cache\MemcacheCache();
                 $cache->setMemcache($memcache);
             } elseif ($memcache instanceof \Memcached) {
                 $cache = new \Doctrine\Common\Cache\MemcachedCache();
                 $cache->setMemcache($memcache);
             }
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_XCACHE:
             $cache = new \Doctrine\Common\Cache\XcacheCache();
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_FILESYSTEM:
             $cache = new \Cx\Core_Modules\Cache\Controller\Doctrine\CacheDriver\FileSystemCache(ASCMS_CACHE_PATH);
             break;
         default:
             $cache = $arrayCache;
             break;
     }
     \Env::set('cache', $cache);
     //$config->setResultCacheImpl($cache);
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(ASCMS_MODEL_PROXIES_PATH);
     $config->setProxyNamespace('Cx\\Model\\Proxies');
     /**
      * This should be set to true if workbench is present and active.
      * Just checking for workbench.config is not really a good solution.
      * Since ConfigurationFactory used by EM caches auto generation
      * config value, there's no possibility to set this later.
      */
     $config->setAutoGenerateProxyClasses(file_exists(ASCMS_DOCUMENT_ROOT . '/workbench.config'));
     $connectionOptions = array('pdo' => $this->getPdoConnection(), 'dbname' => $this->db->getName());
     $evm = new \Doctrine\Common\EventManager();
     $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $driverImpl = new \Cx\Core\Model\Controller\YamlDriver(array(ASCMS_CORE_PATH . '/Core' . '/Model/Yaml'));
     $chainDriverImpl->addDriver($driverImpl, 'Cx');
     //loggable stuff
     $loggableDriverImpl = $config->newDefaultAnnotationDriver(ASCMS_LIBRARY_PATH . '/doctrine/Gedmo/Loggable/Entity');
     $chainDriverImpl->addDriver($loggableDriverImpl, 'Gedmo\\Loggable');
     $this->loggableListener = new \Cx\Core\Model\Model\Event\LoggableListener();
     $this->loggableListener->setUsername('currently_loggedin_user');
     // in real world app the username should be loaded from session, example:
     // Session::getInstance()->read('user')->getUsername();
     $evm->addEventSubscriber($this->loggableListener);
     //tree stuff
     $treeListener = new \Gedmo\Tree\TreeListener();
     $evm->addEventSubscriber($treeListener);
     $config->setMetadataDriverImpl($chainDriverImpl);
     //table prefix
     $prefixListener = new \DoctrineExtension\TablePrefixListener($this->db->getTablePrefix());
     $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefixListener);
     $config->setSqlLogger(new \Cx\Lib\DBG\DoctrineSQLLogger());
     $em = \Cx\Core\Model\Controller\EntityManager::create($connectionOptions, $config, $evm);
     //resolve enum, set errors
     $conn = $em->getConnection();
     $conn->setCharset($this->db->getCharset());
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $this->em = $em;
     return $this->em;
 }
Ejemplo n.º 13
0
 /**
  * Does the resolving work, extends $this->url with targetPath and params.
  */
 public function resolvePage($internal = false)
 {
     // Abort here in case we're handling a legacy request.
     // The legacy request will be handled by $this->legacyResolve().
     // Important: We must check for $internal == FALSE here, to abort the resolving process
     //            only when we're resolving the initial (original) request.
     //            Internal resolving requests might be called by $this->legacyResolve()
     //            and shall therefore be processed.
     if (!$internal && isset($_REQUEST['section'])) {
         throw new ResolverException('Legacy request');
     }
     $path = $this->url->getSuggestedTargetPath();
     if (!$this->page || $internal) {
         if ($this->pagePreview) {
             if (!empty($this->sessionPage) && !empty($this->sessionPage['pageId'])) {
                 $this->getPreviewPage();
             }
         }
         //(I) see what the model has for us
         $result = $this->pageRepo->getPagesAtPath($this->url->getLangDir() . '/' . $path, null, $this->lang, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY);
         if (isset($result['page']) && $result['page'] && $this->pagePreview) {
             if (empty($this->sessionPage)) {
                 if (\Permission::checkAccess(6, 'static', true)) {
                     $result['page']->setActive(true);
                     $result['page']->setDisplay(true);
                     if ($result['page']->getEditingStatus() == 'hasDraft' || $result['page']->getEditingStatus() == 'hasDraftWaiting') {
                         $logEntries = $this->logRepo->getLogEntries($result['page']);
                         $this->logRepo->revert($result['page'], $logEntries[1]->getVersion());
                     }
                 }
             }
         }
         //(II) sort out errors
         if (!$result) {
             throw new ResolverException('Unable to locate page (tried path ' . $path . ').');
         }
         if (!$result['page']) {
             throw new ResolverException('Unable to locate page for this language. (tried path ' . $path . ').');
         }
         if (!$result['page']->isActive()) {
             throw new ResolverException('Page found, but it is not active.');
         }
         // if user has no rights to see this page, we redirect to login
         $this->checkPageFrontendProtection($result['page']);
         // If an older revision was requested, revert to that in-place:
         if (!empty($this->historyId) && \Permission::checkAccess(6, 'static', true)) {
             $this->logRepo->revert($result['page'], $this->historyId);
         }
         //(III) extend our url object with matched path / params
         $this->url->setTargetPath($result['matchedPath'] . $result['unmatchedPath']);
         $this->url->setParams($this->url->getSuggestedParams());
         $this->page = $result['page'];
     }
     if (!$this->urlPage) {
         $this->urlPage = clone $this->page;
     }
     /*
      the page we found could be a redirection.
      in this case, the URL object is overwritten with the target details and
      resolving starts over again.
     */
     $target = $this->page->getTarget();
     $isRedirection = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT;
     $isAlias = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS;
     //handles alias redirections internal / disables external redirection
     $this->forceInternalRedirection = $this->forceInternalRedirection || $isAlias;
     if ($target && ($isRedirection || $isAlias)) {
         // Check if page is a internal redirection and if so handle it
         if ($this->page->isTargetInternal()) {
             //TODO: add check for endless/circular redirection (a -> b -> a -> b ... and more complex)
             $nId = $this->page->getTargetNodeId();
             $lId = $this->page->getTargetLangId();
             $module = $this->page->getTargetModule();
             $cmd = $this->page->getTargetCmd();
             $qs = $this->page->getTargetQueryString();
             $langId = $lId ? $lId : $this->lang;
             // try to find the redirection target page
             if ($nId) {
                 $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $langId));
                 // revert to default language if we could not retrieve the specified langauge by the redirection.
                 // so lets try to load the redirection of the current language
                 if (!$targetPage) {
                     if ($langId != 0) {
                         //make sure we weren't already retrieving the default language
                         $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $this->lang));
                         $langId = $this->lang;
                     }
                 }
             } else {
                 $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $cmd, $langId);
                 // in case we were unable to find the requested page, this could mean that we are
                 // trying to retrieve a module page that uses a string with an ID (STRING_ID) as CMD.
                 // therefore, lets try to find the module by using the string in $cmd and INT in $langId as CMD.
                 // in case $langId is really the requested CMD then we will have to set the
                 // resolved language back to our original language $this->lang.
                 if (!$targetPage) {
                     $targetPage = $this->pageRepo->findOneBymoduleCmdLang($module, $cmd . '_' . $langId, $this->lang);
                     if ($targetPage) {
                         $langId = $this->lang;
                     }
                 }
                 // try to retrieve a module page that uses only an ID as CMD.
                 // lets try to find the module by using the INT in $langId as CMD.
                 // in case $langId is really the requested CMD then we will have to set the
                 // resolved language back to our original language $this->lang.
                 if (!$targetPage) {
                     $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $langId, $this->lang);
                     $langId = $this->lang;
                 }
                 // revert to default language if we could not retrieve the specified langauge by the redirection.
                 // so lets try to load the redirection of the current language
                 if (!$targetPage) {
                     if ($langId != 0) {
                         //make sure we weren't already retrieving the default language
                         $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $cmd, $this->lang);
                         $langId = $this->lang;
                     }
                 }
             }
             //check whether we have a page now.
             if (!$targetPage) {
                 $this->page = null;
                 return;
             }
             // the redirection page is located within a different language.
             // therefore, we must set $this->lang to the target's language of the redirection.
             // this is required because we will next try to resolve the redirection target
             if ($langId != $this->lang) {
                 $this->lang = $langId;
                 $this->url->setLangDir(\FWLanguage::getLanguageCodeById($langId));
                 $this->pathOffset = ASCMS_INSTANCE_OFFSET;
             }
             $targetPath = substr($targetPage->getPath(), 1);
             $this->url->setTargetPath($targetPath . $qs);
             $this->url->setPath($targetPath . $qs);
             $this->isRedirection = true;
             $this->resolvePage(true);
         } else {
             //external target - redirect via HTTP 302
             if (\FWValidator::isUri($target)) {
                 $this->headers['Location'] = $target;
                 $emptyString = '';
                 \Env::set('Resolver', $this);
                 \Env::set('Page', $this->page);
                 \Env::get('cx')->getComponent('Cache')->postFinalize($emptyString);
                 header('Location: ' . $target);
                 exit;
             } else {
                 if ($target[0] == '/') {
                     $target = substr($target, 1);
                 }
                 $langDir = '';
                 if (!file_exists(ASCMS_INSTANCE_PATH . ASCMS_INSTANCE_OFFSET . '/' . $target)) {
                     $langCode = '';
                     if (\Cx\Core\Routing\Url::isVirtualLanguageDirsActive()) {
                         $langCode = \FWLanguage::getLanguageCodeById($this->lang);
                     }
                     if (!empty($langCode)) {
                         $langDir = '/' . $langCode;
                     }
                 }
                 $target = ASCMS_INSTANCE_OFFSET . $langDir . '/' . $target;
                 $this->headers['Location'] = $target;
                 $emptyString = '';
                 \Env::set('Resolver', $this);
                 \Env::set('Page', $this->page);
                 \Env::get('cx')->getComponent('Cache')->postFinalize($emptyString);
                 header('Location: ' . $target);
                 exit;
             }
         }
     }
     //if we followed one or more redirections, the user shall be redirected by 302.
     if ($this->isRedirection && !$this->forceInternalRedirection) {
         $params = $this->url->getSuggestedParams();
         $target = $this->page->getURL($this->pathOffset, array());
         $target->setParams($params);
         $this->headers['Location'] = $target;
         $emptyString = '';
         \Env::set('Resolver', $this);
         \Env::set('Page', $this->page);
         \Env::get('cx')->getComponent('Cache')->postFinalize($emptyString);
         header('Location: ' . $target);
         exit;
     }
     // in case the requested page is of type fallback, we will now handle/load this page
     $this->handleFallbackContent($this->page, !$internal);
     // set legacy <section> and <cmd> in case the requested page is an application
     if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION || $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) {
         $this->command = $this->page->getCmd();
         $this->section = $this->page->getModule();
     }
 }
Ejemplo n.º 14
0
if (!$objDatabase) {
    die($errorMsg);
}
Env::set('db', $objDatabase);
if (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'session_variable')) {
    require_once UPDATE_CORE . '/session.class.php';
    // Start session
    $sessionObj = new cmsSession();
} else {
    require_once UPDATE_CORE . '/session32.class.php';
    $sessionObj = \cmsSession::getInstance();
}
$sessionObj->cmsSessionStatusUpdate('backend');
// Initialize base system
$objInit = new InitCMS('update', \Env::get('em'));
Env::set('init', $objInit);
JS::activate('cx');
JS::activate('jquery-tools');
JS::registerJS('lib/contrexxUpdate.php');
JS::registerJS('lib/javascript/html2dom.js');
// Debugging
try {
    // load file classes
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileInterface.interface.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileSystem.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileSystemFile.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FTPFile.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/File.class.php';
    activateDebugging();
} catch (\Exception $e) {
    // don't handle this exception here because we can't print a nice error message
 /**
  * Do something after resolving is done
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             global $objInit, $_LANGID, $_FRONTEND_LANGID, $_CORELANG, $_ARRAYLANG, $plainCmd;
             $objInit->_initBackendLanguage();
             $objInit->getUserFrontendLangId();
             $_LANGID = $objInit->getBackendLangId();
             $_FRONTEND_LANGID = $objInit->userFrontendLangId;
             /**
              * Language constants
              *
              * Defined as follows:
              * - BACKEND_LANG_ID is set to the visible backend language
              *   in the backend *only*.  In the frontend, it is *NOT* defined!
              *   It indicates a backend user and her currently selected language.
              *   Use this in methods that are intended *for backend use only*.
              *   It *MUST NOT* be used to determine the language for any kind of content!
              * - FRONTEND_LANG_ID is set to the selected frontend or content language
              *   both in the back- and frontend.
              *   It *always* represents the language of content being viewed or edited.
              *   Use FRONTEND_LANG_ID for that purpose *only*!
              * - LANG_ID is set to the same value as BACKEND_LANG_ID in the backend,
              *   and to the same value as FRONTEND_LANG_ID in the frontend.
              *   It *always* represents the current users' selected language.
              *   It *MUST NOT* be used to determine the language for any kind of content!
              * @since 2.2.0
              */
             define('FRONTEND_LANG_ID', $_FRONTEND_LANGID);
             define('BACKEND_LANG_ID', $_LANGID);
             define('LANG_ID', $_LANGID);
             /**
              * Core language data
              * @ignore
              */
             // Corelang might be initialized by CSRF already...
             if (!is_array($_CORELANG) || !count($_CORELANG)) {
                 $_CORELANG = $objInit->loadLanguageData('core');
             }
             /**
              * Module specific language data
              * @ignore
              */
             $_ARRAYLANG = $objInit->loadLanguageData($plainCmd);
             $_ARRAYLANG = array_merge($_ARRAYLANG, $_CORELANG);
             \Env::set('lang', $_ARRAYLANG);
             break;
         default:
             break;
     }
 }
Ejemplo n.º 16
0
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * 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 Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
/**
 * This file is used so index.php works under PHP 5.2 (namespaces!)
 * @author <*****@*****.**>
 */
require_once $basePath . '/../core/Core/Controller/Cx.class.php';
require_once $basePath . '/../core/ClassLoader/ClassLoader.class.php';
require_once $basePath . '/InstallerCx.class.php';
$installerCx = new \InstallerCx($basePath);
$cl = new \Cx\Core\ClassLoader\ClassLoader($installerCx, false);
$cl->loadFile($basePath . '/../core/Env.class.php');
$cl->loadFile($basePath . '/../lib/FRAMEWORK/DBG/DBG.php');
\Env::set('cx', $installerCx);
Ejemplo n.º 17
0
 public static function parseArguments($argv)
 {
     $mapinfo = Env::get('mapinfo');
     $cache = false;
     $args = self::arguments($argv);
     if (isset($args['game'])) {
         if (!isset($mapinfo[$args['game']])) {
             show::Event("ERROR", "Game: " . $args['game'] . " doesn't exists, escaping", 1);
             exit;
         }
         if (isset($args['map'])) {
             if (!isset($mapinfo[$args['game']][$args['map']])) {
                 show::Event("ERROR", "Game: " . $args['game'] . " Map: " . $args['map'] . " doesn't exists, escaping", 1);
                 exit;
             }
             $tmp[$args['game']][$args['map']] = $mapinfo[$args['game']][$args['map']];
             show::Event("ARGS", "--game=" . $args['game'], 2);
             show::Event("ARGS", "--map=" . $args['map'], 2);
         } else {
             $tmp[$args['game']] = $mapinfo[$args['game']];
             show::Event("ARGS", "--game=" . $args['game'], 2);
         }
     } else {
         $visible = '';
         $query = "SELECT code FROM hlstats_Games WHERE hidden='0'";
         $result = DB::doQuery($query);
         if (DB::numRows($result)) {
             while ($row = DB::getAssoc($result)) {
                 foreach ($row as $key => $val) {
                     if (isset($mapinfo[$val])) {
                         $visible .= "{$val}, ";
                         $tmp[$val] = $mapinfo[$val];
                     }
                 }
             }
         }
         show::Event("GAMES", substr($visible, 0, -2), 2);
     }
     if (isset($tmp)) {
         $mapinfo = $tmp;
     }
     if (isset($args['disablecache'])) {
         $cache = true;
         show::Event("ARGS", "--disable-cache=true", 2);
     } else {
         $cache = false;
         show::Event("ARGS", "--disable-cache=false", 2);
     }
     if (isset($args['ignoreinfected'])) {
         $ignore_infected = true;
         show::Event("ARGS", "--ignore-infected=true", 2);
     } else {
         $ignore_infected = false;
         show::Event("ARGS", "--ignore-infected=false", 2);
     }
     Env::set('mapinfo', $mapinfo);
     Env::set('disable_cache', $cache);
     Env::set('ignore_infected', $ignore_infected);
 }
Ejemplo n.º 18
0
<?php

require_once __DIR__ . "/Test01Command.php";
//Env::set("username", "vagrant");
//Env::set("server.port", 2222);
Server::nodesFromSSHConfigHosts();
Server::node("127.0.0.1");
Server::node("localhost", array("host" => "127.0.0.1", "username" => Env::get("username"), "port" => Env::get("server.port"), "key" => Env::get("homedir") . "/.ssh/id_rsa"));
Server::role("test", array("127.0.0.1", "localhost"));
Env::set("server.key", Env::get("homedir") . "/.ssh/id_rsa");
Env::set("server.username", Env::get("username"));
// Basic test task
Task::register("testBasic", function ($task) {
    $task->writeln("output log");
    $task->call("testHidden");
    $task->exec(function ($process) {
        $process->runLocally("echo runLocally!");
    });
    $task->exec(function ($process) {
        $process->run("echo run!");
    }, array("127.0.0.1"));
    $task->exec(function ($process) {
        $process->run("echo run!", array("cwd" => "~"));
        $process->getNode();
    }, array("127.0.0.1"));
    $task->exec(function ($process) {
        $process->run("echo run!");
    });
});
Task::register("testHidden", function ($task) {
    $task->writeln("Run testHidden!");
Ejemplo n.º 19
0
$config->setAutoGenerateProxyClasses(false);
$connection = new \PDO('mysql:dbname=' . $_DBCONFIG['database'] . ';' . (!empty($_DBCONFIG['charset']) ? 'charset=' . $_DBCONFIG['charset'] . ';' : '') . 'host=' . $_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $_DBCONFIG['charset']));
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$connectionOptions = array('pdo' => $connection);
$evm = new \Doctrine\Common\EventManager();
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$driverImpl = new \Doctrine\ORM\Mapping\Driver\YamlDriver(ASCMS_MODEL_PATH . '/yml');
$chainDriverImpl->addDriver($driverImpl, 'Cx\\Model');
$driverImpl = new \Doctrine\ORM\Mapping\Driver\YamlDriver(ASCMS_CORE_PATH . '/ContentManager/Model/Yaml');
$chainDriverImpl->addDriver($driverImpl, 'Cx\\Core\\ContentManager');
//loggable stuff
$loggableDriverImpl = $config->newDefaultAnnotationDriver(array(UPDATE_CORE, $doctrineDir . 'Gedmo/Loggable/Entity'));
$chainDriverImpl->addDriver($loggableDriverImpl, 'Gedmo\\Loggable');
$loggableListener = new \Cx\Update\core\LoggableListener();
$evm->addEventSubscriber($loggableListener);
\Env::set('loggableListener', $loggableListener);
//tree stuff
$treeListener = new \Gedmo\Tree\TreeListener();
$evm->addEventSubscriber($treeListener);
$config->setMetadataDriverImpl($chainDriverImpl);
//table prefix
$prefixListener = new \DoctrineExtension\TablePrefixListener($_DBCONFIG['tablePrefix']);
$evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefixListener);
//page listener for unique slugs
$pageListener = new PageEventListener();
$evm->addEventListener(\Doctrine\ORM\Events::preUpdate, $pageListener);
$evm->addEventListener(\Doctrine\ORM\Events::onFlush, $pageListener);
$evm->addEventListener(\Doctrine\ORM\Events::postPersist, $pageListener);
$evm->addEventListener(\Doctrine\ORM\Events::preRemove, $pageListener);
$config->setSqlLogger(new \Cx\Lib\DBG\DoctrineSQLLogger());
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm);
Ejemplo n.º 20
0
 public static function initItemsBasedOnBaseUrl()
 {
     if (isset($_SERVER['REQUEST_URI'])) {
         $requestUri = $_SERVER['REQUEST_URI'];
         if (preg_match('#https?://[^/]+(/.*)/#', Env::get('base_url'), $matches)) {
             $baseUrlBaseUri = $matches[1];
             if (substr($requestUri, 0, strlen($baseUrlBaseUri)) == $baseUrlBaseUri) {
                 $requestUri = substr($requestUri, strlen($baseUrlBaseUri));
             }
         }
         Env::set('request_url', $requestUri, -10);
     } else {
         Env::set('request_url', false, -10);
     }
     $url = parse_url(Env::get('request_url'), PHP_URL_PATH);
     if ($url != '/') {
         $url = rtrim($url, '/');
     }
     Env::set('controller_url', $url, -10);
     Env::set('page_class', $url == '/' ? 'home' : preg_replace('/[^a-z0-9]+/', '-', ltrim(strtolower($url), '/')) . '-page', -10);
     Env::set('cookie', new CookieManager(), -10);
 }
Ejemplo n.º 21
0
 function checkOptions()
 {
     if (!empty($_SESSION['installer']['config']['useFtp'])) {
         global $objCommon;
         $ftpConfig = array('is_activated' => $_SESSION['installer']['config']['useFtp'], 'host' => $_SESSION['installer']['config']['ftpHostname'], 'port' => isset($_SESSION['installer']['config']['ftpPort']) ? $_SESSION['installer']['config']['ftpPort'] : $objCommon->ftpPort, 'username' => $_SESSION['installer']['config']['ftpUsername'], 'password' => $_SESSION['installer']['config']['ftpPassword'], 'path' => $_SESSION['installer']['config']['ftpPath']);
         \Env::set('ftpConfig', $ftpConfig);
     }
     switch ($this->arrSteps[$_SESSION['installer']['step']]['step']) {
         case 'welcome':
             $this->_checkWelcome();
             break;
         case 'license':
             $this->_checkLicense();
             break;
         case 'requirements':
             $this->_checkRequirements();
             break;
         case 'configuration':
             $this->_checkConfiguration();
             break;
         case 'installation':
             $this->_checkInstallation();
             break;
         case 'systemConfig':
             $this->_checkSystemConfig();
             break;
         case 'adminAccount':
             $this->_checkAdminAccount();
             break;
     }
 }
Ejemplo n.º 22
0
 /**
  * Bind initialized PDO connection
  * @param   \PDO    $pdo    Initialized PDO connection to be used as
  *                          database connection.
  */
 public function setPdoConnection($pdo)
 {
     $this->pdo = $pdo;
     \Env::set('pdo', $this->pdo);
 }
Ejemplo n.º 23
0
function MAL_EVAL($ast, $env)
{
    while (true) {
        #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        // apply list
        $ast = macroexpand($ast, $env);
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        if ($ast->count() === 0) {
            return $ast;
        }
        $a0 = $ast[0];
        $a0v = _symbol_Q($a0) ? $a0->value : $a0;
        switch ($a0v) {
            case "def!":
                $res = MAL_EVAL($ast[2], $env);
                return $env->set($ast[1], $res);
            case "let*":
                $a1 = $ast[1];
                $let_env = new Env($env);
                for ($i = 0; $i < count($a1); $i += 2) {
                    $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
                }
                $ast = $ast[2];
                $env = $let_env;
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "quote":
                return $ast[1];
            case "quasiquote":
                $ast = quasiquote($ast[1]);
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "defmacro!":
                $func = MAL_EVAL($ast[2], $env);
                $func->ismacro = true;
                return $env->set($ast[1], $func);
            case "macroexpand":
                return macroexpand($ast[1], $env);
            case "do":
                eval_ast($ast->slice(1, -1), $env);
                $ast = $ast[count($ast) - 1];
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "if":
                $cond = MAL_EVAL($ast[1], $env);
                if ($cond === NULL || $cond === false) {
                    if (count($ast) === 4) {
                        $ast = $ast[3];
                    } else {
                        $ast = NULL;
                    }
                } else {
                    $ast = $ast[2];
                }
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "fn*":
                return _function('MAL_EVAL', 'native', $ast[2], $env, $ast[1]);
            default:
                $el = eval_ast($ast, $env);
                $f = $el[0];
                $args = array_slice($el->getArrayCopy(), 1);
                if ($f->type === 'native') {
                    $ast = $f->ast;
                    $env = $f->gen_env($args);
                    // Continue loop (TCO)
                } else {
                    return $f->apply($args);
                }
        }
    }
}
Ejemplo n.º 24
0
 /**
  * This populates globals for legacy code
  * @todo Avoid this! All this should be part of some components hook
  * @global type $objFWUser
  * @global type $objTemplate
  * @global type $cl
  * @global \InitCMS $objInit
  * @global type $_LANGID
  * @global type $_CORELANG
  * @global \Cx\Core\Routing\Url $url
  * @param int $no Hook number
  */
 protected function legacyGlobalsHook($no)
 {
     global $objFWUser, $objTemplate, $cl, $objInit, $_LANGID, $_CORELANG, $url;
     switch ($no) {
         case 1:
             // Request URL
             $url = $this->request->getUrl();
             // populate template
             $objTemplate = $this->template;
             // populate classloader
             $cl = $this->cl;
             break;
         case 2:
             // Code to set language
             // @todo: move this to somewhere else
             // in backend it's in Language->postResolve
             if ($this->mode == self::MODE_FRONTEND) {
                 $_LANGID = FRONTEND_LANG_ID;
                 $objInit->setFrontendLangId($_LANGID);
                 define('LANG_ID', $_LANGID);
                 // Load interface language data
                 $_CORELANG = $objInit->loadLanguageData('core');
             }
             \Env::set('Resolver', $this->resolver);
             // Resolver code
             // @todo: move to resolver
             //expose the virtual language directory to the rest of the cms
             $virtualLanguageDirectory = $url->getLangDir(true);
             if (!empty($virtualLanguageDirectory)) {
                 $virtualLanguageDirectory = '/' . $virtualLanguageDirectory;
             }
             \Env::set('virtualLanguageDirectory', $virtualLanguageDirectory);
             // TODO: this constanst used to be located in config/set_constants.php, but needed to be relocated to this very place,
             // because it depends on Env::get('virtualLanguageDirectory').
             // Find an other solution; probably best is to replace CONTREXX_SCRIPT_PATH by a prettier method
             define('CONTREXX_SCRIPT_PATH', $this->codeBaseOffsetPath . \Env::get('virtualLanguageDirectory') . '/' . CONTREXX_DIRECTORY_INDEX);
             break;
     }
 }
Ejemplo n.º 25
0
function activateDebugging()
{
    $File = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/update/dbg.log');
    if ($File->getAccessMode() == \Cx\Lib\FileSystem\File::FTP_ACCESS) {
        throw new \Exception('Cannot write log via FTP (file needs to be loaded into memory which leads to memory overflow)');
    }
    // temporariy disable FTP support to prevent the FileSystem
    // from creating the dbg.log file through FTP
    $ftpConfig = \Env::get('ftpConfig');
    if ($ftpConfig['is_activated']) {
        \DBG::msg('Update: Intentionally deactivate FTP support as we do not support to write the update log (dbg.log) through FTP due to potential memory overflows.');
        $hackedFtpConfig = $ftpConfig;
        $hackedFtpConfig['is_activated'] = false;
        \Env::set('ftpConfig', $hackedFtpConfig);
    }
    $File->touch();
    // reset FTP
    if ($ftpConfig['is_activated']) {
        \Env::set('ftpConfig', $ftpConfig);
    }
    if ($File->makeWritable()) {
        \DBG::activate(DBG_LOG_FILE | DBG_PHP | DBG_DB);
        return true;
    }
    return false;
}
Ejemplo n.º 26
0
 public function setEnv($values)
 {
     foreach ($this->getEnvFieldNames() as $field) {
         if (array_key_exists($field, $values)) {
             Env::set($this->envprefix . $field, $values[$field]);
         }
     }
 }