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? }
function edit_service($update = array(), $service = null) { if (!is_numeric($service)) { return false; } return dbUpdate($update, 'services', '`service_id`=?', array($service)); }
function mergeCart($usr) { require "mysql.php"; require "../../library/connect.php"; $conn = server_connect(); //if there are items in the cart add them to the data base if (isset($_SESSION['cart'])) { $cart = $_SESSION['cart']; foreach ($cart as $item_id => $quantity) { $query = "INSERT INTO cart (user_id, item_id, quantity) VALUES ({$usr}, {$item_id}, {$quantity}) ON DUPLICATE KEY UPDATE quantity = {$quantity} "; dbUpdate($query); } } $cart = array(); $query = "SELECT item_id, quantity FROM cart WHERE user_id = {$usr}"; $result = mysqli_query($conn, $query); if ($result) { while ($row = mysqli_fetch_assoc($result)) { $cart[$row["item_id"]] = $row["quantity"]; } $_SESSION['cart'] = $cart; } else { $_SESSION['log'] .= mysqli_error($conn); } }
function thumbnailForm_submit($form, $form_state) { $params = drupal_get_query_parameters(); // getting the inputted info from the fields $fields = array("FID"); $picData = getFields($fields, $form_state['values']); $picData = stripTags($picData, ''); $oldFID = isset($form_state['oldFID']) ? $form_state['oldFID'] : 0; if (isset($params["UID"])) { // if updating user's profile picture $UID = $params["UID"]; replacePicture($picData['FID'], $oldFID, 'Users'); dbUpdate("profiles", $picData, "UID", $UID); drupal_goto("viewUser", array('query' => array('UID' => $UID))); } else { if (isset($params["OID"])) { // if editing outreach thumbnail $OID = $params["OID"]; replacePicture($picData['FID'], $oldFID, 'Outreach'); dbUpdateOutreach($OID, $picData); drupal_goto("viewOutreach", array('query' => array('OID' => $OID))); } else { if (isset($params["TID"])) { // if editing team thumbnail $TID = $params["TID"]; replacePicture($picData['FID'], $oldFID, 'Teams'); dbUpdateTeam($TID, $picData); drupal_goto("viewTeam", array('query' => array('TID' => $TID))); } else { drupal_goto("myDashboard"); } } } }
function loginCheck() { $user = gpost('uname'); $pass = md5(gpost('passwd')); $t = mysql_query("SELECT * FROM admin WHERE uname='{$uname}' AND passwd='{$passwd}'"); if (mysql_num_rows($t) == 1) { $r = mysql_fetch_array($t); if ($r['app'] == APID || $r['level'] == 1) { $_SESSION[ASID . 'admin_id'] = $r['replid']; $_SESSION[ASID . 'admin_name'] = $r['nama']; $_SESSION[ASID . 'admin_uname'] = $r['uname']; $_SESSION[ASID . 'admin_level'] = $r['level']; $_SESSION[ASID . 'admin_dept'] = $r['departemen']; $_SESSION[ASID . 'admin_pegawai'] = $r['pegawai']; $_SESSION[ASID . 'admin_bahasa'] = $r['bahasa']; dbUpdate("admin", array('tlogin' => date("Y-m-d H:i:s")), "replid='" . $r['replid'] . "'"); echo $r['nama']; } else { echo "0"; //echo $r['nama']; } } else { //echo $r['nama']; echo "0"; } }
function userStoreData(&$session, $isnew, $id) { $session->trace(TC_Gui3, 'forum.UserStoreData'); if ($_POST['forum_postingsperpage'] <= 0) { $_POST['forum_postingsperpage'] = 10; } if ($_POST['forum_threadsperpage'] <= 0) { $_POST['forum_threadsperpage'] = 10; } dbUpdate($session, T_User, $id, 'postingsperpage=' . $_POST['forum_postingsperpage'] . ',threadsperpage=' . $_POST['forum_threadsperpage'] . ','); }
/** * Update a device group * @param $group_id * @param $pattern * @param $name * @param $desc * @return bool */ function EditDeviceGroup($group_id, $name = null, $desc = null, $pattern = null) { $vars = array(); if (!is_null($name)) { $vars['name'] = $name; } if (!is_null($desc)) { $vars['desc'] = $desc; } if (!is_null($pattern)) { $vars['pattern'] = $pattern; } $success = dbUpdate($vars, 'device_groups', 'id=?', array($group_id)) >= 0; if ($success) { UpdateDeviceGroup($group_id); } return $success; }
function main() { if (array_key_exists("CID", $_GET)) { $CID = $_GET["CID"]; } else { print_r("ERROR: CID NOT FOUND"); $CID = 1; } if (!array_key_exists("customerForm", $_GET)) { $data = takeCustomerFromDataBase($CID); showCustomerForm($data, "", array()); // sends an empty array as the badFields } else { $badFields = customerValidate($_GET); // checks to make sure the info given is complete if (count($badFields) != 0) { showCustomerForm($_GET, "", $badFields); } else { // at this point we have good data, and just need to get it into the // database. Before we do it, get the OID from the form data so we // know whether we need to go back to the orders page or customer page $OID = NULL; if (array_key_exists("OID", $_GET)) { $OID = $_GET["OID"]; } $customer = formatForDataBase($_GET); $CID = dbUpdate("customers", $customer, "CID", $CID); // get the configuration information from the Wordpress page so we know where // our target "return to" pages are $config = getConfigData(); $backToOrder = getSpecialVariable("backToOrder", $config); $backToCustomer = getSpecialVariable("backToCustomer", $config); if ($OID) { // came from order backToWPPage($backToOrder, "oid={$OID}"); } else { // otherwise from a customer edit backToWPPage($backToCustomer, "CID={$CID}"); } } } }
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']).")"); }
foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool) { echo "Mempool " . $mempool['mempool_descr'] . ": "; $mempool_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd"); $file = $config['install_dir'] . "/includes/polling/mempools/" . $mempool['mempool_type'] . ".inc.php"; if (is_file($file)) { include $file; } else { // Do we need a generic mempool poller? } if ($mempool['total']) { $percent = round($mempool['used'] / $mempool['total'] * 100, 2); } else { $percent = 0; } echo $percent . "% "; if (!is_file($mempool_rrd)) { rrdtool_create($mempool_rrd, "--step 300 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U " . $config['rrd_rra']); } rrdtool_update($mempool_rrd, "N:" . $mempool['used'] . ":" . $mempool['free']); $mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']); if ($config['memcached']['enable']) { if ($debug) { print_r($mempool['state']); } $memcache->set('mempool-' . $mempool['mempool_id'] . '-value', $mempool['state']); } else { dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id'])); } echo "\n"; } unset($mempool_cache);
function unmute_alert() { global $config; $app = \Slim\Slim::getInstance(); $router = $app->router()->getCurrentRoute()->getParams(); $alert_id = mres($router['id']); $status = 'error'; $err_msg = ''; $message = ''; $code = 500; if (is_numeric($alert_id)) { $status = 'ok'; $code = 200; if (dbUpdate(array('state' => 1), 'alerts', '`id` = ? LIMIT 1', array($alert_id))) { $message = 'Alert has been unmuted'; } else { $message = 'No alert by that ID'; } } else { $err_msg = 'Invalid alert has been provided'; } $output = array('status' => $status, 'err-msg' => $err_msg, 'message' => $message); $app->response->setStatus($code); $app->response->headers->set('Content-Type', 'application/json'); echo _json_encode($output); }
/** * 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 "; } } } } }
function renamehost($id, $new, $source = 'console') { global $config; // FIXME does not check if destination exists! $host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id)); if (rename($config['rrd_dir'] . "/{$host}", $config['rrd_dir'] . "/{$new}") === TRUE) { dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id)); log_event("Hostname changed -> {$new} ({$source})", $id, 'system'); } else { echo "Renaming of {$host} failed\n"; log_event("Renaming of {$host} failed", $id, 'system'); } }
//db operation : add , update, delete $q = false; if ($opt == 'a') { // add $q = dbInsert($dbtable, $inp); $y = mysql_query("SELECT * FROM admin WHERE pegawai='" . $inp['pegawai'] . "'"); // $y=mysql_query("SELECT * FROM admin WHERE pegawai='".$inp['pegawai']."'"); if (mysql_num_rows($y) == 0) { $y = mysql_query("SELECT hrd_pegawai.nip,hrd_pegawai.nama FROM hrd_pegawai WHERE hrd_pegawai.replid='" . $inp['pegawai'] . "'"); $u = mysql_fetch_array($y); $q = mysql_query("INSERT INTO admin SET app='gur', nama='" . $u['nama'] . "', uname='" . $u['nip'] . "', passwd='" . md5('admin') . "', pegawai='" . $inp['pegawai'] . "', level='2'"); } } else { if ($opt == 'u') { // edit $q = dbUpdate($dbtable, $inp, "replid='{$cid}'"); } else { if ($opt == 'd') { // delete $t = mysql_query("SELECT pegawai FROM aka_guru WHERE replid='{$cid}'"); $r = mysql_fetch_array($t); $q = dbDel($dbtable, "replid='{$cid}'"); $q &= dbDel("admin", "pegawai='" . $r['pegawai'] . "'"); } } } $fform->notif($q); } else { // form process if ($opt == 'uf' || $opt == 'df') { // db operation for form : update , delete
if ($_SESSION['userlevel'] >= '10') { // Scan for new plugins and add to the database $new_plugins = scan_new_plugins(); // Check if we have to toggle enabled / disable a particular module $plugin_id = $_POST['plugin_id']; $plugin_active = $_POST['plugin_active']; if (is_numeric($plugin_id) && is_numeric($plugin_active)) { if ($plugin_active == '0') { $plugin_active = 1; } elseif ($plugin_active == '1') { $plugin_active = 0; } else { $plugin_active = 0; } if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { echo ' <script type="text/javascript"> $.ajax({ url: "", context: document.body, success: function(s,x){ $(this).html(s); } }); </script> '; } } //end if ?>
function set_config_name($name, $config_value) { return dbUpdate(array('config_value' => $config_value), 'config', '`config_name`=?', array($name)); }
} echo "VLAN {$vlan_id} \n"; if ($vlan_data) { echo str_pad("dot1d id", 10) . str_pad("ifIndex", 10) . str_pad("Port Name", 25) . str_pad("Priority", 10) . str_pad("State", 15) . str_pad("Cost", 10) . "\n"; } foreach ($vlan_data as $vlan_port_id => $vlan_port) { $port = get_port_by_index_cache($device, $vlan_port['dot1dBasePortIfIndex']); echo str_pad($vlan_port_id, 10) . str_pad($vlan_port['dot1dBasePortIfIndex'], 10) . str_pad($port['ifDescr'], 25) . str_pad($vlan_port['dot1dStpPortPriority'], 10) . str_pad($vlan_port['dot1dStpPortState'], 15) . str_pad($vlan_port['dot1dStpPortPathCost'], 10); $db_w = array('device_id' => $device['device_id'], 'port_id' => $port['port_id'], 'vlan' => $vlan_id); $db_a['baseport'] = $vlan_port_id; $db_a['priority'] = isset($vlan_port['dot1dStpPortPriority']) ? $vlan_port['dot1dStpPortPriority'] : 0; $db_a['state'] = isset($vlan_port['dot1dStpPortState']) ? $vlan_port['dot1dStpPortState'] : "unknown"; $db_a['cost'] = isset($vlan_port['dot1dStpPortPathCost']) ? $vlan_port['dot1dStpPortPathCost'] : 0; $from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?", array($device['device_id'], $port['port_id'], $vlan_id)); if ($from_db['port_vlan_id']) { dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", array($from_db['port_vlan_id'])); echo "Updated"; } else { dbInsert(array_merge($db_w, $db_a), 'ports_vlans'); echo "Inserted"; } echo "\n"; } } } } foreach ($vlans_db as $domain_id => $vlans) { foreach ($vlans as $vlan_id => $vlan) { if (empty($device['vlans'][$domain_id][$vlan_id])) { dbDelete('vlans', "`device_id` = ? AND vlan_domain = ? AND vlan_vlan = ?", array($device['device_id'], $domain_id, $vlan_id)); }
$data=array('kodelokasi'=>$inp['lokasi'],'kodetingkat'=>$inp['tingkatbuku'],'sumber'=>$inp['sumber']); for($i=0;$i<$nunit;$i++){ $inp['urut']=buku_getlasturut()+1; $data['nomorauto']=$inp['urut']; $inp['idbuku']=buku_makeid($data); $inp['barkode']=buku_makebarkode($data);; $q=dbInsert($dbtable,$inp); } } else { $inp['urut']=buku_getlasturut()+1; $q=dbInsert($dbtable,$inp); } //log_print($_SESSION['libdb_dbIsert']); } else if($opt=='u') { // edit $q=dbUpdate($dbtable,$inp,"replid='$cid'"); } else if($opt=='d'){ // delete $q=dbDel($dbtable,"replid='$cid'"); $q=dbDel("pus_peminjaman","buku='$cid'"); } $fform->notif($q); } else { if($opt=='uf'||$opt=='df'){ // Prepocessing form $r=dbSFA("*",$dbtable,"W/replid='$cid'"); $tk=mysql_query("SELECT judul,klasifikasi,pengarang FROM pus_katalog WHERE replid='".$r['katalog']."'"); $rk=mysql_fetch_array($tk); $lok=$r['lokasi']; $sat=$r['satuan']; $tingb=$r['tingkatbuku'];
foreach ($extras as $option) { list($k, $v) = explode('=', $option, 2); if (!empty($k) || !empty($v)) { dbInsert(array('config_name' => 'alert.transports.boxcar.' . $config_id . '.' . $k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Boxcar ' . $v), 'config'); } } } else { $message = 'Could not create config item'; } } } else { if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) { $message = 'Missing config name or value'; } else { $config_id = dbInsert(array('config_name' => $config_name, 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'API Transport'), 'config'); if ($config_id > 0) { dbUpdate(array('config_name' => $config_name . $config_id), 'config', 'config_id=?', array($config_id)); $status = 'ok'; $message = 'Config item created'; } else { $message = 'Could not create config item'; } } } } } } } //end if $response = array('status' => $status, 'message' => $message, 'config_id' => $config_id, 'additional_id' => $additional_id); echo _json_encode($response);
/* * Code for Gridster.sort_by_row_and_col_asc(serialization) call is from http://gridster.net/demos/grid-from-serialize.html */ $no_refresh = true; $default_dash = 0; $tmp = dbFetchCell('SELECT dashboard FROM users WHERE user_id=?', array($_SESSION['user_id'])); if ($tmp != 0) { $default_dash = $tmp; } elseif ((int) $config['webui']['default_dashboard_id']) { // if the user hasn't set their default page, and there is a global default set $default_dash = dbFetchCell('SELECT `dashboard_id` FROM `dashboards` WHERE `dashboard_id` = ?', array((int) $config['webui']['default_dashboard_id'])); } if ($default_dash == 0 && dbFetchCell('SELECT dashboard_id FROM dashboards WHERE user_id=?', array($_SESSION['user_id'])) == 0) { $vars['dashboard'] = dbInsert(array('dashboard_name' => 'Default', 'user_id' => $_SESSION['user_id']), 'dashboards'); if (dbFetchCell('select 1 from users_widgets where user_id = ? && dashboard_id = ?', array($_SESSION['user_id'], 0)) == 1) { dbUpdate(array('dashboard_id' => $vars['dashboard']), 'users_widgets', 'user_id = ? && dashboard_id = ?', array($_SESSION['user_id'], 0)); } } if (!empty($vars['dashboard'])) { $orig = $vars['dashboard']; $vars['dashboard'] = dbFetchRow('select * from dashboards where user_id = ? && dashboard_id = ? order by dashboard_id limit 1', array($_SESSION['user_id'], $vars['dashboard'])); if (empty($vars['dashboard'])) { $vars['dashboard'] = dbFetchRow('select dashboards.*,users.username from dashboards inner join users on dashboards.user_id = users.user_id where dashboards.dashboard_id = ? && dashboards.access > 0', array($orig)); } } if (empty($vars['dashboard'])) { if ($default_dash != 0) { $vars['dashboard'] = dbFetchRow('select dashboards.*,users.username from dashboards inner join users on dashboards.user_id = users.user_id where dashboards.dashboard_id = ?', array($default_dash)); } else { $vars['dashboard'] = dbFetchRow('select * from dashboards where user_id = ? order by dashboard_id limit 1', array($_SESSION['user_id'])); }
if (empty($vars['new_email'])) { $vars['new_email'] = $users_details['email']; } if ($config['twofactor']) { if ($vars['twofactorremove']) { if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { echo "<div class='alert alert-success'>TwoFactor credentials removed.</div>"; } else { echo "<div class='alert alert-danger'>Couldnt remove user's TwoFactor credentials.</div>"; } } if ($vars['twofactorunlock']) { $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?", array($vars['user_id'])); $twofactor = json_decode($twofactor['twofactor'], true); $twofactor['fails'] = 0; if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { echo "<div class='alert alert-success'>User unlocked.</div>"; } else { echo "<div class='alert alert-danger'>Couldnt reset user's TwoFactor failures.</div>"; } } } echo "<form class='form-horizontal' role='form' method='post' action=''>\n <input type='hidden' name='user_id' value='" . $vars['user_id'] . "'>\n <input type='hidden' name='edit' value='yes'>\n <div class='form-group'>\n <label for='new_realname' class='col-sm-2 control-label'>Realname</label>\n <div class='col-sm-4'>\n <input name='new_realname' class='form-control input-sm' value='" . $vars['new_realname'] . "'>\n </div>\n <div class='col-sm-6'>\n </div>\n </div>\n <div class='form-group'>\n <label for='new_email' class='col-sm-2 control-label'>Email</label>\n <div class='col-sm-4'>\n <input name='new_email' class='form-control input-sm' value='" . $vars['new_email'] . "'>\n </div>\n <div class='col-sm-6'>\n </div>\n </div>\n <div class='form-group'>\n <label for='new_level' class='col-sm-2 control-label'>Level</label>\n <div class='col-sm-4'>\n <select name='new_level' class='form-control input-sm'>\n <option value='1'"; if ($vars['new_level'] == '1') { echo "selected"; } echo ">Normal User</option>\n <option value='5'"; if ($vars['new_level'] == '5') { echo "selected"; } echo ">Global Read</option>\n <option value='10'";
$interface = dbFetchRow('SELECT ifDescr, port_id FROM ports WHERE ifIndex = ? AND device_id = ?', array($if_id, $device['device_id'])); echo short_ifname($interface['ifDescr']) . " "; dbUpdate(array('ifVrf' => $vrf_id), 'ports', '`port_id` = ?', array($interface['port_id'])); $if = $interface['port_id']; $valid_vrf_if[$vrf_id][$if] = 1; } } } echo "\n"; foreach (dbFetchRows('SELECT * FROM ports WHERE device_id = ?', array($device['device_id'])) as $row) { $if = $row['port_id']; $vrf_id = $row['ifVrf']; if ($row['ifVrf']) { if (!$valid_vrf_if[$vrf_id][$if]) { echo "-"; dbUpdate(array('ifVrf' => NULL), 'ports', '`port_id` = ?', array($if)); } else { echo "."; } } } foreach (dbFetchRows('SELECT * FROM vrfs WHERE device_id = ?', array($device['device_id'])) as $row) { $vrf_id = $row['vrf_id']; if (!$valid_vrf[$vrf_id]) { echo "-"; dbDelete('vrfs', '`vrf_id` = ?', array($vrf_id)); } else { echo "."; } } unset($valid_vrf_if);
* */ print_message("This page allows you to disable or enable certain Graphs detected for a device."); $graphs_db = array(); foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry) { $graph = $entry['graph']; $section = $config['graph_types']['device'][$graph]['section']; $graphs_db[$graph] = (bool) $entry['enabled']; // Another array sorted by sections $graphs_sections[$section][$graph] = (bool) $entry['enabled']; } $graph = $_POST['toggle_graph']; if ($graph && isset($graphs_db[$graph]) && !in_array($config['graph_types']['device'][$graph]['section'], array('poller', 'system'))) { $value = (int) (!$graphs_db[$graph]); // Toggle current 'enabled' value $updated = dbUpdate(array('enabled' => $value), 'device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph)); if ($updated) { print_success("Graph '{$graph}' " . ($value ? 'enabled' : 'disabled') . '.'); $graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool) $value; } } ?> <div class="row"> <!-- begin row --> <div class="col-md-6"> <!-- begin poller options --> <fieldset> <legend>Device Graphs</legend> </fieldset>
$rows_updated = -1; break; } $rows_updated += $n; } else { if (strncmp($key, 'olddis_', 7) == 0) { // Interface identifier passed as part of the field name $port_id = intval(substr($key, 7)); $olddis = intval($val) ? 1 : 0; $newdis = $_POST['disabled_' . $port_id] ? 1 : 0; // As checkboxes are not posted when unset - we effectively need to do a diff to work // out a set->unset case. if ($olddis == $newdis) { continue; } $n = dbUpdate(array('disabled' => $newdis), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id)); if ($n < 0) { $rows_updated = -1; break; } $rows_updated += $n; } } //end if } //end foreach if ($rows_updated > 0) { $message = $rows_updated . ' Device record updated.'; $status = 'ok'; } else { if ($rows_updated = '-1') {
} if ($device['override_sysLocation'] != $override_sysLocation_bool || $device['location'] != $override_sysLocation_string) { $updated = 1; } if ($override_sysLocation_bool) { $override_sysLocation = 1; } else { $override_sysLocation = 0; } dbUpdate(array('override_sysLocation' => $override_sysLocation), 'devices', '`device_id`=?', array($device['device_id'])); if (isset($override_sysLocation_string)) { dbUpdate(array('location' => $override_sysLocation_string), 'devices', '`device_id`=?', array($device['device_id'])); } #FIXME needs more sanity checking! and better feedback $param = array('purpose' => $_POST['descr'], 'type' => $_POST['type'], 'ignore' => $_POST['ignore'], 'disabled' => $_POST['disabled']); $rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id'])); if ($rows_updated > 0 || $updated) { $update_message = "Device record updated."; $updated = 1; $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); } elseif ($rows_updated = '-1') { $update_message = "Device record unchanged. No update necessary."; $updated = -1; } else { $update_message = "Device record update error."; } } else { include 'includes/error-no-perm.inc.php'; } } $descr = $device['purpose'];
$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'; } $fields[$oid] = $value;
unset($j_prefixes); unset($j_bgp); unset($j_peerIndexes); } //end if // FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE! $update = 'UPDATE bgpPeers_cbgp SET'; $peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes; $peer['c_update']['DeniedPrefixes'] = $cbgpPeerDeniedPrefixes; $peer['c_update']['PrefixAdminLimit'] = $cbgpPeerAdminLimit; $peer['c_update']['PrefixThreshold'] = $cbgpPeerPrefixThreshold; $peer['c_update']['PrefixClearThreshold'] = $cbgpPeerPrefixClearThreshold; $peer['c_update']['AdvertisedPrefixes'] = $cbgpPeerAdvertisedPrefixes; $peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes; $peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes; dbUpdate($peer['c_update'], 'bgpPeers_cbgp', '`device_id` = ? AND bgpPeerIdentifier = ? AND afi = ? AND safi = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $afi, $safi)); $cbgp_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cbgp-' . $peer['bgpPeerIdentifier'] . ".{$afi}.{$safi}.rrd"); if (!is_file($cbgp_rrd)) { $rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000 DS:DeniedPrefixes:GAUGE:600:U:100000000000 DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 DS:SuppressedPrefixes:GAUGE:600:U:100000000000 DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 ' . $config['rrd_rra']; rrdtool_create($cbgp_rrd, $rrd_create); } $fields = array('AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes, 'DeniedPrefixes' => $cbgpPeerDeniedPrefixes, 'AdvertisedPrefixes' => $cbgpPeerAdvertisedPrefixes, 'SuppressedPrefixes' => $cbgpPeerSuppressedPrefixes, 'WithdrawnPrefixes' => $cbgpPeerWithdrawnPrefixes); rrdtool_update("{$cbgp_rrd}", $fields); } //end foreach } //end if
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'])); } }
$raw_mac = $data['ipNetToMediaPhysAddress']; list($if, $ip) = explode('.', $ip, 2); $ipv = 'ipv4'; } $interface = get_port_by_index_cache($device['device_id'], $if); $port_id = $interface['port_id']; if (!empty($ip) && $ipv === 'ipv4' && $raw_mac != '0:0:0:0:0:0' && !isset($arp_table[$port_id][$ip])) { $mac = implode(array_map('zeropad', explode(':', $raw_mac))); $arp_table[$port_id][$ip] = $mac; $index = array_search($ip, $ipv4_addresses); if ($index !== false) { $old_mac = $existing_data[$index]['mac_address']; if ($mac != $old_mac && $mac != '') { d_echo("Changed mac address for {$ip} from {$old_mac} to {$mac}\n"); log_event("MAC change: {$ip} : " . mac_clean_to_readable($old_mac) . ' -> ' . mac_clean_to_readable($mac), $device, 'interface', $port_id); dbUpdate(array('mac_address' => $mac), 'ipv4_mac', 'port_id=? AND ipv4_address=? AND context_name=?', array($port_id, $ip, $context)); } d_echo(null, '.'); } elseif (isset($interface['port_id'])) { d_echo(null, '+'); $insert_data[] = array('port_id' => $port_id, 'mac_address' => $mac, 'ipv4_address' => $ip, 'context_name' => $context); } } } // add new entries if (!empty($insert_data)) { dbBulkInsert($insert_data, 'ipv4_mac'); } // remove stale entries foreach ($existing_data as $entry) { $entry_mac = $entry['mac_address'];
if ($opt == 'd') { dbUpdate("employee", array('level' => 0), "status='{$cid}'"); dbDel($dbtable, "dcid='{$cid}'"); } else { if ($opt == 'up') { $a = MstrGetNextUrut($dbtable, $cid); if ($a[0] != -1) { dbUpdate($dbtable, array('urut' => $a[1]), "dcid='{$cid}'"); dbUpdate($dbtable, array('urut' => $a[2]), "dcid='" . $a[0] . "'"); } } else { if ($opt == 'dn') { $a = MstrGetNextUrut($dbtable, $cid, "DESC"); if ($a[0] != -1) { dbUpdate($dbtable, array('urut' => $a[1]), "dcid='{$cid}'"); dbUpdate($dbtable, array('urut' => $a[2]), "dcid='" . $a[0] . "'"); } } } } } } require_once VWDIR . $fmod . '.php'; } else { $sx = str_replace('f', '', $opt); $nobtn = "Cancel"; // Form dimension $fwidth = 400; $lwidth = 100; $iTextFw = "width:" . ($fwidth - $lwidth - 16) . "px"; // Preprocessing form