/**
  * This listener is run when the KernelEvents::EXCEPTION event is triggered
  *
  * @param GetResponseForExceptionEvent	$event
  */
 public function on_kernel_exception(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $message = $exception->getMessage();
     if ($exception instanceof exception_interface) {
         $message = $this->language->lang_array($message, $exception->get_parameters());
     }
     if (!$event->getRequest()->isXmlHttpRequest()) {
         $this->template->assign_vars(array('TITLE' => $this->language->lang('INFORMATION'), 'BODY' => $message));
         $response = $this->controller_helper->render('installer_main.html', $this->language->lang('INFORMATION'), false, 500);
     } else {
         $data = array();
         if (!empty($message)) {
             $data['message'] = $message;
         }
         if (defined('DEBUG')) {
             $data['trace'] = $exception->getTrace();
         }
         $response = new JsonResponse($data, 500);
     }
     if ($exception instanceof HttpExceptionInterface) {
         $response->setStatusCode($exception->getStatusCode());
         $response->headers->add($exception->getHeaders());
     }
     $event->setResponse($response);
 }
Ejemplo n.º 2
0
 /**
  * Render the list of available convertors
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function render_convert_list()
 {
     $this->template->assign_vars(array('TITLE' => $this->language->lang('CONVERT_INTRO'), 'BODY' => $this->language->lang('CONVERT_INTRO_BODY'), 'S_LIST' => true));
     $convertors = $sort = array();
     $get_info = true;
     // Global flag
     $handle = @opendir($this->phpbb_root_path . 'install/convertors/');
     if (!$handle) {
         die('Unable to access the convertors directory');
     }
     while ($entry = readdir($handle)) {
         if (preg_match('/^convert_([a-z0-9_]+).' . $this->php_ext . '$/i', $entry, $m)) {
             $phpbb_root_path = $this->phpbb_root_path;
             // These globals are required
             $phpEx = $this->php_ext;
             // See above
             include_once $this->phpbb_root_path . 'install/convertors/' . $entry;
             if (isset($convertor_data)) {
                 $sort[strtolower($convertor_data['forum_name'])] = sizeof($convertors);
                 $convertors[] = array('tag' => $m[1], 'forum_name' => $convertor_data['forum_name'], 'version' => $convertor_data['version'], 'dbms' => $convertor_data['dbms'], 'dbhost' => $convertor_data['dbhost'], 'dbport' => $convertor_data['dbport'], 'dbuser' => $convertor_data['dbuser'], 'dbpasswd' => $convertor_data['dbpasswd'], 'dbname' => $convertor_data['dbname'], 'table_prefix' => $convertor_data['table_prefix'], 'author' => $convertor_data['author']);
             }
             unset($convertor_data);
         }
     }
     closedir($handle);
     @ksort($sort);
     foreach ($sort as $void => $index) {
         $this->template->assign_block_vars('convertors', array('AUTHOR' => $convertors[$index]['author'], 'SOFTWARE' => $convertors[$index]['forum_name'], 'VERSION' => $convertors[$index]['version'], 'U_CONVERT' => $this->controller_helper->route('phpbb_convert_settings', array('convertor' => $convertors[$index]['tag']))));
     }
     return $this->controller_helper->render('installer_convert.html', 'SUB_INTRO', true);
 }
Ejemplo n.º 3
0
	/**
	 * Finish conversion, the last function to be called.
	 */
	function finish_conversion()
	{
		global $db, $phpbb_root_path, $phpEx, $convert, $config, $language, $user;
		global $cache, $auth, $phpbb_container, $phpbb_log;

		include_once ($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

		$db->sql_query('DELETE FROM ' . CONFIG_TABLE . "
			WHERE config_name = 'convert_progress'
				OR config_name = 'convert_options'
				OR config_name = 'convert_db_server'
				OR config_name = 'convert_db_user'");
		$db->sql_query('DELETE FROM ' . SESSIONS_TABLE);

		@unlink($phpbb_container->getParameter('core.cache_dir') . 'data_global.' . $phpEx);
		phpbb_cache_moderators($db, $cache, $auth);

		// And finally, add a note to the log
		$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_INSTALL_CONVERTED', false, array($convert->convertor_data['forum_name'], $config['version']));

		$url = $this->controller_helper->route('phpbb_convert_finish');

		$this->template->assign_vars(array(
			'L_SUBMIT'		=> $user->lang['FINAL_STEP'],
			'U_ACTION'		=> $url,
		));

		$this->meta_refresh($url);
		return;
	}
Ejemplo n.º 4
0
 /**
  * Controller logic
  *
  * @return Response|StreamedResponse
  */
 public function handle()
 {
     if ($this->install_helper->is_phpbb_installed()) {
         die('phpBB is already installed');
     }
     $this->template->assign_vars(array('U_ACTION' => $this->controller_helper->route('phpbb_installer_install')));
     // Set up input-output handler
     if ($this->request->is_ajax()) {
         $this->iohandler_factory->set_environment('ajax');
     } else {
         $this->iohandler_factory->set_environment('nojs');
     }
     // Set the appropriate input-output handler
     $this->installer->set_iohandler($this->iohandler_factory->get());
     // Set up navigation
     $nav_data = $this->installer_config->get_navigation_data();
     /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
     $iohandler = $this->iohandler_factory->get();
     // Set active navigation stage
     if (isset($nav_data['active']) && is_array($nav_data['active'])) {
         $iohandler->set_active_stage_menu($nav_data['active']);
         $this->menu_provider->set_nav_property($nav_data['active'], array('selected' => true, 'completed' => false));
     }
     // Set finished navigation stages
     if (isset($nav_data['finished']) && is_array($nav_data['finished'])) {
         foreach ($nav_data['finished'] as $finished_stage) {
             $iohandler->set_finished_stage_menu($finished_stage);
             $this->menu_provider->set_nav_property($finished_stage, array('selected' => false, 'completed' => true));
         }
     }
     if ($this->request->is_ajax()) {
         $installer = $this->installer;
         $response = new StreamedResponse();
         $response->setCallback(function () use($installer) {
             $installer->run();
         });
         // Try to bypass any server output buffers
         $response->headers->set('X-Accel-Buffering', 'no');
         return $response;
     } else {
         // Determine whether the installation was started or not
         if (true) {
             $this->controller_helper->handle_language_select();
             // Set active stage
             $this->menu_provider->set_nav_property(array('install', 0, 'introduction'), array('selected' => true, 'completed' => false));
             // If not, let's render the welcome page
             $this->template->assign_vars(array('SHOW_INSTALL_START_FORM' => true, 'TITLE' => $this->language->lang('INSTALL_INTRO'), 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY')));
             return $this->controller_helper->render('installer_install.html', 'INSTALL', true);
         }
         // @todo: implement no js controller logic
     }
 }
Ejemplo n.º 5
0
 /**
  * Controller entry point
  *
  * @return Response|StreamedResponse
  *
  * @throws http_exception When phpBB is not installed
  */
 public function handle()
 {
     if (!$this->install_helper->is_phpbb_installed()) {
         throw new http_exception(403, 'INSTALL_PHPBB_NOT_INSTALLED');
     }
     $this->template->assign_vars(array('U_ACTION' => $this->controller_helper->route('phpbb_installer_update')));
     // Set up input-output handler
     if ($this->request->is_ajax()) {
         $this->iohandler_factory->set_environment('ajax');
     } else {
         $this->iohandler_factory->set_environment('nojs');
     }
     // Set the appropriate input-output handler
     $this->installer->set_iohandler($this->iohandler_factory->get());
     $this->controller_helper->handle_language_select();
     // Render the intro page
     if ($this->request->is_ajax()) {
         $installer = $this->installer;
         $response = new StreamedResponse();
         $response->setCallback(function () use($installer) {
             $installer->run();
         });
         // Try to bypass any server output buffers
         $response->headers->set('X-Accel-Buffering', 'no');
         $response->headers->set('Content-type', 'application/json');
         return $response;
     } else {
         // Set active stage
         $this->menu_provider->set_nav_property(array('update', 0, 'introduction'), array('selected' => true, 'completed' => false));
         $this->template->assign_vars(array('SHOW_INSTALL_START_FORM' => true, 'TITLE' => $this->language->lang('UPDATE_INSTALLATION'), 'CONTENT' => $this->language->lang('UPDATE_INSTALLATION_EXPLAIN')));
         /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
         $iohandler = $this->iohandler_factory->get();
         $this->controller_helper->handle_navigation($iohandler);
         return $this->controller_helper->render('installer_update.html', 'UPDATE_INSTALLATION', true);
     }
 }