note 59910 deleted from function.ip2long by danbrown
| From: | danbrown@php.net | Date: | Fri, 05 Dec 2008 13:38:26 +0000 |
| Subject: | note 59910 deleted from function.ip2long by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147692@lists.php.net to get a copy of this message | ||
Note Submitter: greg at netops dot gvtc dot com
----
Re: m.ozarek's isIpMask() function
You might want to adjust your preg_match line from:
if(preg_match("/[0-9].[0-9].[0-9].[0-9]/",$mask)){
to
if(preg_match("/[0-9]++\.[0-9]++\.[0-9]++\.[0-9]++/",$mask)){
this should properly match up to 3 characters per octet and require that the periods be periods not
just any character. I tested against a handful of IPs, and it seemed to match fine, and did not
allow a 7 digit number to be considered a mask to check. This is probably more useful if doing a
match against a regular IP than against the subnet mask, but its always good to have more layers of
checking.
*note.. not all applications support the regex + metacharacter.