function implode_exp($expression, $triggerid) { global $ZBX_TR_EXPR_ALLOWED_MACROS, $ZBX_TR_EXPR_REPLACE_TO; $expr = $expression; $short_exp = $expression; /* Replace all {server:key.function(param)} and {MACRO} with '$ZBX_TR_EXPR_REPLACE_TO' */ /* build short expression {12}>10 */ while (ereg(ZBX_EREG_EXPRESSION_TOKEN_FORMAT, $expr, $arr)) { if ($arr[ZBX_EXPRESSION_MACRO_ID] && !isset($ZBX_TR_EXPR_ALLOWED_MACROS[$arr[ZBX_EXPRESSION_MACRO_ID]])) { error('[ie] Unknown macro [' . $arr[ZBX_EXPRESSION_MACRO_ID] . ']'); return false; } else { if (!$arr[ZBX_EXPRESSION_MACRO_ID]) { $s_expr =& $arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID]; $host =& $arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_HOST_ID]; $key =& $arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_KEY_ID]; $function =& $arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_FUNCTION_NAME_ID]; $parameter =& $arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_FUNCTION_PARAM_ID]; $item_res = DBselect('SELECT i.itemid ' . ' FROM items i,hosts h' . ' WHERE i.key_=' . zbx_dbstr($key) . ' AND h.host=' . zbx_dbstr($host) . ' AND h.hostid=i.hostid'); while (($item = DBfetch($item_res)) && !in_node($item['itemid'])) { } if (!$item) { return null; } $item = $item["itemid"]; $functionid = get_dbid("functions", "functionid"); if (!DBexecute('insert into functions (functionid,itemid,triggerid,function,parameter)' . ' values (' . $functionid . ',' . $item . ',' . $triggerid . ',' . zbx_dbstr($function) . ',' . zbx_dbstr($parameter) . ')')) { return null; } $short_exp = str_replace($s_expr, '{' . $functionid . '}', $short_exp); $expr = str_replace($s_expr, $ZBX_TR_EXPR_REPLACE_TO, $expr); continue; } } $expr = $arr[ZBX_EXPRESSION_LEFT_ID] . $ZBX_TR_EXPR_REPLACE_TO . $arr[ZBX_EXPRESSION_RIGHT_ID]; } return $short_exp; }
print '$("addrm_fav").title = "' . S_ADD_TO . ' ' . S_FAVORITES . '";' . "\n"; print '$("addrm_fav").onclick = function(){ add2favorites("graphid","' . $_REQUEST['favid'] . '");}' . "\n"; } } } if (PAGE_TYPE_JS == $page['type'] && $result) { print 'switchElementsClass("addrm_fav","iconminus","iconplus");'; } } } } if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) { exit; } $_REQUEST['graphid'] = get_request('graphid', get_profile('web.charts.graphid', 0, PROFILE_TYPE_ID)); if (!in_node($_REQUEST['graphid'])) { $_REQUEST['graphid'] = 0; } // $_REQUEST['stime'] = get_request('stime',get_profile('web.graph.stime', null, PROFILE_TYPE_STR, $_REQUEST['graphid'])); $_REQUEST['period'] = get_request('period', get_profile('web.graph.period', ZBX_PERIOD_DEFAULT, PROFILE_TYPE_INT, $_REQUEST['graphid'])); $effectiveperiod = navigation_bar_calc(); if ($_REQUEST['graphid'] > 0) { $sql_from = ''; $sql_where = ''; if (isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0) { $sql_where .= ' AND hg.groupid=' . $_REQUEST['groupid']; } if (isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { $sql_where .= ' AND hg.hostid=' . $_REQUEST['hostid']; } $sql = 'SELECT DISTINCT hg.groupid, hg.hostid ' . ' FROM hosts_groups hg, hosts h, graphs g, graphs_items gi, items i ' . ' WHERE g.graphid=' . $_REQUEST['graphid'] . ' AND gi.graphid=g.graphid ' . ' AND i.itemid=gi.itemid ' . ' AND hg.hostid=i.hostid ' . $sql_where . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')';