[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/data/validator/validator.class.php" ); 4 5 /** 6 * \ingroup Validator 7 * 8 * Matches ip address with masks. Returns true wether 9 * the given ip address matches with the given mask 10 */ 11 class IpMatchValidator extends Validator 12 { 13 14 function IpValidator() 15 { 16 $this->Validator(); 17 } 18 19 function validate( $ip, $mask ) 20 { 21 return $this->checkip( $ip, $mask ); 22 } 23 24 /** 25 * @private 26 */ 27 function checkip($ip , $csiext) 28 { 29 $counter = 0; 30 31 $range = explode("/",$csiext); 32 if ($range[1] < 32) { 33 $maskbits = $range[1]; 34 $hostbits = 32 - $maskbits; 35 36 $hostcount = pow(2, $hostbits)-1; 37 $ipstart = ip2long($range[0]); 38 $ipend = $ipstart + $hostcount; 39 if (ip2long($ip) >= $ipstart) { 40 if (ip2long($ip) <= $ipend) { 41 return (true); 42 } 43 } 44 } 45 else { 46 if (ip2long($ip) == ip2long($range[0])) { 47 return (true); 48 } 49 } 50 51 return(false); 52 } 53 } 54 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |