0
|
1 |
<?php
|
|
2 |
/**
|
|
3 |
* Smarty shared plugin
|
|
4 |
*
|
|
5 |
* @package Smarty
|
|
6 |
* @subpackage PluginsShared
|
|
7 |
*/
|
|
8 |
|
|
9 |
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
|
10 |
/**
|
|
11 |
* escape_special_chars common function
|
|
12 |
*
|
|
13 |
* Function: smarty_function_escape_special_chars<br>
|
|
14 |
* Purpose: used by other smarty functions to escape
|
|
15 |
* special chars except for already escaped ones
|
|
16 |
*
|
|
17 |
* @author Monte Ohrt <monte at ohrt dot com>
|
|
18 |
* @param string $string text that should by escaped
|
|
19 |
* @return string
|
|
20 |
*/
|
|
21 |
function smarty_function_escape_special_chars($string)
|
|
22 |
{
|
|
23 |
if (!is_array($string)) {
|
|
24 |
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
|
25 |
}
|
|
26 |
return $string;
|
|
27 |
}
|
|
28 |
} else {
|
|
29 |
/**
|
|
30 |
* escape_special_chars common function
|
|
31 |
*
|
|
32 |
* Function: smarty_function_escape_special_chars<br>
|
|
33 |
* Purpose: used by other smarty functions to escape
|
|
34 |
* special chars except for already escaped ones
|
|
35 |
*
|
|
36 |
* @author Monte Ohrt <monte at ohrt dot com>
|
|
37 |
* @param string $string text that should by escaped
|
|
38 |
* @return string
|
|
39 |
*/
|
|
40 |
function smarty_function_escape_special_chars($string)
|
|
41 |
{
|
|
42 |
if (!is_array($string)) {
|
|
43 |
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
|
44 |
$string = htmlspecialchars($string);
|
|
45 |
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
|
46 |
}
|
|
47 |
return $string;
|
|
48 |
}
|
|
49 |
}
|
|
50 |
|
|
51 |
?> |