public function run($action) { switch ($action) { case 'check-db': $user = $_POST['db_user']; $host = $_POST['db_host']; $pass = $_POST['db_pass']; $name = $_POST['db_name']; if (!$this->canConnectToDatabase($host, $name, $user, $pass)) { print 'Could not connect to database. Please check database details.'; } else { $this->session->set('db_host', $host); $this->session->set('db_name', $name); $this->session->set('db_user', $user); $this->session->set('db_pass', $pass); print 'ok'; } break; case 'install': try { //db $user = $_POST['db_user']; $host = $_POST['db_host']; $pass = $_POST['db_pass']; $name = $_POST['db_name']; if (!$this->canConnectToDatabase($host, $name, $user, $pass)) { throw new Exception('Could not connect to database or database does not exist'); } else { $this->session->set('db_host', $host); $this->session->set('db_name', $name); $this->session->set('db_user', $user); $this->session->set('db_pass', $pass); } // admin config $admin_email = $_POST['admin_email']; $admin_pass = $_POST['admin_pass']; $admin_name = $_POST['admin_name']; if (!$this->isValidAdmin($admin_email, $admin_pass, $admin_name)) { throw new Exception('Administrators account is not valid'); } else { $this->session->set('admin_email', $admin_email); $this->session->set('admin_pass', $admin_pass); $this->session->set('admin_name', $admin_name); } //license $license = $_POST['license']; if (!$this->isValidLicense($license)) { throw new Exception('License Key is not valid'); } else { $this->session->set('license', $license); } $this->makeInstall($this->session); $this->generateEmailTemplates(); session_destroy(); print 'ok'; } catch (Exception $e) { print $e->getMessage(); } break; case 'index': default: $this->session->set('agree', true); $se = new Fuse_Requirements(); $options = $se->getOptions(); $vars = array('tos' => $this->getLicense(), 'folders' => $se->folders(), 'files' => $se->files(), 'os' => PHP_OS, 'os_ok' => true, 'php_ver' => $options['php']['version'], 'php_ver_req' => $options['php']['min_version'], 'php_safe_mode' => $options['php']['safe_mode'], 'php_ver_ok' => $se->isPhpVersionOk(), 'extensions' => $se->extensions(), 'all_ok' => $se->canInstall(), 'db_host' => $this->session->get('db_host'), 'db_name' => $this->session->get('db_name'), 'db_user' => $this->session->get('db_user'), 'db_pass' => $this->session->get('db_pass'), 'admin_email' => $this->session->get('admin_email'), 'admin_pass' => $this->session->get('admin_pass'), 'admin_name' => $this->session->get('admin_name'), 'license' => $this->session->get('license'), 'agree' => $this->session->get('agree'), 'install_module_path' => BF_PATH_INSTALL, 'cron_path' => BF_PATH_CRON, 'config_file_path' => BF_PATH_CONFIG, 'live_site' => BF_URL, 'admin_site' => BF_URL_ADMIN, 'domain' => pathinfo(BF_URL, PATHINFO_BASENAME)); print $this->render('install.phtml', $vars); break; } }