library/HTMLPurifier/AttrDef/URI/IPv4.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef
00008 {
00009     
00013     protected $ip4;
00014     
00015     public function validate($aIP, $config, $context) {
00016         
00017         if (!$this->ip4) $this->_loadRegex();
00018         
00019         if (preg_match('#^' . $this->ip4 . '$#s', $aIP))
00020         {
00021                 return $aIP;
00022         }
00023         
00024         return false;
00025         
00026     }
00027     
00032     protected function _loadRegex() {
00033         $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255
00034         $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})";
00035     }
00036     
00037 }
00038 

Generated on Thu Jun 19 18:47:25 2008 for HTMLPurifier by  doxygen 1.5.3