Редакция 2 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 296 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * Smarty shared plugin
|
3 | * Smarty shared plugin
|
4 | * @package Smarty
|
4 | * @package Smarty
|
5 | * @subpackage plugins
|
5 | * @subpackage plugins
|
6 | */
|
6 | */
|
7 | 7 | ||
8 | 8 | ||
9 | /**
|
9 | /**
|
10 | * escape_special_chars common function
|
10 | * escape_special_chars common function
|
11 | *
|
11 | *
|
12 | * Function: smarty_function_escape_special_chars<br>
|
12 | * Function: smarty_function_escape_special_chars<br>
|
13 | * Purpose: used by other smarty functions to escape
|
13 | * Purpose: used by other smarty functions to escape
|
14 | * special chars except for already escaped ones
|
14 | * special chars except for already escaped ones
|
15 | * @author Monte Ohrt <monte at ohrt dot com>
|
15 | * @author Monte Ohrt <monte at ohrt dot com>
|
16 | * @param string
|
16 | * @param string
|
17 | * @return string
|
17 | * @return string
|
18 | */
|
18 | */
|
19 | function smarty_function_escape_special_chars($string) |
19 | function smarty_function_escape_special_chars($string) |
20 | {
|
20 | {
|
21 | if(!is_array($string)) { |
21 | if(!is_array($string)) { |
22 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
22 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
23 | $string = htmlspecialchars($string); |
23 | $string = htmlspecialchars($string); |
24 | $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); |
24 | $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); |
25 | }
|
25 | }
|
26 | return $string; |
26 | return $string; |
27 | }
|
27 | }
|
28 | 28 | ||
29 | /* vim: set expandtab: */
|
29 | /* vim: set expandtab: */
|
30 | 30 | ||
31 | ?>
|
31 | ?>
|
32 | 32 |