|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
*
|
|
|
f2e824 |
* @package install
|
|
|
f2e824 |
* @version $Id: index.php 8895 2008-09-19 16:54:03Z acydburn $
|
|
|
f2e824 |
* @copyright (c) 2005 phpBB Group
|
|
|
f2e824 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
f2e824 |
*
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
|
|
|
f2e824 |
/**#@+
|
|
|
f2e824 |
* @ignore
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
define('IN_PHPBB', true);
|
|
|
f2e824 |
define('IN_INSTALL', true);
|
|
|
f2e824 |
/**#@-*/
|
|
|
f2e824 |
|
|
|
f2e824 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
|
|
|
f2e824 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Report all errors, except notices
|
|
|
f2e824 |
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
f2e824 |
|
|
|
f2e824 |
// @todo Review this test and see if we can find out what it is which prevents PHP 4.2.x from even displaying the page with requirements on it
|
|
|
f2e824 |
if (version_compare(PHP_VERSION, '4.3.3') < 0)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to install phpBB 3.0');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/*
|
|
|
f2e824 |
* Remove variables created by register_globals from the global scope
|
|
|
f2e824 |
* Thanks to Matt Kavanagh
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function deregister_globals()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$not_unset = array(
|
|
|
f2e824 |
'GLOBALS' => true,
|
|
|
f2e824 |
'_GET' => true,
|
|
|
f2e824 |
'_POST' => true,
|
|
|
f2e824 |
'_COOKIE' => true,
|
|
|
f2e824 |
'_REQUEST' => true,
|
|
|
f2e824 |
'_SERVER' => true,
|
|
|
f2e824 |
'_SESSION' => true,
|
|
|
f2e824 |
'_ENV' => true,
|
|
|
f2e824 |
'_FILES' => true,
|
|
|
f2e824 |
'phpEx' => true,
|
|
|
f2e824 |
'phpbb_root_path' => true
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Not only will array_merge and array_keys give a warning if
|
|
|
f2e824 |
// a parameter is not an array, array_merge will actually fail.
|
|
|
f2e824 |
// So we check if _SESSION has been initialised.
|
|
|
f2e824 |
if (!isset($_SESSION) || !is_array($_SESSION))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$_SESSION = array();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Merge all into one extremely huge array; unset this later
|
|
|
f2e824 |
$input = array_merge(
|
|
|
f2e824 |
array_keys($_GET),
|
|
|
f2e824 |
array_keys($_POST),
|
|
|
f2e824 |
array_keys($_COOKIE),
|
|
|
f2e824 |
array_keys($_SERVER),
|
|
|
f2e824 |
array_keys($_SESSION),
|
|
|
f2e824 |
array_keys($_ENV),
|
|
|
f2e824 |
array_keys($_FILES)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($input as $varname)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (isset($not_unset[$varname]))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Hacking attempt. No point in continuing unless it's a COOKIE
|
|
|
f2e824 |
if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
exit;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$cookie = &$_COOKIE;
|
|
|
f2e824 |
while (isset($cookie['GLOBALS']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
foreach ($cookie['GLOBALS'] as $registered_var => $value)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!isset($not_unset[$registered_var]))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
unset($GLOBALS[$registered_var]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$cookie = &$cookie['GLOBALS'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
unset($GLOBALS[$varname]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
unset($input);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// If we are on PHP >= 6.0.0 we do not need some code
|
|
|
f2e824 |
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* @ignore
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
define('STRIP', false);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
@set_magic_quotes_runtime(0);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Be paranoid with passed vars
|
|
|
f2e824 |
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
deregister_globals();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Try to override some limits - maybe it helps some...
|
|
|
f2e824 |
@set_time_limit(0);
|
|
|
f2e824 |
$mem_limit = @ini_get('memory_limit');
|
|
|
f2e824 |
if (!empty($mem_limit))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$unit = strtolower(substr($mem_limit, -1, 1));
|
|
|
f2e824 |
$mem_limit = (int) $mem_limit;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($unit == 'k')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$mem_limit = floor($mem_limit / 1024);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if ($unit == 'g')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$mem_limit *= 1024;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if (is_numeric($unit))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$mem_limit = max(128, $mem_limit) . 'M';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$mem_limit = '128M';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
@ini_set('memory_limit', $mem_limit);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Include essential scripts
|
|
|
f2e824 |
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/auth.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/session.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/template.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/cache.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
|
|
f2e824 |
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Try and load an appropriate language if required
|
|
|
f2e824 |
$language = basename(request_var('language', ''));
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$language)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$accept_lang_ary = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
|
|
|
f2e824 |
foreach ($accept_lang_ary as $accept_lang)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Set correct format ... guess full xx_yy form
|
|
|
f2e824 |
$accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$language = $accept_lang;
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// No match on xx_yy so try xx
|
|
|
f2e824 |
$accept_lang = substr($accept_lang, 0, 2);
|
|
|
f2e824 |
if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$language = $accept_lang;
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// No appropriate language found ... so let's use the first one in the language
|
|
|
f2e824 |
// dir, this may or may not be English
|
|
|
f2e824 |
if (!$language)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$dir = @opendir($phpbb_root_path . 'language');
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$dir)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
die('Unable to access the language directory');
|
|
|
f2e824 |
exit;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
while (($file = readdir($dir)) !== false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$path = $phpbb_root_path . 'language/' . $file;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$language = $file;
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
closedir($dir);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!file_exists($phpbb_root_path . 'language/' . $language))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
die('No language found!');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// And finally, load the relevant language files
|
|
|
f2e824 |
include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
|
|
|
f2e824 |
|
|
|
f2e824 |
// Define needed constants
|
|
|
f2e824 |
define('CHMOD_ALL', 7);
|
|
|
f2e824 |
define('CHMOD_READ', 4);
|
|
|
f2e824 |
define('CHMOD_WRITE', 2);
|
|
|
f2e824 |
define('CHMOD_EXECUTE', 1);
|
|
|
f2e824 |
|
|
|
f2e824 |
$mode = request_var('mode', 'overview');
|
|
|
f2e824 |
$sub = request_var('sub', '');
|
|
|
f2e824 |
|
|
|
f2e824 |
// Set PHP error handler to ours
|
|
|
f2e824 |
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
|
|
f2e824 |
|
|
|
f2e824 |
$user = new user();
|
|
|
f2e824 |
$auth = new auth();
|
|
|
f2e824 |
$cache = new cache();
|
|
|
f2e824 |
$template = new template();
|
|
|
f2e824 |
|
|
|
f2e824 |
// Add own hook handler, if present. :o
|
|
|
f2e824 |
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
|
|
f2e824 |
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($cache->obtain_hooks() as $hook)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$phpbb_hook = false;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Set some standard variables we want to force
|
|
|
f2e824 |
$config = array(
|
|
|
f2e824 |
'load_tplcompile' => '1'
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_custom_template('../adm/style', 'admin');
|
|
|
f2e824 |
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
|
|
|
f2e824 |
|
|
|
f2e824 |
// the acp template is never stored in the database
|
|
|
f2e824 |
$user->theme['template_storedb'] = false;
|
|
|
f2e824 |
|
|
|
f2e824 |
$install = new module();
|
|
|
f2e824 |
|
|
|
f2e824 |
$install->create('install', "index.$phpEx", $mode, $sub);
|
|
|
f2e824 |
$install->load();
|
|
|
f2e824 |
|
|
|
f2e824 |
// Generate the page
|
|
|
f2e824 |
$install->page_header();
|
|
|
f2e824 |
$install->generate_navigation();
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_filenames(array(
|
|
|
f2e824 |
'body' => $install->get_tpl_name())
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$install->page_footer();
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* @package install
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
class module
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var $id = 0;
|
|
|
f2e824 |
var $type = 'install';
|
|
|
f2e824 |
var $module_ary = array();
|
|
|
f2e824 |
var $filename;
|
|
|
f2e824 |
var $module_url = '';
|
|
|
f2e824 |
var $tpl_name = '';
|
|
|
f2e824 |
var $mode;
|
|
|
f2e824 |
var $sub;
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Private methods, should not be overwritten
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $db, $config, $phpEx, $phpbb_root_path;
|
|
|
f2e824 |
|
|
|
f2e824 |
$module = array();
|
|
|
f2e824 |
|
|
|
f2e824 |
// Grab module information using Bart's "neat-o-module" system (tm)
|
|
|
f2e824 |
$dir = @opendir('.');
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$dir)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->error('Unable to access the installation directory', __LINE__, __FILE__);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$setmodules = 1;
|
|
|
f2e824 |
while (($file = readdir($dir)) !== false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
include($file);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
closedir($dir);
|
|
|
f2e824 |
|
|
|
f2e824 |
unset($setmodules);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!sizeof($module))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->error('No installation modules found', __LINE__, __FILE__);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Order to use and count further if modules get assigned to the same position or not having an order
|
|
|
f2e824 |
$max_module_order = 1000;
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($module as $row)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Module order not specified or module already assigned at this position?
|
|
|
f2e824 |
if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$row['module_order'] = $max_module_order;
|
|
|
f2e824 |
$max_module_order++;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$this->module_ary[$row['module_order']]['name'] = $row['module_title'];
|
|
|
f2e824 |
$this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
|
|
|
f2e824 |
$this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
|
|
|
f2e824 |
$this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
|
|
|
f2e824 |
|
|
|
f2e824 |
if (strtolower($selected_mod) == strtolower($row['module_title']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->id = (int) $row['module_order'];
|
|
|
f2e824 |
$this->filename = (string) $row['module_filename'];
|
|
|
f2e824 |
$this->module_url = (string) $module_url;
|
|
|
f2e824 |
$this->mode = (string) $selected_mod;
|
|
|
f2e824 |
// Check that the sub-mode specified is valid or set a default if not
|
|
|
f2e824 |
if (is_array($row['module_subs']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if (is_array($row['module_stages']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->sub = '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
} // END foreach
|
|
|
f2e824 |
} // END create
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Load and run the relevant module if applicable
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function load($mode = false, $run = true)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $phpbb_root_path, $phpEx;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($run)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!empty($mode))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->mode = $mode;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$module = $this->filename;
|
|
|
f2e824 |
if (!class_exists($module))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$this->module = new $module($this);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (method_exists($this->module, 'main'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->module->main($this->mode, $this->sub);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Output the standard page header
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function page_header()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (defined('HEADER_INC'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
define('HEADER_INC', true);
|
|
|
f2e824 |
global $template, $lang, $stage, $phpbb_root_path;
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'L_CHANGE' => $lang['CHANGE'],
|
|
|
f2e824 |
'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
|
|
|
f2e824 |
'L_SELECT_LANG' => $lang['SELECT_LANG'],
|
|
|
f2e824 |
'L_SKIP' => $lang['SKIP'],
|
|
|
f2e824 |
'PAGE_TITLE' => $this->get_page_title(),
|
|
|
f2e824 |
'T_IMAGE_PATH' => $phpbb_root_path . 'adm/images/',
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
|
|
|
f2e824 |
'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
|
|
|
f2e824 |
'S_CONTENT_FLOW_END' => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
|
|
f2e824 |
'S_CONTENT_ENCODING' => 'UTF-8',
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_USER_LANG' => $lang['USER_LANG'],
|
|
|
f2e824 |
)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
header('Content-type: text/html; charset=UTF-8');
|
|
|
f2e824 |
header('Cache-Control: private, no-cache="set-cookie"');
|
|
|
f2e824 |
header('Expires: 0');
|
|
|
f2e824 |
header('Pragma: no-cache');
|
|
|
f2e824 |
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Output the standard page footer
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function page_footer()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $db, $template;
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->display('body');
|
|
|
f2e824 |
|
|
|
f2e824 |
// Close our DB connection.
|
|
|
f2e824 |
if (!empty($db) && is_object($db))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$db->sql_close();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (function_exists('exit_handler'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
exit_handler();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Returns desired template name
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function get_tpl_name()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return $this->module->tpl_name . '.html';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Returns the desired page title
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function get_page_title()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $lang;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!isset($this->module->page_title))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Generate an HTTP/1.1 header to redirect the user to another page
|
|
|
f2e824 |
* This is used during the installation when we do not have a database available to call the normal redirect function
|
|
|
f2e824 |
* @param string $page The page to redirect to relative to the installer root path
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function redirect($page)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// HTTP_HOST is having the correct browser url in most cases...
|
|
|
f2e824 |
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
|
|
|
f2e824 |
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
|
|
|
f2e824 |
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
|
|
|
f2e824 |
|
|
|
f2e824 |
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
|
|
|
f2e824 |
if (!$script_name)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Replace backslashes and doubled slashes (could happen on some proxy setups)
|
|
|
f2e824 |
$script_name = str_replace(array('\\', '//'), '/', $script_name);
|
|
|
f2e824 |
$script_path = trim(dirname($script_name));
|
|
|
f2e824 |
|
|
|
f2e824 |
$url = (($secure) ? 'https://' : 'http://') . $server_name;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// HTTP HOST can carry a port number...
|
|
|
f2e824 |
if (strpos($server_name, ':') === false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$url .= ':' . $server_port;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$url .= $script_path . '/' . $page;
|
|
|
f2e824 |
header('Location: ' . $url);
|
|
|
f2e824 |
exit;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Generate the navigation tabs
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function generate_navigation()
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $lang, $template, $phpEx, $language;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (is_array($this->module_ary))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
@ksort($this->module_ary);
|
|
|
f2e824 |
foreach ($this->module_ary as $cat_ary)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$cat = $cat_ary['name'];
|
|
|
f2e824 |
$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
|
|
|
f2e824 |
$cat = strtolower($cat);
|
|
|
f2e824 |
$url = $this->module_url . "?mode=$cat&language=$language";
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($this->mode == $cat)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('t_block1', array(
|
|
|
f2e824 |
'L_TITLE' => $l_cat,
|
|
|
f2e824 |
'S_SELECTED' => true,
|
|
|
f2e824 |
'U_TITLE' => $url,
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
if (is_array($this->module_ary[$this->id]['subs']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$subs = $this->module_ary[$this->id]['subs'];
|
|
|
f2e824 |
foreach ($subs as $option)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
|
|
|
f2e824 |
$option = strtolower($option);
|
|
|
f2e824 |
$url = $this->module_url . '?mode=' . $this->mode . "&sub=$option&language=$language";
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_block_vars('l_block1', array(
|
|
|
f2e824 |
'L_TITLE' => $l_option,
|
|
|
f2e824 |
'S_SELECTED' => ($this->sub == $option),
|
|
|
f2e824 |
'U_TITLE' => $url,
|
|
|
f2e824 |
));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (is_array($this->module_ary[$this->id]['stages']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$subs = $this->module_ary[$this->id]['stages'];
|
|
|
f2e824 |
$matched = false;
|
|
|
f2e824 |
foreach ($subs as $option)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
|
|
|
f2e824 |
$option = strtolower($option);
|
|
|
f2e824 |
$matched = ($this->sub == $option) ? true : $matched;
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_block_vars('l_block2', array(
|
|
|
f2e824 |
'L_TITLE' => $l_option,
|
|
|
f2e824 |
'S_SELECTED' => ($this->sub == $option),
|
|
|
f2e824 |
'S_COMPLETE' => !$matched,
|
|
|
f2e824 |
));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('t_block1', array(
|
|
|
f2e824 |
'L_TITLE' => $l_cat,
|
|
|
f2e824 |
'S_SELECTED' => false,
|
|
|
f2e824 |
'U_TITLE' => $url,
|
|
|
f2e824 |
));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Output an error message
|
|
|
f2e824 |
* If skip is true, return and continue execution, else exit
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function error($error, $line, $file, $skip = false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $lang, $db, $template;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($skip)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('checks', array(
|
|
|
f2e824 |
'S_LEGEND' => true,
|
|
|
f2e824 |
'LEGEND' => $lang['INST_ERR'],
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_block_vars('checks', array(
|
|
|
f2e824 |
'TITLE' => basename($file) . ' [ ' . $line . ' ]',
|
|
|
f2e824 |
'RESULT' => '' . $error . '',
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
echo '';
|
|
|
f2e824 |
echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
|
|
|
f2e824 |
echo '<head>';
|
|
|
f2e824 |
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
|
|
|
f2e824 |
echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
|
|
|
f2e824 |
echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
|
|
|
f2e824 |
echo '</head>';
|
|
|
f2e824 |
echo '<body id="errorpage">';
|
|
|
f2e824 |
echo '';
|
|
|
f2e824 |
echo '
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ' . $lang['INST_ERR_FATAL'] . '';
|
|
|
f2e824 |
echo ' ' . $lang['INST_ERR_FATAL'] . " \n";
|
|
|
f2e824 |
echo ' ' . basename($file) . ' [ ' . $line . " ] \n";
|
|
|
f2e824 |
echo ' ' . $error . " \n";
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo '
|
|
|
f2e824 |
echo ' Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group';
|
|
|
f2e824 |
echo ' ';
|
|
|
f2e824 |
echo '';
|
|
|
f2e824 |
echo '</body>';
|
|
|
f2e824 |
echo '</html>';
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!empty($db) && is_object($db))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$db->sql_close();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
exit_handler();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Output an error message for a database related problem
|
|
|
f2e824 |
* If skip is true, return and continue execution, else exit
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function db_error($error, $sql, $line, $file, $skip = false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $lang, $db, $template;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($skip)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('checks', array(
|
|
|
f2e824 |
'S_LEGEND' => true,
|
|
|
f2e824 |
'LEGEND' => $lang['INST_ERR_FATAL'],
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_block_vars('checks', array(
|
|
|
f2e824 |
'TITLE' => basename($file) . ' [ ' . $line . ' ]',
|
|
|
f2e824 |
'RESULT' => '' . $error . ' » SQL:' . $sql,
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_filenames(array(
|
|
|
f2e824 |
'body' => 'install_error.html')
|
|
|
f2e824 |
);
|
|
|
f2e824 |
$this->page_header();
|
|
|
f2e824 |
$this->generate_navigation();
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'MESSAGE_TITLE' => $lang['INST_ERR_FATAL_DB'],
|
|
|
f2e824 |
'MESSAGE_TEXT' => '' . basename($file) . ' [ ' . $line . ' ] SQL : ' . $sql . ' ' . $error . ' ',
|
|
|
f2e824 |
));
|
|
|
f2e824 |
|
|
|
f2e824 |
// Rollback if in transaction
|
|
|
f2e824 |
if ($db->transaction)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$db->sql_transaction('rollback');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$this->page_footer();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Generate the relevant HTML for an input field and the associated label and explanatory text
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function input_field($name, $type, $value='', $options='')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $lang;
|
|
|
f2e824 |
$tpl_type = explode(':', $type);
|
|
|
f2e824 |
$tpl = '';
|
|
|
f2e824 |
|
|
|
f2e824 |
switch ($tpl_type[0])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
case 'text':
|
|
|
f2e824 |
case 'password':
|
|
|
f2e824 |
$size = (int) $tpl_type[1];
|
|
|
f2e824 |
$maxlength = (int) $tpl_type[2];
|
|
|
f2e824 |
|
|
|
f2e824 |
$tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $value . '" />';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'textarea':
|
|
|
f2e824 |
$rows = (int) $tpl_type[1];
|
|
|
f2e824 |
$cols = (int) $tpl_type[2];
|
|
|
f2e824 |
|
|
|
f2e824 |
$tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'radio':
|
|
|
f2e824 |
$key_yes = ($value) ? ' checked="checked" id="' . $name . '"' : '';
|
|
|
f2e824 |
$key_no = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
$tpl_type_cond = explode('_', $tpl_type[1]);
|
|
|
f2e824 |
$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
|
|
|
f2e824 |
|
|
|
f2e824 |
$tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
|
|
|
f2e824 |
$tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
|
|
|
f2e824 |
|
|
|
f2e824 |
$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . ' ' . $tpl_no : $tpl_no . ' ' . $tpl_yes;
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'select':
|
|
|
f2e824 |
eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
|
|
|
f2e824 |
$tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'custom':
|
|
|
f2e824 |
eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
default:
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
return $tpl;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Generate the drop down of available language packs
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function inst_language_select($default = '')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $phpbb_root_path, $phpEx;
|
|
|
f2e824 |
|
|
|
f2e824 |
$dir = @opendir($phpbb_root_path . 'language');
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$dir)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$this->error('Unable to access the language directory', __LINE__, __FILE__);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
while ($file = readdir($dir))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$path = $phpbb_root_path . 'language/' . $file;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
continue;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (file_exists($path . '/iso.txt'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
list($displayname, $localname) = @file($path . '/iso.txt');
|
|
|
f2e824 |
$lang[$localname] = $file;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
closedir($dir);
|
|
|
f2e824 |
|
|
|
f2e824 |
@asort($lang);
|
|
|
f2e824 |
@reset($lang);
|
|
|
f2e824 |
|
|
|
f2e824 |
$user_select = '';
|
|
|
f2e824 |
foreach ($lang as $displayname => $filename)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
|
|
|
f2e824 |
$user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
return $user_select;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
?>
|