Esempio n. 1
0
 public function setDoubleHeader($left, $right)
 {
     $table = new CTable();
     $table->addStyle('width: 100%;');
     $lCol = new CCol($left);
     $lCol->addStyle('text-align: left; border: 0;');
     $rCol = new CCol($right);
     $rCol->addStyle('text-align: right; border: 0;');
     $table->addRow(array($lCol, $rCol));
     $this->_header = new CDiv(null, 'nowrap ui-corner-all ui-widget-header ' . $this->css_class);
     $this->_header->addItem($table);
     return $this->_header;
 }
Esempio n. 2
0
         $maint_span = new CSpan($text, 'orange pointer');
         $maintenanceOptions = array('maintenanceids' => $trigger_host['maintenanceid'], 'output' => API_OUTPUT_EXTEND);
         $maintenances = CMaintenance::get($maintenanceOptions);
         $maintenance = reset($maintenances);
         $maint_hint = new CSpan($maintenance['name'] . ($maintenance['description'] == '' ? '' : ': ' . $maintenance['description']));
         $maint_span->setHint($maint_hint);
     }
     $hosts_span = new CSpan($trigger_host['host'], 'link_menu');
     $hosts_span->setAttribute('onclick', 'javascript: ' . $menus);
     $hosts_list[] = $hosts_span;
     $hosts_list[] = $maint_span;
     $hosts_list[] = ', ';
 }
 array_pop($hosts_list);
 $host = new CCol($hosts_list);
 $host->addStyle('white-space: normal;');
 // }}} host JS menu
 $status = new CSpan(trigger_value2str($trigger['value']), get_trigger_value_style($trigger['value']));
 if (time() - $trigger['lastchange'] < TRIGGER_BLINK_PERIOD) {
     $status->setAttribute('name', 'blink');
 }
 $lastchange = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid']);
 //.'&stime='.date('YmdHis', $trigger['lastchange']
 if ($config['event_ack_enable']) {
     if ($trigger['event_count']) {
         $to_ack = new CCol(array(new CLink(S_ACKNOWLEDGE, 'acknow.php?triggers[]=' . $trigger['triggerid'] . '&backurl=' . $page['file'], 'on'), ' (' . $trigger['event_count'] . ')'));
     } else {
         $to_ack = new CCol(S_ACKNOWLEDGED, 'off');
     }
 } else {
     $to_ack = null;
Esempio n. 3
0
         $div_node_tree->setAttribute('id', 'div_node_tree');
         $div_node_tree->addStyle('display: none');
         if (!is_null($nodesComboBox)) {
             $node_form->addItem(array(new CSpan(_('Current node') . SPACE, 'textcolorstyles'), $nodesComboBox));
         }
         $node_form->addItem($button_show_tree);
         $node_form->addItem($div_node_tree);
         unset($nodesComboBox);
     }
 }
 if (isset($ZBX_SERVER_NAME) && !zbx_empty($ZBX_SERVER_NAME)) {
     $table = new CTable();
     $table->addStyle('width: 100%;');
     $tableColumn = new CCol(new CSpan($ZBX_SERVER_NAME, 'textcolorstyles'));
     if (is_null($node_form)) {
         $tableColumn->addStyle('padding-right: 5px;');
     } else {
         $tableColumn->addStyle('padding-right: 20px; padding-bottom: 2px;');
     }
     $table->addRow(array($tableColumn, $node_form));
     $node_form = $table;
 }
 // 1st level menu
 $table = new CTable(null, 'maxwidth');
 $r_col = new CCol($node_form, 'right');
 $r_col->setAttribute('style', 'line-height: 1.8em;');
 $table->addRow(array($menu_table, $r_col));
 $page_menu = new CDiv(null, 'textwhite');
 $page_menu->setAttribute('id', 'mmenu');
 $page_menu->addItem($table);
 // 2nd level menu
