mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Use elseif instead of else if (#8417)
This commit is contained in:
committed by
Neil Lathwood
parent
10237ea097
commit
8cc8eb8dd2
@@ -48,7 +48,7 @@ class MoxaEtherdevice extends OS implements ProcessorDiscovery
|
|||||||
|
|
||||||
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
||||||
$oid = '.1.3.6.1.4.1.8691.7.116.1.54.0'; // MOXA-IKS6726A-MIB::cpuLoading30s.0
|
$oid = '.1.3.6.1.4.1.8691.7.116.1.54.0'; // MOXA-IKS6726A-MIB::cpuLoading30s.0
|
||||||
} else if ($device['sysDescr'] == 'EDS-G508E-T') {
|
} elseif ($device['sysDescr'] == 'EDS-G508E-T') {
|
||||||
$oid = '.1.3.6.1.4.1.8691.7.69.1.54.0'; // MOXA-EDSG508E-MIB::cpuLoading30s.0
|
$oid = '.1.3.6.1.4.1.8691.7.69.1.54.0'; // MOXA-EDSG508E-MIB::cpuLoading30s.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ $urlargs = array(
|
|||||||
);
|
);
|
||||||
if (is_numeric($_GET['bill_hist_id'])) {
|
if (is_numeric($_GET['bill_hist_id'])) {
|
||||||
$urlargs['bill_hist_id'] = $_GET['bill_hist_id'];
|
$urlargs['bill_hist_id'] = $_GET['bill_hist_id'];
|
||||||
} else if (is_numeric($_GET['from']) && is_numeric($_GET['to'])) {
|
} elseif (is_numeric($_GET['from']) && is_numeric($_GET['to'])) {
|
||||||
$urlargs['from'] = $_GET['from'];
|
$urlargs['from'] = $_GET['from'];
|
||||||
$urlargs['to'] = $_GET['to'];
|
$urlargs['to'] = $_GET['to'];
|
||||||
}
|
}
|
||||||
|
@@ -1274,7 +1274,7 @@ function list_bills()
|
|||||||
$sql .= ' AND `bill_id` IN (SELECT `bill_id` FROM `bill_perms` WHERE `user_id` = ?)';
|
$sql .= ' AND `bill_id` IN (SELECT `bill_id` FROM `bill_perms` WHERE `user_id` = ?)';
|
||||||
$param[] = $_SESSION['user_id'];
|
$param[] = $_SESSION['user_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($period === 'previous') {
|
if ($period === 'previous') {
|
||||||
$select = "SELECT bills.bill_name, bills.bill_notes, bill_history.*, bill_history.traf_total as total_data, bill_history.traf_in as total_data_in, bill_history.traf_out as total_data_out ";
|
$select = "SELECT bills.bill_name, bills.bill_notes, bill_history.*, bill_history.traf_total as total_data, bill_history.traf_in as total_data_in, bill_history.traf_out as total_data_out ";
|
||||||
$query = 'FROM `bills`
|
$query = 'FROM `bills`
|
||||||
@@ -1331,7 +1331,7 @@ function get_bill_graph()
|
|||||||
if (!is_admin() && !is_read()) {
|
if (!is_admin() && !is_read()) {
|
||||||
check_bill_permission($bill_id);
|
check_bill_permission($bill_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($graph_type == 'monthly') {
|
if ($graph_type == 'monthly') {
|
||||||
$graph_type = 'historicmonthly';
|
$graph_type = 'historicmonthly';
|
||||||
}
|
}
|
||||||
@@ -1364,10 +1364,10 @@ function get_bill_graphdata()
|
|||||||
$reducefactor = $_GET['reducefactor'];
|
$reducefactor = $_GET['reducefactor'];
|
||||||
|
|
||||||
$graph_data = getBillingBitsGraphData($bill_id, $from, $to, $reducefactor);
|
$graph_data = getBillingBitsGraphData($bill_id, $from, $to, $reducefactor);
|
||||||
} else if ($graph_type == 'monthly') {
|
} elseif ($graph_type == 'monthly') {
|
||||||
$graph_data = getHistoricTransferGraphData($bill_id);
|
$graph_data = getHistoricTransferGraphData($bill_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($graph_data)) {
|
if (!isset($graph_data)) {
|
||||||
api_error(400, "Unsupported graph type $graph_type");
|
api_error(400, "Unsupported graph type $graph_type");
|
||||||
} else {
|
} else {
|
||||||
@@ -1397,7 +1397,7 @@ function get_bill_history()
|
|||||||
function get_bill_history_graph()
|
function get_bill_history_graph()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$app = \Slim\Slim::getInstance();
|
$app = \Slim\Slim::getInstance();
|
||||||
$router = $app->router()->getCurrentRoute()->getParams();
|
$router = $app->router()->getCurrentRoute()->getParams();
|
||||||
$bill_id = mres($router['bill_id']);
|
$bill_id = mres($router['bill_id']);
|
||||||
@@ -1407,7 +1407,7 @@ function get_bill_history_graph()
|
|||||||
if (!is_admin() && !is_read()) {
|
if (!is_admin() && !is_read()) {
|
||||||
check_bill_permission($bill_id);
|
check_bill_permission($bill_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = array();
|
$vars = array();
|
||||||
|
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
@@ -1415,13 +1415,13 @@ function get_bill_history_graph()
|
|||||||
$graph_type = 'historicbits';
|
$graph_type = 'historicbits';
|
||||||
$vars['reducefactor'] = $_GET['reducefactor'];
|
$vars['reducefactor'] = $_GET['reducefactor'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'day':
|
case 'day':
|
||||||
case 'hour':
|
case 'hour':
|
||||||
$vars['imgtype'] = $graph_type;
|
$vars['imgtype'] = $graph_type;
|
||||||
$graph_type = 'historictransfer';
|
$graph_type = 'historictransfer';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
api_error(400, "Unknown Graph Type $graph_type");
|
api_error(400, "Unknown Graph Type $graph_type");
|
||||||
break;
|
break;
|
||||||
@@ -1451,7 +1451,7 @@ function get_bill_history_graphdata()
|
|||||||
if (!is_admin() && !is_read()) {
|
if (!is_admin() && !is_read()) {
|
||||||
check_bill_permission($bill_id);
|
check_bill_permission($bill_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'bits':
|
case 'bits':
|
||||||
$reducefactor = $_GET['reducefactor'];
|
$reducefactor = $_GET['reducefactor'];
|
||||||
@@ -1463,7 +1463,7 @@ function get_bill_history_graphdata()
|
|||||||
$graph_data = getBillingBandwidthGraphData($bill_id, $bill_hist_id, null, null, $graph_type);
|
$graph_data = getBillingBandwidthGraphData($bill_id, $bill_hist_id, null, null, $graph_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($graph_data)) {
|
if (!isset($graph_data)) {
|
||||||
api_error(400, "Unsupported graph type $graph_type");
|
api_error(400, "Unsupported graph type $graph_type");
|
||||||
} else {
|
} else {
|
||||||
|
@@ -25,7 +25,7 @@ if (is_admin() === false) {
|
|||||||
$status = array('status' => 1, 'message' => 'Device dependency cannot be deleted.');
|
$status = array('status' => 1, 'message' => 'Device dependency cannot be deleted.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($_POST['parent_ids']) {
|
} elseif ($_POST['parent_ids']) {
|
||||||
$error = false;
|
$error = false;
|
||||||
foreach ($_POST['parent_ids'] as $parent) {
|
foreach ($_POST['parent_ids'] as $parent) {
|
||||||
if (is_numeric($parent) && $parent != 0) {
|
if (is_numeric($parent) && $parent != 0) {
|
||||||
@@ -33,7 +33,7 @@ if (is_admin() === false) {
|
|||||||
$error = true;
|
$error = true;
|
||||||
$status = array('status' => 1, 'message' => 'Device dependency cannot be deleted.');
|
$status = array('status' => 1, 'message' => 'Device dependency cannot be deleted.');
|
||||||
}
|
}
|
||||||
} else if ($parent == 0) {
|
} elseif ($parent == 0) {
|
||||||
$status = array('status' => 1, 'message' => 'No dependency to delete.');
|
$status = array('status' => 1, 'message' => 'No dependency to delete.');
|
||||||
$error = true;
|
$error = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -40,7 +40,7 @@ if (is_admin() === false) {
|
|||||||
foreach ($_POST['parent_ids'] as $parent) {
|
foreach ($_POST['parent_ids'] as $parent) {
|
||||||
if (is_numeric($parent) && $parent != 0) {
|
if (is_numeric($parent) && $parent != 0) {
|
||||||
$insert[] = array('parent_device_id' => $parent, 'child_device_id' => $dev);
|
$insert[] = array('parent_device_id' => $parent, 'child_device_id' => $dev);
|
||||||
} else if ($parent == 0) {
|
} elseif ($parent == 0) {
|
||||||
// In case we receive a mixed array with $parent = 0 (which shouldn't happen)
|
// In case we receive a mixed array with $parent = 0 (which shouldn't happen)
|
||||||
// Empty the insert array so we remove any previous dependency so 'None' takes precedence
|
// Empty the insert array so we remove any previous dependency so 'None' takes precedence
|
||||||
$insert = array();
|
$insert = array();
|
||||||
|
@@ -11,7 +11,7 @@ if (is_numeric($bill_hist_id)) {
|
|||||||
$extents = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($bill_id, $bill_hist_id));
|
$extents = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($bill_id, $bill_hist_id));
|
||||||
$dur = $extents['to'] - $extents['from'];
|
$dur = $extents['to'] - $extents['from'];
|
||||||
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
|
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
|
||||||
|
|
||||||
if ($reducefactor < 2) {
|
if ($reducefactor < 2) {
|
||||||
$reducefactor = 2;
|
$reducefactor = 2;
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ if (is_numeric($bill_hist_id)) {
|
|||||||
if ($reducefactor < 2) {
|
if ($reducefactor < 2) {
|
||||||
$dur = $vars['to'] - $vars['from'];
|
$dur = $vars['to'] - $vars['from'];
|
||||||
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
|
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
|
||||||
|
|
||||||
if ($reducefactor < 2) {
|
if ($reducefactor < 2) {
|
||||||
$reducefactor = 2;
|
$reducefactor = 2;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ $lineplot_out->SetWeight(1);
|
|||||||
if (strtolower($graph_data['bill_type']) == 'cdr') {
|
if (strtolower($graph_data['bill_type']) == 'cdr') {
|
||||||
$lineplot_95th = new LinePlot(array($graph_data['rate_95th'], $graph_data['rate_95th']), array($xmin, $xmax));
|
$lineplot_95th = new LinePlot(array($graph_data['rate_95th'], $graph_data['rate_95th']), array($xmin, $xmax));
|
||||||
$lineplot_95th->SetColor('red');
|
$lineplot_95th->SetColor('red');
|
||||||
} else if (strtolower($graph_data['bill_type']) == 'quota') {
|
} elseif (strtolower($graph_data['bill_type']) == 'quota') {
|
||||||
$lineplot_ave = new LinePlot(array($graph_data['rate_average'], $graph_data['rate_average']), array($xmin, $xmax));
|
$lineplot_ave = new LinePlot(array($graph_data['rate_average'], $graph_data['rate_average']), array($xmin, $xmax));
|
||||||
$lineplot_ave->SetColor('red');
|
$lineplot_ave->SetColor('red');
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ $graph->Add($lineplot_out);
|
|||||||
|
|
||||||
if (strtolower($graph_data['bill_type']) == 'cdr') {
|
if (strtolower($graph_data['bill_type']) == 'cdr') {
|
||||||
$graph->Add($lineplot_95th);
|
$graph->Add($lineplot_95th);
|
||||||
} else if (strtolower($graph_data['bill_type']) == 'quota') {
|
} elseif (strtolower($graph_data['bill_type']) == 'quota') {
|
||||||
$graph->Add($lineplot_ave);
|
$graph->Add($lineplot_ave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ use Amenadiel\JpGraph\Plot\LinePlot;
|
|||||||
|
|
||||||
if (is_numeric($vars['bill_hist_id'])) {
|
if (is_numeric($vars['bill_hist_id'])) {
|
||||||
$graph_data = getBillingBandwidthGraphData($vars['id'], $vars['bill_hist_id'], null, null, $vars['imgtype']);
|
$graph_data = getBillingBandwidthGraphData($vars['id'], $vars['bill_hist_id'], null, null, $vars['imgtype']);
|
||||||
} else if (is_numeric($vars['from'])) {
|
} elseif (is_numeric($vars['from'])) {
|
||||||
$graph_data = getBillingBandwidthGraphData($vars['id'], null, $vars['from'], $vars['to'], $vars['imgtype']);
|
$graph_data = getBillingBandwidthGraphData($vars['id'], null, $vars['from'], $vars['to'], $vars['imgtype']);
|
||||||
} else {
|
} else {
|
||||||
$graph_data = getHistoricTransferGraphData($vars['id']);
|
$graph_data = getHistoricTransferGraphData($vars['id']);
|
||||||
@@ -18,7 +18,7 @@ if (is_numeric($vars['bill_hist_id'])) {
|
|||||||
for ($i = 0; $i < count($graph_data['ticklabels']); $i++) {
|
for ($i = 0; $i < count($graph_data['ticklabels']); $i++) {
|
||||||
if ($graph_data['ticklabels'][$i]) {
|
if ($graph_data['ticklabels'][$i]) {
|
||||||
$date = strtotime($graph_data['ticklabels'][$i]);
|
$date = strtotime($graph_data['ticklabels'][$i]);
|
||||||
|
|
||||||
if ($vars['imgtype'] === 'day') {
|
if ($vars['imgtype'] === 'day') {
|
||||||
$graph_data['ticklabels'][$i] = strftime("%e\n%b", $date);
|
$graph_data['ticklabels'][$i] = strftime("%e\n%b", $date);
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ if ($device['os'] == 'moxa-etherdevice') {
|
|||||||
// Moxa people enjoy creating similar MIBs for each model!
|
// Moxa people enjoy creating similar MIBs for each model!
|
||||||
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
||||||
$mibmod = 'MOXA-IKS6726A-MIB';
|
$mibmod = 'MOXA-IKS6726A-MIB';
|
||||||
} else if ($device['sysDescr'] == 'EDS-G508E-T') {
|
} elseif ($device['sysDescr'] == 'EDS-G508E-T') {
|
||||||
$mibmod = 'MOXA-EDSG508E-MIB';
|
$mibmod = 'MOXA-EDSG508E-MIB';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ if (is_array($oids)) {
|
|||||||
$current_value_string = $entry[$state_name];
|
$current_value_string = $entry[$state_name];
|
||||||
if ($current_value_string == 'OK') {
|
if ($current_value_string == 'OK') {
|
||||||
$current_value = 1;
|
$current_value = 1;
|
||||||
} else if ($current_value_string == 'OPEN') {
|
} elseif ($current_value_string == 'OPEN') {
|
||||||
$current_value = 2;
|
$current_value = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
// Moxa people enjoy creating similar MIBs for each model!
|
// Moxa people enjoy creating similar MIBs for each model!
|
||||||
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
||||||
$mibmod = 'MOXA-IKS6726A-MIB';
|
$mibmod = 'MOXA-IKS6726A-MIB';
|
||||||
} else if ($device['sysDescr'] == 'EDS-G508E-T') {
|
} elseif ($device['sysDescr'] == 'EDS-G508E-T') {
|
||||||
$mibmod = 'MOXA-EDSG508E-MIB';
|
$mibmod = 'MOXA-EDSG508E-MIB';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ $data = explode(".", $device["sysObjectID"]);
|
|||||||
$id = end($data);
|
$id = end($data);
|
||||||
if ($id == "1") {
|
if ($id == "1") {
|
||||||
$hardware = "C4";
|
$hardware = "C4";
|
||||||
} else if ($id == "2") {
|
} elseif ($id == "2") {
|
||||||
$hardware = "C4c";
|
$hardware = "C4c";
|
||||||
}
|
}
|
||||||
unset($data);
|
unset($data);
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
// Moxa people enjoy creating MIBs for each model!
|
// Moxa people enjoy creating MIBs for each model!
|
||||||
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
if ($device['sysDescr'] == 'IKS-6726A-2GTXSFP-T') {
|
||||||
$mibmod = 'MOXA-IKS6726A-MIB';
|
$mibmod = 'MOXA-IKS6726A-MIB';
|
||||||
} else if ($device['sysDescr'] == 'EDS-G508E-T') {
|
} elseif ($device['sysDescr'] == 'EDS-G508E-T') {
|
||||||
$mibmod = 'MOXA-EDSG508E-MIB';
|
$mibmod = 'MOXA-EDSG508E-MIB';
|
||||||
}
|
}
|
||||||
$version = snmp_get($device, "firmwareVersion.0", "-OQvs", $mibmod);
|
$version = snmp_get($device, "firmwareVersion.0", "-OQvs", $mibmod);
|
||||||
|
@@ -89,7 +89,7 @@ if (!empty($options['h'])) {
|
|||||||
}
|
}
|
||||||
if (empty($options['s']) && empty($options['h'])) {
|
if (empty($options['s']) && empty($options['h'])) {
|
||||||
echo "Please set -s or -h\n";
|
echo "Please set -s or -h\n";
|
||||||
} else if (!empty($options['s']) && !empty($options['h'])) {
|
} elseif (!empty($options['s']) && !empty($options['h'])) {
|
||||||
echo "Please set either -s or -h, not both\n";
|
echo "Please set either -s or -h, not both\n";
|
||||||
}
|
}
|
||||||
if (!empty($options['i']) && !empty($options['h'])) {
|
if (!empty($options['i']) && !empty($options['h'])) {
|
||||||
|
Reference in New Issue
Block a user