public function bodyToString()
 {
     $res = parent::bodyToString();
     $tbl = new CTable(null, $this->tableclass);
     $tbl->setCellSpacing(0);
     $tbl->setCellPadding(1);
     $tbl->setAlign($this->align);
     // add first row
     if (!is_null($this->title)) {
         $col = new CCol(null, 'form_row_first');
         $col->setColSpan(2);
         if (isset($this->help)) {
             $col->addItem($this->help);
         }
         if (isset($this->title)) {
             $col->addItem($this->title);
         }
         $tbl->setHeader($col);
     }
     // add last row
     $tbl->setFooter($this->bottom_items);
     // add center rows
     foreach ($this->center_items as $item) {
         $tbl->addRow($item);
     }
     return $res . $tbl->toString();
 }
        }
    } else {
        if (empty($apps)) {
            $url = '?open=1&applicationid=0';
        } else {
            if (isset($apps[0])) {
                $url = '?close=1' . url_param($tmp_apps, false, 'apps');
            } else {
                $url = '?close=1&applicationid=0' . url_param($tmp_apps, false, 'apps');
            }
        }
    }
    $url .= url_param('groupid') . url_param('hostid') . url_param('fullscreen') . url_param('select');
    $link = new CLink($img, $url);
    $col = new CCol(array(bold('- ' . 'other' . ' -'), SPACE . '(' . _n('%1$s Item', '%1$s Items', $db_host['item_cnt']) . ')'));
    $col->setColSpan(5);
    // host JS menu link
    $hostSpan = null;
    if ($_REQUEST['hostid'] == 0) {
        $hostSpan = new CSpan($host['name'], 'link_menu menu-host');
        $scripts = $hostScripts[$host['hostid']];
        $hostSpan->setAttribute('data-menu', hostMenuData($host, $scripts));
    }
    $table->addRow(array($link, get_node_name_by_elid($db_host['hostid']), $hostSpan, $col));
    foreach ($app_rows as $row) {
        $table->addRow($row);
    }
}
$latest_wdgt->addItem($table);
$latest_wdgt->show();
require_once 'include/page_footer.php';
Example #3
0
             $time = 'lastdown';
         }
         $key_ = $dservice['key_'];
         if (!zbx_empty($key_)) {
             if (isset($gMacros[$key_])) {
                 $key_ = $gMacros[$key_]['value'];
             }
             $key_ = ': ' . $key_;
         }
         $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
         $discovery_info[$dservice['ip']]['services'][$service_name] = array('class' => $class, 'time' => $dservice[$time]);
     }
 }
 if ($druleid == 0 && !empty($discovery_info)) {
     $col = new CCol(array(bold($drule['name']), SPACE . '(' . count($discovery_info) . SPACE . S_ITEMS . ')'));
     $col->setColSpan(count($services) + 3);
     $table->addRow(array(get_node_name_by_elid($drule['druleid']), $col));
 }
 order_result($discovery_info, $_REQUEST['sort'], $_REQUEST['sortorder']);
 foreach ($discovery_info as $ip => $h_data) {
     $table_row = array(get_node_name_by_elid($h_data['druleid']), $h_data['type'] == 'primary' ? new CSpan($ip, $h_data['class']) : new CSpan(SPACE . SPACE . $ip), new CSpan(empty($h_data['host']) ? '-' : $h_data['host']), new CSpan($h_data['time'] == 0 || $h_data['type'] === 'slave' ? '' : convert_units(time() - $h_data['time'], 'uptime'), $h_data['class']));
     foreach ($services as $name => $foo) {
         $class = null;
         $time = SPACE;
         $hint = new CDiv(SPACE, $class);
         $hintTable = null;
         if (isset($h_data['services'][$name])) {
             $class = $h_data['services'][$name]['class'];
             $time = $h_data['services'][$name]['time'];
             $hintTable = new CTableInfo();
             $hintTable->setAttribute('style', 'width: auto;');
Example #4
0
 public function bodyToString()
 {
     parent::bodyToString();
     $tbl = new CTable(NULL, $this->tableclass);
     $tbl->setOddRowClass('form_odd_row');
     $tbl->setEvenRowClass('form_even_row');
     $tbl->setCellSpacing(0);
     $tbl->setCellPadding(1);
     $tbl->setAlign($this->align);
     // add first row
     $col = new CCol(NULL, 'form_row_first');
     $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);
     }
     $tbl->setHeader($col);
     // add last row
     $tbl->setFooter($this->bottom_items);
     // add center rows
     foreach ($this->center_items as $item) {
         $tbl->addRow($item);
     }
     return $tbl->toString();
 }
Example #5
0
function make_latest_data()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    while ($db_app = DBfetch($db_applications)) {
        $db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock'));
        $app_rows = array();
        $item_cnt = 0;
        while ($db_item = DBfetch($db_items)) {
            $description = item_description($db_item);
            if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
                continue;
            }
            ++$item_cnt;
            if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
                continue;
            }
            if (isset($db_item['lastclock'])) {
                $lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
            } else {
                $lastclock = new CCol('-', 'center');
            }
            $lastvalue = format_lastvalue($db_item);
            if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
                if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
                    $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                } else {
                    $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                }
                $change = nbsp($change);
            } else {
                $change = new CCol('-', 'center');
            }
            if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
                $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
            } else {
                $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
            }
            array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions)));
        }
        if ($item_cnt > 0) {
            if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
                $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            } else {
                $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            }
            $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')'));
            $col->setColSpan(5);
            $table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
            $any_app_exist = true;
            foreach ($app_rows as $row) {
                $table->ShowRow($row);
            }
        }
    }
}
// row template
$hiddenRowTemplate = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'hidden');
$hiddenRowTemplate->setAttribute('id', 'rowTpl');
$iconMapTable->addRow($hiddenRowTemplate);
// add row button
$addCol = new CCol(new CButton('addMapping', _('Add'), '', 'link_menu'));
$addCol->setColSpan(7);
$iconMapTable->addRow($addCol);
// <default icon row>
$numSpan = new CSpan($i++ . ':');
$numSpan->addClass('rowNum');
$iconsComboBox = new CComboBox('iconmap[default_iconid]', $this->data['iconmap']['default_iconid']);
$iconsComboBox->addClass('mappingIcon');
$iconsComboBox->addItems($this->data['iconList']);
$iconPreviewImage = new CImg('imgstore.php?iconid=' . $this->data['iconmap']['default_iconid'] . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview');
$iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $this->data['iconmap']['default_iconid']);
$col = new CCol(_('Default'));
$col->setColSpan(4);
$iconMapTable->addRow(array($col, $iconsComboBox, $iconPreviewImage));
// </default icon row>
$iconMapTab->addRow(_('Mappings'), new CDiv($iconMapTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
$iconMapView = new CTabView();
$iconMapView->addTab('iconmap', _('Icon map'), $iconMapTab);
$iconMapForm->addItem($iconMapView);
// footer
$secondaryActions = array(new CButtonCancel());
if (isset($this->data['iconmapid'])) {
    array_unshift($secondaryActions, new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete icon map?'), url_param('form') . url_param('iconmapid')));
}
$iconMapForm->addItem(makeFormFooter(array(new CSubmit('save', _('Save'))), $secondaryActions));
return $iconMapForm;
Example #7
0
        $i = 1;
        foreach ($trigger['events'] as $enum => $event) {
            $i++;
            $eventStatusSpan = new CSpan(trigger_value2str($event['value']));
            // add colors and blinking to span depending on configuration and trigger parameters
            addTriggerValueStyle($eventStatusSpan, $event['value'], $event['clock'], $event['acknowledged']);
            $statusSpan = new CCol($eventStatusSpan);
            $statusSpan->setColSpan(2);
            $ack = getEventAckState($event, true);
            $ackCheckBox = $event['acknowledged'] == 0 && $event['value'] == TRIGGER_VALUE_TRUE ? new CCheckBox('events[' . $event['eventid'] . ']', 'no', null, $event['eventid']) : SPACE;
            $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $event['eventid']);
            $nextClock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time();
            $emptyColumn = new CCol(SPACE);
            $emptyColumn->setColSpan(3);
            $ackCheckBoxColumn = new CCol($ackCheckBox);
            $ackCheckBoxColumn->setColSpan(2);
            $row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ackCheckBoxColumn : null, $statusSpan, $clock, zbx_date2age($event['clock']), zbx_date2age($nextClock, $event['clock']), $config['event_ack_enable'] ? $ack : null, $displayNodes ? SPACE : null, $emptyColumn), 'odd_row');
            $row->setAttribute('data-parentid', $trigger['triggerid']);
            $row->addStyle('display: none;');
            $triggerTable->addRow($row);
            if ($i > $config['event_show_max']) {
                break;
            }
        }
    }
}
/*
 * Go buttons
 */
