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 Box_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' => BB_PATH_INSTALL, 'cron_path' => BB_PATH_CRON, 'config_file_path' => BB_PATH_CONFIG, 'live_site' => BB_URL, 'admin_site' => BB_URL_ADMIN, 'domain' => pathinfo(BB_URL, PATHINFO_BASENAME)); print $this->render('install.phtml', $vars); break; } }
}; $di['server_package'] = function () use($di) { return new Server_Package(); }; $di['server_client'] = function () use($di) { return new Server_Client(); }; $di['server_account'] = function () use($di) { return new Server_Account(); }; $di['server_manager'] = $di->protect(function ($manager, $config) use($di) { $class = sprintf('Server_Manager_%s', ucfirst($manager)); return new $class($config); }); $di['requirements'] = function () use($di) { $r = new Box_Requirements(); $r->setDi($di); return $r; }; $di['period'] = $di->protect(function ($code) use($di) { return new \Box_Period($code); }); $di['theme'] = function () use($di) { $service = $di['mod_service']('theme'); return $service->getCurrentClientAreaTheme(); }; $di['cart'] = function () use($di) { $service = $di['mod_service']('cart'); return $service->getSessionCart(); }; $di['table'] = $di->protect(function ($name) use($di) {