Blame Identity/Models/Html/phpBB/3.0.4/adm/index.php

d6e8d8
d6e8d8
/**
d6e8d8
*
d6e8d8
* @package acp
d6e8d8
* @version $Id: index.php 8591 2008-06-04 11:40:53Z Kellanved $
d6e8d8
* @copyright (c) 2005 phpBB Group
d6e8d8
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
d6e8d8
*
d6e8d8
*/
d6e8d8
d6e8d8
/**
d6e8d8
*/
d6e8d8
define('IN_PHPBB', true);
d6e8d8
define('ADMIN_START', true);
d6e8d8
define('NEED_SID', true);
d6e8d8
d6e8d8
// Include files
d6e8d8
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
d6e8d8
$phpEx = substr(strrchr(__FILE__, '.'), 1);
d6e8d8
require($phpbb_root_path . 'common.' . $phpEx);
d6e8d8
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
d6e8d8
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
d6e8d8
d6e8d8
// Start session management
d6e8d8
$user->session_begin();
d6e8d8
$auth->acl($user->data);
d6e8d8
$user->setup('acp/common');
d6e8d8
// End session management
d6e8d8
d6e8d8
// Have they authenticated (again) as an admin for this session?
d6e8d8
if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
d6e8d8
{
d6e8d8
	login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
d6e8d8
}
d6e8d8
d6e8d8
// Is user any type of admin? No, then stop here, each script needs to
d6e8d8
// check specific permissions but this is a catchall
d6e8d8
if (!$auth->acl_get('a_'))
d6e8d8
{
d6e8d8
	trigger_error('NO_ADMIN');
d6e8d8
}
d6e8d8
d6e8d8
// We define the admin variables now, because the user is now able to use the admin related features...
d6e8d8
define('IN_ADMIN', true);
d6e8d8
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
d6e8d8
d6e8d8
// Some oft used variables
d6e8d8
$safe_mode		= (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false;
d6e8d8
$file_uploads	= (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on') ? true : false;
d6e8d8
$module_id		= request_var('i', '');
d6e8d8
$mode			= request_var('mode', '');
d6e8d8
d6e8d8
// Set custom template for admin area
d6e8d8
$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
d6e8d8
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
d6e8d8
d6e8d8
// the acp template is never stored in the database
d6e8d8
$user->theme['template_storedb'] = false;
d6e8d8
d6e8d8
// Instantiate new module
d6e8d8
$module = new p_master();
d6e8d8
d6e8d8
// Instantiate module system and generate list of available modules
d6e8d8
$module->list_modules('acp');
d6e8d8
d6e8d8
// Select the active module
d6e8d8
$module->set_active($module_id, $mode);
d6e8d8
d6e8d8
// Assign data to the template engine for the list of modules
d6e8d8
// We do this before loading the active module for correct menu display in trigger_error
d6e8d8
$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx"));
d6e8d8
d6e8d8
// Load and execute the relevant module
d6e8d8
$module->load_active();
d6e8d8
d6e8d8
// Generate the page
d6e8d8
adm_page_header($module->get_page_title());
d6e8d8
d6e8d8
$template->set_filenames(array(
d6e8d8
	'body' => $module->get_tpl_name(),
d6e8d8
));
d6e8d8
d6e8d8
adm_page_footer();
d6e8d8
d6e8d8
/**
d6e8d8
* Header for acp pages
d6e8d8
*/
d6e8d8
function adm_page_header($page_title)
d6e8d8
{
d6e8d8
	global $config, $db, $user, $template;
d6e8d8
	global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
d6e8d8
d6e8d8
	if (defined('HEADER_INC'))
d6e8d8
	{
d6e8d8
		return;
d6e8d8
	}
d6e8d8
d6e8d8
	define('HEADER_INC', true);
d6e8d8
d6e8d8
	// gzip_compression
d6e8d8
	if ($config['gzip_compress'])
d6e8d8
	{
d6e8d8
		if (@extension_loaded('zlib') && !headers_sent())
d6e8d8
		{
d6e8d8
			ob_start('ob_gzhandler');
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	$template->assign_vars(array(
d6e8d8
		'PAGE_TITLE'			=> $page_title,
d6e8d8
		'USERNAME'				=> $user->data['username'],
d6e8d8
d6e8d8
		'SID'					=> $SID,
d6e8d8
		'_SID'					=> $_SID,
d6e8d8
		'SESSION_ID'			=> $user->session_id,
d6e8d8
		'ROOT_PATH'				=> $phpbb_admin_path,
d6e8d8
d6e8d8
		'U_LOGOUT'				=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
d6e8d8
		'U_ADM_LOGOUT'			=> append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'),
d6e8d8
		'U_ADM_INDEX'			=> append_sid("{$phpbb_admin_path}index.$phpEx"),
d6e8d8
		'U_INDEX'				=> append_sid("{$phpbb_root_path}index.$phpEx"),
d6e8d8
d6e8d8
		'T_IMAGES_PATH'			=> "{$phpbb_root_path}images/",
d6e8d8
		'T_SMILIES_PATH'		=> "{$phpbb_root_path}{$config['smilies_path']}/",
d6e8d8
		'T_AVATAR_PATH'			=> "{$phpbb_root_path}{$config['avatar_path']}/",
d6e8d8
		'T_AVATAR_GALLERY_PATH'	=> "{$phpbb_root_path}{$config['avatar_gallery_path']}/",
d6e8d8
		'T_ICONS_PATH'			=> "{$phpbb_root_path}{$config['icons_path']}/",
d6e8d8
		'T_RANKS_PATH'			=> "{$phpbb_root_path}{$config['ranks_path']}/",
d6e8d8
		'T_UPLOAD_PATH'			=> "{$phpbb_root_path}{$config['upload_path']}/",
d6e8d8
d6e8d8
		'ICON_MOVE_UP'				=> '' . $user->lang['MOVE_UP'] . '',
d6e8d8
		'ICON_MOVE_UP_DISABLED'		=> '' . $user->lang['MOVE_UP'] . '',
d6e8d8
		'ICON_MOVE_DOWN'			=> '' . $user->lang['MOVE_DOWN'] . '',
d6e8d8
		'ICON_MOVE_DOWN_DISABLED'	=> '' . $user->lang['MOVE_DOWN'] . '',		
d6e8d8
		'ICON_EDIT'					=> '' . $user->lang['EDIT'] . '',
d6e8d8
		'ICON_EDIT_DISABLED'		=> '' . $user->lang['EDIT'] . '',
d6e8d8
		'ICON_DELETE'				=> '' . $user->lang['DELETE'] . '',
d6e8d8
		'ICON_DELETE_DISABLED'		=> '' . $user->lang['DELETE'] . '',
d6e8d8
		'ICON_SYNC'					=> '' . $user->lang['RESYNC'] . '',
d6e8d8
		'ICON_SYNC_DISABLED'		=> '' . $user->lang['RESYNC'] . '',
d6e8d8
d6e8d8
		'S_USER_LANG'			=> $user->lang['USER_LANG'],
d6e8d8
		'S_CONTENT_DIRECTION'	=> $user->lang['DIRECTION'],
d6e8d8
		'S_CONTENT_ENCODING'	=> 'UTF-8',
d6e8d8
		'S_CONTENT_FLOW_BEGIN'	=> ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
d6e8d8
		'S_CONTENT_FLOW_END'	=> ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
d6e8d8
	));
d6e8d8
d6e8d8
	// application/xhtml+xml not used because of IE
d6e8d8
	header('Content-type: text/html; charset=UTF-8');
d6e8d8
d6e8d8
	header('Cache-Control: private, no-cache="set-cookie"');
d6e8d8
	header('Expires: 0');
d6e8d8
	header('Pragma: no-cache');
d6e8d8
d6e8d8
	return;
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Page footer for acp pages
d6e8d8
*/
d6e8d8
function adm_page_footer($copyright_html = true)
d6e8d8
{
d6e8d8
	global $db, $config, $template, $user, $auth, $cache;
d6e8d8
	global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
d6e8d8
d6e8d8
	// Output page creation time
d6e8d8
	if (defined('DEBUG'))
d6e8d8
	{
d6e8d8
		$mtime = explode(' ', microtime());
d6e8d8
		$totaltime = $mtime[0] + $mtime[1] - $starttime;
d6e8d8
d6e8d8
		if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
d6e8d8
		{
d6e8d8
			$db->sql_report('display');
d6e8d8
		}
d6e8d8
d6e8d8
		$debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
d6e8d8
d6e8d8
		if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
d6e8d8
		{
d6e8d8
			if (function_exists('memory_get_usage'))
d6e8d8
			{
d6e8d8
				if ($memory_usage = memory_get_usage())
d6e8d8
				{
d6e8d8
					global $base_memory_usage;
d6e8d8
					$memory_usage -= $base_memory_usage;
d6e8d8
					$memory_usage = get_formatted_filesize($memory_usage);
d6e8d8
d6e8d8
					$debug_output .= ' | Memory Usage: ' . $memory_usage;
d6e8d8
				}
d6e8d8
			}
d6e8d8
d6e8d8
			$debug_output .= ' | Explain';
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	$template->assign_vars(array(
d6e8d8
		'DEBUG_OUTPUT'		=> (defined('DEBUG')) ? $debug_output : '',
d6e8d8
		'TRANSLATION_INFO'	=> (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
d6e8d8
		'S_COPYRIGHT_HTML'	=> $copyright_html,
d6e8d8
		'VERSION'			=> $config['version'])
d6e8d8
	);
d6e8d8
d6e8d8
	$template->display('body');
d6e8d8
d6e8d8
	garbage_collection();
d6e8d8
	exit_handler();
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Generate back link for acp pages
d6e8d8
*/
d6e8d8
function adm_back_link($u_action)
d6e8d8
{
d6e8d8
	global $user;
d6e8d8
	return '

« ' . $user->lang['BACK_TO_PREV'] . '';
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Build select field options in acp pages
d6e8d8
*/
d6e8d8
function build_select($option_ary, $option_default = false)
d6e8d8
{
d6e8d8
	global $user;
d6e8d8
d6e8d8
	$html = '';
d6e8d8
	foreach ($option_ary as $value => $title)
d6e8d8
	{
d6e8d8
		$selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : '';
d6e8d8
		$html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>';
d6e8d8
	}
d6e8d8
d6e8d8
	return $html;
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Build radio fields in acp pages
d6e8d8
*/
d6e8d8
function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
d6e8d8
{
d6e8d8
	global $user;
d6e8d8
d6e8d8
	$html = '';
d6e8d8
	$id_assigned = false;
d6e8d8
	foreach ($input_ary as $value => $title)
d6e8d8
	{
d6e8d8
		$selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
d6e8d8
		$html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>';
d6e8d8
		$id_assigned = true;
d6e8d8
	}
d6e8d8
d6e8d8
	return $html;
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Build configuration template for acp configuration pages
d6e8d8
*/
d6e8d8
function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
d6e8d8
{
d6e8d8
	global $user, $module;
d6e8d8
d6e8d8
	$tpl = '';
d6e8d8
	$name = 'config[' . $config_key . ']';
d6e8d8
d6e8d8
	switch ($tpl_type[0])
d6e8d8
	{
d6e8d8
		case 'text':
d6e8d8
		case 'password':
d6e8d8
			$size = (int) $tpl_type[1];
d6e8d8
			$maxlength = (int) $tpl_type[2];
d6e8d8
d6e8d8
			$tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
d6e8d8
		break;
d6e8d8
d6e8d8
		case 'dimension':
d6e8d8
			$size = (int) $tpl_type[1];
d6e8d8
			$maxlength = (int) $tpl_type[2];
d6e8d8
d6e8d8
			$tpl = '<input id="' . $key . '" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" /> x <input type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" />';
d6e8d8
		break;
d6e8d8
d6e8d8
		case 'textarea':
d6e8d8
			$rows = (int) $tpl_type[1];
d6e8d8
			$cols = (int) $tpl_type[2];
d6e8d8
d6e8d8
			$tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
d6e8d8
		break;
d6e8d8
d6e8d8
		case 'radio':
d6e8d8
			$key_yes	= ($new[$config_key]) ? ' checked="checked"' : '';
d6e8d8
			$key_no		= (!$new[$config_key]) ? ' checked="checked"' : '';
d6e8d8
d6e8d8
			$tpl_type_cond = explode('_', $tpl_type[1]);
d6e8d8
			$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
d6e8d8
d6e8d8
			$tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']) . '</label>';
d6e8d8
			$tpl_yes = '<label><input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']) . '</label>';
d6e8d8
d6e8d8
			$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes;
d6e8d8
		break;
d6e8d8
d6e8d8
		case 'select':
d6e8d8
		case 'custom':
d6e8d8
			
d6e8d8
			$return = '';
d6e8d8
d6e8d8
			if (isset($vars['method']))
d6e8d8
			{
d6e8d8
				$call = array($module->module, $vars['method']);
d6e8d8
			}
d6e8d8
			else if (isset($vars['function']))
d6e8d8
			{
d6e8d8
				$call = $vars['function'];
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				break;
d6e8d8
			}
d6e8d8
d6e8d8
			if (isset($vars['params']))
d6e8d8
			{
d6e8d8
				$args = array();
d6e8d8
				foreach ($vars['params'] as $value)
d6e8d8
				{
d6e8d8
					switch ($value)
d6e8d8
					{
d6e8d8
						case '{CONFIG_VALUE}':
d6e8d8
							$value = $new[$config_key];
d6e8d8
						break;
d6e8d8
d6e8d8
						case '{KEY}':
d6e8d8
							$value = $key;
d6e8d8
						break;
d6e8d8
					}
d6e8d8
d6e8d8
					$args[] = $value;
d6e8d8
				}
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$args = array($new[$config_key], $key);
d6e8d8
			}
d6e8d8
			
d6e8d8
			$return = call_user_func_array($call, $args);
d6e8d8
d6e8d8
			if ($tpl_type[0] == 'select')
d6e8d8
			{
d6e8d8
				$tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>';
d6e8d8
			}
d6e8d8
			else
d6e8d8
			{
d6e8d8
				$tpl = $return;
d6e8d8
			}
d6e8d8
d6e8d8
		break;
d6e8d8
d6e8d8
		default:
d6e8d8
		break;
d6e8d8
	}
d6e8d8
d6e8d8
	if (isset($vars['append']))
d6e8d8
	{
d6e8d8
		$tpl .= $vars['append'];
d6e8d8
	}
d6e8d8
d6e8d8
	return $tpl;
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Going through a config array and validate values, writing errors to $error. The validation method  accepts parameters separated by ':' for string and int.
d6e8d8
* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required.
d6e8d8
*/
d6e8d8
function validate_config_vars($config_vars, &$cfg_array, &$error)
d6e8d8
{
d6e8d8
	global $phpbb_root_path, $user;
d6e8d8
	$type	= 0;
d6e8d8
	$min	= 1;
d6e8d8
	$max	= 2;
d6e8d8
	
d6e8d8
	foreach ($config_vars as $config_name => $config_definition)
d6e8d8
	{
d6e8d8
		if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
d6e8d8
		{
d6e8d8
			continue;
d6e8d8
		}
d6e8d8
	
d6e8d8
		if (!isset($config_definition['validate']))
d6e8d8
		{
d6e8d8
			continue;
d6e8d8
		}
d6e8d8
		
d6e8d8
		$validator = explode(':', $config_definition['validate']);
d6e8d8
d6e8d8
		// Validate a bit. ;) (0 = type, 1 = min, 2= max)
d6e8d8
		switch ($validator[$type])
d6e8d8
		{
d6e8d8
			case 'string':
d6e8d8
				$length = strlen($cfg_array[$config_name]);
d6e8d8
d6e8d8
				// the column is a VARCHAR
d6e8d8
				$validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255;
d6e8d8
d6e8d8
				if (isset($validator[$min]) && $length < $validator[$min])
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]);
d6e8d8
				}
d6e8d8
				else if (isset($validator[$max]) && $length > $validator[2])
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]);
d6e8d8
				}
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'bool':
d6e8d8
				$cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0;
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'int':
d6e8d8
				$cfg_array[$config_name] = (int) $cfg_array[$config_name];
d6e8d8
d6e8d8
				if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min])
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]);
d6e8d8
				}
d6e8d8
				else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max])
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]);
d6e8d8
				}
