package.xml 0000644 0001750 0001750 00000003316 11461242426 013764 0 ustar clockwerx clockwerx
Net_CheckIPpear.php.netCheck the syntax of IPv4 addressesThis package validates IPv4 addresses.Martin Jansenmjmj@php.netyes2010-10-251.2.21.2.1stablestableMIT License
QA release
SVN dir layout
4.0.01.4.0b11.2.21.2.1stablestable2010-10-25MIT License
QA release
SVN dir layout
Net_CheckIP-1.2.2/Net/CheckIP.php 0000600 0001750 0001750 00000004544 11461242426 017062 0 ustar clockwerx clockwerx
*
* @author Martin Jansen
* @author Guido Haeger
* @package Net_CheckIP
* @version 1.1
* @access public
*/
class Net_CheckIP
{
/**
* Validate the syntax of the given IP adress
*
* This function splits the IP address in 4 pieces
* (separated by ".") and checks for each piece
* if it's an integer value between 0 and 255.
* If all 4 parameters pass this test, the function
* returns true.
*
* @param string $ip IP adress
* @return bool true if syntax is valid, otherwise false
*/
function check_ip($ip)
{
$oct = explode('.', $ip);
if (count($oct) != 4) {
return false;
}
for ($i = 0; $i < 4; $i++) {
if (!preg_match("/^[0-9]+$/", $oct[$i])) {
return false;
}
if ($oct[$i] < 0 || $oct[$i] > 255) {
return false;
}
}
return true;
}
}
?>