public function execute(HTTPRequestCustom $request)
 {
     parent::load_lang($request);
     $this->build_form();
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $login = $this->form->get_value('email');
         if ($this->form->get_value('custom_login', false)) {
             $login = $this->form->get_value('login');
         }
         $installation_services = new InstallationServices();
         $installation_services->create_admin($login, $this->form->get_value('password'), $this->form->get_value('email'), $this->form->get_value('createSession'), $this->form->get_value('autoconnect'));
         HtaccessFileCache::regenerate();
         AppContext::get_response()->redirect(InstallUrlBuilder::finish());
     }
     return $this->create_response();
 }
 protected function load_lang(HTTPRequestCustom $request)
 {
     $locale = TextHelper::htmlspecialchars($request->get_string('lang', self::DEFAULT_LOCALE));
     $locale = in_array($locale, InstallationServices::get_available_langs()) ? $locale : self::DEFAULT_LOCALE;
     LangLoader::set_locale($locale);
     InstallUrlBuilder::set_locale($locale);
     $this->lang = LangLoader::get('install', 'install');
 }
 private function create_phpboost_tables()
 {
     AppContext::get_cache_service()->clear_cache();
     try {
         $this->installation->create_phpboost_tables(DBFactory::MYSQL, $this->db_host, $this->db_port, $this->db_schema, $this->db_user, $this->db_password, $this->db_tables_prefix);
         return true;
     } catch (UnexistingDatabaseException $exception) {
         CLIOutput::writeln('Database ' . $this->db_schema . ' does not exist and attempt to create it failed. Create it and relaunch the installation');
     } catch (DBConnectionException $exception) {
         CLIOutput::writeln('Connection to database failed, check your connection parameters');
     } catch (IOException $exception) {
         CLIOutput::writeln('Can\'t write database configuration file informations to /kernel/db/config.php. ' . 'Check file or parent directory permissions.');
     }
     return false;
 }
 private function add_language_bar()
 {
     $lang = TextHelper::htmlspecialchars(AppContext::get_request()->get_string('lang', InstallController::DEFAULT_LOCALE));
     $lang = in_array($lang, InstallationServices::get_available_langs()) ? $lang : InstallController::DEFAULT_LOCALE;
     $lang_dir = new Folder(PATH_TO_ROOT . '/lang');
     $langs = array();
     foreach ($lang_dir->get_folders('`^[a-z_-]+$`i') as $folder) {
         $info_lang = load_ini_file(PATH_TO_ROOT . '/lang/', $folder->get_name());
         if (!empty($info_lang['name'])) {
             $langs[] = array('LANG' => $folder->get_name(), 'LANG_NAME' => $info_lang['name'], 'SELECTED' => $folder->get_name() == $lang ? 'selected="selected"' : '');
             if ($folder->get_name() == $lang) {
                 $this->full_view->put('LANG_IDENTIFIER', $info_lang['identifier']);
             }
         }
     }
     $this->full_view->put('lang', $langs);
 }
 private function handle_form()
 {
     $installation_services = new InstallationServices();
     $installation_services->configure_website($this->form->get_value('host'), $this->form->get_value('path'), $this->form->get_value('name'), $this->form->get_value('slogan'), $this->form->get_value('description'), $this->form->get_value('timezone')->get_raw_value());
     $this->security_config->set_internal_password_min_length($this->form->get_value('internal_password_min_length'));
     $this->security_config->set_internal_password_strength($this->form->get_value('internal_password_strength')->get_raw_value());
     if ($this->form->get_value('login_and_email_forbidden_in_password')) {
         $this->security_config->forbid_login_and_email_in_password();
     } else {
         $this->security_config->allow_login_and_email_in_password();
     }
     SecurityConfig::save();
     if ($this->server_configuration->has_curl_library()) {
         if ($this->form->get_value('fb_auth_enabled')) {
             $this->authentication_config->enable_fb_auth();
             $this->authentication_config->set_fb_app_id($this->form->get_value('fb_app_id'));
             $this->authentication_config->set_fb_app_key($this->form->get_value('fb_app_key'));
         } else {
             $this->authentication_config->disable_fb_auth();
         }
         if ($this->form->get_value('google_auth_enabled')) {
             $this->authentication_config->enable_google_auth();
             $this->authentication_config->set_google_client_id($this->form->get_value('google_client_id'));
             $this->authentication_config->set_google_client_secret($this->form->get_value('google_client_secret'));
         } else {
             $this->authentication_config->disable_google_auth();
         }
         AuthenticationConfig::save();
     }
     AppContext::get_response()->redirect(InstallUrlBuilder::admin());
 }
 private function create_tables(InstallationServices $service, $host, $port, $login, $password, $schema, $tables_prefix)
 {
     if (!$service->is_already_installed() || !$this->overwrite_field->is_disabled() && $this->overwrite_field->is_checked()) {
         PersistenceContext::close_db_connection();
         $service->create_phpboost_tables(DBFactory::MYSQL, $host, $port, $schema, $login, $password, $tables_prefix);
         AppContext::get_response()->redirect(InstallUrlBuilder::website());
     } else {
         $this->overwrite_fieldset->enable();
         $this->error = $this->lang['phpboost.alreadyInstalled.explanation'];
     }
 }