d6e8d8
			break;
d6e8d8
d6e8d8
			// Absolute path
d6e8d8
			case 'script_path':
d6e8d8
				if (!$cfg_array[$config_name])
d6e8d8
				{
d6e8d8
					break;
d6e8d8
				}
d6e8d8
d6e8d8
				$destination = str_replace('\\', '/', $cfg_array[$config_name]);
d6e8d8
d6e8d8
				if ($destination !== '/')
d6e8d8
				{
d6e8d8
					// Adjust destination path (no trailing slash)
d6e8d8
					if (substr($destination, -1, 1) == '/')
d6e8d8
					{
d6e8d8
						$destination = substr($destination, 0, -1);
d6e8d8
					}
d6e8d8
d6e8d8
					$destination = str_replace(array('../', './'), '', $destination);
d6e8d8
d6e8d8
					if ($destination[0] != '/')
d6e8d8
					{
d6e8d8
						$destination = '/' . $destination;
d6e8d8
					}
d6e8d8
				}
d6e8d8
d6e8d8
				$cfg_array[$config_name] = trim($destination);
d6e8d8
d6e8d8
			break;
d6e8d8
d6e8d8
			// Absolute path
d6e8d8
			case 'lang':
d6e8d8
				if (!$cfg_array[$config_name])
