Source for file security_functions.php

Documentation is available at security_functions.php

  1. <?php
  2. /**
  3.  * CodeIgniter
  4.  *
  5.  * An open source application development framework for PHP 4.3.2 or newer
  6.  *
  7.  * @package        CodeIgniter
  8.  * @subpackage     Helpers
  9.  * @author        ExpressionEngine Dev Team
  10.  * @copyright    Copyright (c) 2006, EllisLab, Inc.
  11.  * @license        http://codeigniter.com/user_guide/license.html
  12.  * @link        http://codeigniter.com
  13.  * @since        Version 1.0
  14.  * @filesource
  15.  */
  16.  
  17. // ------------------------------------------------------------------------
  18.  
  19. /**
  20.  * CodeIgniter Security Helpers
  21.  *
  22.  * @author        ExpressionEngine Dev Team
  23.  * @link        http://codeigniter.com/user_guide/helpers/security_helper.html
  24.  */
  25.  
  26. // ------------------------------------------------------------------------
  27.  
  28. if (function_exists('xss_clean')) {
  29.     /**
  30.      * XSS Filtering
  31.      *
  32.      * @access    public
  33.      * @param    string 
  34.      * @param    string    the character set of your data
  35.      * @return    string 
  36.      */    
  37.     function xss_clean($str$charset 'ISO-8859-1')
  38.     {
  39.         trigger_error('Función xss_clean() no implementada.'E_USER_ERROR);
  40.         $CI =get_instance();
  41.         return $CI->input->xss_clean($str$charset);
  42.     }
  43. }
  44.  
  45. // --------------------------------------------------------------------
  46.  
  47. if (function_exists('dohash')) {    
  48.     /**
  49.      * Hash encode a string
  50.      *
  51.      * @access    public
  52.      * @param    string 
  53.      * @return    string 
  54.      */    
  55.     function dohash($str$type 'sha1')
  56.     {
  57.         if ($type == 'sha1')
  58.         {
  59.             if function_exists('sha1'))
  60.             {
  61.                 if function_exists('mhash'))
  62.                 {    
  63.                     require_once(BASEPATH.'libraries/Sha1'.EXT);
  64.                     $SH new CI_SHA;
  65.                     return $SH->generate($str);
  66.                 }
  67.                 else
  68.                 {
  69.                     return bin2hex(mhash(MHASH_SHA1$str));
  70.                 }
  71.             }
  72.             else
  73.             {
  74.                 return sha1($str);
  75.             }    
  76.         }
  77.         else
  78.         {
  79.             return md5($str);
  80.         }
  81.     }
  82. }
  83.     
  84. // ------------------------------------------------------------------------
  85.  
  86. if (function_exists('strip_image_tags')) {
  87.     /**
  88.      * Strip Image Tags
  89.      *
  90.      * @access    public
  91.      * @param    string 
  92.      * @return    string 
  93.      */    
  94.     function strip_image_tags($str)
  95.     {
  96.         $str preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#""\\1"$str);
  97.         $str preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#""\\1"$str);
  98.             
  99.         return $str;
  100.     }
  101. }
  102.     
  103. // ------------------------------------------------------------------------
  104.  
  105. if (function_exists('encode_php_tags')){
  106.     /**
  107.      * Convert PHP tags to entities
  108.      *
  109.      * @access    public
  110.      * @param    string 
  111.      * @return    string 
  112.      */    
  113.     function encode_php_tags($str)
  114.     {
  115.         return str_replace(array('<?php''<?PHP''<?''?>'),  array('&lt;?php''&lt;?PHP''&lt;?''?&gt;')$str);
  116.     }
  117. }
  118.  
  119. ?>

Documentation generated on Tue, 22 Nov 2011 13:28:59 -0200 by phpDocumentor 1.4.3