1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-20 07:42:09 +02:00

[ticket/10824] Move parse_cfg_file() to functions_compatibility

PHPBB3-10824
This commit is contained in:
Marc Alexander 2018-12-28 10:59:02 +01:00
parent d43144c5a2
commit ca4fdeaf2b
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
2 changed files with 62 additions and 62 deletions

View File

@ -2668,68 +2668,6 @@ function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = f
return $s_hidden_fields;
}
/**
* Parse cfg file
* @param string $filename
* @param bool|array $lines
* @return array
*
* @deprecated Will be removed in the future as *.cfg files are being replaced by composer.json files
*/
function parse_cfg_file($filename, $lines = false)
{
$parsed_items = array();
if ($lines === false)
{
$lines = file($filename);
}
foreach ($lines as $line)
{
$line = trim($line);
if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false)
{
continue;
}
// Determine first occurrence, since in values the equal sign is allowed
$key = htmlspecialchars(strtolower(trim(substr($line, 0, $delim_pos))), ENT_COMPAT);
$value = trim(substr($line, $delim_pos + 1));
if (in_array($value, array('off', 'false', '0')))
{
$value = false;
}
else if (in_array($value, array('on', 'true', '1')))
{
$value = true;
}
else if (!trim($value))
{
$value = '';
}
else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"'))
{
$value = htmlspecialchars(substr($value, 1, strlen($value)-2), ENT_COMPAT);
}
else
{
$value = htmlspecialchars($value, ENT_COMPAT);
}
$parsed_items[$key] = $value;
}
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name'])
{
unset($parsed_items['parent']);
}
return $parsed_items;
}
/**
* Return a nicely formatted backtrace.
*

View File

@ -881,3 +881,65 @@ function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $re
$controller_helper->display_sql_report();
}
/**
* Parse cfg file
* @param string $filename
* @param bool|array $lines
* @return array
*
* @deprecated 4.0.0-a1 (To be removed: 5.0.0)
*/
function parse_cfg_file($filename, $lines = false)
{
$parsed_items = array();
if ($lines === false)
{
$lines = file($filename);
}
foreach ($lines as $line)
{
$line = trim($line);
if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false)
{
continue;
}
// Determine first occurrence, since in values the equal sign is allowed
$key = htmlspecialchars(strtolower(trim(substr($line, 0, $delim_pos))), ENT_COMPAT);
$value = trim(substr($line, $delim_pos + 1));
if (in_array($value, array('off', 'false', '0')))
{
$value = false;
}
else if (in_array($value, array('on', 'true', '1')))
{
$value = true;
}
else if (!trim($value))
{
$value = '';
}
else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"'))
{
$value = htmlspecialchars(substr($value, 1, strlen($value)-2), ENT_COMPAT);
}
else
{
$value = htmlspecialchars($value, ENT_COMPAT);
}
$parsed_items[$key] = $value;
}
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name'])
{
unset($parsed_items['parent']);
}
return $parsed_items;
}