d6e8d8
				{
d6e8d8
					break;
d6e8d8
				}
d6e8d8
d6e8d8
				$cfg_array[$config_name] = basename($cfg_array[$config_name]);
d6e8d8
d6e8d8
				if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/'))
d6e8d8
				{
d6e8d8
					$error[] = $user->lang['WRONG_DATA_LANG'];
d6e8d8
				}
d6e8d8
			break;
d6e8d8
d6e8d8
			// Relative path (appended $phpbb_root_path)
d6e8d8
			case 'rpath':
d6e8d8
			case 'rwpath':
d6e8d8
				if (!$cfg_array[$config_name])
d6e8d8
				{
d6e8d8
					break;
d6e8d8
				}
d6e8d8
d6e8d8
				$destination = $cfg_array[$config_name];
d6e8d8
d6e8d8
				// Adjust destination path (no trailing slash)
d6e8d8
				if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
d6e8d8
				{
d6e8d8
					$destination = substr($destination, 0, -1);
d6e8d8
				}
d6e8d8
d6e8d8
				$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
d6e8d8
				if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
d6e8d8
				{
d6e8d8
					$destination = '';
d6e8d8
				}
d6e8d8
d6e8d8
				$cfg_array[$config_name] = trim($destination);
d6e8d8
d6e8d8
			// Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir...
