本文整理汇总了PHP中get_dbid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dbid函数的具体用法?PHP get_dbid怎么用?PHP get_dbid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dbid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update_node_profile
function update_node_profile($nodeids)
{
DBstart();
DBexecute('DELETE FROM profiles WHERE userid=' . CWebUser::$data['userid'] . ' AND idx=' . zbx_dbstr('web.nodes.selected'));
foreach ($nodeids as $nodeid) {
DBexecute('INSERT INTO profiles (profileid,userid,idx,value_id,type)' . ' VALUES (' . get_dbid('profiles', 'profileid') . ',' . CWebUser::$data['userid'] . ',' . zbx_dbstr('web.nodes.selected') . ',' . $nodeid . ',4)');
}
DBend();
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:9,代码来源:nodes.inc.php
示例2: add_script
function add_script($name, $command, $usrgrpid, $groupid, $access)
{
$scriptid = get_dbid('scripts', 'scriptid');
$sql = 'INSERT INTO scripts (scriptid,name,command,usrgrpid,groupid,host_access) ' . " VALUES ({$scriptid}," . zbx_dbstr($name) . ',' . zbx_dbstr($command) . ",{$usrgrpid},{$groupid},{$access})";
$result = DBexecute($sql);
if ($result) {
$result = $scriptid;
}
return $result;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:10,代码来源:scripts.inc.php
示例3: 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
示例4: 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
示例5: add_user_to_group
function add_user_to_group($userid, $usrgrpid)
{
$result = false;
if (granted2move_user($userid, $usrgrpid)) {
DBexecute('DELETE FROM users_groups WHERE userid=' . zbx_dbstr($userid) . ' AND usrgrpid=' . zbx_dbstr($usrgrpid));
$users_groups_id = get_dbid('users_groups', 'id');
$result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES (' . $users_groups_id . ',' . zbx_dbstr($usrgrpid) . ',' . zbx_dbstr($userid) . ')');
} else {
error(_('User cannot change status of himself.'));
}
return $result;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:12,代码来源:users.inc.php
示例6: add_image
function add_image($name, $imagetype, $file)
{
if (!is_null($file)) {
if ($file["error"] != 0 || $file["size"] == 0) {
error("Incorrect Image");
} else {
if ($file["size"] < 1024 * 1024) {
global $DB;
$imageid = get_dbid("images", "imageid");
$image = fread(fopen($file["tmp_name"], "r"), filesize($file["tmp_name"]));
if ($DB['TYPE'] == "ORACLE") {
DBstart();
$lobimage = OCINewDescriptor($DB['DB'], OCI_D_LOB);
$stid = OCIParse($DB['DB'], "insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . ",EMPTY_BLOB())" . " return image into :image");
if (!$stid) {
$e = ocierror($stid);
error("Parse SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
return false;
}
OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
if (!OCIExecute($stid, OCI_DEFAULT)) {
$e = ocierror($stid);
error("Execute SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
return false;
}
$result = DBend($lobimage->save($image));
if (!$result) {
error("Couldn't save image!\n");
return false;
}
$lobimage->free();
OCIFreeStatement($stid);
return $stid;
} else {
if ($DB['TYPE'] == "POSTGRESQL") {
$image = pg_escape_bytea($image);
} else {
if ($DB['TYPE'] == "SQLITE3") {
$image = bin2hex($image);
}
}
}
return DBexecute("insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . "," . zbx_dbstr($image) . ")");
} else {
error("Image size must be less than 1Mb");
}
}
} else {
error("Select image to download");
}
return false;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:52,代码来源:images.inc.php
示例7: 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
示例8: update_node_profile
function update_node_profile($nodeids)
{
global $USER_DETAILS;
DBstart();
$sql = 'DELETE FROM profiles WHERE userid=' . $USER_DETAILS['userid'] . ' AND idx=' . zbx_dbstr('web.nodes.selected');
DBexecute($sql);
foreach ($nodeids as $nodeid) {
$profileid = get_dbid('profiles', 'profileid');
$sql = 'INSERT INTO profiles (profileid, userid, idx, value_id, type)' . ' VALUES (' . $profileid . ',' . $USER_DETAILS['userid'] . ', ' . zbx_dbstr('web.nodes.selected') . ',' . $nodeid . ', 4)';
DBexecute($sql);
}
DBend();
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:13,代码来源:nodes.inc.php
示例9: add
/**
* Adds favorite value to DB.
*
* @param string $idx identifier of favorite value group
* @param int $favid value id
* @param string $favobj source object
*
* @return bool did SQL INSERT succeeded
*/
public static function add($idx, $favid, $favobj = null)
{
if (self::exists($idx, $favid, $favobj)) {
return true;
}
// add to cache only if cache is created
if (isset(self::$cache[$idx])) {
self::$cache[$idx][] = array('value' => $favid, 'source' => $favobj);
}
$values = array('profileid' => get_dbid('profiles', 'profileid'), 'userid' => CWebUser::$data['userid'], 'idx' => zbx_dbstr($idx), 'value_id' => zbx_dbstr($favid), 'type' => PROFILE_TYPE_ID);
if (!is_null($favobj)) {
$values['source'] = zbx_dbstr($favobj);
}
return DBexecute('INSERT INTO profiles (' . implode(', ', array_keys($values)) . ')' . ' VALUES (' . implode(', ', $values) . ')');
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:24,代码来源:CFavorite.php
示例10: add_valuemap
function add_valuemap($name, $mappings)
{
if (!is_array($mappings)) {
return FALSE;
}
$valuemapid = get_dbid("valuemaps", "valuemapid");
$result = DBexecute("insert into valuemaps (valuemapid,name) values ({$valuemapid}," . zbx_dbstr($name) . ")");
if (!$result) {
return $result;
}
$result = add_mapping_to_valuemap($valuemapid, $mappings);
if (!$result) {
delete_valuemap($valuemapid);
} else {
$result = $valuemapid;
}
return $result;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:18,代码来源:valuemap.inc.php
示例11: add_service_alarm
function add_service_alarm($serviceid, $status, $clock)
{
if (latest_service_alarm($serviceid, $status)) {
return true;
}
$result = DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES (' . get_dbid('service_alarms', 'servicealarmid') . ',' . $serviceid . ',' . $clock . ',' . $status . ')');
return $result;
}
开发者ID:phedders,项目名称:zabbix,代码行数:8,代码来源:services.inc.php
示例12: update_slideshow
function update_slideshow($slideshowid, $name, $delay, $slides)
{
// validate slides
if (empty($slides)) {
error(_('Slide show must contain slides.'));
return false;
}
// validate screens
$screenids = zbx_objectValues($slides, 'screenid');
$screens = API::Screen()->get(array('screenids' => $screenids, 'output' => array('screenid')));
$screens = ZBX_toHash($screens, 'screenid');
foreach ($screenids as $screenid) {
if (!isset($screens[$screenid])) {
error(_('Incorrect screen provided for slide show.'));
return false;
}
}
// validate slide name
$db_slideshow = DBfetch(DBselect('SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.name=' . zbx_dbstr($name) . ' AND s.slideshowid<>' . zbx_dbstr($slideshowid) . ' ' . andDbNode('s.slideshowid')));
if (!empty($db_slideshow)) {
error(_s('Slide show "%s" already exists.', $name));
return false;
}
$db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid=' . zbx_dbstr($slideshowid)));
$db_slideshow = $db_slideshow[0];
$changed = false;
$slideshow = array('name' => $name, 'delay' => $delay);
foreach ($slideshow as $key => $val) {
if ($db_slideshow[$key] != $val) {
$changed = true;
break;
}
}
if ($changed) {
if (!($result = DBexecute('UPDATE slideshows SET name=' . zbx_dbstr($name) . ',delay=' . zbx_dbstr($delay) . ' WHERE slideshowid=' . zbx_dbstr($slideshowid)))) {
return false;
}
}
// get slides
$db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($slideshowid)), 'slideid');
$slidesToDel = zbx_objectValues($db_slides, 'slideid');
$slidesToDel = zbx_toHash($slidesToDel);
$step = 0;
foreach ($slides as $slide) {
$slide['delay'] = $slide['delay'] ? $slide['delay'] : 0;
if (isset($db_slides[$slide['slideid']])) {
// update slide
if ($db_slides[$slide['slideid']]['delay'] != $slide['delay'] || $db_slides[$slide['slideid']]['step'] != $step) {
$result = DBexecute('UPDATE slides SET step=' . zbx_dbstr($step) . ', delay=' . zbx_dbstr($slide['delay']) . ' WHERE slideid=' . zbx_dbstr($slide['slideid']));
} else {
$result = true;
}
unset($slidesToDel[$slide['slideid']]);
} else {
$slideid = get_dbid('slides', 'slideid');
$result = DBexecute('INSERT INTO slides (slideid,slideshowid,screenid,step,delay)' . ' VALUES (' . zbx_dbstr($slideid) . ',' . zbx_dbstr($slideshowid) . ',' . zbx_dbstr($slide['screenid']) . ',' . zbx_dbstr($step) . ',' . zbx_dbstr($slide['delay']) . ')');
}
$step++;
if (!$result) {
return false;
}
}
// delete unnecessary slides
if (!empty($slidesToDel)) {
DBexecute('DELETE FROM slides WHERE slideid IN(' . implode(',', $slidesToDel) . ')');
}
return true;
}
开发者ID:itnihao,项目名称:Zabbix_,代码行数:68,代码来源:screens.inc.php
示例13: insert_dependency
function insert_dependency($triggerid_down, $triggerid_up)
{
$triggerdepid = get_dbid("trigger_depends", "triggerdepid");
$result = DBexecute("insert into trigger_depends (triggerdepid,triggerid_down,triggerid_up)" . " values ({$triggerdepid},{$triggerid_down},{$triggerid_up})");
if (!$result) {
return $result;
}
return DBexecute("update triggers set dep_level=dep_level+1 where triggerid={$triggerid_up}");
}
开发者ID:rennhak,项目名称:zabbix,代码行数:9,代码来源:triggers.inc.php
示例14: create
/**
* Add images.
*
* @param array $images ['name' => string, 'image' => string, 'imagetype' => int]
*
* @return array
*/
public function create($images)
{
global $DB;
$images = zbx_toArray($images);
$this->validateCreate($images);
$imageids = array();
foreach ($images as $image) {
// decode BASE64
$image['image'] = base64_decode($image['image']);
// validate image (size and format)
$this->checkImage($image['image']);
$imageid = get_dbid('images', 'imageid');
$values = array('imageid' => $imageid, 'name' => zbx_dbstr($image['name']), 'imagetype' => zbx_dbstr($image['imagetype']));
switch ($DB['TYPE']) {
case ZBX_DB_ORACLE:
$values['image'] = 'EMPTY_BLOB()';
$lob = oci_new_descriptor($DB['DB'], OCI_D_LOB);
$sql = 'INSERT INTO images (' . implode(' ,', array_keys($values)) . ') VALUES (' . implode(',', $values) . ')' . ' returning image into :imgdata';
$stmt = oci_parse($DB['DB'], $sql);
if (!$stmt) {
$e = oci_error($DB['DB']);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Parse SQL error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
oci_bind_by_name($stmt, ':imgdata', $lob, -1, OCI_B_BLOB);
if (!oci_execute($stmt, OCI_DEFAULT)) {
$e = oci_error($stmt);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Execute SQL error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
if (!$lob->save($image['image'])) {
$e = oci_error($stmt);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Image load error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
$lob->free();
oci_free_statement($stmt);
break;
case ZBX_DB_DB2:
$stmt = db2_prepare($DB['DB'], 'INSERT INTO images (' . implode(' ,', array_keys($values)) . ',image)' . ' VALUES (' . implode(',', $values) . ', ?)');
if (!$stmt) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
$variable = $image['image'];
if (!db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN, DB2_BINARY)) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
if (!db2_execute($stmt)) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
break;
case ZBX_DB_SQLITE3:
$values['image'] = zbx_dbstr(bin2hex($image['image']));
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
case ZBX_DB_MYSQL:
$values['image'] = zbx_dbstr($image['image']);
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
case ZBX_DB_POSTGRESQL:
$values['image'] = "'" . pg_escape_bytea($image['image']) . "'";
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
}
$imageids[] = $imageid;
}
return array('imageids' => $imageids);
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:81,代码来源:CImage.php
示例15: add_action
function add_action($name, $eventsource, $esc_period, $def_shortdata, $def_longdata, $recovery_msg, $r_shortdata, $r_longdata, $evaltype, $status, $conditions, $operations)
{
if (!is_array($conditions) || count($conditions) == 0) {
/*
error(S_NO_CONDITIONS_DEFINED);
return false;
*/
} else {
if (!check_permission_for_action_conditions($conditions)) {
return false;
}
foreach ($conditions as $condition) {
if (!validate_condition($condition['type'], $condition['value'])) {
return false;
}
}
}
if (!is_array($operations) || count($operations) == 0) {
error(S_NO_OPERATIONS_DEFINED);
return false;
}
foreach ($operations as $operation) {
if (!validate_operation($operation)) {
return false;
}
}
$actionid = get_dbid('actions', 'actionid');
$result = DBexecute('INSERT INTO actions (actionid,name,eventsource,esc_period,def_shortdata,def_longdata,recovery_msg,r_shortdata,r_longdata,evaltype,status)' . ' VALUES (' . $actionid . ',' . zbx_dbstr($name) . ',' . $eventsource . ',' . $esc_period . ',' . zbx_dbstr($def_shortdata) . ',' . zbx_dbstr($def_longdata) . ',' . $recovery_msg . ',' . zbx_dbstr($r_shortdata) . ',' . zbx_dbstr($r_longdata) . ',' . $evaltype . ',' . $status . ')');
if (!$result) {
return $result;
}
foreach ($operations as $operation) {
if (!($result = add_action_operation($actionid, $operation))) {
break;
}
}
if ($result) {
foreach ($conditions as $condition) {
if (!($result = add_action_condition($actionid, $condition))) {
break;
}
}
}
return $actionid;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:45,代码来源:actions.inc.php
示例16: create
/**
* Add Template
*
* @param array $templates multidimensional array with templates data
* @param string $templates['host']
* @return boolean
*/
public function create($templates)
{
$templates = zbx_toArray($templates);
$templateids = array();
// CHECK IF HOSTS HAVE AT LEAST 1 GROUP {{{
foreach ($templates as $tnum => $template) {
if (empty($template['groups'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('No groups for template [ %s ]', $template['host']));
}
$templates[$tnum]['groups'] = zbx_toArray($templates[$tnum]['groups']);
foreach ($templates[$tnum]['groups'] as $gnum => $group) {
$groupids[$group['groupid']] = $group['groupid'];
}
}
// }}} CHECK IF HOSTS HAVE AT LEAST 1 GROUP
// PERMISSIONS {{{
$options = array('groupids' => $groupids, 'editable' => 1, 'preservekeys' => 1);
$updGroups = API::HostGroup()->get($options);
foreach ($groupids as $gnum => $groupid) {
if (!isset($updGroups[$groupid])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
}
}
// }}} PERMISSIONS
foreach ($templates as $tnum => $template) {
// If visible name is not given or empty it should be set to host name
if (!isset($template['name']) || isset($template['name']) && zbx_empty(trim($template['name']))) {
if (isset($template['host'])) {
$template['name'] = $template['host'];
}
}
$templateDbFields = array('host' => null);
if (!check_db_fields($templateDbFields, $template)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Field "host" is mandatory'));
}
if (!preg_match('/^' . ZBX_PREG_HOST_FORMAT . '$/', $template['host'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect characters used for Template name [ %1$s ]', $template['host']));
}
if (isset($template['host'])) {
if ($this->exists(array('host' => $template['host']))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Template "%s" already exists.', $template['host']));
}
if (API::Host()->exists(array('host' => $template['host']))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Host "%s" already exists.', $template['host']));
}
}
if (isset($template['name'])) {
if ($this->exists(array('name' => $template['name']))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Template with the same visible name "%s" already exists.', $template['name']));
}
if (API::Host()->exists(array('name' => $template['name']))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Host with the same visible name "%s" already exists.', $template['name']));
}
}
$templateid = DB::insert('hosts', array(array('host' => $template['host'], 'name' => $template['name'], 'status' => HOST_STATUS_TEMPLATE)));
$templateids[] = $templateid = reset($templateid);
foreach ($template['groups'] as $group) {
$hostgroupid = get_dbid('hosts_groups', 'hostgroupid');
$result = DBexecute('INSERT INTO hosts_groups (hostgroupid,hostid,groupid) VALUES (' . zbx_dbstr($hostgroupid) . ',' . zbx_dbstr($templateid) . ',' . zbx_dbstr($group['groupid']) . ')');
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
}
$template['templateid'] = $templateid;
$options = array();
$options['templates'] = $template;
if (isset($template['templates']) && !is_null($template['templates'])) {
$options['templates_link'] = $template['templates'];
}
if (isset($template['macros']) && !is_null($template['macros'])) {
$options['macros'] = $template['macros'];
}
if (isset($template['hosts']) && !is_null($template['hosts'])) {
$options['hosts'] = $template['hosts'];
}
$result = $this->massAdd($options);
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS);
}
}
return array('templateids' => $templateids);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:89,代码来源:CTemplate.php
示例17: add_discovery_rule
function add_discovery_rule($proxy_hostid, $name, $iprange, $delay, $status, $dchecks)
{
if (!validate_ip_range($iprange)) {
error('Incorrect IP range.');
return false;
}
$druleid = get_dbid('drules', 'druleid');
$result = DBexecute('insert into drules (druleid,proxy_hostid,name,iprange,delay,status) ' . ' values (' . $druleid . ',' . $proxy_hostid . ',' . zbx_dbstr($name) . ',' . zbx_dbstr($iprange) . ',' . $delay . ',' . $status . ')');
if ($result) {
if (isset($dchecks)) {
foreach ($dchecks as $val) {
add_discovery_check($druleid, $val['type'], $val['ports'], $val['key'], $val['snmp_community'], $val['snmpv3_securityname'], $val['snmpv3_securitylevel'], $val['snmpv3_authpassphrase'], $val['snmpv3_privpassphrase']);
}
}
$result = $druleid;
}
return $result;
}
开发者ID:phedders,项目名称:zabbix,代码行数:18,代码来源:discovery.inc.php
示例18: create
/**
* Add alerts
*
* @param _array $alerts multidimensional array with alerts data
* @param array $alerts[0,...]['expression']
* @param array $alerts[0,...]['description']
* @param array $alerts[0,...]['type'] OPTIONAL
* @param array $alerts[0,...]['priority'] OPTIONAL
* @param array $alerts[0,...]['status'] OPTIONAL
* @param array $alerts[0,...]['comments'] OPTIONAL
* @param array $alerts[0,...]['url'] OPTIONAL
* @return boolean
*/
public static function create($alerts)
{
$alerts = zbx_toArray($alerts);
$alertids = array();
$result = false;
self::BeginTransaction(__METHOD__);
foreach ($alerts as $anum => $alert) {
$alert_db_fields = array('actionid' => null, 'eventid' => null, 'userid' => null, 'clock' => time(), 'mediatypeid' => 0, 'sendto' => null, 'subject' => '', 'message' => '', 'status' => ALERT_STATUS_NOT_SENT, 'retries' => 0, 'error' => '', 'nextcheck' => null, 'esc_step' => 0, 'alerttype' => ALERT_TYPE_MESSAGE);
if (!check_db_fields($alert_db_fields, $alert)) {
$result = false;
break;
}
$alertid = get_dbid('alerts', 'alertid');
$sql = 'INSERT INTO alerts ' . '(alertid, actionid, eventid, userid, mediatypeid, clock, sendto, subject, message, status, retries, error, nextcheck, esc_step, alerttype) ' . ' VALUES (' . $alertid . ',' . $alert['actionid'] . ',' . $alert['eventid'] . ',' . $alert['userid'] . ',' . $alert['mediatypeid'] . ',' . $alert['clock'] . ',' . zbx_dbstr($alert['sendto']) . ',' . zbx_dbstr($alert['subject']) . ',' . zbx_dbstr($alert['message']) . ',' . $alert['status'] . ',' . $alert['retries'] . ',' . zbx_dbstr($alert['error']) . ',' . $alert['nextcheck'] . ',' . $alert['esc_step'] . ',' . $alert['alerttype'] . ' )';
$result = DBexecute($sql);
if (!$result) {
break;
}
$alertids[] = $alertid;
}
$result = self::EndTransaction($result, __METHOD__);
if ($result) {
return array('alertids' => $alertids);
} else {
self::$error[] = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal Zabbix error');
return false;
}
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:41,代码来源:class.calert.php
示例19: addUserHistory
function addUserHistory($title, $url)
{
$userId = CWebUser::$data['userid'];
$history5 = DBfetch(DBSelect('SELECT uh.title5,uh.url5' . ' FROM user_history uh' . ' WHERE uh.userid=' . $userId));
if ($history5) {
if ($history5['title5'] === $title) {
if ($history5['url5'] === $url) {
return true;
} else {
$sql = 'UPDATE user_history SET url5=' . zbx_dbstr($url) . ' WHERE userid=' . $userId;
}
} else {
$sql = 'UPDATE user_history' . ' SET title1=title2,' . ' url1=url2,' . ' title2=title3,' . ' url2=url3,' . ' title3=title4,' . ' url3=url4,' . ' title4=title5,' . ' url4=url5,' . ' title5=' . zbx_dbstr($title) . ',' . ' url5=' . zbx_dbstr($url) . ' WHERE userid=' . $userId;
}
} else {
$userHistoryId = get_dbid('user_history', 'userhistoryid');
$sql = 'INSERT INTO user_history (userhistoryid, userid, title5, url5)' . ' VALUES(' . $userHistoryId . ', ' . $userId . ', ' . zbx_dbstr($title) . ', ' . zbx_dbstr($url) . ')';
}
return DBexecute($sql);
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:20,代码来源:profiles.inc.php
示例20: create
/**
* Add template.
*
* @param array $templates
*
* @return array
*/
public function create(array $templates)
{
$templates = zbx_toArray($templates);
$this->validateCreate($templates);
$templateIds = array();
foreach ($templates as $key => $template) {
$templates[$key]['groups'] = zbx_toArray($template['groups']);
}
foreach ($templates as $template) {
// if visible name is not given or empty it should be set to host name
if ((!isset($template['name']) || zbx_empty(trim($template['name']))) && isset($template['host'])) {
$template['name'] = $template['host'];
}
$newTemplateIds = DB::insert('hosts', array(array('host' => $template['host'], 'name' => $template['name'], 'description' => isset($template['description']) ? $template['description'] : null, 'status' => HOST_STATUS_TEMPLATE)));
$templateId = reset($newTemplateIds);
$templateIds[] = $templateId;
foreach ($template['groups'] as $group) {
$hostGroupId = get_dbid('hosts_groups', 'hostgroupid');
$result = DBexecute('INSERT INTO hosts_groups (hostgroupid,hostid,groupid)' . ' VALUES (' . zbx_dbstr($hostGroupId) . ',' . zbx_dbstr($templateId) . ',' . zbx_dbstr($group['groupid']) . ')');
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot add group.'));
}
}
$template['templateid'] = $templateId;
$result = $this->massAdd(array('templates' => $template, 'templates_link' => isset($template['templates']) ? $template['templates'] : null, 'macros' => isset($template['macros']) ? $template['macros'] : null, 'hosts' => isset($template['hosts']) ? $template['hosts'] : null));
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot create template.'));
}
}
return array('templateids' => $templateIds);
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:38,代码来源:CTemplate.php
注:本文中的get_dbid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论