]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/framework/Web/THttpUtility.php
baculum: New Baculum API and Baculum Web
[bacula/bacula] / gui / baculum / framework / Web / THttpUtility.php
1 <?php
2 /**
3  * THttpUtility class file
4  *
5  * @author Qiang Xue <qiang.xue@gmail.com>
6  * @link https://github.com/pradosoft/prado
7  * @copyright Copyright &copy; 2005-2016 The PRADO Group
8  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9  * @package System.Web
10  */
11
12 /**
13  * THttpUtility class
14  *
15  * @author Qiang Xue <qiang.xue@gmail.com>
16  * @package System.Web
17  * @since 3.0
18  */
19 class THttpUtility
20 {
21         private static $_encodeTable=array('<'=>'&lt;','>'=>'&gt;','"'=>'&quot;');
22         private static $_decodeTable=array('&lt;'=>'<','&gt;'=>'>','&quot;'=>'"');
23         private static $_stripTable=array('&lt;'=>'','&gt;'=>'','&quot;'=>'');
24
25         /**
26          * HTML-encodes a string.
27          * This method translates the following characters to their corresponding
28          * HTML entities: <, >, "
29          * Note, unlike {@link htmlspecialchars}, & is not translated.
30          * @param string string to be encoded
31          * @return string encoded string
32          */
33         public static function htmlEncode($s)
34         {
35                 return strtr($s,self::$_encodeTable);
36         }
37
38         /**
39          * HTML-decodes a string.
40          * It is the inverse of {@link htmlEncode}.
41          * @param string string to be decoded
42          * @return string decoded string
43          */
44         public static function htmlDecode($s)
45         {
46                 return strtr($s,self::$_decodeTable);
47         }
48
49         /**
50          * This method strips the following characters from a string:
51          * HTML entities: <, >, "
52          * @param string string to be encoded
53          * @return string encoded string
54          */
55         public static function htmlStrip($s)
56         {
57                 return strtr($s,self::$_stripTable);
58         }
59 }
60