/** * 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); }
/** * htaccess_rewrite * * Rewrite the htaccess file, with support for * plugin access. * * @access public * @return bool */ function htaccess_rewrite() { global $SETTINGS; require_once HOME . '_inc/function/defaults.php'; $Plugins = Plugins::getInstance(); /** * if the apache_get_modules function is * available, make sure that the apache * rewrite module is loaded */ if (function_exists('apache_get_modules')) { $modules = apache_get_modules(); if (!in_array('mod_rewrite', $modules)) { error('The apache module mod_rewrite must be installed. Please visit <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">' . 'Apache Module mod_rewrite</a> for more details.', 'Apache Error'); } } /** * build up array of rewrite rules and filter * through the plugin filter */ $rules = defaults_htaccess_rules(SITE_URL); $rules = $Plugins->filter('general', 'filter_htaccess', $rules); $htaccess = defaults_htaccess_content($rules); /** * write htaccess file or throw error */ file_put_contents(HOME . '.htaccess', $htaccess) 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'); if ($SETTINGS['index'] == 0) { $robots = defaults_robots_content(0, SITE_URL); $robots = $Plugins->filter('general', 'filter_robots', $robots); } else { $robots = defaults_robots_content(1, SITE_URL); $file = HOME . 'sitemap.xml'; if (file_exists($file)) { unlink($file); } } /** * write robots.txt or throw error */ file_put_contents(HOME . 'robots.txt', $robots); return true; }