Esempio n. 4
0
         $div_node_tree->addItem(new CButton('select_nodes', S_SELECT, "javascript: " . " if(IE6) hidePopupDiv('select_iframe');" . " \$('div_node_tree').setStyle({display:'none'});"));
         $div_node_tree->setAttribute('id', 'div_node_tree');
         $div_node_tree->addStyle('display: none');
         if (!is_null($combo_node_list)) {
             $node_form->addItem(array(new CSpan(S_CURRENT_NODE . SPACE, 'textcolorstyles'), $combo_node_list));
         }
         $node_form->addItem($button_show_tree);
         $node_form->addItem($div_node_tree);
         unset($combo_node_list);
     }
 }
 if (isset($ZBX_SERVER_NAME) && !zbx_empty($ZBX_SERVER_NAME)) {
     $tab = new CTable();
     $td_l = new CCol(new CSpan($ZBX_SERVER_NAME, 'textcolorstyles'));
     if (is_null($node_form)) {
         $td_l->addStyle('padding-right: 5px;');
     } else {
         $td_l->addStyle('padding-right: 20px; padding-bottom: 2px;');
     }
     $tab->addRow(array($td_l, $node_form));
     $node_form = $tab;
 }
 // 1st level menu
 $table = new CTable();
 $table->setCellSpacing(0);
 $table->setCellPadding(0);
 $table->setAttribute('style', 'width: 100%;');
 $r_col = new CCol($node_form);
 $r_col->setAttribute('align', 'right');
 //		$r_col->setAttribute('style','text-align: right;');
 $table->addRow(array($menu_table, $r_col));