$footer = null;
if ($config['event_ack_enable']) {
Example #8
0
function get_timeperiod_form()
{
    $tblPeriod = new CTable(null, 'formElementTable');
    // init new_timeperiod variable
    $new_timeperiod = getRequest('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod)) {
        if (isset($new_timeperiod['id'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id']));
        }
        if (isset($new_timeperiod['timeperiodid'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid']));
        }
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // start time
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // period
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // daysofweek
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    // months
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    $bit_dayofweek = strrev($dayofweek);
    $bit_month = strrev($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only'));
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $tblPeriod->addRow(array(_('Period type'), $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
        $tabDays = new CTable();
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
        $tblPeriod->addRow(array(_('Day of week'), $tabDays));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tabMonths = new CTable();
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December')));
        $tblPeriod->addRow(array(_('Month'), $tabMonths));
        $tblPeriod->addRow(array(_('Date'), array(new CRadioButton('new_timeperiod[month_date_type]', '0', null, null, !$new_timeperiod['month_date_type'], 'submit()'), _('Day'), SPACE, new CRadioButton('new_timeperiod[month_date_type]', '1', null, null, $new_timeperiod['month_date_type'], 'submit()'), _('Day of week'))));
        if ($new_timeperiod['month_date_type'] > 0) {
            $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
            $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
            $cmbCount->addItem(1, _('First'));
            $cmbCount->addItem(2, _('Second'));
            $cmbCount->addItem(3, _('Third'));
            $cmbCount->addItem(4, _('Fourth'));
            $cmbCount->addItem(5, _('Last'));
            $td = new CCol($cmbCount);
            $td->setColSpan(2);
            $tabDays = new CTable();
            $tabDays->addRow($td);
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
            $tblPeriod->addRow(array(_('Day of week'), $tabDays));
        } else {
            $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
            $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
        }
    } else {
        $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        if (isset($_REQUEST['add_timeperiod'])) {
            $date = array('y' => getRequest('new_timeperiod_start_date_year'), 'm' => getRequest('new_timeperiod_start_date_month'), 'd' => getRequest('new_timeperiod_start_date_day'), 'h' => getRequest('new_timeperiod_start_date_hour'), 'i' => getRequest('new_timeperiod_start_date_minute'));
        } else {
            $date = zbxDateToTime($new_timeperiod['start_date'] ? $new_timeperiod['start_date'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time()));
        }
        $tblPeriod->addRow(array(_('Date'), createDateSelector('new_timeperiod_start_date', $date)));
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tblPeriod->addRow(array(_('At (hour:minute)'), array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2))));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours'], null, range(0, 23));
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes'], null, range(0, 59));
    $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, _('Hours') . SPACE . SPACE, $perMinutes, _('Minutes'))));
    return $tblPeriod;
}
Example #9
0
     $chkBox = new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']);
     $step_cout = DBfetch(DBselect('select count(*) as cnt from httpstep where httptestid=' . $httptest_data['httptestid']));
     $step_cout = $step_cout['cnt'];
     array_push($app_rows, new CRow(array($chkBox, is_show_all_nodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? NULL : SPACE, array(str_repeat(SPACE, 4), $name), $step_cout, $httptest_data['delay'], $status)));
 }
 unset($app_rows);
 unset($db_app);
 foreach ($tab_rows as $appid => $app_rows) {
     $db_app =& $db_apps[$appid];
     if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
         $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     } else {
         $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     }
     $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));
     $col->setColSpan(6);
     $table->addRow(array(get_node_name_by_elid($db_app['applicationid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
     $any_app_exist = true;
     foreach ($app_rows as $row) {
         $table->addRow($row);
     }
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('activate', S_ACTIVATE_SELECTED);
 $goBox->addItem('disable', S_DISABLE_SELECTED);
 $goBox->addItem('clean_history', S_CLEAN_HISTORY_SELECTED_ITEMS);
 $goBox->addItem('delete', S_DELETE_SELECTED);
 // goButton name is necessary!!!
 $goButton = new CButton('goButton', S_GO . ' (0)');
 $goButton->setAttribute('id', 'goButton');
        $httpTableRows[$db_app['applicationid']] = array();
    }
    if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($this->data['showAllApps'])) {
        continue;
    }
    $httpTableRows[$db_app['applicationid']][] = array(new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']), is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? null : $db_app['hostname'], new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid')), $httptest_data['step_count'], $httptest_data['delay'], new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&go=' . ($httptest_data['status'] ? 'activate' : 'disable'), httptest_status2style($httptest_data['status']))));
}
foreach ($httpTableRows as $appid => $app_rows) {
    $db_app = $this->data['db_apps'][$appid];
    if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($this->data['showAllApps'])) {
        $link = new CLink(new CImg('images/general/minus.png'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
    } else {
        $link = new CLink(new CImg('images/general/plus.png'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
    }
    $column = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . _n('%1$d scenario', '%1$d scenarios', $db_app['scenarios_cnt']) . ')'));
    $column->setColSpan(6);
    $httpTable->addRow(array(get_node_name_by_elid($db_app['applicationid']), $column));
    foreach ($app_rows as $row) {
        $httpTable->addRow($row);
    }
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('clean_history', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected WEB scenarios?'));
include 'include/views/js/administration.general.valuemapping.edit.js.php';
$valueMappingForm = new CForm();
$valueMappingForm->setName('valueMappingForm');
$valueMappingForm->addVar('form', $this->data['form']);
$valueMappingForm->addVar('form_refresh', $this->data['form_refresh'] + 1);
$valueMappingForm->addVar('valuemapid', $this->data['valuemapid']);
// create form list
$valueMappingFormList = new CFormList('valueMappingFormList');
// name
$valueMappingFormList->addRow(_('Name'), new CTextBox('mapname', $this->data['mapname'], 40, null, 64));
// mappings
$mappingsTable = new CTable(SPACE, 'formElementTable');
$mappingsTable->setAttribute('id', 'mappingsTable');
$mappingsTable->addRow(array(_('Value'), SPACE, _('Mapped to'), SPACE));
$addCol = new CCol(new CButton('addMapping', _('Add'), '', 'link_menu'));
$addCol->setColSpan(4);
$mappingsTable->addRow($addCol);
$valueMappingFormList->addRow(_('Mappings'), new CDiv($mappingsTable, 'border_dotted inlineblock objectgroup'));
// add mappings to form by js
if (empty($this->data['mappings'])) {
    zbx_add_post_js('mappingsManager.addNew();');
} else {
    $json = new CJSON();
    zbx_add_post_js('mappingsManager.addExisting(' . $json->encode(array_values($this->data['mappings'])) . ');');
}
// append tab
$valueMappingTab = new CTabView();
$valueMappingTab->addTab('valuemapping', _('Value mapping'), $valueMappingFormList);
$valueMappingForm->addItem($valueMappingTab);
// append buttons
$saveButton = new CSubmit('save', _('Save'));
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);
}
Example #13
0
     }
 }
 function exibeEvento($chave, $linha)
 {
     if (array_key_exists($chave, $linha)) {
         return array(imagem('down', $linha[$chave]['maior_desc'], $linha[$chave]['maiores']), imagem('up', $linha[$chave]['menor_desc'], $linha[$chave]['menores']));
     } else {
         return "";
     }
 }
 $table->setHeader(array(_zeT('Amount'), is_show_all_nodes() ? _('Node') : null, _('Host'), _('Trigger'), $eventTitles[1], $eventTitles[2], $eventTitles[3], $eventTitles[4], $eventTitles[5], $eventTitles[6], $eventTitles[7], $eventTitles[8], $eventTitles[9], $eventTitles[10]));
 // Atribuir ao table o report ----------------------------------------------
 if ($possui === false) {
     // Avisa que não foram encontrados eventos no período
     $tmp = new CCol(array(_zeT("Sem eventos para correlacionar com os parâmetros informados")), 'center');
     $tmp->setColSpan(13);
     $table->addRow($tmp);
 } else {
     // Ordenando o array
     $report = array_sort($report, 'count', SORT_DESC);
     foreach ($report as $enum => $linha) {
         /*inicio adail*/
         if ($linha['count'] >= $min_events) {
             $table->addRow(array($linha['count'], $linha['host'], $linha['description'], exibeEvento('event1', $linha), exibeEvento('event2', $linha), exibeEvento('event3', $linha), exibeEvento('event4', $linha), exibeEvento('event5', $linha), exibeEvento('event6', $linha), exibeEvento('event7', $linha), exibeEvento('event8', $linha), exibeEvento('event9', $linha), exibeEvento('event10', $linha)));
         }
         if ($CSV_EXPORT) {
             $csvRows[] = array(zbx_date2str(EVENTS_ACTION_TIME_FORMAT, $event['clock']), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['name'] : null, $description, trigger_value2str($event['value']), getSeverityCaption($trigger['priority']), $event['duration'], $config['event_ack_enable'] ? $event['acknowledges'] ? _('Yes') : _('No') : null, strip_tags((string) $actions));
         }
     }
 }
 /*fim adail*/
             $time = 'lastdown';
         }
         $key_ = $dservice['key_'];
         if (!zbx_empty($key_)) {
             if (isset($this->data['macros'][$key_])) {
                 $key_ = $this->data['macros'][$key_]['value'];
             }
             $key_ = NAME_DELIMITER . $key_;
         }
         $serviceName = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
         $discovery_info[$dservice['ip']]['services'][$serviceName] = array('class' => $class, 'time' => $dservice[$time]);
     }
 }
 if (empty($this->data['druleid']) && !empty($discovery_info)) {
     $col = new CCol(array(bold($drule['name']), SPACE . '(' . _n('%d device', '%d devices', count($discovery_info)) . ')'));
     $col->setColSpan(count($this->data['services']) + 3);
     $discoveryTable->addRow($col);
 }
 order_result($discovery_info, $this->data['sort'], $this->data['sortorder']);
 foreach ($discovery_info as $ip => $h_data) {
     $dns = $h_data['dns'] == '' ? '' : ' (' . $h_data['dns'] . ')';
     $row = array($h_data['type'] == 'primary' ? new CSpan($ip . $dns, $h_data['class']) : new CSpan(SPACE . SPACE . $ip . $dns), new CSpan(empty($h_data['host']) ? '-' : $h_data['host']), new CSpan($h_data['time'] == 0 || $h_data['type'] === 'slave' ? '' : convert_units(array('value' => time() - $h_data['time'], 'units' => 'uptime')), $h_data['class']));
     foreach ($this->data['services'] as $name => $foo) {
         $class = null;
         $time = SPACE;
         $hint = new CDiv(SPACE, $class);
         $hintTable = null;
         if (isset($h_data['services'][$name])) {
             $class = $h_data['services'][$name]['class'];
             $time = $h_data['services'][$name]['time'];
             $hintTable = new CTableInfo();
Example #15
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);
}
 /**
  * Process screen with particular screen objects.
  *
  * @return CTable
  */
 public function show()
 {
     if (empty($this->screen)) {
         return new CTableInfo(_('No screens defined.'));
     }
     $skipedFields = array();
     $screenitems = array();
     $emptyScreenColumns = array();
     // calculate table columns and rows
     foreach ($this->screen['screenitems'] as $screenitem) {
         $screenitems[] = $screenitem;
         for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) {
             for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) {
                 if ($i != 0 || $j != 0) {
                     if (!isset($skipedFields[$screenitem['y'] + $i])) {
                         $skipedFields[$screenitem['y'] + $i] = array();
                     }
                     $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1;
                 }
             }
         }
     }
     // create screen table
     $screenTable = new CTable();
     $screenTable->setAttribute('class', in_array($this->mode, array(SCREEN_MODE_PREVIEW, SCREEN_MODE_SLIDESHOW)) ? 'screen_view' : 'screen_edit');
     $screenTable->setAttribute('id', 'iframe');
     // action top row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $newColumns = array(new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         for ($i = 0, $size = $this->screen['hsize'] + 1; $i < $size; $i++) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_col=' . $i . '";');
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow($newColumns);
     }
     for ($r = 0; $r < $this->screen['vsize']; $r++) {
         $newColumns = array();
         $emptyScreenRow = true;
         // action left cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_row=' . $r . '";');
             array_push($newColumns, new CCol($icon));
         }
         for ($c = 0; $c < $this->screen['hsize']; $c++) {
             if (isset($skipedFields[$r][$c])) {
                 continue;
             }
             // screen item
             $isEditForm = false;
             $screenitem = array();
             foreach ($screenitems as $tmprow) {
                 if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                     $screenitem = $tmprow;
                     break;
                 }
             }
             if (empty($screenitem)) {
                 $screenitem = array('screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC);
             }
             if (!empty($screenitem['screenitemid'])) {
                 $emptyScreenRow = false;
                 $emptyScreenColumns[$c] = 1;
             }
             // action
             if ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] != 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
             } elseif ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] == 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
             } else {
                 $action = null;
             }
             // edit form cell
             if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) {
                 $screenView = new CView('configuration.screen.constructor.edit', array('screen' => $this->screen));
                 $item = $screenView->render();
                 $isEditForm = true;
             } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) {
                 $screenBase = CScreenBuilder::getScreen(array('isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem));
                 if (!empty($screenBase)) {
                     if ($this->mode == SCREEN_MODE_EDIT && !empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
                     } elseif ($this->mode == SCREEN_MODE_EDIT && empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
                     }
                     $item = $screenBase->get();
                 } else {
                     $item = null;
                 }
             } else {
                 $item = array(SPACE);
                 if ($this->mode == SCREEN_MODE_EDIT) {
                     array_push($item, BR(), new CLink(_('Change'), $action, 'empty_change_link'));
                 }
             }
             // align
             $halign = 'def';
             if ($screenitem['halign'] == HALIGN_CENTER) {
                 $halign = 'cntr';
             }
             if ($screenitem['halign'] == HALIGN_LEFT) {
                 $halign = 'left';
             }
             if ($screenitem['halign'] == HALIGN_RIGHT) {
                 $halign = 'right';
             }
             $valign = 'def';
             if ($screenitem['valign'] == VALIGN_MIDDLE) {
                 $valign = 'mdl';
             }
             if ($screenitem['valign'] == VALIGN_TOP) {
                 $valign = 'top';
             }
             if ($screenitem['valign'] == VALIGN_BOTTOM) {
                 $valign = 'bttm';
             }
             if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) {
                 $item = new CDiv($item, 'draggable');
                 $item->setAttribute('id', 'position_' . $r . '_' . $c);
                 $item->setAttribute('data-xcoord', $c);
                 $item->setAttribute('data-ycoord', $r);
             }
             // colspan/rowspan
             $newColumn = new CCol($item, $halign . '_' . $valign . ' screenitem');
             if (!empty($screenitem['colspan'])) {
                 $newColumn->setColSpan($screenitem['colspan']);
             }
             if (!empty($screenitem['rowspan'])) {
                 $newColumn->setRowSpan($screenitem['rowspan']);
             }
             array_push($newColumns, $newColumn);
         }
         // action right cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if ($emptyScreenRow) {
                 $removeRowLink = 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '";';
             } else {
                 $removeRowLink = 'javascript: if (Confirm("' . _('This screen-row is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '"; }';
             }
             $icon->addAction('onclick', $removeRowLink);
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow(new CRow($newColumns));
     }
     // action bottom row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
         $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&add_row=' . $this->screen['vsize'] . '";');
         $newColumns = array(new CCol($icon));
         for ($i = 0; $i < $this->screen['hsize']; $i++) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if (isset($emptyScreenColumns[$i])) {
                 $removeColumnLink = 'javascript: if (Confirm("' . _('This screen-column is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '"; }';
             } else {
                 $removeColumnLink = 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '";';
             }
             $icon->addAction('onclick', $removeColumnLink);
             array_push($newColumns, new CCol($icon));
         }
         array_push($newColumns, new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         $screenTable->addRow($newColumns);
     }
     return $screenTable;
 }
