本文整理汇总了PHP中zbx_dbstr函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_dbstr函数的具体用法?PHP zbx_dbstr怎么用?PHP zbx_dbstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_dbstr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: bodyToString
public function bodyToString()
{
$this->cleanItems();
$total = 0;
// fetch accessible host ids
$hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true));
$hostIds = array_keys($hosts);
if (remove_nodes_from_id($this->groupid) > 0) {
$cond_from = ',hosts_groups hg';
$cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
} else {
$cond_from = '';
$cond_where = andDbNode('h.hostid', $this->nodeid);
}
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$avail = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$notav = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$uncn = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$node = get_node_by_nodeid($this->nodeid);
$header_str = _('Hosts info') . SPACE;
if ($node > 0) {
$header_str .= '(' . $node['name'] . ')' . SPACE;
}
if (remove_nodes_from_id($this->groupid) > 0) {
$group = get_hostgroup_by_groupid($this->groupid);
$header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
} else {
$header_str .= _('All groups');
}
$header = new CCol($header_str, 'header');
if ($this->style == STYLE_HORISONTAL) {
$header->setColspan(4);
}
$this->addRow($header);
$avail = new CCol($avail . ' ' . _('Available'), 'avail');
$notav = new CCol($notav . ' ' . _('Not available'), 'notav');
$uncn = new CCol($uncn . ' ' . _('Unknown'), 'uncn');
$total = new CCol($total . ' ' . _('Total'), 'total');
if ($this->style == STYLE_HORISONTAL) {
$this->addRow(array($avail, $notav, $uncn, $total));
} else {
$this->addRow($avail);
$this->addRow($notav);
$this->addRow($uncn);
$this->addRow($total);
}
return parent::bodyToString();
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:56,代码来源:class.chostsinfo.php
示例2: login
public static function login($login, $password)
{
try {
self::setDefault();
self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
if (!self::$data) {
throw new Exception();
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
if (empty(self::$data['url'])) {
self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
}
if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
CProfile::init();
CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
CProfile::flush();
}
// remove guest session after successful login
DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
zbx_setcookie('zbx_sessionid', self::$data['sessionid'], self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0);
return true;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:class.cwebuser.php
示例3: import
/**
* Import template screens.
*
* @param array $allScreens
*
* @return void
*/
public function import(array $allScreens)
{
$screensToCreate = array();
$screensToUpdate = array();
foreach ($allScreens as $template => $screens) {
// TODO: select all at once out of loop
$dbScreens = DBselect('SELECT s.screenid,s.name FROM screens s WHERE' . ' s.templateid=' . zbx_dbstr($this->referencer->resolveTemplate($template)) . ' AND ' . dbConditionString('s.name', array_keys($screens)));
while ($dbScreen = DBfetch($dbScreens)) {
$screens[$dbScreen['name']]['screenid'] = $dbScreen['screenid'];
}
foreach ($screens as $screen) {
$screen = $this->resolveScreenReferences($screen);
if (isset($screen['screenid'])) {
$screensToUpdate[] = $screen;
} else {
$screen['templateid'] = $this->referencer->resolveTemplate($template);
$screensToCreate[] = $screen;
}
}
}
if ($this->options['templateScreens']['createMissing'] && $screensToCreate) {
API::TemplateScreen()->create($screensToCreate);
}
if ($this->options['templateScreens']['updateExisting'] && $screensToUpdate) {
API::TemplateScreen()->update($screensToUpdate);
}
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:34,代码来源:CTemplateScreenImporter.php
示例4: expandById
/**
* Add trigger by trigger id, required fields for description expanding are queried from DB.
*
* @param string $triggerId
*
* @return string
*/
public function expandById($triggerId)
{
$trigger = DBfetch(DBselect('SELECT DISTINCT t.description,t.expression,t.triggerid' . ' FROM triggers t' . ' WHERE t.triggerid=' . zbx_dbstr($triggerId)));
$triggers = $this->expandDescriptions(array($trigger['triggerid'] => $trigger));
$trigger = reset($triggers);
return $trigger['description'];
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:14,代码来源:CTriggerDescription.php
示例5: updateRegexp
function updateRegexp(array $regexp, array $expressions)
{
try {
$regexpId = $regexp['regexpid'];
unset($regexp['regexpid']);
// check existence
if (!getRegexp($regexpId)) {
throw new Exception(_('Regular expression does not exist.'));
}
// check required fields
$dbFields = array('name' => null);
if (!check_db_fields($dbFields, $regexp)) {
throw new Exception(_('Incorrect arguments passed to function') . ' [updateRegexp]');
}
// check duplicate name
$dbRegexp = DBfetch(DBselect('SELECT re.regexpid' . ' FROM regexps re' . ' WHERE re.name=' . zbx_dbstr($regexp['name']) . andDbNode('re.regexpid')));
if ($dbRegexp && bccomp($regexpId, $dbRegexp['regexpid']) != 0) {
throw new Exception(_s('Regular expression "%s" already exists.', $regexp['name']));
}
rewriteRegexpExpressions($regexpId, $expressions);
DB::update('regexps', array('values' => $regexp, 'where' => array('regexpid' => $regexpId)));
} catch (Exception $e) {
error($e->getMessage());
return false;
}
return true;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:27,代码来源:regexp.inc.php
示例6: login
/**
* Tries to login a user and populates self::$data on success.
*
* @param string $login user login
* @param string $password user password
*
* @throws Exception if user cannot be logged in
*
* @return bool
*/
public static function login($login, $password)
{
try {
self::setDefault();
self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
if (!self::$data) {
throw new Exception();
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
if (empty(self::$data['url'])) {
self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
}
$result = (bool) self::$data;
if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
CProfile::init();
CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
$result &= CProfile::flush();
}
// remove guest session after successful login
$result &= DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
if ($result) {
self::setSessionCookie(self::$data['sessionid']);
add_audit_ext(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, self::$data['userid'], '', null, null, null);
}
return $result;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:45,代码来源:CWebUser.php
示例7: zbx_session_start
function zbx_session_start($userid, $name, $password)
{
$sessionid = md5(time() . $password . $name . rand(0, 10000000));
zbx_setcookie('zbx_sessionid', $sessionid);
DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES (' . zbx_dbstr($sessionid) . ',' . $userid . ',' . time() . ',' . ZBX_SESSION_ACTIVE . ')');
return $sessionid;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:7,代码来源:perm.inc.php
示例8: get
/**
* Get GraphItems data
*
* @param array $options
* @return array|boolean
*/
public function get($options = array())
{
$result = array();
$userType = self::$userData['type'];
$userid = self::$userData['userid'];
$sqlParts = array('select' => array('gitems' => 'gi.gitemid'), 'from' => array('graphs_items' => 'graphs_items gi'), 'where' => array(), 'order' => array(), 'limit' => null);
$defOptions = array('graphids' => null, 'itemids' => null, 'type' => null, 'editable' => null, 'nopermissions' => null, 'selectGraphs' => null, 'output' => API_OUTPUT_EXTEND, 'expandData' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($defOptions, $options);
$this->checkDeprecatedParam($options, 'expandData');
// editable + PERMISSION CHECK
if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
$permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ;
$userGroups = getUserGroupsByUserId($userid);
$sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE gi.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ' GROUP BY i.itemid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ' AND MAX(r.permission)>=' . zbx_dbstr($permission) . ')';
}
// graphids
if (!is_null($options['graphids'])) {
zbx_value2array($options['graphids']);
$sqlParts['from']['graphs'] = 'graphs g';
$sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
$sqlParts['where'][] = dbConditionInt('g.graphid', $options['graphids']);
}
// itemids
if (!is_null($options['itemids'])) {
zbx_value2array($options['itemids']);
$sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
}
// type
if (!is_null($options['type'])) {
$sqlParts['where'][] = 'gi.type=' . zbx_dbstr($options['type']);
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($gitem = DBfetch($dbRes)) {
if (!is_null($options['countOutput'])) {
$result = $gitem['rowscount'];
} else {
$result[$gitem['gitemid']] = $gitem;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
$result = $this->unsetExtraFields($result, array('graphid'), $options['output']);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:64,代码来源:CGraphItem.php
示例9: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$hostids = array();
$dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid']));
while ($dbHostGroup = DBfetch($dbHostGroups)) {
$hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid'];
}
return $this->getOutput(get_items_data_overview($hostids, $this->screenitem['style']));
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:14,代码来源:CScreenDataOverview.php
示例10: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$hostids = array();
$dbHostGroups = DBselect('SELECT DISTINCT hg.hostid' . ' FROM hosts_groups hg' . ' WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid']));
while ($dbHostGroup = DBfetch($dbHostGroups)) {
$hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid'];
}
return $this->getOutput(getTriggersOverview($hostids, $this->screenitem['application'], $this->pageFile, $this->screenitem['style'], $this->screenid));
}
开发者ID:itnihao,项目名称:Zabbix_,代码行数:14,代码来源:CScreenTriggersOverview.php
示例11: checkDbVersionTable
/**
* Check if 'dbversion' table exists.
*
* @return bool
*/
protected function checkDbVersionTable()
{
global $DB;
$tableExists = DBfetch(DBselect('SELECT 1 FROM information_schema.tables' . ' WHERE table_catalog=' . zbx_dbstr($DB['DATABASE']) . " AND table_schema='public'" . " AND table_name='dbversion'"));
if (!$tableExists) {
$this->setError(_('The frontend does not match Zabbix database.'));
return false;
}
return true;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:15,代码来源:PostgresqlDbBackend.php
示例12: get_image_by_imageid
/**
* Get image data from db, cache is used
* @param $imageid
* @return array image data from db
*/
function get_image_by_imageid($imageid)
{
static $images = array();
if (!isset($images[$imageid])) {
$row = DBfetch(DBselect('SELECT i.* FROM images i WHERE i.imageid=' . zbx_dbstr($imageid)));
$row['image'] = zbx_unescape_image($row['image']);
$images[$imageid] = $row;
}
return $images[$imageid];
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:15,代码来源:images.inc.php
示例13: get_service_children
function get_service_children($serviceid, $soft = 0)
{
$children = [];
$result = DBselect('SELECT sl.servicedownid' . ' FROM services_links sl' . ' WHERE sl.serviceupid=' . zbx_dbstr($serviceid) . ($soft ? '' : ' AND sl.soft=0'));
while ($row = DBfetch($result)) {
$children[] = $row['servicedownid'];
$children = array_merge($children, get_service_children($row['servicedownid']));
}
return $children;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:10,代码来源:services.inc.php
示例14: getLast
/**
* Returns the last $limit history objects for the given items.
*
* @param array $items an array of items with the 'itemid' and 'value_type' properties
* @param int $limit
* @param int $period the maximum period to retrieve data for
*
* @return array an array with items IDs as keys and arrays of history objects as values
*/
public function getLast(array $items, $limit = 1, $period = null)
{
$rs = array();
foreach ($items as $item) {
$values = DBfetchArray(DBselect('SELECT *' . ' FROM ' . self::getTableName($item['value_type']) . ' h' . ' WHERE h.itemid=' . zbx_dbstr($item['itemid']) . ($period ? ' AND h.clock>' . (time() - $period) : '') . ' ORDER BY h.clock DESC', $limit));
if ($values) {
$rs[$item['itemid']] = $values;
}
}
return $rs;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:20,代码来源:CHistoryManager.php
示例15: add_expression
function add_expression($regexpid, $expression = array())
{
$db_fields = array('expression' => null, 'expression_type' => null, 'case_sensitive' => 0, 'exp_delimiter' => ',');
if (!check_db_fields($db_fields, $expression)) {
error('Incorrect arguments pasted to function [add_expression]');
return false;
}
$expressionid = get_dbid('expressions', 'expressionid');
$result = DBexecute('INSERT INTO expressions (expressionid,regexpid,expression,expression_type,case_sensitive,exp_delimiter) ' . ' VALUES (' . $expressionid . ',' . $regexpid . ',' . zbx_dbstr($expression['expression']) . ',' . $expression['expression_type'] . ',' . $expression['case_sensitive'] . ',' . zbx_dbstr($expression['exp_delimiter']) . ')');
return $result ? $expressionid : false;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:11,代码来源:regexp.inc.php
示例16: add_expression
function add_expression($regexpid, $expression = array())
{
$db_fields = array('expression' => null, 'expression_type' => null, 'case_sensitive' => 0, 'exp_delimiter' => ',');
if (!check_db_fields($db_fields, $expression)) {
error(S_INCORRECT_ARGUMENTS_PASSED_TO_FUNCTION . ' [add_expression]');
return false;
}
$expressionid = get_dbid('expressions', 'expressionid');
$result = DBexecute('INSERT INTO expressions (expressionid,regexpid,expression,expression_type,case_sensitive,exp_delimiter) ' . ' VALUES (' . $expressionid . ',' . $regexpid . ',' . zbx_dbstr($expression['expression']) . ',' . $expression['expression_type'] . ',' . $expression['case_sensitive'] . ',' . zbx_dbstr($expression['exp_delimiter']) . ')');
return $result ? $expressionid : false;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:11,代码来源:regexp.inc.php
示例17: checkDbVersionTable
/**
* Check if 'dbversion' table exists.
*
* @return boolean
*/
protected function checkDbVersionTable()
{
global $DB;
$tabSchema = zbx_dbstr(!empty($DB['SCHEMA']) ? $DB['SCHEMA'] : zbx_strtoupper($DB['USER']));
$tableExists = DBfetch(DBselect('SELECT 1 FROM SYSCAT.TABLES' . " WHERE TABNAME='DBVERSION'" . " AND TABSCHEMA=" . $tabSchema));
if (!$tableExists) {
$this->setError(_('The frontend does not match Zabbix database.'));
return false;
}
return true;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:16,代码来源:Db2DbBackend.php
示例18: getLast
/**
* Returns the last $limit history objects for the given items.
*
* @param array $items an array of items with the 'itemid' and 'value_type' properties
* @param int $limit
*
* @return array an array with items IDs as keys and arrays of history objects as values
*/
public function getLast(array $items, $limit = 1)
{
$rs = array();
foreach ($items as $item) {
$table = self::getTableName($item['value_type']);
$query = DBselect('SELECT *' . ' FROM ' . $table . ' h' . ' WHERE h.itemid=' . zbx_dbstr($item['itemid']) . ' ORDER BY h.clock DESC', $limit);
while ($history = DBfetch($query)) {
$rs[$history['itemid']][] = $history;
}
}
return $rs;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:20,代码来源:CHistoryManager.php
示例19: add_acknowledge_coment
function add_acknowledge_coment($eventid, $userid, $message)
{
$result = set_event_acnowledged($eventid);
if (!$result) {
return $result;
}
$acknowledgeid = get_dbid("acknowledges", "acknowledgeid");
$result = DBexecute("insert into acknowledges (acknowledgeid,userid,eventid,clock,message)" . " values ({$acknowledgeid},{$userid},{$eventid}," . time() . "," . zbx_dbstr($message) . ")");
if (!$result) {
return $result;
}
return $acknowledgeid;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:13,代码来源:acknow.inc.php
示例20: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$hostids = array();
$dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid']));
while ($dbHostGroup = DBfetch($dbHostGroups)) {
$hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid'];
}
// application filter
$applicationIds = null;
if ($this->screenitem['application'] !== '') {
$applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostids, 'search' => array('name' => $this->screenitem['application'])));
$applicationIds = zbx_objectValues($applications, 'applicationid');
}
return $this->getOutput(getItemsDataOverview($hostids, $applicationIds, $this->screenitem['style']));
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:20,代码来源:CScreenDataOverview.php
注:本文中的zbx_dbstr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论