本文整理匯總了PHP中DBin_node函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBin_node函數的具體用法?PHP DBin_node怎麽用?PHP DBin_node使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBin_node函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: slideshow_accessible
function slideshow_accessible($slideshowid, $perm)
{
$result = false;
$sql = 'SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.slideshowid=' . zbx_dbstr($slideshowid) . ' AND ' . DBin_node('s.slideshowid', get_current_nodeid(null, $perm));
if (DBselect($sql)) {
$result = true;
$screenids = array();
$db_screens = DBselect('SELECT DISTINCT s.screenid' . ' FROM slides s' . ' WHERE s.slideshowid=' . zbx_dbstr($slideshowid));
while ($slide_data = DBfetch($db_screens)) {
$screenids[$slide_data['screenid']] = $slide_data['screenid'];
}
$options = array('screenids' => $screenids);
if ($perm == PERM_READ_WRITE) {
$options['editable'] = true;
}
$screens = API::Screen()->get($options);
$screens = zbx_toHash($screens, 'screenid');
foreach ($screenids as $screenid) {
if (!isset($screens[$screenid])) {
return false;
}
}
}
return $result;
}
示例2: updateRegexp
function updateRegexp(array $regexp, array $expressions)
{
try {
$regexpId = $regexp['regexpid'];
unset($regexp['regexpid']);
// check existence
if (!getRegexp($regexpId)) {
throw new Exception(_('Regular expression does not exist.'));
}
// check required fields
$dbFields = array('name' => null);
if (!check_db_fields($dbFields, $regexp)) {
throw new Exception(_('Incorrect arguments passed to function') . ' [updateRegexp]');
}
// check duplicate name
$dbRegexp = DBfetch(DBselect('SELECT re.regexpid ' . 'FROM regexps re ' . 'WHERE re.name=' . zbx_dbstr($regexp['name']) . ' AND ' . DBin_node('re.regexpid')));
if ($dbRegexp && bccomp($regexpId, $dbRegexp['regexpid']) != 0) {
throw new Exception(_s('Regular expression "%s" already exists.', $regexp['name']));
}
rewriteRegexpExpressions($regexpId, $expressions);
DB::update('regexps', array('values' => $regexp, 'where' => array('regexpid' => $regexpId)));
} catch (Exception $e) {
error($e->getMessage());
return false;
}
return true;
}
示例3: show_report2_header
function show_report2_header($config, &$PAGE_GROUPS, &$PAGE_HOSTS)
{
global $USER_DETAILS;
$available_groups = $PAGE_GROUPS['groupids'];
$available_hosts = $PAGE_HOSTS['hostids'];
// $available_groups = $PAGE_GROUPS['groupids'];
// $available_hosts = $PAGE_HOSTS['hostids'];
$r_form = new CForm();
$r_form->setMethod('get');
$cmbConf = new CComboBox('config', $config, 'submit()');
$cmbConf->addItem(0, S_BY_HOST);
$cmbConf->addItem(1, S_BY_TRIGGER_TEMPLATE);
$r_form->addItem(array(S_MODE . SPACE, $cmbConf, SPACE));
$cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
$cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
$cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name);
}
foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) {
$cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $name);
}
$r_form->addItem(array(S_GROUP . SPACE, $cmbGroups));
$r_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
if (1 == $config) {
$cmbTrigs = new CComboBox('tpl_triggerid', get_request('tpl_triggerid', 0), 'submit()');
$cmbHGrps = new CComboBox('hostgroupid', get_request('hostgroupid', 0), 'submit()');
$cmbTrigs->addItem(0, S_ALL_SMALL);
$cmbHGrps->addItem(0, S_ALL_SMALL);
}
if (0 == $config) {
show_table_header(S_AVAILABILITY_REPORT_BIG, $r_form);
} else {
$sql_cond = ' AND h.hostid=ht.hostid ';
if ($_REQUEST['hostid'] > 0) {
$sql_cond .= ' AND ht.templateid=' . $_REQUEST['hostid'];
}
if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) {
$sql_cond .= ' AND t.templateid=' . $_REQUEST['tpl_triggerid'];
}
$result = DBselect('SELECT DISTINCT g.groupid,g.name ' . ' FROM triggers t,hosts h,items i,functions f, hosts_templates ht, groups g, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond . ' ORDER BY g.name');
while ($row = DBfetch($result)) {
$cmbHGrps->addItem($row['groupid'], get_node_name_by_elid($row['groupid']) . $row['name']);
}
$sql_cond = $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] : ' AND ' . DBcondition('h.hostid', $available_hosts);
$sql = 'SELECT DISTINCT t.triggerid,t.description ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sql_cond . ' ORDER BY t.description';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$cmbTrigs->addItem($row['triggerid'], get_node_name_by_elid($row['triggerid']) . expand_trigger_description($row['triggerid']));
}
$rr_form = new CForm();
$rr_form->setMethod('get');
$rr_form->addVar('config', $config);
$rr_form->addVar('groupid', $_REQUEST['groupid']);
$rr_form->addVar('hostid', $_REQUEST['hostid']);
$rr_form->addItem(array(S_TRIGGER . SPACE, $cmbTrigs, BR(), S_FILTER, SPACE, S_HOST_GROUP . SPACE, $cmbHGrps));
show_table_header(S_AVAILABILITY_REPORT_BIG, array($r_form, $rr_form));
}
}
示例4: bodyToString
public function bodyToString()
{
global $USER_DETAILS;
$this->cleanItems();
$total = 0;
$accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
$cond_from = '';
if (remove_nodes_from_id($this->groupid) > 0) {
$cond_from = ', hosts_groups hg ';
$cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . $this->groupid;
} else {
$cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid);
}
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$avail = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$notav = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$uncn = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$node = get_node_by_nodeid($this->nodeid);
$header_str = S_HOSTS_INFO . SPACE;
$header_str .= S_FOR_GROUP_SMALL . SPACE . '"';
if ($node > 0) {
$header_str .= '(' . $node['name'] . ')' . SPACE;
}
if (remove_nodes_from_id($this->groupid) > 0) {
$group = get_hostgroup_by_groupid($this->groupid);
$header_str .= $group['name'] . '"';
} else {
$header_str .= S_ALL_S . '"';
}
$header = new CCol($header_str, "header");
if ($this->style == STYLE_HORISONTAL) {
$header->SetColspan(4);
}
$this->addRow($header);
$avail = new CCol($avail . ' ' . S_AVAILABLE, 'avail');
$notav = new CCol($notav . ' ' . S_NOT_AVAILABLE, 'notav');
$uncn = new CCol($uncn . ' ' . S_UNKNOWN, 'uncn');
$total = new CCol($total . ' ' . S_TOTAL, 'total');
if ($this->style == STYLE_HORISONTAL) {
$this->addRow(array($avail, $notav, $uncn, $total));
} else {
$this->addRow($avail);
$this->addRow($notav);
$this->addRow($uncn);
$this->addRow($total);
}
return parent::bodyToString();
}
示例5: bodyToString
public function bodyToString()
{
$this->cleanItems();
$total = 0;
// fetch accessible host ids
$hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => true));
$hostIds = array_keys($hosts);
$cond_from = '';
if (remove_nodes_from_id($this->groupid) > 0) {
$cond_from = ', hosts_groups hg ';
$cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
} else {
$cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid);
}
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$avail = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$notav = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$uncn = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$node = get_node_by_nodeid($this->nodeid);
$header_str = _('Hosts info') . SPACE;
if ($node > 0) {
$header_str .= '(' . $node['name'] . ')' . SPACE;
}
if (remove_nodes_from_id($this->groupid) > 0) {
$group = get_hostgroup_by_groupid($this->groupid);
$header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
} else {
$header_str .= _('All groups');
}
$header = new CCol($header_str, 'header');
if ($this->style == STYLE_HORISONTAL) {
$header->setColspan(4);
}
$this->addRow($header);
$avail = new CCol($avail . ' ' . _('Available'), 'avail');
$notav = new CCol($notav . ' ' . _('Not available'), 'notav');
$uncn = new CCol($uncn . ' ' . _('Unknown'), 'uncn');
$total = new CCol($total . ' ' . _('Total'), 'total');
if ($this->style == STYLE_HORISONTAL) {
$this->addRow(array($avail, $notav, $uncn, $total));
} else {
$this->addRow($avail);
$this->addRow($notav);
$this->addRow($uncn);
$this->addRow($total);
}
return parent::bodyToString();
}
示例6: get_userid_by_usrgrpid
function get_userid_by_usrgrpid($usrgrpids)
{
zbx_value2array($usrgrpids);
$userids = array();
$db_users = DBselect('SELECT DISTINCT u.userid' . ' FROM users u,users_groups ug' . ' WHERE u.userid=ug.userid' . ' AND ' . dbConditionInt('ug.usrgrpid', $usrgrpids) . ' AND ' . DBin_node('ug.usrgrpid', false));
while ($user = DBFetch($db_users)) {
$userids[$user['userid']] = $user['userid'];
}
return $userids;
}
示例7: get_default_image
function get_default_image($image = false, $imagetype = IMAGE_TYPE_ICON)
{
if ($image) {
$image = imagecreate(50, 50);
$color = imagecolorallocate($image, 250, 50, 50);
imagefill($image, 0, 0, $color);
} else {
$sql = 'SELECT i.imageid ' . ' FROM images i ' . ' WHERE ' . DBin_node('i.imageid', false) . ' AND imagetype=' . $imagetype . ' ORDER BY name ASC';
$result = DBselect($sql, 1);
if ($image = DBfetch($result)) {
return $image;
} else {
$image = array();
$image['imageid'] = 0;
}
}
return $image;
}
示例8: sysmap_accessible
function sysmap_accessible($sysmapid, $perm)
{
global $USER_DETAILS;
$nodes = get_current_nodeid(null, $perm);
$result = (bool) count($nodes);
$sql = 'SELECT * ' . ' FROM sysmaps_elements ' . ' WHERE sysmapid=' . $sysmapid . ' AND ' . DBin_node('sysmapid', $nodes);
$db_result = DBselect($sql);
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
//SDI($available_hosts);
while (($se_data = DBfetch($db_result)) && $result) {
switch ($se_data['elementtype']) {
case SYSMAP_ELEMENT_TYPE_HOST:
if (!isset($available_hosts[$se_data['elementid']])) {
$result = false;
}
break;
case SYSMAP_ELEMENT_TYPE_MAP:
$result = sysmap_accessible($se_data['elementid'], $perm);
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$available_triggers = get_accessible_triggers($perm, array(), PERM_RES_IDS_ARRAY);
if (!isset($available_triggers[$se_data['elementid']])) {
$result = false;
}
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$available_groups = get_accessible_groups_by_user($USER_DETAILS, $perm);
if (!isset($available_groups[$se_data['elementid']])) {
$result = false;
}
break;
}
}
//SDI($se_data['elementid']);
return $result;
}
示例9: get
//.........這裏部分代碼省略.........
}
if (!is_null($options['select_graphs'])) {
$options['select_graphs'] = API_OUTPUT_EXTEND;
}
if (!is_null($options['select_applications'])) {
$options['select_applications'] = API_OUTPUT_EXTEND;
}
if (!is_null($options['select_macros'])) {
$options['select_macros'] = API_OUTPUT_EXTEND;
}
}
if (is_array($options['output'])) {
unset($sql_parts['select']['hosts']);
$sql_parts['select']['hostid'] = ' h.hostid';
foreach ($options['output'] as $key => $field) {
$sql_parts['select'][$field] = ' h.' . $field;
}
$options['output'] = API_OUTPUT_CUSTOM;
}
// editable + PERMISSION CHECK
if (USER_TYPE_SUPER_ADMIN == $user_type || $options['nopermissions']) {
} else {
$permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ_ONLY;
$sql_parts['where'][] = 'EXISTS (' . ' SELECT hh.hostid ' . ' FROM hosts hh, hosts_groups hgg, rights r, users_groups ug ' . ' WHERE hh.hostid=h.hostid ' . ' AND hh.hostid=hgg.hostid ' . ' AND r.id=hgg.groupid ' . ' AND r.groupid=ug.usrgrpid ' . ' AND ug.userid=' . $userid . ' AND r.permission>=' . $permission . ' AND NOT EXISTS( ' . ' SELECT hggg.groupid ' . ' FROM hosts_groups hggg, rights rr, users_groups gg ' . ' WHERE hggg.hostid=hgg.hostid ' . ' AND rr.id=hggg.groupid ' . ' AND rr.groupid=gg.usrgrpid ' . ' AND gg.userid=' . $userid . ' AND rr.permission<' . $permission . ' )) ';
}
// nodeids
$nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
$sql_parts['where']['hostid'] = DBcondition('h.hostid', $options['hostids']);
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('h.hostid', $nodeids);
}
}
// groupids
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sql_parts['select']['groupid'] = 'hg.groupid';
}
$sql_parts['from']['hosts_groups'] = 'hosts_groups hg';
$sql_parts['where'][] = DBcondition('hg.groupid', $options['groupids']);
$sql_parts['where']['hgh'] = 'hg.hostid=h.hostid';
if (!is_null($options['groupCount'])) {
$sql_parts['group']['groupid'] = 'hg.groupid';
}
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('hg.groupid', $nodeids);
}
}
// proxyids
if (!is_null($options['proxyids'])) {
zbx_value2array($options['proxyids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sql_parts['select']['proxy_hostid'] = 'h.proxy_hostid';
}
$sql_parts['where'][] = DBcondition('h.proxy_hostid', $options['proxyids']);
}
// templateids
if (!is_null($options['templateids'])) {
zbx_value2array($options['templateids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sql_parts['select']['templateid'] = 'ht.templateid';
示例10: update_user_group
function update_user_group($usrgrpid, $name, $users_status, $gui_access, $api_access, $debug_mode, $users = array(), $rights = array())
{
global $USER_DETAILS;
$sql = 'SELECT * ' . ' FROM usrgrp ' . ' WHERE name=' . zbx_dbstr($name) . ' AND usrgrpid<>' . $usrgrpid . ' AND ' . DBin_node('usrgrpid', get_current_nodeid(false));
if (DBfetch(DBselect($sql))) {
error("Group '{$name}' already exists");
return 0;
}
$result = DBexecute('UPDATE usrgrp SET name=' . zbx_dbstr($name) . ' WHERE usrgrpid=' . $usrgrpid);
if (!$result) {
return $result;
}
// must come before adding user to group
$result &= change_group_status($usrgrpid, $users_status);
$result &= change_group_gui_access($usrgrpid, $gui_access);
$result &= change_group_api_access($usrgrpid, $api_access);
$result &= change_group_debug_mode($usrgrpid, $debug_mode);
if (!$result) {
return $result;
}
//-------
$grant = true;
if ($gui_access == GROUP_GUI_ACCESS_DISABLED || $users_status == GROUP_STATUS_DISABLED) {
$grant = !uint_in_array($USER_DETAILS['userid'], $users);
}
if ($grant) {
$result = DBexecute('DELETE FROM users_groups WHERE usrgrpid=' . $usrgrpid);
foreach ($users as $userid => $name) {
$result = add_user_to_group($userid, $usrgrpid);
if (!$result) {
return $result;
}
}
} else {
error(S_USER_CANNOT_DISABLE_ITSELF);
return false;
}
$result = DBexecute('DELETE FROM rights WHERE groupid=' . $usrgrpid);
foreach ($rights as $right) {
$id = get_dbid('rights', 'rightid');
$result = DBexecute('INSERT INTO rights (rightid,groupid,permission,id)' . ' VALUES (' . $id . ',' . $usrgrpid . ',' . $right['permission'] . ',' . $right['id'] . ')');
if (!$result) {
return $result;
}
}
return $result;
}
示例11: CForm
}
$form = new CForm();
$form->SetMethod('get');
$form->AddItem(new CButton("form", S_CREATE_MEDIA_TYPE));
$row_count = 0;
$numrows = new CSpan(null, 'info');
$numrows->addOption('name', 'numrows');
$header = get_table_header(array(S_CONFIGURATION_OF_MEDIA_TYPES_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
show_table_header($header, $form);
if (isset($_REQUEST["form"])) {
echo SBR;
insert_media_type_form();
} else {
$table = new CTableInfo(S_NO_MEDIA_TYPES_DEFINED);
$table->setHeader(array(make_sorting_link(S_TYPE, 'mt.type'), make_sorting_link(S_DESCRIPTION, 'mt.description'), S_DETAILS));
$result = DBselect('SELECT mt.* ' . ' FROM media_type mt' . ' WHERE ' . DBin_node('mt.mediatypeid') . order_by('mt.type,mt.description'));
while ($row = DBfetch($result)) {
switch ($row['type']) {
case MEDIA_TYPE_EMAIL:
$details = S_SMTP_SERVER . ": '" . $row['smtp_server'] . "', " . S_SMTP_HELO . ": '" . $row['smtp_helo'] . "', " . S_SMTP_EMAIL . ": '" . $row['smtp_email'] . "'";
break;
case MEDIA_TYPE_EXEC:
$details = S_SCRIPT_NAME . ": '" . $row['exec_path'] . "'";
break;
case MEDIA_TYPE_SMS:
$details = S_GSM_MODEM . ": '" . $row['gsm_modem'] . "'";
break;
case MEDIA_TYPE_JABBER:
$details = S_JABBER_IDENTIFIER . ": '" . $row['username'] . "'";
break;
default:
示例12: array
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array("msg" => array(T_ZBX_STR, O_OPT, null, null, NULL), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, IN("'hat'"), NULL), 'favid' => array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), 'state' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'));
check_fields($fields);
/* AJAX */
if (isset($_REQUEST['favobj'])) {
if ('hat' == $_REQUEST['favobj']) {
update_profile('web.services.hats.' . $_REQUEST['favid'] . '.state', $_REQUEST['state'], PROFILE_TYPE_INT);
}
}
if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) {
exit;
}
//--------
//--------------------------------------------------------------------------
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY);
$query = 'SELECT DISTINCT s.serviceid, sl.servicedownid, sl_p.serviceupid as serviceupid, s.triggerid, ' . ' s.name as caption, s.algorithm, t.description, t.expression, s.sortorder, sl.linkid, s.showsla, s.goodsla, s.status ' . ' FROM services s ' . ' LEFT JOIN triggers t ON s.triggerid = t.triggerid ' . ' LEFT JOIN services_links sl ON s.serviceid = sl.serviceupid and NOT(sl.soft=0) ' . ' LEFT JOIN services_links sl_p ON s.serviceid = sl_p.servicedownid and sl_p.soft=0 ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (t.triggerid IS NULL OR ' . DBcondition('t.triggerid', $available_triggers) . ') ' . ' ORDER BY s.sortorder, sl_p.serviceupid, s.serviceid';
$result = DBSelect($query);
$services = array();
$row = array('id' => 0, 'serviceid' => 0, 'serviceupid' => 0, 'caption' => S_ROOT_SMALL, 'status' => SPACE, 'algorithm' => SPACE, 'description' => SPACE, 'soft' => 0, 'linkid' => '');
$services[0] = $row;
while ($row = DBFetch($result)) {
$row['id'] = $row['serviceid'];
empty($row['serviceupid']) ? $row['serviceupid'] = '0' : '';
empty($row['triggerid']) ? $row['description'] = 'None' : ($row['description'] = expand_trigger_description($row['triggerid']));
if (isset($services[$row['serviceid']])) {
$services[$row['serviceid']] = array_merge($services[$row['serviceid']], $row);
} else {
$services[$row['serviceid']] = $row;
}
if (isset($row['serviceupid'])) {
$services[$row['serviceupid']]['childs'][] = array('id' => $row['serviceid'], 'soft' => 0, 'linkid' => 0);
示例13: update_config
function update_config($configs)
{
$update = array();
if (isset($configs['work_period']) && !is_null($configs['work_period'])) {
if (!validate_period($configs['work_period'])) {
error(S_ICORRECT_WORK_PERIOD);
return NULL;
}
}
if (isset($configs['alert_usrgrpid']) && !is_null($configs['alert_usrgrpid'])) {
if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('select usrgrpid from usrgrp where usrgrpid=' . $configs['alert_usrgrpid']))) {
error(S_INCORRECT_GROUP);
return NULL;
}
}
foreach ($configs as $key => $value) {
if (!is_null($value)) {
$update[] = $key . '=' . zbx_dbstr($value);
}
}
if (count($update) == 0) {
error(S_NOTHING_TO_DO);
return NULL;
}
return DBexecute('update config set ' . implode(',', $update) . ' where ' . DBin_node('configid', get_current_nodeid(false)));
}
示例14: time
$services[0] = $row;
$now = time();
while ($row = DBFetch($result)) {
$row['id'] = $row['serviceid'];
empty($row['serviceupid']) ? $row['serviceupid'] = '0' : '';
empty($row['description']) ? $row['description'] = 'None' : '';
$row['graph'] = new CLink(S_SHOW, "srv_status.php?serviceid=" . $row["serviceid"] . "&showgraph=1" . url_param('path'), "action");
if (isset($row["triggerid"]) && !empty($row["triggerid"])) {
$url = new CLink(expand_trigger_description($row['triggerid']), 'events.php?triggerid=' . $row['triggerid']);
$row['caption'] = array($row['caption'] . ' [', $url, ']');
}
if ($row["status"] == 0 || isset($service) && bccomp($service["serviceid"], $row["serviceid"]) == 0) {
$row['reason'] = '-';
} else {
$row['reason'] = '-';
$result2 = DBselect('SELECT s.triggerid,s.serviceid ' . ' FROM services s, triggers t ' . ' WHERE s.status>0 ' . ' AND s.triggerid is not NULL ' . ' AND t.triggerid=s.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND ' . DBin_node('s.serviceid') . ' ORDER BY s.status DESC, t.description');
while ($row2 = DBfetch($result2)) {
if (is_string($row['reason']) && $row['reason'] == '-') {
$row['reason'] = new CList(null, "itservices");
}
if (does_service_depend_on_the_service($row["serviceid"], $row2["serviceid"])) {
$row['reason']->AddItem(new CLink(expand_trigger_description($row2["triggerid"]), "events.php?triggerid=" . $row2["triggerid"]));
}
}
}
if ($row["showsla"] == 1) {
$row['sla'] = new CLink(new CImg("chart_sla.php?serviceid=" . $row["serviceid"]), "report3.php?serviceid=" . $row["serviceid"] . "&year=" . date("Y"));
$now = time(NULL);
$period_start = $now - 7 * 24 * 3600;
$period_end = $now;
$stat = calculate_service_availability($row["serviceid"], $period_start, $period_end);
示例15: get_table_header
$header = get_table_header(array(S_MAINTENANCE_PERIODS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
show_table_header($header, $form);
// ----
$available_maintenances = get_accessible_maintenance_by_user(PERM_READ_ONLY);
$sqls = array();
$config = select_config();
$maintenances = array();
$maintenanceids = array();
if ($_REQUEST['groupid'] > 0) {
$sqls[] = 'SELECT m.* ' . ' FROM maintenances m, maintenances_groups mg ' . ' WHERE ' . DBin_node('m.maintenanceid') . ' AND ' . DBcondition('m.maintenanceid', $available_maintenances) . ' AND mg.groupid=' . $_REQUEST['groupid'] . ' AND m.maintenanceid=mg.maintenanceid ';
' ORDER BY m.name';
$sqls[] = 'SELECT m.* ' . ' FROM maintenances m, maintenances_hosts mh, hosts_groups hg ' . ' WHERE ' . DBin_node('m.maintenanceid') . ' AND ' . DBcondition('m.maintenanceid', $available_maintenances) . ' AND hg.groupid=' . $_REQUEST['groupid'] . ' AND mh.hostid=hg.hostid ' . ' AND m.maintenanceid=mh.maintenanceid ';
' ORDER BY m.name';
} else {
if ($config['dropdown_first_entry'] == ZBX_DROPDOWN_FIRST_ALL) {
$sqls[] = 'SELECT m.* ' . ' FROM maintenances m ' . ' WHERE ' . DBin_node('m.maintenanceid') . ' AND ' . DBcondition('m.maintenanceid', $available_maintenances) . ' ORDER BY m.name';
}
}
foreach ($sqls as $num => $sql) {
$db_maintenances = DBselect($sql);
while ($maintenance = DBfetch($db_maintenances)) {
$maintenances[$maintenance['maintenanceid']] = $maintenance;
$maintenanceids[$maintenance['maintenanceid']] = $maintenance['maintenanceid'];
}
}
$form = new CForm(null, 'post');
$form->setName('maintenances');
$table = new CTableInfo();
$table->setHeader(array(new CCheckBox('all_maintenances', NULL, "checkAll('" . $form->GetName() . "','all_maintenances','maintenanceids');"), make_sorting_link(S_NAME, 'm.name'), S_TYPE, S_STATUS, S_DESCRIPTION));
foreach ($maintenances as $maintenanceid => $maintenance) {
if ($maintenance['active_till'] < time()) {