PDF rausgenommen
This commit is contained in:
93
msd2/phpBB3/phpbb/install/controller/archive_download.php
Normal file
93
msd2/phpBB3/phpbb/install/controller/archive_download.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\exception\http_exception;
|
||||
use phpbb\install\helper\config;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||
|
||||
class archive_download
|
||||
{
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
*/
|
||||
public function __construct(config $config)
|
||||
{
|
||||
$this->installer_config = $config;
|
||||
$this->installer_config->load_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends response with the merge conflict archive
|
||||
*
|
||||
* Merge conflicts always have to be resolved manually,
|
||||
* so we use a different archive for that.
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function conflict_archive()
|
||||
{
|
||||
$filename = $this->installer_config->get('update_file_conflict_archive', '');
|
||||
|
||||
if (empty($filename))
|
||||
{
|
||||
throw new http_exception(404, 'URL_NOT_FOUND');
|
||||
}
|
||||
|
||||
return $this->send_response($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends response with the updated files' archive
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function update_archive()
|
||||
{
|
||||
$filename = $this->installer_config->get('update_file_archive', '');
|
||||
|
||||
if (empty($filename))
|
||||
{
|
||||
throw new http_exception(404, 'URL_NOT_FOUND');
|
||||
}
|
||||
|
||||
return $this->send_response($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a download response
|
||||
*
|
||||
* @param string $filename Path to the file to download
|
||||
*
|
||||
* @return BinaryFileResponse Response object
|
||||
*/
|
||||
private function send_response($filename)
|
||||
{
|
||||
$response = new BinaryFileResponse($filename);
|
||||
$response->setContentDisposition(
|
||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||
basename($filename)
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
413
msd2/phpBB3/phpbb/install/controller/helper.php
Normal file
413
msd2/phpBB3/phpbb/install/controller/helper.php
Normal file
@ -0,0 +1,413 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use phpbb\language\language;
|
||||
use phpbb\language\language_file_helper;
|
||||
use phpbb\path_helper;
|
||||
use phpbb\request\request;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\routing\router;
|
||||
use phpbb\symfony_request;
|
||||
use phpbb\template\template;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
/**
|
||||
* A duplicate of \phpbb\controller\helper
|
||||
*
|
||||
* This class is necessary because of controller\helper's legacy function calls
|
||||
* to page_header() page_footer() functions which has unavailable dependencies.
|
||||
*/
|
||||
class helper
|
||||
{
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var bool|string
|
||||
*/
|
||||
protected $language_cookie;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language_file_helper
|
||||
*/
|
||||
protected $lang_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\navigation\navigation_provider
|
||||
*/
|
||||
protected $navigation_provider;
|
||||
|
||||
/**
|
||||
* @var \phpbb\template\template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var \phpbb\path_helper
|
||||
*/
|
||||
protected $path_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\request\request
|
||||
*/
|
||||
protected $phpbb_request;
|
||||
|
||||
/**
|
||||
* @var \phpbb\symfony_request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var \phpbb\routing\router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_admin_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
* @param language $language
|
||||
* @param language_file_helper $lang_helper
|
||||
* @param navigation_provider $nav
|
||||
* @param template $template
|
||||
* @param path_helper $path_helper
|
||||
* @param request $phpbb_request
|
||||
* @param symfony_request $request
|
||||
* @param router $router
|
||||
* @param string $phpbb_root_path
|
||||
*/
|
||||
public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path)
|
||||
{
|
||||
$this->installer_config = $config;
|
||||
$this->language = $language;
|
||||
$this->language_cookie = false;
|
||||
$this->lang_helper = $lang_helper;
|
||||
$this->navigation_provider = $nav;
|
||||
$this->template = $template;
|
||||
$this->path_helper = $path_helper;
|
||||
$this->phpbb_request = $phpbb_request;
|
||||
$this->request = $request;
|
||||
$this->router = $router;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpbb_admin_path = $phpbb_root_path . 'adm/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Automate setting up the page and creating the response object.
|
||||
*
|
||||
* @param string $template_file The template handle to render
|
||||
* @param string $page_title The title of the page to output
|
||||
* @param bool $selected_language True to enable language selector it, false otherwise
|
||||
* @param int $status_code The status code to be sent to the page header
|
||||
*
|
||||
* @return Response object containing rendered page
|
||||
*/
|
||||
public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200)
|
||||
{
|
||||
$this->page_header($page_title, $selected_language);
|
||||
|
||||
$this->template->set_filenames(array(
|
||||
'body' => $template_file,
|
||||
));
|
||||
|
||||
$response = new Response($this->template->assign_display('body'), $status_code);
|
||||
|
||||
// Set language cookie
|
||||
if ($this->language_cookie !== false)
|
||||
{
|
||||
$cookie = new Cookie('lang', $this->language_cookie, time() + 3600);
|
||||
$response->headers->setCookie($cookie);
|
||||
|
||||
$this->language_cookie = false;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns path from route name
|
||||
*
|
||||
* @param string $route_name
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function route($route_name, $parameters = array())
|
||||
{
|
||||
$url = $this->router->generate($route_name, $parameters);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles language selector form
|
||||
*/
|
||||
public function handle_language_select()
|
||||
{
|
||||
$lang = null;
|
||||
|
||||
// Check if language form has been submited
|
||||
$submit = $this->phpbb_request->variable('change_lang', '');
|
||||
if (!empty($submit))
|
||||
{
|
||||
$lang = $this->phpbb_request->variable('language', '');
|
||||
}
|
||||
|
||||
// Retrieve language from cookie
|
||||
$lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE);
|
||||
if (empty($lang) && !empty($lang_cookie))
|
||||
{
|
||||
$lang = $lang_cookie;
|
||||
}
|
||||
|
||||
$lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null;
|
||||
$this->language_cookie = $lang;
|
||||
|
||||
$this->render_language_select($lang);
|
||||
|
||||
if ($lang !== null)
|
||||
{
|
||||
$this->language->set_user_language($lang, true);
|
||||
$this->installer_config->set('user_language', $lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process navigation data to reflect active/completed stages
|
||||
*
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler
|
||||
*/
|
||||
public function handle_navigation($iohandler = null)
|
||||
{
|
||||
$nav_data = $this->installer_config->get_navigation_data();
|
||||
|
||||
// Set active navigation stage
|
||||
if (isset($nav_data['active']) && is_array($nav_data['active']))
|
||||
{
|
||||
if ($iohandler !== null)
|
||||
{
|
||||
$iohandler->set_active_stage_menu($nav_data['active']);
|
||||
}
|
||||
|
||||
$this->navigation_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)
|
||||
{
|
||||
if ($iohandler !== null)
|
||||
{
|
||||
$iohandler->set_finished_stage_menu($finished_stage);
|
||||
}
|
||||
|
||||
$this->navigation_provider->set_nav_property($finished_stage, array(
|
||||
'selected' => false,
|
||||
'completed' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default template variables
|
||||
*
|
||||
* @param string $page_title Title of the page
|
||||
* @param bool $selected_language True to enable language selector it, false otherwise
|
||||
*/
|
||||
protected function page_header($page_title, $selected_language = false)
|
||||
{
|
||||
// Path to templates
|
||||
$paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path);
|
||||
$paths = array_filter($paths, 'is_dir');
|
||||
$path = array_shift($paths);
|
||||
$path = substr($path, strlen($this->phpbb_root_path));
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'L_CHANGE' => $this->language->lang('CHANGE'),
|
||||
'L_COLON' => $this->language->lang('COLON'),
|
||||
'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'),
|
||||
'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'),
|
||||
'L_SKIP' => $this->language->lang('SKIP'),
|
||||
'PAGE_TITLE' => $this->language->lang($page_title),
|
||||
'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images',
|
||||
'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js',
|
||||
'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style',
|
||||
'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets',
|
||||
|
||||
'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'),
|
||||
'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right',
|
||||
'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left',
|
||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||
'S_LANG_SELECT' => $selected_language,
|
||||
|
||||
'S_USER_LANG' => $this->language->lang('USER_LANG'),
|
||||
));
|
||||
|
||||
$this->render_navigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render navigation
|
||||
*/
|
||||
protected function render_navigation()
|
||||
{
|
||||
// Get navigation items
|
||||
$nav_array = $this->navigation_provider->get();
|
||||
$nav_array = $this->sort_navigation_level($nav_array);
|
||||
|
||||
$active_main_menu = $this->get_active_main_menu($nav_array);
|
||||
|
||||
// Pass navigation to template
|
||||
foreach ($nav_array as $key => $entry)
|
||||
{
|
||||
$this->template->assign_block_vars('t_block1', array(
|
||||
'L_TITLE' => $this->language->lang($entry['label']),
|
||||
'S_SELECTED' => ($active_main_menu === $key),
|
||||
'U_TITLE' => $this->route($entry['route']),
|
||||
));
|
||||
|
||||
if (is_array($entry[0]) && $active_main_menu === $key)
|
||||
{
|
||||
$entry[0] = $this->sort_navigation_level($entry[0]);
|
||||
|
||||
foreach ($entry[0] as $name => $sub_entry)
|
||||
{
|
||||
if (isset($sub_entry['stage']) && $sub_entry['stage'] === true)
|
||||
{
|
||||
$this->template->assign_block_vars('l_block2', array(
|
||||
'L_TITLE' => $this->language->lang($sub_entry['label']),
|
||||
'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true),
|
||||
'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true),
|
||||
'STAGE_NAME' => $name,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->template->assign_block_vars('l_block1', array(
|
||||
'L_TITLE' => $this->language->lang($sub_entry['label']),
|
||||
'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')),
|
||||
'U_TITLE' => $this->route($sub_entry['route']),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render language select form
|
||||
*
|
||||
* @param string $selected_language
|
||||
*/
|
||||
protected function render_language_select($selected_language = null)
|
||||
{
|
||||
$langs = $this->lang_helper->get_available_languages();
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
$this->template->assign_block_vars('language_select_item', array(
|
||||
'VALUE' => $lang['iso'],
|
||||
'NAME' => $lang['local_name'],
|
||||
'SELECTED' => ($lang['iso'] === $selected_language),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the active main menu item
|
||||
*
|
||||
* @param array $nav_array
|
||||
*
|
||||
* @return string|bool Returns the name of the active main menu element, if the element not found, returns false
|
||||
*/
|
||||
protected function get_active_main_menu($nav_array)
|
||||
{
|
||||
$active_route = $this->request->get('_route');
|
||||
|
||||
foreach ($nav_array as $nav_name => $nav_options)
|
||||
{
|
||||
$current_menu = $nav_name;
|
||||
|
||||
if (isset($nav_options['route']) && $nav_options['route'] === $active_route)
|
||||
{
|
||||
return $nav_name;
|
||||
}
|
||||
|
||||
if (is_array($nav_options[0]))
|
||||
{
|
||||
foreach ($nav_options[0] as $sub_menus)
|
||||
{
|
||||
if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route)
|
||||
{
|
||||
return $current_menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the top level of navigation array
|
||||
*
|
||||
* @param array $nav_array Navigation array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function sort_navigation_level($nav_array)
|
||||
{
|
||||
$sorted = array();
|
||||
foreach ($nav_array as $key => $nav)
|
||||
{
|
||||
$order = (isset($nav['order'])) ? $nav['order'] : 0;
|
||||
$sorted[$order][$key] = $nav;
|
||||
}
|
||||
|
||||
// Linearization of navigation array
|
||||
$nav_array = array();
|
||||
ksort($sorted);
|
||||
foreach ($sorted as $nav)
|
||||
{
|
||||
$nav_array = array_merge($nav_array, $nav);
|
||||
}
|
||||
|
||||
return $nav_array;
|
||||
}
|
||||
}
|
172
msd2/phpBB3/phpbb/install/controller/install.php
Normal file
172
msd2/phpBB3/phpbb/install/controller/install.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\exception\http_exception;
|
||||
use phpbb\install\helper\install_helper;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use phpbb\install\helper\iohandler\factory;
|
||||
use phpbb\template\template;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\install\installer;
|
||||
use phpbb\language\language;
|
||||
|
||||
/**
|
||||
* Controller for installing phpBB
|
||||
*/
|
||||
class install
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $controller_helper;
|
||||
|
||||
/**
|
||||
* @var factory
|
||||
*/
|
||||
protected $iohandler_factory;
|
||||
|
||||
/**
|
||||
* @var navigation_provider
|
||||
*/
|
||||
protected $menu_provider;
|
||||
|
||||
/**
|
||||
* @var language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var request_interface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var installer
|
||||
*/
|
||||
protected $installer;
|
||||
|
||||
/**
|
||||
* @var install_helper
|
||||
*/
|
||||
protected $install_helper;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $helper
|
||||
* @param factory $factory
|
||||
* @param navigation_provider $nav_provider
|
||||
* @param language $language
|
||||
* @param template $template
|
||||
* @param request_interface $request
|
||||
* @param installer $installer
|
||||
* @param install_helper $install_helper
|
||||
*/
|
||||
public function __construct(helper $helper, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper)
|
||||
{
|
||||
$this->controller_helper = $helper;
|
||||
$this->iohandler_factory = $factory;
|
||||
$this->menu_provider = $nav_provider;
|
||||
$this->language = $language;
|
||||
$this->template = $template;
|
||||
$this->request = $request;
|
||||
$this->installer = $installer;
|
||||
$this->install_helper = $install_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller logic
|
||||
*
|
||||
* @return Response|StreamedResponse
|
||||
*
|
||||
* @throws http_exception When phpBB is already installed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->install_helper->is_phpbb_installed())
|
||||
{
|
||||
throw new http_exception(403, 'INSTALL_PHPBB_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());
|
||||
$this->controller_helper->handle_language_select();
|
||||
|
||||
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)
|
||||
{
|
||||
// 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'),
|
||||
));
|
||||
|
||||
/** @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_install.html', 'INSTALL', true);
|
||||
}
|
||||
|
||||
// @todo: implement no js controller logic
|
||||
}
|
||||
}
|
||||
}
|
81
msd2/phpBB3/phpbb/install/controller/installer_index.php
Normal file
81
msd2/phpBB3/phpbb/install/controller/installer_index.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
class installer_index
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var \phpbb\template\template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $helper
|
||||
* @param \phpbb\language\language $language
|
||||
* @param \phpbb\template\template $template
|
||||
* @param string $phpbb_root_path
|
||||
*/
|
||||
public function __construct(helper $helper, \phpbb\language\language $language, \phpbb\template\template $template, $phpbb_root_path)
|
||||
{
|
||||
$this->helper = $helper;
|
||||
$this->language = $language;
|
||||
$this->template = $template;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
}
|
||||
|
||||
public function handle($mode)
|
||||
{
|
||||
$this->helper->handle_language_select();
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case "intro":
|
||||
$title = $this->language->lang('INTRODUCTION_TITLE');
|
||||
$body = $this->language->lang('INTRODUCTION_BODY');
|
||||
break;
|
||||
case "support":
|
||||
$title = $this->language->lang('SUPPORT_TITLE');
|
||||
$body = $this->language->lang('SUPPORT_BODY');
|
||||
break;
|
||||
case "license":
|
||||
$title = $this->language->lang('LICENSE_TITLE');
|
||||
$body = implode("<br/>\n", file($this->phpbb_root_path . 'docs/LICENSE.txt'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'TITLE' => $title,
|
||||
'BODY' => $body,
|
||||
));
|
||||
|
||||
return $this->helper->render('installer_main.html', $title, true);
|
||||
}
|
||||
}
|
80
msd2/phpBB3/phpbb/install/controller/timeout_check.php
Normal file
80
msd2/phpBB3/phpbb/install/controller/timeout_check.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class timeout_check
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $helper
|
||||
* @param string $phpbb_root_path
|
||||
*/
|
||||
public function __construct(helper $helper, $phpbb_root_path)
|
||||
{
|
||||
$this->helper = $helper;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for querying installer status
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$lock_file = $this->phpbb_root_path . 'store/io_lock.lock';
|
||||
$response = new JsonResponse();
|
||||
|
||||
if (!file_exists($lock_file))
|
||||
{
|
||||
$response->setData(array(
|
||||
'status' => 'fail',
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$fp = @fopen($lock_file, 'r');
|
||||
|
||||
if ($fp && flock($fp, LOCK_EX | LOCK_NB))
|
||||
{
|
||||
$status = (filesize($lock_file) >= 2 && fread($fp, 2) === 'ok') ? 'continue' : 'fail';
|
||||
|
||||
$response->setData(array(
|
||||
'status' => $status,
|
||||
));
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response->setData(array(
|
||||
'status' => 'running',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
166
msd2/phpBB3/phpbb/install/controller/update.php
Normal file
166
msd2/phpBB3/phpbb/install/controller/update.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\exception\http_exception;
|
||||
use phpbb\install\helper\install_helper;
|
||||
use phpbb\install\helper\iohandler\factory;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use phpbb\install\installer;
|
||||
use phpbb\language\language;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\template\template;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* Updater controller
|
||||
*/
|
||||
class update
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $controller_helper;
|
||||
|
||||
/**
|
||||
* @var installer
|
||||
*/
|
||||
protected $installer;
|
||||
|
||||
/**
|
||||
* @var install_helper
|
||||
*/
|
||||
protected $install_helper;
|
||||
|
||||
/**
|
||||
* @var factory
|
||||
*/
|
||||
protected $iohandler_factory;
|
||||
|
||||
/**
|
||||
* @var language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var navigation_provider
|
||||
*/
|
||||
protected $menu_provider;
|
||||
|
||||
/**
|
||||
* @var request_interface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $controller_helper
|
||||
* @param installer $installer
|
||||
* @param install_helper $install_helper
|
||||
* @param factory $iohandler
|
||||
* @param language $language
|
||||
* @param navigation_provider $menu_provider
|
||||
* @param request_interface $request
|
||||
* @param template $template
|
||||
*/
|
||||
public function __construct(helper $controller_helper, installer $installer, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $menu_provider, request_interface $request, template $template)
|
||||
{
|
||||
$this->controller_helper = $controller_helper;
|
||||
$this->installer = $installer;
|
||||
$this->install_helper = $install_helper;
|
||||
$this->iohandler_factory = $iohandler;
|
||||
$this->language = $language;
|
||||
$this->menu_provider = $menu_provider;
|
||||
$this->request = $request;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user