summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-09-17 09:35:13 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-09-17 09:35:13 +0000
commit2ae95f35e566afdee93ea06bbf02443257ce7716 (patch)
tree0eddf35ca439ddc34473ffe97fce4615705017ad /frontends/php
parentcb2c5743fee519c1490317552b98a09f48daf92a (diff)
downloadzabbix-2ae95f35e566afdee93ea06bbf02443257ce7716.tar.gz
zabbix-2ae95f35e566afdee93ea06bbf02443257ce7716.tar.xz
zabbix-2ae95f35e566afdee93ea06bbf02443257ce7716.zip
[DEV-23] improvements in configure.in IPv6 (Sasha)
[DEV-23] Autodiscovery for IPv6 (Sasha) [DEV-17] Add support of IPv6 to standard library (comms.c) (Sasha) [DEV-21] extended size of IP fields to accept IPv6 style IPs (Alexei) [DEV-21] added basic validation of IPv6 IP addresses in GUI (Alexei) [DEV-18] Modified structures of include/db.h to have larger length for IP addresses. [DEV-18] database schema enhanced for IPv6 addresses (Alexei) Minor fix for confgure.in. support of --enable-ipv6 for configure.in (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@4752 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/include/defines.inc.php2
-rw-r--r--frontends/php/include/forms.inc.php9
-rw-r--r--frontends/php/include/validate.inc.php89
3 files changed, 96 insertions, 4 deletions
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index d52df3c4..8360dd51 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -437,6 +437,8 @@
/* Define if your logs are in non-standard format */
/* define('ZBX_LOG_ENCODING_DEFAULT', 'Shift_JIS');*/
+ define('ZBX_HAVE_IPV6', 1);
+
global $_GET, $_POST, $_COOKIE, $_REQUEST;
/* Support for PHP5. PHP5 does not have $HTTP_..._VARS */
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index a92aafae..2589473e 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -4087,7 +4087,14 @@ include_once 'include/discovery.inc.php';
else
{
$frmHost->AddRow(S_DNS_NAME,new CTextBox("dns",$dns,"40"));
- $frmHost->AddRow(S_IP_ADDRESS,new CTextBox("ip",$ip,"15"));
+ if(defined('ZBX_HAVE_IPV6'))
+ {
+ $frmHost->AddRow(S_IP_ADDRESS,new CTextBox("ip",$ip,"39"));
+ }
+ else
+ {
+ $frmHost->AddRow(S_IP_ADDRESS,new CTextBox("ip",$ip,"15"));
+ }
$cmbConnectBy = new CComboBox('useip', $useip);
$cmbConnectBy->AddItem(0, S_DNS_NAME);
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php
index 997e7f76..a628744f 100644
--- a/frontends/php/include/validate.inc.php
+++ b/frontends/php/include/validate.inc.php
@@ -70,15 +70,41 @@
{
return 'ereg(\'^([0-9a-zA-Z\_\.[.-.]\$ ]+)$\',{'.$var.'})&&';
}
-
- function validate_ip($str,&$arr)
+ function validate_ipv4($str,&$arr)
{
if( !ereg('^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$', $str, $arr) ) return false;
for($i=1; $i<=4; $i++) if( !is_numeric($arr[$i]) || $arr[$i] > 255 || $arr[$i] < 0 ) return false;
return true;
}
+ function validate_ipv6($str,&$arr)
+ {
+ $pattern1 = '([A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}';
+ $pattern2 = ':(:[A-Fa-f0-9]{1,4}){1,7}';
+ $pattern3 = '[A-Fa-f0-9]{1,4}::([A-Fa-f0-9]{1,4}:){0,5}[A-Fa-f0-9]{1,4}';
+ $pattern4 = '([A-Fa-f0-9]{1,4}:){2}:([A-Fa-f0-9]{1,4}:){0,4}[A-Fa-f0-9]{1,4}';
+ $pattern5 = '([A-Fa-f0-9]{1,4}:){3}:([A-Fa-f0-9]{1,4}:){0,3}[A-Fa-f0-9]{1,4}';
+ $pattern6 = '([A-Fa-f0-9]{1,4}:){4}:([A-Fa-f0-9]{1,4}:){0,2}[A-Fa-f0-9]{1,4}';
+ $pattern7 = '([A-Fa-f0-9]{1,4}:){5}:([A-Fa-f0-9]{1,4}:){0,1}[A-Fa-f0-9]{1,4}';
+ $pattern8 = '([A-Fa-f0-9]{1,4}:){6}:[A-Fa-f0-9]{1,4}';
+
+ $full = "/^($pattern1)$|^($pattern2)$|^($pattern3)$|^($pattern4)$|^($pattern5)$|^($pattern6)$|^($pattern7)$|^($pattern8)$/";
+
+ if( !ereg($full, $str, $arr) ) return false;
+ return true;
+ }
- function validate_ip_range($str)
+ function validate_ip($str,&$arr)
+ {
+ if(validate_ipv4($str,&$arr))
+ return true;
+ if(defined('ZBX_HAVE_IPV6'))
+ {
+ return validate_ipv6($str,&$arr);
+ }
+ return false;
+ }
+
+/* function validate_ip_range($str)
{
foreach(explode(',',$str) as $ip_range)
{
@@ -100,7 +126,64 @@
}
return true;
}
+*/
+ function validate_ip_range($str)
+ {
+ foreach(explode(',',$str) as $ip_range)
+ {
+ $parts = explode('-', $ip_range);
+ $parts_count = count($parts);
+ if($parts_count > 2) return false;
+
+ if(validate_ipv4($parts[0], $arr))
+ {
+ $ip_parts = explode('.', $parts[0]);
+
+ if( $parts_count == 2 )
+ {
+ if( !ereg('^[0-9]{1,3}$', $parts[1]) ) return false;
+
+ sscanf($ip_parts[3], "%d", $from_value);
+ sscanf($parts[1], "%d", $to_value);
+ if($to_value > 255 || $from_value > $to_value) return false;
+ }
+ }
+ else if( defined('ZBX_HAVE_IPV6') && validate_ipv6($parts[0], $arr) )
+ {
+ $ip_parts = explode(':', $parts[0]);
+ $ip_parts_count = count($ip_parts);
+
+ if( $parts_count == 2 )
+ {
+ if( !ereg('^[A-Fa-f0-9]{1,4}$', $parts[1]) ) return false;
+
+ sscanf($ip_parts[$ip_parts_count - 1], "%x", $from_value);
+ sscanf($parts[1], "%x", $to_value);
+ if($from_value > $to_value) return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ return true;
+ }
+/* function validate_ip_range($str)
+ {
+ if(defined('ZBX_HAVE_IPV6'))
+ {
+ return validate_ipv4_ipv6_range($str);
+ }
+ else
+ {
+ return validate_ipv4_range($str);
+ }
+ return false;
+ }
+*/
function validate_port_list($str)
{
foreach(explode(',',$str) as $port_range)