+++ /dev/null
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-\r
-/**\r
- * Smarty escape modifier plugin\r
- *\r
- * Type: modifier<br>\r
- * Name: escape<br>\r
- * Purpose: Escape the string according to escapement type\r
- * @link http://smarty.php.net/manual/en/language.modifier.escape.php\r
- * escape (Smarty online manual)\r
- * @param string\r
- * @param html|htmlall|url|quotes|hex|hexentity|javascript\r
- * @return string\r
- */\r
-function smarty_modifier_escape($string, $esc_type = 'html')\r
-{\r
- switch ($esc_type) {\r
- case 'html':\r
- return htmlspecialchars($string, ENT_QUOTES);\r
-\r
- case 'htmlall':\r
- return htmlentities($string, ENT_QUOTES);\r
-\r
- case 'url':\r
- return urlencode($string);\r
-\r
- case 'quotes':\r
- // escape unescaped single quotes\r
- return preg_replace("%(?<!\\\\)'%", "\\'", $string);\r
-\r
- case 'hex':\r
- // escape every character into hex\r
- $return = '';\r
- for ($x=0; $x < strlen($string); $x++) {\r
- $return .= '%' . bin2hex($string[$x]);\r
- }\r
- return $return;\r
- \r
- case 'hexentity':\r
- $return = '';\r
- for ($x=0; $x < strlen($string); $x++) {\r
- $return .= '&#x' . bin2hex($string[$x]) . ';';\r
- }\r
- return $return;\r
-\r
- case 'javascript':\r
- // escape quotes and backslashes and newlines\r
- return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n'));\r
-\r
- default:\r
- return $string;\r
- }\r
-}\r
-\r
-/* vim: set expandtab: */\r
-\r
-?>\r