public function ConfigPage() { // $this->addTitle(LAN_EURL_NAME_CONFIG); $active = e107::getPref('url_config'); $set = array(); // all available URL modules $set['url_modules'] = eRouter::adminReadModules(); // set by user URL config locations $set['url_config'] = eRouter::adminBuildConfig($active, $set['url_modules']); // all available URL config locations $set['url_locations'] = eRouter::adminBuildLocations($set['url_modules']); $form = $this->getUI(); $text = "\n\t\t\t<form action='" . e_SELF . "?mode=main&action=config' method='post' id='urlconfig-form'>\n\t\t\t\t<fieldset id='core-eurl-core'>\n\t\t\t\t\t<legend>" . LAN_EURL_LEGEND_CONFIG . "</legend>\n\t\t\t\t\t<table class='table adminlist'>\n\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t<col class='col-label' style='width:20%' />\n\t\t\t\t\t\t\t<col class='col-control' style='width:60%' />\n\t\t\t\t\t\t\t<col style='width:20%' />\n\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t <th>" . LAN_TYPE . "</th>\n\t\t\t\t\t\t <th>" . LAN_URL . "</th>\n\t\t\t\t\t\t <th>" . LAN_OPTIONS . "</th>\n\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t<tbody>\n\t\t"; $text .= $this->renderConfig($set['url_config'], $set['url_locations']); $text .= "\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t<div class='buttons-bar center'>\n\t\t\t\t\t\t" . $form->admin_button('update', LAN_UPDATE, 'update') . "\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t</form>\n\t\t"; return $text; }
/** * Parases a URL based on this rule. * @param eRouter $manager the router/URL manager * @param eRequest $request the request object * @param string $pathInfo path info part of the URL * @param string $rawPathInfo path info that contains the potential URL suffix * @return mixed the route that consists of the controller ID and action ID or false on error */ public function parseUrl($manager, $request, $pathInfo, $rawPathInfo) { $case = 'i'; # 'i' = insensitive if ($this->urlSuffix !== null) { $pathInfo = $manager->removeUrlSuffix($rawPathInfo, $this->urlSuffix); } $pathInfo = rtrim($pathInfo, '/') . '/'; // pathInfo is decoded, pattern could be encoded - required for proper url assemble (e.g. cyrillic chars) if (preg_match(rawurldecode($this->pattern) . $case, $pathInfo, $matches)) { foreach ($this->defaultParams as $name => $value) { //if (!isset($_GET[$name])) $_REQUEST[$name] = $_GET[$name] = $value; if (!$request->isRequestParam($name)) { $request->setRequestParam($name, $value); } } $tr = array(); foreach ($matches as $key => $value) { if (isset($this->references[$key])) { $tr[$this->references[$key]] = $value; } elseif (isset($this->params[$key])) { //$_REQUEST[$key] = $_GET[$key] = $value; $request->setRequestParam($key, $value); } } if ($pathInfo !== $matches[0]) { $manager->parsePathInfo($request, ltrim(substr($pathInfo, strlen($matches[0])), '/')); } return null !== $this->routePattern ? strtr($this->route, $tr) : $this->route; } else { return false; } }
public function import_configuration() { $this->logLine('Starting configuration import'); // PRE-CONFIG start - create and register blank config instances - do not load! $config_aliases = array('core', 'core_backup', 'emote', 'menu', 'search', 'notify'); foreach ($config_aliases as $alias) { e107::getConfig($alias, false)->clearPrefCache(); } // PRE-CONFIG end // Basic stuff to get the handlers/classes to work. // $udirs = "admin/|plugins/|temp"; // $e_SELF = $_SERVER['PHP_SELF']; // $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); //define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); // define('CHARSET', 'utf-8'); // define("e_LANGUAGE", $this->previous_steps['language']); // define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']); $themeImportFile = array(); $themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'] . $this->previous_steps['prefs']['sitetheme'] . "/install.xml"; $themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'] . $this->previous_steps['prefs']['sitetheme'] . "/install/install.xml"; $themeImportFile[3] = $this->e107->e107_dirs['CORE_DIRECTORY'] . "xml/default_install.xml"; if (vartrue($this->previous_steps['generate_content'])) { foreach ($themeImportFile as $file) { if (is_readable($file)) { $XMLImportfile = $file; break; } } } else { $XMLImportfile = $this->e107->e107_dirs['CORE_DIRECTORY'] . "xml/default_install.xml"; } $tp = e107::getParser(); define('PREVIEWTHEMENAME', ""); // Notice Removal. include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'] . $this->previous_steps['language'] . "/lan_prefs.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'] . $this->previous_steps['language'] . "/admin/lan_theme.php"); //should be 'add' not 'replace' - but 'add' doesn't insert arrays correctly. // [SecretR] should work now - fixed log errors (argument noLogs = true) change to false to enable log e107::getXml()->e107Import($XMLImportfile, 'add', true, false); // Add missing core pref values $this->logLine('Core prefs written'); //Create default plugin-table entries. // e107::getConfig('core')->clearPrefCache(); e107::getPlugin()->update_plugins_table(); $this->logLine('Plugins table updated'); // Install Theme-required plugins if (vartrue($this->previous_steps['install_plugins'])) { if ($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme'])) { if (isset($themeInfo['plugins']['plugin'])) { foreach ($themeInfo['plugins']['plugin'] as $k => $plug) { $this->install_plugin($plug['@attributes']['name']); $this->logLine('Theme-related plugin installed: ' . $plug['@attributes']['name']); } } } } // Media import /* e107::getMedia()->import('news',e_IMAGE.'newspost_images/') //TODO remove when news are pluginized ->import('page',e_IMAGE.'custom/') //TODO remove when pages are pluginized // ->importIcons(e_PLUGIN) - icons for plugins are imported on install ->importIcons(e_IMAGE."icons/") ->importIcons(e_THEME.$this->previous_steps['prefs']['sitetheme']."/images/") ->importIcons(e_THEME.$this->previous_steps['prefs']['sitetheme']."/icons/"); $this->logLine('Media imported to media manager'); */ e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list. $this->logLine('Addon prefs saved'); $tm = e107::getSingleton('themeHandler'); $tm->noLog = true; // false to enable log $tm->setTheme($this->previous_steps['prefs']['sitetheme']); // Admin log fix - don't allow logs to be called inside pref handler e107::getConfig('core')->setParam('nologs', false); // change to true to enable log $pref = e107::getConfig('core')->getPref(); // Set Preferences defined during install - overwriting those that may exist in the XML. $this->previous_steps['prefs']['sitelanguage'] = $this->previous_steps['language']; $this->previous_steps['prefs']['sitelang_init'] = $this->previous_steps['language']; $this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email']; $this->previous_steps['prefs']['install_date'] = time(); $this->previous_steps['prefs']['siteurl'] = e_HTTP; $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2; $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3; $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email']; // Cookie name fix, ended up with 406 error when non-latin words used $cookiename = preg_replace('/[^a-z0-9]/i', '', trim($this->previous_steps['prefs']['sitename'])); $this->previous_steps['prefs']['cookie_name'] = ($cookiename ? substr($cookiename, 0, 4) . '_' : 'e_') . 'cookie'; ### URL related prefs // set all prefs so that they are available, required for adminReadModules() - it checks which plugins are installed e107::getConfig('core')->setPref($this->previous_steps['prefs']); $url_modules = eRouter::adminReadModules(); $url_locations = eRouter::adminBuildLocations($url_modules); $url_config = eRouter::adminBuildConfig(array(), $url_modules); $this->previous_steps['prefs']['url_aliases'] = array(); $this->previous_steps['prefs']['url_config'] = $url_config; $this->previous_steps['prefs']['url_modules'] = $url_modules; $this->previous_steps['prefs']['url_locations'] = $url_locations; eRouter::clearCache(); $this->logLine('Core URL config set to default state'); // Set prefs, save e107::getConfig('core')->setPref($this->previous_steps['prefs']); e107::getConfig('core')->save(FALSE, TRUE); // save preferences made during install. $this->logLine('Core prefs set to install choices'); // Create the admin user - replacing any that may be been included in the XML. $ip = $_SERVER['REMOTE_ADDR']; $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '" . md5($this->previous_steps['admin']['password']) . "', '', '{$this->previous_steps['admin']['email']}', '', '', 0, " . time() . ", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', " . time() . ", ''"; $qry = "REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})"; $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})"); $this->logLine('Admin user created'); mysql_close($this->dbLink); return false; }
/** * Rebuild URL configuration values * Note - new core system pref values will be set, but not saved * e107::getConfig()->save() is required outside after execution of this method * @return void */ public function rebuildUrlConfig() { $modules = eRouter::adminReadModules(); // get all available locations, non installed plugins will be ignored $config = eRouter::adminBuildConfig(e107::getPref('url_config'), $modules); // merge with current config $locations = eRouter::adminBuildLocations($modules); // rebuild locations pref $aliases = eRouter::adminSyncAliases(e107::getPref('url_aliases'), $config); // rebuild aliases // set new values, changes should be saved outside this methods e107::getConfig()->set('url_aliases', $aliases)->set('url_config', $config)->set('url_modules', $modules)->set('url_locations', $locations); eRouter::clearCache(); }