Initial Kohana install
[speedfreak] / Server / system / helpers / security.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * Security helper class.
4  *
5  * $Id: security.php 3769 2008-12-15 00:48:56Z zombor $
6  *
7  * @package    Core
8  * @author     Kohana Team
9  * @copyright  (c) 2007-2008 Kohana Team
10  * @license    http://kohanaphp.com/license.html
11  */
12 class security_Core {
13
14         /**
15          * Sanitize a string with the xss_clean method.
16          *
17          * @param   string  string to sanitize
18          * @return  string
19          */
20         public static function xss_clean($str)
21         {
22                 return Input::instance()->xss_clean($str);
23         }
24
25         /**
26          * Remove image tags from a string.
27          *
28          * @param   string  string to sanitize
29          * @return  string
30          */
31         public static function strip_image_tags($str)
32         {
33                 return preg_replace('#<img\s.*?(?:src\s*=\s*["\']?([^"\'<>\s]*)["\']?[^>]*)?>#is', '$1', $str);
34         }
35
36         /**
37          * Remove PHP tags from a string.
38          *
39          * @param   string  string to sanitize
40          * @return  string
41          */
42         public static function encode_php_tags($str)
43         {
44                 return str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $str);
45         }
46
47 } // End security