本文整理匯總了PHP中DBcondition函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBcondition函數的具體用法?PHP DBcondition怎麽用?PHP DBcondition使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBcondition函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: delete_script
function delete_script($scriptids)
{
zbx_value2array($scriptids);
$sql = 'DELETE FROM scripts WHERE ' . DBcondition('scriptid', $scriptids);
$result = DBexecute($sql);
return $result;
}
示例2: 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();
}
示例3: updateMessageSettings
function updateMessageSettings($messages)
{
global $USER_DETAILS;
if (!isset($messages['enabled'])) {
$messages['enabled'] = 0;
}
if (isset($messages['triggers.severities'])) {
$messages['triggers.severities'] = serialize($messages['triggers.severities']);
}
$sql = 'SELECT profileid, idx, source, value_str ' . ' FROM profiles ' . ' WHERE userid=' . $USER_DETAILS['userid'] . ' AND ' . DBcondition('idx', array('web.messages'), false, true);
$db_profiles = DBselect($sql);
while ($profile = DBfetch($db_profiles)) {
$profile['value'] = $profile['value_str'];
$dbMessages[$profile['source']] = $profile;
}
$inserts = array();
$updates = array();
foreach ($messages as $key => $value) {
$values = array('userid' => $USER_DETAILS['userid'], 'idx' => 'web.messages', 'source' => $key, 'value_str' => $value, 'type' => PROFILE_TYPE_STR);
if (!isset($dbMessages[$key])) {
$inserts[] = $values;
} else {
if ($dbMessages[$key]['value'] != $value) {
$updates[] = array('values' => $values, 'where' => array('profileid=' . $dbMessages[$key]['profileid']));
}
}
}
try {
DB::insert('profiles', $inserts);
DB::update('profiles', $updates);
} catch (APIException $e) {
$errors = $e->getErrors();
$error = reset($errors);
error($error);
}
return $messages;
}
示例4: get
/**
* Get history data
*
* {@source}
* @access public
* @static
* @since 1.8.3
* @version 1.3
*
* @param array $options
* @param array $options['itemids']
* @param boolean $options['editable']
* @param string $options['pattern']
* @param int $options['limit']
* @param string $options['order']
* @return array|int item data as array or false if error
*/
public static function get($options = array())
{
global $USER_DETAILS;
$nodeCheck = false;
$result = array();
$sort_columns = array('itemid', 'clock');
// allowed columns for sorting
$subselects_allowed_outputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
// allowed output options for [ select_* ] params
$sql_parts = array('select' => array('history' => 'h.itemid'), 'from' => array(), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
$def_options = array('history' => ITEM_VALUE_TYPE_UINT64, 'nodeids' => null, 'hostids' => null, 'itemids' => null, 'triggerids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'startSearch' => null, 'excludeSearch' => null, 'time_from' => null, 'time_till' => null, 'output' => API_OUTPUT_REFER, 'countOutput' => null, 'groupCount' => null, 'groupOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($def_options, $options);
switch ($options['history']) {
case ITEM_VALUE_TYPE_LOG:
$sql_parts['from']['history'] = 'history_log h';
$sort_columns[] = 'id';
break;
case ITEM_VALUE_TYPE_TEXT:
$sql_parts['from']['history'] = 'history_text h';
$sort_columns[] = 'id';
break;
case ITEM_VALUE_TYPE_STR:
$sql_parts['from']['history'] = 'history_str h';
break;
case ITEM_VALUE_TYPE_UINT64:
$sql_parts['from']['history'] = 'history_uint h';
break;
case ITEM_VALUE_TYPE_FLOAT:
default:
$sql_parts['from']['history'] = 'history h';
}
// editable + PERMISSION CHECK
if (USER_TYPE_SUPER_ADMIN == $USER_DETAILS['type'] || $options['nopermissions']) {
} else {
$itemOptions = array('editable' => $options['editable'], 'preservekeys' => 1);
if (!is_null($options['itemids'])) {
$itemOptions['itemids'] = $options['itemids'];
}
$items = CItem::get($itemOptions);
$options['itemids'] = array_keys($items);
}
// nodeids
$nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
// itemids
if (!is_null($options['itemids'])) {
zbx_value2array($options['itemids']);
$sql_parts['where']['itemid'] = DBcondition('h.itemid', $options['itemids']);
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
}
}
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sql_parts['select']['hostid'] = 'i.hostid';
}
$sql_parts['from']['items'] = 'items i';
$sql_parts['where']['i'] = DBcondition('i.hostid', $options['hostids']);
$sql_parts['where']['hi'] = 'h.itemid=i.itemid';
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('i.hostid', $nodeids);
}
}
// node check !!!!!
// should be last, after all ****IDS checks
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
}
// time_from
if (!is_null($options['time_from'])) {
$sql_parts['select']['clock'] = 'h.clock';
$sql_parts['where']['clock_from'] = 'h.clock>=' . $options['time_from'];
}
// time_till
if (!is_null($options['time_till'])) {
$sql_parts['select']['clock'] = 'h.clock';
$sql_parts['where']['clock_till'] = 'h.clock<=' . $options['time_till'];
}
// filter
//.........這裏部分代碼省略.........
示例5: array
**/
require_once 'include/config.inc.php';
require_once 'include/triggers.inc.php';
$page['file'] = 'chart4.php';
$page['title'] = "S_CHART";
$page['type'] = PAGE_TYPE_IMAGE;
include_once 'include/page_header.php';
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array('triggerid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, NULL));
check_fields($fields);
$sql = 'SELECT DISTINCT i.hostid ' . ' FROM functions f, items i ' . ' WHERE f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid';
if (!($host = DBfetch(DBselect($sql)))) {
fatal_error(S_NO_TRIGGER_DEFINED);
}
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($host['hostid']));
$sql = 'SELECT DISTINCT t.triggerid,t.description,t.expression, h.host,h.hostid ' . ' FROM hosts h, items i, functions f, triggers t' . ' WHERE h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.triggerid=' . $_REQUEST['triggerid'] . ' AND ' . DBcondition('t.triggerid', $available_triggers);
if (!($db_data = DBfetch(DBselect($sql)))) {
access_deny();
}
$start_time = time(NULL);
$sizeX = 900;
$sizeY = 300;
$shiftX = 12;
$shiftYup = 17;
$shiftYdown = 25 + 15 * 3;
$im = imagecreate($sizeX + $shiftX + 61, $sizeY + $shiftYup + $shiftYdown + 10);
$red = imagecolorallocate($im, 255, 0, 0);
$darkred = imagecolorallocate($im, 150, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$darkgreen = imagecolorallocate($im, 0, 150, 0);
$bluei = imagecolorallocate($im, 0, 0, 255);
示例6: 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);
示例7: getDeletableHostGroups
function getDeletableHostGroups($groupids = null)
{
zbx_value2array($groupids);
$dlt_groupids = array();
$hostids = getUnlinkableHosts($groupids);
$sql_where = '';
if (!is_null($groupids)) {
$sql_where .= ' AND ' . DBcondition('g.groupid', $groupids);
}
$sql = 'SELECT DISTINCT g.groupid ' . ' FROM groups g ' . ' WHERE g.internal=' . ZBX_NOT_INTERNAL_GROUP . $sql_where . ' AND NOT EXISTS (' . 'SELECT hg.groupid ' . ' FROM hosts_groups hg ' . ' WHERE g.groupid=hg.groupid ' . ' AND ' . DBcondition('hg.hostid', $hostids, true) . ')';
$res = DBselect($sql);
while ($group = DBfetch($res)) {
$dlt_groupids[$group['groupid']] = $group['groupid'];
}
return $dlt_groupids;
}
示例8: delete_expression
function delete_expression($expressionids)
{
zbx_value2array($expressionids);
$sql = 'DELETE FROM expressions WHERE ' . DBcondition('expressionid', $expressionids);
return DBexecute($sql);
}
示例9: get_triggers_overview
function get_triggers_overview($hostids, $view_style = null)
{
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids);
if (is_null($view_style)) {
$view_style = get_profile('web.overview.view.style', STYLE_TOP);
}
$table = new CTableInfo(S_NO_TRIGGERS_DEFINED);
$result = DBselect('SELECT DISTINCT t.triggerid,t.description,t.expression,t.value,t.priority,t.lastchange,h.hostid,h.host' . ' FROM hosts h,items i,triggers t, functions f ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY t.description');
unset($triggers);
unset($hosts);
$triggers = array();
while ($row = DBfetch($result)) {
if (trigger_dependent($row['triggerid'])) {
continue;
}
$row['host'] = get_node_name_by_elid($row['hostid']) . $row['host'];
$row['description'] = expand_trigger_description_constants($row['description'], $row);
$hosts[strtolower($row['host'])] = $row['host'];
// A little tricky check for attempt to overwrite active trigger (value=1) with
// inactive or active trigger with lower priority.
if (!isset($triggers[$row['description']][$row['host']]) || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE && $row['value'] == TRIGGER_VALUE_TRUE || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE || $row['value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $triggers[$row['description']][$row['host']]['priority'])) {
$triggers[$row['description']][$row['host']] = array('hostid' => $row['hostid'], 'triggerid' => $row['triggerid'], 'value' => $row['value'], 'lastchange' => $row['lastchange'], 'priority' => $row['priority']);
}
}
if (!isset($hosts)) {
return $table;
}
ksort($hosts);
if ($view_style == STYLE_TOP) {
$header = array(new CCol(S_TRIGGERS, 'center'));
foreach ($hosts as $hostname) {
$header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname)));
}
$table->setHeader($header, 'vertical_header');
foreach ($triggers as $descr => $trhosts) {
$table_row = array(nbsp($descr));
foreach ($hosts as $hostname) {
$table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
}
$table->AddRow($table_row);
}
} else {
$header = array(new CCol(S_HOSTS, 'center'));
foreach ($triggers as $descr => $trhosts) {
$descr = array(new CImg('vtext.php?text=' . $descr));
array_push($header, $descr);
}
$table->SetHeader($header, 'vertical_header');
foreach ($hosts as $hostname) {
$table_row = array(nbsp($hostname));
foreach ($triggers as $descr => $trhosts) {
$table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
}
$table->AddRow($table_row);
}
}
return $table;
}
示例10: delete_discovery_rule
function delete_discovery_rule($druleid)
{
$result = true;
$actionids = array();
// conditions
$sql = 'SELECT DISTINCT actionid ' . ' FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_DRULE . " AND value='{$druleid}'";
$db_actions = DBselect($sql);
while ($db_action = DBfetch($db_actions)) {
$actionids[] = $db_action['actionid'];
}
// disabling actions with deleted conditions
if (!empty($actionids)) {
DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids));
// delete action conditions
DBexecute('DELETE FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_DRULE . " AND value='{$druleid}'");
}
if ($result) {
$db_dhosts = DBselect('select dhostid from dhosts' . ' where druleid=' . $druleid . ' and ' . DBin_node('dhostid'));
while ($result && ($db_dhost = DBfetch($db_dhosts))) {
$result = DBexecute('delete from dservices where' . ' dhostid=' . $db_dhost['dhostid']);
}
}
if ($result) {
$result = DBexecute('delete from dhosts where druleid=' . $druleid);
}
if ($result) {
$result = DBexecute('delete from dchecks where druleid=' . $druleid);
}
if ($result) {
$result = DBexecute('delete from drules where druleid=' . $druleid);
}
return $result;
}
示例11: deleteItems
/**
* Delete graph items
*
* @static
* @param array $items
* @return boolean
*/
public static function deleteItems($item_list, $force = false)
{
$error = 'Unknown ZABBIX internal error';
$result = true;
$graphid = $item_list['graphid'];
$items = $item_list['items'];
if (!$force) {
// check if graph is templated graph, then items cannot be deleted
$graph = CGraph::getById(array('graphid' => $graphid));
if ($graph['templateid'] != 0) {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Cannot edit templated graph : ' . $graph['name']);
return false;
}
}
$chd_graphs = get_graphs_by_templateid($graphid);
while ($chd_graph = DBfetch($chd_graphs)) {
$item_list['graphid'] = $chd_graph['graphid'];
$result = self::deleteItems($item_list, true);
if (!$result) {
return false;
}
}
$sql = 'SELECT curr.itemid
FROM graphs_items gi, items curr, items src
WHERE gi.graphid=' . $graphid . ' AND gi.itemid=curr.itemid
AND curr.key_=src.key_
AND ' . DBcondition('src.itemid', $items);
$db_items = DBselect($sql);
$gitems = array();
while ($curr_item = DBfetch($db_items)) {
$gitems[$curr_item['itemid']] = $curr_item['itemid'];
}
$sql = 'DELETE
FROM graphs_items
WHERE graphid=' . $graphid . ' AND ' . DBcondition('itemid', $gitems);
$result = DBselect($sql);
return $result;
}
示例12: delete
/**
* Delete alerts
*
* @param array $alertids
* @return boolean
*/
public static function delete($alertids)
{
$alerts = zbx_toArray($alerts);
$alertids = array();
$result = false;
//------
$options = array('alertids' => zbx_objectValues($alerts, 'alertid'), 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1);
$del_alerts = self::get($options);
foreach ($alerts as $snum => $alert) {
if (!isset($del_alerts[$alert['alertid']])) {
self::setError(__METHOD__, ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION);
return false;
}
$alertids[] = $alert['alertid'];
}
if (!empty($alertids)) {
$sql = 'DELETE FROM alerts WHERE ' . DBcondition('alertid', $alertids);
$result = DBexecute($sql);
} else {
self::setError(__METHOD__, ZBX_API_ERROR_PARAMETERS, S_EMPTY_INPUT_PARAMETER . ' [ alertids ]');
$result = false;
}
if ($result) {
return array('alertids' => $alertids);
} else {
self::setError(__METHOD__);
return false;
}
}
示例13: ltrim
$_REQUEST['paramtype'] = PARAM_TYPE_COUNTS;
$_REQUEST['param'] = ltrim($_REQUEST['param'], '#');
}
$operator = $expr_res[count($expr_res) - 2];
$_REQUEST['expr_type'] = $expr_res[ZBX_SIMPLE_EXPRESSION_FUNCTION_NAME_ID] . '[' . $operator . ']';
$_REQUEST['value'] = $expr_res[count($expr_res) - 1];
}
}
unset($expr_res);
$dstfrm = get_request("dstfrm", 0);
// destination form
$dstfld1 = get_request("dstfld1", '');
// destination field
$itemid = get_request("itemid", 0);
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
if ($item_data = DBfetch(DBselect('SELECT DISTINCT h.host,i.* ' . ' FROM hosts h,items i ' . ' WHERE h.hostid=i.hostid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND i.itemid=' . $itemid))) {
$description = $item_data['host'] . ':' . item_description($item_data);
} else {
$itemid = 0;
$description = '';
}
$expr_type = get_request("expr_type", 'last[=]');
if (eregi('^([a-z]{1,})\\[([' . implode('', array_keys($operators)) . '])\\]$', $expr_type, $expr_res)) {
$function = $expr_res[1];
$operator = $expr_res[2];
if (!str_in_array($function, array_keys($functions))) {
unset($function);
}
}
unset($expr_res);
if (!isset($function)) {
示例14: CTextBox
$access = $script['host_access'];
}
}
$frmScr->addRow(S_NAME, new CTextBox('name', $name, 80));
$frmScr->addRow(S_COMMAND, new CTextBox('command', $command, 80));
$usr_groups = new CCombobox('usrgrpid', $usrgrpid);
$usr_groups->addItem(0, S_ALL_S);
$sql = 'SELECT DISTINCT ug.name, ug.usrgrpid ' . ' FROM usrgrp ug ' . ' WHERE ' . DBin_node('ug.usrgrpid') . ' ORDER BY ug.name';
$usrgrp_result = DBselect($sql);
while ($usr_group = DBfetch($usrgrp_result)) {
$usr_groups->addItem($usr_group['usrgrpid'], $usr_group['name']);
}
$frmScr->addRow(S_USER_GROUPS, $usr_groups);
$host_groups = new CCombobox('groupid', $groupid);
$host_groups->addItem(0, S_ALL_S);
$sql = 'SELECT DISTINCT g.name, g.groupid ' . ' FROM groups g ' . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' ORDER BY g.name';
$grp_result = DBselect($sql);
while ($group = DBfetch($grp_result)) {
$host_groups->addItem($group['groupid'], $group['name']);
}
$frmScr->addRow(S_HOST_GROUPS, $host_groups);
$select_acc = new CCombobox('access', $access);
$select_acc->addItem(PERM_READ_ONLY, S_READ);
$select_acc->addItem(PERM_READ_WRITE, S_WRITE);
$frmScr->addRow(S_REQUIRED_HOST . SPACE . S_PERMISSIONS_SMALL, $select_acc);
$frmScr->addItemToBottomRow(new CButton('save', S_SAVE, "javascript: document.getElementById('scripts').action+='?action=1'; "));
$frmScr->addItemToBottomRow(SPACE);
if (isset($_REQUEST['scriptid'])) {
$deleteButton = new CButtonDelete(S_DELETE_SCRIPTS_Q, '&action=1&scriptid=' . $_REQUEST['scriptid']);
$frmScr->addItemToBottomRow($deleteButton);
$frmScr->addItemToBottomRow(SPACE);
示例15: get_report2_filter
function get_report2_filter($config, &$PAGE_GROUPS, &$PAGE_HOSTS)
{
global $USER_DETAILS;
$available_groups = $PAGE_GROUPS['groupids'];
$available_hosts = $PAGE_HOSTS['hostids'];
/************************* FILTER *************************/
/***********************************************************/
$filterForm = new CFormTable();
//,'events.php?filter_set=1','POST',null,'sform');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->addVar('config', $config);
$filterForm->addVar('filter_timesince', date('YmdHis', $_REQUEST['filter_timesince']));
$filterForm->addVar('filter_timetill', date('YmdHis', $_REQUEST['filter_timetill']));
$cmbGroups = new CComboBox('filter_groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
$cmbHosts = new CComboBox('filter_hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
$cmbGroups->addItem($groupid, get_node_name_by_elid($groupid, null, ': ') . $name);
}
foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) {
$cmbHosts->addItem($hostid, get_node_name_by_elid($hostid, null, ': ') . $name);
}
$filterForm->addRow(S_GROUP, $cmbGroups);
$filterForm->addRow(S_HOST, $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);
$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'], null, ': ') . $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'], null, ': ') . expand_trigger_description($row['triggerid']));
}
$filterForm->addRow(S_TRIGGER, $cmbTrigs);
$filterForm->addRow(S_FILTER . SPACE . S_HOST_GROUP, $cmbHGrps);
}
//*
$clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
$clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
$filtertimetab = new CTable(null, 'calendar');
$filtertimetab->setAttribute('width', '10%');
$filtertimetab->setCellPadding(0);
$filtertimetab->setCellSpacing(0);
$filtertimetab->addRow(array(S_FROM, new CNumericBox('filter_since_day', $_REQUEST['filter_timesince'] > 0 ? date('d', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_month', $_REQUEST['filter_timesince'] > 0 ? date('m', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_year', $_REQUEST['filter_timesince'] > 0 ? date('Y', $_REQUEST['filter_timesince']) : '', 4), SPACE, new CNumericBox('filter_since_hour', $_REQUEST['filter_timesince'] > 0 ? date('H', $_REQUEST['filter_timesince']) : '', 2), ':', new CNumericBox('filter_since_minute', $_REQUEST['filter_timesince'] > 0 ? date('i', $_REQUEST['filter_timesince']) : '', 2), $clndr_icon));
zbx_add_post_js('create_calendar(null,' . '["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],' . '"avail_report_since",' . '"filter_timesince");');
$clndr_icon->AddAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
$filtertimetab->AddRow(array(S_TILL, new CNumericBox('filter_till_day', $_REQUEST['filter_timetill'] > 0 ? date('d', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_month', $_REQUEST['filter_timetill'] > 0 ? date('m', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_year', $_REQUEST['filter_timetill'] > 0 ? date('Y', $_REQUEST['filter_timetill']) : '', 4), SPACE, new CNumericBox('filter_till_hour', $_REQUEST['filter_timetill'] > 0 ? date('H', $_REQUEST['filter_timetill']) : '', 2), ':', new CNumericBox('filter_till_minute', $_REQUEST['filter_timetill'] > 0 ? date('i', $_REQUEST['filter_timetill']) : '', 2), $clndr_icon));
zbx_add_post_js('create_calendar(null,' . '["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],' . '"avail_report_till",' . '"filter_timetill");');
zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),"click",CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
$filterForm->addRow(S_PERIOD, $filtertimetab);
//*/
$filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER));
$reset = new CButton("filter_rst", S_RESET);
$reset->setType('button');
$reset->setAction('javascript: var url = new Curl(location.href); url.setArgument("filter_rst",1); location.href = url.getUrl();');
$filterForm->addItemToBottomRow($reset);
return $filterForm;
}