mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/14044] Deduplicate the installers
PHPBB3-14044
This commit is contained in:
committed by
Marc Alexander
parent
cc1a96a804
commit
597297b169
59
phpBB/install/app.php
Normal file
59
phpBB/install/app.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('IN_PHPBB', true);
|
||||
define('IN_INSTALL', true);
|
||||
define('PHPBB_ENVIRONMENT', 'production');
|
||||
$phpbb_root_path = '../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
|
||||
$startup_new_path = $phpbb_root_path . 'install/update/update/new/install/startup.' . $phpEx;
|
||||
$startup_path = (file_exists($startup_new_path)) ? $startup_new_path : $phpbb_root_path . 'install/startup.' . $phpEx;
|
||||
require($startup_path);
|
||||
|
||||
/** @var \phpbb\filesystem\filesystem $phpbb_filesystem */
|
||||
$phpbb_filesystem = $phpbb_installer_container->get('filesystem');
|
||||
|
||||
/** @var \phpbb\template\template $template */
|
||||
$template = $phpbb_installer_container->get('template');
|
||||
|
||||
|
||||
// Path to templates
|
||||
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
|
||||
$paths = array_filter($paths, 'is_dir');
|
||||
|
||||
$template->set_custom_style(array(
|
||||
array(
|
||||
'name' => 'adm',
|
||||
'ext_path' => 'adm/style/',
|
||||
),
|
||||
), $paths);
|
||||
|
||||
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */
|
||||
$phpbb_dispatcher = $phpbb_installer_container->get('dispatcher');
|
||||
|
||||
/** @var \phpbb\language\language $language */
|
||||
$language = $phpbb_installer_container->get('language');
|
||||
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting'));
|
||||
|
||||
/* @var $http_kernel \Symfony\Component\HttpKernel\HttpKernel */
|
||||
$http_kernel = $phpbb_installer_container->get('http_kernel');
|
||||
|
||||
/* @var $symfony_request \phpbb\symfony_request */
|
||||
$symfony_request = $phpbb_installer_container->get('symfony_request');
|
||||
$response = $http_kernel->handle($symfony_request);
|
||||
$response->send();
|
||||
$http_kernel->terminate($symfony_request, $response);
|
@@ -1,270 +0,0 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
$update_start_time = time();
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('IN_PHPBB', true);
|
||||
define('IN_INSTALL', true);
|
||||
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
|
||||
function phpbb_end_update($cache, $config)
|
||||
{
|
||||
$cache->purge();
|
||||
|
||||
$config->increment('assets_version', 1);
|
||||
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<span class="corners-bottom"><span></span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="page-footer">
|
||||
<div class="copyright">
|
||||
Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Limited
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
|
||||
garbage_collection();
|
||||
exit_handler();
|
||||
}
|
||||
|
||||
require($phpbb_root_path . 'includes/startup.' . $phpEx);
|
||||
require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
|
||||
|
||||
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
|
||||
$phpbb_class_loader->register();
|
||||
|
||||
$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
|
||||
extract($phpbb_config_php_file->get_all());
|
||||
|
||||
if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type))
|
||||
{
|
||||
die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update.");
|
||||
}
|
||||
|
||||
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
|
||||
$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
|
||||
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
|
||||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
// Set up container (must be done here because extensions table may not exist)
|
||||
$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
|
||||
$phpbb_container = $phpbb_container_builder
|
||||
->with_config($phpbb_config_php_file)
|
||||
->without_extensions()
|
||||
->without_cache()
|
||||
->get_container()
|
||||
;
|
||||
|
||||
// set up caching
|
||||
/* @var $cache \phpbb\cache\service */
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
// Instantiate some basic classes
|
||||
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
|
||||
/* @var $request \phpbb\request\request_interface */
|
||||
$request = $phpbb_container->get('request');
|
||||
|
||||
/* @var $user \phpbb\user */
|
||||
$user = $phpbb_container->get('user');
|
||||
|
||||
/* @var $auth \phpbb\auth\auth */
|
||||
$auth = $phpbb_container->get('auth');
|
||||
|
||||
/* @var $db \phpbb\db\driver\driver_interface */
|
||||
$db = $phpbb_container->get('dbal.conn');
|
||||
|
||||
/* @var $phpbb_log \phpbb\log\log_interface */
|
||||
$phpbb_log = $phpbb_container->get('log');
|
||||
|
||||
/** @var \phpbb\language\language $language */
|
||||
$language = $phpbb_container->get('language');
|
||||
|
||||
// Grab global variables, re-cache if necessary
|
||||
/* @var $config \phpbb\config\config */
|
||||
$config = $phpbb_container->get('config');
|
||||
|
||||
if (!isset($config['version_update_from']))
|
||||
{
|
||||
$config->set('version_update_from', $config['version']);
|
||||
}
|
||||
|
||||
$orig_version = $config['version_update_from'];
|
||||
|
||||
$user->add_lang(array('common', 'acp/common', 'install', 'migrator'));
|
||||
|
||||
// Add own hook handler, if present. :o
|
||||
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
|
||||
{
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
||||
|
||||
/* @var $phpbb_hook_finder \phpbb\hook\finder */
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpbb_hook = false;
|
||||
}
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html dir="<?php echo $user->lang['DIRECTION']; ?>" lang="<?php echo $user->lang['USER_LANG']; ?>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></title>
|
||||
|
||||
<link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrap">
|
||||
<div id="page-header"> </div>
|
||||
|
||||
<div id="page-body">
|
||||
<div id="acp">
|
||||
<div class="panel">
|
||||
<span class="corners-top"><span></span></span>
|
||||
<div id="content">
|
||||
<div id="main" class="install-body">
|
||||
|
||||
<h1><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></h1>
|
||||
|
||||
<br />
|
||||
|
||||
<p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->get_sql_layer(); ?></strong><br />
|
||||
<?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br />
|
||||
|
||||
<?php
|
||||
|
||||
define('IN_DB_UPDATE', true);
|
||||
|
||||
/**
|
||||
* @todo mysql update?
|
||||
*/
|
||||
|
||||
// End startup code
|
||||
|
||||
/* @var $migrator \phpbb\db\migrator */
|
||||
$migrator = $phpbb_container->get('migrator');
|
||||
|
||||
/** @var \phpbb\filesystem\filesystem_interface $phpbb_filesystem */
|
||||
$phpbb_filesystem = $phpbb_container->get('filesystem');
|
||||
$migrator->set_output_handler(new \phpbb\db\output_handler\log_wrapper_migrator_output_handler($language, new \phpbb\db\output_handler\html_migrator_output_handler($language), $phpbb_root_path . 'store/migrations_' . time() . '.log', $phpbb_filesystem));
|
||||
|
||||
$migrator->create_migrations_table();
|
||||
|
||||
/* @var $phpbb_extension_manager \phpbb\extension\manager */
|
||||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||
|
||||
$migrations = $phpbb_extension_manager
|
||||
->get_finder()
|
||||
->core_path('phpbb/db/migration/data/')
|
||||
->extension_directory('/migrations')
|
||||
->get_classes();
|
||||
|
||||
$migrator->set_migrations($migrations);
|
||||
|
||||
// What is a safe limit of execution time? Half the max execution time should be safe.
|
||||
// No more than 15 seconds so the user isn't sitting and waiting for a very long time
|
||||
$phpbb_ini = new \bantu\IniGetWrapper\IniGetWrapper();
|
||||
$safe_time_limit = min(15, ($phpbb_ini->getNumeric('max_execution_time') / 2));
|
||||
|
||||
// While we're going to try limit this to half the max execution time,
|
||||
// we want to try and take additional measures to prevent hitting the
|
||||
// max execution time (if, say, one migration step takes much longer
|
||||
// than the max execution time)
|
||||
@set_time_limit(0);
|
||||
|
||||
while (!$migrator->finished())
|
||||
{
|
||||
try
|
||||
{
|
||||
$migrator->update();
|
||||
}
|
||||
catch (\phpbb\db\migration\exception $e)
|
||||
{
|
||||
echo $e->getLocalisedMessage($user);
|
||||
|
||||
phpbb_end_update($cache, $config);
|
||||
}
|
||||
|
||||
$state = array_merge(array(
|
||||
'migration_schema_done' => false,
|
||||
'migration_data_done' => false,
|
||||
),
|
||||
$migrator->last_run_migration['state']
|
||||
);
|
||||
|
||||
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
|
||||
if ((time() - $update_start_time) >= $safe_time_limit)
|
||||
{
|
||||
echo '<br />' . $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br /><br />';
|
||||
echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';
|
||||
|
||||
phpbb_end_update($cache, $config);
|
||||
}
|
||||
}
|
||||
|
||||
if ($orig_version != $config['version'])
|
||||
{
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_DATABASE', false, array($orig_version, $config['version']));
|
||||
}
|
||||
|
||||
echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '<br />';
|
||||
|
||||
if ($request->variable('type', 0))
|
||||
{
|
||||
echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '<br /><br />';
|
||||
echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&sub=update_db&language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<div class="errorbox">' . $user->lang['UPDATE_FILES_NOTICE'] . '</div>';
|
||||
echo $user->lang['COMPLETE_LOGIN_TO_BOARD'];
|
||||
}
|
||||
|
||||
$config->delete('version_update_from');
|
||||
|
||||
phpbb_end_update($cache, $config);
|
@@ -1,874 +0,0 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**#@+
|
||||
* @ignore
|
||||
*/
|
||||
define('IN_PHPBB', true);
|
||||
define('IN_INSTALL', true);
|
||||
define('PHPBB_ENVIRONMENT', 'production');
|
||||
/**#@-*/
|
||||
|
||||
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.4') < 0)
|
||||
{
|
||||
die('You are running an unsupported PHP version. Please upgrade to PHP 5.4 or higher before trying to install phpBB 3.2');
|
||||
}
|
||||
|
||||
function phpbb_require_updated($path, $optional = false)
|
||||
{
|
||||
global $phpbb_root_path, $table_prefix;
|
||||
|
||||
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
|
||||
$old_path = $phpbb_root_path . $path;
|
||||
|
||||
if (file_exists($new_path))
|
||||
{
|
||||
require($new_path);
|
||||
}
|
||||
else if (!$optional || file_exists($old_path))
|
||||
{
|
||||
require($old_path);
|
||||
}
|
||||
}
|
||||
|
||||
function phpbb_include_updated($path, $optional = false)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
|
||||
$old_path = $phpbb_root_path . $path;
|
||||
|
||||
if (file_exists($new_path))
|
||||
{
|
||||
include($new_path);
|
||||
}
|
||||
else if (!$optional || file_exists($old_path))
|
||||
{
|
||||
include($old_path);
|
||||
}
|
||||
}
|
||||
|
||||
phpbb_require_updated('includes/startup.' . $phpEx);
|
||||
|
||||
// Try to override some limits - maybe it helps some...
|
||||
@set_time_limit(0);
|
||||
$mem_limit = @ini_get('memory_limit');
|
||||
if (!empty($mem_limit))
|
||||
{
|
||||
$unit = strtolower(substr($mem_limit, -1, 1));
|
||||
$mem_limit = (int) $mem_limit;
|
||||
|
||||
if ($unit == 'k')
|
||||
{
|
||||
$mem_limit = floor($mem_limit / 1024);
|
||||
}
|
||||
else if ($unit == 'g')
|
||||
{
|
||||
$mem_limit *= 1024;
|
||||
}
|
||||
else if (is_numeric($unit))
|
||||
{
|
||||
$mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
|
||||
}
|
||||
$mem_limit = max(128, $mem_limit) . 'M';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mem_limit = '128M';
|
||||
}
|
||||
@ini_set('memory_limit', $mem_limit);
|
||||
|
||||
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
|
||||
$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
|
||||
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
|
||||
|
||||
// Include essential scripts
|
||||
phpbb_require_updated('phpbb/class_loader.' . $phpEx);
|
||||
|
||||
phpbb_require_updated('includes/functions.' . $phpEx);
|
||||
|
||||
phpbb_require_updated('includes/functions_content.' . $phpEx, true);
|
||||
|
||||
phpbb_include_updated('includes/functions_admin.' . $phpEx);
|
||||
phpbb_include_updated('includes/utf/utf_tools.' . $phpEx);
|
||||
phpbb_require_updated('includes/functions_install.' . $phpEx);
|
||||
|
||||
// Setup class loader first
|
||||
$phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
|
||||
$phpbb_class_loader_new->register();
|
||||
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
||||
$phpbb_class_loader_ext->register();
|
||||
|
||||
// Set up container
|
||||
$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
|
||||
$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
|
||||
$phpbb_container_builder
|
||||
->without_extensions()
|
||||
->without_cache()
|
||||
->without_compiled_container()
|
||||
;
|
||||
|
||||
$other_config_path = $phpbb_root_path . 'install/update/new/config/';
|
||||
$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/';
|
||||
$phpbb_container_builder->with_config_path($config_path);
|
||||
|
||||
$phpbb_container_builder->with_custom_parameters(array(
|
||||
'core.root_path' => $phpbb_root_path,
|
||||
'core.adm_relative_path' => $phpbb_adm_relative_path,
|
||||
'core.php_ext' => $phpEx,
|
||||
'core.table_prefix' => '',
|
||||
'cache.driver.class' => 'phpbb\cache\driver\file',
|
||||
));
|
||||
|
||||
$phpbb_container = $phpbb_container_builder->get_container();
|
||||
$phpbb_container->register('dbal.conn.driver')->setSynthetic(true);
|
||||
$phpbb_container->register('template.twig.environment')->setSynthetic(true);
|
||||
$phpbb_container->register('language.loader')->setSynthetic(true);
|
||||
$phpbb_container->compile();
|
||||
|
||||
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
||||
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
||||
|
||||
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
|
||||
/* @var $request \phpbb\request\request_interface */
|
||||
$request = $phpbb_container->get('request');
|
||||
|
||||
// Try and load an appropriate language if required
|
||||
$language = basename($request->variable('language', ''));
|
||||
|
||||
if ($request->header('Accept-Language') && !$language)
|
||||
{
|
||||
$accept_lang_ary = explode(',', strtolower($request->header('Accept-Language')));
|
||||
foreach ($accept_lang_ary as $accept_lang)
|
||||
{
|
||||
// Set correct format ... guess full xx_yy form
|
||||
$accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
|
||||
{
|
||||
$language = $accept_lang;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No match on xx_yy so try xx
|
||||
$accept_lang = substr($accept_lang, 0, 2);
|
||||
if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
|
||||
{
|
||||
$language = $accept_lang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No appropriate language found ... so let's use the first one in the language
|
||||
// dir, this may or may not be English
|
||||
if (!$language)
|
||||
{
|
||||
$dir = @opendir($phpbb_root_path . 'language');
|
||||
|
||||
if (!$dir)
|
||||
{
|
||||
die('Unable to access the language directory');
|
||||
exit;
|
||||
}
|
||||
|
||||
while (($file = readdir($dir)) !== false)
|
||||
{
|
||||
$path = $phpbb_root_path . 'language/' . $file;
|
||||
|
||||
if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
|
||||
{
|
||||
$language = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_root_path . 'language/' . $language))
|
||||
{
|
||||
die('No language found!');
|
||||
}
|
||||
|
||||
// And finally, load the relevant language files
|
||||
$load_lang_files = array('common', 'acp/common', 'acp/board', 'install', 'posting');
|
||||
$new_path = $phpbb_root_path . 'install/update/new/language/' . $language . '/';
|
||||
$old_path = $phpbb_root_path . 'language/' . $language . '/';
|
||||
|
||||
// NOTE: we can not use "phpbb_include_updated" as the files uses vars which would be required
|
||||
// to be global while loading.
|
||||
foreach ($load_lang_files as $lang_file)
|
||||
{
|
||||
if (file_exists($new_path . $lang_file . '.' . $phpEx))
|
||||
{
|
||||
include($new_path . $lang_file . '.' . $phpEx);
|
||||
}
|
||||
else
|
||||
{
|
||||
include($old_path . $lang_file . '.' . $phpEx);
|
||||
}
|
||||
}
|
||||
|
||||
// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
|
||||
|
||||
// Define needed constants
|
||||
define('CHMOD_ALL', 7);
|
||||
define('CHMOD_READ', 4);
|
||||
define('CHMOD_WRITE', 2);
|
||||
define('CHMOD_EXECUTE', 1);
|
||||
|
||||
$mode = $request->variable('mode', 'overview');
|
||||
$sub = $request->variable('sub', '');
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
$lang_service = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
|
||||
$lang_service->add_lang($load_lang_files);
|
||||
$lang_service->set_user_language($language);
|
||||
$user = new \phpbb\user($lang_service, '\phpbb\datetime');
|
||||
$auth = new \phpbb\auth\auth();
|
||||
|
||||
// Add own hook handler, if present. :o
|
||||
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
|
||||
{
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
||||
|
||||
/* @var $phpbb_hook_finder \phpbb\hook\finder */
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpbb_hook = false;
|
||||
}
|
||||
|
||||
// Set some standard variables we want to force
|
||||
$config = new \phpbb\config\config(array(
|
||||
'load_tplcompile' => '1'
|
||||
));
|
||||
|
||||
/* @var $symfony_request \phpbb\symfony_request */
|
||||
$symfony_request = $phpbb_container->get('symfony_request');
|
||||
|
||||
/* @var $phpbb_filesystem \phpbb\filesystem\filesystem_interface */
|
||||
$phpbb_filesystem = $phpbb_container->get('filesystem');
|
||||
|
||||
/* @var $phpbb_path_helper \phpbb\path_helper */
|
||||
$phpbb_path_helper = $phpbb_container->get('path_helper');
|
||||
$cache_path = $phpbb_root_path . 'cache/';
|
||||
|
||||
$twig_environment = new \phpbb\template\twig\environment(
|
||||
$config,
|
||||
$phpbb_filesystem,
|
||||
$phpbb_path_helper,
|
||||
$phpbb_container,
|
||||
$cache_path,
|
||||
null,
|
||||
$phpbb_container->get('template.twig.loader')
|
||||
);
|
||||
|
||||
$language_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$phpbb_container->set('template.twig.environment', $twig_environment);
|
||||
$phpbb_container->set('language.loader', $language_loader);
|
||||
$twig_context = new \phpbb\template\context();
|
||||
$template = new \phpbb\template\twig\twig(
|
||||
$phpbb_path_helper,
|
||||
$config,
|
||||
$twig_context,
|
||||
$twig_environment,
|
||||
$cache_path,
|
||||
$user,
|
||||
array($phpbb_container->get('template.twig.extensions.phpbb'))
|
||||
);
|
||||
|
||||
/** @var \phpbb\language\language $lang_service */
|
||||
$lang_service = $phpbb_container->get('language');
|
||||
$lang_service->add_lang($load_lang_files);
|
||||
$lang_service->set_user_language($language);
|
||||
|
||||
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
|
||||
$paths = array_filter($paths, 'is_dir');
|
||||
$template->set_custom_style(array(
|
||||
array(
|
||||
'name' => 'adm',
|
||||
'ext_path' => 'adm/style/',
|
||||
),
|
||||
), $paths);
|
||||
|
||||
$path = array_shift($paths);
|
||||
|
||||
$template->assign_var('T_ASSETS_PATH', $path . '/../../assets');
|
||||
$template->assign_var('T_TEMPLATE_PATH', $path);
|
||||
|
||||
$install = new module();
|
||||
|
||||
$install->create('install', "index.$phpEx", $mode, $sub);
|
||||
$install->load();
|
||||
|
||||
// Generate the page
|
||||
$install->page_header();
|
||||
$install->generate_navigation();
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => $install->get_tpl_name())
|
||||
);
|
||||
|
||||
$install->page_footer();
|
||||
|
||||
class module
|
||||
{
|
||||
var $id = 0;
|
||||
var $type = 'install';
|
||||
var $module_ary = array();
|
||||
var $filename;
|
||||
var $module_url = '';
|
||||
var $tpl_name = '';
|
||||
var $mode;
|
||||
var $sub;
|
||||
|
||||
/**
|
||||
* Private methods, should not be overwritten
|
||||
*/
|
||||
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
|
||||
{
|
||||
global $db, $config, $phpEx, $phpbb_root_path;
|
||||
|
||||
$module = array();
|
||||
|
||||
// Grab module information using Bart's "neat-o-module" system (tm)
|
||||
$dir = @opendir('.');
|
||||
|
||||
if (!$dir)
|
||||
{
|
||||
$this->error('Unable to access the installation directory', __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
$setmodules = 1;
|
||||
while (($file = readdir($dir)) !== false)
|
||||
{
|
||||
if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
|
||||
{
|
||||
include($file);
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
unset($setmodules);
|
||||
|
||||
if (!sizeof($module))
|
||||
{
|
||||
$this->error('No installation modules found', __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
// Order to use and count further if modules get assigned to the same position or not having an order
|
||||
$max_module_order = 1000;
|
||||
|
||||
foreach ($module as $row)
|
||||
{
|
||||
// Module order not specified or module already assigned at this position?
|
||||
if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
|
||||
{
|
||||
$row['module_order'] = $max_module_order;
|
||||
$max_module_order++;
|
||||
}
|
||||
|
||||
$this->module_ary[$row['module_order']]['name'] = $row['module_title'];
|
||||
$this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
|
||||
$this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
|
||||
$this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
|
||||
|
||||
if (strtolower($selected_mod) == strtolower($row['module_title']))
|
||||
{
|
||||
$this->id = (int) $row['module_order'];
|
||||
$this->filename = (string) $row['module_filename'];
|
||||
$this->module_url = (string) $module_url;
|
||||
$this->mode = (string) $selected_mod;
|
||||
// Check that the sub-mode specified is valid or set a default if not
|
||||
if (is_array($row['module_subs']))
|
||||
{
|
||||
$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
|
||||
}
|
||||
else if (is_array($row['module_stages']))
|
||||
{
|
||||
$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sub = '';
|
||||
}
|
||||
}
|
||||
} // END foreach
|
||||
} // END create
|
||||
|
||||
/**
|
||||
* Load and run the relevant module if applicable
|
||||
*/
|
||||
function load($mode = false, $run = true)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
if ($run)
|
||||
{
|
||||
if (!empty($mode))
|
||||
{
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
$module = $this->filename;
|
||||
if (!class_exists($module))
|
||||
{
|
||||
$this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
|
||||
}
|
||||
$this->module = new $module($this);
|
||||
|
||||
if (method_exists($this->module, 'main'))
|
||||
{
|
||||
$this->module->main($this->mode, $this->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the standard page header
|
||||
*/
|
||||
function page_header()
|
||||
{
|
||||
if (defined('HEADER_INC'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
define('HEADER_INC', true);
|
||||
global $template, $lang, $stage, $phpbb_admin_path, $path;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_CHANGE' => $lang['CHANGE'],
|
||||
'L_COLON' => $lang['COLON'],
|
||||
'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
|
||||
'L_SELECT_LANG' => $lang['SELECT_LANG'],
|
||||
'L_SKIP' => $lang['SKIP'],
|
||||
'PAGE_TITLE' => $this->get_page_title(),
|
||||
'T_IMAGE_PATH' => htmlspecialchars($phpbb_admin_path) . 'images/',
|
||||
'T_JQUERY_LINK' => $path . '/../../assets/javascript/jquery.min.js',
|
||||
|
||||
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
|
||||
'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
|
||||
'S_CONTENT_FLOW_END' => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||
|
||||
'S_USER_LANG' => $lang['USER_LANG'],
|
||||
)
|
||||
);
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
header('Cache-Control: private, no-cache="set-cookie"');
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the standard page footer
|
||||
*/
|
||||
function page_footer()
|
||||
{
|
||||
global $db, $template;
|
||||
|
||||
$template->display('body');
|
||||
|
||||
// Close our DB connection.
|
||||
if (!empty($db) && is_object($db))
|
||||
{
|
||||
$db->sql_close();
|
||||
}
|
||||
|
||||
if (function_exists('exit_handler'))
|
||||
{
|
||||
exit_handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns desired template name
|
||||
*/
|
||||
function get_tpl_name()
|
||||
{
|
||||
return $this->module->tpl_name . '.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the desired page title
|
||||
*/
|
||||
function get_page_title()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
if (!isset($this->module->page_title))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an HTTP/1.1 header to redirect the user to another page
|
||||
* This is used during the installation when we do not have a database available to call the normal redirect function
|
||||
* @param string $page The page to redirect to relative to the installer root path
|
||||
*/
|
||||
function redirect($page)
|
||||
{
|
||||
global $request;
|
||||
|
||||
// HTTP_HOST is having the correct browser url in most cases...
|
||||
$server_name = strtolower(htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME'))));
|
||||
$server_port = $request->server('SERVER_PORT', 0);
|
||||
$secure = $request->is_secure() ? 1 : 0;
|
||||
|
||||
$script_name = htmlspecialchars_decode($request->server('PHP_SELF'));
|
||||
if (!$script_name)
|
||||
{
|
||||
$script_name = htmlspecialchars_decode($request->server('REQUEST_URI'));
|
||||
}
|
||||
|
||||
// Replace backslashes and doubled slashes (could happen on some proxy setups)
|
||||
$script_name = str_replace(array('\\', '//'), '/', $script_name);
|
||||
$script_path = trim(dirname($script_name));
|
||||
|
||||
$url = (($secure) ? 'https://' : 'http://') . $server_name;
|
||||
|
||||
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
|
||||
{
|
||||
// HTTP HOST can carry a port number...
|
||||
if (strpos($server_name, ':') === false)
|
||||
{
|
||||
$url .= ':' . $server_port;
|
||||
}
|
||||
}
|
||||
|
||||
$url .= $script_path . '/' . $page;
|
||||
header('Location: ' . $url);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the navigation tabs
|
||||
*/
|
||||
function generate_navigation()
|
||||
{
|
||||
global $lang, $template, $phpEx, $language;
|
||||
|
||||
if (is_array($this->module_ary))
|
||||
{
|
||||
@ksort($this->module_ary);
|
||||
foreach ($this->module_ary as $cat_ary)
|
||||
{
|
||||
$cat = $cat_ary['name'];
|
||||
$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
|
||||
$cat = strtolower($cat);
|
||||
$url = $this->module_url . "?mode=$cat&language=$language";
|
||||
|
||||
if ($this->mode == $cat)
|
||||
{
|
||||
$template->assign_block_vars('t_block1', array(
|
||||
'L_TITLE' => $l_cat,
|
||||
'S_SELECTED' => true,
|
||||
'U_TITLE' => $url,
|
||||
));
|
||||
|
||||
if (is_array($this->module_ary[$this->id]['subs']))
|
||||
{
|
||||
$subs = $this->module_ary[$this->id]['subs'];
|
||||
foreach ($subs as $option)
|
||||
{
|
||||
$l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
|
||||
$option = strtolower($option);
|
||||
$url = $this->module_url . '?mode=' . $this->mode . "&sub=$option&language=$language";
|
||||
|
||||
$template->assign_block_vars('l_block1', array(
|
||||
'L_TITLE' => $l_option,
|
||||
'S_SELECTED' => ($this->sub == $option),
|
||||
'U_TITLE' => $url,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($this->module_ary[$this->id]['stages']))
|
||||
{
|
||||
$subs = $this->module_ary[$this->id]['stages'];
|
||||
$matched = false;
|
||||
foreach ($subs as $option)
|
||||
{
|
||||
$l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
|
||||
$option = strtolower($option);
|
||||
$matched = ($this->sub == $option) ? true : $matched;
|
||||
|
||||
$template->assign_block_vars('l_block2', array(
|
||||
'L_TITLE' => $l_option,
|
||||
'S_SELECTED' => ($this->sub == $option),
|
||||
'S_COMPLETE' => !$matched,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_block_vars('t_block1', array(
|
||||
'L_TITLE' => $l_cat,
|
||||
'S_SELECTED' => false,
|
||||
'U_TITLE' => $url,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an error message
|
||||
* If skip is true, return and continue execution, else exit
|
||||
*/
|
||||
function error($error, $line, $file, $skip = false)
|
||||
{
|
||||
global $lang, $db, $template, $phpbb_admin_path;
|
||||
|
||||
if ($skip)
|
||||
{
|
||||
$template->assign_block_vars('checks', array(
|
||||
'S_LEGEND' => true,
|
||||
'LEGEND' => $lang['INST_ERR'],
|
||||
));
|
||||
|
||||
$template->assign_block_vars('checks', array(
|
||||
'TITLE' => basename($file) . ' [ ' . $line . ' ]',
|
||||
'RESULT' => '<b style="color:red">' . $error . '</b>',
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<!DOCTYPE html>';
|
||||
echo '<html dir="ltr">';
|
||||
echo '<head>';
|
||||
echo '<meta charset="utf-8">';
|
||||
echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
|
||||
echo '<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
|
||||
echo '</head>';
|
||||
echo '<body id="errorpage">';
|
||||
echo '<div id="wrap">';
|
||||
echo ' <div id="page-header">';
|
||||
echo ' </div>';
|
||||
echo ' <div id="page-body">';
|
||||
echo ' <div id="acp">';
|
||||
echo ' <div class="panel">';
|
||||
echo ' <span class="corners-top"><span></span></span>';
|
||||
echo ' <div id="content">';
|
||||
echo ' <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
|
||||
echo ' <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
|
||||
echo ' <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
|
||||
echo ' <p><b>' . $error . "</b></p>\n";
|
||||
echo ' </div>';
|
||||
echo ' <span class="corners-bottom"><span></span></span>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' </div>';
|
||||
echo ' <div id="page-footer">';
|
||||
echo ' Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Limited';
|
||||
echo ' </div>';
|
||||
echo '</div>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
|
||||
if (!empty($db) && is_object($db))
|
||||
{
|
||||
$db->sql_close();
|
||||
}
|
||||
|
||||
exit_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an error message for a database related problem
|
||||
* If skip is true, return and continue execution, else exit
|
||||
*/
|
||||
function db_error($error, $sql, $line, $file, $skip = false)
|
||||
{
|
||||
global $lang, $db, $template;
|
||||
|
||||
if ($skip)
|
||||
{
|
||||
$template->assign_block_vars('checks', array(
|
||||
'S_LEGEND' => true,
|
||||
'LEGEND' => $lang['INST_ERR_FATAL'],
|
||||
));
|
||||
|
||||
$template->assign_block_vars('checks', array(
|
||||
'TITLE' => basename($file) . ' [ ' . $line . ' ]',
|
||||
'RESULT' => '<b style="color:red">' . $error . '</b><br />» SQL:' . $sql,
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => 'install_error.html')
|
||||
);
|
||||
$this->page_header();
|
||||
$this->generate_navigation();
|
||||
|
||||
$template->assign_vars(array(
|
||||
'MESSAGE_TITLE' => $lang['INST_ERR_FATAL_DB'],
|
||||
'MESSAGE_TEXT' => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
|
||||
));
|
||||
|
||||
// Rollback if in transaction
|
||||
if ($db->get_transaction())
|
||||
{
|
||||
$db->sql_transaction('rollback');
|
||||
}
|
||||
|
||||
$this->page_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the relevant HTML for an input field and the associated label and explanatory text
|
||||
*/
|
||||
function input_field($name, $type, $value = '', $options = '')
|
||||
{
|
||||
global $lang;
|
||||
$tpl_type = explode(':', $type);
|
||||
$tpl = '';
|
||||
|
||||
switch ($tpl_type[0])
|
||||
{
|
||||
case 'text':
|
||||
case 'password':
|
||||
// HTML5 text-like input types
|
||||
case 'color':
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'datetime':
|
||||
case 'datetime-local':
|
||||
case 'email':
|
||||
case 'month':
|
||||
case 'number':
|
||||
case 'range':
|
||||
case 'search':
|
||||
case 'tel':
|
||||
case 'url':
|
||||
case 'week':
|
||||
|
||||
$size = (int) $tpl_type[1];
|
||||
$maxlength = (int) $tpl_type[2];
|
||||
$autocomplete = (isset($options['autocomplete']) && $options['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
|
||||
|
||||
$tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '"' . $autocomplete . ' value="' . $value . '" />';
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$rows = (int) $tpl_type[1];
|
||||
$cols = (int) $tpl_type[2];
|
||||
|
||||
$tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
$key_yes = ($value) ? ' checked="checked" id="' . $name . '"' : '';
|
||||
$key_no = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
|
||||
|
||||
$tpl_type_cond = explode('_', $tpl_type[1]);
|
||||
$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
|
||||
|
||||
$tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
|
||||
$tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
|
||||
|
||||
$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . ' ' . $tpl_no : $tpl_no . ' ' . $tpl_yes;
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
// @codingStandardsIgnoreStart
|
||||
eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
|
||||
break;
|
||||
|
||||
case 'custom':
|
||||
// @codingStandardsIgnoreStart
|
||||
eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
|
||||
// @codingStandardsIgnoreEnd
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the drop down of available language packs
|
||||
*/
|
||||
function inst_language_select($default = '')
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$dir = @opendir($phpbb_root_path . 'language');
|
||||
|
||||
if (!$dir)
|
||||
{
|
||||
$this->error('Unable to access the language directory', __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
while ($file = readdir($dir))
|
||||
{
|
||||
$path = $phpbb_root_path . 'language/' . $file;
|
||||
|
||||
if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($path . '/iso.txt'))
|
||||
{
|
||||
list($displayname, $localname) = @file($path . '/iso.txt');
|
||||
$lang[$localname] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
@asort($lang);
|
||||
@reset($lang);
|
||||
|
||||
$user_select = '';
|
||||
foreach ($lang as $displayname => $filename)
|
||||
{
|
||||
$selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
|
||||
$user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
|
||||
}
|
||||
|
||||
return $user_select;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,78 +0,0 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
if ( !defined('IN_INSTALL') )
|
||||
{
|
||||
// Someone has tried to access the file direct. This is not a good idea, so exit
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($setmodules))
|
||||
{
|
||||
$module[] = array(
|
||||
'module_type' => 'install',
|
||||
'module_title' => 'OVERVIEW',
|
||||
'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1),
|
||||
'module_order' => 0,
|
||||
'module_subs' => array('INTRO', 'LICENSE', 'SUPPORT'),
|
||||
'module_stages' => '',
|
||||
'module_reqs' => ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main Tab - Installation
|
||||
*/
|
||||
class install_main extends module
|
||||
{
|
||||
function install_main(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($mode, $sub)
|
||||
{
|
||||
global $lang, $template, $language;
|
||||
|
||||
switch ($sub)
|
||||
{
|
||||
case 'intro' :
|
||||
$title = $lang['SUB_INTRO'];
|
||||
$body = $lang['OVERVIEW_BODY'];
|
||||
break;
|
||||
|
||||
case 'license' :
|
||||
$title = $lang['GPL'];
|
||||
$body = implode("<br/>\n", file(__DIR__ . '/../docs/LICENSE.txt'));
|
||||
break;
|
||||
|
||||
case 'support' :
|
||||
$title = $lang['SUB_SUPPORT'];
|
||||
$body = $lang['SUPPORT_BODY'];
|
||||
break;
|
||||
}
|
||||
|
||||
$this->tpl_name = 'install_main';
|
||||
$this->page_title = $title;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TITLE' => $title,
|
||||
'BODY' => $body,
|
||||
|
||||
'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>',
|
||||
));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
44
phpBB/install/phpbbcli.php
Normal file
44
phpBB/install/phpbbcli.php
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env php
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli')
|
||||
{
|
||||
echo 'This program must be run from the command line.' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
define('IN_INSTALL', true);
|
||||
define('PHPBB_ENVIRONMENT', 'production');
|
||||
$phpbb_root_path = __DIR__ . '/../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
|
||||
//
|
||||
// Let's do the common.php logic
|
||||
//
|
||||
$startup_new_path = $phpbb_root_path . 'install/update/update/new/install/startup.' . $phpEx;
|
||||
$startup_path = (file_exists($startup_new_path)) ? $startup_new_path : $phpbb_root_path . 'install/startup.' . $phpEx;
|
||||
require($startup_path);
|
||||
|
||||
/** @var \phpbb\filesystem\filesystem $phpbb_filesystem */
|
||||
$phpbb_filesystem = $phpbb_installer_container->get('filesystem');
|
||||
|
||||
/** @var \phpbb\language\language $language */
|
||||
$language = $phpbb_installer_container->get('language');
|
||||
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting', 'cli'));
|
||||
|
||||
$application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language);
|
||||
$application->setDispatcher($phpbb_installer_container->get('dispatcher'));
|
||||
$application->register_container_commands($phpbb_installer_container->get('console.installer.command_collection'));
|
||||
$application->run($input);
|
@@ -1,14 +0,0 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
phpinfo();
|
84
phpBB/install/startup.php
Normal file
84
phpBB/install/startup.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @ignore */
|
||||
if (!defined('IN_PHPBB') || !defined('IN_INSTALL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
function phpbb_require_updated($path, $phpbb_root_path, $optional = false)
|
||||
{
|
||||
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
|
||||
$old_path = $phpbb_root_path . $path;
|
||||
|
||||
if (file_exists($new_path))
|
||||
{
|
||||
require($new_path);
|
||||
}
|
||||
else if (!$optional || file_exists($old_path))
|
||||
{
|
||||
require($old_path);
|
||||
}
|
||||
}
|
||||
|
||||
function phpbb_include_updated($path, $phpbb_root_path, $optional = false)
|
||||
{
|
||||
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
|
||||
$old_path = $phpbb_root_path . $path;
|
||||
|
||||
if (file_exists($new_path))
|
||||
{
|
||||
include($new_path);
|
||||
}
|
||||
else if (!$optional || file_exists($old_path))
|
||||
{
|
||||
include($old_path);
|
||||
}
|
||||
}
|
||||
|
||||
phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path);
|
||||
phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path);
|
||||
|
||||
$phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
|
||||
$phpbb_class_loader_new->register();
|
||||
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
||||
$phpbb_class_loader_ext->register();
|
||||
|
||||
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
|
||||
$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
|
||||
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
|
||||
|
||||
// Include files
|
||||
phpbb_require_updated('includes/functions.' . $phpEx, $phpbb_root_path);
|
||||
phpbb_require_updated('includes/functions_content.' . $phpEx, $phpbb_root_path);
|
||||
phpbb_include_updated('includes/functions_compatibility.' . $phpEx, $phpbb_root_path);
|
||||
phpbb_require_updated('includes/functions_user.' . $phpEx, $phpbb_root_path);
|
||||
phpbb_require_updated('includes/utf/utf_tools.' . $phpEx, $phpbb_root_path);
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
$phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
|
||||
$phpbb_installer_container_builder
|
||||
->with_environment('installer')
|
||||
->without_extensions();
|
||||
|
||||
$other_config_path = $phpbb_root_path . 'install/update/new/config';
|
||||
$config_path = (file_exists($other_config_path . '/installer/config.yml')) ? $other_config_path : $phpbb_root_path . 'config';
|
||||
|
||||
$phpbb_installer_container = $phpbb_installer_container_builder
|
||||
->with_config_path($config_path)
|
||||
->get_container();
|
Reference in New Issue
Block a user