mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12124)
This commit is contained in:
@@ -16,10 +16,10 @@ require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
// Find the correct bill, exit if we get anything other than 1 result.
|
||||
function list_bills($bill_name)
|
||||
{
|
||||
$bill = dbFetchRows("SELECT `bill_id`,`bill_name` FROM `bills` WHERE `bill_name` LIKE ?", ["$bill_name"]);
|
||||
$bill = dbFetchRows('SELECT `bill_id`,`bill_name` FROM `bills` WHERE `bill_name` LIKE ?', ["$bill_name"]);
|
||||
if (count($bill) != 1) {
|
||||
echo "Did not find exactly 1 bill, exiting\n";
|
||||
echo "Query:" . $bill . "\n";
|
||||
echo 'Query:' . $bill . "\n";
|
||||
exit(1);
|
||||
} else {
|
||||
echo "Found bill {$bill[0]['bill_name']} ({$bill[0]['bill_id']})\n";
|
||||
@@ -38,7 +38,7 @@ function create_bill($bill_name, $bill_type, $bill_cdr, $bill_day)
|
||||
* - bill_cdr: if bill_type is cdr, then this is in bits, if bill_type is quota, then it's in bytes (!!)
|
||||
* - bill_day: day of month billing starts.
|
||||
**/
|
||||
echo "Creating bill with name : " . $bill_name . " (Type: " . $bill_type . ", Quota: " . $bill_cdr . ")\n";
|
||||
echo 'Creating bill with name : ' . $bill_name . ' (Type: ' . $bill_type . ', Quota: ' . $bill_cdr . ")\n";
|
||||
$insert = [
|
||||
'bill_name' => $bill_name,
|
||||
'bill_type' => $bill_type,
|
||||
@@ -46,7 +46,7 @@ function create_bill($bill_name, $bill_type, $bill_cdr, $bill_day)
|
||||
'bill_day' => '1',
|
||||
];
|
||||
$create_bill = dbInsert($insert, 'bills');
|
||||
echo "Created bill ID " . $create_bill . "\n";
|
||||
echo 'Created bill ID ' . $create_bill . "\n";
|
||||
|
||||
return $create_bill;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ function create_bill($bill_name, $bill_type, $bill_cdr, $bill_day)
|
||||
// This will get an array of devices we are interested in from the CLI glob
|
||||
function get_devices($host_glob, $nameType)
|
||||
{
|
||||
return dbFetchRows("SELECT `device_id`,`hostname`,`sysName` FROM `devices` WHERE `" . $nameType . "` LIKE ?", ["%$host_glob%"]);
|
||||
return dbFetchRows('SELECT `device_id`,`hostname`,`sysName` FROM `devices` WHERE `' . $nameType . '` LIKE ?', ["%$host_glob%"]);
|
||||
}
|
||||
|
||||
// This will flush bill ports if -r is set on cli
|
||||
@@ -75,8 +75,8 @@ function add_ports_to_bill($devs, $intf_glob, $id)
|
||||
|
||||
// Expected interface glob:
|
||||
echo "Interface glob: $intf_glob\n";
|
||||
$device_ids = array_column($devs, "device_id");
|
||||
$ids = implode(",", $device_ids);
|
||||
$device_ids = array_column($devs, 'device_id');
|
||||
$ids = implode(',', $device_ids);
|
||||
|
||||
// Find the devices which match the list of IDS and also the interface glob
|
||||
$query = "SELECT ports.port_id,ports.ifName,ports.ifAlias FROM ports INNER JOIN devices ON ports.device_id = devices.device_id WHERE ifType = 'ethernetCsmacd' AND ports.ifAlias LIKE '%$intf_glob%' AND ports.device_id in ($ids)";
|
||||
@@ -129,11 +129,11 @@ $options = getopt('b:s:h:i:f:np:t:q:');
|
||||
|
||||
if (! empty($options['s'])) {
|
||||
$host_glob = str_replace('*', '%', mres($options['s']));
|
||||
$nameType = "sysName";
|
||||
$nameType = 'sysName';
|
||||
}
|
||||
if (! empty($options['h'])) {
|
||||
$host_glob = str_replace('*', '%', mres($options['h']));
|
||||
$nameType = "hostname";
|
||||
$nameType = 'hostname';
|
||||
}
|
||||
if (array_key_exists('n', $options)) {
|
||||
$create_bill = true;
|
||||
|
Reference in New Issue
Block a user