/** * install_settings * * formats the information collected in the install * stages and outputs it to the .settings.php file * this function also creates the .htaccess and * robots.txt files * * @return void */ function install_settings() { global $constants; global $settings; $prefix = $_SESSION['db']['prefix']; // constants for .settings.php $constants = array('DB_PAGES' => $prefix . 'pages', 'DB_USERS' => $prefix . 'users', 'DB_TRASH' => $prefix . 'trash', 'DB_GROUPS' => $prefix . 'groups', 'DB_USERS_GROUPS' => $prefix . 'users_groups', 'DB_OPTIONS' => $prefix . 'options', 'DB_FILES' => $prefix . 'files', 'TEMPLATE_DIR' => HOME . '_www/vitruvius/', 'DB_PREFIX' => $prefix, 'VERSION' => '0.9.2', 'SITE_URL' => $_SESSION['settings']['site_url'], 'USERS_DIR' => $_SESSION['settings']['user_files'], 'DIAGNOSTIC_MODE' => 0, 'LANG' => 'English', 'SET_REVISION' => 100); $constants = defaults_constants($constants); // no plugins installed by default $plugins = array(); /* * settings array for .settings.php */ $settings = array('site_title' => addslashes($_SESSION['settings']['title']), 'site_subtitle' => addslashes($_SESSION['settings']['sub_title']), 'index' => (int) $_SESSION['settings']['index'], 'maintenance' => $_SESSION['settings']['maintenance'], 'system_alert' => ''); $db = array('name' => addslashes($_SESSION['db']['name']), 'host' => addslashes($_SESSION['db']['host']), 'user' => addslashes($_SESSION['db']['user']), 'pass' => addslashes($_SESSION['db']['pass'])); $filecontents = defaults_settings_content($settings, $db, $plugins, $constants); /** * write settings file */ file_put_contents(HOME . '.settings.php', $filecontents) or error('Please grant <i>0777</i> write access to the <i>' . HOME . '</i> directory then reload this page to complete installation.'); /** * create htaccess file */ $rules = defaults_htaccess_rules($_SESSION['settings']['site_url']); $htaccess = defaults_htaccess_content($rules); file_put_contents(HOME . '.htaccess', $htaccess); /** * create robots file */ $robots = defaults_robots_content($settings['index'], $_SESSION['settings']['site_url']); file_put_contents(HOME . 'robots.txt', $robots); return array($settings, $constants); }
/** * settings_rewrite * * Used to change any of the variables written in the * settings.php file, executes htaccess_rewrite also as * it is possible within settings_rewrite that the active * plugins are changed. * * @param mixed $SETTINGS * @param mixed $DB * @param mixed $PLUGINS * @param mixed $constants optional * @access public * @return void */ function settings_rewrite($SETTINGS, $DB, $PLUGINS, $constants = array()) { require_once HOME . '_inc/function/defaults.php'; $constants = defaults_constants($constants); $Plugins = Plugins::getInstance(); /** * calculate plugin dependencies */ $plugins = array(); foreach ($PLUGINS as $p_name => $version) { $plugin = $Plugins->plugins($p_name); if (!$plugin) { require HOME . '_plugins/' . $p_name . '/plugin.php'; } array_push($plugins, array('sys_name' => $p_name, 'name' => $plugin['name'], 'version' => $plugin['version'], 'dependencies' => @$plugin['dependencies'])); } $PLUGINS = resolve_dependencies($plugins, $PLUGINS); /** * plugins - filter the settings, constants and plugins arrays */ list($SETTINGS, $constants, $PLUGINS) = $Plugins->filter('general', 'filter_settings', array($SETTINGS, $constants, $PLUGINS)); $filecontents = defaults_settings_content($SETTINGS, $DB, $PLUGINS, $constants); /** * write file or throw error */ file_put_contents(HOME . '.settings.php', $filecontents) or error('You must grant <i>0777</i> write access to the <i>' . HOME . '</i> directory for <a href="http://furasta.org">Furasta.Org</a> to function correctly.' . 'Please do so then reload this page to save the settings.', 'Runtime Error'); return htaccess_rewrite(); }