diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-05-18 17:07:02 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-05-18 17:19:29 +0200 |
commit | 71f5c9c32715b634d315f79aa11df07be2a9676c (patch) | |
tree | 4c0345ab8db037d43acd1769acd18b2bc9419d98 /phpBB/includes/bbcode.php | |
parent | c967ba7b9ba42d9cf72cd1bb0927ae5214894eda (diff) | |
download | forums-71f5c9c32715b634d315f79aa11df07be2a9676c.tar forums-71f5c9c32715b634d315f79aa11df07be2a9676c.tar.gz forums-71f5c9c32715b634d315f79aa11df07be2a9676c.tar.bz2 forums-71f5c9c32715b634d315f79aa11df07be2a9676c.tar.xz forums-71f5c9c32715b634d315f79aa11df07be2a9676c.zip |
[ticket/13832] Use preg_replace_callback instead of /e modifier
PHPBB3-13832
Diffstat (limited to 'phpBB/includes/bbcode.php')
-rw-r--r-- | phpBB/includes/bbcode.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 24eaddf067..dce9966efd 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -385,7 +385,16 @@ class bbcode } // Replace {L_*} lang strings - $bbcode_tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $bbcode_tpl); + $bbcode_tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { + if (!empty($user->lang[$match['1']])) + { + return $user->lang[$match['1']]; + } + else + { + return ucwords(strtolower(str_replace('_', ' ', $match['1']))); + } + }, $bbcode_tpl); if (!empty($rowset[$bbcode_id]['second_pass_replace'])) { @@ -509,7 +518,16 @@ class bbcode 'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2') ); - $tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl); + $tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { + if (!empty($user->lang[$match['1']])) + { + return $user->lang[$match['1']]; + } + else + { + return ucwords(strtolower(str_replace('_', ' ', $match['1']))); + } + }, $tpl); if (!empty($replacements[$tpl_name])) { |