Example #17
0
$options = array();
$options['templated_hosts'] = 1;
$hosts = API::Host()->get($options);
$filtroSegHosts = " hos.status <> 1 AND " . dbConditionInt('hos.hostid', zbx_objectValues($hosts, 'hostid'));
$rep2_wdgt = new CWidget();
$rep2_wdgt->addPageHeader(_zeT('Not Supported Items Report'));
$filter_form = new CForm();
$filter_form->setMethod('get');
$filter_form->setAttribute('name', 'zbx_filter');
$filter_form->setAttribute('id', 'zbx_filter');
$filter = new CButton('filter', _("Filter"));
$filter->onClick("javascript: submit();");
$reset = new CButton('reset', _('Reset'));
$reset->onClick("javascript: clearAllForm('zbx_filter');");
$footer_col = new CCol(array($filter, SPACE, $reset), 'center');
$footer_col->setColSpan(4);
$filter_table->addRow($footer_col);
$filter_form->addItem($filter_table);
//		$filterForm = get_report2_filter($config, $PAGE_GROUPS, $PAGE_HOSTS);
$rep2_wdgt->addFlicker($filter_form, true);
if (isset($hostid)) {
    $sql_from = '';
    $sql_where = '';
    if (0 == $config) {
        if ($_REQUEST['groupid'] > 0) {
            $sql_from .= ',hosts_groups hg ';
            $sql_where .= ' AND hg.hostid=h.hostid AND hg.groupid=' . $_REQUEST['groupid'];
        }
        if ($_REQUEST['hostid'] > 0) {
            $sql_where .= ' AND h.hostid=' . $hostid;
        }
Example #18
0
                    }
                } else {
                    $ack = SPACE;
                }
            }
            if ($row_event['acknowledged'] == 0 && $row_event['value'] == TRIGGER_VALUE_TRUE) {
                $ack_cb = new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']);
            } else {
                $ack_cb = SPACE;
            }
            $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $row_event['eventid']);
            $next_clock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time();
            $empty_col = new CCol(SPACE);
            $empty_col->setColSpan(3);
            $ack_cb_col = new CCol($ack_cb);
            $ack_cb_col->setColSpan(2);
            $row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ack_cb_col : null, $status, $clock, zbx_date2age($row_event['clock']), zbx_date2age($next_clock, $row_event['clock']), $config['event_ack_enable'] ? $ack : NULL, is_show_all_nodes() ? SPACE : null, $empty_col), 'odd_row');
            $row->setAttribute('data-parentid', $trigger['triggerid']);
            $row->addStyle('display: none;');
            $table->addRow($row);
            if ($i > $config['event_show_max']) {
                break;
            }
        }
    }
}
//----- GO ------
$footer = null;
if ($config['event_ack_enable']) {
    $goBox = new CComboBox('go');
    $goBox->addItem('bulkacknowledge', S_BULK_ACKNOWLEDGE);
$templateUrlLink = new CTextBox('urls[#{id}][url]', '', 32);
$templateUrlLink->setAttribute('disabled', 'disabled');
$templateUrlEtype = new CComboBox('urls[#{id}][elementtype]');
$templateUrlEtype->setAttribute('disabled', 'disabled');
$templateUrlEtype->addItems(sysmap_element_types());
$templateRemoveButton = new CSpan(_('Remove'), 'link_menu');
$templateRemoveButton->addAction('onclick', '$("entry_#{id}").remove();');
$templateUrlRow = new CRow(array($templateUrlLabel, $templateUrlLink, $templateUrlEtype, $templateRemoveButton));
$templateUrlRow->addStyle('display: none');
$templateUrlRow->setAttribute('id', 'urlEntryTpl');
$urlTable->addRow($templateUrlRow);
// append "add" button to url table
$addButton = new CSpan(_('Add'), 'link_menu');
$addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')');
$addButtonColumn = new CCol($addButton);
$addButtonColumn->setColSpan(4);
$urlTable->addRow($addButtonColumn);
// append url table to form list
$sysmapList->addRow(_('URLs'), new CDiv($urlTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// append sysmap to form
$sysmapTab = new CTabView();
$sysmapTab->addTab('sysmapTab', _('Map'), $sysmapList);
$sysmapForm->addItem($sysmapTab);
// append buttons to form
if (hasRequest('sysmapid') && getRequest('sysmapid') > 0) {
    $sysmapForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), array(new CButton('clone', _('Clone')), new CButtonDelete(_('Delete network map?'), url_param('form') . url_param('sysmapid')), new CButtonCancel())));
} else {
    $sysmapForm->addItem(makeFormFooter(new CSubmit('add', _('Add')), new CButtonCancel()));
}
// append form to widget
$sysmapWidget->addItem($sysmapForm);
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $this->dataId = 'discovery';
     $sort_field = $this->data['sort'];
     $sort_order = $this->data['sortorder'];
     $druleid = $this->data['druleid'];
     // discovery rules
     $options = ['output' => ['druleid', 'name'], 'selectDHosts' => ['dhostid', 'status', 'lastup', 'lastdown'], 'filter' => ['status' => DRULE_STATUS_ACTIVE]];
     if ($druleid > 0) {
         $options['druleids'] = $druleid;
         // set selected discovery rule id
     }
     $drules = API::DRule()->get($options);
     if ($drules) {
         order_result($drules, 'name');
     }
     // discovery services
     $options = ['selectHosts' => ['hostid', 'name', 'status'], 'output' => ['dserviceid', 'type', 'key_', 'port', 'status', 'lastup', 'lastdown', 'ip', 'dns'], 'sortfield' => $sort_field, 'sortorder' => $sort_order, 'limitSelects' => 1];
     if ($druleid > 0) {
         $options['druleids'] = $druleid;
     } else {
         $options['druleids'] = zbx_objectValues($drules, 'druleid');
     }
     $dservices = API::DService()->get($options);
     // user macros
     $macros = API::UserMacro()->get(['output' => ['macro', 'value'], 'globalmacro' => true]);
     $macros = zbx_toHash($macros, 'macro');
     // services
     $services = [];
     foreach ($dservices as $dservice) {
         $key_ = $dservice['key_'];
         if ($key_ !== '') {
             if (array_key_exists($key_, $macros)) {
                 $key_ = $macros[$key_]['value'];
             }
             $key_ = ': ' . $key_;
         }
         $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
         $services[$service_name] = 1;
     }
     ksort($services);
     // discovery services to hash
     $dservices = zbx_toHash($dservices, 'dserviceid');
     // discovery hosts
     $dhosts = API::DHost()->get(['druleids' => zbx_objectValues($drules, 'druleid'), 'selectDServices' => ['dserviceid', 'ip', 'dns', 'type', 'status', 'key_'], 'output' => ['dhostid', 'lastdown', 'lastup', 'druleid']]);
     $dhosts = zbx_toHash($dhosts, 'dhostid');
     $header = [make_sorting_header(_('Discovered device'), 'ip', $sort_field, $sort_order, 'zabbix.php?action=discovery.view'), _('Monitored host'), _('Uptime') . '/' . _('Downtime')];
     foreach ($services as $name => $foo) {
         $header[] = (new CColHeader($name))->addClass('vertical_rotation');
     }
     // create table
     $table = (new CTableInfo())->makeVerticalRotation()->setHeader($header);
     foreach ($drules as $drule) {
         $discovery_info = [];
         foreach ($drule['dhosts'] as $dhost) {
             if ($dhost['status'] == DHOST_STATUS_DISABLED) {
                 $hclass = 'disabled';
                 $htime = $dhost['lastdown'];
             } else {
                 $hclass = 'enabled';
                 $htime = $dhost['lastup'];
             }
             // $primary_ip stores the primary host ip of the dhost
             $primary_ip = '';
             foreach ($dhosts[$dhost['dhostid']]['dservices'] as $dservice) {
                 $dservice = $dservices[$dservice['dserviceid']];
                 $hostName = '';
                 $host = reset($dservices[$dservice['dserviceid']]['hosts']);
                 if (!is_null($host)) {
                     $hostName = $host['name'];
                 }
                 if ($primary_ip !== '') {
                     if ($primary_ip === $dservice['ip']) {
                         $htype = 'primary';
                     } else {
                         $htype = 'slave';
                     }
                 } else {
                     $primary_ip = $dservice['ip'];
                     $htype = 'primary';
                 }
                 if (!array_key_exists($dservice['ip'], $discovery_info)) {
                     $discovery_info[$dservice['ip']] = ['ip' => $dservice['ip'], 'dns' => $dservice['dns'], 'type' => $htype, 'class' => $hclass, 'host' => $hostName, 'time' => $htime];
                 }
                 if ($dservice['status'] == DSVC_STATUS_DISABLED) {
                     $class = ZBX_STYLE_INACTIVE_BG;
                     $time = 'lastdown';
                 } else {
                     $class = ZBX_STYLE_ACTIVE_BG;
                     $time = 'lastup';
                 }
                 $key_ = $dservice['key_'];
                 if ($key_ !== '') {
                     if (array_key_exists($key_, $macros)) {
                         $key_ = $macros[$key_]['value'];
                     }
                     $key_ = NAME_DELIMITER . $key_;
                 }
                 $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
                 $discovery_info[$dservice['ip']]['services'][$service_name] = ['class' => $class, 'time' => $dservice[$time]];
             }
         }
         if ($druleid == 0 && $discovery_info) {
             $col = new CCol([bold($drule['name']), SPACE . '(' . _n('%d device', '%d devices', count($discovery_info)) . ')']);
             $col->setColSpan(count($services) + 3);
             $table->addRow($col);
         }
         order_result($discovery_info, $sort_field, $sort_order);
         foreach ($discovery_info as $ip => $h_data) {
             $dns = $h_data['dns'] == '' ? '' : ' (' . $h_data['dns'] . ')';
             $row = [$h_data['type'] == 'primary' ? (new CSpan($ip . $dns))->addClass($h_data['class']) : new CSpan(SPACE . SPACE . $ip . $dns), new CSpan(array_key_exists('host', $h_data) ? $h_data['host'] : ''), (new CSpan($h_data['time'] == 0 || $h_data['type'] === 'slave' ? '' : convert_units(['value' => time() - $h_data['time'], 'units' => 'uptime'])))->addClass($h_data['class'])];
             foreach ($services as $name => $foo) {
                 $class = null;
                 $time = SPACE;
                 $hint = (new CDiv(SPACE))->addClass($class);
                 $hint_table = null;
                 if (array_key_exists($name, $h_data['services'])) {
                     $class = $h_data['services'][$name]['class'];
                     $time = $h_data['services'][$name]['time'];
                     $hint_table = (new CTableInfo())->setAttribute('style', 'width: auto;');
                     if ($class == ZBX_STYLE_ACTIVE_BG) {
                         $hint_table->setHeader(_('Uptime'));
                     } else {
                         $hint_table->setHeader(_('Downtime'));
                     }
                     $hint_table->addRow((new CCol(zbx_date2age($h_data['services'][$name]['time'])))->addClass($class));
                 }
                 $column = (new CCol($hint))->addClass($class);
                 if (!is_null($hint_table)) {
                     $column->setHint($hint_table);
                 }
                 $row[] = $column;
             }
             $table->addRow($row);
         }
     }
     return $this->getOutput($table, true, $this->data);
 }
