PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_CheckIP » Bug #6915

Validates wrongly formatted IP

Details

Submitted2006-02-24 03:22 UTC
Frommanantha at gmail dot com
StatusDuplicate
PackageNet_CheckIP
PHP Version4.4.0
OSLinux
Roadmaps(Not assigned)

Comments

[2006-02-24 03:22 UTC] manantha at gmail dot com

Description:
------------
if (Net_CheckIP::check_ip("226e+0.33.22.1")) {
echo "ok";
}

this returns "ok". but writing this addr into a postgresql database inet field returns an error.

Test script:
---------------
<?php
require_once "Net/CheckIP.php";

if (Net_CheckIP::check_ip("226e+0.33.22.1")) {
echo "ok";
} else {
echo "no";
}
?>

Instead of doing a is_numeric check on each octet, it will be better to do a is_int or a regex /^[0-9]+$/
or check the ip with this regx /^(\d+\.){3}\d+$/