$users_id = array(); $db_users = DBselect('SELECT DISTINCT u.alias,u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . $row['usrgrpid'] . ' ORDER BY u.alias'); while ($db_user = DBfetch($db_users)) { if (!empty($users)) { $users[$db_user['userid']][] = ', '; } else { $users[$db_user['userid']] = array(); } $users[$db_user['userid']][] = new Clink($db_user['alias'], 'users.php?form=update&config=0&userid=' . $db_user['userid'] . '#form'); } $gui_access = user_auth_type2str($row['gui_access']); $users_status = $row['users_status'] == GROUP_STATUS_ENABLED ? S_ENABLED : S_DISABLED; if (granted2update_group($row['usrgrpid'])) { $next_gui_auth = $row['gui_access'] + 1 > GROUP_GUI_ACCESS_DISABLED ? GROUP_GUI_ACCESS_SYSTEM : $row['gui_access'] + 1; $gui_access = new CLink($gui_access, 'users.php?form=update' . '&set_gui_access=' . $next_gui_auth . '&usrgrpid=' . $row['usrgrpid'] . url_param('config'), $row['gui_access'] == GROUP_GUI_ACCESS_DISABLED ? 'orange' : 'enabled'); $users_status = new CLink($users_status, 'users.php?form=update' . '&set_users_status=' . ($row['users_status'] == GROUP_STATUS_ENABLED ? GROUP_STATUS_DISABLED : GROUP_STATUS_ENABLED) . '&usrgrpid=' . $row['usrgrpid'] . url_param('config'), $row['users_status'] == GROUP_STATUS_ENABLED ? 'enabled' : 'disabled'); } else { $gui_access = new CSpan($gui_access, $row['gui_access'] == GROUP_GUI_ACCESS_DISABLED ? 'orange' : 'green'); $users_status = new CSpan($users_status, $row['users_status'] == GROUP_STATUS_ENABLED ? 'green' : 'red'); } $table->addRow(array($users_status, $gui_access, array(new CCheckBox('group_groupid[' . $row['usrgrpid'] . ']', NULL, NULL, $row['usrgrpid']), $alias = new CLink($row['name'], 'users.php?form=update' . url_param('config') . '&usrgrpid=' . $row['usrgrpid'] . '#form', 'action')), new CCol($users, 'wraptext'))); $row_count++; } $table->SetFooter(new CCol(new CButtonQMessage('delete_selected', S_DELETE_SELECTED, S_DELETE_SELECTED_GROUPS_Q))); $form->AddItem($table); $form->Show(); } } } zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");'); include_once 'include/page_footer.php';
while ($action_data = DBfetch($db_actions)) { if (!action_accessible($action_data['actionid'], PERM_READ_WRITE)) { continue; } $conditions = array(); $db_conditions = DBselect('select * from conditions where actionid=' . $action_data['actionid'] . ' order by conditiontype,conditionid'); while ($condition_data = DBfetch($db_conditions)) { array_push($conditions, array(get_condition_desc($condition_data['conditiontype'], $condition_data['operator'], $condition_data['value']), BR())); } unset($db_conditions, $condition_data); $operations = array(); $db_operations = DBselect('select * from operations where actionid=' . $action_data['actionid'] . ' order by operationtype,operationid'); while ($operation_data = DBfetch($db_operations)) { array_push($operations, array(get_operation_desc(SHORT_DESCRITION, $operation_data), BR())); } if ($action_data['status'] == ACTION_STATUS_DISABLED) { $status = new CLink(S_DISABLED, 'actionconf.php?group_enable=1&g_actionid%5B%5D=' . $action_data['actionid'] . url_param('eventsource'), 'disabled'); } else { $status = new CLink(S_ENABLED, 'actionconf.php?group_disable=1&g_actionid%5B%5D=' . $action_data['actionid'] . url_param('eventsource'), 'enabled'); } $tblActions->addRow(array(array(new CCheckBox('g_actionid[' . $action_data['actionid'] . ']', null, null, $action_data['actionid']), SPACE, new CLink($action_data['name'], 'actionconf.php?form=update&actionid=' . $action_data['actionid'], 'action')), $conditions, $operations, $status)); $row_count++; } $tblActions->SetFooter(new CCol(array(new CButtonQMessage('group_enable', S_ENABLE_SELECTED, S_ENABLE_SELECTED_ACTIONS_Q), SPACE, new CButtonQMessage('group_disable', S_DISABLE_SELECTED, S_DISABLE_SELECTED_ACTIONS_Q), SPACE, new CButtonQMessage('group_delete', S_DELETE_SELECTED, S_DELETE_SELECTED_ACTIONS_Q)))); $form->addItem($tblActions); $form->Show(); } if (isset($row_count)) { zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");'); } include_once "include/page_footer.php";
/* form */ insert_drule_form(); } else { show_table_header(S_DISCOVERY_BIG); /* table */ $form = new CForm(); $form->SetName('frmdrules'); $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED); $tblDiscovery->SetHeader(array(array(new CCheckBox('all_drules', null, "CheckAll('" . $form->GetName() . "','all_drules');"), make_sorting_link(S_NAME, 'd.name')), make_sorting_link(S_IP_RANGE, 'd.iprange'), make_sorting_link(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS)); $db_rules = DBselect('SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid')); while ($rule_data = DBfetch($db_rules)) { $cheks = array(); $db_checks = DBselect("select * from dchecks where druleid=" . $rule_data["druleid"] . " order by type,druleid"); while ($check_data = DBfetch($db_checks)) { $cheks[] = discovery_check_type2str($check_data['type']); } $status = new CCol(new CLink(discovery_status2str($rule_data["status"]), '?g_druleid%5B%5D=' . $rule_data['druleid'] . ($rule_data["status"] == DRULE_STATUS_ACTIVE ? '&group_disable=1' : '&group_enable=1'), discovery_status2style($rule_data["status"]))); $description = array(); if ($rule_data["proxy_hostid"]) { $proxy = get_host_by_hostid($rule_data["proxy_hostid"]); array_push($description, $proxy["host"], ":"); } array_push($description, new CLink($rule_data['name'], "?form=update&druleid=" . $rule_data['druleid'], 'action')); $drule = new CCol(array(new CCheckBox('g_druleid[' . $rule_data["druleid"] . ']', null, null, $rule_data["druleid"]), SPACE, $description)); $tblDiscovery->AddRow(array($drule, $rule_data['iprange'], $rule_data['delay'], implode(',', $cheks), $status)); } $tblDiscovery->SetFooter(new CCol(array(new CButtonQMessage('group_enable', S_ENABLE_SELECTED, S_ENABLE_SELECTED_RULES_Q), SPACE, new CButtonQMessage('group_disable', S_DISABLE_SELECTED, S_DISABLE_SELECTED_RULES_Q), SPACE, new CButtonQMessage('group_delete', S_DELETE_SELECTED, S_DELETE_SELECTED_RULES_Q)))); $form->AddItem($tblDiscovery); $form->Show(); } include_once "include/page_footer.php";
$trigger_cnt = array(new CCheckBox('triggers[' . $host['hostid'] . ']', isset($triggers[$host['hostid']]) || !isset($update), NULL, true), $host['triggers_cnt']); } else { $trigger_cnt = '-'; } /* calculate graphs */ if (isset($host['graphs_cnt']) && $host['graphs_cnt'] > 0) { $graph_cnt = array(new CCheckBox('graphs[' . $host['hostid'] . ']', isset($graphs[$host['hostid']]) || !isset($update), NULL, true), $host['graphs_cnt']); } else { $graph_cnt = '-'; } /* $screens = 0; */ if ($host["status"] == HOST_STATUS_TEMPLATE) { $ip = $dns = $port = '-'; } else { $ip = empty($host["ip"]) ? '-' : $host["ip"]; $dns = empty($host["dns"]) ? '-' : $host["dns"]; if ($host["useip"] == 1) { $ip = bold($ip); } else { $dns = bold($dns); } $port = empty($host["port"]) ? '-' : $host["port"]; } $table->AddRow(array($host_name, $dns, $ip, $port, $status, $template_cnt, $item_cnt, $trigger_cnt, $graph_cnt)); } $table->SetFooter(new CCol(array(new CButton('preview', S_PREVIEW), new CButton('export', S_EXPORT)))); $form->AddItem($table); $form->Show(); } } include_once "include/page_footer.php";
function get_expressions_tab() { if (isset($_REQUEST['regexpid']) && !isset($_REQUEST["form_refresh"])) { $expressions = array(); $sql = 'SELECT e.* ' . ' FROM expressions e ' . ' WHERE ' . DBin_node('e.expressionid') . ' AND e.regexpid=' . $_REQUEST['regexpid'] . ' ORDER BY e.expression_type'; $db_exps = DBselect($sql); while ($exp = DBfetch($db_exps)) { $expressions[] = $exp; } } else { $expressions = get_request('expressions', array()); } $tblExp = new CTableInfo(); $tblExp->setHeader(array(new CCheckBox('all_expressions', null, 'CheckAll("Regular expression","all_expressions","g_expressionid");'), S_EXPRESSION, S_EXPECTED_RESULT, S_IGNORE_CASE, S_EDIT)); // zbx_rksort($timeperiods); foreach ($expressions as $id => $expression) { $exp_result = expression_type2str($expression['expression_type']); if (EXPRESSION_TYPE_ANY_INCLUDED == $expression['expression_type']) { $exp_result .= ' (' . S_DELIMITER . "='" . $expression['exp_delimiter'] . "')"; } $tblExp->addRow(array(new CCheckBox('g_expressionid[]', 'no', null, $id), $expression['expression'], $exp_result, $expression['case_sensitive'] ? S_YES : S_NO, new CButton('edit_expressionid[' . $id . ']', S_EDIT))); $tblExp->addItem(new Cvar('expressions[' . $id . '][expression]', $expression['expression'])); $tblExp->addItem(new Cvar('expressions[' . $id . '][expression_type]', $expression['expression_type'])); $tblExp->addItem(new Cvar('expressions[' . $id . '][case_sensitive]', $expression['case_sensitive'])); $tblExp->addItem(new Cvar('expressions[' . $id . '][exp_delimiter]', $expression['exp_delimiter'])); } $buttons = array(); if (!isset($_REQUEST['new_expression'])) { $buttons[] = new CButton('new_expression', S_NEW); $buttons[] = new CButton('delete_expression', S_DELETE); } $td = new CCol($buttons); $td->addOption('colspan', '5'); $td->addOption('style', 'text-align: right;'); $tblExp->SetFooter($td); return $tblExp; }
$table->SetHeader(array(S_NAME)); $sql_from = ''; $sql_where = ''; if ($groupid > 0) { $sql_from .= ',hosts_groups hg '; $sql_where .= ' AND hg.groupid=' . $groupid . ' AND h.hostid=hg.hostid '; } $sql = 'SELECT DISTINCT h.* ' . ' FROM hosts h' . $sql_from . ' WHERE ' . DBin_node('h.hostid', $nodeid) . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status=' . HOST_STATUS_TEMPLATE . $sql_where . ' ORDER BY h.host,h.hostid'; $db_hosts = DBselect($sql); while ($host = DBfetch($db_hosts)) { $chk = new CCheckBox('templates[' . $host['hostid'] . ']', isset($templates[$host['hostid']]), null, $host['host']); $chk->setEnabled(!isset($existed_templates[$host['hostid']])); $table->addRow(array(array($chk, $host['host']))); unset($host); } $table->SetFooter(new CButton('select', S_SELECT)); $form = new CForm(); $form->addVar('existed_templates', $existed_templates); if ($monitored_hosts) { $form->addVar('monitored_hosts', 1); } if ($real_hosts) { $form->addVar('real_hosts', 1); } $form->addVar('dstfrm', $dstfrm); $form->addVar('dstfld1', $dstfld1); $form->addVar('srctbl', $srctbl); $form->addVar('srcfld1', $srcfld1); $form->addVar('srcfld2', $srcfld2); $form->addItem($table); $form->Show();
} $chkBox = new CCheckBox('group_graphid[' . $row['graphid'] . ']', NULL, NULL, $row['graphid']); if ($row['templateid'] > 0) { $chkBox->SetEnabled(false); } switch ($row['graphtype']) { case GRAPH_TYPE_STACKED: $graphtype = S_STACKED; break; case GRAPH_TYPE_PIE: $graphtype = S_PIE; break; case GRAPH_TYPE_EXPLODED: $graphtype = S_EXPLODED; break; default: $graphtype = S_NORMAL; break; } $table->addRow(array($host_list, array($chkBox, $name), $row['width'], $row['height'], $graphtype)); $row_count++; } $table->SetFooter(new CCol(array(new CButtonQMessage('delete', S_DELETE_SELECTED, S_DELETE_SELECTED_ITEMS_Q), SPACE, new CButton('form_copy_to', S_COPY_SELECTED_TO)))); $form->AddItem($table); $form->Show(); } } if (isset($row_count)) { zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");'); } include_once 'include/page_footer.php';
$prefix = null; $trigger = "-"; $description = $db_service_data["name"]; if (isset($db_service_data["triggerid"])) { $trigger = expand_trigger_description($db_service_data["triggerid"]); } $description = new CLink($description, '#', 'action'); $description->SetAction('window.opener.add_child_service(' . zbx_jsvalue($db_service_data["name"]) . ',' . zbx_jsvalue($db_service_data["serviceid"]) . ',' . zbx_jsvalue($trigger) . ',' . zbx_jsvalue($db_service_data["triggerid"]) . '); self.close(); return false;'); $table->AddRow(array(array($prefix, $description), algorithm2str($db_service_data["algorithm"]), $trigger)); } $cb = new CButton('cancel', S_CANCEL); $cb->SetType('button'); $cb->SetAction('javascript: self.close();'); $td = new CCol($cb); $td->setAttribute('style', 'text-align:right;'); $table->SetFooter($td); $form->AddItem($table); $form->Show(); } //-------------------------------------------- </CHILD SERVICES LIST> -------------------------------------------- //-------------------------------------------- <FORM> -------------------------------------------- if (isset($_REQUEST['sform'])) { $frmService = new CFormTable(S_SERVICE, 'services_form.php', 'POST', null, 'sform'); $frmService->SetHelp("web.services.service.php"); $frmService->SetTableClass('formlongtable'); //service times if (isset($_REQUEST["add_service_time"]) && isset($_REQUEST["new_service_time"])) { $_REQUEST['service_times'] = get_request('service_times', array()); $new_service_time['type'] = $_REQUEST["new_service_time"]['type']; if ($_REQUEST["new_service_time"]['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME) { $new_service_time['from'] = $_REQUEST['new_service_time']['from'];
while ($exp = DBfetch($db_exps)) { if (!isset($expressions[$exp['regexpid']])) { $count[$exp['regexpid']] = 1; } else { $count[$exp['regexpid']]++; } if (!isset($expressions[$exp['regexpid']])) { $expressions[$exp['regexpid']] = new CTable(); } $expressions[$exp['regexpid']]->addRow(array($count[$exp['regexpid']], ' » ', $exp['expression'], ' [' . expression_type2str($exp['expression_type']) . ']')); $regexp[$exp['regexpid']]['expressions'][$exp['expressionid']] = $exp; } $form = new CForm(null, 'post'); $form->setName('regexp'); $table = new CTableInfo(); $table->setHeader(array(array(new CCheckBox('all_regexps', NULL, "CheckAll('" . $form->GetName() . "','all_regexps','group_regexpid');"), S_NAME), S_EXPRESSIONS)); foreach ($regexps as $regexpid => $regexp) { $table->addRow(array(array(new CCheckBox('regexpids[' . $regexp['regexpid'] . ']', NULL, NULL, $regexp['regexpid']), new CLink($regexp['name'], 'config.php?form=update' . url_param('config') . '®expid=' . $regexp['regexpid'] . '#form', 'action')), isset($expressions[$regexpid]) ? $expressions[$regexpid] : '-')); } // $table->SetFooter(new CCol(new CButtonQMessage('delete_selected',S_DELETE_SELECTED,S_DELETE_SELECTED_USERS_Q))); $table->SetFooter(new CCol(array(new CButtonQMessage('delete', S_DELETE_SELECTED, S_DELETE_SELECTED_REGULAR_EXPRESSIONS_Q)))); $form->AddItem($table); $form->show(); } } } } } } } include_once 'include/page_footer.php';
} if ($row['status'] == TRIGGER_STATUS_DISABLED) { $status = new CLink(S_DISABLED, 'triggers.php?group_enable=1&g_triggerid%5B%5D=' . $row['triggerid'] . '&hostid=' . $row['hostid'], 'disabled'); } else { if ($row['status'] == TRIGGER_STATUS_UNKNOWN) { $status = new CLink(S_UNKNOWN, 'triggers.php?group_disable=1&g_triggerid%5B%5D=' . $row['triggerid'] . '&hostid=' . $row['hostid'], 'unknown'); } else { if ($row['status'] == TRIGGER_STATUS_ENABLED) { $status = new CLink(S_ENABLED, 'triggers.php?group_disable=1&g_triggerid%5B%5D=' . $row['triggerid'] . '&hostid=' . $row['hostid'], 'enabled'); } } } if ($row['status'] != TRIGGER_STATUS_UNKNOWN) { $row['error'] = SPACE; } $table->addRow(array($priority, $status, $_REQUEST['hostid'] > 0 ? NULL : $row['host'], $description, explode_exp($row['expression'], 1))); $row_count++; } $table->SetFooter(new CCol(array(new CButtonQMessage('group_enable', S_ENABLE_SELECTED, S_ENABLE_SELECTED_TRIGGERS_Q), SPACE, new CButtonQMessage('group_disable', S_DISABLE_SELECTED, S_DISABLE_SELECTED_TRIGGERS_Q), SPACE, new CButtonQMessage('group_delete', S_DELETE_SELECTED, S_DELETE_SELECTED_TRIGGERS_Q), SPACE, new CButton('form_copy_to', S_COPY_SELECTED_TO), SPACE, new CButton('massupdate', S_TRIGGERS_MASSUPDATE)))); $form->AddItem($table); $form->Show(); } } } if (isset($row_count)) { zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");'); } ?> <?php include_once 'include/page_footer.php';