$robots_follow = NULL; $content_type_header = NULL; /** * Default 200 = success */ $http_response_code = 200; /** * @global array IDs of featured posts that are being displayed -- needed so we can filter it out of normal post flow */ $featured_displayed_item_IDs = array(); // Initialize some variables for template functions $required_js = array(); $required_css = array(); $headlines = array(); // ############ Get ReqPath & ReqURI ############## list($ReqPath, $ReqURI) = get_ReqURI(); /** * Full requested Host (including protocol). * * {@internal Note: on IIS you can receive 'off' in the HTTPS field!! :[ }} * * @global string */ $ReqHost = ''; if (!empty($_SERVER['HTTP_HOST'])) { $ReqHost = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']; } $ReqURL = $ReqHost . $ReqURI; $Debuglog->add('vars: $ReqHost: ' . $ReqHost, 'request'); $Debuglog->add('vars: $ReqURI: ' . $ReqURI, 'request'); $Debuglog->add('vars: $ReqPath: ' . $ReqPath, 'request');
/** * Check request for quick installation * Update basic config file from url params * * @return boolean|string TRUE on success, OR error messages */ function check_quick_install_request() { global $config_is_done, $db_config, $install_login, $install_password, $Messages; $admin_login = param('admin_login', 'string', ''); $admin_password = param('admin_password', 'string', ''); if (!empty($admin_login)) { // Try to use an admin login from request: if (param_check_valid_login('admin_login')) { // We can use this login name $install_login = $admin_login; } else { // Display an error message for impossible login name: $Messages->add(sprintf('ERROR: Impossible to use "%s" for the admin account. Using "admin" instead.', $admin_login)); } } if (!empty($admin_password) && param_check_passwords('admin_password', 'admin_password', false, 5)) { // Set admin password from request: $install_password = $admin_password; } if ($config_is_done) { // Config is already done, Don't use url params to update basic config file return true; } // DB Access: $db_user = param('db_user', 'string', ''); $db_password = param('db_password', 'raw', ''); $db_name = param('db_name', 'string', ''); $db_host = param('db_host', 'string', ''); $db_tableprefix = param('db_tableprefix', 'string', ''); // Admin e-mail: global $admin_email; $default_admin_email = $admin_email; $conf_admin_email = param('admin_email', 'string', '', false, true); if (!empty($conf_admin_email) || !empty($db_user) || !empty($db_password) || !empty($db_name) || !empty($db_host) || !empty($db_tableprefix)) { // Try to update basic config file ONLY when at least one of these params are defined if (empty($conf_admin_email) || !param_check_email('admin_email')) { // Use default admin email if it is empty from request $conf_admin_email = $default_admin_email; } // Base URL: global $baseurl, $admin_url, $dispatcher, $tableprefix; $baseurl = param('baseurl', 'string', '', false, true); if (empty($baseurl) || !preg_match('~https?://~', $baseurl)) { // Try to autogenerate base url if it is empty or wrong from request: $baseurl = 'http://' . (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'yourserver.com'); if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80') { $baseurl .= ':' . $_SERVER['SERVER_PORT']; } list($ReqPath, $ReqURI) = get_ReqURI(); $baseurl .= preg_replace('#/install(/(index.php)?)?$#', '', $ReqPath) . '/'; } // Add a slash at the end if it is missed: $baseurl = trim($baseurl, '/') . '/'; // Update $admin_url to new value because it depends on $baseurl: $admin_url = $baseurl . $dispatcher; // Update $tableprefix to new from request: $tableprefix = $db_tableprefix; // Try to create basic config file: $basic_config_params = array('db_user' => $db_user, 'db_password' => $db_password, 'db_name' => $db_name, 'db_host' => $db_host, 'db_tableprefix' => $db_tableprefix, 'baseurl' => $baseurl, 'admin_email' => $conf_admin_email, 'print_messages' => false, 'quick_install' => true); if (update_basic_config_file($basic_config_params)) { // Basic config file has been created successfully // Update DB config to connect to DB correctly $db_config['user'] = $db_user; $db_config['password'] = $db_password; $db_config['name'] = $db_name; $db_config['host'] = $db_host; } else { // Failed on createing of basic config file return false; } } // Revert config admin email to original value: $admin_email = $default_admin_email; return true; }