/** * {@inheritdoc} */ public function run() { $cookie_secure = $this->io_handler->is_secure(); $server_protocol = $this->io_handler->is_secure() ? 'https://' : 'http://'; $server_port = $this->io_handler->get_server_variable('SERVER_PORT', 0); // HTTP_HOST is having the correct browser url in most cases... $server_name = strtolower(htmlspecialchars_decode($this->io_handler->get_header_variable('Host', $this->io_handler->get_server_variable('SERVER_NAME')))); // HTTP HOST can carry a port number... if (strpos($server_name, ':') !== false) { $server_name = substr($server_name, 0, strpos($server_name, ':')); } $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('PHP_SELF')); if (!$script_path) { $script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('REQUEST_URI')); } $script_path = str_replace(array('\\', '//'), '/', $script_path); $script_path = trim(dirname(dirname(dirname($script_path)))); // Because we are in install/app.php/route_name // Server data $cookie_secure = $this->io_handler->get_input('cookie_secure', $cookie_secure); $server_protocol = $this->io_handler->get_input('server_protocol', $server_protocol); $force_server_vars = $this->io_handler->get_input('force_server_vars', 0); $server_name = $this->io_handler->get_input('server_name', $server_name); $server_port = $this->io_handler->get_input('server_port', $server_port); $script_path = $this->io_handler->get_input('script_path', $script_path); // Clean up script path if ($script_path !== '/') { // Adjust destination path (no trailing slash) if (substr($script_path, -1) === '/') { $script_path = substr($script_path, 0, -1); } $script_path = str_replace(array('../', './'), '', $script_path); if ($script_path[0] !== '/') { $script_path = '/' . $script_path; } } // Check if data is sent if ($this->io_handler->get_input('submit_server', false)) { $this->install_config->set('cookie_secure', $cookie_secure); $this->install_config->set('server_protocol', $server_protocol); $this->install_config->set('force_server_vars', $force_server_vars); $this->install_config->set('server_name', $server_name); $this->install_config->set('server_port', $server_port); $this->install_config->set('script_path', $script_path); } else { // Render form $server_form = array('cookie_secure' => array('label' => 'COOKIE_SECURE', 'description' => 'COOKIE_SECURE_EXPLAIN', 'type' => 'radio', 'options' => array(array('value' => 0, 'label' => 'NO', 'selected' => !$cookie_secure), array('value' => 1, 'label' => 'YES', 'selected' => $cookie_secure))), 'force_server_vars' => array('label' => 'FORCE_SERVER_VARS', 'description' => 'FORCE_SERVER_VARS_EXPLAIN', 'type' => 'radio', 'options' => array(array('value' => 0, 'label' => 'NO', 'selected' => true), array('value' => 1, 'label' => 'YES', 'selected' => false))), 'server_protocol' => array('label' => 'SERVER_PROTOCOL', 'description' => 'SERVER_PROTOCOL_EXPLAIN', 'type' => 'text', 'default' => $server_protocol), 'server_name' => array('label' => 'SERVER_NAME', 'description' => 'SERVER_NAME_EXPLAIN', 'type' => 'text', 'default' => $server_name), 'server_port' => array('label' => 'SERVER_PORT', 'description' => 'SERVER_PORT_EXPLAIN', 'type' => 'text', 'default' => $server_port), 'script_path' => array('label' => 'SCRIPT_PATH', 'description' => 'SCRIPT_PATH_EXPLAIN', 'type' => 'text', 'default' => $script_path), 'submit_server' => array('label' => 'SUBMIT', 'type' => 'submit')); $this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form); $this->io_handler->send_response(); throw new user_interaction_required_exception(); } }