Copyright © 2005-2008 Andrea Tincani

AndreaPHP | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (smtp server)Next Topic (Cookie How to) New Topic New Poll Post Reply
AndreaPHP Forum : PHP General : regexp to filter IP
Poster Message
ross96
Level: Protégé

Registered: 01-09-2005
Posts: 8

icon regexp to filter IP

what is the PHP syntax to compare an IP address string with a filter in order to know if the address is in specified subnetwork...

I need to know if a visitor IP is part of a specific subnetwork, so I have to test that the string is in the format "192.168.101.x".

...and also a way to filter a B class address "192.168.x.x"

15-11-2005 at 10:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 35

icon Re: regexp to filter IP

you can use ereg function this way:


<?
//check if the IP address is in the form 192.168.x.x
if (ereg("^192.168.[0-9]{1,3}.[0-9]{1,3}",$IPToCheck) echo "match"

//check if the IP address is in the form 192.168.101.x
if (ereg("^192.168.101.[0-9]{1,3}",$IPToCheck) echo "match"
?>




hope this helps

[Edited by admin on 16-11-2005 at 06:23 PM GMT]

____________________________
AndreaVB

16-11-2005 at 05:23 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaPHP Forum : PHP General : regexp to filter IP
Previous Topic (smtp server)Next Topic (Cookie How to) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: AndreaVB

Copyright © 2005-2008 Andrea Tincani

Powered by: tForum tForum Edition b0.92p1
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team.