Example #21
0
 // FULL CLONE }
 $host_footer = array();
 $host_footer[] = new CButton('save', S_SAVE);
 if ($templateid > 0 && $_REQUEST['form'] != 'full_clone') {
     $host_footer[] = SPACE;
     $host_footer[] = new CButton('clone', S_CLONE);
     $host_footer[] = SPACE;
     $host_footer[] = new CButton('full_clone', S_FULL_CLONE);
     $host_footer[] = SPACE;
     $host_footer[] = new CButtonDelete(S_DELETE_TEMPLATE_Q, url_param('form') . url_param('templateid') . url_param('groupid'));
     $host_footer[] = SPACE;
     $host_footer[] = new CButtonQMessage('delete_and_clear', S_DELETE_AND_CLEAR, S_DELETE_AND_CLEAR_TEMPLATE_Q, url_param('form') . url_param('templateid') . url_param('groupid'));
 }
 array_push($host_footer, SPACE, new CButtonCancel(url_param('groupid')));
 $host_footer = new CCol($host_footer);
 $host_footer->setColSpan(2);
 $template_tbl->setFooter($host_footer);
 $tplForm_wdgt = new CWidget();
 $tplForm_wdgt->setClass('header');
 $tplForm_wdgt->addHeader($frm_title);
 $tplForm_wdgt->addItem($template_tbl);
 // } TEMPLATE WIDGET
 // MACROS WIDGET {
 $macros_wdgt = get_macros_widget($templateid);
 // } MACROS WIDGET
 $left_table = new CTable();
 $left_table->setCellPadding(4);
 $left_table->setCellSpacing(4);
 $left_table->addRow($tplForm_wdgt);
 $right_table = new CTable();
 $right_table->setCellPadding(4);