Esempio n. 5
0
function get_regexp_form()
{
    $frm_title = S_REGULAR_EXPRESSION;
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST["form_refresh"])) {
        $sql = 'SELECT re.* ' . ' FROM regexps re ' . ' WHERE ' . DBin_node('re.regexpid') . ' AND re.regexpid=' . $_REQUEST['regexpid'];
        $regexp = DBfetch(DBSelect($sql));
        $frm_title .= ' [' . $regexp['name'] . ']';
        $rename = $regexp['name'];
        $test_string = $regexp['test_string'];
        $expressions = array();
        $sql = 'SELECT e.* ' . ' FROM expressions e ' . ' WHERE ' . DBin_node('e.expressionid') . ' AND e.regexpid=' . $regexp['regexpid'] . ' ORDER BY e.expression_type';
        $db_exps = DBselect($sql);
        while ($exp = DBfetch($db_exps)) {
            $expressions[] = $exp;
        }
    } else {
        $rename = get_request('rename', '');
        $test_string = get_request('test_string', '');
        $expressions = get_request('expressions', array());
    }
    $tblRE = new CTable('', 'nowrap');
    $tblRE->addStyle('border-left: 1px #AAA solid; border-right: 1px #AAA solid; background-color: #EEE; padding: 2px; padding-left: 6px; padding-right: 6px;');
    $tblRE->addRow(array(S_NAME, new CTextBox('rename', $rename, 60)));
    $tblRE->addRow(array(S_TEST_STRING, new CTextArea('test_string', $test_string, 66, 5)));
    $tabExp = new CTableInfo();
    $td1 = new CCol(S_EXPRESSION);
    $td1->addStyle('background-color: #CCC;');
    $td2 = new CCol(S_EXPECTED_RESULT);
    $td2->addStyle('background-color: #CCC;');
    $td3 = new CCol(S_RESULT);
    $td3->addStyle('background-color: #CCC;');
    $tabExp->setHeader(array($td1, $td2, $td3));
    $final_result = !empty($test_string);
    foreach ($expressions as $id => $expression) {
        $results = array();
        $paterns = array($expression['expression']);
        if (!empty($test_string)) {
            if ($expression['expression_type'] == EXPRESSION_TYPE_ANY_INCLUDED) {
                $paterns = explode($expression['exp_delimiter'], $expression['expression']);
            }
            if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_TRUE, EXPRESSION_TYPE_FALSE))) {
                if ($expression['case_sensitive']) {
                    $results[$id] = ereg($paterns[0], $test_string);
                } else {
                    $results[$id] = eregi($paterns[0], $test_string);
                }
                if ($expression['expression_type'] == EXPRESSION_TYPE_TRUE) {
                    $final_result &= $results[$id];
                } else {
                    $final_result &= !$results[$id];
                }
            } else {
                $results[$id] = true;
                $tmp_result = false;
                if ($expression['case_sensitive']) {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_stristr($test_string, $patern) !== false;
                    }
                } else {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_strstr($test_string, $patern) !== false;
                    }
                }
                $results[$id] &= $tmp_result;
                $final_result &= $results[$id];
            }
        }
        if (isset($results[$id]) && $results[$id]) {
            $exp_res = new CSpan(S_TRUE_BIG, 'green bold');
        } else {
            $exp_res = new CSpan(S_FALSE_BIG, 'red bold');
        }
        $expec_result = expression_type2str($expression['expression_type']);
        if (EXPRESSION_TYPE_ANY_INCLUDED == $expression['expression_type']) {
            $expec_result .= ' (' . S_DELIMITER . "='" . $expression['exp_delimiter'] . "')";
        }
        $tabExp->addRow(array($expression['expression'], $expec_result, $exp_res));
    }
    $td = new CCol(S_COMBINED_RESULT, 'bold');
    $td->setColSpan(2);
    if ($final_result) {
        $final_result = new CSpan(S_TRUE_BIG, 'green bold');
    } else {
        $final_result = new CSpan(S_FALSE_BIG, 'red bold');
    }
    $tabExp->addRow(array($td, $final_result));
    $tblRE->addRow(array(S_RESULT, $tabExp));
    $tblFoot = new CTableInfo(null);
    $td = new CCol(array(new CButton('save', S_SAVE)));
    $td->setColSpan(2);
    $td->addStyle('text-align: right;');
    $td->addItem(SPACE);
    $td->addItem(new CButton('test', S_TEST));
    if (isset($_REQUEST['regexpid'])) {
        $td->addItem(SPACE);
        $td->addItem(new CButton('clone', S_CLONE));
        $td->addItem(SPACE);
        $td->addItem(new CButtonDelete(S_DELETE_REGULAR_EXPRESSION_Q, url_param('form') . url_param('config') . url_param('regexpid')));
    }
    $td->addItem(SPACE);
    $td->addItem(new CButtonCancel(url_param("regexpid")));
    $tblFoot->SetFooter($td);
    return array($tblRE, $tblFoot);
}
Esempio n. 6
0
                 $hint .= "\n" . $maintenance['description'];
             }
             $maintenanceIcon->setHint($hint);
             $maintenanceIcon->addClass('pointer');
         }
         $hostDiv->addItem($maintenanceIcon);
     }
     // add comma after hosts, except last
     if (next($trigger['hosts'])) {
         $hostDiv->addItem(',' . SPACE);
     }
     $hostList[] = $hostDiv;
 }
 // host
 $hostColumn = new CCol($hostList);
 $hostColumn->addStyle('white-space: normal;');
 // status
 $statusSpan = new CSpan(trigger_value2str($trigger['value']));
 // add colors and blinking to span depending on configuration and trigger parameters
 addTriggerValueStyle($statusSpan, $trigger['value'], $trigger['lastchange'], $config['event_ack_enable'] ? $trigger['event_count'] == 0 : false);
 $lastChangeDate = zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']);
 $lastChange = empty($trigger['lastchange']) ? $lastChangeDate : new CLink($lastChangeDate, 'events.php?triggerid=' . $trigger['triggerid'] . '&stime=' . date(TIMESTAMP_FORMAT, $trigger['lastchange']) . '&period=' . ZBX_PERIOD_DEFAULT . '&source=' . EVENT_SOURCE_TRIGGERS);
 // acknowledge
 if ($config['event_ack_enable']) {
     if ($trigger['hasEvents']) {
         if ($trigger['event_count']) {
             $ackColumn = new CCol(array(new CLink(_('Acknowledge'), 'acknow.php?' . 'triggers[]=' . $trigger['triggerid'] . '&backurl=' . $page['file'], 'on'), ' (' . $trigger['event_count'] . ')'));
         } else {
             $ackColumn = new CCol(new CLink(_('Acknowledged'), 'acknow.php?' . 'eventid=' . $trigger['lastEvent']['eventid'] . '&triggerid=' . $trigger['lastEvent']['objectid'] . '&backurl=' . $page['file'], 'off'));
         }
     } else {
Esempio n. 7
0
 /**
  * Set widget header with left and right parts.
  *
  * @param string|array|CTag $leftColumn
  * @param string|array|CTag $rightColumn
  */
 public function setDoubleHeader($leftColumn, $rightColumn)
 {
     $leftColumn = new CCol($leftColumn);
     $leftColumn->addStyle('text-align: left; border: 0;');
     $rightColumn = new CCol($rightColumn);
     $rightColumn->addStyle('text-align: right; border: 0;');
     $table = new CTable();
     $table->addStyle('width: 100%;');
     $table->addRow(array($leftColumn, $rightColumn));
     $this->header = new CDiv($table, 'nowrap ui-corner-all ui-widget-header header');
 }
function get_regexp_form()
{
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
        $sql = 'SELECT re.* ' . ' FROM regexps re ' . ' WHERE ' . DBin_node('re.regexpid') . ' AND re.regexpid=' . zbx_dbstr($_REQUEST['regexpid']);
        $regexp = DBfetch(DBSelect($sql));
        $rename = $regexp['name'];
        $test_string = $regexp['test_string'];
        $expressions = array();
        $sql = 'SELECT e.* ' . ' FROM expressions e ' . ' WHERE ' . DBin_node('e.expressionid') . ' AND e.regexpid=' . zbx_dbstr($regexp['regexpid']) . ' ORDER BY e.expression_type';
        $db_exps = DBselect($sql);
        while ($exp = DBfetch($db_exps)) {
            $expressions[] = $exp;
        }
    } else {
        $rename = get_request('rename', '');
        $test_string = get_request('test_string', '');
        $expressions = get_request('expressions', array());
    }
    $tblRE = new CTable('', 'formtable nowrap');
    $tblRE->addRow(array(_('Name'), new CTextBox('rename', $rename, 60, 'no', 128)));
    $tblRE->addRow(array(_('Test string'), new CTextArea('test_string', $test_string)));
    $tabExp = new CTableInfo();
    $td1 = new CCol(_('Expression'));
    $td2 = new CCol(_('Expected result'));
    $td3 = new CCol(_('Result'));
    $tabExp->setHeader(array($td1, $td2, $td3));
    $final_result = !empty($test_string);
    foreach ($expressions as $id => $expression) {
        $results = array();
        $paterns = array($expression['expression']);
        if (!empty($test_string)) {
            if ($expression['expression_type'] == EXPRESSION_TYPE_ANY_INCLUDED) {
                $paterns = explode($expression['exp_delimiter'], $expression['expression']);
            }
            if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_TRUE, EXPRESSION_TYPE_FALSE))) {
                if ($expression['case_sensitive']) {
                    $results[$id] = preg_match('/' . $paterns[0] . '/', $test_string);
                } else {
                    $results[$id] = preg_match('/' . $paterns[0] . '/i', $test_string);
                }
                if ($expression['expression_type'] == EXPRESSION_TYPE_TRUE) {
                    $final_result &= $results[$id];
                } else {
                    $final_result &= !$results[$id];
                }
            } else {
                $results[$id] = true;
                $tmp_result = false;
                if ($expression['case_sensitive']) {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_strstr($test_string, $patern) !== false;
                    }
                } else {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_stristr($test_string, $patern) !== false;
                    }
                }
                if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_INCLUDED, EXPRESSION_TYPE_ANY_INCLUDED))) {
                    $results[$id] &= $tmp_result;
                } else {
                    if ($expression['expression_type'] == EXPRESSION_TYPE_NOT_INCLUDED) {
                        $results[$id] &= !$tmp_result;
                    }
                }
                $final_result &= $results[$id];
            }
        }
        if (isset($results[$id]) && $results[$id]) {
            $exp_res = new CSpan(_('TRUE'), 'green bold');
        } else {
            $exp_res = new CSpan(_('FALSE'), 'red bold');
        }
        $expec_result = expression_type2str($expression['expression_type']);
        if (EXPRESSION_TYPE_ANY_INCLUDED == $expression['expression_type']) {
            $expec_result .= ' (' . _('Delimiter') . "='" . $expression['exp_delimiter'] . "')";
        }
        $tabExp->addRow(array($expression['expression'], $expec_result, $exp_res));
    }
    $td = new CCol(_('Combined result'), 'bold');
    $td->setColSpan(2);
    if ($final_result) {
        $final_result = new CSpan(_('TRUE'), 'green bold');
    } else {
        $final_result = new CSpan(_('FALSE'), 'red bold');
    }
    $tabExp->addRow(array($td, $final_result));
    $tblRE->addRow(array(_('Result'), $tabExp));
    $tblFoot = new CTableInfo(null);
    $td = new CCol(array(new CSubmit('save', _('Save'))));
    $td->setColSpan(2);
    $td->addStyle('text-align: right;');
    $td->addItem(SPACE);
    $td->addItem(new CSubmit('test', _('Test')));
    if (isset($_REQUEST['regexpid'])) {
        $td->addItem(SPACE);
        $td->addItem(new CSubmit('clone', _('Clone')));
        $td->addItem(SPACE);
        $td->addItem(new CButtonDelete(_('Delete regular expression?'), url_param('form') . url_param('config') . url_param('regexpid') . url_param('delete', false, 'go')));
    }
    $td->addItem(SPACE);
    $td->addItem(new CButtonCancel(url_param("regexpid")));
    $tblFoot->setFooter($td);
    return array($tblRE, $tblFoot);
}