Line 45 | Line 45 |
---|
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables
|
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables
|
$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false; $file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
| $safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false; $file_uploads = (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on') ? true : false;
|
$module_id = request_var('i', ''); $mode = request_var('mode', '');
| $module_id = request_var('i', ''); $mode = request_var('mode', '');
|
Line 116 | Line 116 |
---|
'ROOT_PATH' => $phpbb_admin_path,
'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
|
'ROOT_PATH' => $phpbb_admin_path,
'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
|
| 'U_ADM_LOGOUT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'),
|
'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
| 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
|
Line 184 | Line 185 |
---|
{ global $base_memory_usage; $memory_usage -= $base_memory_usage;
|
{ global $base_memory_usage; $memory_usage -= $base_memory_usage;
|
$memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
| $memory_usage = get_formatted_filesize($memory_usage);
|
$debug_output .= ' | Memory Usage: ' . $memory_usage; }
| $debug_output .= ' | Memory Usage: ' . $memory_usage; }
|
Line 198 | Line 199 |
---|
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html,
|
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html,
|
| 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group'),
|
'VERSION' => $config['version']) );
| 'VERSION' => $config['version']) );
|
Line 236 | Line 238 |
---|
/** * Build radio fields in acp pages */
|
/** * Build radio fields in acp pages */
|
function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
| function h_radio($name, $input_ary, $input_default = false, $id = false, $key = false, $separator = '')
|
{ global $user;
| { global $user;
|
Line 245 | Line 247 |
---|
foreach ($input_ary as $value => $title) { $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
|
foreach ($input_ary as $value => $title) { $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
|
$html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>';
| $html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>' . $separator;
|
$id_assigned = true; }
| $id_assigned = true; }
|
Line 261 | Line 263 |
---|
$tpl = ''; $name = 'config[' . $config_key . ']';
|
$tpl = ''; $name = 'config[' . $config_key . ']';
|
| // Make sure there is no notice printed out for non-existent config options (we simply set them) if (!isset($new[$config_key])) { $new[$config_key] = ''; }
|
switch ($tpl_type[0]) {
| switch ($tpl_type[0]) {
|
Line 269 | Line 277 |
---|
$size = (int) $tpl_type[1]; $maxlength = (int) $tpl_type[2];
|
$size = (int) $tpl_type[1]; $maxlength = (int) $tpl_type[2];
|
$tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
| $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '"' . (($tpl_type[0] === 'password') ? ' autocomplete="off"' : '') . ' />';
|
break;
case 'dimension':
| break;
case 'dimension':
|
Line 367 | Line 375 |
---|
}
/**
|
}
/**
|
* Going through a config array and validate values, writing errors to $error.
| * Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int. * 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.
|
*/ function validate_config_vars($config_vars, &$cfg_array, &$error) { global $phpbb_root_path, $user;
|
*/ function validate_config_vars($config_vars, &$cfg_array, &$error) { global $phpbb_root_path, $user;
|
| $type = 0; $min = 1; $max = 2;
|
foreach ($config_vars as $config_name => $config_definition) {
| foreach ($config_vars as $config_name => $config_definition) {
|
Line 385 | Line 397 |
---|
continue; }
|
continue; }
|
// Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again switch ($config_definition['validate'])
| $validator = explode(':', $config_definition['validate']);
// Validate a bit. ;) (0 = type, 1 = min, 2= max) switch ($validator[$type])
|
{
|
{
|
| case 'string': $length = utf8_strlen($cfg_array[$config_name]);
// the column is a VARCHAR $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255;
if (isset($validator[$min]) && $length < $validator[$min]) { $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]); } else if (isset($validator[$max]) && $length > $validator[2]) { $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]); } break;
|
case 'bool': $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; break;
case 'int': $cfg_array[$config_name] = (int) $cfg_array[$config_name];
|
case 'bool': $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; break;
case 'int': $cfg_array[$config_name] = (int) $cfg_array[$config_name];
|
| if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min]) { $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]); } else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max]) { $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); }
if (strpos($config_name, '_max') !== false) { // Min/max pairs of settings should ensure that min <= max // Replace _max with _min to find the name of the minimum // corresponding configuration variable $min_name = str_replace('_max', '_min', $config_name);
if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) { // A minimum value exists and the maximum value is less than it $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); } } break;
case 'email': if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) { $error[] = $user->lang['EMAIL_INVALID_EMAIL']; }
|
break;
// Absolute path
| break;
// Absolute path
|
Line 464 | Line 524 |
---|
$cfg_array[$config_name] = trim($destination);
|
$cfg_array[$config_name] = trim($destination);
|
| // Absolute file path case 'absolute_path': case 'absolute_path_writable':
|
// Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... case 'path': case 'wpath':
| // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... case 'path': case 'wpath':
|
Line 482 | Line 545 |
---|
break; }
|
break; }
|
if (!file_exists($phpbb_root_path . $cfg_array[$config_name]))
| $path = in_array($config_definition['validate'], array('wpath', 'path', 'rpath', 'rwpath')) ? $phpbb_root_path . $cfg_array[$config_name] : $cfg_array[$config_name];
if (!file_exists($path))
|
{ $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); }
|
{ $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); }
|
if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name]))
| if (file_exists($path) && !is_dir($path))
|
{ $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); }
// Check if the path is writable
|
{ $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); }
// Check if the path is writable
|
if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
| if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath' || $config_definition['validate'] === 'absolute_path_writable')
|
{
|
{
|
if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name]))
| if (file_exists($path) && !phpbb_is_writable($path))
|
{ $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); }
| { $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); }
|
Line 506 | Line 571 |
---|
}
return;
|
}
return;
|
| }
/** * Checks whatever or not a variable is OK for use in the Database * param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))' * param mixed $error The error array */ function validate_range($value_ary, &$error) { global $user;
$column_types = array( 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1), 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535), 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff), // Do not use (int) 0x80000000 - it evaluates to different // values on 32-bit and 64-bit systems. // Apparently -2147483648 is a float on 32-bit systems, // despite fitting in an int, thus explicit cast is needed. 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff), 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127),
'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255), ); foreach ($value_ary as $value) { $column = explode(':', $value['column_type']); $max = $min = 0; $type = 0; if (!isset($column_types[$column[0]])) { continue; } else { $type = $column_types[$column[0]]; }
switch ($type['php_type']) { case 'string' : $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max']; if (utf8_strlen($value['value']) > $max) { $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max); } break;
case 'int': $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min']; $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max']; if ($value['value'] < $min) { $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min); } else if ($value['value'] > $max) { $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max); } break; } }
|
}
?>
| }
?>
|