What's on your network?
It is currently Fri Apr 20, 2018 10:33 pm

All times are UTC + 10 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu May 06, 2010 8:49 pm 
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1944
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 ?

   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";

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

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

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

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

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 and also referenced here

Support and Development hours available from Opmantek.
Please consider a purchase to help make Open-AudIT better for everyone.

Reply with quote  
PostPosted: Fri May 07, 2010 3:09 am 

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1254
My guess would be that you need to escape the "/" in the middle.
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))

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))

Reply with quote  
PostPosted: Mon May 24, 2010 3:08 am 

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

You said you wanted to match

Here is what I've come up with

Here is a screen shot of it matching

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 10 hours

Who is online

Users browsing this forum: No registered users and 3 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