Re: IP regex

"Vladimir V. Kolpakov" <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
On Sun, Oct 31, 2004 at 02:02:26PM -0500, Michael Stassen wrote:
> My advice: It makes no sense to keep IPs in a VARCHAR(30) column.  (Even if 
> a string was the right way to go, you'd need at most 15 characters.)  The 
> better way is to use an INT UNSIGNED.  Then you store an IP using 
> INET_ATON(IP) and retrieve it with INET_NTOA(ip_column).  That takes 4 
> bytes instead of 8 to 16, and reduces the likelihood of garbage values in 

It's very common mistake, --
to think integer occupies in databases 4 bytes.
Please look DESC on your table, and you can find
it takes 11 bytes, because is stored in character form.

> >>>I have been given the chore of taking a DB table of client records, 
> >>>which has a field called IP address.  Whenever a client logs onto our 
> >>>site, I'm supposed to display the IP address they logged on from THE 
> >>>LAST TIME they visited, as a security measure.

> >>>Can someone point me in the direction of creating REGEX to test whether 
> >>>an IP address is valid. (Valid in the sense of syntax i.e. 
> >>>192.168.24.20 is  valid, but
> >>>277.22.49.75, or 65.23 is not)?
> >>>Gregg Allen

Gregg, --

Why you need to check IP addr, anyway?
If it comes from apache cgi's $ENV{REMOTE_ADDR},
and user input does not affect on it,
what's the reason for regex-ing?


--w

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.