本文整理汇总了PHP中dbInsert函数的典型用法代码示例。如果您正苦于以下问题:PHP dbInsert函数的具体用法?PHP dbInsert怎么用?PHP dbInsert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbInsert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discover_wifi_radio
function discover_wifi_radio($device_id, $radio)
{
$params = array('radio_ap', 'radio_mib', 'radio_number', 'radio_type', 'radio_status', 'radio_clients', 'radio_txpower', 'radio_channel', 'radio_mac', 'radio_protection', 'radio_bsstype');
if (is_array($GLOBALS['cache']['wifi_radios'][$radio['radio_ap']][$radio['radio_number']])) {
$radio_db = $GLOBALS['cache']['wifi_radios'][$radio['radio_ap']][$radio['radio_number']];
}
if (!isset($radio_db['wifi_radio_id'])) {
$insert = array();
$insert['device_id'] = $device_id;
foreach ($params as $param) {
$insert[$param] = $radio[$param];
if ($radio[$param] == NULL) {
$insert[$param] = array('NULL');
}
}
$wifi_radio_id = dbInsert($insert, 'wifi_radios');
echo "+";
} else {
$update = array();
foreach ($params as $param) {
if ($radio[$param] != $radio_db[$param]) {
$update[$param] = $radio[$param];
}
}
if (count($update)) {
dbUpdate($update, 'wifi_radios', '`wifi_radio_id` = ?', array($radio_db['wifi_radio_id']));
echo 'U';
} else {
echo '.';
}
}
$GLOBALS['valid']['wifi']['radio'][$radio['radio_mib']][$wifi_radio_id] = 1;
// FIXME. What? How it passed there?
}
示例2: AddDeviceGroup
/**
* Add a new device group
* @param $pattern
* @param $name
* @param $desc
* @return int|string
*/
function AddDeviceGroup($name, $desc, $pattern)
{
$group_id = dbInsert(array('name' => $name, 'desc' => $desc, 'pattern' => $pattern), 'device_groups');
if ($group_id) {
UpdateDeviceGroup($group_id);
}
return $group_id;
}
示例3: adduser
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1', $description = "")
{
if (!user_exists($username)) {
$encrypted = crypt($password, '$1$' . generateSalt(8) . '$');
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description), 'users');
} else {
return FALSE;
}
}
示例4: adduser
function adduser($username, $password, $level, $email = '', $realname = '', $can_modify_passwd = '1')
{
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
} else {
return false;
}
}
示例5: add_service
function add_service($device, $type, $desc, $ip = 'localhost', $param = "", $ignore = 0)
{
if (!is_array($device)) {
$device = device_by_id_cache($device);
}
if (empty($ip)) {
$ip = $device['hostname'];
}
$insert = array('device_id' => $device['device_id'], 'service_ip' => $ip, 'service_type' => $type, 'service_changed' => array('UNIX_TIMESTAMP(NOW())'), 'service_desc' => $desc, 'service_param' => $param, 'service_ignore' => $ignore, 'service_status' => 3, 'service_message' => 'Service not yet checked');
return dbInsert($insert, 'services');
}
示例6: post_notifications
/**
* Post notifications to users
* @return null
*/
function post_notifications()
{
$notifs = get_notifications();
echo '[ ' . date('r') . ' ] Updating DB ';
foreach ($notifs as $notif) {
if (dbFetchCell('select 1 from notifications where checksum = ?', array($notif['checksum'])) != 1 && dbInsert('notifications', $notif) > 0) {
echo '.';
}
}
echo ' Done';
echo PHP_EOL;
}
示例7: ecError
function ecError($file, $error, $fatal = 0)
{
global $ecLocal, $ecUser;
$fatalMessage = $fatal == 1 ? 'Fatal error' : 'Skript Error';
$message = $fatalMessage . ' in file ' . $file . ': ' . $error;
array_push($ecLocal['errors'], $message);
if ($ecLocal['errorLog'] == 1) {
$insertData['errorsFatal'] = $fatal;
$insertData['errorsMessage'] = $error;
$insertData['errorsTimestamp'] = $ecLocal['timestamp'];
$insertData['errorsUserId'] = $ecUser['userId'];
$insertData['errorsUserIP'] = $ecLocal['userIP'];
$insertData['errorsFile'] = $file;
dbInsert(1, 'errors', $insertData);
}
}
示例8: adduser
function adduser($username, $level = 0, $email = '', $realname = '', $can_modify_passwd = 0, $description = '', $twofactor = 0)
{
// Check to see if user is already added in the database
if (!user_exists_in_db($username)) {
$userid = dbInsert(array('username' => $username, 'realname' => $realname, 'email' => $email, 'descr' => $description, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'twofactor' => $twofactor, 'user_id' => get_userid($username)), 'users');
if ($userid == false) {
return false;
} else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc', array($userid)) as $notif) {
dbInsert(array('notifications_id' => $notif['notifications_id'], 'user_id' => $userid, 'key' => 'read', 'value' => 1), 'notifications_attribs');
}
}
return $userid;
} else {
return false;
}
}
示例9: adduser
function adduser($username, $password, $level, $email = '', $realname = '', $can_modify_passwd = 1, $description = '', $twofactor = 0)
{
if (!user_exists($username)) {
$hasher = new PasswordHash(8, false);
$encrypted = $hasher->HashPassword($password);
$userid = dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
if ($userid == false) {
return false;
} else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc', array($userid)) as $notif) {
dbInsert(array('notifications_id' => $notif['notifications_id'], 'user_id' => $userid, 'key' => 'read', 'value' => 1), 'notifications_attribs');
}
}
return $userid;
} else {
return false;
}
}
示例10: process_port_adsl
function process_port_adsl(&$this_port, $device, $port)
{
// Check to make sure Port data is cached.
if (!isset($this_port['adslLineCoding'])) {
return;
}
// Used below for StatsD only
$adsl_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAtucChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate', 'adslAturChanCurrTxRate', 'adslAtucPerfLofs', 'adslAtucPerfLoss', 'adslAtucPerfLprs', 'adslAtucPerfESs', 'adslAtucPerfInits', 'adslAturPerfLofs', 'adslAturPerfLoss', 'adslAturPerfLprs', 'adslAturPerfESs', 'adslAtucChanCorrectedBlks', 'adslAtucChanUncorrectBlks', 'adslAturChanCorrectedBlks', 'adslAturChanUncorrectBlks');
$adsl_db_oids = array('adslLineCoding', 'adslLineType', 'adslAtucInvVendorID', 'adslAtucInvVersionNumber', 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAturInvSerialNumber', 'adslAturInvVendorID', 'adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate');
$adsl_tenth_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr');
foreach ($adsl_tenth_oids as $oid) {
if (isset($this_port[$oid])) {
$this_port[$oid] = $this_port[$oid] / 10;
}
}
if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])) == "0") {
dbInsert(array('port_id' => $port['port_id']), 'ports_adsl');
}
$adsl_update = array('port_adsl_updated' => array('NOW()'));
foreach ($adsl_db_oids as $oid) {
$adsl_update[$oid] = $this_port[$oid];
}
dbUpdate($adsl_update, 'ports_adsl', '`port_id` = ?', array($port['port_id']));
if ($this_port['adslAtucCurrSnrMgn'] > "1280") {
$this_port['adslAtucCurrSnrMgn'] = "U";
}
if ($this_port['adslAturCurrSnrMgn'] > "1280") {
$this_port['adslAturCurrSnrMgn'] = "U";
}
rrdtool_update_ng($device, 'port-adsl', array('AtucCurrSnrMgn' => $this_port['adslAtucCurrSnrMgn'], 'AtucCurrAtn' => $this_port['adslAtucCurrAtn'], 'AtucCurrOutputPwr' => $this_port['adslAtucCurrOutputPwr'], 'AtucCurrAttainableR' => $this_port['adslAtucCurrAttainableR'], 'AtucChanCurrTxRate' => $this_port['adslAtucChanCurrTxRate'], 'AturCurrSnrMgn' => $this_port['adslAturCurrSnrMgn'], 'AturCurrAtn' => $this_port['adslAturCurrAtn'], 'AturCurrOutputPwr' => $this_port['adslAturCurrOutputPwr'], 'AturCurrAttainableR' => $this_port['adslAturCurrAttainableR'], 'AturChanCurrTxRate' => $this_port['adslAturChanCurrTxRate'], 'AtucPerfLofs' => $this_port['adslAtucPerfLofs'], 'AtucPerfLoss' => $this_port['adslAtucPerfLoss'], 'AtucPerfLprs' => $this_port['adslAtucPerfLprs'], 'AtucPerfESs' => $this_port['adslAtucPerfESs'], 'AtucPerfInits' => $this_port['adslAtucPerfInits'], 'AturPerfLofs' => $this_port['adslAturPerfLofs'], 'AturPerfLoss' => $this_port['adslAturPerfLoss'], 'AturPerfLprs' => $this_port['adslAturPerfLprs'], 'AturPerfESs' => $this_port['adslAturPerfESs'], 'AtucChanCorrectedBl' => $this_port['adslAtucChanCorrectedBl'], 'AtucChanUncorrectBl' => $this_port['adslAtucChanUncorrectBl'], 'AturChanCorrectedBl' => $this_port['adslAturChanCorrectedBl'], 'AturChanUncorrectBl' => $this_port['adslAturChanUncorrectBl']), get_port_rrdindex($port));
if ($GLOBALS['config']['statsd']['enable']) {
foreach ($adsl_oids as $oid) {
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
}
}
//echo("ADSL (".$this_port['adslLineCoding']."/".formatRates($this_port['adslAtucChanCurrTxRate'])."/".formatRates($this_port['adslAturChanCurrTxRate']).")");
}
示例11: d_echo
d_echo(" numasoclients: {$numasoclients}\n");
d_echo(" interference: {$interference}\n");
// if there is a numeric channel, assume the rest of the data is valid, I guess
if (!is_numeric($channel)) {
continue;
}
$rrd_name = array('arubaap', $name . $radionum);
$rrd_def = array('DS:channel:GAUGE:600:0:200', 'DS:txpow:GAUGE:600:0:200', 'DS:radioutil:GAUGE:600:0:100', 'DS:nummonclients:GAUGE:600:0:500', 'DS:nummonbssid:GAUGE:600:0:200', 'DS:numasoclients:GAUGE:600:0:500', 'DS:interference:GAUGE:600:0:2000');
$fields = array('channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'nummonclients' => $nummonclients, 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference);
$tags = compact('name', 'radionum', 'rrd_name', 'rrd_def');
data_update($device, 'arubaap', $tags, $fields);
$foundid = 0;
for ($z = 0; $z < sizeof($ap_db); $z++) {
if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) {
$foundid = $ap_db[$z]['accesspoint_id'];
$ap_db[$z]['seen'] = 1;
continue;
}
}
if ($foundid == 0) {
$ap_id = dbInsert(array('device_id' => $device['device_id'], 'name' => $name, 'radio_number' => $radionum, 'type' => $type, 'mac_addr' => $mac, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points');
} else {
dbUpdate(array('mac_addr' => $mac, 'type' => $type, 'deleted' => 0, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points', '`accesspoint_id` = ?', array($foundid));
}
}
//end foreach
for ($z = 0; $z < sizeof($ap_db); $z++) {
if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) {
dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id']));
}
}
示例12: snmpwalk_cache_oid
<?php
$rserver_array = snmpwalk_cache_oid($device, 'cesServerFarmRserverTable', array(), 'CISCO-ENHANCED-SLB-MIB');
$rserver_db = dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ?', array($device['device_id']));
foreach ($rserver_db as $serverfarm) {
$serverfarms[$serverfarm['farm_id']] = $serverfarm;
}
foreach ($rserver_array as $index => $serverfarm) {
$farm_id = preg_replace('@\\d+\\."(.*?)"\\.\\d+@', '\\1', $index);
$oids = array('cesServerFarmRserverTotalConns', 'cesServerFarmRserverCurrentConns', 'cesServerFarmRserverFailedConns');
$db_oids = array($farm_id => 'farm_id', 'cesServerFarmRserverStateDescr' => 'StateDescr');
if (!is_array($serverfarms[$farm_id])) {
$rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $farm_id, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers');
} else {
foreach ($db_oids as $db_oid => $db_value) {
$db_update[$db_value] = $serverfarm[$db_oid];
}
$updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']);
}
$rrd_name = array('rserver', $serverfarms[$farm_id]['rserver_id']);
$rrd_def = array();
foreach ($oids as $oid) {
$oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, '');
$rrd_def[] = "DS:{$oid_ds}:GAUGE:600:-1:100000000";
}
$fields = array();
foreach ($oids as $oid) {
if (is_numeric($serverfarm[$oid])) {
$value = $serverfarm[$oid];
} else {
$value = '0';
示例13: add_edit_rule
function add_edit_rule()
{
global $config;
$app = \Slim\Slim::getInstance();
$data = json_decode(file_get_contents('php://input'), true);
$status = 'error';
$message = '';
$code = 500;
$rule_id = mres($data['rule_id']);
$device_id = mres($data['device_id']);
if (empty($device_id) && !isset($rule_id)) {
$message = 'Missing the device id or global device id (-1)';
} elseif ($device_id == 0) {
$device_id = '-1';
}
$rule = $data['rule'];
if (empty($rule)) {
$message = 'Missing the alert rule';
}
$name = mres($data['name']);
if (empty($name)) {
$message = 'Missing the alert rule name';
}
$severity = mres($data['severity']);
$sevs = array('ok', 'warning', 'critical');
if (!in_array($severity, $sevs)) {
$message = 'Missing the severity';
}
$disabled = mres($data['disabled']);
if ($disabled != '0' && $disabled != '1') {
$disabled = 0;
}
$count = mres($data['count']);
$mute = mres($data['mute']);
$delay = mres($data['delay']);
$delay_sec = convert_delay($delay);
if ($mute == 1) {
$mute = true;
} else {
$mute = false;
}
$extra = array('mute' => $mute, 'count' => $count, 'delay' => $delay_sec);
$extra_json = json_encode($extra);
if (dbFetchCell('SELECT `name` FROM `alert_rules` WHERE `name`=?', array($name)) == $name) {
$message = 'Name has already been used';
}
if (empty($message)) {
if (is_numeric($rule_id)) {
if (dbUpdate(array('name' => $name, 'rule' => $rule, 'severity' => $severity, 'disabled' => $disabled, 'extra' => $extra_json), 'alert_rules', 'id=?', array($rule_id)) >= 0) {
$status = 'ok';
$code = 200;
} else {
$message = 'Failed to update existing alert rule';
}
} elseif (dbInsert(array('name' => $name, 'device_id' => $device_id, 'rule' => $rule, 'severity' => $severity, 'disabled' => $disabled, 'extra' => $extra_json), 'alert_rules')) {
$status = 'ok';
$code = 200;
} else {
$message = 'Failed to create new alert rule';
}
}
$output = array('status' => $status, 'err-msg' => $message);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例14: RunRules
/**
* Run all rules for a device
* @param int $device Device-ID
* @return void
*/
function RunRules($device)
{
global $debug;
$chk = dbFetchRow("SELECT id FROM alert_schedule WHERE alert_schedule.device_id = ? AND NOW() BETWEEN alert_schedule.start AND alert_schedule.end", array($device));
if ($chk['id'] > 0) {
return false;
}
foreach (dbFetchRows("SELECT * FROM alert_rules WHERE alert_rules.disabled = 0 && ( alert_rules.device_id = -1 || alert_rules.device_id = ? ) ORDER BY device_id,id", array($device)) as $rule) {
echo " #" . $rule['id'] . ":";
$chk = dbFetchRow("SELECT state FROM alerts WHERE rule_id = ? && device_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'], $device));
$sql = GenSQL($rule['rule']);
$qry = dbFetchRows($sql, array($device));
if (sizeof($qry) > 0) {
if ($chk['state'] === "2") {
echo " SKIP ";
} elseif ($chk['state'] === "1") {
echo " NOCHG ";
} else {
$extra = gzcompress(json_encode(array('contacts' => GetContacts($qry), 'rule' => $qry)), 9);
if (dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'details' => $extra), 'alert_log')) {
if (!dbUpdate(array('state' => 1, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device, $rule['id']))) {
dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1), 'alerts');
}
echo " ALERT ";
}
}
} else {
if ($chk['state'] === "0") {
echo " NOCHG ";
} else {
if (dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id']), 'alert_log')) {
if (!dbUpdate(array('state' => 0, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device, $rule['id']))) {
dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1), 'alerts');
}
echo " OK ";
}
}
}
}
}
示例15: dbDelete
dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']));
}
}
if ($vars['action'] == "addifperm") {
if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) {
dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms');
}
}
if ($vars['action'] == "delbillperm") {
if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) {
dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']));
}
}
if ($vars['action'] == "addbillperm") {
if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) {
dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms');
}
}
echo '<div class="row">
<div class="col-md-4">';
// Display devices this users has access to
echo "<h3>Device Access</h3>";
echo "<div class='panel panel-default panel-condensed'>\n <table class='table table-hover table-condensed table-striped'>\n <tr>\n <th>Device</th>\n <th>Action</th>\n </tr>";
$device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id']));
foreach ($device_perms as $device_perm) {
echo "<tr><td><strong>" . $device_perm['hostname'] . "</td><td> <a href='edituser/action=deldevperm/user_id=" . $vars['user_id'] . "/device_id=" . $device_perm['device_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></strong></td></tr>";
$access_list[] = $device_perm['device_id'];
$permdone = "yes";
}
echo "</table>\n </div>";
if (!$permdone) {