本文整理汇总了PHP中zbx_empty函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_empty函数的具体用法?PHP zbx_empty怎么用?PHP zbx_empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_empty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: call
public static function call($method, $params, $sessionid = null)
{
// List of methods without params
$notifications = array('apiinfo.version' => 1, 'user.logout' => 1);
if (is_null($params) && !isset($notifications[$method])) {
return array('error' => ZBX_API_ERROR_PARAMETERS, 'data' => _('Empty parameters'));
}
// list of methods which does not require authentication
$withoutAuth = array('user.login' => 1, 'user.checkAuthentication' => 1, 'apiinfo.version' => 1);
// Authentication
if (!isset($withoutAuth[$method]) || !zbx_empty($sessionid)) {
// compatibility mode
if ($method == 'user.authenticate') {
$method = 'user.login';
}
if (!zbx_empty($sessionid)) {
$usr = self::callAPI('user.checkAuthentication', $sessionid);
if (!isset($usr['result'])) {
return array('error' => ZBX_API_ERROR_NO_AUTH, 'data' => _('Not authorized'));
}
} elseif (!isset($withoutAuth[$method])) {
return array('error' => ZBX_API_ERROR_NO_AUTH, 'data' => _('Not authorized'));
}
}
return self::callAPI($method, $params);
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:26,代码来源:class.czbxrpc.php
示例2: connect
public function connect()
{
// connection already established
if ($this->ds) {
return true;
}
$this->bound = 0;
if (!($this->ds = ldap_connect($this->cnf['host'], $this->cnf['port']))) {
error('LDAP: couldn\'t connect to LDAP server.');
return false;
}
// set protocol version and dependend options
if ($this->cnf['version']) {
if (!ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, $this->cnf['version'])) {
error('Setting LDAP Protocol version ' . $this->cnf['version'] . ' failed.');
} else {
// use TLS (needs version 3)
if (isset($this->cnf['starttls']) && !ldap_start_tls($this->ds)) {
error('Starting TLS failed.');
}
// needs version 3
if (!zbx_empty($this->cnf['referrals']) && !ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $this->cnf['referrals'])) {
error('Setting LDAP referrals to off failed.');
}
}
}
// set deref mode
if (isset($this->cnf['deref']) && !ldap_set_option($this->ds, LDAP_OPT_DEREF, $this->cnf['deref'])) {
error('Setting LDAP Deref mode ' . $this->cnf['deref'] . ' failed.');
}
return true;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:32,代码来源:CLdap.php
示例3: validate
/**
* Validates the given string and checks if it contains LLD macros.
*/
public function validate($value)
{
if (!parent::validate($value)) {
return false;
}
// check if a string contains an LLD macro
if (!zbx_empty($value) && !preg_match('/(\\{#' . ZBX_PREG_MACRO_NAME_LLD . '\\})+/', $value)) {
$this->error($this->messageMacro);
return false;
}
return true;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:15,代码来源:CLldMacroStringValidator.php
示例4: __construct
/**
* Creates a UL list.
*
* @param mixed $value a single or an array of values to add to the list
* @param string $class HTML class
* @param string $emptyString text to display if the list is empty
*/
public function __construct($value = null, $class = null, $emptyString = null)
{
parent::__construct('ul', 'yes');
$this->tag_end = '';
$this->addItem($value);
$this->addClass($class);
if (is_null($value)) {
$emptyString = !zbx_empty($emptyString) ? $emptyString : _('List is empty');
$this->addItem($emptyString, 'empty');
$this->emptyList = true;
}
}
开发者ID:davidmr001,项目名称:zatree-2.2,代码行数:19,代码来源:class.clist.php
示例5: isValid
/**
* Checks if expression is valid.
*
* @static
*
* @param $regExp
*
* @throws Exception
* @return bool
*/
public static function isValid($regExp)
{
if (zbx_empty($regExp)) {
throw new Exception('Empty expression', self::ERROR_REGEXP_EMPTY);
}
if ($regExp[0] == '@') {
$regExp = substr($regExp, 1);
$sql = 'SELECT r.regexpid' . ' FROM regexps r' . ' WHERE r.name=' . zbx_dbstr($regExp);
if (!DBfetch(DBselect($sql))) {
throw new Exception(_('Global expression does not exist.'), self::ERROR_REGEXP_NOT_EXISTS);
}
}
return true;
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:24,代码来源:CGlobalRegexp.php
示例6: fromArray
/**
* Recursive function for processing nested arrays.
*
* @param array $array
* @param null $parentName name of parent node
*/
protected function fromArray(array $array, $parentName = null)
{
foreach ($array as $name => $value) {
if ($newName = $this->mapName($parentName)) {
$this->xmlWriter->startElement($newName);
} else {
$this->xmlWriter->startElement($name);
}
if (is_array($value)) {
$this->fromArray($value, $name);
} elseif (!zbx_empty($value)) {
$this->xmlWriter->text($value);
}
$this->xmlWriter->endElement();
}
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:22,代码来源:CXmlExportWriter.php
示例7: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$resourceid = !empty($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid'];
$containerid = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$graphDims = getGraphDims();
$graphDims['graphHeight'] = $this->screenitem['height'];
$graphDims['width'] = $this->screenitem['width'];
// get time control
$timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerid, 'objDims' => $graphDims, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
// host feature
if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
$newitemid = get_same_item_for_host($resourceid, $this->hostid);
$resourceid = !empty($newitemid) ? $newitemid : '';
}
if ($this->mode == SCREEN_MODE_PREVIEW && !empty($resourceid)) {
$this->action = 'history.php?action=showgraph&itemid=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams();
}
if (!zbx_empty($resourceid) && $this->mode != SCREEN_MODE_EDIT) {
if ($this->mode == SCREEN_MODE_PREVIEW) {
$timeControlData['loadSBox'] = 1;
}
}
$timeControlData['src'] = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'];
$timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
$timeControlData['src'] .= $this->getProfileUrlParams();
// output
if ($this->mode == SCREEN_MODE_JS) {
return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ')';
} else {
if ($this->mode == SCREEN_MODE_SLIDESHOW) {
insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');
} else {
zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');
}
if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW) {
$item = new CDiv();
} elseif ($this->mode == SCREEN_MODE_PREVIEW) {
$item = new CLink(null, 'history.php?action=showgraph&itemid=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
}
$item->setAttribute('id', $containerid);
return $this->getOutput($item);
}
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:49,代码来源:CScreenSimpleGraph.php
示例8: doAction
protected function doAction()
{
$filter = ['groupids' => null, 'maintenance' => null, 'severity' => null, 'trigger_name' => '', 'extAck' => 0];
if (CProfile::get('web.dashconf.filter.enable', 0) == 1) {
// groups
if (CProfile::get('web.dashconf.groups.grpswitch', 0) == 0) {
// null mean all groups
$filter['groupids'] = null;
} else {
$filter['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
$hideHostGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
if ($hideHostGroupIds) {
// get all groups if no selected groups defined
if (!$filter['groupids']) {
$dbHostGroups = API::HostGroup()->get(['output' => ['groupid']]);
$filter['groupids'] = zbx_objectValues($dbHostGroups, 'groupid');
}
$filter['groupids'] = array_diff($filter['groupids'], $hideHostGroupIds);
// get available hosts
$dbAvailableHosts = API::Host()->get(['groupids' => $filter['groupids'], 'output' => ['hostid']]);
$availableHostIds = zbx_objectValues($dbAvailableHosts, 'hostid');
$dbDisabledHosts = API::Host()->get(['groupids' => $hideHostGroupIds, 'output' => ['hostid']]);
$disabledHostIds = zbx_objectValues($dbDisabledHosts, 'hostid');
$filter['hostids'] = array_diff($availableHostIds, $disabledHostIds);
} else {
if (!$filter['groupids']) {
// null mean all groups
$filter['groupids'] = null;
}
}
}
// hosts
$maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
$filter['maintenance'] = $maintenance == 0 ? 0 : null;
// triggers
$severity = CProfile::get('web.dashconf.triggers.severity', null);
$filter['severity'] = zbx_empty($severity) ? null : explode(';', $severity);
$filter['severity'] = zbx_toHash($filter['severity']);
$filter['trigger_name'] = CProfile::get('web.dashconf.triggers.name', '');
$config = select_config();
$filter['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0;
}
$this->setResponse(new CControllerResponseData(['filter' => $filter, 'user' => ['debug_mode' => $this->getDebugMode()]]));
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:44,代码来源:CControllerWidgetSystemView.php
示例9: validate
/**
* Checks if the given string is:
* - empty
* - not too long
* - matches a certain regex
*
* @param string $value
*
* @return bool
*/
public function validate($value)
{
if (zbx_empty($value)) {
if ($this->empty) {
return true;
} else {
$this->error($this->messageEmpty);
return false;
}
}
if ($this->maxLength && zbx_strlen($value) > $this->maxLength) {
$this->error($this->messageMaxLength, $this->maxLength);
return false;
}
if ($this->regex && !zbx_empty($value) && !preg_match($this->regex, $value)) {
$this->error($this->messageRegex, $value);
return false;
}
return true;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:30,代码来源:CStringValidator.php
示例10: validateSinglePeriod
/**
* Validate single time period.
* Time period is a string with format:
* 'day1-day2,time1-time2;' (day2 and ';' are optional)
* Examples:
* 5-7,00:00-09:00
* 5,0:00-9:00
*
* @param string $period
*
* @return bool
*/
protected function validateSinglePeriod($period)
{
$daysRegExp = '(?P<day1>[1-7])(-(?P<day2>[1-7]))?';
$time1RegExp = '(?P<hour1>20|21|22|23|24|[0-1]\\d|\\d):(?P<min1>[0-5]\\d)';
$time2RegExp = '(?P<hour2>20|21|22|23|24|[0-1]\\d|\\d):(?P<min2>[0-5]\\d)';
if (!preg_match('#^' . $daysRegExp . ',' . $time1RegExp . '-' . $time2RegExp . '$#', $period, $matches)) {
$this->setError(_s('Incorrect time period "%1$s".', $period));
return false;
}
if ($matches['hour2'] == '24' && $matches['min2'] != 0) {
$this->setError(_s('Incorrect time period "%1$s".', $period));
return false;
}
if (!zbx_empty($matches['day2']) && $matches['day1'] > $matches['day2']) {
$this->setError(_s('Incorrect time period "%1$s" start day must be less or equal to end day.', $period));
return false;
}
if ($matches['hour1'] > $matches['hour2'] || $matches['hour1'] == $matches['hour2'] && $matches['min1'] >= $matches['min2']) {
$this->setError(_s('Incorrect time period "%1$s" start time must be less than end time.', $period));
return false;
}
return true;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:35,代码来源:CTimePeriodValidator.php
示例11: arrayToDOM
public static function arrayToDOM(&$dom, $array, $parentKey = null)
{
if (!is_null($parentKey)) {
$parentNode = $dom->appendChild(new DOMElement($parentKey));
} else {
$parentNode = $dom;
}
foreach ($array as $key => $value) {
if (is_numeric($key)) {
$key = rtrim($parentKey, 's');
}
if (is_array($value)) {
$child = self::arrayToDOM($dom, $value, $key);
$parentNode->appendChild($child);
//SDI($dom->saveXML($parentNode));
} else {
if (!zbx_empty($value)) {
$n = $parentNode->appendChild(new DOMElement($key));
$n->appendChild(new DOMText($value));
}
}
}
return $parentNode;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:24,代码来源:export.inc.php
示例12: shedule2str
function shedule2str($timeperiod)
{
$timeperiod['hour'] = floor($timeperiod['start_time'] / SEC_PER_HOUR);
$timeperiod['minute'] = floor(($timeperiod['start_time'] - $timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
if ($timeperiod['hour'] < 10) {
$timeperiod['hour'] = '0' . $timeperiod['hour'];
}
if ($timeperiod['minute'] < 10) {
$timeperiod['minute'] = '0' . $timeperiod['minute'];
}
if ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_ONETIME) {
$str = zbx_date2str(DATE_TIME_FORMAT, $timeperiod['start_date']);
} elseif ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
$str = _n('At %1$s:%2$s on every day', 'At %1$s:%2$s on every %3$s days', $timeperiod['hour'], $timeperiod['minute'], $timeperiod['every']);
} elseif ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
$days = '';
$dayofweek = zbx_num2bitstr($timeperiod['dayofweek'], true);
$length = strlen($dayofweek);
for ($i = 0; $i < $length; $i++) {
if ($dayofweek[$i] == 1) {
if (!zbx_empty($days)) {
$days .= ', ';
}
$days .= getDayOfWeekCaption($i + 1);
}
}
$str = _n('At %1$s:%2$s on every %3$s of every week', 'At %1$s:%2$s on every %3$s of every %4$s weeks', $timeperiod['hour'], $timeperiod['minute'], $days, $timeperiod['every']);
} elseif ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
$months = '';
$month = zbx_num2bitstr($timeperiod['month'], true);
$length = strlen($month);
for ($i = 0; $i < $length; $i++) {
if ($month[$i] == 1) {
if (!zbx_empty($months)) {
$months .= ', ';
}
$months .= getMonthCaption($i + 1);
}
}
if ($timeperiod['dayofweek'] > 0) {
$days = '';
$dayofweek = zbx_num2bitstr($timeperiod['dayofweek'], true);
$length = strlen($dayofweek);
for ($i = 0; $i < $length; $i++) {
if ($dayofweek[$i] == 1) {
if (!zbx_empty($days)) {
$days .= ', ';
}
$days .= getDayOfWeekCaption($i + 1);
}
}
$every = '';
switch ($timeperiod['every']) {
case 1:
$every = _('First');
break;
case 2:
$every = _('Second');
break;
case 3:
$every = _('Third');
break;
case 4:
$every = _('Fourth');
break;
case 5:
$every = _('Last');
break;
}
$str = _s('At %1$s:%2$s on %3$s %4$s of every %5$s', $timeperiod['hour'], $timeperiod['minute'], $every, $days, $months);
} else {
$str = _s('At %1$s:%2$s on day %3$s of every %4$s', $timeperiod['hour'], $timeperiod['minute'], $timeperiod['day'], $months);
}
}
return $str;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:76,代码来源:maintenances.inc.php
示例13: get
//.........这里部分代码省略.........
if (is_array($options['filter'])) {
zbx_db_filter($sql_parts['from']['history'], $options, $sql_parts);
}
// search
if (is_array($options['search'])) {
zbx_db_search($sql_parts['from']['history'], $options, $sql_parts);
}
// output
if ($options['output'] == API_OUTPUT_EXTEND) {
unset($sql_parts['select']['clock']);
$sql_parts['select']['history'] = 'h.*';
}
// countOutput
if (!is_null($options['countOutput'])) {
$options['sortfield'] = '';
$sql_parts['select'] = array('count(DISTINCT h.hostid) as rowscount');
//groupCount
if (!is_null($options['groupCount'])) {
foreach ($sql_parts['group'] as $key => $fields) {
$sql_parts['select'][$key] = $fields;
}
}
}
// groupOutput
$groupOutput = false;
if (!is_null($options['groupOutput'])) {
if (str_in_array('h.' . $options['groupOutput'], $sql_parts['select']) || str_in_array('h.*', $sql_parts['select'])) {
$groupOutput = true;
}
}
// order
// restrict not allowed columns for sorting
$options['sortfield'] = str_in_array($options['sortfield'], $sort_columns) ? $options['sortfield'] : '';
if (!zbx_empty($options['sortfield'])) {
$sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
if ($options['sortfield'] == 'clock') {
$sql_parts['order']['itemid'] = 'h.itemid ' . $sortorder;
}
$sql_parts['order'][$options['sortfield']] = 'h.' . $options['sortfield'] . ' ' . $sortorder;
if (!str_in_array('h.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('h.*', $sql_parts['select'])) {
$sql_parts['select'][$options['sortfield']] = 'h.' . $options['sortfield'];
}
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sql_parts['limit'] = $options['limit'];
}
//---------------
$itemids = array();
$triggerids = array();
$sql_parts['select'] = array_unique($sql_parts['select']);
$sql_parts['from'] = array_unique($sql_parts['from']);
$sql_parts['where'] = array_unique($sql_parts['where']);
$sql_parts['order'] = array_unique($sql_parts['order']);
$sql_select = '';
$sql_from = '';
$sql_where = '';
$sql_order = '';
if (!empty($sql_parts['select'])) {
$sql_select .= implode(',', $sql_parts['select']);
}
if (!empty($sql_parts['from'])) {
$sql_from .= implode(',', $sql_parts['from']);
}
if (!empty($sql_parts['where'])) {
$sql_where .= implode(' AND ', $sql_parts['where']);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.chistory.php
示例14: make_latest_data
function make_latest_data()
{
global $USER_DETAILS;
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
while ($db_app = DBfetch($db_applications)) {
$db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock'));
$app_rows = array();
$item_cnt = 0;
while ($db_item = DBfetch($db_items)) {
$description = item_description($db_item);
if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
continue;
}
++$item_cnt;
if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
continue;
}
if (isset($db_item['lastclock'])) {
$lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
} else {
$lastclock = new CCol('-', 'center');
}
$lastvalue = format_lastvalue($db_item);
if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
$change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
} else {
$change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
}
$change = nbsp($change);
} else {
$change = new CCol('-', 'center');
}
if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
$actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
} else {
$actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
}
array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions)));
}
if ($item_cnt > 0) {
if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
$link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
} else {
$link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
}
$col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')'));
$col->setColSpan(5);
$table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
$any_app_exist = true;
foreach ($app_rows as $row) {
$table->ShowRow($row);
}
}
}
}
开发者ID:phedders,项目名称:zabbix,代码行数:56,代码来源:blocks.inc.php
示例15: zbx_toHash
$groupids = zbx_toHash($groupids);
$grpswitch = get_request('grpswitch', 0);
$maintenance = get_request('maintenance', 0);
$extAck = get_request('extAck', 0);
$severity = get_request('trgSeverity', array());
$severity = array_keys($severity);
} else {
$filterEnable = CProfile::get('web.dashconf.filter.enable', 0);
$groupids = get_favorites('web.dashconf.groups.groupids');
$groupids = zbx_objectValues($groupids, 'value');
$groupids = zbx_toHash($groupids);
$grpswitch = CProfile::get('web.dashconf.groups.grpswitch', 0);
$maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
$extAck = CProfile::get('web.dashconf.events.extAck', 0);
$severity = CProfile::get('web.dashconf.triggers.severity', '0;1;2;3;4;5');
$severity = zbx_empty($severity) ? array() : explode(';', $severity);
}
$dashForm->addVar('filterEnable', $filterEnable);
if ($filterEnable) {
$cbFilter = new CSpan(S_ENABLED, 'green underline pointer');
$cbFilter->setAttribute('onclick', "create_var('" . $dashForm->getName() . "', 'filterEnable', 0, true);");
} else {
$cbFilter = new CSpan(S_DISABLED, 'red underline pointer');
$cbFilter->setAttribute('onclick', "\$('dashform').enable(); create_var('" . $dashForm->getName() . "', 'filterEnable', 1, true);");
}
$dashForm->addRow(S_DASHBOARD_FILTER, $cbFilter);
$dashForm->addVar('groupids', $groupids);
$cmbGroups = new CComboBox('grpswitch', $grpswitch, 'submit();');
$cmbGroups->addItem(0, S_ALL_S);
$cmbGroups->addItem(1, S_SELECTED);
if (!$filterEnable) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:dashconf.php
示例16: resolveTriggerExpressionUserMacro
/**
* Resolve user macros in trigger expression.
*
* @static
*
* @param array $trigger
* @param array $trigger['triggerid']
* @param array $trigger['expression']
*
* @return string
*/
public static function resolveTriggerExpressionUserMacro(array $trigger)
{
if (zbx_empty($trigger['expression'])) {
return $trigger['expression'];
}
self::init();
$triggers = self::$macrosResolver->resolve(array('config' => 'triggerExpressionUser', 'data' => zbx_toHash(array($trigger), 'triggerid')));
$trigger = reset($triggers);
return $trigger['expression'];
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:21,代码来源:CMacrosResolverHelper.php
示例17: make_status_of_zbx
case 'hat_stszbx':
$stszbx = make_status_of_zbx();
$stszbx->show();
break;
}
}
}
if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) {
exit;
}
$admin = uint_in_array($USER_DETAILS['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN));
$rows_per_page = $USER_DETAILS['rows_per_page'];
$search_wdgt = new CWidget('search_wdgt');
$search = get_request('search', '');
// Header
if (zbx_empty($search)) {
$search = 'Search pattern is empty';
}
$search_wdgt->addHeader(array(S_SEARCH_BIG . ': ', bold($search)), SPACE);
//-------------
$left_tab = new CTable();
$left_tab->setCellPadding(3);
$left_tab->setCellSpacing(3);
$left_tab->setAttribute('border', 0);
$right_tab = new CTable();
$right_tab->setCellPadding(3);
$right_tab->setCellSpacing(3);
$right_tab->setAttribute('border', 0);
// FIND Hosts
$params = array('nodeids' => get_current_nodeid(), 'extendoutput' => true, 'pattern' => $search, 'extend_pattern' => true, 'limit' => $rows_per_page, 'order' => 'host');
$db_hosts = CHost::get($params);
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:search.php
示例18: CDiv
}
if ($show_events != EVENTS_OPTION_NOEVENT && !empty($trigger['events'])) {
$open_close = new CDiv(SPACE, 'filterclosed');
$open_close->setAttribute('data-switcherid', $trigger['triggerid']);
} else {
if ($show_events == EVENTS_OPTION_NOEVENT) {
$open_close = null;
} else {
$open_close = SPACE;
}
}
$severity_col = new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $trigger['value']));
if ($show_event_col) {
$severity_col->setColSpan(2);
}
$table->addRow(array($open_close, $config['event_ack_enable'] ? $show_event_col ? null : new CCheckBox('triggers[' . $trigger['triggerid'] . ']', 'no', null, $trigger['triggerid']) : null, $severity_col, $status, $lastchange, zbx_date2age($trigger['lastchange']), $show_event_col ? SPACE : NULL, $to_ack, get_node_name_by_elid($trigger['triggerid']), $host, $tr_desc, new CLink(zbx_empty($trigger['comments']) ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $trigger['triggerid'])), 'even_row');
if ($show_events != EVENTS_OPTION_NOEVENT) {
$i = 1;
foreach ($trigger['events'] as $enum => $row_event) {
$i++;
$status = new CSpan(trigger_value2str($row_event['value']), get_trigger_value_style($row_event['value']));
if ($config['event_ack_enable']) {
if ($row_event['value'] == TRIGGER_VALUE_TRUE) {
if ($row_event['acknowledged'] == 1) {
$acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid=' . $row_event['eventid']));
$ack = array(new CSpan(S_YES, 'off'), SPACE . '(' . $acks_cnt['cnt'] . SPACE, new CLink(S_SHOW, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file']), ')');
} else {
$ack = new CLink(S_NOT_ACKNOWLEDGED, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'on');
}
} else {
$ack = SPACE;
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:tr_status.php
示例19: dbFilter
/**
* Apply filter conditions to sql built query.
*
* @param string $table
* @param array $options
* @param array $sqlParts
*
* @return bool
*/
protected function dbFilter($table, $options, &$sqlParts)
{
list($table, $tableShort) = explode(' ', $table);
$tableSchema = DB::getSchema($table);
$filter = [];
foreach ($options['filter'] as $field => $value) {
// skip missing fields and text fields (not supported by Oracle)
// skip empty values
if (!isset($tableSchema['fields'][$field]) || $tableSchema['fields'][$field]['type'] == DB::FIELD_TYPE_TEXT || zbx_empty($value)) {
continue;
}
zbx_value2array($value);
$fieldName = $this->fieldId($field, $tableShort);
$filter[$field] = DB::isNumericFieldType($tableSchema['fields'][$field]['type']) ? dbConditionInt($fieldName, $value) : dbConditionString($fieldName, $value);
}
if ($filter) {
if (isset($sqlParts['where']['filter'])) {
$filter[] = $sqlParts['where']['filter'];
}
if (is_null($options['searchByAny']) || $options['searchByAny'] === false || count($filter) == 1) {
$sqlParts['where']['filter'] = implode(' AND ', $filter);
} else {
$sqlParts['where']['filter'] = '(' . implode(' OR ', $filter) . ')';
}
return true;
}
return false;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:37,代码来源:CApiService.php
示例20: update
/**
* Update maintenances.
*
* @param array $maintenances
*
* @return boolean
*/
public function update(array $maintenances)
{
$maintenances = zbx_toArray($maintenances);
$maintenanceids = zbx_objectValues($maintenances, 'maintenanceid');
// validate maintenance permissions
if (self::$userData['type'] == USER_TYPE_ZABBIX_USER) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
}
$updMaintenances = $this->get(['maintenanceids' => zbx_objectValues($maintenances, 'maintenanceid'), 'editable' => true, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => ['groupid'], 'selectHosts' => ['hostid'], 'selectTimeperiods' => API_OUTPUT_EXTEND, 'preservekeys' => true]);
$maintenanceNamesChanged = [];
foreach ($maintenances as $maintenance) {
if (!isset($updMaintenances[$maintenance['maintenanceid']])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
}
if (isset($maintenance['name']) && !zbx_empty($maintenance['name']) && $updMaintenances[$maintenance['maintenanceid']]['name'] !== $maintenance['name']) {
if (isset($maintenanceNamesChanged[$maintenance['name']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%1$s" already exists.', $maintenance['name']));
} else {
$maintenanceNamesChanged[$maintenance['name']] = $maintenance['name'];
}
}
}
// check if maintenance already exists
if ($maintenanceNamesChanged) {
$dbMaintenances = $this->get(['output' => ['name'], 'filter' => ['name' => $maintenanceNamesChanged], 'nopermissions' => true, 'limit' => 1]);
if ($dbMaintenances) {
$dbMaintenance = reset($dbMaintenances);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%1$s" already exists.', $dbMaintenance['name']));
}
}
$hostids = [];
$groupids = [];
foreach ($maintenances as $maintenance) {
// validate maintenance active since
if (!validateUnixTime($maintenance['active_since'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active since')));
}
// validate maintenance active till
if (!validateUnixTime($maintenance['active_till'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active till')));
}
// validate maintenance active interval
if ($maintenance['active_since'] > $maintenance['active_till']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Maintenance "Active since" value cannot be bigger than "Active till".'));
}
// validate timeperiods
if (!array_key_exists('timeperiods', $maintenance) || !is_array($maintenance['timeperiods']) || !$maintenance['timeperiods']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.'));
}
foreach ($maintenance['timeperiods'] as $timeperiod) {
if (!is_array($timeperiod)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.'));
}
}
$hostids = array_merge($hostids, $maintenance['hostids']);
$groupids = array_merge($groupids, $maintenance['groupids']);
}
// validate hosts & groups
if (empty($hostids) && empty($groupids)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one host or group should be selected.'));
}
// validate hosts permissions
$options = ['hostids' => $hostids, 'editable' => true, 'output' => ['hostid'], 'preservekeys' => true];
$updHosts = API::Host()->get($options);
foreach ($hostids as $hostid) {
if (!isset($updHosts[$hostid])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
}
}
// validate groups permissions
$options = ['groupids' => $groupids, 'editable' => true, 'output' => ['groupid'], 'preservekeys' => true];
$updGroups = API::HostGroup()->get($options);
foreach ($groupids as $groupid) {
if (!isset($updGroups[$groupid])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
}
}
$this->removeSecondsFromTimes($maintenances);
$update = [];
foreach ($maintenances as $mnum => $maintenance) {
$dbFields = ['maintenanceid' => null];
// validate fields
if (!check_db_fields($dbFields, $maintenance)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect parameters for maintenance.'));
}
$update[$mnum] = ['values' => $maintenance, 'where' => ['maintenanceid' => $maintenance['maintenanceid']]];
// update time periods
$this->replaceTimePeriods($updMaintenances[$maintenance['maintenanceid']], $maintenance);
}
DB::update('maintenances', $update);
// some of the hosts and groups bound to maintenance must be deleted, other inserted and others left alone
$insertHosts = [];
$insertGroups = [];
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CMaintenance.php
注:本文中的zbx_empty函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开 |
请发表评论