Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Fri Mar 29, 2024 7:35 am

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: Thu May 06, 2010 8:49 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
I have replaced all the ereg functions with preg_match functions - except the one below. Can anyone that's a regex guru work this out for me ?

[code]
if (! preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}(( ([0-9]{1,3}\.){3}[0-9]{1,3})|(/[0-9]{1,2}))$/',$my_net_info))
{
$details->error = "Error - invalid input";
return($details);
}
[/code]

$mynetinfo should be an IP Address and subnet, seperated by a space. Like
$mynetinfo = "192.168.0.1 255.255.255.0";

FYI - it should also valide against IP & CIDR Netmask: 10.0.0.1/22 and IP & Wildcard Mask: 10.0.0.1 0.0.3.255 type addresses.


When I keep this code in, I get a PHP error such

[code]
A PHP Error was encountered
Severity: Warning
Message: preg_match() [function.preg-match]: Unknown modifier '['
Filename: helpers/network_helper.php
Line Number: 37
[/code]

With line number 37 being the if (! preg_match('/^([....... line.

Any help much appreciated.
I think this is the last stumbling block to getting OAv2 working on PHP5.3.
I could simply comment out this function and it should still work fine. We should only be inputting valid IP Addresses anyway - but that's not the point.

BTW - the original code is here
[url]http://moggert.net/subnetcalc.php.txt[/url] and also referenced here [url]http://meta.wikimedia.org/wiki/User:Oblivious/SubnetCalc[/url].

_________________
Support and Development hours available from [url=https://opmantek.com]Opmantek[/url].
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 07, 2010 3:09 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
My guess would be that you need to escape the "/" in the middle.
So
[code]if (! preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}(( ([0-9]{1,3}\.){3}[0-9]{1,3})|(/[0-9]{1,2}))$/',$my_net_info))[/code]

becomes
[code]if (! preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}(( ([0-9]{1,3}\.){3}[0-9]{1,3})|(\/[0-9]{1,2}))$/',$my_net_info))[/code]


Top
 Profile  
Reply with quote  
PostPosted: Mon May 24, 2010 3:08 am 
Offline
Newbie

Joined: Thu Feb 11, 2010 2:41 am
Posts: 19
Mark,

You said you wanted to match

    192.168.0.1 255.255.255.0
    10.0.0.1 0.0.3.255
    10.0.0.1/22


Here is what I've come up with
[code]
/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b\W\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b\W[0-9]{2}\b/
[/code]
Here is a screen shot of it matching
http://gyazo.com/07909bb45772713fe2c843c3fe90b7c9.png


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group