public function ajax_db_check() { if (request::is_ajax()) { $this->auto_render = FALSE; } else { return Event::run('system.404'); } $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $host = isset($_POST['host']) ? $_POST['host'] : ''; $database = isset($_POST['database']) ? $_POST['database'] : ''; $prefix = isset($_POST['prefix']) ? $_POST['prefix'] : ''; Session::instance()->delete('conn_status'); try { setup::check_db($username, $password, $host, $database, $prefix); Session::instance()->set('conn_status', 'pass'); echo __('true:Connection was successful and database was created'); } catch (Exception $e) { $error = $e->getMessage(); switch ($error) { case 'access': echo __('Wrong username or password.'); break; case 'unknown_host': echo __('Could not find the host.'); break; case 'connect_to_host': echo __('Could not connect to host.'); break; case 'create': echo __('Could not create the database.'); break; case 'select': echo __('Could not select the database.'); break; case 'prefix': echo __('The Table Prefix you chose is already in use.'); break; default: echo $error; } } }