mirror of
				https://github.com/phpbb/phpbb.git
				synced 2025-10-23 04:36:15 +02:00 
			
		
		
		
	* upstream/develop: (35 commits) [ticket/10730] Added label tag around "select" text in post splitting UI [ticket/10732] Add config_dev.php and config_test.php to .gitignore [ticket/10586] Added space in if statement [ticket/10586] Tidy up comments [task/php5.3] Updated range of tested PHP versions [task/php5.3] Looks like I missed a few places that needed PHP 5.2 changed to PHP 5.3.2 [task/php5.3] Changed minimum PHP requirement for Ascraeus to 5.3.2 [ticket/10129] Remove apostrophes and plurals in ACP user management -> permissions language file as per ticket. [ticket/10703] Added a condition to check if ext directory exists [ticket/10708] Check converted passwords for multi-byte characters [ticket/10586] Tests finally work (thanks naderman) [ticket/10586] Correctly purge board cache and don't rename install directory [ticket/10586] trying to get tests to work [ticket/10586] more work on getting tests to pass [ticket/10586] Tests are coming along, just a little more to go [ticket/10586] Rename install directory back to install/ after tests [ticket/10586] browse tests now work, but mine dont. at least we are making progress [ticket/10586] initial work on copying fixtures. Note that this depends on 10706 [ticket/10586] Adding the extensions used by the tests [ticket/10586] Now tests run, but fail. But here is what I have. ...
		
			
				
	
	
		
			743 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			743 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
| *
 | |
| * @package install
 | |
| * @copyright (c) 2005 phpBB Group
 | |
| * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
 | |
| *
 | |
| */
 | |
| 
 | |
| /**#@+
 | |
| * @ignore
 | |
| */
 | |
| define('IN_PHPBB', true);
 | |
| define('IN_INSTALL', true);
 | |
| /**#@-*/
 | |
| 
 | |
| $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
 | |
| $phpEx = substr(strrchr(__FILE__, '.'), 1);
 | |
| 
 | |
| if (version_compare(PHP_VERSION, '5.3.2') < 0)
 | |
| {
 | |
| 	die('You are running an unsupported PHP version. Please upgrade to PHP 5.3.2 or higher before trying to install phpBB 3.1');
 | |
| }
 | |
| 
 | |
| function phpbb_require_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))
 | |
| 	{
 | |
| 		require($new_path);
 | |
| 	}
 | |
| 	else if (!$optional || file_exists($old_path))
 | |
| 	{
 | |
| 		require($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);
 | |
| 
 | |
| // Include essential scripts
 | |
| require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
 | |
| require($phpbb_root_path . 'includes/functions.' . $phpEx);
 | |
| 
 | |
| phpbb_require_updated('includes/functions_content.' . $phpEx, true);
 | |
| 
 | |
| include($phpbb_root_path . 'includes/auth.' . $phpEx);
 | |
| include($phpbb_root_path . 'includes/session.' . $phpEx);
 | |
| include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
 | |
| include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
 | |
| require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
 | |
| 
 | |
| $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
 | |
| $phpbb_class_loader_ext->register();
 | |
| $phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
 | |
| $phpbb_class_loader->register();
 | |
| 
 | |
| // set up caching
 | |
| $cache_factory = new phpbb_cache_factory('file');
 | |
| $cache = $cache_factory->get_service();
 | |
| $phpbb_class_loader_ext->set_cache($cache->get_driver());
 | |
| $phpbb_class_loader->set_cache($cache->get_driver());
 | |
| 
 | |
| $phpbb_dispatcher = new phpbb_event_dispatcher();
 | |
| $request = new phpbb_request();
 | |
| 
 | |
| // make sure request_var uses this request instance
 | |
| request_var('', 0, false, false, $request); // "dependency injection" for a function
 | |
| 
 | |
| // Try and load an appropriate language if required
 | |
| $language = basename(request_var('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
 | |
| include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx);
 | |
| include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx);
 | |
| include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx);
 | |
| include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
 | |
| include($phpbb_root_path . 'language/' . $language . '/posting.' . $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_var('mode', 'overview');
 | |
| $sub = request_var('sub', '');
 | |
| 
 | |
| // Set PHP error handler to ours
 | |
| set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
 | |
| 
 | |
| $user = new user();
 | |
| $auth = new 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')));
 | |
| 
 | |
| 	foreach ($cache->obtain_hooks() 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(array(
 | |
| 	'load_tplcompile'	=> '1'
 | |
| ));
 | |
| 
 | |
| $phpbb_template_locator = new phpbb_template_locator();
 | |
| $phpbb_template_path_provider = new phpbb_template_path_provider();
 | |
| $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider);
 | |
| $template->set_ext_dir_prefix('adm/');
 | |
| $template->set_custom_template('../adm/style', 'admin');
 | |
| $template->assign_var('T_ASSETS_PATH', '../assets');
 | |
| $template->assign_var('T_TEMPLATE_PATH', '../adm/style');
 | |
| 
 | |
| $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();
 | |
| 
 | |
| /**
 | |
| * @package install
 | |
| */
 | |
| 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_root_path;
 | |
| 
 | |
| 		$template->assign_vars(array(
 | |
| 			'L_CHANGE'				=> $lang['CHANGE'],
 | |
| 			'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'			=> $phpbb_root_path . 'adm/images/',
 | |
| 
 | |
| 			'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: 0');
 | |
| 		header('Pragma: no-cache');
 | |
| 
 | |
| 		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;
 | |
| 
 | |
| 		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="../adm/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="http://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group';
 | |
| 		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->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':
 | |
| 				$size = (int) $tpl_type[1];
 | |
| 				$maxlength = (int) $tpl_type[2];
 | |
| 
 | |
| 				$tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" 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':
 | |
| 				eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
 | |
| 				$tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
 | |
| 			break;
 | |
| 
 | |
| 			case 'custom':
 | |
| 				eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
 | |
| 			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;
 | |
| 	}
 | |
| }
 |