package.xml0000644000175000017500000000331611461242426013764 0ustar clockwerxclockwerx Net_CheckIP pear.php.net Check the syntax of IPv4 addresses This package validates IPv4 addresses. Martin Jansen mj mj@php.net yes 2010-10-25 1.2.2 1.2.1 stable stable MIT License QA release SVN dir layout 4.0.0 1.4.0b1 1.2.2 1.2.1 stable stable 2010-10-25 MIT License QA release SVN dir layout Net_CheckIP-1.2.2/Net/CheckIP.php0000600000175000017500000000454411461242426017062 0ustar clockwerxclockwerx * * @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; } } ?>