Ejemplo n.º 1
0
function media_severity2str($severity)
{
    $mapping = array(0 => array('letter' => 'N', 'style' => $severity & 1 ? 'enabled' : NULL), 1 => array('letter' => 'I', 'style' => $severity & 2 ? 'enabled' : NULL), 2 => array('letter' => 'W', 'style' => $severity & 4 ? 'enabled' : NULL), 3 => array('letter' => 'A', 'style' => $severity & 8 ? 'enabled' : NULL), 4 => array('letter' => 'H', 'style' => $severity & 16 ? 'enabled' : NULL), 5 => array('letter' => 'D', 'style' => $severity & 32 ? 'enabled' : NULL));
    foreach ($mapping as $id => $map) {
        $result[$id] = new CSpan($map['letter'], $map['style']);
        $result[$id]->SetHint(get_severity_description($id) . " (" . (isset($map['style']) ? "on" : "off") . ")");
    }
    return $result;
}
Ejemplo n.º 2
0
function condition_value2str($conditiontype, $value)
{
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $group = get_hostgroup_by_groupid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true);
            }
            $str_val .= $group['name'];
            break;
        case CONDITION_TYPE_TRIGGER:
            $str_val = expand_trigger_description($value);
            break;
        case CONDITION_TYPE_HOST:
        case CONDITION_TYPE_HOST_TEMPLATE:
            $host = get_host_by_hostid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true);
            }
            $str_val .= $host['host'];
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $str_val = trigger_value2str($value);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $str_val = get_severity_description($value);
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $str_val = $value;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $str_val = S_MAINTENANCE_SMALL;
            break;
        case CONDITION_TYPE_DHOST_IP:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $str_val = discovery_check_type2str($value);
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSTATUS:
            $str_val = discovery_object_status2str($value);
            break;
        case CONDITION_TYPE_DUPTIME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DVALUE:
            $str_val = $value;
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            $str_val = $value ? S_ACK : S_NOT_ACK;
            break;
        case CONDITION_TYPE_APPLICATION:
            $str_val = $value;
            break;
        default:
            return S_UNKNOWN;
            break;
    }
    return '"' . $str_val . '"';
}
Ejemplo n.º 3
0
foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
    $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name);
}
$form->addItem(array(S_GROUP . SPACE, $cmbGroups, SPACE));
$cmbType = new CComboBox('type', $_REQUEST['type'], 'submit()');
$cmbType->addItem(SHOW_TRIGGERS, S_TRIGGERS);
$cmbType->addItem(SHOW_DATA, S_DATA);
$form->addItem(array(S_TYPE . SPACE, $cmbType));
$help = new CHelp('web.view.php', 'right');
$help_table = new CTableInfo();
$help_table->setAttribute('style', 'width: 200px');
if ($_REQUEST['type'] == SHOW_TRIGGERS) {
    $help_table->addRow(array(new CCol(SPACE, 'normal'), S_DISABLED));
}
foreach (array(1, 2, 3, 4, 5) as $tr_severity) {
    $help_table->addRow(array(new CCol(get_severity_description($tr_severity), get_severity_style($tr_severity)), S_ENABLED));
}
$help_table->addRow(array(new CCol(SPACE, 'unknown_trigger'), S_UNKNOWN));
if ($_REQUEST['type'] == SHOW_TRIGGERS) {
    $col = new CCol(SPACE, 'unknown_trigger');
    $col->setAttribute('style', 'background-image: url(images/gradients/blink1.gif); ' . 'background-position: top left; background-repeat: repeate;');
    $help_table->addRow(array($col, S_5_MIN));
    $col = new CCol(SPACE, 'unknown_trigger');
    $col->setAttribute('style', 'background-image: url(images/gradients/blink2.gif); ' . 'background-position: top left; background-repeat: repeate;');
    $help_table->addRow(array($col, S_15_MIN));
    $help_table->addRow(array(new CCol(SPACE), S_NO_TRIGGER));
} else {
    $help_table->addRow(array(new CCol(SPACE), S_DISABLED . ' ' . S_OR . ' ' . S_NO_TRIGGER));
}
$help->setHint($help_table);
$over_wdgt = new CWidget();
Ejemplo n.º 4
0
            if ($row_event['acknowledged'] == 1) {
                $acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid=' . $row_event['eventid']));
                $ack = array(new CSpan(S_YES, 'off'), SPACE . '(' . $acks_cnt['cnt'] . SPACE, new CLink(S_SHOW, 'acknow.php?eventid=' . $row_event['eventid'], 'action'), ')');
            } else {
                $ack = new CLink(S_NOT_ACKNOWLEDGED, 'acknow.php?eventid=' . $row_event['eventid'], 'on');
            }
        }
        $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT);
        $font = new CTag('font', 'yes');
        $font->setAttribute('color', '#808080');
        $font->addItem(array(' - ', $description));
        $description = $font;
        $description = new CCol($description);
        $description->setAttribute('style', 'white-space: normal; width: 90%;');
        $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row_event['eventid'], 'action');
        $table->addRow(array($config['event_ack_enable'] ? $row_event['acknowledged'] == 1 ? SPACE : new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']) : NULL, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row_event['value'])), $value, $clock, get_node_name_by_elid($row['triggerid']), $host, $description, $actions, $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, new CLink($row['comments'] == '' ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $row['triggerid'], 'action')));
        $event_limit++;
        if ($event_limit >= $config['event_show_max']) {
            break;
        }
    }
    unset($row, $description, $actions);
}
//----- GO ------
if ($config['event_ack_enable']) {
    $goBox = new CComboBox('go');
    $goBox->addItem('bulkacknowledge', S_BULK_ACKNOWLEDGE);
    // goButton name is necessary!!!
    $goButton = new CButton('goButton', S_GO . ' (0)');
    $goButton->setAttribute('id', 'goButton');
    zbx_add_post_js('chkbxRange.pageGoName = "events";');
Ejemplo n.º 5
0
function get_history_of_triggers_events($start, $num, $groupid = 0, $hostid = 0)
{
    global $USER_DETAILS;
    $config = select_config();
    $show_unknown = get_profile('web.events.filter.show_unknown', 0);
    $sql_from = $sql_cond = '';
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_LIST);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_DATA_ARRAY, get_current_nodeid());
    if ($hostid > 0) {
        $sql_cond = ' AND h.hostid=' . $hostid;
    } else {
        if ($groupid > 0) {
            $sql_from = ', hosts_groups hg ';
            $sql_cond = ' AND h.hostid=hg.hostid AND hg.groupid=' . $groupid;
        } else {
            $sql_from = '';
            $sql_cond = ' AND ' . DBcondition('h.hostid', $available_hosts);
        }
    }
    //---
    $triggers = array();
    $trigger_list = array();
    $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type ' . ' FROM triggers t, functions f, items i, hosts h ' . $sql_from . ' WHERE ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid ' . ' AND i.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond;
    $rez = DBselect($sql);
    while ($rowz = DBfetch($rez)) {
        $triggers[$rowz['triggerid']] = $rowz;
        array_push($trigger_list, $rowz['triggerid']);
    }
    $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : '';
    $table = new CTableInfo(S_NO_EVENTS_FOUND);
    $table->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY));
    if (!empty($triggers)) {
        $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND ' . DBcondition('e.objectid', $trigger_list) . $sql_cond . ' ORDER BY e.eventid DESC';
        $result = DBselect($sql, 10 * ($start + $num));
    }
    $col = 0;
    $skip = $start;
    while (!empty($triggers) && $col < $num && ($row = DBfetch($result))) {
        if ($skip > 0) {
            if ($show_unknown == 0 && $row['value'] == TRIGGER_VALUE_UNKNOWN) {
                continue;
            }
            $skip--;
            continue;
        }
        $value = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value']));
        $row = array_merge($triggers[$row['triggerid']], $row);
        if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) {
            continue;
        }
        $table->AddRow(array(date("Y.M.d H:i:s", $row["clock"]), get_node_name_by_elid($row['triggerid']), $hostid == 0 ? $row['host'] : null, new CLink(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), $value, new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"]))));
        $col++;
    }
    return $table;
}
Ejemplo n.º 6
0
function get_act_new_cond_form($action = null)
{
    $tblCond = new CTable('', 'nowrap');
    if (isset($_REQUEST['actionid']) && empty($action)) {
        $action = get_action_by_actionid($_REQUEST['actionid']);
    }
    if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) {
        $eventsource = $action['eventsource'];
        $evaltype = $action['evaltype'];
    } else {
        $evaltype = get_request('evaltype');
        $eventsource = get_request('eventsource');
    }
    $allowed_conditions = get_conditions_by_eventsource($eventsource);
    /* init new_condition variable */
    $new_condition = get_request('new_condition', array());
    if (!is_array($new_condition)) {
        $new_condition = array();
    }
    if (!isset($new_condition['type'])) {
        $new_condition['type'] = CONDITION_TYPE_TRIGGER_NAME;
    }
    if (!isset($new_condition['operator'])) {
        $new_condition['operator'] = CONDITION_OPERATOR_LIKE;
    }
    if (!isset($new_condition['value'])) {
        $new_condition['value'] = '';
    }
    if (!str_in_array($new_condition['type'], $allowed_conditions)) {
        $new_condition['type'] = $allowed_conditions[0];
    }
    // NEW CONDITION
    $rowCondition = array();
    // add condition type
    $cmbCondType = new CComboBox('new_condition[type]', $new_condition['type'], 'submit()');
    foreach ($allowed_conditions as $cond) {
        $cmbCondType->addItem($cond, condition_type2str($cond));
    }
    array_push($rowCondition, $cmbCondType);
    // add condition operation
    $cmbCondOp = new CComboBox('new_condition[operator]');
    foreach (get_operators_by_conditiontype($new_condition['type']) as $op) {
        $cmbCondOp->addItem($op, condition_operator2str($op));
    }
    array_push($rowCondition, $cmbCondOp);
    // add condition value
    switch ($new_condition['type']) {
        case CONDITION_TYPE_HOST_GROUP:
            $tblCond->addItem(new CVar('new_condition[value]', '0'));
            $rowCondition[] = array(new CTextBox('group', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=group&srctbl=host_group" . "&srcfld1=groupid&srcfld2=name',450,450);", 'T'));
            break;
        case CONDITION_TYPE_HOST_TEMPLATE:
            $tblCond->addItem(new CVar('new_condition[value]', '0'));
            $rowCondition[] = array(new CTextBox('host', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=host_templates" . "&srcfld1=hostid&srcfld2=host',450,450);", 'T'));
            break;
        case CONDITION_TYPE_HOST:
            $tblCond->addItem(new CVar('new_condition[value]', '0'));
            $rowCondition[] = array(new CTextBox('host', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=hosts" . "&srcfld1=hostid&srcfld2=host',450,450);", 'T'));
            break;
        case CONDITION_TYPE_TRIGGER:
            $tblCond->addItem(new CVar('new_condition[value]', '0'));
            $rowCondition[] = array(new CTextBox('trigger', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=trigger&srctbl=triggers" . "&srcfld1=triggerid&srcfld2=description');", 'T'));
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
            $rowCondition[] = new CTextBox('new_condition[value]', "", 40);
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $cmbCondVal = new CComboBox('new_condition[value]');
            foreach (array(TRIGGER_VALUE_FALSE, TRIGGER_VALUE_TRUE) as $tr_val) {
                $cmbCondVal->addItem($tr_val, trigger_value2str($tr_val));
            }
            $rowCondition[] = $cmbCondVal;
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $rowCondition[] = new CTextBox('new_condition[value]', "1-7,00:00-23:59", 40);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $cmbCondVal = new CComboBox('new_condition[value]');
            foreach (array(TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER) as $id) {
                $cmbCondVal->addItem($id, get_severity_description($id));
            }
            $rowCondition[] = $cmbCondVal;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $rowCondition[] = new CCol(S_MAINTENANCE_SMALL);
            break;
        case CONDITION_TYPE_DHOST_IP:
            $rowCondition[] = new CTextBox('new_condition[value]', '192.168.0.1-127,192.168.2.1', 50);
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $cmbCondVal = new CComboBox('new_condition[value]');
            foreach (array(SVC_SSH, SVC_LDAP, SVC_SMTP, SVC_FTP, SVC_HTTP, SVC_POP, SVC_NNTP, SVC_IMAP, SVC_TCP, SVC_AGENT, SVC_SNMPv1, SVC_SNMPv2, SVC_ICMPPING) as $svc) {
                $cmbCondVal->addItem($svc, discovery_check_type2str($svc));
            }
            $rowCondition[] = $cmbCondVal;
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $rowCondition[] = new CTextBox('new_condition[value]', '0-1023,1024-49151', 40);
            break;
        case CONDITION_TYPE_DSTATUS:
            $cmbCondVal = new CComboBox('new_condition[value]');
            foreach (array(DOBJECT_STATUS_UP, DOBJECT_STATUS_DOWN, DOBJECT_STATUS_DISCOVER, DOBJECT_STATUS_LOST) as $stat) {
                $cmbCondVal->addItem($stat, discovery_object_status2str($stat));
            }
            $rowCondition[] = $cmbCondVal;
            break;
        case CONDITION_TYPE_DUPTIME:
            $rowCondition[] = new CNumericBox('new_condition[value]', '600', 15);
            break;
        case CONDITION_TYPE_DVALUE:
            $rowCondition[] = new CTextBox('new_condition[value]', "", 40);
            break;
        case CONDITION_TYPE_APPLICATION:
            $rowCondition[] = new CTextBox('new_condition[value]', "", 40);
            break;
    }
    $tblCond->addRow($rowCondition);
    $tblConditions = new CTableInfo();
    $tblConditions->addRow($tblCond);
    $td = new CCol(array(new CButton('add_condition', S_ADD), new CButton('cancel_new_condition', S_CANCEL)));
    $td->addOption('colspan', '3');
    $td->addOption('style', 'text-align: right;');
    $tblConditions->SetFooter($td);
    unset($grouped_conditions, $cond_el, $cond_buttons);
    // end of NEW CONDITION
    return $tblConditions;
}
Ejemplo n.º 7
0
function get_screen($screenid, $editmode, $effectiveperiod = NULL)
{
    global $USER_DETAILS;
    if ($screenid == 0) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $r = CScreen::get(array('screenids' => $screenid, 'editable' => $editmode == 1 ? 1 : null, 'output' => API_OUTPUT_SHORTEN));
    if (empty($r)) {
        access_deny();
    }
    if (is_null($effectiveperiod)) {
        $effectiveperiod = ZBX_MIN_PERIOD;
    }
    $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid);
    $row = DBfetch($result);
    if (!$row) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid;
    $iresult = DBSelect($sql);
    $skip_field = array();
    $irows = array();
    while ($irow = DBfetch($iresult)) {
        $irows[] = $irow;
        for ($i = 0; $i < $irow['rowspan'] || $i == 0; $i++) {
            for ($j = 0; $j < $irow['colspan'] || $j == 0; $j++) {
                if ($i != 0 || $j != 0) {
                    if (!isset($skip_field[$irow['y'] + $i])) {
                        $skip_field[$irow['y'] + $i] = array();
                    }
                    $skip_field[$irow['y'] + $i][$irow['x'] + $j] = 1;
                }
            }
        }
    }
    $table = new CTable(new CLink(S_NO_ROWS_IN_SCREEN . SPACE . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit');
    $table->setAttribute('id', 'iframe');
    if ($editmode == 1) {
        $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        for ($c = 0; $c < $row['hsize'] + 1; $c++) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_col={$c}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        $table->addRow($new_cols);
    }
    $empty_screen_col = array();
    for ($r = 0; $r < $row['vsize']; $r++) {
        $new_cols = array();
        $empty_screen_row = true;
        if ($editmode == 1) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$r}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        for ($c = 0; $c < $row['hsize']; $c++) {
            $item = array();
            if (isset($skip_field[$r][$c])) {
                continue;
            }
            $item_form = false;
            $irow = false;
            foreach ($irows as $tmprow) {
                if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                    $irow = $tmprow;
                    break;
                }
            }
            if ($irow) {
                $screenitemid = $irow['screenitemid'];
                $resourcetype = $irow['resourcetype'];
                $resourceid = $irow['resourceid'];
                $width = $irow['width'];
                $height = $irow['height'];
                $colspan = $irow['colspan'];
                $rowspan = $irow['rowspan'];
                $elements = $irow['elements'];
                $valign = $irow['valign'];
                $halign = $irow['halign'];
                $style = $irow['style'];
                $url = $irow['url'];
                $dynamic = $irow['dynamic'];
            } else {
                $screenitemid = 0;
                $resourcetype = 0;
                $resourceid = 0;
                $width = 0;
                $height = 0;
                $colspan = 0;
                $rowspan = 0;
                $elements = 0;
                $valign = VALIGN_DEFAULT;
                $halign = HALIGN_DEFAULT;
                $style = 0;
                $url = '';
                $dynamic = 0;
            }
            if ($screenitemid > 0) {
                $empty_screen_row = false;
                $empty_screen_col[$c] = 1;
            }
            if ($editmode == 1 && $screenitemid != 0) {
                $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');";
                $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form';
            } else {
                if ($editmode == 1 && $screenitemid == 0) {
                    $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');";
                    $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form';
                } else {
                    $action = NULL;
                }
            }
            if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) {
                // click on empty field
                $item = get_screen_item_form();
                $item_form = true;
            } else {
                if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) {
                    // click on element
                    $item = get_screen_item_form();
                    $item_form = true;
                } else {
                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) {
                        if ($editmode == 0) {
                            $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime');
                        }
                        // GRAPH & ZOOM features
                        $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                        $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                        $graphDims = getGraphDims($resourceid);
                        $graphDims['graphHeight'] = $height;
                        $graphDims['width'] = $width;
                        $graph = get_graph_by_graphid($resourceid);
                        $graphid = $graph['graphid'];
                        $legend = $graph['show_legend'];
                        $graph3d = $graph['show_3d'];
                        //-------------
                        // Host feature
                        if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                            $options = array('hostids' => $_REQUEST['hostid'], 'output' => array('hostid', 'host'));
                            $hosts = CHost::get($options);
                            $host = reset($hosts);
                            $options = array('graphids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_REFER, 'select_graph_items' => API_OUTPUT_EXTEND);
                            $graph = CGraph::get($options);
                            $graph = reset($graph);
                            if (count($graph['hosts']) == 1) {
                                // if items from one host we change them, or set calculated if not exist on that host
                                if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymax_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymax_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                                if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymin_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymin_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                            }
                            $url = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php';
                            $url = new Curl($url);
                            foreach ($graph as $name => $value) {
                                if ($name == 'width' || $name == 'height') {
                                    continue;
                                }
                                $url->setArgument($name, $value);
                            }
                            $new_items = get_same_graphitems_for_host($graph['gitems'], $_REQUEST['hostid'], false);
                            foreach ($new_items as $gitem) {
                                unset($gitem['gitemid']);
                                unset($gitem['graphid']);
                                foreach ($gitem as $name => $value) {
                                    $url->setArgument('items[' . $gitem['itemid'] . '][' . $name . ']', $value);
                                }
                            }
                            $url->setArgument('name', $host['host'] . ': ' . $graph['name']);
                            $url = $url->getUrl();
                        }
                        //-------------
                        $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                        $default = false;
                        if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart6.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $timeline = array();
                            $timeline['period'] = $effectiveperiod;
                            $timeline['starttime'] = date('YmdHis', get_min_itemclock_by_graphid($resourceid));
                            if (isset($_REQUEST['stime'])) {
                                $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                            }
                            // $src = $url.'&width='.$width.'&height='.$height.'&legend='.$legend.'&graph3d='.$graph3d;
                            $src = $url . '&width=' . $width . '&height=' . $height . '&legend=' . $legend . '&graph3d=' . $graph3d . '&period=' . $effectiveperiod . url_param('stime');
                            $objData['src'] = $src;
                        } else {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart2.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $src = $url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime');
                            $timeline = array();
                            if (isset($graphid) && !is_null($graphid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                                //get_min_itemclock_by_graphid($graphid);
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $objData['src'] = $src;
                        }
                        if ($editmode || !$default) {
                            $item = new CDiv();
                        } else {
                            $item = new CLink(null, $action);
                        }
                        $item->setAttribute('id', $containerid);
                        $item = array($item);
                        if ($editmode == 1) {
                            $item[] = BR();
                            $item[] = new CLink(S_CHANGE, $action);
                        }
                        if ($editmode == 2) {
                            insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        } else {
                            zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        }
                    } else {
                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
                            $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                            $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                            $graphDims = getGraphDims();
                            $graphDims['graphHeight'] = $height;
                            $graphDims['width'] = $width;
                            $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                            // Host feature
                            if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                    $resourceid = $newitemid;
                                } else {
                                    $resourceid = '';
                                }
                            }
                            //-------------
                            if ($editmode == 0 && !empty($resourceid)) {
                                $action = 'history.php?action=showgraph&itemid=' . $resourceid . url_param('period') . url_param('stime');
                            }
                            $timeline = array();
                            $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                            if (!zbx_empty($resourceid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $src = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&';
                            $src .= $url . 'width=' . $width . '&height=' . $height;
                            $objData['src'] = $src;
                            if ($editmode) {
                                $item = new CDiv();
                            } else {
                                $item = new CLink(null, $action);
                            }
                            $item->setAttribute('id', $containerid);
                            $item = array($item);
                            if ($editmode == 1) {
                                $item[] = BR();
                                $item[] = new CLink(S_CHANGE, $action);
                            }
                            if ($editmode == 2) {
                                insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            } else {
                                zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            }
                        } else {
                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) {
                                $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}&curtime=" . time());
                                if ($editmode == 0) {
                                    $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_selements' => API_OUTPUT_EXTEND, 'nopermissions' => 1);
                                    $sysmaps = CMap::get($options);
                                    $sysmap = reset($sysmaps);
                                    $action_map = getActionMapBySysmap($sysmap);
                                    $image_map->setMap($action_map->getName());
                                    $item = array($action_map, $image_map);
                                } else {
                                    $item = $image_map;
                                    //						$item = new CLink($image_map, $action);
                                }
                            } else {
                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                                    // Host feature
                                    if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                        if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                            $resourceid = $newitemid;
                                        } else {
                                            $resourceid = 0;
                                        }
                                    }
                                    //-------------
                                    $item = array(get_screen_plaintext($resourceid, $elements, $style));
                                    if ($editmode == 1) {
                                        array_push($item, new CLink(S_CHANGE, $action));
                                    }
                                } else {
                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTGROUP_TRIGGERS) {
                                        $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                        $tr_form = S_ALL_S;
                                        if ($resourceid > 0) {
                                            $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                            $hostgroups = CHostgroup::get($options);
                                            $hostgroup = reset($hostgroups);
                                            $tr_form = new CSpan(S_GROUP . ': ' . $hostgroup['name'], 'white');
                                            $params['groupids'] = $hostgroup['groupid'];
                                        } else {
                                            $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                            $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                            CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                            CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            $groups = CHostGroup::get($options);
                                            order_result($groups, 'name');
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            if ($groupid > 0) {
                                                $options['groupids'] = $groupid;
                                            }
                                            $hosts = CHost::get($options);
                                            $hosts = zbx_toHash($hosts, 'hostid');
                                            order_result($hosts, 'host');
                                            if (!isset($hosts[$hostid])) {
                                                $hostid = 0;
                                            }
                                            $tr_form = new CForm();
                                            $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                            $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                            $cmbGroup->addItem(0, S_ALL_SMALL);
                                            $cmbHosts->addItem(0, S_ALL_SMALL);
                                            foreach ($groups as $gnum => $group) {
                                                $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                            }
                                            foreach ($hosts as $hnum => $host) {
                                                $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                            }
                                            $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                            $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                            if ($groupid > 0) {
                                                $params['groupids'] = $groupid;
                                            }
                                            if ($hostid > 0) {
                                                $params['hostids'] = $hostid;
                                            }
                                        }
                                        $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                        $item[] = make_latest_issues($params);
                                        if ($editmode == 1) {
                                            array_push($item, new CLink(S_CHANGE, $action));
                                        }
                                        ///-----------------------
                                    } else {
                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOST_TRIGGERS) {
                                            $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                            $tr_form = S_ALL_S;
                                            if ($resourceid > 0) {
                                                $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                                $hosts = CHost::get($options);
                                                $host = reset($hosts);
                                                $tr_form = new CSpan(S_HOST . ': ' . $host['host'], 'white');
                                                $params['hostids'] = $host['hostid'];
                                            } else {
                                                $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                                $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                                CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                                CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                $groups = CHostGroup::get($options);
                                                order_result($groups, 'name');
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                if ($groupid > 0) {
                                                    $options['groupids'] = $groupid;
                                                }
                                                $hosts = CHost::get($options);
                                                $hosts = zbx_toHash($hosts, 'hostid');
                                                order_result($hosts, 'host');
                                                if (!isset($hosts[$hostid])) {
                                                    $hostid = 0;
                                                }
                                                $tr_form = new CForm();
                                                $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                                $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                                $cmbGroup->addItem(0, S_ALL_SMALL);
                                                $cmbHosts->addItem(0, S_ALL_SMALL);
                                                foreach ($groups as $gnum => $group) {
                                                    $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                                }
                                                foreach ($hosts as $hnum => $host) {
                                                    $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                                }
                                                $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                                $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                                if ($groupid > 0) {
                                                    $params['groupids'] = $groupid;
                                                }
                                                if ($hostid > 0) {
                                                    $params['hostids'] = $hostid;
                                                }
                                            }
                                            ///-----------------------
                                            $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                            $item[] = make_latest_issues($params);
                                            if ($editmode == 1) {
                                                array_push($item, new CLink(S_CHANGE, $action));
                                            }
                                        } else {
                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) {
                                                $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0);
                                                $item = array(get_table_header(array(S_SYSTEM_STATUS, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT))));
                                                $item[] = make_system_status($params);
                                                if ($editmode == 1) {
                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                }
                                            } else {
                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) {
                                                    $item = array(new CHostsInfo($resourceid, $style));
                                                    if ($editmode == 1) {
                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                    }
                                                } else {
                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                                        $item = new CTriggersInfo($resourceid, null, $style);
                                                        $item = array($item);
                                                        if ($editmode == 1) {
                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                        }
                                                    } else {
                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) {
                                                            //					$item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx());
                                                            $item = array(new CServerInfo());
                                                            if ($editmode == 1) {
                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                            }
                                                        } else {
                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) {
                                                                $item = new CFlashClock($width, $height, $style, $action);
                                                            } else {
                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) {
                                                                    $item = array(get_screen($resourceid, 2, $effectiveperiod));
                                                                    if ($editmode == 1) {
                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                    }
                                                                } else {
                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) {
                                                                        $hostids = array();
                                                                        $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                        while ($tmp_host = DBfetch($res)) {
                                                                            $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                        }
                                                                        $item = array(get_triggers_overview($hostids, $style));
                                                                        if ($editmode == 1) {
                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                        }
                                                                    } else {
                                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) {
                                                                            $hostids = array();
                                                                            $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                            while ($tmp_host = DBfetch($res)) {
                                                                                $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                            }
                                                                            $item = array(get_items_data_overview($hostids, $style));
                                                                            if ($editmode == 1) {
                                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                                            }
                                                                        } else {
                                                                            if ($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));
                                                                                }
                                                                            } else {
                                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) {
                                                                                    $item = array(get_history_of_actions($elements));
                                                                                    if ($editmode == 1) {
                                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                                    }
                                                                                } else {
                                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) {
                                                                                        $options = array('monitored' => 1, 'value' => array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE), 'limit' => $elements);
                                                                                        $hide_unknown = CProfile::get('web.events.filter.hide_unknown', 0);
                                                                                        if ($hide_unknown) {
                                                                                            $options['value'] = array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE);
                                                                                        }
                                                                                        $item = new CTableInfo(S_NO_EVENTS_FOUND);
                                                                                        $item->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION, S_VALUE, S_SEVERITY));
                                                                                        $events = getLastEvents($options);
                                                                                        foreach ($events as $enum => $event) {
                                                                                            $trigger = $event['trigger'];
                                                                                            $host = $event['host'];
                                                                                            $value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value']));
                                                                                            //						$row = zbx_array_merge($triggers[$row['triggerid']],$row);
                                                                                            //						if((1 == $hide_unknown) && (!event_initial_time($row,$hide_unknown))) continue;
                                                                                            $item->addRow(array(zbx_date2str(S_EVENTS_TRIGGERS_EVENTS_HISTORY_LIST_DATE_FORMAT, $event['clock']), get_node_name_by_elid($event['objectid']), $host['host'], new CLink($trigger['description'], 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']), $value, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority']))));
                                                                                        }
                                                                                        $item = array($item);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    } else {
                                                                                        $item = array(SPACE);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $str_halign = 'def';
            if ($halign == HALIGN_CENTER) {
                $str_halign = 'cntr';
            }
            if ($halign == HALIGN_LEFT) {
                $str_halign = 'left';
            }
            if ($halign == HALIGN_RIGHT) {
                $str_halign = 'right';
            }
            $str_valign = 'def';
            if ($valign == VALIGN_MIDDLE) {
                $str_valign = 'mdl';
            }
            if ($valign == VALIGN_TOP) {
                $str_valign = 'top';
            }
            if ($valign == VALIGN_BOTTOM) {
                $str_valign = 'bttm';
            }
            if ($editmode == 1 && !$item_form) {
                $item = new CDiv($item, 'draggable');
                $item->setAttribute('id', 'position_' . $r . '_' . $c);
                if ($editmode == 1) {
                    $item->setAttribute('onclick', 'javascript: ' . $onclick_action);
                }
            }
            $new_col = new CCol($item, $str_halign . '_' . $str_valign);
            if ($colspan) {
                $new_col->SetColSpan($colspan);
            }
            if ($rowspan) {
                $new_col->SetRowSpan($rowspan);
            }
            array_push($new_cols, $new_col);
        }
        if ($editmode == 1) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if ($empty_screen_row) {
                $rmv_row_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';";
            } else {
                $rmv_row_link = "javascript: if(Confirm('" . S_THIS_SCREEN_ROW_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';}";
            }
            $rmv_icon->addAction('onclick', $rmv_row_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        $table->addRow(new CRow($new_cols));
    }
    if ($editmode == 1) {
        $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
        $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$row['vsize']}';");
        $new_cols = array(new Ccol($add_icon));
        for ($c = 0; $c < $row['hsize']; $c++) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if (isset($empty_screen_col[$c])) {
                $rmv_col_link = "javascript: if(Confirm('" . S_THIS_SCREEN_COLUMN_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';}";
            } else {
                $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';";
            }
            $rmv_icon->addAction('onclick', $rmv_col_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        $table->addRow($new_cols);
    }
    return $table;
}
Ejemplo n.º 8
0
function make_trigger_details($triggerid, &$trigger_data)
{
    $table = new CTableInfo();
    if (is_show_subnodes()) {
        $table->AddRow(array(S_NODE, get_node_name_by_elid($triggerid)));
    }
    $table->AddRow(array(S_HOST, $trigger_data['host']));
    $table->AddRow(array(S_TRIGGER, $trigger_data['exp_desc']));
    $table->AddRow(array(S_SEVERITY, new CCol(get_severity_description($trigger_data["priority"]), get_severity_style($trigger_data["priority"]))));
    $table->AddRow(array(S_EXPRESSION, $trigger_data['exp_expr']));
    $table->AddRow(array(S_EVENT_GENERATION, S_NORMAL . (TRIGGER_MULT_EVENT_ENABLED == $trigger_data['type'] ? SPACE . '+' . SPACE . S_MULTIPLE_TRUE_EVENTS : '')));
    $table->AddRow(array(S_DISABLED, TRIGGER_STATUS_ENABLED == $trigger_data['status'] ? new CCol(S_NO, 'off') : new CCol(S_YES, 'on')));
    return $table;
}
Ejemplo n.º 9
0
function condition_value2str($conditiontype, $value)
{
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $group = get_hostgroup_by_groupid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $group['name'];
            break;
        case CONDITION_TYPE_TRIGGER:
            $trig = CTrigger::get(array('triggerids' => $value, 'expandTriggerDescriptions' => true, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'nodeids' => get_current_nodeid(true)));
            $trig = reset($trig);
            $host = reset($trig['hosts']);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $host['host'] . ':' . $trig['description'];
            break;
        case CONDITION_TYPE_HOST:
        case CONDITION_TYPE_HOST_TEMPLATE:
            $host = get_host_by_hostid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $host['host'];
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_HOST_NAME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $str_val = trigger_value2str($value);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $str_val = get_severity_description($value);
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $str_val = $value;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $str_val = S_MAINTENANCE_SMALL;
            break;
        case CONDITION_TYPE_NODE:
            $node = get_node_by_nodeid($value);
            $str_val = $node['name'];
            break;
        case CONDITION_TYPE_DRULE:
            $drule = get_discovery_rule_by_druleid($value);
            $str_val = $drule['name'];
            break;
        case CONDITION_TYPE_DCHECK:
            $row = DBfetch(DBselect('SELECT DISTINCT r.name,c.dcheckid,c.type,c.key_,c.snmp_community,c.ports' . ' FROM drules r,dchecks c WHERE r.druleid=c.druleid AND c.dcheckid=' . $value));
            $str_val = $row['name'] . ':' . discovery_check2str($row['type'], $row['snmp_community'], $row['key_'], $row['ports']);
            break;
        case CONDITION_TYPE_DOBJECT:
            $str_val = discovery_object2str($value);
            break;
        case CONDITION_TYPE_PROXY:
            $host = get_host_by_hostid($value);
            $str_val = $host['host'];
            break;
        case CONDITION_TYPE_DHOST_IP:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $str_val = discovery_check_type2str($value);
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSTATUS:
            $str_val = discovery_object_status2str($value);
            break;
        case CONDITION_TYPE_DUPTIME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DVALUE:
            $str_val = $value;
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            $str_val = $value ? S_ACK : S_NOT_ACK;
            break;
        case CONDITION_TYPE_APPLICATION:
            $str_val = $value;
            break;
        default:
            return S_UNKNOWN;
            break;
    }
    return '"' . $str_val . '"';
}
Ejemplo n.º 10
0
             case TRIGGER_STATUS_DISABLED:
                 $status = new CSpan(S_DISABLED, 'disabled');
                 break;
             case TRIGGER_STATUS_UNKNOWN:
                 $status = new CSpan(S_UNKNOWN, 'unknown');
                 break;
             case TRIGGER_STATUS_ENABLED:
                 $status = new CSpan(S_ENABLED, 'enabled');
                 break;
         }
         //if($row["status"] != TRIGGER_STATUS_UNKNOWN) $row["error"]=SPACE;
         //if($row["error"]=="") $row["error"]=SPACE;
         if ($multiselect) {
             $description = new CCol(array(new CCheckBox('trigger[' . $row['triggerid'] . ']', NULL, NULL, $row['triggerid']), $description));
         }
         $table->addRow(array($description, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'])), $status));
         unset($description);
         unset($status);
     }
     $form->addItem($table);
     $form->show();
 } else {
     if ($srctbl == "logitems") {
         insert_js_function('add_item_variable');
         $table = new CTableInfo(S_NO_ITEMS_DEFINED);
         $table->SetHeader(array($hostid > 0 ? null : S_HOST, S_DESCRIPTION, S_KEY, nbsp(S_UPDATE_INTERVAL), S_STATUS));
         $db_items = DBselect('SELECT DISTINCT h.host,i.* ' . ' FROM items i,hosts h' . ' WHERE i.value_type=' . ITEM_VALUE_TYPE_LOG . ' AND h.hostid=i.hostid ' . ' AND ' . DBin_node('i.itemid', $nodeid) . ($hostid > 0 ? ' AND ' . $hostid . '=i.hostid ' : '') . ' and ' . DBcondition('h.hostid', $available_hosts) . ' and h.status in (' . implode(',', $host_status) . ')' . ' ORDER BY h.host,i.description, i.key_, i.itemid');
         while ($db_item = DBfetch($db_items)) {
             $description = new CSpan(item_description($db_item), 'link');
             $description->onClick("return add_item_variable('" . $dstfrm . "','" . $db_item["itemid"] . "');");
             switch ($db_item["status"]) {
Ejemplo n.º 11
0
         $description->setAttribute('onclick', $js_action);
         if (count($trigger['dependencies']) > 0) {
             $description = array($description, BR(), bold(S_DEPENDS_ON), BR());
             foreach ($trigger['dependencies'] as $val) {
                 $description[] = array(expand_trigger_description_by_data($val), BR());
             }
         }
         switch ($trigger['status']) {
             case TRIGGER_STATUS_DISABLED:
                 $status = new CSpan(S_DISABLED, 'disabled');
                 break;
             case TRIGGER_STATUS_ENABLED:
                 $status = new CSpan(S_ENABLED, 'enabled');
                 break;
         }
         $table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', NULL, NULL, $trigger['triggerid']) : null, $description, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'])), $status));
     }
     if ($multiselect) {
         $button = new CButton('select', S_SELECT, "javascript: addSelectedValues('triggers', " . zbx_jsvalue($reference) . ");");
         $button->setType('button');
         $table->setFooter(new CCol($button, 'right'));
     }
     $form->addItem($table);
     $form->show();
 } else {
     if ($srctbl == 'items') {
         $form = new CForm();
         $form->setName('itemform');
         $form->setAttribute('id', 'items');
         $table = new CTableInfo(S_NO_ITEMS_DEFINED);
         insert_js_function('addSelectedValues');
Ejemplo n.º 12
0
function insert_trigger_form()
{
    $frmTrig = new CFormTable(S_TRIGGER, 'triggers.php');
    $frmTrig->setHelp('config_triggers.php');
    //		if(isset($_REQUEST['hostid'])){
    //			$frmTrig->addVar('hostid',$_REQUEST['hostid']);
    //		}
    $dep_el = array();
    $dependencies = get_request('dependencies', array());
    $limited = null;
    if (isset($_REQUEST['triggerid'])) {
        $frmTrig->addVar('triggerid', $_REQUEST['triggerid']);
        $trigger = get_trigger_by_triggerid($_REQUEST['triggerid']);
        $caption = array();
        $trigid = $_REQUEST['triggerid'];
        do {
            $sql = 'SELECT t.triggerid, t.templateid, h.host' . ' FROM triggers t, functions f, items i, hosts h' . ' WHERE t.triggerid=' . $trigid . ' AND h.hostid=i.hostid' . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid';
            $trig = DBfetch(DBselect($sql));
            if ($_REQUEST['triggerid'] != $trigid) {
                $caption[] = ' : ';
                $caption[] = new CLink($trig['host'], 'triggers.php?form=update&triggerid=' . $trig['triggerid'], 'highlight underline');
            }
            $trigid = $trig['templateid'];
        } while ($trigid != 0);
        $caption[] = S_TRIGGER . ' "';
        $caption = array_reverse($caption);
        $caption[] = htmlspecialchars($trigger['description']);
        $caption[] = '"';
        $frmTrig->setTitle($caption);
        $limited = $trigger['templateid'] ? 'yes' : null;
    }
    $expression = get_request('expression', '');
    $description = get_request('description', '');
    $type = get_request('type', 0);
    $priority = get_request('priority', 0);
    $status = get_request('status', 0);
    $comments = get_request('comments', '');
    $url = get_request('url', '');
    $expr_temp = get_request('expr_temp', '');
    $input_method = get_request('input_method', IM_ESTABLISHED);
    if (isset($_REQUEST['triggerid']) && !isset($_REQUEST['form_refresh']) || isset($limited)) {
        $description = $trigger['description'];
        $expression = explode_exp($trigger['expression'], 0);
        if (!isset($limited) || !isset($_REQUEST['form_refresh'])) {
            $type = $trigger['type'];
            $priority = $trigger['priority'];
            $status = $trigger['status'];
            $comments = $trigger['comments'];
            $url = $trigger['url'];
            $trigs = DBselect('SELECT t.triggerid,t.description,t.expression ' . ' FROM triggers t,trigger_depends d ' . ' WHERE t.triggerid=d.triggerid_up ' . ' AND d.triggerid_down=' . $_REQUEST['triggerid']);
            while ($trig = DBfetch($trigs)) {
                if (uint_in_array($trig['triggerid'], $dependencies)) {
                    continue;
                }
                array_push($dependencies, $trig['triggerid']);
            }
        }
    }
    $frmTrig->addRow(S_NAME, new CTextBox('description', $description, 90, $limited));
    if ($input_method == IM_TREE) {
        $alz = analyze_expression($expression);
        if ($alz !== false) {
            list($outline, $eHTMLTree) = $alz;
            if (isset($_REQUEST['expr_action']) && $eHTMLTree != null) {
                $new_expr = remake_expression($expression, $_REQUEST['expr_target_single'], $_REQUEST['expr_action'], $expr_temp);
                if ($new_expr !== false) {
                    $expression = $new_expr;
                    $alz = analyze_expression($expression);
                    if ($alz !== false) {
                        list($outline, $eHTMLTree) = $alz;
                    } else {
                        show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
                    }
                    $expr_temp = '';
                } else {
                    show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
                }
            }
            $frmTrig->addVar('expression', $expression);
            $exprfname = 'expr_temp';
            $exprtxt = new CTextBox($exprfname, $expr_temp, 65, 'yes');
            $macrobtn = new CButton('insert_macro', S_INSERT_MACRO, 'return call_ins_macro_menu(event);');
            //disabling button, if this trigger is templated
            if ($limited == 'yes') {
                $macrobtn->setAttribute('disabled', 'disabled');
            }
            $exprparam = "this.form.elements['{$exprfname}'].value";
        } else {
            show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
            $input_method = IM_ESTABLISHED;
        }
    }
    if ($input_method != IM_TREE) {
        $exprfname = 'expression';
        $exprtxt = new CTextBox($exprfname, $expression, 75, $limited);
        $exprparam = "getSelectedText(this.form.elements['{$exprfname}'])";
    }
    $add_expr_button = new CButton('insert', $input_method == IM_TREE ? S_EDIT : S_ADD, "return PopUp('popup_trexpr.php?dstfrm=" . $frmTrig->getName() . "&dstfld1={$exprfname}&srctbl=expression" . "&srcfld1=expression&expression=' + escape({$exprparam}),1000,700);");
    //disabling button, if this trigger is templated
    if ($limited == 'yes') {
        $add_expr_button->setAttribute('disabled', 'disabled');
    }
    $row = array($exprtxt, $add_expr_button);
    if (isset($macrobtn)) {
        array_push($row, $macrobtn);
    }
    if ($input_method == IM_TREE) {
        array_push($row, BR());
        if (empty($outline)) {
            $tmpbtn = new CButton('add_expression', S_ADD, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
        } else {
            $tmpbtn = new CButton('and_expression', S_AND_BIG, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
            $tmpbtn = new CButton('or_expression', S_OR_BIG, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
            $tmpbtn = new CButton('replace_expression', S_REPLACE, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
        }
    }
    $frmTrig->addVar('input_method', $input_method);
    $frmTrig->addVar('toggle_input_method', '');
    $exprtitle = array(S_EXPRESSION);
    if ($input_method != IM_FORCED) {
        $btn_im = new CSpan(S_TOGGLE_INPUT_METHOD, 'link');
        $btn_im->setAttribute('onclick', 'javascript: ' . "document.getElementById('toggle_input_method').value=1;" . "document.getElementById('input_method').value=" . ($input_method == IM_TREE ? IM_ESTABLISHED : IM_TREE) . ';' . "document.forms['" . $frmTrig->getName() . "'].submit();");
        $exprtitle[] = array(SPACE, '(', $btn_im, ')');
    }
    $frmTrig->addRow($exprtitle, $row);
    if ($input_method == IM_TREE) {
        $exp_table = new CTable();
        $exp_table->setClass('tableinfo');
        $exp_table->setAttribute('id', 'exp_list');
        $exp_table->setOddRowClass('even_row');
        $exp_table->setEvenRowClass('even_row');
        $exp_table->setHeader(array($limited == 'yes' ? null : S_TARGET, S_EXPRESSION, S_EXPRESSION_PART_ERROR, $limited == 'yes' ? null : S_DELETE));
        $allowedTesting = true;
        if ($eHTMLTree != null) {
            foreach ($eHTMLTree as $i => $e) {
                if ($limited != 'yes') {
                    $del_url = new CSpan(S_DELETE, 'link');
                    $del_url->setAttribute('onclick', 'javascript: if(confirm("' . S_DELETE_EXPRESSION_Q . '")) {' . ' delete_expression(\'' . $e['id'] . '\');' . ' document.forms["config_triggers.php"].submit(); ' . '}');
                    $tgt_chk = new CCheckbox('expr_target_single', $i == 0 ? 'yes' : 'no', 'check_target(this);', $e['id']);
                } else {
                    $tgt_chk = null;
                }
                if (!isset($e['expression']['levelErrors'])) {
                    $errorImg = new CImg('images/general/ok_icon.png', 'expression_no_errors');
                    $errorImg->setHint(S_EXPRESSION_PART_NO_ERROR, '', '', false);
                } else {
                    $allowedTesting = false;
                    $errorImg = new CImg('images/general/error_icon.png', 'expression_errors');
                    $errorTexts = array();
                    if (is_array($e['expression']['levelErrors'])) {
                        foreach ($e['expression']['levelErrors'] as $expVal => $errTxt) {
                            if (count($errorTexts) > 0) {
                                array_push($errorTexts, BR());
                            }
                            array_push($errorTexts, $expVal, ':', $errTxt);
                        }
                    }
                    $errorImg->setHint($errorTexts, '', 'left', false);
                }
                //if it is a templated trigger
                if ($limited == 'yes') {
                    //make all links inside inactive
                    for ($i = 0; $i < count($e['list']); $i++) {
                        if (gettype($e['list'][$i]) == 'object' && get_class($e['list'][$i]) == 'CSpan' && $e['list'][$i]->getAttribute('class') == 'link') {
                            $e['list'][$i]->setClass('');
                            $e['list'][$i]->setAttribute('onclick', '');
                        }
                    }
                }
                $errorCell = new CCol($errorImg, 'center');
                $row = new CRow(array($tgt_chk, $e['list'], $errorCell, isset($del_url) ? $del_url : null));
                $exp_table->addRow($row);
            }
        } else {
            $allowedTesting = false;
            $outline = '';
        }
        $frmTrig->addVar('remove_expression', '');
        $btn_test = new CButton('test_expression', S_TEST, "openWinCentered(" . "'tr_testexpr.php?expression=' + encodeURIComponent(this.form.elements['expression'].value)" . ",'ExpressionTest'" . ",850,400" . ",'titlebar=no, resizable=yes, scrollbars=yes');" . "return false;");
        if (!isset($allowedTesting) || !$allowedTesting) {
            $btn_test->setAttribute('disabled', 'disabled');
        }
        if (empty($outline)) {
            $btn_test->setAttribute('disabled', 'yes');
        }
        //SDI($outline);
        $wrapOutline = new CSpan(array($outline));
        $wrapOutline->addStyle('white-space: pre;');
        $frmTrig->addRow(SPACE, array($wrapOutline, BR(), BR(), $exp_table, $btn_test));
    }
    // dependencies
    foreach ($dependencies as $val) {
        array_push($dep_el, array(new CCheckBox('rem_dependence[' . $val . ']', 'no', null, strval($val)), expand_trigger_description($val)), BR());
        $frmTrig->addVar('dependencies[]', strval($val));
    }
    if (count($dep_el) == 0) {
        array_push($dep_el, S_NO_DEPENDENCES_DEFINED);
    } else {
        array_push($dep_el, new CButton('del_dependence', S_DELETE_SELECTED));
    }
    $frmTrig->addRow(S_THE_TRIGGER_DEPENDS_ON, $dep_el);
    /* end dependencies */
    /* new dependency */
    //		$frmTrig->addVar('new_dependence','0');
    //		$txtCondVal = new CTextBox('trigger','',75,'yes');
    $btnSelect = new CButton('btn1', S_ADD, "return PopUp('popup.php?srctbl=triggers" . '&srcfld1=triggerid' . '&reference=deptrigger' . '&multiselect=1' . "',1000,700);", 'T');
    $frmTrig->addRow(S_NEW_DEPENDENCY, $btnSelect, 'new');
    // end new dependency
    $type_select = new CComboBox('type');
    $type_select->additem(TRIGGER_MULT_EVENT_DISABLED, S_NORMAL, $type == TRIGGER_MULT_EVENT_ENABLED ? 'no' : 'yes');
    $type_select->additem(TRIGGER_MULT_EVENT_ENABLED, S_NORMAL . SPACE . '+' . SPACE . S_MULTIPLE_PROBLEM_EVENTS, $type == TRIGGER_MULT_EVENT_ENABLED ? 'yes' : 'no');
    $frmTrig->addRow(S_EVENT_GENERATION, $type_select);
    $cmbPrior = new CComboBox('priority', $priority);
    for ($i = 0; $i <= 5; $i++) {
        $cmbPrior->addItem($i, get_severity_description($i));
    }
    $frmTrig->addRow(S_SEVERITY, $cmbPrior);
    $frmTrig->addRow(S_COMMENTS, new CTextArea("comments", $comments, 90, 7));
    $frmTrig->addRow(S_URL, new CTextBox("url", $url, 90));
    $frmTrig->addRow(S_DISABLED, new CCheckBox("status", $status));
    $frmTrig->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["triggerid"])) {
        $frmTrig->addItemToBottomRow(SPACE);
        $frmTrig->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmTrig->addItemToBottomRow(SPACE);
        if (!$limited) {
            $frmTrig->addItemToBottomRow(new CButtonDelete(S_DELETE_TRIGGER_Q, url_param("form") . url_param('groupid') . url_param("hostid") . url_param("triggerid")));
        }
    }
    $frmTrig->addItemToBottomRow(SPACE);
    $frmTrig->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $jsmenu = new CPUMenu(null, 170);
    $jsmenu->InsertJavaScript();
    $script = "function addPopupValues(list){\n\t\t\t\t\t\tif(!isset('object', list)) return false;\n\n\t\t\t\t\t\tif(list.object == 'deptrigger'){\n\t\t\t\t\t\t\tfor(var i=0; i < list.values.length; i++){\n\t\t\t\t\t\t\t\tcreate_var('" . $frmTrig->getName() . "', 'new_dependence['+i+']', list.values[i], false);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcreate_var('" . $frmTrig->getName() . "','add_dependence', 1, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}";
    insert_js($script);
    return $frmTrig;
}
Ejemplo n.º 13
0
 }
 $new_row = array(nbsp(date("[Y.M.d H:i:s]", $row["clock"])));
 if ($item_cout > 1) {
     array_push($new_row, $row["host"] . ":" . item_description($row));
 }
 if ($row["timestamp"] == 0) {
     array_push($new_row, new CCol("-", "center"));
 } else {
     array_push($new_row, date("Y.M.d H:i:s", $row["timestamp"]));
 }
 if ($row["source"] == "") {
     array_push($new_row, new CCol("-", "center"));
 } else {
     array_push($new_row, $row["source"]);
 }
 array_push($new_row, new CCol(get_severity_description($row["severity"]), get_severity_style($row["severity"])));
 $row["value"] = trim($row["value"], "\r\n");
 //				array_push($new_row,htmlspecialchars($row["value"]));
 array_push($new_row, encode_log($row["value"]));
 if (!isset($_REQUEST["plaintext"])) {
     $crow = new CRow($new_row);
     if (is_null($color_style) && is_array($_REQUEST["itemid"])) {
         $min_color = 0x98;
         $max_color = 0xf8;
         $int_color = ($max_color - $min_color) / count($_REQUEST["itemid"]);
         $int_color *= array_search($row["itemid"], $_REQUEST["itemid"]);
         $int_color += $min_color;
         $crow->AddOption("style", "background-color: " . sprintf("#%X%X%X", $int_color, $int_color, $int_color));
     } else {
         $crow->SetClass($color_style);
     }
Ejemplo n.º 14
0
$media = get_request('media', -1);
$sendto = get_request('sendto', '');
$mediatypeid = get_request('mediatypeid', 0);
$active = get_request('active', 0);
$period = get_request('period', '1-7,00:00-23:59');
$frmMedia = new CFormTable(S_NEW_MEDIA);
$frmMedia->SetHelp("web.media.php");
$frmMedia->AddVar("media", $media);
$frmMedia->AddVar("dstfrm", $_REQUEST["dstfrm"]);
$cmbType = new CComboBox("mediatypeid", $mediatypeid);
$types = DBselect('SELECT mediatypeid,description ' . ' FROM media_type' . ' WHERE ' . DBin_node('mediatypeid') . ' ORDER BY type');
while ($type = DBfetch($types)) {
    $cmbType->AddItem($type["mediatypeid"], get_node_name_by_elid($type["mediatypeid"]) . $type["description"]);
}
$frmMedia->AddRow(S_TYPE, $cmbType);
$frmMedia->AddRow(S_SEND_TO, new CTextBox("sendto", $sendto, 20));
$frmMedia->AddRow(S_WHEN_ACTIVE, new CTextBox("period", $period, 48));
$frm_row = array();
for ($i = 0; $i <= 5; $i++) {
    array_push($frm_row, array(new CCheckBox("severity[{$i}]", str_in_array($i, $severity) ? 'yes' : 'no', null, $i), get_severity_description($i)), BR());
}
$frmMedia->AddRow(S_USE_IF_SEVERITY, $frm_row);
$cmbStat = new CComboBox("active", $active);
$cmbStat->AddItem(0, S_ENABLED);
$cmbStat->AddItem(1, S_DISABLED);
$frmMedia->AddRow("Status", $cmbStat);
$frmMedia->AddItemToBottomRow(new CButton("add", $media > -1 ? S_SAVE : S_ADD));
$frmMedia->AddItemToBottomRow(SPACE);
$frmMedia->AddItemToBottomRow(new CButtonCancel(null, 'close_window();'));
$frmMedia->Show();
include_once "include/page_footer.php";
Ejemplo n.º 15
0
    $triggers[$row['triggerid']]['items'][$row['itemid']] = $item;
}
foreach ($triggers as $triggerid => $row) {
    $description = expand_trigger_description_by_data($row);
    $menus = '';
    $host_nodeid = id2nodeid($row['hostid']);
    foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) {
        $script_nodeid = id2nodeid($script['scriptid']);
        if (bccomp($host_nodeid, $script_nodeid) == 0) {
            $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        }
    }
    $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
    $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
    $menus = rtrim($menus, ',');
    $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);";
    $host = new CSpan($row['host']);
    $host->addOption('onclick', 'javascript: ' . $menus);
    $host->addOption('onmouseover', "javascript: this.style.cursor = 'pointer';");
    $tr_conf_link = 'null';
    if ($USER_DETAILS['type'] > USER_TYPE_ZABBIX_USER) {
        $tr_conf_link = "['" . S_CONFIGURATION_OF_TRIGGERS . "',\"javascript: redirect('triggers.php?form=update&triggerid=" . $row['triggerid'] . "&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
    }
    $tr_desc = new CSpan($description, 'pointer');
    $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $row['triggerid'] . "', 'lastchange': '" . $row['lastchange'] . "'}," . $tr_conf_link . ")," . zbx_jsvalue($row['items']) . ");");
    $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $tr_desc, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'])), $row['cnt_event']));
}
$table->show();
$jsmenu = new CPUMenu(null, 170);
$jsmenu->InsertJavaScript();
include_once 'include/page_footer.php';
Ejemplo n.º 16
0
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']);
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on');
                }
            }
            $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT);
            $tr_desc = new CSpan($description, 'pointer');
            $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");");
            // Duration
            $tr_event = $event + $trigger;
            if ($next_event = get_next_event($tr_event, $events, $_REQUEST['hide_unknown'])) {
                $event['duration'] = zbx_date2age($tr_event['clock'], $next_event['clock']);
            } else {
                $event['duration'] = zbx_date2age($tr_event['clock']);
            }
            $table->addRow(array(new CLink(zbx_date2str(S_EVENTS_ACTION_TIME_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['host'] : null, new CSpan($tr_desc, 'link_menu'), new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])), new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $event['value'])), $event['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions));
        }
    }
    $table = array($paging, $table, $paging);
    $jsmenu = new CPUMenu(null, 170);
    $jsmenu->InsertJavaScript();
}
$events_wdgt->addItem($table);
// NAV BAR
$timeline = array('period' => $effectiveperiod, 'starttime' => date('YmdHis', $starttime), 'usertime' => date('YmdHis', $till));
$dom_graph_id = 'scroll_events_id';
$objData = array('id' => 'timeline_1', 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1);
zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
zbx_add_post_js('timeControl.processObjects();');
$events_wdgt->show();
include_once 'include/page_footer.php';
Ejemplo n.º 17
0
        $last_clock = !empty($clock) ? min($clock) : null;
        order_page_result($events, 'clock', ZBX_SORT_DOWN);
        foreach ($events as $num => $row) {
            // Actions
            $actions = get_event_actions_status($row['eventid']);
            //--------
            if ($config['event_ack_enable']) {
                if ($row['acknowledged'] == 1) {
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row['eventid'], 'action');
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row['eventid'], 'on');
                }
            }
            $tr_desc = new CSpan($row['desc'], 'pointer');
            $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $row['triggerid'] . "', 'lastchange': '" . $row['clock'] . "'})," . zbx_jsvalue($row['items']) . ");");
            $table->addRow(array(new CLink(date('Y.M.d H:i:s', $row['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($row['triggerid']) : null, $_REQUEST['hostid'] == 0 ? $row['host'] : null, $tr_desc, $row['value'], new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $row['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions));
        }
    }
}
// Navigation
$next_clock = $last_clock;
$navForm = new CForm('events.php');
$navForm->setMethod('get');
if (isset($_REQUEST['groupid'])) {
    $navForm->addVar('groupid', $_REQUEST['groupid']);
}
if (isset($_REQUEST['hostid'])) {
    $navForm->addVar('hostid', $_REQUEST['hostid']);
}
$navForm->addVar('fullscreen', $_REQUEST['fullscreen']);
$navForm->addVar('prev_clock', $prev_clock);
Ejemplo n.º 18
0
         $to_ack = new CCol(S_ACKNOWLEDGED, 'off');
     }
 } else {
     $to_ack = null;
 }
 if ($show_events != EVENTS_OPTION_NOEVENT && !empty($trigger['events'])) {
     $open_close = new CDiv(SPACE, 'filterclosed');
     $open_close->setAttribute('data-switcherid', $trigger['triggerid']);
 } else {
     if ($show_events == EVENTS_OPTION_NOEVENT) {
         $open_close = null;
     } else {
         $open_close = SPACE;
     }
 }
 $severity_col = new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $trigger['value']));
 if ($show_event_col) {
     $severity_col->setColSpan(2);
 }
 $table->addRow(array($open_close, $config['event_ack_enable'] ? $show_event_col ? null : new CCheckBox('triggers[' . $trigger['triggerid'] . ']', 'no', null, $trigger['triggerid']) : null, $severity_col, $status, $lastchange, zbx_date2age($trigger['lastchange']), $show_event_col ? SPACE : NULL, $to_ack, get_node_name_by_elid($trigger['triggerid']), $host, $tr_desc, new CLink(zbx_empty($trigger['comments']) ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $trigger['triggerid'])), 'even_row');
 if ($show_events != EVENTS_OPTION_NOEVENT) {
     $i = 1;
     foreach ($trigger['events'] as $enum => $row_event) {
         $i++;
         $status = new CSpan(trigger_value2str($row_event['value']), get_trigger_value_style($row_event['value']));
         if ($config['event_ack_enable']) {
             if ($row_event['value'] == TRIGGER_VALUE_TRUE) {
                 if ($row_event['acknowledged'] == 1) {
                     $acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid=' . $row_event['eventid']));
                     $ack = array(new CSpan(S_YES, 'off'), SPACE . '(' . $acks_cnt['cnt'] . SPACE, new CLink(S_SHOW, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file']), ')');
                 } else {
Ejemplo n.º 19
0
     $rowCondition[] = new CTextBox('new_condition[value]', "", 40);
     break;
 case CONDITION_TYPE_TRIGGER_VALUE:
     $cmbCondVal = new CComboBox('new_condition[value]');
     foreach (array(TRIGGER_VALUE_FALSE, TRIGGER_VALUE_TRUE) as $tr_val) {
         $cmbCondVal->addItem($tr_val, trigger_value2str($tr_val));
     }
     $rowCondition[] = $cmbCondVal;
     break;
 case CONDITION_TYPE_TIME_PERIOD:
     $rowCondition[] = new CTextBox('new_condition[value]', "1-7,00:00-23:59", 40);
     break;
 case CONDITION_TYPE_TRIGGER_SEVERITY:
     $cmbCondVal = new CComboBox('new_condition[value]');
     foreach (array(TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER) as $id) {
         $cmbCondVal->addItem($id, get_severity_description($id));
     }
     $rowCondition[] = $cmbCondVal;
     break;
 case CONDITION_TYPE_MAINTENANCE:
     $rowCondition[] = new CCol(S_MAINTENANCE_SMALL);
     break;
 case CONDITION_TYPE_NODE:
     $tblNewCond->addItem(new CVar('new_condition[value]', '0'));
     $rowCondition[] = array(new CTextBox('node', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?writeonly=1&dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=node&srctbl=nodes" . "&srcfld1=nodeid&srcfld2=name',450,450);", 'T'));
     break;
 case CONDITION_TYPE_DRULE:
     $tblNewCond->addItem(new CVar('new_condition[value]', '0'));
     $rowCondition[] = array(new CTextBox('drule', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=drule&srctbl=drules" . "&srcfld1=druleid&srcfld2=name',450,450);", 'T'));
     break;
 case CONDITION_TYPE_DCHECK: