/** * @param int $mode */ public function init($mode = Core::ROUTE_NORMAL) { $globalConfigs = array('ENV' => self::ENV_DEVELOPMENT, 'JS_FOLDER' => '/js', 'CSS_FOLDER' => '/css', 'CONSOLIDATE_FOLDER' => '/consolidated', 'PROFILER_ENABLED' => false); foreach ($globalConfigs as $config => $val) { if (!defined($config)) { define($config, $val); } } if (ENV == self::ENV_DEVELOPMENT) { error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); } if (is_object($this->session) && $this->isCLI() === false) { $this->session->start(); } $this->mode = $mode; $this->startTimer(__CLASS__); // Assign our output handler to output clean errors ob_start(); // ingore user abort, is recommed for ajax request and db changes if ($this->request->isXmlHttpRequest()) { ignore_user_abort(true); } $this->registryManager->init(); if ($this->isCLI() === false) { // Sanitize all request variables $_GET = $this->sanitize($_GET); $_POST = $this->sanitize($_POST); $_COOKIE = $this->sanitize($_COOKIE); if ($mode === Core::ROUTE_NORMAL) { $this->cache->load(); // Try to load a site by the requested URI $this->route->loadSite(); if (!$this->request->isXmlHttpRequest() && !$this->request->isPost()) { echo '<!-- ' . $this->getPageLoadTime() . 'sec -->'; } $this->response->finish(false, true); } } else { $params = getopt('p:'); if ($params['p']) { $_SERVER['REQUEST_URI'] = $params['p']; $this->route->loadVirtualRoutes(); echo $this->route->checkVirtualRoute(); } } }
/** * @param int $mode */ public function init($mode = Core::ROUTE_NORMAL) { if (ENV == self::ENV_DEVELOPMENT) { error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); } if (is_object($this->session) && $this->isCLI() === false) { $this->session->start(); } $this->mode = $mode; $this->startTimer(__CLASS__); // Assign our output handler to output clean errors ob_start(); // ingore user abort, is recommed for ajax request and db changes if ($this->request->isXmlHttpRequest()) { ignore_user_abort(true); } $this->registryManager->init(); if ($this->isCLI() === false) { // Sanitize all request variables $_GET = $this->sanitize($_GET); $_POST = $this->sanitize($_POST); $_COOKIE = $this->sanitize($_COOKIE); if ($mode === Core::ROUTE_NORMAL) { $this->cache->load(); // Try to load a site by the requested URI $this->route->loadSite(); $this->response->finish(false, true); } } else { $params = getopt('p:'); if ($params['p']) { $_SERVER['REQUEST_URI'] = $params['p']; $this->route->loadRoutes(); echo $this->route->getVirtualRouteContent(); } } }
/** * @return array|bool */ protected function initConfigurations() { $gp = $this->request->getGPAsObject(); $errors = []; /** * create default language */ $locale = new \Fraym\Locale\Entity\Locale(); switch ($gp->locale) { case 'german': $locale->name = 'German'; $locale->locale = 'de_DE'; $locale->country = 'Germany'; $locale->default = true; break; case 'french': $locale->name = 'French'; $locale->locale = 'fr_FR'; $locale->country = 'France'; $locale->default = true; break; case 'swedish': $locale->name = 'swedish'; $locale->locale = 'sv_SE'; $locale->country = 'Sweden'; $locale->default = true; break; case 'spanish': $locale->name = 'Spanish'; $locale->locale = 'es_ES'; $locale->country = 'Spain'; $locale->default = true; break; default: // english $locale->name = 'English'; $locale->locale = 'en_US'; $locale->country = 'USA'; $locale->default = true; break; } $this->db->persist($locale); $this->db->flush(); $this->locale->setLocale($locale); $this->db->setUpTranslateable()->setUpSortable(); /** * create site */ $site = new \Fraym\Site\Entity\Site(); $site->name = $gp->site->name; $site->caching = true; $site->active = true; $site->menuItems->clear(); $this->db->persist($site); /** * create domain for site */ $domain = new \Fraym\Site\Entity\Domain(); $domain->site = $site; $domain->address = $gp->site->url; $this->db->persist($domain); $this->addMenuItems($site); $adminGroup = new \Fraym\User\Entity\Group(); $adminGroup->name = $this->translation->autoTranslation('Administrator', 'en', $this->locale->getLocale()->locale); $adminGroup->identifier = 'Administrator'; $this->db->persist($adminGroup); $adminUser = new \Fraym\User\Entity\User(); $adminUser->updateEntity($gp->user, false); if (strlen($gp->user->password) < 8) { $errors[] = 'Password is too short.'; } elseif ($gp->user->password === $gp->user->password_repeat) { $adminUser->password = $gp->user->password; } else { $errors[] = 'Passwords do not match.'; } $adminUser->groups->add($adminGroup); $this->db->persist($adminUser); if (count($errors) === 0) { $this->db->flush(); $this->db->clear(); /** * Register extensions, default theme... */ $this->registry->registerExtensions(); /** * Set menuitem template -> default theme */ $this->setupMenuItemTemplate(); /** * Login admin user */ $this->user->setUserId($adminUser->id); return true; } return $errors; }