aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_acp.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_acp.php')
-rw-r--r--phpBB/includes/functions_acp.php70
1 files changed, 40 insertions, 30 deletions
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index c4afb39ff0..a2014a7d5b 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -24,9 +24,9 @@ if (!defined('IN_PHPBB'))
*/
function adm_page_header($page_title)
{
- global $config, $db, $user, $template;
+ global $config, $user, $template;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
- global $phpbb_dispatcher;
+ global $phpbb_dispatcher, $phpbb_container;
if (defined('HEADER_INC'))
{
@@ -88,6 +88,7 @@ function adm_page_header($page_title)
'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/",
'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/",
+ 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$phpbb_root_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'],
'T_ASSETS_VERSION' => $config['assets_version'],
@@ -107,14 +108,17 @@ function adm_page_header($page_title)
'S_CONTENT_ENCODING' => 'UTF-8',
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
+
+ 'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false,
));
- // An array of http headers that phpbb will set. The following event may override these.
+ // An array of http headers that phpBB will set. The following event may override these.
$http_headers = array(
// application/xhtml+xml not used because of IE
'Content-type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'private, no-cache="set-cookie"',
'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
+ 'Referrer-Policy' => 'strict-origin-when-cross-origin',
);
/**
@@ -142,8 +146,8 @@ function adm_page_header($page_title)
*/
function adm_page_footer($copyright_html = true)
{
- global $db, $config, $template, $user, $auth, $cache;
- global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
+ global $db, $config, $template, $user, $auth;
+ global $phpbb_root_path;
global $request, $phpbb_dispatcher;
// A listener can set this variable to `true` when it overrides this function
@@ -232,7 +236,7 @@ function h_radio($name, $input_ary, $input_default = false, $id = false, $key =
/**
* Build configuration template for acp configuration pages
*/
-function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
+function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars)
{
global $user, $module, $phpbb_dispatcher;
@@ -240,18 +244,18 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$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]))
+ if (!isset($new_ary[$config_key]))
{
- $new[$config_key] = '';
+ $new_ary[$config_key] = '';
}
switch ($tpl_type[0])
{
case 'password':
- if ($new[$config_key] !== '')
+ if ($new_ary[$config_key] !== '')
{
// replace passwords with asterixes
- $new[$config_key] = '********';
+ $new_ary[$config_key] = '********';
}
case 'text':
case 'url':
@@ -263,7 +267,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$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_type[0] === 'password') ? ' autocomplete="off"' : '') . ' />';
+ $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new_ary[$config_key] . '"' . (($tpl_type[0] === 'password') ? ' autocomplete="off"' : '') . ' />';
break;
case 'color':
@@ -271,7 +275,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
case 'datetime-local':
case 'month':
case 'week':
- $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
+ $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '" name="' . $name . '" value="' . $new_ary[$config_key] . '" />';
break;
case 'date':
@@ -285,7 +289,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$max = (int) $tpl_type[2];
}
- $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (( $min != '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="' . $name . '" value="' . $new[$config_key] . '" />';
+ $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (( $min != '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="' . $name . '" value="' . $new_ary[$config_key] . '" />';
break;
case 'dimension':
@@ -298,19 +302,19 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$max = (int) $tpl_type[2];
}
- $tpl = '<input id="' . $key . '" type="number"' . (( $min !== '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" /> x <input type="number"' . (( $min !== '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" />';
+ $tpl = '<input id="' . $key . '" type="number"' . (( $min !== '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="config[' . $config_key . '_width]" value="' . $new_ary[$config_key . '_width'] . '" /> x <input type="number"' . (( $min !== '' ) ? ' min="' . $min . '"' : '') . (( $max != '' ) ? ' max="' . $max . '"' : '') . ' name="config[' . $config_key . '_height]" value="' . $new_ary[$config_key . '_height'] . '" />';
break;
case 'textarea':
$rows = (int) $tpl_type[1];
$cols = (int) $tpl_type[2];
- $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
+ $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new_ary[$config_key] . '</textarea>';
break;
case 'radio':
- $key_yes = ($new[$config_key]) ? ' checked="checked"' : '';
- $key_no = (!$new[$config_key]) ? ' checked="checked"' : '';
+ $key_yes = ($new_ary[$config_key]) ? ' checked="checked"' : '';
+ $key_no = (!$new_ary[$config_key]) ? ' checked="checked"' : '';
$tpl_type_cond = explode('_', $tpl_type[1]);
$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
@@ -324,8 +328,6 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
case 'select':
case 'custom':
- $return = '';
-
if (isset($vars['method']))
{
$call = array($module->module, $vars['method']);
@@ -347,7 +349,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
switch ($value)
{
case '{CONFIG_VALUE}':
- $value = $new[$config_key];
+ $value = $new_ary[$config_key];
break;
case '{KEY}':
@@ -360,7 +362,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
}
else
{
- $args = array($new[$config_key], $key);
+ $args = array($new_ary[$config_key], $key);
}
$return = call_user_func_array($call, $args);
@@ -388,6 +390,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$tpl .= $vars['append'];
}
+ $new = $new_ary;
/**
* Overwrite the html code we display for the config value
*
@@ -405,6 +408,8 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
*/
$vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl');
extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars)));
+ $new_ary = $new;
+ unset($new);
return $tpl;
}
@@ -415,7 +420,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
*/
function validate_config_vars($config_vars, &$cfg_array, &$error)
{
- global $phpbb_root_path, $user, $phpbb_dispatcher;
+ global $phpbb_root_path, $user, $phpbb_dispatcher, $phpbb_filesystem, $language;
$type = 0;
$min = 1;
@@ -438,6 +443,16 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
// Validate a bit. ;) (0 = type, 1 = min, 2= max)
switch ($validator[$type])
{
+ case 'url':
+ $cfg_array[$config_name] = trim($cfg_array[$config_name]);
+
+ if (!empty($cfg_array[$config_name]) && !preg_match('#^' . get_preg_expression('url') . '$#iu', $cfg_array[$config_name]))
+ {
+ $error[] = $language->lang('URL_INVALID', $language->lang($config_definition['lang']));
+ }
+
+ // no break here
+
case 'string':
$length = utf8_strlen($cfg_array[$config_name]);
@@ -560,9 +575,6 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
$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':
@@ -581,7 +593,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
break;
}
- $path = in_array($config_definition['validate'], array('wpath', 'path', 'rpath', 'rwpath')) ? $phpbb_root_path . $cfg_array[$config_name] : $cfg_array[$config_name];
+ $path = $phpbb_root_path . $cfg_array[$config_name];
if (!file_exists($path))
{
@@ -594,9 +606,9 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
}
// Check if the path is writable
- if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath' || $config_definition['validate'] === 'absolute_path_writable')
+ if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
{
- if (file_exists($path) && !phpbb_is_writable($path))
+ if (file_exists($path) && !$phpbb_filesystem->is_writable($path))
{
$error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]);
}
@@ -652,8 +664,6 @@ function validate_range($value_ary, &$error)
foreach ($value_ary as $value)
{
$column = explode(':', $value['column_type']);
- $max = $min = 0;
- $type = 0;
if (!isset($column_types[$column[0]]))
{
continue;