Koowa_Filter
[ class tree: Koowa_Filter ] [ index: Koowa_Filter ] [ all elements ]

Source for file ip.php

Documentation is available at ip.php

  1. <?php
  2. /**
  3. @version        $Id: ip.php 4628 2012-05-06 19:56:43Z johanjanssens $
  4. @package      Koowa_Filter
  5. @copyright    Copyright (C) 2007 - 2012 Johan Janssens. All rights reserved.
  6. @license      GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
  7. @link         http://www.nooku.org
  8. */
  9.  
  10. /**
  11.  * IP filter
  12.  *
  13.  * @author        Johan Janssens <johan@nooku.org>
  14.  * @package     Koowa_Filter
  15.  */
  16. class KFilterIP extends KFilterAbstract
  17. {
  18.     /**
  19.      * Validate a value
  20.      *
  21.      * @param    scalar    Value to be validated
  22.      * @return    bool    True when the variable is valid
  23.      */
  24.     protected function _validate($value)
  25.     {
  26.         $value trim($value);
  27.         return (false !== filter_var($valueFILTER_VALIDATE_IP));
  28.     }
  29.  
  30.     /**
  31.      * Sanitize a value
  32.      *
  33.      * @param    scalar    Value to be sanitized
  34.      * @return    string 
  35.      */
  36.     protected function _sanitize($value)
  37.     {
  38.         return preg_replace('#[^a-f0-9:\.]#i'''$value);
  39.     }
  40. }

Documentation generated on Sun, 19 May 2013 03:04:25 +0200 by phpDocumentor 1.4.3