diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-12-12 09:42:46 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-12-12 09:42:46 +0000 |
| commit | c0529a72a421c43e903376c9c2661cf9b2e221d8 (patch) | |
| tree | c1597b558cb9a46961d204e9461d5c2a6eea59e6 /frontends/php/include | |
| parent | 1e32b65c56449dba7140c470a2e18024a05063d4 (diff) | |
| download | zabbix-c0529a72a421c43e903376c9c2661cf9b2e221d8.tar.gz zabbix-c0529a72a421c43e903376c9c2661cf9b2e221d8.tar.xz zabbix-c0529a72a421c43e903376c9c2661cf9b2e221d8.zip | |
- [ZBX-208] html output parsing (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5164 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/actions.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/classes/cscript.inc.php | 41 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctable.inc.php | 17 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctag.inc.php | 19 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctree.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 16 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 88 | ||||
| -rw-r--r-- | frontends/php/include/html.inc.php | 51 | ||||
| -rw-r--r-- | frontends/php/include/js.inc.php | 9 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/reports.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/screens.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/services.inc.php | 8 | ||||
| -rw-r--r-- | frontends/php/include/setup.inc.php | 54 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 64 | ||||
| -rw-r--r-- | frontends/php/include/validate.inc.php | 9 |
18 files changed, 232 insertions, 164 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index f7076a5f..ba92cc07 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -449,11 +449,11 @@ include_once 'include/discovery.inc.php'; switch($data['operationtype']) { case OPERATION_TYPE_MESSAGE: - $result = bold(S_SUBJECT).': '.$data['shortdata']."\n"; - $result .= bold(S_MESSAGE).":\n".$data['longdata']; + $result = bold(S_SUBJECT)->ToString().': '.$data['shortdata']."\n"; + $result .= bold(S_MESSAGE)->ToString().":\n".$data['longdata']; break; case OPERATION_TYPE_COMMAND: - $result = bold(S_REMOTE_COMMANDS).":\n".$data['longdata']; + $result = bold(S_REMOTE_COMMANDS)->ToString().":\n".$data['longdata']; break; default: break; } diff --git a/frontends/php/include/classes/cscript.inc.php b/frontends/php/include/classes/cscript.inc.php new file mode 100644 index 00000000..6ace5ca7 --- /dev/null +++ b/frontends/php/include/classes/cscript.inc.php @@ -0,0 +1,41 @@ +<?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 CScript extends CObject{ +/* public */ + + function CScript($item=NULL){ + $this->items = array(); + $this->AddItem($item); + } + + function AddItem($value){ + if(is_array($value)){ + foreach($value as $item){ + array_push($this->items,unpack_object($item)); + } + } + else if(!is_null($value)){ + array_push($this->items,unpack_object($value)); + } + } +} +?> diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php index 03711739..5ccca19d 100644 --- a/frontends/php/include/classes/ctable.inc.php +++ b/frontends/php/include/classes/ctable.inc.php @@ -62,15 +62,17 @@ } elseif(is_array($item)){ foreach($item as $el){ - if(strtolower(get_class($el))=='ccol') { - parent::AddItem($el); + if(strtolower(get_class($el))=='ccol') { + parent::AddItem($el); } elseif(!is_null($el)) { - parent::AddItem('<td>'.unpack_object($el).'</td>'); +// parent::AddItem('<td>'.unpack_object($el).'</td>'); + parent::AddItem(new CCol($el)); } } } elseif(!is_null($item)){ - parent::AddItem('<td>'.unpack_object($item).'</td>'); +// parent::AddItem('<td>'.unpack_object($item).'</td>'); + parent::AddItem(new CCol($item)); } } @@ -150,7 +152,8 @@ $this->oddRowClass: $this->evenRowClass); }/**/ - return $item->ToString(); + return $item; +// return $item->ToString(); } function SetHeader($value=NULL,$class=NULL){ @@ -169,6 +172,7 @@ if(is_null($class)) $class = $this->footerClass; $this->footer = $this->PrepareRow($value,$class); + $this->footer = $this->footer->ToString(); } function AddRow($item,$rowClass=NULL){ @@ -178,7 +182,7 @@ } function ShowRow($item,$rowClass=NULL){ - echo $this->PrepareRow($item,$rowClass); + echo $this->PrepareRow($item,$rowClass)->ToString(); ++$this->rownum; } /* protected */ @@ -196,6 +200,7 @@ $ret = ""; if($this->rownum == 0 && isset($this->message)) { $ret = $this->PrepareRow(new CCol($this->message,'message')); + $ret = $ret->ToString(); } $ret .= $this->footer; $ret .= parent::EndToString(); diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index 923cc00a..97cc2325 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -90,17 +90,22 @@ function CleanItems() { $this->items = array(); } function ItemsCount() { return count($this->items); } + function AddItem($value) { - if(is_array($value)) - { - foreach($value as $item) - { - array_push($this->items,unpack_object($item)); + if(is_object($value)){ + array_push($this->items,unpack_object($value)); + } + else if(is_string($value)){ + array_push($this->items,str_replace(array('<','>','"'),array('<','>','"'),$value)); +// array_push($this->items,htmlspecialchars($value)); + } + else if(is_array($value)){ + foreach($value as $item){ + $this->AddItem($item); // Attention, recursion !!! } } - elseif(!is_null($value)) - { + else if(!is_null($value)){ array_push($this->items,unpack_object($value)); } } diff --git a/frontends/php/include/classes/ctree.inc.php b/frontends/php/include/classes/ctree.inc.php index 7972bb14..0592c19d 100644 --- a/frontends/php/include/classes/ctree.inc.php +++ b/frontends/php/include/classes/ctree.inc.php @@ -238,7 +238,6 @@ function CheckTree(){ $this->tree[$parentid]['childnodes'][] = $id; $this->tree[$id]['nodelist'] = ''; -// echo $id.BR; } return true; diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 5840f8c3..202ec64c 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -18,9 +18,9 @@ ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ -function SDI($msg="SDI") { echo "DEBUG INFO: "; var_dump($msg); echo BR; } // DEBUG INFO!!! -function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$msg.'"'.SPACE; var_dump($var); echo BR; } // DEBUG INFO!!! -function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! +function SDI($msg="SDI") { echo "DEBUG INFO: "; var_dump($msg); echo SBR; } // DEBUG INFO!!! +function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$msg.'"'.SPACE; var_dump($var); echo SBR; } // DEBUG INFO!!! +function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! ?> <?php @@ -61,6 +61,7 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! require_once("include/classes/cpumenu.inc.php"); require_once("include/classes/graph.inc.php"); require_once('include/classes/ctree.inc.php'); + require_once('include/classes/cscript.inc.php'); // Include Tactical Overview modules @@ -1357,14 +1358,15 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!! /************ HISTORY **************/ function get_user_history(){ - $history=''; + $history=array(); $delimiter = new CSpan('»','delimiter'); - $delimiter = $delimiter->ToString(); for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ if($rows = get_profile('web.history.'.$i,false)){ - $history.= ($i>0)?($delimiter):(''); + if($i>0){ + array_push($history,$delimiter); + } $url = new CLink($rows[0],$rows[1],'history'); - $history.= SPACE.($url->ToString()).SPACE; + array_push($history,array(SPACE,$url,SPACE)); } } return $history; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 8628e51e..b92f788c 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -418,7 +418,7 @@ { $result = array(); $keys = (array_keys($row)); - foreach ($keys as $k) $result[strtolower($k)] = $row[$k]; + foreach($keys as $k) $result[strtolower($k)] = $row[$k]; } break; case "SQLITE3": diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 67dd6531..86f0b7cc 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -423,7 +423,8 @@ define('DHOST_STATUS_ACTIVE', 0); define('DHOST_STATUS_DISABLED', 1); - define('BR', "<br/>\n"); +// define('BR', "<br/>\n"); + define('SBR', "<br/>\n"); define('SPACE', ' '); define('RARR', '⇒'); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 023f09e1..b42e5ba6 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -136,7 +136,7 @@ '&dstfld1=screen_name&srcfld1=name'. '&dstfld2=new_step%5Bscreenid%5D&srcfld2=screenid");'), S_DELAY, - new CNumericBox('new_step[delay]', $new_step['delay'], 5), BR, + new CNumericBox('new_step[delay]', $new_step['delay'], 5), BR(), new CButton('add_step', isset($new_step['sid']) ? S_SAVE : S_ADD), new CButton('cancel_step', S_CANCEL) @@ -234,7 +234,7 @@ new CCheckBox('selected_checks[]',null,null,$id), SPACE, discovery_check_type2str($data['type']), SPACE, '('.$data['ports'].')'.SPACE.$external_param, - BR + BR() ); } @@ -273,12 +273,12 @@ { case SVC_SNMPv1: case SVC_SNMPv2: - $external_param = array_merge($external_param, array(BR, S_SNMP_COMMUNITY, SPACE, new CTextBox('new_check_snmp_community', $new_check_snmp_community))); - $external_param = array_merge($external_param, array(BR, S_SNMP_OID, new CTextBox('new_check_key', $new_check_key), BR)); + $external_param = array_merge($external_param, array(BR(), S_SNMP_COMMUNITY, SPACE, new CTextBox('new_check_snmp_community', $new_check_snmp_community))); + $external_param = array_merge($external_param, array(BR(), S_SNMP_OID, new CTextBox('new_check_key', $new_check_key), BR())); break; case SVC_AGENT: $form->AddVar('new_check_snmp_community', ''); - $external_param = array_merge($external_param, array(BR, S_KEY, new CTextBox('new_check_key', $new_check_key), BR)); + $external_param = array_merge($external_param, array(BR(), S_KEY, new CTextBox('new_check_key', $new_check_key), BR())); break; default: $form->AddVar('new_check_snmp_community', ''); @@ -488,7 +488,7 @@ $form->AddVar('steps', $steps); $form->AddRow(S_STEPS, array( - (count($steps) > 0) ? array ($tblSteps, BR) : null , + (count($steps) > 0) ? array ($tblSteps, BR()) : null , new CButton('add_step',S_ADD, 'return PopUp("popup_httpstep.php?dstfrm='.$form->GetName().'");'), (count($steps) > 0) ? new CButton('del_sel_step',S_DELETE_SELECTED) : null @@ -832,7 +832,7 @@ $frmUser->AddRow(S_GROUPS, array( $lstGroups, - BR, + BR(), new CButton('add_group',S_ADD, 'return PopUp("popup_usrgrp.php?dstfrm='.$frmUser->GetName(). '&list_name=user_groups_to_del[]&var_name=user_groups",450, 450);'), @@ -1043,7 +1043,7 @@ $frmUserG->AddRow(S_USERS, array( $lstUsers, - BR, + BR(), new CButton('add_user',S_ADD, "return PopUp('popup_users.php?dstfrm=".$frmUserG->GetName(). "&list_name=group_users_to_del[]&var_name=group_users',450,450);"), @@ -1327,7 +1327,7 @@ if(ZBX_DISTRIBUTED && $selection_mode) { - $form->AddRow('from '.bold(S_NODE).' like', array( + $form->AddRow(array('from ',bold(S_NODE),' like'), array( new CTextBox('with_node',$with_node,32), new CButton("btn_node",S_SELECT,"return PopUp('popup.php?dstfrm=".$form->GetName(). "&dstfld1=with_node&srctbl=nodes&srcfld1=name',450,450);", @@ -1337,7 +1337,7 @@ if($selection_mode) { - $form->AddRow('from '.bold(S_HOST_GROUP).' like', array( + $form->AddRow(array('from ',bold(S_HOST_GROUP),' like'), array( new CTextBox('with_group',$with_group,32), new CButton("btn_group",S_SELECT,"return PopUp('popup.php?dstfrm=".$form->GetName(). "&dstfld1=with_group&srctbl=host_group&srcfld1=name',450,450);", @@ -1345,7 +1345,7 @@ )); } - $form->AddRow('from '.bold(S_HOST).' like',array( + $form->AddRow(array('from ',bold(S_HOST),' like'),array( new CTextBox('with_host',$with_host,32), new CButton("btn_host",S_SELECT, "return PopUp('popup.php?dstfrm=".$form->GetName(). @@ -1355,7 +1355,7 @@ if($selection_mode) { - $form->AddRow('from '.bold(S_APPLICATION).' like',array( + $form->AddRow(array('from ',bold(S_APPLICATION),' like'),array( new CTextBox('with_application', $with_application, 32), new CButton('btn_app',S_SELECT, 'return PopUp("popup.php?dstfrm='.$form->GetName(). @@ -1365,7 +1365,7 @@ )); } - $form->AddRow('with '.bold(S_DESCRIPTION).' like', new CTextBox("with_description",$with_description,40)); + $form->AddRow(array('with ',bold(S_DESCRIPTION),' like'), new CTextBox("with_description",$with_description,40)); if($selection_mode) { @@ -1375,26 +1375,26 @@ ITEM_TYPE_SNMPV1, ITEM_TYPE_SNMPV2C, ITEM_TYPE_SNMPV3, ITEM_TYPE_TRAPPER, ITEM_TYPE_INTERNAL, ITEM_TYPE_AGGREGATE, ITEM_TYPE_HTTPTEST,ITEM_TYPE_DB_MONITOR) as $it) $cmbType->AddItem($it, item_type2str($it)); - $form->AddRow('with '.bold(S_TYPE), $cmbType); + $form->AddRow(array('with ',bold(S_TYPE)), $cmbType); } - $form->AddRow('with '.bold(S_KEY).' like', array(new CTextBox("with_key",$with_key,40))); + $form->AddRow(array('with ',bold(S_KEY),' like'), array(new CTextBox("with_key",$with_key,40))); if($selection_mode) { if(($with_type==ITEM_TYPE_SNMPV1)||($with_type==ITEM_TYPE_SNMPV2C)||$with_type==ITEM_TYPE_SNMPV3) { - $form->AddRow('with '.bold(S_SNMP_COMMUNITY).' like', + $form->AddRow(array('with ',bold(S_SNMP_COMMUNITY),' like'), new CTextBox("with_snmp_community",$with_snmp_community,16)); - $form->AddRow('with '.bold(S_SNMP_OID).' like', + $form->AddRow(array('with ',bold(S_SNMP_OID),' like'), new CTextBox("with_snmp_oid",$with_snmp_oid,40)); - $form->AddRow('with '.bold(S_SNMP_PORT).' like', + $form->AddRow(array('with ',bold(S_SNMP_PORT),' like'), new CNumericBox("with_snmp_port",$with_snmp_port,5,null,true)); } if($with_type==ITEM_TYPE_SNMPV3) { - $form->AddRow('with '.bold(S_SNMPV3_SECURITY_NAME).' like', + $form->AddRow(array('with ',bold(S_SNMPV3_SECURITY_NAME),' like'), new CTextBox("with_snmpv3_securityname",$with_snmpv3_securityname,64)); $cmbSecLevel = new CComboBox("with_snmpv3_securitylevel",$with_snmpv3_securitylevel); @@ -1402,12 +1402,12 @@ $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV,"NoAuthPriv"); $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV,"AuthNoPriv"); $cmbSecLevel->AddItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV,"AuthPriv"); - $form->AddRow('with '.bold(S_SNMPV3_SECURITY_LEVEL), $cmbSecLevel); + $form->AddRow(array('with ',bold(S_SNMPV3_SECURITY_LEVEL)), $cmbSecLevel); - $form->AddRow('with '.bold(S_SNMPV3_AUTH_PASSPHRASE).' like', + $form->AddRow(array('with ',bold(S_SNMPV3_AUTH_PASSPHRASE),' like'), new CTextBox("with_snmpv3_authpassphrase",$with_snmpv3_authpassphrase,64)); - $form->AddRow('with '.bold(S_SNMPV3_PRIV_PASSPHRASE).' like', + $form->AddRow(array('with ',bold(S_SNMPV3_PRIV_PASSPHRASE),' like'), new CTextBox("with_snmpv3_privpassphrase",$with_snmpv3_privpassphrase,64)); } @@ -1419,34 +1419,34 @@ $cmbValType->AddItem(ITEM_VALUE_TYPE_STR, S_CHARACTER); $cmbValType->AddItem(ITEM_VALUE_TYPE_LOG, S_LOG); $cmbValType->AddItem(ITEM_VALUE_TYPE_TEXT, S_TEXT); - $form->AddRow('with '.bold(S_TYPE_OF_INFORMATION),$cmbValType); + $form->AddRow(array('with ',bold(S_TYPE_OF_INFORMATION)),$cmbValType); if( ($with_value_type==ITEM_VALUE_TYPE_FLOAT) || ($with_value_type==ITEM_VALUE_TYPE_UINT64)) { - $form->AddRow('with '.bold(S_UNITS), new CTextBox("with_units",$with_units,40)); - $form->AddRow('with '.bold(S_CUSTOM_MULTIPLIER).' like', new CTextBox("with_formula",$with_formula,40)); + $form->AddRow(array('with ',bold(S_UNITS)), new CTextBox("with_units",$with_units,40)); + $form->AddRow(array('with ',bold(S_CUSTOM_MULTIPLIER),' like'), new CTextBox("with_formula",$with_formula,40)); } if($with_type != ITEM_TYPE_TRAPPER && $with_type != ITEM_TYPE_HTTPTEST) { - $form->AddRow('with '.bold(S_UPDATE_INTERVAL_IN_SEC), + $form->AddRow(array('with ',bold(S_UPDATE_INTERVAL_IN_SEC)), new CNumericBox("with_delay",$with_delay,5,null,true)); } - $form->AddRow('with '.bold(S_KEEP_HISTORY_IN_DAYS), + $form->AddRow(array('with ',bold(S_KEEP_HISTORY_IN_DAYS)), new CNumericBox("with_history",$with_history,8,null,true)); - $form->AddRow('with '.bold(S_KEEP_TRENDS_IN_DAYS), new CNumericBox("with_trends",$with_trends,8,null,true)); + $form->AddRow(array('with ',bold(S_KEEP_TRENDS_IN_DAYS)), new CNumericBox("with_trends",$with_trends,8,null,true)); $cmbStatus = new CComboBox("with_status",$with_status); $cmbStatus->AddItem(-1,S_ALL_SMALL); foreach(array(ITEM_STATUS_ACTIVE,ITEM_STATUS_DISABLED,ITEM_STATUS_NOTSUPPORTED) as $st) $cmbStatus->AddItem($st,item_status2str($st)); - $form->AddRow('with '.bold(S_STATUS),$cmbStatus); + $form->AddRow(array('with ',bold(S_STATUS)),$cmbStatus); if($with_value_type==ITEM_VALUE_TYPE_LOG) { - $form->AddRow('with '.bold(S_LOG_TIME_FORMAT), new CTextBox("with_logtimefmt",$with_logtimefmt,16)); + $form->AddRow(array('with ',bold(S_LOG_TIME_FORMAT)), new CTextBox("with_logtimefmt",$with_logtimefmt,16)); } if( ($with_value_type==ITEM_VALUE_TYPE_FLOAT) || ($with_value_type==ITEM_VALUE_TYPE_UINT64)) @@ -1456,12 +1456,12 @@ $cmbDelta->AddItem(0,S_AS_IS); $cmbDelta->AddItem(1,S_DELTA_SPEED_PER_SECOND); $cmbDelta->AddItem(2,S_DELTA_SIMPLE_CHANGE); - $form->AddRow('with '.bold(S_STORE_VALUE),$cmbDelta); + $form->AddRow(array('with ',bold(S_STORE_VALUE)),$cmbDelta); } if($with_type==ITEM_TYPE_TRAPPER) { - $form->AddRow('with '.bold(S_ALLOWED_HOSTS).' like', new CTextBox("with_trapper_hosts",$with_trapper_hosts,40)); + $form->AddRow(array('with ',bold(S_ALLOWED_HOSTS),' like'), new CTextBox("with_trapper_hosts",$with_trapper_hosts,40)); } } @@ -1608,7 +1608,7 @@ " sec at ", $val["period"] ), - BR); + BR()); $frmItem->AddVar("delay_flex[".$i."][delay]", $val['delay']); $frmItem->AddVar("delay_flex[".$i."][period]", $val['period']); $i++; @@ -1789,7 +1789,7 @@ S_DELAY, SPACE, new CNumericBox("new_delay_flex[delay]","50",5), S_PERIOD, SPACE, - new CTextBox("new_delay_flex[period]","1-7,00:00-23:59",27), BR, + new CTextBox("new_delay_flex[period]","1-7,00:00-23:59",27), BR(), new CButton("add_delay_flex",S_ADD) ),'new'); } @@ -2008,7 +2008,7 @@ " sec at ", $val["period"] ), - BR); + BR()); $frmItem->AddVar("delay_flex[".$i."][delay]", $val['delay']); $frmItem->AddVar("delay_flex[".$i."][period]", $val['period']); $i++; @@ -2084,7 +2084,7 @@ S_DELAY, SPACE, new CNumericBox("new_delay_flex[delay]","50",5), S_PERIOD, SPACE, - new CTextBox("new_delay_flex[period]","1-7,00:00-23:59",27), BR, + new CTextBox("new_delay_flex[period]","1-7,00:00-23:59",27), BR(), new CButton("add_delay_flex",S_ADD) )); $new_delay_flex_el->AddOption('name', 'new_delay_flex_el'); @@ -2203,7 +2203,7 @@ $target['target_id']), SPACE, $target['target_name'], - BR + BR() )); } @@ -2315,7 +2315,7 @@ new CCheckBox("rem_dependence[]", 'no', null, strval($val)), expand_trigger_description($val) ), - BR); + BR()); $frmTrig->AddVar("dependences[]",strval($val)); } @@ -2339,7 +2339,7 @@ 'T'); $frmTrig->AddRow("New dependency",array($txtCondVal, - $btnSelect, BR, + $btnSelect, BR(), new CButton("add_dependence",S_ADD) ),'new'); @@ -2818,7 +2818,7 @@ new CCheckBox("rem_value[]", 'no', null, $i), $value["value"].SPACE.RARR.SPACE.$value["newvalue"] ), - BR); + BR()); $frmValmap->AddVar("valuemap[$i][value]",$value["value"]); $frmValmap->AddVar("valuemap[$i][newvalue]",$value["newvalue"]); $i++; @@ -3146,7 +3146,7 @@ include_once 'include/discovery.inc.php'; $frmAction->AddRow(S_NEW_CONDITION, array( $rowCondition, - BR, + BR(), new CButton('add_condition',S_ADD), new CButton('cancel_new_condition',S_CANCEL)), 'new'); @@ -4021,7 +4021,7 @@ include_once 'include/discovery.inc.php'; $i), /* value */ get_severity_description($i) ), - BR); + BR()); } $frmMedia->AddRow(S_USE_IF_SEVERITY,$frm_row); @@ -4244,7 +4244,7 @@ include_once 'include/discovery.inc.php'; ), get_node_name_by_elid($db_group["groupid"]).$db_group["name"] ), - BR); + BR()); } $frmHost->AddRow(S_GROUPS,$frm_row); @@ -5006,7 +5006,7 @@ include_once 'include/discovery.inc.php'; $btnAdd->SetType('button'); - $frmCnct->AddRow(S_LINK_STATUS_INDICATORS,array($table, BR, $btnAdd, $btnRemove)); + $frmCnct->AddRow(S_LINK_STATUS_INDICATORS,array($table, BR(), $btnAdd, $btnRemove)); //---------- diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index 7233eb6e..75893b27 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -19,16 +19,21 @@ **/ ?> <?php - function bold($str) - { + function bold($str){ if(is_array($str)){ foreach($str as $key => $val) - if(is_string($val)) - $str[$key] = "<b>$val</b>"; - } elseif(is_string($str)) { - $str = "<b>$str</b>"; + if(is_string($val)){ + $b = new CTag('strong','yes'); + $b->AddItem($val); + $str[$key] = $b; + } + } + else if(is_string($str)) { + $b = new CTag('strong','yes'); + $b->AddItem($str); + $str = $b; } - return $str; + return $str; } function bfirst($str) // mark first symbol of string as bold @@ -110,38 +115,28 @@ return $result; } - function url_param($parameter,$request=true,$name=null) - { - $result = ""; - - - if(!is_array($parameter)) - { - if(!isset($name)) - { + function url_param($parameter,$request=true,$name=null){ + $result = ''; + if(!is_array($parameter)){ + if(!isset($name)){ if(!$request) fatal_error('not request variable require url name [url_param]'); - + $name = $parameter; } } - if($request) - { - global $_REQUEST; - + if($request){ $var =& $_REQUEST[$parameter]; } - else - { + else{ $var =& $parameter; } - if(isset($var)) - { + if(isset($var)){ $result = prepare_url($var,$name); } - return $result; + return $result; } function table_begin($class="tableinfo") @@ -207,4 +202,8 @@ echo "</TR>"; echo "</TABLE>"; } + + function BR(){ + return new CTag('br','no'); + } ?> diff --git a/frontends/php/include/js.inc.php b/frontends/php/include/js.inc.php index 2a59a364..f6d527f5 100644 --- a/frontends/php/include/js.inc.php +++ b/frontends/php/include/js.inc.php @@ -56,7 +56,7 @@ function zbx_add_post_js($script) function get_js_sizeable_graph($dom_graph_id,$url){ -return ' +return new CScript(' <script language="JavaScript" type="text/javascript"> <!-- A_SBOX["'.$dom_graph_id.'"] = new Object; @@ -71,14 +71,13 @@ return ' insert_sizeable_graph('.zbx_jsvalue($dom_graph_id).','.zbx_jsvalue($url).'); --> - </script> - '; + </script>'); } function get_dynamic_chart($dom_graph_id,$img_src,$width=0){ if(is_int($width) && $width > 0) $img_src.= url_param($width, false, 'width'); - $result = ' + $result = new CScript(' <script language="JavaScript" type="text/javascript"> <!-- var width = "'.((!(is_int($width) && $width > 0)) ? $width : '').'"; @@ -105,7 +104,7 @@ function get_dynamic_chart($dom_graph_id,$img_src,$width=0){ document.write(\'<img src="\'+img_src + width +\'" alt="chart" id="'.$dom_graph_id.'" />\'); --> - </script>'; + </script>'); return $result; } diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index a3662304..21b9e70a 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -494,7 +494,7 @@ COpt::compare_files_with_menu($ZBX_MENU); $table->AddRow($tr); $table->Show(); } elseif(($page["type"] == PAGE_TYPE_HTML) && !defined('ZBX_PAGE_NO_MENU')) { - echo BR; + echo SBR; } //------------------------------------ </HISTORY> --------------------------------------- diff --git a/frontends/php/include/reports.inc.php b/frontends/php/include/reports.inc.php index 2e82fcb0..2553ab52 100644 --- a/frontends/php/include/reports.inc.php +++ b/frontends/php/include/reports.inc.php @@ -156,4 +156,4 @@ function show_report2_header($config,$available_hosts){ } } -?>
\ No newline at end of file +?> diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 115c439a..1b285563 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -500,7 +500,7 @@ elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_URL) ) { $item = array(new CIFrame($url,$width,$height,"auto")); - if($editmode == 1) array_push($item,BR,new CLink(S_CHANGE,$action)); + if($editmode == 1) array_push($item,BR(),new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_ACTIONS) ) { @@ -515,7 +515,7 @@ else { $item = array(SPACE); - if($editmode == 1) array_push($item,BR,new CLink(S_CHANGE,$action)); + if($editmode == 1) array_push($item,BR(),new CLink(S_CHANGE,$action)); } $str_halign = "def"; diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php index 75f5c373..8f4e484a 100644 --- a/frontends/php/include/services.inc.php +++ b/frontends/php/include/services.inc.php @@ -479,7 +479,7 @@ if(!isset($data[$period_end])) $data[$period_end] = array(); /* - print('From: '.date('l d M Y H:i',$period_start).' To: '.date('l d M Y H:i',$period_end).BR); + print('From: '.date('l d M Y H:i',$period_start).' To: '.date('l d M Y H:i',$period_end).SBR); $ut = 0; $dt = 0; foreach($data as $ts => $val) @@ -492,7 +492,7 @@ $dt = 0; if(isset($val['dt_e'])) {print(' dt_e-'.$val['dt_e']); $dt-=$val['dt_e'];} if(isset($val['alarm'])) {print(' alarm is '.$val['alarm']); } print(' ut = '.$ut.' dt = '.$dt); - print(BR); + print(SBR); } */ /* calculate times */ @@ -508,7 +508,7 @@ $dt = 0; $prev_alarm = $data[$period_start]['alarm']; $prev_time = $period_start; -//print_r($data[$period_start]); print(BR); +//print_r($data[$period_start]); print(SBR); if(isset($data[$period_start]['ut_s'])) $ut_cnt += $data[$period_start]['ut_s']; if(isset($data[$period_start]['ut_e'])) $ut_cnt -= $data[$period_start]['ut_e']; @@ -540,7 +540,7 @@ $dt = 0; { $sla_time[$period_type]['ok_time'] += $ts - $prev_time; } -//print_r($val); print(BR); +//print_r($val); print(SBR); if(isset($val['ut_s'])) $ut_cnt += $val['ut_s']; if(isset($val['ut_e'])) $ut_cnt -= $val['ut_e']; if(isset($val['dt_s'])) $dt_cnt += $val['dt_s']; diff --git a/frontends/php/include/setup.inc.php b/frontends/php/include/setup.inc.php index 3003dd51..e0de8761 100644 --- a/frontends/php/include/setup.inc.php +++ b/frontends/php/include/setup.inc.php @@ -130,7 +130,7 @@ $list->AddItem($data['title'], $style); } - return $list->ToString(); + return $list; } function GetState() @@ -142,11 +142,11 @@ function Stage0() { - return new CTag('div', 'yes', 'Welcome to the ZABBIX frontend installation wizard.'.BR.BR. - 'This installation wizard will guide you through the installation of ZABBIX frontend'.BR.BR. + return new CTag('div', 'yes', array('Welcome to the ZABBIX frontend installation wizard.',BR(),BR(), + 'This installation wizard will guide you through the installation of ZABBIX frontend',BR(),BR(), 'Click to "Next" button to proceed to the next screen. If you want to change something '. - 'on a previous screen, click "Previous" button'.BR.BR. - 'You may cancel installation at any time by clicking "Cancel" button', 'text'); + 'on a previous screen, click "Previous" button',BR(),BR(), + 'You may cancel installation at any time by clicking "Cancel" button'), 'text'); } function Stage1() @@ -157,10 +157,10 @@ return array( new CTag('div', 'yes', (file_exists($LICENCE_FILE) ? - nl2br(nbsp(htmlspecialchars(file_get_contents($LICENCE_FILE)))) : + new CScript(nl2br(nbsp(htmlspecialchars(file_get_contents($LICENCE_FILE))))) : 'Missing licence file. See GPL licence.') , 'licence'), - BR, + BR(), new CTag('div', 'yes', array( new CCheckBox( @@ -236,7 +236,7 @@ $this->get_test_result( $final_result, 'PHP Databases support: ', - implode(BR, $ZBX_CONFIG['allowed_db']), + new CScript(implode(SBR, $ZBX_CONFIG['allowed_db'])), !isset($ZBX_CONFIG['allowed_db']['no']), 'Required any databases support [MySQL or PostgreSQL or Oracle]')); @@ -292,7 +292,7 @@ $this->get_test_result( $final_result, 'Image formats:', - implode(BR, $img_formats), + $img_formats, !isset($no_img_formats), 'Required images genetarion support [PNG]')); @@ -329,7 +329,7 @@ $final_result = new CSpan(S_OK,'ok'); } - return array($table, BR, $final_result); + return array($table, BR(), $final_result); } function Stage3() @@ -354,15 +354,15 @@ $table->AddRow(array(S_PASSWORD, new CPassBox('password', $this->GetConfig('DB_PASSWORD', '')))); return array( - 'Please create database manually.', BR, + 'Please create database manually.', BR(), 'And set the configuration parameters of connection to this database.', - BR,BR, + BR(),BR(), 'And press "Test connection" button.', - BR,BR, + BR(),BR(), $table, - BR, + BR(), !$this->DISABLE_NEXT_BUTTON ? new CSpan(S_OK,'ok') : new CSpan(S_FAIL, 'fail'), - BR, + BR(), new CButton('retry', 'Test connection') ); } @@ -378,8 +378,8 @@ $table->AddRow(array(S_PORT, new CNumericBox('zbx_server_port', $this->GetConfig('ZBX_SERVER_PORT', '10051'),5))); return array( - 'Please enter host name or host IP address', BR, - 'and port number of ZABBIX server', BR, BR, + 'Please enter host name or host IP address', BR(), + 'and port number of ZABBIX server', BR(), BR(), $table, ); } @@ -446,9 +446,9 @@ $table1->AddRow(array('ZABBIX server:', $this->GetConfig('ZBX_SERVER', 'unknown'))); $table1->AddRow(array('ZABBIX server port:', $this->GetConfig('ZBX_SERVER_PORT', 'unknown'))); return array( - 'Please check configuration parameters.', BR, - 'If all correct press "Next" button, or "Previous" button to change configuration parameters.', BR, BR, - $table, BR, + 'Please check configuration parameters.', BR(), + 'If all correct press "Next" button, or "Previous" button to change configuration parameters.', BR(), BR(), + $table, BR(), $table1 ); } @@ -495,15 +495,15 @@ */ return array( - $table, BR, - $this->DISABLE_NEXT_BUTTON ? array(new CButton('retry', S_RETRY), BR,BR) : null, + $table, BR(), + $this->DISABLE_NEXT_BUTTON ? array(new CButton('retry', S_RETRY), BR(),BR()) : null, !$this->GetConfig('ZBX_CONFIG_FILE_CORRECT', false) ? - array('Please install configuration file manualy.',BR,BR, + array('Please install configuration file manualy.',BR(),BR(), 'By pressing "Save configuration file" button download configuration file ', - 'and place them into the ',BR, - '"'.$ZBX_CONFIGURATION_FILE.'"',BR,BR, + 'and place them into the ',BR(), + '"'.$ZBX_CONFIGURATION_FILE.'"',BR(),BR(), new CButton('save_config',"Save configuration file"), - BR,BR + BR(),BR() ) : null, 'Press the '.($this->DISABLE_NEXT_BUTTON ? '"Retry"' : '"Next"').' button' @@ -513,7 +513,7 @@ function Stage7() { return array( - 'Congratulation with succesfull instalation of ZABBIX frontend.',BR,BR, + 'Congratulation with succesfull instalation of ZABBIX frontend.',BR(),BR(), 'Press "Finish" button to complete installation' ); } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index d1e8a387..56c3f4c8 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -886,10 +886,15 @@ ******************************************************************************/ function explode_exp ($expression, $html,$template=false) { -# echo "EXPRESSION:",$expression,"<Br>"; +// echo "EXPRESSION:",$expression,"<Br>"; $functionid=''; - $exp=''; + if(0 == $html){ + $exp=''; + } + else{ + $exp=array(); + } $state=''; for($i=0,$max=strlen($expression); $i<$max; $i++) { @@ -902,44 +907,52 @@ if($expression[$i] == '}') { $state=''; - if($functionid=="TRIGGER.VALUE") - { - $exp .= "{".$functionid."}"; + if($functionid=="TRIGGER.VALUE"){ + if(0 == $html) $exp.='{'.$functionid.'}'; + else array_push($exp,'{'.$functionid.'}'); } - else if(is_numeric($functionid) && $function_data = DBfetch(DBselect('select h.host,i.key_,f.function,f.parameter,i.itemid,i.value_type'. - ' from items i,functions f,hosts h'. - ' where f.functionid='.$functionid.' and i.itemid=f.itemid and h.hostid=i.hostid'))) + else if(is_numeric($functionid) && + $function_data = DBfetch(DBselect('select h.host,i.key_,f.function,f.parameter,i.itemid,i.value_type'. + ' from items i,functions f,hosts h'. + ' where f.functionid='.$functionid. + ' and i.itemid=f.itemid '. + ' and h.hostid=i.hostid' + ))) { if($template) $function_data["host"] = '{HOSTNAME}'; - if($html == 0) - { - $exp .= "{".$function_data["host"].":".$function_data["key_"].".". - $function_data["function"]."(".$function_data["parameter"].")}"; + if($html == 0){ + $exp.='{'.$function_data['host'].':'.$function_data['key_'].'.'.$function_data['function'].'('.$function_data['parameter'].')}'; } - else - { - $link = new CLink($function_data["host"].":".$function_data["key_"], - 'history.php?action='.( $function_data["value_type"] ==0 ? 'showvalues' : 'showgraph'). + else{ + $link = new CLink($function_data['host'].':'.$function_data['key_'], + 'history.php?action='.( $function_data['value_type'] ==0 ? 'showvalues' : 'showgraph'). '&itemid='.$function_data['itemid']); - $exp .= '{'.$link->ToString().'.'.bold($function_data["function"].'(').$function_data["parameter"].bold(')').'}'; + array_push($exp,array('{',$link,'.',bold($function_data['function'].'('),$function_data['parameter'],bold(')'),'}')); } } - else - { - if($html == 1) $exp .= "<FONT COLOR=\"#AA0000\">"; - $exp .= "*ERROR*"; - if($html == 1) $exp .= "</FONT>"; + else{ + if(1 == $html){ + $font = new CTag('font','yes'); + $font->AddOption('color','#AA0000'); + $font->AddItem('*ERROR*'); + array_push($exp,$font); + } + else{ + $exp.= '*ERROR*'; + } + } continue; } - if($state == "FUNCTIONID") - { + if($state == "FUNCTIONID"){ $functionid=$functionid.$expression[$i]; continue; } - $exp=$exp.$expression[$i]; + + if(1 == $html) array_push($exp,$expression[$i]); + else $exp.=$expression[$i]; } # echo "EXP:",$exp,"<Br>"; return $exp; @@ -1501,7 +1514,6 @@ $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY); } if(!is_array($accessible_hosts)) $accessible_hosts = explode(',', $accessible_hosts); - $db_hosts = get_hosts_by_expression($expression); while($host_data = DBfetch($db_hosts)) { diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index c30fa424..9fbb2bc1 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -218,14 +218,14 @@ //*/ //echo $f,":",$expression,"<br>"; $expression = str_replace('{'.$f.'}','$_REQUEST["'.$f.'"]',$expression); -//$debug .= $f." = ".$_REQUEST[$f].BR; +//$debug .= $f." = ".$_REQUEST[$f].SBR; } $expression = trim($expression,"& "); $exec = "return (".$expression.") ? 1 : 0;"; $ret = eval($exec); //echo $debug; -//echo "$field - result: ".$ret." exec: $exec".BR.BR; +//echo "$field - result: ".$ret." exec: $exec".SBR.SBR; //SDI("$field - result: ".$ret." exec: $exec"); return $ret; } @@ -415,6 +415,11 @@ return ZBX_VALID_WARNING; } } + + if($type == T_ZBX_STR){ +// XSS +// $var=str_replace('<','<',$var); + } if(($type == T_ZBX_CLR) && !is_hex_color($var)) { $var = 'FFFFFF'; |
