本文整理汇总了PHP中str_in_array函数的典型用法代码示例。如果您正苦于以下问题:PHP str_in_array函数的具体用法?PHP str_in_array怎么用?PHP str_in_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_in_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addItem
public function addItem($value, $caption = '', $selected = null, $enabled = 'yes')
{
if ($value instanceof CComboItem || $value instanceof COptGroup) {
parent::addItem($value);
} else {
$title = false;
// if caption is too long ( > 44 symbols), we add new class - 'selectShorten',
// so that the select box would not stretch
if (zbx_strlen($caption) > 44 && !$this->hasClass('selectShorten')) {
$this->setAttribute('class', $this->getAttribute('class') . ' selectShorten');
$title = true;
}
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} elseif (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
} else {
$selected = 'yes';
}
$citem = new CComboItem($value, $caption, $selected, $enabled);
if ($title) {
$citem->setTitle($caption);
}
parent::addItem($citem);
}
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:class.ccombobox.php
示例2: addItem
public function addItem($value, $caption = '', $selected = null, $enabled = true, $class = null)
{
if ($value instanceof CComboItem || $value instanceof COptGroup) {
parent::addItem($value);
} else {
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} elseif (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
} else {
$selected = 'yes';
}
$citem = new CComboItem($value, $caption, $selected, $enabled);
if ($class !== null) {
$citem->addClass($class);
}
parent::addItem($citem);
}
return $this;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:25,代码来源:CComboBox.php
示例3: addItem
public function addItem($value, $caption = '', $selected = null, $enabled = 'yes', $class = null)
{
if (is_null($selected)) {
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$this->value_exist = 1;
}
} elseif (strcmp($value, $this->value) == 0) {
$this->value_exist = 1;
}
}
parent::addItem($value, $caption, $selected, $enabled, $class);
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:13,代码来源:CEditableComboBox.php
示例4: addItem
public function addItem($value, $caption, $selected = null, $enabled = 'yes')
{
if (is_null($selected)) {
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 1;
}
} else {
if (strcmp($value, $this->value) == 0) {
$selected = 1;
}
}
}
if (is_bool($selected) && $selected || is_int($selected) && $selected != 0 || is_string($selected) && ($selected == 'yes' || $selected == 'selected' || $selected == 'on')) {
$this->lbox->addItem($value, $caption, null, $enabled);
$this->form->addVar($this->varname . '[' . $value . ']', $value);
} else {
$this->rbox->addItem($value, $caption, null, $enabled);
}
}
开发者ID:rennhak,项目名称:zabbix,代码行数:20,代码来源:class.ctweenbox.php
示例5: addItem
public function addItem($value, $caption = '', $selected = NULL, $enabled = 'yes')
{
// if($enabled=='no') return; /* disable item method 1 */
if (strtolower(get_class($value)) == 'ccomboitem') {
parent::addItem($value);
} else {
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} else {
if (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
}
}
parent::addItem(new CComboItem($value, $caption, $selected, $enabled));
}
}
开发者ID:rennhak,项目名称:zabbix,代码行数:21,代码来源:class.ccombobox.php
示例6: addItem
public function addItem($value, $caption = '', $selected = NULL, $enabled = 'yes')
{
// if($enabled=='no') return; /* disable item method 1 */
if (is_object($value) && zbx_strtolower(get_class($value)) == 'ccomboitem') {
parent::addItem($value);
} else {
if (zbx_strlen($caption) > 44) {
$this->setAttribute('class', 'select selectShorten');
}
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} else {
if (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
}
}
parent::addItem(new CComboItem($value, $caption, $selected, $enabled));
}
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:24,代码来源:class.ccombobox.php
示例7: get
//.........这里部分代码省略.........
}
// druleids
if (isset($dservice['druleid']) && is_null($options['selectDRules'])) {
if (!isset($result[$dservice['dserviceid']]['drules'])) {
$result[$dservice['dserviceid']]['drules'] = array();
}
$result[$dservice['dserviceid']]['drules'][] = array('druleid' => $dservice['druleid']);
}
// dhostids
if (isset($dservice['dhostid']) && is_null($options['selectDHosts'])) {
if (!isset($result[$dservice['dserviceid']]['dhosts'])) {
$result[$dservice['dserviceid']]['dhosts'] = array();
}
$result[$dservice['dserviceid']]['dhosts'][] = array('dhostid' => $dservice['dhostid']);
}
// dcheckids
if (isset($dservice['dcheckid']) && is_null($options['selectDChecks'])) {
if (!isset($result[$dservice['dserviceid']]['dchecks'])) {
$result[$dservice['dserviceid']]['dchecks'] = array();
}
$result[$dservice['dserviceid']]['dchecks'][] = array('dcheckid' => $dservice['dcheckid']);
}
$result[$dservice['dserviceid']] += $dservice;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
// Adding Objects
// select_drules
if (!is_null($options['selectDRules'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1);
if (is_array($options['selectDRules']) || str_in_array($options['selectDRules'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectDRules'];
$drules = API::DRule()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($drules, 'name');
}
foreach ($drules as $druleid => $drule) {
unset($drules[$druleid]['dservices']);
$count = array();
foreach ($drule['dservices'] as $dnum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['drules'][] =& $drules[$druleid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectDRules']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$drules = API::DRule()->get($objParams);
$drules = zbx_toHash($drules, 'dserviceid');
foreach ($result as $dserviceid => $dservice) {
if (isset($drules[$dserviceid])) {
$result[$dserviceid]['drules'] = $drules[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['drules'] = 0;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CDService.php
示例8: get
//.........这里部分代码省略.........
}
// 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
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'])) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.chistory.php
示例9: applyQuerySortField
/**
* Adds a specific property from the 'sortfield' parameter to the $sqlParts array.
*
* @param string $sortfield
* @param string $sortorder
* @param string $alias
* @param array $sqlParts
*
* @return array
*/
protected function applyQuerySortField($sortfield, $sortorder, $alias, array $sqlParts)
{
// add sort field to select if distinct is used
if (count($sqlParts['from']) > 1 && !str_in_array($alias . '.' . $sortfield, $sqlParts['select']) && !str_in_array($alias . '.*', $sqlParts['select'])) {
$sqlParts['select'][$sortfield] = $alias . '.' . $sortfield;
}
$sqlParts['order'][$alias . '.' . $sortfield] = $alias . '.' . $sortfield . $sortorder;
return $sqlParts;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:19,代码来源:CApiService.php
示例10: add_host_profile_ext
function add_host_profile_ext($hostid, $ext_host_profiles = array())
{
$ext_profiles_fields = array('device_alias', 'device_type', 'device_chassis', 'device_os', 'device_os_short', 'device_hw_arch', 'device_serial', 'device_model', 'device_tag', 'device_vendor', 'device_contract', 'device_who', 'device_status', 'device_app_01', 'device_app_02', 'device_app_03', 'device_app_04', 'device_app_05', 'device_url_1', 'device_url_2', 'device_url_3', 'device_networks', 'device_notes', 'device_hardware', 'device_software', 'ip_subnet_mask', 'ip_router', 'ip_macaddress', 'oob_ip', 'oob_subnet_mask', 'oob_router', 'date_hw_buy', 'date_hw_install', 'date_hw_expiry', 'date_hw_decomm', 'site_street_1', 'site_street_2', 'site_street_3', 'site_city', 'site_state', 'site_country', 'site_zip', 'site_rack', 'site_notes', 'poc_1_name', 'poc_1_email', 'poc_1_phone_1', 'poc_1_phone_2', 'poc_1_cell', 'poc_1_screen', 'poc_1_notes', 'poc_2_name', 'poc_2_email', 'poc_2_phone_1', 'poc_2_phone_2', 'poc_2_cell', 'poc_2_screen', 'poc_2_notes');
$result = DBselect('SELECT * FROM hosts_profiles_ext WHERE hostid=' . $hostid);
if (DBfetch($result)) {
error(S_HOST_PROFILE . SPACE . S_ALREADY_EXISTS);
return false;
}
$sql = 'INSERT INTO hosts_profiles_ext (hostid,';
$values = ' VALUES (' . $hostid . ',';
foreach ($ext_host_profiles as $field => $value) {
if (str_in_array($field, $ext_profiles_fields)) {
$sql .= $field . ',';
$values .= zbx_dbstr($value) . ',';
}
}
$sql = rtrim($sql, ',') . ')';
$values = rtrim($values, ',') . ')';
$result = DBexecute($sql . $values);
return $result;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:21,代码来源:hosts.inc.php
示例11: DBend
$result = API::Itemprototype()->update($item);
} else {
$result = API::Itemprototype()->create($item);
}
}
$result = DBend($result);
if (hasRequest('add')) {
show_messages($result, _('Item prototype added'), _('Cannot add item prototype'));
} else {
show_messages($result, _('Item prototype updated'), _('Cannot update item prototype'));
}
if ($result) {
unset($_REQUEST['itemid'], $_REQUEST['form']);
uncheckTableRows(getRequest('parent_discoveryid'));
}
} elseif (hasRequest('action') && str_in_array(getRequest('action'), ['itemprototype.massenable', 'itemprototype.massdisable']) && hasRequest('group_itemid')) {
$groupItemId = getRequest('group_itemid');
$enable = getRequest('action') == 'itemprototype.massenable';
DBstart();
$result = $enable ? activate_item($groupItemId) : disable_item($groupItemId);
$result = DBend($result);
$updated = count($groupItemId);
$messageSuccess = $enable ? _n('Item prototype enabled', 'Item prototypes enabled', $updated) : _n('Item prototype disabled', 'Item prototypes disabled', $updated);
$messageFailed = $enable ? _n('Cannot enable item prototype', 'Cannot enable item prototypes', $updated) : _n('Cannot disable item prototype', 'Cannot disable item prototypes', $updated);
if ($result) {
uncheckTableRows(getRequest('parent_discoveryid'));
}
show_messages($result, $messageSuccess, $messageFailed);
} elseif (hasRequest('action') && getRequest('action') == 'itemprototype.massdelete' && hasRequest('group_itemid')) {
DBstart();
$result = API::Itemprototype()->delete(getRequest('group_itemid'));
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:disc_prototypes.php
示例12: get
//.........这里部分代码省略.........
$sqlParts['group'] = array_unique($sqlParts['group']);
$sqlParts['order'] = array_unique($sqlParts['order']);
$sqlSelect = '';
$sqlFrom = '';
$sqlWhere = '';
$sqlGroup = '';
$sqlOrder = '';
if (!empty($sqlParts['select'])) {
$sqlSelect .= implode(',', $sqlParts['select']);
}
if (!empty($sqlParts['from'])) {
$sqlFrom .= implode(',', $sqlParts['from']);
}
if (!empty($sqlParts['where'])) {
$sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
}
if (!empty($sqlParts['group'])) {
$sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
}
if (!empty($sqlParts['order'])) {
$sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
}
$sqlLimit = $sqlParts['limit'];
$sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('a.applicationid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
$res = DBselect($sql, $sqlLimit);
while ($application = DBfetch($res)) {
if (!is_null($options['countOutput'])) {
if (!is_null($options['groupCount'])) {
$result[] = $application;
} else {
$result = $application['rowscount'];
}
} else {
$applicationids[$application['applicationid']] = $application['applicationid'];
if ($options['output'] == API_OUTPUT_SHORTEN) {
$result[$application['applicationid']] = array('applicationid' => $application['applicationid']);
} else {
if (!isset($result[$application['applicationid']])) {
$result[$application['applicationid']] = array();
}
if (!is_null($options['selectHosts']) && !isset($result[$application['applicationid']]['hosts'])) {
$result[$application['applicationid']]['hosts'] = array();
}
if (!is_null($options['selectItems']) && !isset($result[$application['applicationid']]['items'])) {
$result[$application['applicationid']]['items'] = array();
}
// hostids
if (isset($application['hostid']) && is_null($options['selectHosts'])) {
if (!isset($result[$application['applicationid']]['hosts'])) {
$result[$application['applicationid']]['hosts'] = array();
}
$result[$application['applicationid']]['hosts'][] = array('hostid' => $application['hostid']);
}
// itemids
if (isset($application['itemid']) && is_null($options['selectItems'])) {
if (!isset($result[$application['applicationid']]['items'])) {
$result[$application['applicationid']]['items'] = array();
}
$result[$application['applicationid']]['items'][] = array('itemid' => $application['itemid']);
unset($application['itemid']);
}
$result[$application['applicationid']] += $application;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
// adding objects
// adding hosts
if ($options['selectHosts'] !== null && (is_array($options['selectHosts']) || str_in_array($options['selectHosts'], $subselectsAllowedOutputs))) {
$objParams = array('output' => $options['selectHosts'], 'applicationids' => $applicationids, 'nopermissions' => 1, 'templated_hosts' => true, 'preservekeys' => 1);
$hosts = API::Host()->get($objParams);
foreach ($hosts as $hostid => $host) {
$iapplications = $host['applications'];
unset($host['applications']);
foreach ($iapplications as $application) {
$result[$application['applicationid']]['hosts'][] = $host;
}
}
}
// adding objects
// adding items
if (!is_null($options['selectItems']) && str_in_array($options['selectItems'], $subselectsAllowedOutputs)) {
$objParams = array('output' => $options['selectItems'], 'applicationids' => $applicationids, 'nopermissions' => true, 'preservekeys' => true);
$items = API::Item()->get($objParams);
foreach ($items as $itemid => $item) {
$iapplications = $item['applications'];
unset($item['applications']);
foreach ($iapplications as $application) {
$result[$application['applicationid']]['items'][] = $item;
}
}
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CApplication.php
示例13: DBend
$result = API::DiscoveryRule()->update($newItem);
$result = DBend($result);
} else {
$result = API::DiscoveryRule()->create([$newItem]);
}
}
if (hasRequest('add')) {
show_messages($result, _('Discovery rule created'), _('Cannot add discovery rule'));
} else {
show_messages($result, _('Discovery rule updated'), _('Cannot update discovery rule'));
}
if ($result) {
unset($_REQUEST['itemid'], $_REQUEST['form']);
uncheckTableRows(getRequest('hostid'));
}
} elseif (hasRequest('action') && str_in_array(getRequest('action'), ['discoveryrule.massenable', 'discoveryrule.massdisable']) && hasRequest('g_hostdruleid')) {
$groupHostDiscoveryRuleId = getRequest('g_hostdruleid');
$enable = getRequest('action') == 'discoveryrule.massenable';
DBstart();
$result = $enable ? activate_item($groupHostDiscoveryRuleId) : disable_item($groupHostDiscoveryRuleId);
$result = DBend($result);
if ($result) {
uncheckTableRows(getRequest('hostid'));
}
$updated = count($groupHostDiscoveryRuleId);
$messageSuccess = $enable ? _n('Discovery rule enabled', 'Discovery rules enabled', $updated) : _n('Discovery rule disabled', 'Discovery rules disabled', $updated);
$messageFailed = $enable ? _n('Cannot enable discovery rule', 'Cannot enable discovery rules', $updated) : _n('Cannot disable discovery rule', 'Cannot disable discovery rules', $updated);
show_messages($result, $messageSuccess, $messageFailed);
} elseif (hasRequest('action') && getRequest('action') == 'discoveryrule.massdelete' && hasRequest('g_hostdruleid')) {
$result = API::DiscoveryRule()->delete(getRequest('g_hostdruleid'));
if ($result) {
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:host_discovery.php
示例14: checkInput
//.........这里部分代码省略.........
$item['delay_flex'] = '';
}
if ($fullItem['value_type'] == ITEM_VALUE_TYPE_STR) {
$item['delta'] = 0;
}
if ($fullItem['value_type'] != ITEM_VALUE_TYPE_UINT64) {
$item['data_type'] = 0;
}
// check if the item requires an interface
$itemInterfaceType = itemTypeInterface($fullItem['type']);
if ($itemInterfaceType !== false && $host['status'] != HOST_STATUS_TEMPLATE) {
if (!$fullItem['interfaceid']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('No interface found.'));
} elseif (!isset($interfaces[$fullItem['interfaceid']]) || bccomp($interfaces[$fullItem['interfaceid']]['hostid'], $fullItem['hostid']) != 0) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Item uses host interface from non-parent host.'));
} elseif ($itemInterfaceType !== INTERFACE_TYPE_ANY && $interfaces[$fullItem['interfaceid']]['type'] != $itemInterfaceType) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Item uses incorrect interface type.'));
}
} else {
$item['interfaceid'] = 0;
}
// item key
if ($fullItem['type'] == ITEM_TYPE_DB_MONITOR && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_DB_MONITOR) == 0 || $fullItem['type'] == ITEM_TYPE_SSH && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_SSH) == 0 || $fullItem['type'] == ITEM_TYPE_TELNET && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_TELNET) == 0 || $fullItem['type'] == ITEM_TYPE_JMX && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_JMX) == 0) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Check the key, please. Default example was passed.'));
}
// key
$itemKey = new CItemKey($fullItem['key_']);
if (!$itemKey->isValid()) {
self::exception(ZBX_API_ERROR_PARAMETERS, _params($this->getErrorMsg(self::ERROR_INVALID_KEY), array($fullItem['key_'], $fullItem['name'], $host['name'], $itemKey->getError())));
}
// parameters
if ($fullItem['type'] == ITEM_TYPE_AGGREGATE) {
$params = $itemKey->getParameters();
if (!str_in_array($itemKey->getKeyId(), array('grpmax', 'grpmin', 'grpsum', 'grpavg')) || count($params) != 4 || !str_in_array($params[2], array('last', 'min', 'max', 'avg', 'sum', 'count'))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Key "%1$s" does not match <grpmax|grpmin|grpsum|grpavg>["Host group(s)", "Item key",' . ' "<last|min|max|avg|sum|count>", "parameter"].', $itemKey->getKeyId()));
}
}
// type of information
if ($fullItem['type'] == ITEM_TYPE_AGGREGATE && $fullItem['value_type'] != ITEM_VALUE_TYPE_FLOAT && $fullItem['value_type'] != ITEM_VALUE_TYPE_UINT64) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Type of information must be "Numeric (float)" for aggregate items.'));
}
// log
if ($fullItem['value_type'] != ITEM_VALUE_TYPE_LOG && str_in_array($itemKey->getKeyId(), array('log', 'logrt', 'eventlog'))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Type of information must be "Log" for log key.'));
}
// update interval
if ($fullItem['type'] != ITEM_TYPE_TRAPPER && $fullItem['type'] != ITEM_TYPE_SNMPTRAP) {
$res = calculateItemNextcheck(0, $fullItem['type'], $fullItem['delay'], $fullItem['delay_flex'], time());
if ($res == ZBX_JAN_2038) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Item will not be refreshed. Please enter a correct update interval.'));
}
}
// ssh, telnet
if ($fullItem['type'] == ITEM_TYPE_SSH || $fullItem['type'] == ITEM_TYPE_TELNET) {
if (zbx_empty($fullItem['username'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('No authentication user name specified.'));
}
if ($fullItem['type'] == ITEM_TYPE_SSH && $fullItem['authtype'] == ITEM_AUTHTYPE_PUBLICKEY) {
if (zbx_empty($fullItem['publickey'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('No public key file specified.'));
}
if (zbx_empty($fullItem['privatekey'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('No private key file specified.'));
}
}
}
开发者ID:hujingguang,项目名称:work,代码行数:67,代码来源:CItemGeneral.php
示例15: DBfetch
/**
* Returns the next data set from a DB resource or false if there are no more results.
*
* @param resource $cursor
* @param bool $convertNulls convert all null values to string zeroes
*
* @return array|bool
*/
function DBfetch($cursor, $convertNulls = true)
{
global $DB;
$result = false;
if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) {
return $result;
}
switch ($DB['TYPE']) {
case ZBX_DB_MYSQL:
$result = mysqli_fetch_assoc($cursor);
if (!$result) {
mysqli_free_result($cursor);
}
break;
case ZBX_DB_POSTGRESQL:
if (!($result = pg_fetch_assoc($cursor))) {
pg_free_result($cursor);
}
break;
case ZBX_DB_ORACLE:
if ($row = oci_fetch_assoc($cursor)) {
$result = array();
foreach ($row as $key => $value) {
$field_type = strtolower(oci_field_type($cursor, $key));
// Oracle does not support NULL values for string fields, so if the string is empty, it will return NULL
// convert it to an empty string to be consistent with other databases
$value = str_in_array($field_type, array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
if (is_object($value) && strpos($field_type, 'lob') !== false) {
$value = $value->load();
}
$result[strtolower($key)] = $value;
}
}
break;
case ZBX_DB_DB2:
if (!($result = db2_fetch_assoc($cursor))) {
db2_free_result($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
if ($value !== null) {
$value = (string) $value;
}
}
unset($value);
}
break;
case ZBX_DB_SQLITE3:
if ($DB['TRANSACTIONS'] == 0) {
lock_sqlite3_access();
}
if (!($result = $cursor->fetchArray(SQLITE3_ASSOC))) {
unset($cursor);
} else {
// cast all of the values to string to be consistent with other DB drivers: all of them return
// only strings.
foreach ($result as &$value) {
$value = (string) $value;
}
unset($value);
}
if ($DB['TRANSACTIONS'] == 0) {
unlock_sqlite3_access();
}
break;
}
if ($result) {
if ($convertNulls) {
foreach ($result as $key => $val) {
if (is_null($val)) {
$result[$key] = '0';
}
}
}
return $result;
}
return false;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:87,代码来源:db.inc.php
示例16: DBstart
DBstart();
while ($db_group = DBfetch($db_groups)) {
if (!uint_in_array($db_group['groupid'], $groups)) {
continue;
}
/* if(!$group = get_hostgroup_by_groupid($db_group['groupid'])) continue;*/
$result &= delete_host_group($db_group['groupid']);
/* if($result){
add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST_GROUP,
S_HOST_GROUP.' ['.$group['name'].' ] ['.$group['groupid'].']');
}*/
}
$result = DBend($result);
show_messages(true, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
} else {
if (str_in_array($_REQUEST['go'], array('activate', 'disable'))) {
$result = true;
$status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED;
$groups = get_request('groups', array());
$db_hosts = DBselect('select h.hostid, hg.groupid ' . ' from hosts_groups hg, hosts h' . ' where h.hostid=hg.hostid ' . ' and h.status in (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' and ' . DBin_node('h.hostid'));
DBstart();
while ($db_host = DBfetch($db_hosts)) {
if (!uint_in_array($db_host['groupid'], $groups)) {
continue;
}
$host = get_host_by_hostid($db_host['hostid']);
$result &= update_host_status($db_host['hostid'], $status);
/* add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,
'Old status ['.$host['status'].'] '.'New status ['.$status.']');*/
}
$result = DBend($result);
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:hostgroups.php
示例17: CDiv
$newOperationsTable->addRow(array(_('Conditions'), new CDiv($operationConditionsTable, 'objectgroup inlineblock border_dotted ui-corner-all')), 'indent_top');
}
// append new operation condition to form list
if (isset($_REQUEST['new_opcondition'])) {
$newOperationConditionTable = new CTable(null, 'formElementTable');
$allowedOpConditions = get_opconditions_by_eventsource($this->data['eventsource']);
$new_opcondition = get_request('new_opcondition', array());
if (!is_array($new_opcondition)) {
$new_opcondition = array();
}
if (empty($new_opcondition)) {
$new_opcondition['conditiontype'] = CONDITION_TYPE_EVENT_ACKNOWLEDGED;
$new_opcondition['operator'] = CONDITION_OPERATOR_LIKE;
$new_opcondition['value'] = 0;
}
if (!str_in_array($new_opcondition['conditiontype'], $allowedOpConditions)) {
$new_opcondition['conditiontype'] = $allowedOpConditions[0];
}
$rowCondition = array();
$conditionTypeComboBox = new CComboBox('new_opcondition[conditiontype]', $new_opcondition['conditiontype'], 'submit()');
foreach ($allowedOpConditions as $opcondition) {
$conditionTypeComboBox->addItem($opcondition, condition_type2str($opcondition));
}
array_push($rowCondition, $conditionTypeComboBox);
$operationConditionComboBox = new CComboBox('new_opcondition[operator]');
foreach (get_operators_by_conditiontype($new_opcondition['conditiontype']) as $operationCondition) {
$operationConditionComboBox->addItem($operationCondition, condition_operator2str($operationCondition));
}
array_push($rowCondition, $operationConditionComboBox);
if ($new_opcondition['conditiontype'] == CONDITION_TYPE_EVENT_ACKNOWLEDGED) {
$operationConditionValueComboBox = new CComboBox('new_opcondition[value]', $new_opcondition['value']);
开发者ID:itnihao,项目名称:Zabbix_,代码行数:31,代码来源:configuration.action.edit.php
示例18: zbx_define_menu_restrictions
function zbx_define_menu_restrictions($page, $ZBX_MENU)
{
foreach ($ZBX_MENU as $section) {
foreach ($section['pages'] as $menu_page) {
if ($menu_page['url'] == $page['file'] || isset($menu_page['sub_pages']) && str_in_array($page['file'], $menu_page['sub_pages'])) {
if (isset($section['force_disable_all_nodes']) && !defined('ZBX_NOT_ALLOW_ALL_NODES')) {
define('ZBX_NOT_ALLOW_ALL_NODES', 1);
}
if (isset($section['hide_node_selection']) && !defined('ZBX_HIDE_NODE_SELECTION')) {
define('ZBX_HIDE_NODE_SELECTION', 1);
}
return null;
}
}
}
}
开发者ID:sogaoh,项目名称:hyclops,代码行数:16,代码来源:menu.inc.php
示例19: get
//.........这里部分代码省略.........
if (!is_null($options['selectTemplates']) && !isset($result[$graph['graphid']]['templates'])) {
$result[$graph['graphid']]['templates'] = array();
}
if (!is_null($options['selectItems']) && !isset($result[$graph['graphid']]['items'])) {
$result[$graph['graphid']]['items'] = array();
}
if (!is_null($options['selectDiscoveryRule']) && !isset($result[$graph['graphid']]['discoveryRule'])) {
$result[$graph['graphid']]['discoveryRule'] = array();
}
// hostids
if (isset($graph['hostid']) && is_null($options['selectHosts'])) {
if (!isset($result[$graph['graphid']]['hosts'])) {
$result[$graph['graphid']]['hosts'] = array();
}
$result[$graph['graphid']]['hosts'][] = array('hostid' => $graph['hostid']);
unset($graph['hostid']);
}
// itemids
if (isset($graph['itemid']) && is_null($options['selectItems'])) {
if (!isset($result[$graph['graphid']]['items'])) {
$result[$graph['graphid']]['items'] = array();
}
$result[$graph['graphid']]['items'][] = array('itemid' => $graph['itemid']);
unset($graph['itemid']);
}
$result[$graph['graphid']] += $graph;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
// adding GraphItems
if (!is_null($options['selectGraphItems']) && str_in_array($options['selectGraphItems'], $subselectsAllowedOutputs)) {
$gitems = API::GraphItem()->get(array('nodeids' => $nodeids, 'output' => $options['selectGraphItems'], 'graphids' => $graphids, 'nopermissions' => true, 'preservekeys' => true));
foreach ($gitems as $gitem) {
$ggraphs = $gitem['graphs'];
unset($gitem['graphs']);
foreach ($ggraphs as $graph) {
$result[$graph['graphid']]['gitems'][$gitem['gitemid']] = $gitem;
}
}
}
// adding Hostgroups
if (!is_null($options['selectGroups'])) {
if (is_array($options['selectGroups']) || str_in_array($options['selectGroups'], $subselectsAllowedOutputs)) {
$groups = API::HostGroup()->get(array('nodeids' => $nodeids, 'output' => $options['selectGroups'], 'graphids' => $graphids, 'nopermissions' => true, 'preservekeys' => true));
foreach ($groups as $group) {
$ggraphs = $group['graphs'];
unset($group['graphs']);
foreach ($ggraphs as $graph) {
$result[$graph['graphid']]['groups'][] = $group;
}
}
}
}
// adding Hosts
if (!is_null($options['selectHosts'])) {
if (is_array($options['selectHosts']) || str_in_array($options['selectHosts'], $subselectsAllowedOutputs)) {
$hosts = API::Host()->get(array('nodeids' => $nodeids, 'output' => $options['selectHosts'], 'graphids' => $graphids, 'nopermissions' => true, 'preservekeys' => true));
foreach ($hosts as $host) {
$hgraphs = $host['graphs'];
unset($host['graphs']);
foreach ($hgraphs as $graph) {
$result[$graph['graphid']]['hosts'][] = $host;
|
请发表评论