diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-26 08:17:13 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-26 08:17:13 +0000 |
| commit | 1b9fa06acb3c68871d5d87053d047430ff0acbfb (patch) | |
| tree | 39e1430c9c1e3531d0ec406c883a5643f59e6cb9 /frontends/php | |
| parent | 4d02efc00fc5a4c076f12c4039197baf080c33d4 (diff) | |
| download | zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.tar.gz zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.tar.xz zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.zip | |
- developed IP input box (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3384 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/include/classes/ctextbox.inc.php | 31 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/validate.inc.php | 35 | ||||
| -rw-r--r-- | frontends/php/nodes.php | 6 |
5 files changed, 58 insertions, 18 deletions
diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php index 587799ad..9f385afc 100644 --- a/frontends/php/include/classes/ctextbox.inc.php +++ b/frontends/php/include/classes/ctextbox.inc.php @@ -29,9 +29,9 @@ parent::CTag('input','no'); $this->tag_body_start = ''; $this->options['class'] = 'biginput'; - $this->options['name'] = $name; - $this->options['size'] = $size; - $this->options['value'] = $value; + $this->AddOption('name', $name); + $this->AddOption('size', $size); + $this->AddOption('value',$value); $this->SetReadonly($readonly); } function SetReadonly($value='yes') @@ -64,15 +64,17 @@ class CNumericBox extends CTextBox { - function CNumericBox($name='password',$value='',$size=20) + function CNumericBox($name='password',$value='',$size=20,$readonly="no") { - parent::CTextBox($name,$value,$size); - $this->options['OnKeyPress'] = + parent::CTextBox($name,$value,$size,$readonly); + $this->AddOption('MaxLength', $size); + $this->AddOption('Style', 'text-align: right;'); + $this->AddOption('OnKeyPress', " var c= (event.which) ? event.which : event.keyCode; ". - " if(c <= 31 || (c >= 48 && c <= 57)) return true; else return false; "; + " if(c <= 31 || (c >= 48 && c <= 57)) return true; else return false; "); } } -/* TEST + class CIpBox { var $ip_parts = array(); @@ -88,7 +90,17 @@ for($i = 0; $i < 4; $i++) { $this->ip_parts[$i] = new CNumericBox($name.'['.$i.']', $value[$i], 3); - if($i < 3) $this->ip_parts[$i]->tag_end = ''; + if($i != 3) + { + $this->ip_parts[$i]->tag_end = ''; + $this->ip_parts[$i]->AddOption('OnKeyDown', + ' this.maxlength = this.getAttribute("maxlength"); '. + ' this.oldlength = this.value.length; '); + $this->ip_parts[$i]->AddOption('OnKeyUp', + ' if(this.oldlength != this.value.length && this.value.length == this.maxlength) {'. + ' var el = this.form.elements["'.$name.'['.($i+1).']'.'"];'. + ' if(el) { el.focus(); el.select(); }}'); + } $this->ip_parts[$i] = unpack_object($this->ip_parts[$i]); } } @@ -107,6 +119,5 @@ echo $this->ToString($destroy); } } -TEST */ ?> diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 7b67f43e..b882785f 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -26,6 +26,7 @@ define("T_ZBX_INT", 1); define("T_ZBX_DBL", 2); define("T_ZBX_PERIOD", 3); + define("T_ZBX_IP", 4); define("O_MAND", 0); define("O_OPT", 1); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index bb7bede1..4af25ba3 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -84,8 +84,7 @@ $cmbTimeZone->AddItem($i, "GMT".sprintf("%+03d:00", $i)); } $frmNode->AddRow(S_TIME_ZONE, $cmbTimeZone); - $frmNode->AddRow(S_IP, new CTextBox('ip', $ip, 17)); -//TEST $frmNode->AddRow(S_IP.'(test)', new CIpBox('ip', $ip)); + $frmNode->AddRow(S_IP, new CIpBox('ip', $ip)); $frmNode->AddRow(S_PORT, new CNumericBox('port', $port,5)); $frmNode->AddRow(S_DO_NOT_KEEP_HISTORY_OLDER_THAN, new CNumericBox('slave_history', $slave_history,6)); $frmNode->AddRow(S_DO_NOT_KEEP_TRENDS_OLDER_THAN, new CNumericBox('slave_trends', $slave_trends,6)); diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index dba4ffae..2489c52a 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -92,8 +92,8 @@ { foreach($_REQUEST[$field] as $key => $val) { - $expression = str_replace("{}",'$_REQUEST["'.$field.'"]['.$key.']',$expression); - if(calc_exp2($fields,$field,$expression)==FALSE) + $expression2 = str_replace("{}",'$_REQUEST["'.$field.'"]['.$key.']',$expression); + if(calc_exp2($fields,$field,$expression2)==FALSE) return FALSE; } return TRUE; @@ -150,7 +150,7 @@ function check_type(&$field, $flags, &$var, $type) { - if(is_array($var)) + if(is_array($var) && $type != T_ZBX_IP) { $err = ZBX_VALID_OK; foreach($var as $el) @@ -160,6 +160,27 @@ return $err; } + if($type == T_ZBX_IP) + { + if(!is_array($var)) $var = explode('.',$var); + if(!isset($var[0]) || !isset($var[1]) || !isset($var[2]) || !isset($var[3])) + { + if($flags&P_SYS) + { + info("Critical error. Field [".$field."] is not IP"); + return ZBX_VALID_ERROR; + } + else + { + info("Warning. Field [".$field."] is not IP"); + return ZBX_VALID_WARNING; + } + } + $err = ZBX_VALID_OK; + foreach($var as $el) $err |= check_type($field, $flags, $el, T_ZBX_INT); + return $err; + } + if(($type == T_ZBX_INT) && !is_numeric($var)) { if($flags&P_SYS) { @@ -220,6 +241,8 @@ { list($type,$opt,$flags,$validation,$exception)=$checks; + if($type == T_ZBX_IP) $validation = BETWEEN(0,255); + //echo "Field: $field<br>"; if($exception==NULL) $except=FALSE; @@ -294,6 +317,12 @@ } } } + + if($type == T_ZBX_IP) + { + $_REQUEST[$field] = implode('.', $_REQUEST[$field]); + } + return ZBX_VALID_OK; } diff --git a/frontends/php/nodes.php b/frontends/php/nodes.php index 89e78a28..2dbc022b 100644 --- a/frontends/php/nodes.php +++ b/frontends/php/nodes.php @@ -39,7 +39,7 @@ include_once "include/page_header.php"; "name"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'), "timezone"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(-12,+13),'isset({save})'), - "ip"=> array(T_ZBX_STR, O_OPT, null, DB_ID, 'isset({save})'), + "ip"=> array(T_ZBX_IP, O_OPT, null, null, 'isset({save})'), "port"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(1,65535),'isset({save})'), "slave_history"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,65535),'isset({save})'), "slave_trends"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,65535),'isset({save})'), @@ -95,7 +95,7 @@ include_once "include/page_header.php"; $node_data = get_node_by_nodeid($_REQUEST['nodeid']); $result = delete_node($_REQUEST['nodeid']); show_messages($result, S_NODE_DELETED, S_CANNOT_DELETE_NODE); - add_audit_if($result,AUDIT_ACTION_DELETE,'Node ['.$node_data['name'].'] id ['.$node_data['nodeid'].']'); + add_audit_if($result,AUDIT_ACTION_DELETE,AUDIT_RESOURCE_NODE,'Node ['.$node_data['name'].'] id ['.$node_data['nodeid'].']'); if($result) { unset($_REQUEST['form'],$node_data); @@ -118,7 +118,7 @@ include_once "include/page_header.php"; $db_nodes = DBselect('select * from nodes where nodeid in ('. get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '. - ' order by nodetype desc,name '); + ' order by nodetype desc, masterid, name '); while($row=DBfetch($db_nodes)) { |
