diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-29 08:47:18 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-29 08:47:18 +0000 |
| commit | 0990cdce6c98be640a3c70bea413ac1f44865016 (patch) | |
| tree | 97a9c36f69226f682f7326b668ee99b07ca6c684 /frontends/php/include | |
| parent | 3442ec61fa38eea4e68a3edea4ea3225ff78c8a0 (diff) | |
- changed IT Services interface (Artem)
- added class CTree
- added Javascript class for Cookies management
git-svn-id: svn://svn.zabbix.com/trunk@4188 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes/cbutton.inc.php | 25 | ||||
| -rw-r--r-- | frontends/php/include/classes/ccheckbox.inc.php | 24 | ||||
| -rw-r--r-- | frontends/php/include/classes/cformtable.inc.php | 121 | ||||
| -rw-r--r-- | frontends/php/include/classes/cpumenu.inc.php | 136 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctable.inc.php | 113 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctree.inc.php | 251 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 7 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 898 | ||||
| -rw-r--r-- | frontends/php/include/services.inc.php | 147 |
11 files changed, 1043 insertions, 681 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php index cf737cf9..30d6def4 100644 --- a/frontends/php/include/classes/cbutton.inc.php +++ b/frontends/php/include/classes/cbutton.inc.php @@ -19,11 +19,9 @@ **/ ?> <?php - class CButton extends CTag - { + class CButton extends CTag{ /* public */ - function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL) - { + function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL){ parent::CTag('input','no'); $this->tag_body_start = ''; $this->options['type'] = 'submit'; @@ -33,26 +31,29 @@ $this->SetAction($action); $this->SetAccessKey($accesskey); } - function SetAction($value=null) - { + + function SetAction($value=null){ $this->AddAction('onClick', $value); } - function SetTitle($value='button title') - { + + function SetTitle($value='button title'){ $this->AddOption('title', $value); } - function SetAccessKey($value='B') - { + + function SetAccessKey($value='B'){ if(isset($value)) if(!isset($this->options['title'])) $this->SetTitle($this->options['value'].' [Alt+'.$value.']'); return $this->AddOption('accessKey', $value); } + + function SetType($type="button"){ + $this->AddOption('type',$type); + } } - class CButtonCancel extends CButton - { + class CButtonCancel extends CButton{ function CButtonCancel($vars=NULL,$action=NULL){ parent::CButton('cancel',S_CANCEL); $this->options['type'] = 'button'; diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php index 84bf8eb3..d59e11a7 100644 --- a/frontends/php/include/classes/ccheckbox.inc.php +++ b/frontends/php/include/classes/ccheckbox.inc.php @@ -98,30 +98,24 @@ ?> <script language="JavaScript" type="text/javascript"> <!-- - function visibility_status_changeds(value, obj_name, replace_to) - { + function visibility_status_changeds(value, obj_name, replace_to){ var obj = document.getElementsByName(obj_name); if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]"; - for(i = obj.length-1; i>=0; i--) - { - if(replace_to && replace_to != "") - { - if(obj[i].originalObject) - { + for(i = obj.length-1; i>=0; i--){ + if(replace_to && replace_to != ""){ + if(obj[i].originalObject){ var old_obj = obj[i].originalObject; old_obj.originalObject = obj[i]; obj[i].parentNode.replaceChild(old_obj, obj[i]); } - else if(!value) - { + else if(!value){ var new_obj = null; try { new_obj = document.createElement("<a name='" + obj[i].name + "'>"); } - catch(err) - { + catch(err){ new_obj = document.createElement("a"); new_obj.name = obj[i].name; } @@ -133,13 +127,11 @@ new_obj.originalObject = obj[i]; obj[i].parentNode.replaceChild(new_obj, obj[i]); } - else - { + else{ throw "Missed originalObject for restoring"; } } - else - { + else{ value = value ? 'visible' : 'hidden'; obj[i].style.visibility = value; } diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php index 4f888c81..9a51d8d4 100644 --- a/frontends/php/include/classes/cformtable.inc.php +++ b/frontends/php/include/classes/cformtable.inc.php @@ -30,21 +30,19 @@ var $center_items = array(); var $bottom_items = array();*/ /* public */ - function CFormTable($title=null, $action=null, $method=null, $enctype=null, $form_variable=null) - { + function CFormTable($title=null, $action=null, $method=null, $enctype=null, $form_variable=null){ global $_REQUEST; $this->top_items = array(); $this->center_items = array(); $this->bottom_items = array(); + $this->tableclass = 'formtable'; - if( null == $method ) - { + if( null == $method ){ $method = 'get'; } - if( null == $form_variable ) - { + if( null == $form_variable ){ $form_variable = 'form'; } @@ -63,8 +61,8 @@ $this->bottom_items = new CCol(SPACE,'form_row_last'); $this->bottom_items->SetColSpan(2); } - function SetAction($value) - { + + function SetAction($value){ if(is_string($value)) return parent::SetAction($value); @@ -73,39 +71,36 @@ else return $this->error("Incorrect value for SetAction [$value]"); } - function SetName($value) - { - if(!is_string($value)) - { + + function SetName($value){ + if(!is_string($value)){ return $this->error("Incorrect value for SetAlign [$value]"); } return $this->AddOption('name',$value); } - function SetAlign($value) - { - if(!is_string($value)) - { + + function SetAlign($value){ + if(!is_string($value)){ return $this->error("Incorrect value for SetAlign [$value]"); } return $this->align = $value; } - function SetTitle($value=NULL) - { - if(is_null($value)) - { + + function SetTitle($value=NULL){ + if(is_null($value)){ unset($this->title); return 0; } -/* elseif(!is_string($value)) - { +/* + elseif(!is_string($value)){ return $this->error("Incorrect value for SetTitle [$value]"); } $this->title = nbsp($value); - */ +*/ $this->title = unpack_object($value); } - function SetHelp($value=NULL) - { + + function SetHelp($value=NULL){ if(is_null($value)) { $this->help = new CHelp(); } elseif(strtolower(get_class($value)) == 'chelp') { @@ -114,38 +109,48 @@ $this->help = new CHelp($value); if($this->GetName()==NULL) $this->SetName($value); - } else - { + } else { return $this->error("Incorrect value for SetHelp [$value]"); } return 0; } - function AddVar($name, $value) - { + + function AddVar($name, $value){ $this->AddItemToTopRow(new CVar($name, $value)); } - function AddItemToTopRow($value) - { + + function AddItemToTopRow($value){ array_push($this->top_items, $value); } - function AddRow($item1, $item2=NULL, $class=NULL) - { - if(is_string($item1)) - $item1=nbsp($item1); - - if(empty($item1)) $item1 = SPACE; - if(empty($item2)) $item2 = SPACE; - - $row = new CRow(array( - new CCol($item1,'form_row_l'), - new CCol($item2,'form_row_r') - ), - $class - ); - array_push($this->center_items, $row); + + function AddRow($item1, $item2=NULL, $class=NULL){ + if(strtolower(get_class($item1)) == 'crow'){ + + } elseif(strtolower(get_class($item1)) == 'ctable'){ + $td = new CCol($item1,'form_row_c'); + $td->SetColSpan(2); + + $item1 = new CRow($td); + + } else{ + if(is_string($item1)){ + $item1=nbsp($item1); + } + + if(empty($item1)) $item1 = SPACE; + if(empty($item2)) $item2 = SPACE; + + $item1 = new CRow(array( + new CCol($item1,'form_row_l'), + new CCol($item2,'form_row_r') + ), + $class); + } + + array_push($this->center_items, $item1); } - function AddSpanRow($value, $class=NULL) - { + + function AddSpanRow($value, $class=NULL){ if(is_string($value)) $item1=nbsp($value); @@ -156,16 +161,23 @@ $col->SetColSpan(2); array_push($this->center_items,new CRow($col)); } - function AddItemToBottomRow($value) - { + + + function AddItemToBottomRow($value){ $this->bottom_items->AddItem($value); } + + function SetTableClass($class){ + if(is_string($class)){ + $this->tableclass = $class; + } + } + /* protected */ - function BodyToString() - { + function BodyToString(){ parent::BodyToString(); - $tbl = new CTable(NULL,'formtable'); + $tbl = new CTable(NULL,$this->tableclass); $tbl->SetOddRowClass('form_odd_row'); $tbl->SetEvenRowClass('form_even_row'); @@ -174,7 +186,8 @@ $tbl->SetAlign($this->align); # add first row $col = new CCol(NULL,'form_row_first'); - $col->SetColSpan(2); + $col->SetColSpan(2); + if(isset($this->help)) $col->AddItem($this->help); if(isset($this->title)) $col->AddItem($this->title); foreach($this->top_items as $item) $col->AddItem($item); diff --git a/frontends/php/include/classes/cpumenu.inc.php b/frontends/php/include/classes/cpumenu.inc.php index 95cb104e..ef583ea6 100644 --- a/frontends/php/include/classes/cpumenu.inc.php +++ b/frontends/php/include/classes/cpumenu.inc.php @@ -1,69 +1,67 @@ -<?php -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -**/ -?> -<?php - class CPUMenu - { -/* private */ - /* - var $items = array(); - var $width; - */ -/* public */ - function CPUMenu($items=array(), $width=null) - { - $this->InsertJavaScript(); - /*********************** ITEM ARRAY *********************** - ITEM: array(name, url, param, css, submenu1, submenu2, ... , submenuN) - - name: text - url: text (url for href perameter) - param: array(tw => t_val, sb => s_val) - tw: target parameter - t_val: one of '_blank', '_parent', '_self', '_top' - sb: text for statusbar) - s_val: text - css: array(outer => cssarray, inner => cssarray) - outer -> style for outer div element - inner -> style for inner link element with text - cssarray -> array(normal, mouseover, mousedown) - submen1-N: list of subitems - **********************************************************/ - $this->items = $items; - $this->width = $width; - } - - function GetOnActionJS() - { - if(count($this->items) <= 0) return NULL; - - return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');'; - } - - function InsertJavaScript() - { - if(defined('CPUMENU_INSERTJAVASCRIPT_INSERTED')) return; - define('CPUMENU_INSERTJAVASCRIPT_INSERTED', 1); -?> -<script language="JavaScript" type="text/javascript" src="js/menu.js"></script> -<?php - } - } -?> +<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ class CPUMenu
+ {
+/* private */
+ /*
+ var $items = array();
+ var $width;
+ */
+/* public */
+ function CPUMenu($items=array(), $width=null)
+ {
+ $this->InsertJavaScript();
+ /*********************** ITEM ARRAY ***********************
+ ITEM: array(name, url, param, css, submenu1, submenu2, ... , submenuN)
+
+ name: text
+ url: text (url for href perameter)
+ param: array(tw => t_val, sb => s_val)
+ tw: target parameter
+ t_val: one of '_blank', '_parent', '_self', '_top'
+ sb: text for statusbar)
+ s_val: text
+ css: array(outer => cssarray, inner => cssarray)
+ outer -> style for outer div element
+ inner -> style for inner link element with text
+ cssarray -> array(normal, mouseover, mousedown)
+ submen1-N: list of subitems
+ **********************************************************/
+ $this->items = $items;
+ $this->width = $width;
+ }
+
+ function GetOnActionJS()
+ {
+ if(count($this->items) <= 0) return NULL;
+
+ return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');';
+ }
+
+ function InsertJavaScript()
+ {
+ if(defined('CPUMENU_INSERTJAVASCRIPT_INSERTED')) return;
+ define('CPUMENU_INSERTJAVASCRIPT_INSERTED', 1);
+ echo '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>';
+ }
+ }
+?>
diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php index 5001ec30..c54420e7 100644 --- a/frontends/php/include/classes/ctable.inc.php +++ b/frontends/php/include/classes/ctable.inc.php @@ -19,51 +19,49 @@ **/ ?> <?php - class CCol extends CTag - { + class CCol extends CTag{ /* public */ - function CCol($item=NULL,$class=NULL) - { + function CCol($item=NULL,$class=NULL){ parent::CTag("td","yes"); $this->AddItem($item); $this->SetClass($class); } - function SetAlign($value) - { + + function SetAlign($value){ return $this->options['align'] = $value; } - function SetRowSpan($value) - { + + function SetRowSpan($value){ return $this->options['rowspan'] = strval($value); } - function SetColSpan($value) - { + + function SetColSpan($value){ return $this->options['colspan'] =strval($value); } + + function SetWidth($value){ + if(is_string($value))$this->AddOption('width',$value); + } } - class CRow extends CTag - { + class CRow extends CTag{ /* public */ - function CRow($item=NULL,$class=NULL) - { + function CRow($item=NULL,$class=NULL){ parent::CTag("tr","yes"); $this->AddItem($item); $this->SetClass($class); } - function SetAlign($value) - { + + function SetAlign($value){ return $this->options['align'] = $value; } - function AddItem($item) - { + + function AddItem($item){ if(strtolower(get_class($item))=='ccol') { parent::AddItem($item); } - elseif(is_array($item)) - { - foreach($item as $el) - { + elseif(is_array($item)){ + foreach($item as $el){ if(strtolower(get_class($el))=='ccol') { parent::AddItem($el); } elseif(!is_null($el)) { @@ -71,15 +69,17 @@ } } } - elseif(!is_null($item)) - { + elseif(!is_null($item)){ parent::AddItem('<td>'.unpack_object($item).'</td>'); } } + + function SetWidth($value){ + if(is_string($value))$this->AddOption('width',$value); + } } - class CTable extends CTag - { + class CTable extends CTag{ /* protected *//* var $oddRowClass; var $evenRowClass; @@ -91,8 +91,7 @@ var $footerClass; var $message;*/ /* public */ - function CTable($message=NULL,$class=NULL) - { + function CTable($message=NULL,$class=NULL){ parent::CTag("table","yes"); $this->SetClass($class); @@ -109,29 +108,28 @@ $this->message = $message; } - function SetOddRowClass($value=NULL) - { + + function SetOddRowClass($value=NULL){ $this->oddRowClass = $value; } - function SetEvenRowClass($value=NULL) - { + + function SetEvenRowClass($value=NULL){ $this->evenRowClass = $value; } - function SetAlign($value) - { + + function SetAlign($value){ return $this->options['align'] = $value; } - function SetCellPadding($value) - { + + function SetCellPadding($value){ return $this->options['cellpadding'] = strval($value); } - function SetCellSpacing($value) - { + + function SetCellSpacing($value){ return $this->options['cellspacing'] = strval($value); } - function PrepareRow($item,$rowClass=NULL) - { + function PrepareRow($item,$rowClass=NULL){ if(is_null($item)) return NULL; if(strtolower(get_class($item))=='ccol') { @@ -144,20 +142,18 @@ if(isset($rowClass)) $item->SetClass($rowClass); } - else - { + else{ $item = new CRow($item,$rowClass); } - if(!isset($item->options['class'])) - { + if(!isset($item->options['class'])){ $item->SetClass(($this->rownum % 2) ? $this->oddRowClass: $this->evenRowClass); }/**/ return $item->ToString(); } - function SetHeader($value=NULL,$class=NULL) - { + + function SetHeader($value=NULL,$class=NULL){ if(is_null($class)) $class = $this->headerClass; if(strtolower(get_class($value))=='crow') { @@ -168,40 +164,37 @@ $this->colnum = $value->ItemsCount(); $this->header = $value->ToString(); } - function SetFooter($value=NULL,$class=NULL) - { + + function SetFooter($value=NULL,$class=NULL){ if(is_null($class)) $class = $this->footerClass; $this->footer = $this->PrepareRow($value,$class);; } - function AddRow($item,$rowClass=NULL) - { + + function AddRow($item,$rowClass=NULL){ $item = $this->AddItem($this->PrepareRow($item,$rowClass)); ++$this->rownum; return $item; } - function ShowRow($item,$rowClass=NULL) - { + + function ShowRow($item,$rowClass=NULL){ echo $this->PrepareRow($item,$rowClass); ++$this->rownum; } /* protected */ - function GetNumRows() - { + function GetNumRows(){ return $this->rownum; } - function StartToString() - { + function StartToString(){ $ret = parent::StartToString(); $ret .= $this->header; return $ret; } - function EndToString() - { + + function EndToString(){ $ret = ""; - if($this->rownum == 0 && isset($this->message)) - { + if($this->rownum == 0 && isset($this->message)) { $ret = $this->PrepareRow(new CCol($this->message,'message')); } $ret .= $this->footer; diff --git a/frontends/php/include/classes/ctree.inc.php b/frontends/php/include/classes/ctree.inc.php new file mode 100644 index 00000000..9b2412be --- /dev/null +++ b/frontends/php/include/classes/ctree.inc.php @@ -0,0 +1,251 @@ +<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+class CTree{
+
+/*public*/
+var $tree='';
+var $fields='';
+var $treename='';
+
+/*private*/
+var $size=0;
+var $maxlevel=0;
+
+
+/*public*/
+function CTree($value=array(),$fields=array()){
+// parent::CTable();
+ $this->tree = $value;
+ $this->fields = $fields;
+ $this->treename = $this->fields['caption'];
+
+ $this->size = count($value);
+ unset($value);
+ unset($fields);
+
+ if(!$this->CheckTree()){
+ $this->Destroy();
+ return false;
+ } else {
+ $this->CountDepth();
+ }
+}
+
+function GetTree(){
+ return $this->tree;
+}
+
+/*private*/
+function MakeHeaders(){
+ $c=0;
+ $tr = new CRow();
+ $tr->AddItem($this->fields['caption']);
+ $tr->SetClass('treeheader');
+ unset($this->fields['caption']);
+ foreach($this->fields as $id => $caption){
+ $tr->AddItem($caption);
+ $fields[$c] = $id;
+ $c++;
+ }
+ $this->fields = $fields;
+return $tr;
+}
+
+function SimpleHTML(){
+ $table = new CTableInfo('','tabletree');
+
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+
+ $table->oddRowClass = 'odd_row';
+ $table->evenRowClass = 'even_row';
+ $table->headerClass = 'header';
+ $table->footerClass = 'footer';
+
+ $table->AddOption('border','0');
+ $table->AddRow($this->MakeHeaders());
+// $table->AddRow();
+ foreach($this->tree as $id => $rows){
+ $table->AddRow($this->MakeSHTMLRow($id));
+ }
+return $table->ToString();
+}
+
+
+function MakeSHTMLRow($id){
+ $table = new CTable();
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+ $table->AddOption('width','200');
+
+ $tr = $this->MakeSImgStr($id);
+
+ $td = new CCol($this->tree[$id]['caption']);
+ $td->SetAlign('left');
+
+
+ $tr->AddItem($td);
+ $table->AddRow($tr);
+
+ $tr = new CRow();
+ $tr->AddItem($table);
+ $tr->AddOption('id',$id);
+// $tr->AddOption('ntype',$this->tree[$id]['childs']);
+ $tr->AddOption('style',($this->tree[$id]['parentid'] != '0')?('display: none;'):(''));
+
+ foreach($this->fields as $key => $value){
+// $tr->AddItem(' ');
+ $td = new CCol($this->tree[$id][$value]);
+// $td->SetAlign('left');
+ $tr->AddItem($td);
+ }
+return $tr;
+}
+
+function MakeSImgStr($id){
+ $tr = new CRow();
+ $tr->AddOption('height',18);
+ $count=(isset($this->tree[$id]['nodeimg']))?(strlen($this->tree[$id]['nodeimg'])):(0);
+ for($i=0; $i<$count; $i++){
+ switch($this->tree[$id]['nodeimg'][$i]){
+ case 'O':
+ $img= new CImg('images/general/tree/O.gif','o','22','18');
+ break;
+ case 'I':
+ $img= new CImg('images/general/tree/I.gif','i','22','18');
+ break;
+ case 'L':
+ if($this->tree[$id]['nodetype'] == 2){
+ $img= new CImg('images/general/tree/Yc.gif','y','22','18');
+ $img->AddOption('OnClick','javascript: tree.closeSNodeX('.$id.',this);');
+ $img->AddOption('id',$id.'I');
+ $img->SetClass('imgnode');
+
+ } else {
+ $img= new CImg('images/general/tree/L.gif','l','22','18');
+ }
+ break;
+ case 'T':
+ if($this->tree[$id]['nodetype'] == 2){
+ $img= new CImg('images/general/tree/Xc.gif','x','22','18');
+ $img->AddOption('OnClick','javascript: tree.closeSNodeX('.$id.',this);');
+ $img->AddOption('id',$id.'I');
+ $img->SetClass('imgnode');
+ } else {
+ $img= new CImg('images/general/tree/T.gif','t','22','18');
+ }
+ break;
+ }
+ $td = new CCol($img,'tdtree');
+ $tr->AddItem($td);
+ }
+// echo $txt.' '.$this->tree[$id]['Name'].'<br />';
+return $tr;
+}
+
+function CountDepth(){
+ foreach($this->tree as $id => $rows){
+
+ if($id == '0'){
+ continue;
+ }
+ $parentid = $this->tree[$id]['parentid'];
+
+ $this->tree[$id]['nodeimg'] = $this->GetImg($id,(isset($this->tree[$parentid]['nodeimg']))?($this->tree[$parentid]['nodeimg']):(''));
+ //$this->tree[$parentid]['childs'] = ($this->tree[$parentid]['childs']+$this->tree[$id]['childs']+1);
+
+ $this->tree[$parentid]['nodetype'] = 2;
+
+ $this->tree[$id]['Level'] = (isset($this->tree[$parentid]['Level']))?($this->tree[$parentid]['Level']+1):(1);
+
+ ($this->maxlevel>$this->tree[$id]['Level'])?(''):($this->maxlevel = $this->tree[$id]['Level']);
+ }
+
+}
+
+
+function CreateJS(){
+global $page;
+ $js = '
+ <script src="js/tree.js" type="text/javascript"></script>
+ <script src="js/cookies.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ var treenode = new Array(0);
+ var tree_name = "tree_'.$this->getUserAlias().'_'.$page["file"].'";
+ ';
+
+ foreach($this->tree as $id => $rows){
+ $parentid = $rows['parentid'];
+ $this->tree[$parentid]['nodelist'].=$id.'.';
+ }
+
+ foreach($this->tree as $id => $rows){
+ if($rows['nodetype'] == '2'){
+ $js .= 'treenode['.$id.'] = { status: \'close\', nodelist : \''.$rows['nodelist'].'\', parentid : \''.$rows['parentid'].'\'};';
+ }
+ }
+return $js.'window.onload = function(){tree.init()};
+</script>';
+}
+
+function GetImg($id,$img){
+ $img=str_replace('T','I',$img);
+ $img=str_replace('L','O',$img);
+ $ch = 'L';
+
+ $childs = $this->tree[$this->tree[$id]['parentid']]['childnodes'];
+ $childs_last = count($this->tree[$this->tree[$id]['parentid']]['childnodes'])-1;
+
+ if(isset($childs[$childs_last]) && ($childs[$childs_last] != $id)){
+ $ch='T';
+ }
+ $img.=$ch;
+return $img;
+}
+
+function CheckTree(){
+ if(!is_array($this->tree)){
+ return false;
+ }
+ foreach($this->tree as $id => $cell){
+ $this->tree[$id]['nodetype'] = 0;
+
+ $parentid=$cell['parentid'];
+ $this->tree[$parentid]['childnodes'][] = $id;
+
+ $this->tree[$id]['nodelist'] = '';
+// echo $id.BR;
+ }
+
+return true;
+}
+
+function Destroy(){
+ unset($this->tree);
+}
+
+function getUserAlias(){
+global $USER_DETAILS;
+return $USER_DETAILS["alias"];
+}
+}
+
+?>
\ No newline at end of file diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index a0a95118..314a974c 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -60,6 +60,7 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! require_once("include/classes/ciframe.inc.php"); require_once("include/classes/cpumenu.inc.php"); require_once("include/classes/graph.inc.php"); +require_once('include/classes/ctree.inc.php'); // Include Tactical Overview modules diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 9f3619f7..8fb45872 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -414,6 +414,7 @@ COpt::savesqlrequest($query); return $result; } + /* string value prepearing */ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 9cd30829..c3518f06 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -1093,6 +1093,9 @@ 'S_SERVICE_TIMES'=> 'Service times', 'S_NEW_SERVICE_TIME'=> 'New service time', 'S_NOTE'=> 'Note', + 'S_SOFT_LINK'=> 'Soft Link', + 'S_REMOVE'=> 'Remove', + 'S_DEPENDS_ON'=> 'Depends on', 'S_SUNDAY'=> 'Sunday', 'S_MONDAY'=> 'Monday', @@ -1154,6 +1157,7 @@ 'S_SHOW_DISABLED_TRIGGERS'=> 'Show disabled triggers', 'S_HIDE_DISABLED_TRIGGERS'=> 'Hide disabled triggers', + // tr_comments.php 'S_TRIGGER_COMMENTS'=> 'Trigger comments', 'S_TRIGGER_COMMENTS_BIG'=> 'TRIGGER COMMENTS', @@ -1302,6 +1306,7 @@ 'S_LATEST_DATA'=> 'Latest data', // Errors - 'S_INCORRECT_DESCRIPTION'=> 'Incorrect description' + 'S_INCORRECT_DESCRIPTION'=> 'Incorrect description', + 'S_CANT_FORMAT_TREE'=> 'Can\'t format Tree' ); ?> diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 2eb67272..7c2015bd 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -1,448 +1,450 @@ -<?php -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -**/ -?> -<?php - require_once("include/config.inc.php"); - require_once("include/perm.inc.php"); - - - global $USER_DETAILS; - global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID; - global $ZBX_CURNODEID, $ZBX_CURMASTERID; - global $page; - -COpt::profiling_start("page"); - - unset($denyed_page_requested); - - if(!isset($page["type"])) $page["type"] = PAGE_TYPE_HTML; - if(!isset($page["file"])) $page["file"] = basename($_SERVER['PHP_SELF']); - - include_once "include/locales/en_gb.inc.php"; - process_locales(); - - /* Init CURRENT NODE ID */ - init_nodes(); - - /* set Page header */ - switch($page["type"]) - { - case PAGE_TYPE_IMAGE: - set_image_header(); - define('ZBX_PAGE_NO_MENU', 1); - break; - case PAGE_TYPE_XML: - header('Content-Type: text/xml'); - header('Content-Disposition: attachment; filename="'.$page['file'].'"'); - define('ZBX_PAGE_NO_MENU', 1); - break; - case PAGE_TYPE_HTML: - default: - header('Content-Type: text/html; charset='.S_HTML_CHARSET); - - if(isset($page['title']) && defined($page['title'])) $page['title'] = constant($page['title']); - - if(!isset($page['title'])) $page['title'] = 'ZABBIX'; - - if(defined('ZBX_DISTRIBUTED')) - { - if($curr_node_data = DBfetch(DBselect('select * from nodes where nodeid='.$ZBX_CURNODEID))) - $page['title'] .= ' ('.$curr_node_data['name'].')'; - } - if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"]) - { - $page['title'] .= ' [refreshed every '.$USER_DETAILS['refresh'].' sec]'; - /* header('Refresh: '.$USER_DETAILS["refresh"]); */ /* is not part of the official HTTP specification */ - } - break; /* case PAGE_TYPE_HTML */ - } /* switch($page["type"]) */ - - /* NOTE - menu array format: - first level: - 'label' = main menu title. - 'default_page_id = default page url from 'pages' then opened menu. - 'pages' = collection of pages whitch displayed from this menu - this pages are saved a last visited submenu of main menu. - - second level (pages): - 'url' = real url for this page - 'label' = submenu title, if missed menu skipped, but remmembed as last visited page. - 'sub_pages' = collection of pages for displaying but dont remember as last visited. - - */ - $ZBX_MENU = array( - "view"=>array( - "label" => S_MONITORING, - "node_perm" => PERM_READ_LIST, - "default_page_id" => 0, - "pages"=>array( - array("url"=>"overview.php" ,"label"=>S_OVERVIEW ), - array("url"=>"httpmon.php" ,"label"=>S_WEB , - "sub_pages"=>array("httpdetails.php") - ), - array("url"=>"latest.php" ,"label"=>S_LATEST_DATA , - "sub_pages"=>array("history.php","chart.php") - ), - array("url"=>"tr_status.php" ,"label"=>S_TRIGGERS , - "sub_pages"=>array("tr_events.php","acknow.php","tr_comments.php", - "chart4.php") - ), - array("url"=>"queue.php" ,"label"=>S_QUEUE ), - array("url"=>"events.php" ,"label"=>S_EVENTS ), - array("url"=>"actions.php" ,"label"=>S_ACTIONS ), - array("url"=>"maps.php" ,"label"=>S_MAPS , - "sub_pages"=>array("map.php") - ), - array("url"=>"charts.php" ,"label"=>S_GRAPHS , - "sub_pages"=>array("chart2.php") - ), - array("url"=>"screens.php" ,"label"=>S_SCREENS ), - array("url"=>"discovery.php" ,"label"=>S_DISCOVERY , "user_type"=>USER_TYPE_ZABBIX_ADMIN), - array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES , - "sub_pages"=>array("report3.php","chart_sla.php","chart5.php") - ), - array("url"=>"vtext.php"), - array("url"=>"chart3.php") - ) - ), - "cm"=>array( - "label" => S_INVENTORY, - "node_perm" => PERM_READ_LIST, - "default_page_id" => 0, - "pages"=>array( - array("url"=>"hostprofiles.php" ,"label"=>S_HOSTS ) - ) - ), - "reports"=>array( - "label" => S_REPORTS, - "node_perm" => PERM_READ_LIST, - "default_page_id" => 0, - "pages"=>array( - array("url"=>"report1.php", "label"=>S_STATUS_OF_ZABBIX ), - array("url"=>"report2.php", "label"=>S_AVAILABILITY_REPORT ), - array("url"=>"report5.php", "label"=>S_TRIGGERS_TOP_100 ) - ) - ), - "config"=>array( - "label" => S_CONFIGURATION, - "user_type" => USER_TYPE_ZABBIX_ADMIN, - "node_perm" => PERM_READ_LIST, - "default_page_id" => 0, - "pages"=>array( - array("url"=>"config.php" ,"label"=>S_GENERAL , - "sub_pages"=>array("image.php") - ), - array("url"=>"httpconf.php" ,"label"=>S_WEB , - "sub_pages"=>array("popup_httpstep.php") - ), - array("url"=>"hosts.php" ,"label"=>S_HOSTS ), - array("url"=>"items.php" ,"label"=>S_ITEMS ), - array("url"=>"triggers.php" ,"label"=>S_TRIGGERS , - "sub_pages"=>array("popup_trexpr.php") - ), - array("url"=>"actionconf.php" ,"label"=>S_ACTIONS ), - array("url"=>"sysmaps.php" ,"label"=>S_MAPS , - "sub_pages"=>array("sysmap.php") - ), - array("url"=>"graphs.php" ,"label"=>S_GRAPHS , - "sub_pages"=>array("popup_gitem.php") - ), - array("url"=>"screenconf.php" ,"label"=>S_SCREENS , - "sub_pages"=>array("screenedit.php") - ), - array("url"=>"services.php" ,"label"=>S_IT_SERVICES ), - array('url'=>'discoveryconf.php','label'=>S_DISCOVERY ), - array("url"=>"exp_imp.php" ,"label"=>S_EXPORT_IMPORT ), - array("url"=>"popup.php") - ) - ), - "admin"=>array( - "label" => S_ADMINISTRATION, - "user_type" => USER_TYPE_SUPER_ADMIN, - "node_perm" => PERM_READ_WRITE, - "default_page_id" => 1, - "pages"=>array( - ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null , - array("url"=>"users.php" ,"label"=>S_USERS , - "sub_pages"=>array("popup_media.php", - "popup_usrgrp.php","popup_right.php","popup_users.php") - ), - array("url"=>"media_types.php" ,"label"=>S_MEDIA_TYPES ), - array("url"=>"audit.php" ,"label"=>S_AUDIT ), - array("url"=>"report4.php" ,"label"=>S_NOTIFICATIONS ), - array("url"=>"instal.php" ,"label"=>S_INSTALLATION , - "sub_pages"=>array("setup.php")) - ) - ), - "login"=>array( - "label" => S_LOGIN, - "default_page_id" => 0, - "pages"=>array( - array("url"=>"index.php", - "sub_pages"=>array("profile.php") - ) - ) - ) - ); - - $main_menu_row = array(); - $sub_menu_row = array(); - - foreach($ZBX_MENU as $label=>$sub) - { -// Check permissions for main menu - unset($deny); - if(!defined('ZBX_PAGE_NO_AUTHERIZATION')) - { - if(isset($sub['user_type'])) - { - if($USER_DETAILS['type'] < $sub['user_type']) - $deny = true; - } - - if(isset($sub['node_perm'])) - { - if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user( - $USER_DETAILS,$sub['node_perm'],null, - PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))) - $deny = true; - } - - if($label=='login') - { - unset($deny); - } - } - -// End of main menu permissions checking - - unset($menu_url); - foreach($sub['pages'] as $id => $sub_pages) - { - if(!defined('ZBX_PAGE_NO_AUTHERIZATION')) - { - if(isset($sub_pages['user_type'])) - { - if($USER_DETAILS['type'] < $sub_pages['user_type']) - { - unset($sub['pages'][$id]); - continue; - } - } - - if(isset($sub_pages['node_perm'])) - { - if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user( - $USER_DETAILS,$sub_pages['node_perm'],null, - PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))) - { - unset($sub['pages'][$id]); - continue; - } - } - } - - if(isset($page_exist)) continue; - - if($page['file'] == $sub_pages['url']) - { - if(isset($sub_pages['label'])) - { - $menu_url = $sub_pages['url']; - } - $page_exist = true; - $sub['pages'][$id]['active'] = true; /* mark as active */ - } - else if(isset($sub_pages['sub_pages'])) - { - if(in_array($page['file'], $sub_pages['sub_pages'])) - { - if(isset($sub_pages['label'])) - { - $menu_url = $sub_pages['url']; - } - $page_exist = true; - $sub['pages'][$id]['active'] = true; /* mark as active */ - } - } - } - - if(isset($menu_url)) /* active menu */ - { - $class = "active"; - - update_profile('web.menu.'.$label.'.last', $menu_url); - - if(isset($deny)) - { - $denyed_page_requested = true; - continue; - } - - foreach($sub['pages'] as $sub_pages) - { - if(!isset($sub_pages['label'])) continue; - - $label = new CLink($sub_pages['label'], $sub_pages['url'],'highlight'); - if(isset($sub_pages['active'])) $label = new CSpan($label, 'active'); - - array_push($sub_menu_row, - $label, - new CSpan(SPACE.SPACE.'|'.SPACE.SPACE, 'divider') - ); - } - } - else - { - if(isset($deny)) continue; - - $class = "horizontal_menu_n"; - - $menu_url = get_profile('web.menu.'.$label.'.last',false); - - if(!$menu_url) - $menu_url = $sub['pages'][$sub['default_page_id']]["url"]; - } - - array_push($main_menu_row, new CCol(new CLink($sub['label'], $menu_url, "highlight"),$class)); - unset($menu_url, $class); - } - - if((!isset($page_exist) && $page['type']!=PAGE_TYPE_XML)) - { - $denyed_page_requested = true; - } - - zbx_flush_post_cookies(isset($denyed_page_requested)); - - if($page["type"] == PAGE_TYPE_HTML) - { -?> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title><?php echo $page['title'] ?></title> -<?php if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"]) { ?> - <meta http-equiv="refresh" content="<?php echo $USER_DETAILS["refresh"]; ?>"> -<?php } ?> - <link rel="stylesheet" href="css.css"> - <meta name="Author" content="ZABBIX SIA"> - <script type="text/javascript" src="js/common.js"></script> - </head> -<body onLoad="zbxCallPostScripts();"> -<?php - } - - define ('PAGE_HEADER_LOADED', 1); - - if(!defined('ZBX_PAGE_NO_MENU')) - { -COpt::compare_files_with_menu($ZBX_MENU); - - $help = new CLink(S_HELP, "http://www.zabbix.com/manual/v1.1/index.php", "small_font"); - $help->SetTarget('_blank'); - $page_header_r_col = array($help, - ($USER_DETAILS["alias"] != "guest") ? - array("|", new CLink(S_PROFILE, "profile.php", "small_font")) : - null - ); - $logo = new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com"); - $logo->SetTarget('_blank'); - - $top_page_row = array(new CCol($logo, "page_header_l"), new CCol($page_header_r_col, "page_header_r")); - unset($logo, $page_header_r_col, $help); - - $table = new CTable(NULL,"page_header"); - $table->SetCellSpacing(0); - $table->SetCellPadding(5); - $table->AddRow($top_page_row); - $table->Show(); - - $menu_table = new CTable(NULL,'menu'); - $menu_table->SetCellSpacing(0); - $menu_table->SetCellPadding(5); - $menu_table->AddRow($main_menu_row); - - $node_form = null; - - if(ZBX_DISTRIBUTED) - { - $lst_nodes = new CComboBox('switch_node', $ZBX_CURNODEID); - $db_nodes = DBselect('select * from nodes where nodeid in ('. - get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '. - ' order by name '); - while($node_data = DBfetch($db_nodes)) - { - $lst_nodes->AddItem($node_data['nodeid'],$node_data['name']); - } - - if($lst_nodes->ItemsCount()) - { - $node_form = new CForm(); - $node_form->AddItem(S_CURRENT_NODE.' ['.$ZBX_CURNODEID.'] '); - $node_form->AddItem($lst_nodes); - unset($lst_nodes); - $node_form->AddItem(new CButton('submit',S_SWITCH)); - } - } - - $table = new CTable(); - $table->SetCellSpacing(0); - $table->SetCellPadding(0); - $table->options['style'] = "width: 100%;"; - - $r_col = new CCol($node_form); - $r_col->options['style'] = "text-align: right;"; - - $table->AddRow(array($menu_table,$r_col)); - $table->Show(); - - $sub_menu_table = new CTable(NULL,'sub_menu'); - $sub_menu_table->SetCellSpacing(0); - $sub_menu_table->SetCellPadding(5); - $sub_menu_table->AddRow(new CCol($sub_menu_row)); - - $sub_menu_table->Show(); - } - unset($ZBX_MENU); - - unset($table, $top_page_row, $menu_table, $node_form); - unset($main_menu_row); - unset($db_nodes, $node_data); - unset($sub_menu_table, $sub_menu_row); - - if(isset($denyed_page_requested)) - { - access_deny(); - } - - if(version_compare(phpversion(), '5.1.0RC1', '>=') && $page['type'] == PAGE_TYPE_HTML) - { - $tmezone = ini_get('date.timezone'); - if(empty($tmezone)) - { - info('Timezone for PHP is not set. Please set "date.timezone" option in php.ini.'); - date_default_timezone_set('UTC'); - } - unset($tmezone); - } - - show_messages(); -?> +<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once("include/config.inc.php");
+ require_once("include/perm.inc.php");
+
+
+ global $USER_DETAILS;
+ global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID;
+ global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $page;
+
+COpt::profiling_start("page");
+
+ unset($denyed_page_requested);
+
+ if(!isset($page["type"])) $page["type"] = PAGE_TYPE_HTML;
+ if(!isset($page["file"])) $page["file"] = basename($_SERVER['PHP_SELF']);
+
+ include_once "include/locales/en_gb.inc.php";
+ process_locales();
+
+ /* Init CURRENT NODE ID */
+ init_nodes();
+
+ /* set Page header */
+ switch($page["type"])
+ {
+ case PAGE_TYPE_IMAGE:
+ set_image_header();
+ define('ZBX_PAGE_NO_MENU', 1);
+ break;
+ case PAGE_TYPE_XML:
+ header('Content-Type: text/xml');
+ header('Content-Disposition: attachment; filename="'.$page['file'].'"');
+ define('ZBX_PAGE_NO_MENU', 1);
+ break;
+ case PAGE_TYPE_HTML:
+ default:
+ header('Content-Type: text/html; charset='.S_HTML_CHARSET);
+
+ if(isset($page['title']) && defined($page['title'])) $page['title'] = constant($page['title']);
+
+ if(!isset($page['title'])) $page['title'] = 'ZABBIX';
+
+ if(defined('ZBX_DISTRIBUTED'))
+ {
+ if($curr_node_data = DBfetch(DBselect('select * from nodes where nodeid='.$ZBX_CURNODEID)))
+ $page['title'] .= ' ('.$curr_node_data['name'].')';
+ }
+ if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"])
+ {
+ $page['title'] .= ' [refreshed every '.$USER_DETAILS['refresh'].' sec]';
+ /* header('Refresh: '.$USER_DETAILS["refresh"]); */ /* is not part of the official HTTP specification */
+ }
+ break; /* case PAGE_TYPE_HTML */
+ } /* switch($page["type"]) */
+
+ /* NOTE - menu array format:
+ first level:
+ 'label' = main menu title.
+ 'default_page_id = default page url from 'pages' then opened menu.
+ 'pages' = collection of pages whitch displayed from this menu
+ this pages are saved a last visited submenu of main menu.
+
+ second level (pages):
+ 'url' = real url for this page
+ 'label' = submenu title, if missed menu skipped, but remmembed as last visited page.
+ 'sub_pages' = collection of pages for displaying but dont remember as last visited.
+
+ */
+ $ZBX_MENU = array(
+ "view"=>array(
+ "label" => S_MONITORING,
+ "node_perm" => PERM_READ_LIST,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"overview.php" ,"label"=>S_OVERVIEW ),
+ array("url"=>"httpmon.php" ,"label"=>S_WEB ,
+ "sub_pages"=>array("httpdetails.php")
+ ),
+ array("url"=>"latest.php" ,"label"=>S_LATEST_DATA ,
+ "sub_pages"=>array("history.php","chart.php")
+ ),
+ array("url"=>"tr_status.php" ,"label"=>S_TRIGGERS ,
+ "sub_pages"=>array("tr_events.php","acknow.php","tr_comments.php",
+ "chart4.php")
+ ),
+ array("url"=>"queue.php" ,"label"=>S_QUEUE ),
+ array("url"=>"events.php" ,"label"=>S_EVENTS ),
+ array("url"=>"actions.php" ,"label"=>S_ACTIONS ),
+ array("url"=>"maps.php" ,"label"=>S_MAPS ,
+ "sub_pages"=>array("map.php")
+ ),
+ array("url"=>"charts.php" ,"label"=>S_GRAPHS ,
+ "sub_pages"=>array("chart2.php")
+ ),
+ array("url"=>"screens.php" ,"label"=>S_SCREENS ),
+ array("url"=>"discovery.php" ,"label"=>S_DISCOVERY , "user_type"=>USER_TYPE_ZABBIX_ADMIN),
+ array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES ,
+ "sub_pages"=>array("report3.php","chart_sla.php","chart5.php")
+ ),
+ array("url"=>"vtext.php"),
+ array("url"=>"chart3.php")
+ )
+ ),
+ "cm"=>array(
+ "label" => S_INVENTORY,
+ "node_perm" => PERM_READ_LIST,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"hostprofiles.php" ,"label"=>S_HOSTS )
+ )
+ ),
+ "reports"=>array(
+ "label" => S_REPORTS,
+ "node_perm" => PERM_READ_LIST,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"report1.php", "label"=>S_STATUS_OF_ZABBIX ),
+ array("url"=>"report2.php", "label"=>S_AVAILABILITY_REPORT ),
+ array("url"=>"report5.php", "label"=>S_TRIGGERS_TOP_100 )
+ )
+ ),
+ "config"=>array(
+ "label" => S_CONFIGURATION,
+ "user_type" => USER_TYPE_ZABBIX_ADMIN,
+ "node_perm" => PERM_READ_LIST,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"config.php" ,"label"=>S_GENERAL ,
+ "sub_pages"=>array("image.php")
+ ),
+ array("url"=>"httpconf.php" ,"label"=>S_WEB ,
+ "sub_pages"=>array("popup_httpstep.php")
+ ),
+ array("url"=>"hosts.php" ,"label"=>S_HOSTS ),
+ array("url"=>"items.php" ,"label"=>S_ITEMS ),
+ array("url"=>"triggers.php" ,"label"=>S_TRIGGERS ,
+ "sub_pages"=>array("popup_trexpr.php")
+ ),
+ array("url"=>"actionconf.php" ,"label"=>S_ACTIONS ),
+ array("url"=>"sysmaps.php" ,"label"=>S_MAPS ,
+ "sub_pages"=>array("sysmap.php")
+ ),
+ array("url"=>"graphs.php" ,"label"=>S_GRAPHS ,
+ "sub_pages"=>array("popup_gitem.php")
+ ),
+ array("url"=>"screenconf.php" ,"label"=>S_SCREENS ,
+ "sub_pages"=>array("screenedit.php")
+ ),
+ array("url"=>"services.php" ,"label"=>S_IT_SERVICES ,
+ "sub_pages"=>array("services_form.php")
+ ),
+ array('url'=>'discoveryconf.php','label'=>S_DISCOVERY ),
+ array("url"=>"exp_imp.php" ,"label"=>S_EXPORT_IMPORT ),
+ array("url"=>"popup.php")
+ )
+ ),
+ "admin"=>array(
+ "label" => S_ADMINISTRATION,
+ "user_type" => USER_TYPE_SUPER_ADMIN,
+ "node_perm" => PERM_READ_WRITE,
+ "default_page_id" => 1,
+ "pages"=>array(
+ ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null ,
+ array("url"=>"users.php" ,"label"=>S_USERS ,
+ "sub_pages"=>array("popup_media.php",
+ "popup_usrgrp.php","popup_right.php","popup_users.php")
+ ),
+ array("url"=>"media_types.php" ,"label"=>S_MEDIA_TYPES ),
+ array("url"=>"audit.php" ,"label"=>S_AUDIT ),
+ array("url"=>"report4.php" ,"label"=>S_NOTIFICATIONS ),
+ array("url"=>"instal.php" ,"label"=>S_INSTALLATION ,
+ "sub_pages"=>array("setup.php"))
+ )
+ ),
+ "login"=>array(
+ "label" => S_LOGIN,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"index.php",
+ "sub_pages"=>array("profile.php")
+ )
+ )
+ )
+ );
+
+ $main_menu_row = array();
+ $sub_menu_row = array();
+
+ foreach($ZBX_MENU as $label=>$sub)
+ {
+// Check permissions for main menu
+ unset($deny);
+ if(!defined('ZBX_PAGE_NO_AUTHERIZATION'))
+ {
+ if(isset($sub['user_type']))
+ {
+ if($USER_DETAILS['type'] < $sub['user_type'])
+ $deny = true;
+ }
+
+ if(isset($sub['node_perm']))
+ {
+ if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user(
+ $USER_DETAILS,$sub['node_perm'],null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ $deny = true;
+ }
+
+ if($label=='login')
+ {
+ unset($deny);
+ }
+ }
+
+// End of main menu permissions checking
+
+ unset($menu_url);
+ foreach($sub['pages'] as $id => $sub_pages)
+ {
+ if(!defined('ZBX_PAGE_NO_AUTHERIZATION'))
+ {
+ if(isset($sub_pages['user_type']))
+ {
+ if($USER_DETAILS['type'] < $sub_pages['user_type'])
+ {
+ unset($sub['pages'][$id]);
+ continue;
+ }
+ }
+
+ if(isset($sub_pages['node_perm']))
+ {
+ if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user(
+ $USER_DETAILS,$sub_pages['node_perm'],null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ unset($sub['pages'][$id]);
+ continue;
+ }
+ }
+ }
+
+ if(isset($page_exist)) continue;
+
+ if($page['file'] == $sub_pages['url'])
+ {
+ if(isset($sub_pages['label']))
+ {
+ $menu_url = $sub_pages['url'];
+ }
+ $page_exist = true;
+ $sub['pages'][$id]['active'] = true; /* mark as active */
+ }
+ else if(isset($sub_pages['sub_pages']))
+ {
+ if(in_array($page['file'], $sub_pages['sub_pages']))
+ {
+ if(isset($sub_pages['label']))
+ {
+ $menu_url = $sub_pages['url'];
+ }
+ $page_exist = true;
+ $sub['pages'][$id]['active'] = true; /* mark as active */
+ }
+ }
+ }
+
+ if(isset($menu_url)) /* active menu */
+ {
+ $class = "active";
+
+ update_profile('web.menu.'.$label.'.last', $menu_url);
+
+ if(isset($deny))
+ {
+ $denyed_page_requested = true;
+ continue;
+ }
+
+ foreach($sub['pages'] as $sub_pages)
+ {
+ if(!isset($sub_pages['label'])) continue;
+
+ $label = new CLink($sub_pages['label'], $sub_pages['url'],'highlight');
+ if(isset($sub_pages['active'])) $label = new CSpan($label, 'active');
+
+ array_push($sub_menu_row,
+ $label,
+ new CSpan(SPACE.SPACE.'|'.SPACE.SPACE, 'divider')
+ );
+ }
+ }
+ else
+ {
+ if(isset($deny)) continue;
+
+ $class = "horizontal_menu_n";
+
+ $menu_url = get_profile('web.menu.'.$label.'.last',false);
+
+ if(!$menu_url)
+ $menu_url = $sub['pages'][$sub['default_page_id']]["url"];
+ }
+
+ array_push($main_menu_row, new CCol(new CLink($sub['label'], $menu_url, "highlight"),$class));
+ unset($menu_url, $class);
+ }
+
+ if((!isset($page_exist) && $page['type']!=PAGE_TYPE_XML))
+ {
+ $denyed_page_requested = true;
+ }
+
+ zbx_flush_post_cookies(isset($denyed_page_requested));
+
+ if($page["type"] == PAGE_TYPE_HTML)
+ {
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title><?php echo $page['title'] ?></title>
+<?php if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"]) { ?>
+ <meta http-equiv="refresh" content="<?php echo $USER_DETAILS["refresh"]; ?>">
+<?php } ?>
+ <link rel="stylesheet" href="css.css">
+ <meta name="Author" content="ZABBIX SIA">
+ <script type="text/javascript" src="js/common.js"></script>
+ </head>
+<body onLoad="zbxCallPostScripts();">
+<?php
+ }
+
+ define ('PAGE_HEADER_LOADED', 1);
+
+ if(!defined('ZBX_PAGE_NO_MENU'))
+ {
+COpt::compare_files_with_menu($ZBX_MENU);
+
+ $help = new CLink(S_HELP, "http://www.zabbix.com/manual/v1.1/index.php", "small_font");
+ $help->SetTarget('_blank');
+ $page_header_r_col = array($help,
+ ($USER_DETAILS["alias"] != "guest") ?
+ array("|", new CLink(S_PROFILE, "profile.php", "small_font")) :
+ null
+ );
+ $logo = new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com");
+ $logo->SetTarget('_blank');
+
+ $top_page_row = array(new CCol($logo, "page_header_l"), new CCol($page_header_r_col, "page_header_r"));
+ unset($logo, $page_header_r_col, $help);
+
+ $table = new CTable(NULL,"page_header");
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(5);
+ $table->AddRow($top_page_row);
+ $table->Show();
+
+ $menu_table = new CTable(NULL,'menu');
+ $menu_table->SetCellSpacing(0);
+ $menu_table->SetCellPadding(5);
+ $menu_table->AddRow($main_menu_row);
+
+ $node_form = null;
+
+ if(ZBX_DISTRIBUTED)
+ {
+ $lst_nodes = new CComboBox('switch_node', $ZBX_CURNODEID);
+ $db_nodes = DBselect('select * from nodes where nodeid in ('.
+ get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' order by name ');
+ while($node_data = DBfetch($db_nodes))
+ {
+ $lst_nodes->AddItem($node_data['nodeid'],$node_data['name']);
+ }
+
+ if($lst_nodes->ItemsCount())
+ {
+ $node_form = new CForm();
+ $node_form->AddItem(S_CURRENT_NODE.' ['.$ZBX_CURNODEID.'] ');
+ $node_form->AddItem($lst_nodes);
+ unset($lst_nodes);
+ $node_form->AddItem(new CButton('submit',S_SWITCH));
+ }
+ }
+
+ $table = new CTable();
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+ $table->options['style'] = "width: 100%;";
+
+ $r_col = new CCol($node_form);
+ $r_col->options['style'] = "text-align: right;";
+
+ $table->AddRow(array($menu_table,$r_col));
+ $table->Show();
+
+ $sub_menu_table = new CTable(NULL,'sub_menu');
+ $sub_menu_table->SetCellSpacing(0);
+ $sub_menu_table->SetCellPadding(5);
+ $sub_menu_table->AddRow(new CCol($sub_menu_row));
+
+ $sub_menu_table->Show();
+ }
+ unset($ZBX_MENU);
+
+ unset($table, $top_page_row, $menu_table, $node_form);
+ unset($main_menu_row);
+ unset($db_nodes, $node_data);
+ unset($sub_menu_table, $sub_menu_row);
+
+ if(isset($denyed_page_requested))
+ {
+ access_deny();
+ }
+
+ if(version_compare(phpversion(), '5.1.0RC1', '>=') && $page['type'] == PAGE_TYPE_HTML)
+ {
+ $tmezone = ini_get('date.timezone');
+ if(empty($tmezone))
+ {
+ info('Timezone for PHP is not set. Please set "date.timezone" option in php.ini.');
+ date_default_timezone_set('UTC');
+ }
+ unset($tmezone);
+ }
+
+ show_messages();
+?>
diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php index 6d671dd5..b36dacbf 100644 --- a/frontends/php/include/services.inc.php +++ b/frontends/php/include/services.inc.php @@ -19,16 +19,35 @@ **/ ?> <?php - function add_service($name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array()) - { + function add_service($name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array(),$parentid,$childs){ + + foreach($childs as $id => $child){ //add childs + if($parentid == $child['serviceid']){ + error('Service can\'t be parent and child in onetime.'); + return FALSE; + } + } + if(is_null($triggerid) || $triggerid==0) $triggerid = 'NULL'; $serviceid=get_dbid("services","serviceid"); + + remove_service_links($serviceid); //removes all links with current serviceid + + $result =($parentid != 0)?(add_service_link($serviceid,$parentid,0)):(true); //add parent + + foreach($childs as $id => $child){ //add childs + if(!isset($child['soft']) || empty($child['soft'])) $child['soft'] = 0; + $result = add_service_link($child['serviceid'],$serviceid,$child['soft']); + } + + if(!$result){ + return FALSE; + } $result=DBexecute("insert into services (serviceid,name,status,triggerid,algorithm,showsla,goodsla,sortorder)". " values ($serviceid,".zbx_dbstr($name).",0,$triggerid,".zbx_dbstr($algorithm).",$showsla,".zbx_dbstr($goodsla).",$sortorder)"); - if(!$result) - { + if(!$result){ return FALSE; } DBExecute('DELETE FROM services_times WHERE serviceid='.$serviceid); @@ -47,8 +66,26 @@ return $serviceid; } - function update_service($serviceid,$name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array()) - { + function update_service($serviceid,$name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array(),$parentid,$childs){ + foreach($childs as $id => $child){ //add childs + if($parentid == $child['serviceid']){ + error('Service can\'t be parent and child in onetime.'); + return FALSE; + } + } + remove_service_links($serviceid); //removes all links with current serviceid + + $result =($parentid != 0)?(add_service_link($serviceid,$parentid,0)):(true); //add parent + + foreach($childs as $id => $child){ //add childs + if(empty($child['soft']) || !isset($child['soft'])) $child['soft'] = 0; + $result = add_service_link($child['serviceid'],$serviceid,$child['soft']); + } + + if(!$result){ + return FALSE; + } + if(is_null($triggerid) || $triggerid==0) $triggerid = 'NULL'; $result = DBexecute("update services set name=".zbx_dbstr($name).",triggerid=$triggerid,status=0,algorithm=$algorithm,showsla=$showsla,goodsla=$goodsla,sortorder=$sortorder where serviceid=$serviceid"); @@ -162,16 +199,13 @@ return TRUE; } - function add_service_link($servicedownid,$serviceupid,$softlink) - { - if( ($softlink==0) && (is_service_hardlinked($servicedownid)==true) ) - { + function add_service_link($servicedownid,$serviceupid,$softlink){ + if( ($softlink==0) && (is_service_hardlinked($servicedownid)==true) ){ error("cannot link hardlinked service."); return false; } - if($servicedownid==$serviceupid) - { + if($servicedownid==$serviceupid){ error("cannot link service to itself."); return false; } @@ -186,15 +220,13 @@ return $linkid; } - function update_service_link($linkid,$servicedownid,$serviceupid,$softlink) - { - if( ($softlink==0) && (is_service_hardlinked($servicedownid)==true) ) - { + + function update_service_link($linkid,$servicedownid,$serviceupid,$softlink){ + if( ($softlink==0) && (is_service_hardlinked($servicedownid)==true) ){ return false; } - if($servicedownid==$serviceupid) - { + if($servicedownid==$serviceupid){ error("cannot link service to itself."); return false; } @@ -202,9 +234,17 @@ $sql="update services_links set servicedownid=$servicedownid, serviceupid=$serviceupid, soft=$softlink where linkid=$linkid"; return dbexecute($sql); } + + function remove_service_links($serviceid){ + $query='DELETE + FROM services_links + WHERE serviceupid='.$serviceid.' + OR (servicedownid='.$serviceid.' + AND soft<>1)'; + DBExecute($query); + } - function get_last_service_value($serviceid,$clock) - { + function get_last_service_value($serviceid,$clock){ $sql="select count(*) as cnt,max(clock) as maxx from service_alarms where serviceid=$serviceid and clock<=$clock"; // echo " $sql<br>"; @@ -517,7 +557,9 @@ $dt = 0; } function get_service_childs($serviceid,&$childs,$soft=0){ - $query = 'SELECT sl.servicedownid FROM services_links sl WHERE sl.serviceupid = '.$serviceid.(($soft == 1)?(''):(' AND sl.soft <> 1')); + $query = 'SELECT sl.servicedownid '. + ' FROM services_links sl '. + ' WHERE sl.serviceupid = '.$serviceid.(($soft == 1)?(''):(' AND sl.soft <> 1')); $res = DBSelect($query); while($row = DBFetch($res)){ @@ -525,4 +567,67 @@ $dt = 0; get_service_childs($row['servicedownid'],$childs); } } + + function createServiceTree(&$services,$id=0,&$temp=array(),$serviceupid=0,$parentid=0, $soft=0, $linkid=''){ + + //echo 'IN: id='.$id.' ,serviceupid='.$serviceupid.' ,paranetid='.$parentid.' ,soft='.$soft.BR; + $rows = $services[$id]; + $rows['algorithm'] = algorithm2str($rows['algorithm']); + + //---------------------------- if not leaf ----------------------------- + $rows['parentid'] = $parentid; + if($soft == 0){ + $rows['caption'] = new CLink($rows['caption'],'#',null,'javascript: call_menu(event, '.zbx_jsvalue($rows['serviceid']).','.zbx_jsvalue($rows['caption']).'); return false;'); + + $temp[$rows['serviceid']]=$rows; + + if(isset($rows['childs'])){ + foreach($rows['childs'] as $cid => $nodeid){ + if(!isset($services[$nodeid['id']])){ + continue; + } + createServiceTree($services,$nodeid['id'],$temp,$services[$nodeid['id']]['serviceupid'],$rows['serviceid'],$nodeid['soft'], $nodeid['linkid']); + } + } + } else { + $rows['caption'] = '<font style="color: #888888;">'.$rows['caption'].'</font>'; + $temp[$rows['serviceid'].','.$linkid]=$rows; + } + return ; + } + + function createShowServiceTree(&$services,$id=0,&$temp=array(),$serviceupid=0,$parentid=0, $soft=0, $linkid=''){ + + //echo 'IN: id='.$id.' ,serviceupid='.$serviceupid.' ,paranetid='.$parentid.' ,soft='.$soft.BR; + $rows = $services[$id]; + + + //---------------------------- if not leaf ----------------------------- + $rows['parentid'] = $parentid; + $rows['status'] = get_service_status_description($rows["status"]); + + if($soft == 0){ + + $temp[$rows['serviceid']]=$rows; + + if(isset($rows['childs'])){ + foreach($rows['childs'] as $cid => $nodeid){ + if(!isset($services[$nodeid['id']])){ + continue; + } + createShowServiceTree($services,$nodeid['id'],$temp,$services[$nodeid['id']]['serviceupid'],$rows['serviceid'],$nodeid['soft'], $nodeid['linkid']); + } + } + } else { + $rows['caption'] = new CSpan($rows['caption']); + $rows['caption']->AddOption('style','color: #888888;'); + $temp[$rows['serviceid'].','.$linkid]=$rows; + } + return ; + } + + function closeform(){ + + zbx_add_post_js('closeform();'); + } ?> |
