本文整理汇总了PHP中whereDbNode函数的典型用法代码示例。如果您正苦于以下问题:PHP whereDbNode函数的具体用法?PHP whereDbNode怎么用?PHP whereDbNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了whereDbNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DBend
}
DBend($result);
}
/*
* Display
*/
$form = new CForm();
$form->cleanItems();
$cmbConf = new CComboBox('configDropDown', 'adm.other.php', 'redirect(this.options[this.selectedIndex].value);');
$cmbConf->addItems(array('adm.gui.php' => _('GUI'), 'adm.housekeeper.php' => _('Housekeeping'), 'adm.images.php' => _('Images'), 'adm.iconmapping.php' => _('Icon mapping'), 'adm.regexps.php' => _('Regular expressions'), 'adm.macros.php' => _('Macros'), 'adm.valuemapping.php' => _('Value mapping'), 'adm.workingtime.php' => _('Working time'), 'adm.triggerseverities.php' => _('Trigger severities'), 'adm.triggerdisplayoptions.php' => _('Trigger displaying options'), 'adm.other.php' => _('Other')));
$form->addItem($cmbConf);
$cnf_wdgt = new CWidget();
$cnf_wdgt->addPageHeader(_('OTHER CONFIGURATION PARAMETERS'), $form);
$data = array();
$data['form_refresh'] = get_request('form_refresh', 0);
if ($data['form_refresh']) {
$data['config']['discovery_groupid'] = get_request('discovery_groupid');
$data['config']['alert_usrgrpid'] = get_request('alert_usrgrpid');
$data['config']['refresh_unsupported'] = get_request('refresh_unsupported');
$data['config']['snmptrap_logging'] = get_request('snmptrap_logging');
} else {
$data['config'] = select_config(false);
}
$data['discovery_groups'] = API::HostGroup()->get(array('output' => array('usrgrpid', 'name'), 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL), 'editable' => true));
order_result($data['discovery_groups'], 'name');
$data['alert_usrgrps'] = DBfetchArray(DBselect('SELECT u.usrgrpid,u.name' . ' FROM usrgrp u' . whereDbNode('u.usrgrpid')));
order_result($data['alert_usrgrps'], 'name');
$otherForm = new CView('administration.general.other.edit', $data);
$cnf_wdgt->addItem($otherForm->render());
$cnf_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例2: getItemFormData
//.........这里部分代码省略.........
$data['type'] = $data['item']['type'];
$data['snmp_community'] = $data['item']['snmp_community'];
$data['snmp_oid'] = $data['item']['snmp_oid'];
$data['port'] = $data['item']['port'];
$data['value_type'] = $data['item']['value_type'];
$data['data_type'] = $data['item']['data_type'];
$data['trapper_hosts'] = $data['item']['trapper_hosts'];
$data['units'] = $data['item']['units'];
$data['valuemapid'] = $data['item']['valuemapid'];
$data['multiplier'] = $data['item']['multiplier'];
$data['hostid'] = $data['item']['hostid'];
$data['params'] = $data['item']['params'];
$data['snmpv3_contextname'] = $data['item']['snmpv3_contextname'];
$data['snmpv3_securityname'] = $data['item']['snmpv3_securityname'];
$data['snmpv3_securitylevel'] = $data['item']['snmpv3_securitylevel'];
$data['snmpv3_authprotocol'] = $data['item']['snmpv3_authprotocol'];
$data['snmpv3_authpassphrase'] = $data['item']['snmpv3_authpassphrase'];
$data['snmpv3_privprotocol'] = $data['item']['snmpv3_privprotocol'];
$data['snmpv3_privpassphrase'] = $data['item']['snmpv3_privpassphrase'];
$data['ipmi_sensor'] = $data['item']['ipmi_sensor'];
$data['authtype'] = $data['item']['authtype'];
$data['username'] = $data['item']['username'];
$data['password'] = $data['item']['password'];
$data['publickey'] = $data['item']['publickey'];
$data['privatekey'] = $data['item']['privatekey'];
$data['formula'] = $data['item']['formula'];
$data['logtimefmt'] = $data['item']['logtimefmt'];
$data['inventory_link'] = $data['item']['inventory_link'];
$data['new_application'] = get_request('new_application', '');
$data['lifetime'] = $data['item']['lifetime'];
$data['filter'] = $data['item']['filter'];
if (!$data['limited'] || !isset($_REQUEST['form_refresh'])) {
$data['delay'] = $data['item']['delay'];
if (($data['type'] == ITEM_TYPE_TRAPPER || $data['type'] == ITEM_TYPE_SNMPTRAP) && $data['delay'] == 0) {
$data['delay'] = ZBX_ITEM_DELAY_DEFAULT;
}
$data['history'] = $data['item']['history'];
$data['status'] = $data['item']['status'];
$data['delta'] = $data['item']['delta'];
$data['trends'] = $data['item']['trends'];
$db_delay_flex = $data['item']['delay_flex'];
if (isset($db_delay_flex)) {
$arr_of_dellays = explode(';', $db_delay_flex);
foreach ($arr_of_dellays as $one_db_delay) {
$arr_of_delay = explode('/', $one_db_delay);
if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) {
continue;
}
array_push($data['delay_flex'], array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1]));
}
}
$data['applications'] = array_unique(zbx_array_merge($data['applications'], get_applications_by_itemid($data['itemid'])));
}
}
// applications
if (count($data['applications']) == 0) {
array_push($data['applications'], 0);
}
$data['db_applications'] = DBfetchArray(DBselect('SELECT DISTINCT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . zbx_dbstr($data['hostid'])));
order_result($data['db_applications'], 'name');
// interfaces
$data['interfaces'] = API::HostInterface()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND));
// valuemapid
if ($data['limited']) {
if (!empty($data['valuemapid'])) {
if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid=' . zbx_dbstr($data['valuemapid'])))) {
$data['valuemaps'] = $map_data['name'];
}
}
} else {
$data['valuemaps'] = DBfetchArray(DBselect('SELECT v.*' . ' FROM valuemaps v' . whereDbNode('v.valuemapid')));
order_result($data['valuemaps'], 'name');
}
// possible host inventories
if (empty($data['parent_discoveryid'])) {
$data['possibleHostInventories'] = getHostInventories();
// get already populated fields by other items
$data['alreadyPopulated'] = API::item()->get(array('output' => array('inventory_link'), 'filter' => array('hostid' => $data['hostid']), 'nopermissions' => true));
$data['alreadyPopulated'] = zbx_toHash($data['alreadyPopulated'], 'inventory_link');
}
// template
$data['is_template'] = isTemplate($data['hostid']);
// unset snmpv3 fields
if ($data['type'] != ITEM_TYPE_SNMPV3) {
$data['snmpv3_contextname'] = '';
$data['snmpv3_securityname'] = '';
$data['snmpv3_securitylevel'] = ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV;
$data['snmpv3_authprotocol'] = ITEM_AUTHPROTOCOL_MD5;
$data['snmpv3_authpassphrase'] = '';
$data['snmpv3_privprotocol'] = ITEM_PRIVPROTOCOL_DES;
$data['snmpv3_privpassphrase'] = '';
}
// unset ssh auth fields
if ($data['type'] != ITEM_TYPE_SSH) {
$data['authtype'] = ITEM_AUTHTYPE_PASSWORD;
$data['publickey'] = '';
$data['privatekey'] = '';
}
return $data;
}
示例3: _
$cmbPeriod->addItem('daily', _('Daily'));
$cmbPeriod->addItem('weekly', _('Weekly'));
$cmbPeriod->addItem('monthly', _('Monthly'));
$cmbPeriod->addItem('yearly', _('Yearly'));
$form->addItem($cmbPeriod);
if ($period != 'yearly') {
$form->addItem(SPACE . _('Year') . SPACE);
$cmbYear = new CComboBox('year', $year, 'submit();');
for ($y = $minYear; $y <= date('Y'); $y++) {
$cmbYear->addItem($y, $y);
}
$form->addItem($cmbYear);
}
show_table_header(_('Notifications'), $form);
$header = array();
$db_users = DBselect('SELECT u.*' . ' FROM users u' . whereDbNode('u.userid') . ' ORDER BY u.alias,u.userid');
while ($user_data = DBfetch($db_users)) {
$header[] = new CCol($user_data['alias'], 'vertical_rotation');
$users[$user_data['userid']] = $user_data['alias'];
}
$intervals = array();
switch ($period) {
case 'yearly':
$minTime = mktime(0, 0, 0, 1, 1, $minYear);
$dateFormat = REPORT4_ANNUALLY_DATE_FORMAT;
array_unshift($header, new CCol(_('Year'), 'center'));
for ($i = $minYear; $i <= date('Y'); $i++) {
$intervals[mktime(0, 0, 0, 1, 1, $i)] = mktime(0, 0, 0, 1, 1, $i + 1);
}
break;
case 'monthly':
示例4: DBselect
$db_slides = DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($data['slideshowid']) . ' ORDER BY s.step');
while ($slide = DBfetch($db_slides)) {
$data['slides'][$slide['step']] = array('slideid' => $slide['slideid'], 'screenid' => $slide['screenid'], 'delay' => $slide['delay']);
}
}
// get slides without delay
$data['slides_without_delay'] = $data['slides'];
for ($i = 0, $size = count($data['slides_without_delay']); $i < $size; $i++) {
unset($data['slides_without_delay'][$i]['delay']);
}
// render view
$slideshowView = new CView('configuration.slideconf.edit', $data);
$slideshowView->render();
$slideshowView->show();
} else {
$data['slides'] = DBfetchArray(DBselect('SELECT s.slideshowid,s.name,s.delay,COUNT(sl.slideshowid) AS cnt' . ' FROM slideshows s' . ' LEFT JOIN slides sl ON sl.slideshowid=s.slideshowid' . whereDbNode('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay'));
order_result($data['slides'], getPageSortField('name'), getPageSortOrder());
$data['paging'] = getPagingLine($data['slides'], array('slideshowid'));
// nodes
if ($data['displayNodes'] = is_array(get_current_nodeid())) {
foreach ($data['slides'] as &$slide) {
$slide['nodename'] = get_node_name_by_elid($slide['slideshowid'], true);
}
unset($slide);
}
// render view
$slideshowView = new CView('configuration.slideconf.list', $data);
$slideshowView->render();
$slideshowView->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';
示例5: dirname
if ($_REQUEST['favobj'] == 'timelinefixedperiod') {
if (isset($_REQUEST['favid'])) {
CProfile::update('web.slides.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT);
}
}
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
require_once dirname(__FILE__) . '/include/page_footer.php';
exit;
}
/*
* Display
*/
$data = array('fullscreen' => $_REQUEST['fullscreen'], 'slideshows' => array());
// get slideshows
$db_slideshows = DBselect('SELECT s.slideshowid,s.name' . ' FROM slideshows s' . whereDbNode('s.slideshowid'));
while ($slideshow = DBfetch($db_slideshows)) {
if (slideshow_accessible($slideshow['slideshowid'], PERM_READ)) {
$data['slideshows'][$slideshow['slideshowid']] = $slideshow;
}
}
order_result($data['slideshows'], 'name');
// get element id
$data['elementid'] = get_request('elementid', CProfile::get('web.slides.elementid', null));
CProfile::update('web.slides.elementid', $data['elementid'], PROFILE_TYPE_ID);
if (!isset($data['slideshows'][$data['elementid']])) {
$slideshow = reset($data['slideshows']);
$data['elementid'] = $slideshow['slideshowid'];
}
// get screen
$data['screen'] = empty($data['elementid']) ? array() : get_slideshow($data['elementid'], 0);
示例6: array
$regExpWidget->addPageHeader(_('CONFIGURATION OF REGULAR EXPRESSIONS'), $regExpForm);
if (isset($_REQUEST['form'])) {
$data = array('form_refresh' => get_request('form_refresh'), 'regexpid' => get_request('regexpid'));
if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
$regExp = DBfetch(DBSelect('SELECT re.name,re.test_string' . ' FROM regexps re' . ' WHERE re.regexpid=' . zbx_dbstr($_REQUEST['regexpid']) . andDbNode('re.regexpid')));
$data['name'] = $regExp['name'];
$data['test_string'] = $regExp['test_string'];
$dbExpressions = DBselect('SELECT e.expressionid,e.expression,e.expression_type,e.exp_delimiter,e.case_sensitive' . ' FROM expressions e' . ' WHERE e.regexpid=' . zbx_dbstr($_REQUEST['regexpid']) . andDbNode('e.expressionid') . ' ORDER BY e.expression_type');
$data['expressions'] = DBfetchArray($dbExpressions);
} else {
$data['name'] = get_request('name', '');
$data['test_string'] = get_request('test_string', '');
$data['expressions'] = get_request('expressions', array());
}
$regExpForm = new CView('administration.general.regularexpressions.edit', $data);
} else {
$data = array('displayNodes' => is_array(get_current_nodeid()), 'cnf_wdgt' => &$regExpWidget, 'regexps' => array(), 'regexpids' => array());
$dbRegExp = DBselect('SELECT re.* FROM regexps re ' . whereDbNode('re.regexpid'));
while ($regExp = DBfetch($dbRegExp)) {
$regExp['expressions'] = array();
$regExp['nodename'] = $data['displayNodes'] ? get_node_name_by_elid($regExp['regexpid'], true) : '';
$data['regexps'][$regExp['regexpid']] = $regExp;
$data['regexpids'][$regExp['regexpid']] = $regExp['regexpid'];
}
order_result($data['regexps'], 'name');
$data['db_exps'] = DBfetchArray(DBselect('SELECT e.*' . ' FROM expressions e' . ' WHERE ' . dbConditionInt('e.regexpid', $data['regexpids']) . andDbNode('e.expressionid') . ' ORDER BY e.expression_type'));
$regExpForm = new CView('administration.general.regularexpressions.list', $data);
}
$regExpWidget->addItem($regExpForm->render());
$regExpWidget->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例7: get_request
}
$data['selected_usrgrp'] = get_request('selusrgrp', 0);
// sort group rights
order_result($data['group_rights'], 'name');
// get users
if ($data['selected_usrgrp'] > 0) {
$sqlFrom = ',users_groups g';
$sqlWhere = ' WHERE ' . dbConditionInt('u.userid', $data['group_users']) . ' OR (u.userid=g.userid AND g.usrgrpid=' . zbx_dbstr($data['selected_usrgrp']) . andDbNode('u.userid') . ')';
} else {
$sqlFrom = '';
$sqlWhere = whereDbNode('u.userid');
}
$data['users'] = DBfetchArray(DBselect('SELECT DISTINCT u.userid,u.alias,u.name,u.surname' . ' FROM users u' . $sqlFrom . $sqlWhere));
order_result($data['users'], 'alias');
// get user groups
$data['usergroups'] = DBfetchArray(DBselect('SELECT ug.usrgrpid,ug.name' . ' FROM usrgrp ug' . whereDbNode('usrgrpid')));
order_result($data['usergroups'], 'name');
// render view
$userGroupsView = new CView('administration.usergroups.edit', $data);
$userGroupsView->render();
$userGroupsView->show();
} else {
$data = array('displayNodes' => is_array(get_current_nodeid()));
$sortfield = getPageSortField('name');
$data['usergroups'] = API::UserGroup()->get(array('output' => API_OUTPUT_EXTEND, 'selectUsers' => API_OUTPUT_EXTEND, 'sortfield' => $sortfield, 'limit' => $config['search_limit'] + 1));
// sorting & paging
order_result($data['usergroups'], $sortfield, getPageSortOrder());
$data['paging'] = getPagingLine($data['usergroups'], array('usrgrpid'));
// nodes
if ($data['displayNodes']) {
foreach ($data['usergroups'] as &$userGroup) {
示例8: count
$data['initial_item_type'] = $initialItemType;
$data['multiple_interface_types'] = count(array_unique($usedInterfacesTypes)) > 1;
}
// application
if (count($data['applications']) == 0) {
array_push($data['applications'], 0);
}
if (!empty($data['hostid'])) {
$data['db_applications'] = DBfetchArray(DBselect('SELECT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . zbx_dbstr($data['hostid'])));
order_result($data['db_applications'], 'name');
}
// item types
$data['itemTypes'] = item_type2str();
unset($data['itemTypes'][ITEM_TYPE_HTTPTEST]);
// valuemap
$data['valuemaps'] = DBfetchArray(DBselect('SELECT v.valuemapid,v.name' . ' FROM valuemaps v' . whereDbNode('v.valuemapid')));
order_result($data['valuemaps'], 'name');
// render view
$itemView = new CView('configuration.item.massupdate', $data);
$itemView->render();
$itemView->show();
} elseif ($_REQUEST['go'] == 'copy_to' && isset($_REQUEST['group_itemid'])) {
$data = array('group_itemid' => get_request('group_itemid', array()), 'hostid' => get_request('hostid', 0), 'copy_type' => get_request('copy_type', 0), 'copy_groupid' => get_request('copy_groupid', 0), 'copy_targetid' => get_request('copy_targetid', array()));
if (!is_array($data['group_itemid']) || is_array($data['group_itemid']) && count($data['group_itemid']) < 1) {
error(_('Incorrect list of items.'));
} else {
// group
$data['groups'] = API::HostGroup()->get(array('output' => API_OUTPUT_EXTEND));
order_result($data['groups'], 'name');
// hosts
if ($data['copy_type'] == 0) {
示例9: info
info(_n('There is "%1$d" group with Internal GUI access.', 'There are "%1$d" groups with Internal GUI access.', $result['cnt_usrgrp']));
}
if (update_config($config)) {
// reset all sessions
if ($isAuthenticationTypeChanged) {
DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr(CWebUser::$data['sessionid']));
}
$isAuthenticationTypeChanged = false;
add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, _('Authentication method changed to HTTP'));
show_message(_('Authentication method changed to HTTP'));
} else {
show_error_message(_('Cannot change authentication method to HTTP'));
}
}
}
show_messages();
/*
* Display
*/
$data = array('form_refresh' => get_request('form_refresh'), 'config' => $config, 'is_authentication_type_changed' => $isAuthenticationTypeChanged, 'user' => get_request('user', CWebUser::$data['alias']), 'user_password' => get_request('user_password', ''), 'user_list' => null, 'change_bind_password' => get_request('change_bind_password'));
// get tab title
$data['title'] = authentication2str($config['authentication_type']);
// get user list
if (getUserGuiAccess(CWebUser::$data['userid']) == GROUP_GUI_ACCESS_INTERNAL) {
$data['user_list'] = DBfetchArray(DBselect('SELECT u.alias,u.userid' . ' FROM users u' . whereDbNode('u.userid') . ' ORDER BY u.alias'));
}
// render view
$authenticationView = new CView('administration.authentication.edit', $data);
$authenticationView->render();
$authenticationView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例10: get_request
$severity[$i] = $i;
}
}
} else {
$severity = get_request('severity', array(0, 1, 2, 3, 4, 5));
}
$media = get_request('media', -1);
$sendto = get_request('sendto', '');
$mediatypeid = get_request('mediatypeid', 0);
$active = get_request('active', 0);
$period = get_request('period', ZBX_DEFAULT_INTERVAL);
$frmMedia = new CFormTable(_('New media'));
$frmMedia->addVar('media', $media);
$frmMedia->addVar('dstfrm', $_REQUEST['dstfrm']);
$cmbType = new CComboBox('mediatypeid', $mediatypeid);
$types = DBfetchArrayAssoc(DBselect('SELECT mt.mediatypeid,mt.description' . ' FROM media_type mt' . whereDbNode('mt.mediatypeid')), 'mediatypeid');
CArrayHelper::sort($types, array('description'));
foreach ($types as $mediaTypeId => $type) {
$cmbType->addItem($mediaTypeId, get_node_name_by_elid($type['mediatypeid'], null, NAME_DELIMITER) . $type['description']);
}
$frmMedia->addRow(_('Type'), $cmbType);
$frmMedia->addRow(_('Send to'), new CTextBox('sendto', $sendto, 48));
$frmMedia->addRow(_('When active'), new CTextBox('period', $period, 48));
$frm_row = array();
foreach (getSeverityCaption() as $i => $caption) {
$frm_row[] = array(new CCheckBox('severity[' . $i . ']', str_in_array($i, $severity), null, $i), $caption);
$frm_row[] = BR();
}
$frmMedia->addRow(_('Use if severity'), $frm_row);
$cmbStat = new CComboBox('active', $active);
$cmbStat->addItem(0, _('Enabled'));
示例11: get_request
$data['mappings'] = get_request('mappings', array());
}
$valueMapCount = DBfetch(DBselect('SELECT COUNT(i.itemid) AS cnt FROM items i WHERE i.valuemapid=' . zbx_dbstr($data['valuemapid'])));
$data['confirmMessage'] = $valueMapCount['cnt'] ? _n('Delete selected value mapping? It is used for %d item!', 'Delete selected value mapping? It is used for %d items!', $valueMapCount['cnt']) : _('Delete selected value mapping?');
}
if (empty($data['valuemapid']) && !empty($data['form_refresh'])) {
$data['mapname'] = get_request('mapname', '');
$data['mappings'] = get_request('mappings', array());
}
order_result($data['mappings'], 'value');
$valueMapForm = new CView('administration.general.valuemapping.edit', $data);
} else {
$data = array('valuemaps' => array(), 'displayNodes' => is_array(get_current_nodeid()));
$valueMapWidget->addHeader(_('Value mapping'));
$valueMapWidget->addItem(BR());
$dbValueMaps = DBselect('SELECT v.valuemapid,v.name' . ' FROM valuemaps v' . whereDbNode('v.valuemapid'));
while ($dbValueMap = DBfetch($dbValueMaps)) {
$dbValueMap['nodename'] = $data['displayNodes'] ? get_node_name_by_elid($dbValueMap['valuemapid'], true) : '';
$data['valuemaps'][$dbValueMap['valuemapid']] = $dbValueMap;
$data['valuemaps'][$dbValueMap['valuemapid']]['maps'] = array();
}
order_result($data['valuemaps'], 'name');
$dbMaps = DBselect('SELECT m.valuemapid,m.value,m.newvalue' . ' FROM mappings m' . whereDbNode('m.mappingid'));
while ($dbMap = DBfetch($dbMaps)) {
$data['valuemaps'][$dbMap['valuemapid']]['maps'][] = array('value' => $dbMap['value'], 'newvalue' => $dbMap['newvalue']);
}
$valueMapForm = new CView('administration.general.valuemapping.list', $data);
}
$valueMapWidget->addItem($valueMapForm->render());
$valueMapWidget->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例12: array
$screens = API::Screen()->get(array('nodeids' => $nodeId, 'output' => array('screenid', 'name'), 'editable' => $writeonly === null ? null : true));
order_result($screens, 'name');
foreach ($screens as $screen) {
if (check_screen_recursion($_REQUEST['screenid'], $screen['screenid'])) {
continue;
}
$name = new CLink($screen['name'], '#');
$action = get_window_opener($dstfrm, $dstfld1, $screen[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $screen[$srcfld2]) : '');
$name->setAttribute('onclick', $action . ' close_window(); return false;');
$table->addRow($name);
}
$table->show();
} elseif ($srctbl == 'drules') {
$table = new CTableInfo(_('No discovery rules found.'));
$table->setHeader(_('Name'));
$result = DBselect('SELECT d.*' . ' FROM drules d' . whereDbNode('d.druleid', $nodeId));
while ($row = DBfetch($result)) {
$action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
$name = new CSpan($row['name'], 'link');
$name->setAttribute('onclick', $action . ' close_window(); return false;');
$table->addRow($name);
}
$table->show();
} elseif ($srctbl == 'dchecks') {
$table = new CTableInfo(_('No discovery rules found.'));
$table->setHeader(_('Name'));
$dRules = API::DRule()->get(array('selectDChecks' => array('dcheckid', 'type', 'key_', 'ports'), 'output' => array('name'), 'nodeids' => $nodeId));
foreach ($dRules as $dRule) {
foreach ($dRule['dchecks'] as $dCheck) {
$name = $dRule['name'] . NAME_DELIMITER . discovery_check2str($dCheck['type'], $dCheck['key_'], $dCheck['ports']);
$action = get_window_opener($dstfrm, $dstfld1, $dCheck[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $name) : '');
示例13: get_accessible_groups_by_user
/**
* Returns the host groups that are accessible by the current user with the permission level given in $perm.
*
* Can return results in different formats, based on the $per_res parameter. Possible values are:
* - PERM_RES_IDS_ARRAY - return only host group ids;
* - PERM_RES_DATA_ARRAY - return an array of host groups.
*
* @param array $userData an array defined as array('userid' => userid, 'type' => type)
* @param int $perm requested permission level
* @param int|null $permRes result format
* @param int $nodeId
*
* @return array
*/
function get_accessible_groups_by_user($userData, $perm, $permRes = PERM_RES_IDS_ARRAY, $nodeId = null)
{
$userId =& $userData['userid'];
if (!isset($userId)) {
fatal_error(_('Incorrect user data in "get_accessible_groups_by_user".'));
}
if (is_null($nodeId)) {
$nodeId = get_current_nodeid();
}
$userType =& $userData['type'];
$result = array();
$processed = array();
if ($userType == USER_TYPE_SUPER_ADMIN) {
$sql = 'SELECT n.nodeid AS nodeid,n.name AS node_name,hg.groupid,hg.name' . ' FROM groups hg' . ' LEFT JOIN nodes n ON ' . DBid2nodeid('hg.groupid') . '=n.nodeid' . whereDbNode('hg.groupid', $nodeId) . ' GROUP BY n.nodeid,n.name,hg.groupid,hg.name';
} else {
$sql = 'SELECT n.nodeid AS nodeid,n.name AS node_name,hg.groupid,hg.name,MAX(r.permission) AS permission,MIN(r.permission) AS permission_deny,g.userid' . ' FROM groups hg' . ' LEFT JOIN rights r ON r.id=hg.groupid' . ' LEFT JOIN users_groups g ON r.groupid=g.usrgrpid' . ' LEFT JOIN nodes n ON ' . DBid2nodeid('hg.groupid') . '=n.nodeid' . ' WHERE g.userid=' . zbx_dbstr($userId) . andDbNode('hg.groupid', $nodeId) . ' GROUP BY n.nodeid,n.name,hg.groupid,hg.name,g.userid';
}
$dbGroups = DBselect($sql);
while ($groupData = DBfetch($dbGroups)) {
if (zbx_empty($groupData['nodeid'])) {
$groupData['nodeid'] = id2nodeid($groupData['groupid']);
}
// calculate permissions
if ($userType == USER_TYPE_SUPER_ADMIN) {
$groupData['permission'] = PERM_READ_WRITE;
} elseif (isset($processed[$groupData['groupid']])) {
if ($groupData['permission_deny'] == PERM_DENY) {
unset($result[$groupData['groupid']]);
} elseif ($processed[$groupData['groupid']] > $groupData['permission']) {
unset($processed[$groupData['groupid']]);
} else {
continue;
}
}
$processed[$groupData['groupid']] = $groupData['permission'];
if ($groupData['permission'] < $perm) {
continue;
}
switch ($permRes) {
case PERM_RES_DATA_ARRAY:
$result[$groupData['groupid']] = $groupData;
break;
default:
$result[$groupData['groupid']] = $groupData['groupid'];
break;
}
}
unset($processed, $groupData, $dbGroups);
if ($userType == USER_TYPE_SUPER_ADMIN) {
CArrayHelper::sort($result, array(array('field' => 'node_name', 'order' => ZBX_SORT_UP), array('field' => 'name', 'order' => ZBX_SORT_UP)));
} else {
CArrayHelper::sort($result, array(array('field' => 'node_name', 'order' => ZBX_SORT_UP), array('field' => 'name', 'order' => ZBX_SORT_UP), array('field' => 'permission', 'order' => ZBX_SORT_UP)));
}
return $result;
}
示例14: foreach
echo $dstfrm;
?>
'];
<!--
<?php
foreach ($new_groups as $id) {
echo 'add_var_to_opener_obj(form,"new_groups[' . $id . ']","' . $id . '")' . "\r";
}
?>
if(form){
form.submit();
close_window();
}
-->
</script>
<?php
}
$form = new CForm();
$form->addVar('dstfrm', $dstfrm);
$form->setName('groups');
$table = new CTableInfo(_('No user groups found.'));
$table->setHeader(array(new CCheckBox("all_groups", NULL, "checkAll('" . $form->getName() . "','all_groups','new_groups');"), _('Name')));
$userGroups = DBfetchArray(DBselect('SELECT ug.usrgrpid,ug.name FROM usrgrp ug ' . whereDbNode('ug.usrgrpid')));
order_result($userGroups, 'name');
foreach ($userGroups as $userGroup) {
$table->addRow(array(new CCheckBox('new_groups[' . $userGroup['usrgrpid'] . ']', isset($new_groups[$userGroup['usrgrpid']]), null, $userGroup['usrgrpid']), $userGroup['name']));
}
$table->setFooter(new CCol(new CSubmit('select', _('Select'))));
$form->addItem($table);
$form->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例15: get_status
function get_status()
{
global $ZBX_SERVER, $ZBX_SERVER_PORT;
$status = array('triggers_count' => 0, 'triggers_count_enabled' => 0, 'triggers_count_disabled' => 0, 'triggers_count_off' => 0, 'triggers_count_on' => 0, 'items_count' => 0, 'items_count_monitored' => 0, 'items_count_disabled' => 0, 'items_count_not_supported' => 0, 'hosts_count' => 0, 'hosts_count_monitored' => 0, 'hosts_count_not_monitored' => 0, 'hosts_count_template' => 0, 'users_online' => 0, 'qps_total' => 0);
// server
$zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, 0);
$status['zabbix_server'] = $zabbixServer->isRunning() ? _('Yes') : _('No');
// triggers
$dbTriggers = DBselect('SELECT COUNT(DISTINCT t.triggerid) AS cnt,t.status,t.value' . ' FROM triggers t' . ' INNER JOIN functions f ON t.triggerid=f.triggerid' . ' INNER JOIN items i ON f.itemid=i.itemid' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')' . ' GROUP BY t.status,t.value');
while ($dbTrigger = DBfetch($dbTriggers)) {
switch ($dbTrigger['status']) {
case TRIGGER_STATUS_ENABLED:
switch ($dbTrigger['value']) {
case TRIGGER_VALUE_FALSE:
$status['triggers_count_off'] = $dbTrigger['cnt'];
break;
case TRIGGER_VALUE_TRUE:
$status['triggers_count_on'] = $dbTrigger['cnt'];
break;
}
break;
case TRIGGER_STATUS_DISABLED:
$status['triggers_count_disabled'] += $dbTrigger['cnt'];
break;
}
}
$status['triggers_count_enabled'] = $status['triggers_count_off'] + $status['triggers_count_on'];
$status['triggers_count'] = $status['triggers_count_enabled'] + $status['triggers_count_disabled'];
// items
$dbItems = DBselect('SELECT COUNT(i.itemid) AS cnt,i.status,i.state' . ' FROM items i' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND i.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')' . ' AND i.type<>' . ITEM_TYPE_HTTPTEST . ' GROUP BY i.status,i.state');
while ($dbItem = DBfetch($dbItems)) {
if ($dbItem['status'] == ITEM_STATUS_ACTIVE) {
if ($dbItem['state'] == ITEM_STATE_NORMAL) {
$status['items_count_monitored'] = $dbItem['cnt'];
} else {
$status['items_count_not_supported'] = $dbItem['cnt'];
}
} elseif ($dbItem['status'] == ITEM_STATUS_DISABLED) {
$status['items_count_disabled'] += $dbItem['cnt'];
}
}
$status['items_count'] = $status['items_count_monitored'] + $status['items_count_disabled'] + $status['items_count_not_supported'];
// hosts
$dbHosts = DBselect('SELECT COUNT(*) AS cnt,h.status' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.status', array(HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED, HOST_STATUS_TEMPLATE)) . ' AND ' . dbConditionInt('h.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' GROUP BY h.status');
while ($dbHost = DBfetch($dbHosts)) {
switch ($dbHost['status']) {
case HOST_STATUS_MONITORED:
$status['hosts_count_monitored'] = $dbHost['cnt'];
break;
case HOST_STATUS_NOT_MONITORED:
$status['hosts_count_not_monitored'] = $dbHost['cnt'];
break;
case HOST_STATUS_TEMPLATE:
$status['hosts_count_template'] = $dbHost['cnt'];
break;
}
}
$status['hosts_count'] = $status['hosts_count_monitored'] + $status['hosts_count_not_monitored'] + $status['hosts_count_template'];
// users
$row = DBfetch(DBselect('SELECT COUNT(*) AS usr_cnt' . ' FROM users u' . whereDbNode('u.userid')));
$status['users_count'] = $row['usr_cnt'];
$status['users_online'] = 0;
$db_sessions = DBselect('SELECT s.userid,s.status,MAX(s.lastaccess) AS lastaccess' . ' FROM sessions s' . ' WHERE s.status=' . ZBX_SESSION_ACTIVE . andDbNode('s.userid') . ' GROUP BY s.userid,s.status');
while ($session = DBfetch($db_sessions)) {
if ($session['lastaccess'] + ZBX_USER_ONLINE_TIME >= time()) {
$status['users_online']++;
}
}
// comments: !!! Don't forget sync code with C !!!
$row = DBfetch(DBselect('SELECT SUM(1.0/i.delay) AS qps' . ' FROM items i,hosts h' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND i.hostid=h.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.delay<>0'));
$status['qps_total'] = round($row['qps'], 2);
return $status;
}