d6e8d8
			case 'path':
d6e8d8
			case 'wpath':
d6e8d8
d6e8d8
				if (!$cfg_array[$config_name])
d6e8d8
				{
d6e8d8
					break;
d6e8d8
				}
d6e8d8
d6e8d8
				$cfg_array[$config_name] = trim($cfg_array[$config_name]);
d6e8d8
d6e8d8
				// Make sure no NUL byte is present...
d6e8d8
				if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false)
d6e8d8
				{
d6e8d8
					$cfg_array[$config_name] = '';
d6e8d8
					break;
d6e8d8
				}
d6e8d8
d6e8d8
				if (!file_exists($phpbb_root_path . $cfg_array[$config_name]))
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]);
d6e8d8
				}
d6e8d8
d6e8d8
				if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name]))
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]);
d6e8d8
				}
d6e8d8
d6e8d8
				// Check if the path is writable
d6e8d8
				if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
d6e8d8
				{
d6e8d8
					if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name]))
d6e8d8
					{
d6e8d8
						$error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]);
d6e8d8
					}
d6e8d8
				}
d6e8d8
d6e8d8
			break;
d6e8d8
		}
d6e8d8
	}
d6e8d8
d6e8d8
	return;
d6e8d8
}
d6e8d8
d6e8d8
/**
d6e8d8
* Checks whatever or not a variable is OK for use in the Database
d6e8d8
* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))'
d6e8d8
* param mixed $error The error array
d6e8d8
*/
d6e8d8
function validate_range($value_ary, &$error)
d6e8d8
{
d6e8d8
	global $user;
d6e8d8
	
d6e8d8
	$column_types = array(
d6e8d8
		'BOOL'	=> array('php_type' => 'int', 		'min' => 0, 				'max' => 1),
d6e8d8
		'USINT'	=> array('php_type' => 'int',		'min' => 0, 				'max' => 65535),
d6e8d8
		'UINT'	=> array('php_type' => 'int', 		'min' => 0, 				'max' => (int) 0x7fffffff),
d6e8d8
		'INT'	=> array('php_type' => 'int', 		'min' => (int) 0x80000000, 	'max' => (int) 0x7fffffff),
d6e8d8
		'TINT'	=> array('php_type' => 'int',		'min' => -128,				'max' => 127),
d6e8d8
		
d6e8d8
		'VCHAR'	=> array('php_type' => 'string', 	'min' => 0, 				'max' => 255),
d6e8d8
	);
d6e8d8
	foreach ($value_ary as $value)
d6e8d8
	{
d6e8d8
		$column = explode(':', $value['column_type']);
d6e8d8
		$max = $min = 0;
d6e8d8
		$type = 0;
d6e8d8
		if (!isset($column_types[$column[0]]))
d6e8d8
		{
d6e8d8
			continue;
d6e8d8
		}
d6e8d8
		else
d6e8d8
		{
d6e8d8
			$type = $column_types[$column[0]];
d6e8d8
		}
d6e8d8
d6e8d8
		switch ($type['php_type'])
d6e8d8
		{
d6e8d8
			case 'string' :
d6e8d8
				$max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max'];
d6e8d8
				if (strlen($value['value']) > $max)
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max);
d6e8d8
				}
d6e8d8
			break;
d6e8d8
d6e8d8
			case 'int': 
d6e8d8
				$min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min'];
d6e8d8
				$max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max'];
d6e8d8
				if ($value['value'] < $min)
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min);
d6e8d8
				}
d6e8d8
				else if ($value['value'] > $max)
d6e8d8
				{
d6e8d8
					$error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max);
d6e8d8
				}
d6e8d8
			break;
d6e8d8
		}
d6e8d8
	}
d6e8d8
}
d6e8d8
d6e8d8
?>