Skip to content

Commit

Permalink
refactor: Refactor fix php codesniffer 3.x issues (librenms#7816)
Browse files Browse the repository at this point in the history
We cannot use 3.x because it  requires php 5.4, so update to 2.9.1 or newer 2.x release.
  • Loading branch information
murrant authored and laf committed Nov 29, 2017
1 parent ce913cd commit d6db01a
Show file tree
Hide file tree
Showing 23 changed files with 231 additions and 171 deletions.
4 changes: 2 additions & 2 deletions LibreNMS/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function setComponentPrefs($device_id, $ARRAY)
}

// Ignore type, we cant change that.
unset($AVP['type'],$OLD[$device_id][$COMPONENT]['type']);
unset($AVP['type'], $OLD[$device_id][$COMPONENT]['type']);

// If the Status has changed we need to add a log entry
if ($AVP['status'] != $OLD[$device_id][$COMPONENT]['status']) {
Expand All @@ -322,7 +322,7 @@ public function setComponentPrefs($device_id, $ARRAY)
}

// Unset the reserved field. We don't want to insert it below.
unset($AVP[$k],$OLD[$device_id][$COMPONENT][$k]);
unset($AVP[$k], $OLD[$device_id][$COMPONENT][$k]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static function getCombined($os, $key, $default = array())
* @param string $group webui group (only set when initially created)
* @param string $sub_group webui subgroup (only set when initially created)
*/
public static function set($key, $value, $persist = false, $default ='', $descr='', $group='', $sub_group='')
public static function set($key, $value, $persist = false, $default = '', $descr = '', $group = '', $sub_group = '')
{
global $config;

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"palanik/corsslim": "^1.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.6.*",
"squizlabs/php_codesniffer": "^2.9.1",
"phpunit/phpunit": "4.*",
"jakub-onderka/php-parallel-lint": "*",
"jakub-onderka/php-console-highlighter": "*",
Expand Down
2 changes: 1 addition & 1 deletion html/ajax_rulesuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function levsort($base, $obj)
$obj = array(array('name' => 'Error: No suggestions found.'));
$term = array();
$current = false;
if (isset($_GET['term'],$_GET['device_id'])) {
if (isset($_GET['term'], $_GET['device_id'])) {
$chk = array();
$_GET['term'] = mres($_GET['term']);
$_GET['device_id'] = mres($_GET['device_id']);
Expand Down
2 changes: 1 addition & 1 deletion html/includes/forms/create-alert-item.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
$_POST['target'] = $target;
$_POST['map_id'] = '';
include 'create-map-item.inc.php';
unset($ret,$target,$raw,$rule,$msg,$map_id);
unset($ret, $target, $raw, $rule, $msg, $map_id);
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion html/includes/forms/test-transport.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
$opts = $config['alert']['transports'][$transport];
if ($opts) {
eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };');
$tmp = $tmp($obj,$opts);
$tmp = $tmp($obj, $opts);
if ($tmp) {
$status = 'ok';
}
Expand Down
12 changes: 7 additions & 5 deletions html/includes/modal/new_bill.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
if (is_admin() !== false) {
require 'includes/javascript-interfacepicker.inc.php';

$port_device_id = -1;
if (is_numeric($vars['port'])) {
$port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port']));
Expand Down Expand Up @@ -53,19 +53,21 @@
<label class="col-sm-4 control-label" for="port_id">Port</label>
<div class="col-sm-8">
<select class="form-control input-sm" id="port_id" name="port_id">
<?php if (is_array($port)) {
<?php
if (is_array($port)) {
// Need to pre-populate port as we've got a port pre-selected
foreach (dbFetch('SELECT * FROM ports WHERE device_id = ?', array($port_device_id)) as $interface) {
$interface = cleanPort($interface);
$string = $interface['label'].' - '.display($interface['ifAlias']);
$selected = $interface['port_id'] === $port['port_id'] ? " selected" : "";
echo "<option value='${interface['port_id']}' $selected>$string</option>\n";
}
} ?>
}
?>
</select>
</div>
</div>
</div>

<?php

$bill_data['bill_type'] = 'cdr';
Expand Down
14 changes: 10 additions & 4 deletions html/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@
<div class="col-md-6 col-md-offset-3">
<form class="form-inline" role="form" method="post">
<input type="hidden" name="stage" value="1">
<button type="submit" class="btn btn-success pull-right" <?php if (!$complete) {
<button type="submit" class="btn btn-success pull-right"
<?php
if (!$complete) {
echo "disabled='disabled'";
} ?>>Next Stage</button>
}
?>>Next Stage</button>
</form>
</div>
</div>
Expand Down Expand Up @@ -498,9 +501,12 @@
<input type="hidden" name="dbpass" value="<?php echo $dbpass; ?>">
<input type="hidden" name="dbname" value="<?php echo $dbname; ?>">
<input type="hidden" name="dbsocket" value="<?php echo $dbsocket; ?>">
<button type="submit" class="btn btn-success pull-right" <?php if ($proceed == "1") {
<button type="submit" class="btn btn-success pull-right"
<?php
if ($proceed == "1") {
echo "disabled='disabled'";
} ?>>Generate Config</button>
}
?>>Generate Config</button>
</form>
</div>
<div class="col-md-3">
Expand Down
132 changes: 66 additions & 66 deletions html/pages/bill.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,41 @@ function print_port_list()
'transfer' => 'Transfer Graphs',
'history' => 'Historical Graphs'
);
if ($_SESSION['userlevel'] >= '10') {
$menu_options['edit'] = 'Edit';
$menu_options['delete'] = 'Delete';
$menu_options['reset'] = 'Reset';
}
if ($_SESSION['userlevel'] >= '10') {
$menu_options['edit'] = 'Edit';
$menu_options['delete'] = 'Delete';
$menu_options['reset'] = 'Reset';
}
$sep = '';
foreach ($menu_options as $option => $text) {
echo $sep;
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}

echo generate_link($text, $vars, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}
foreach ($menu_options as $option => $text) {
echo $sep;
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}

$sep = ' | ';
echo generate_link($text, $vars, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}

$sep = ' | ';
}

echo '<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => 'bills')).'/"><i class="fa fa-arrow-left fa-lg icon-theme" aria-hidden="true"></i> Back to Bills</a></div>';

print_optionbar_end();

if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/edit.inc.php';
} elseif ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/delete.inc.php';
} elseif ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/reset.inc.php';
} elseif ($vars['view'] == 'history') {
include 'pages/bill/history.inc.php';
} elseif ($vars['view'] == 'transfer') {
include 'pages/bill/transfer.inc.php';
} elseif ($vars['view'] == 'quick' || $vars['view'] == 'accurate') {
if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/edit.inc.php';
} elseif ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/delete.inc.php';
} elseif ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') {
include 'pages/bill/reset.inc.php';
} elseif ($vars['view'] == 'history') {
include 'pages/bill/history.inc.php';
} elseif ($vars['view'] == 'transfer') {
include 'pages/bill/transfer.inc.php';
} elseif ($vars['view'] == 'quick' || $vars['view'] == 'accurate') {
?>

<?php if ($bill_data['bill_type'] == 'quota') { ?>
Expand All @@ -147,18 +147,18 @@ function print_port_list()
<br /><br />

<div class="row">
<div class="col-lg-6 col-lg-push-6">
<?php print_port_list() ?>
<div class="col-lg-6 col-lg-push-6">
<?php print_port_list() ?>
</div>
<div class="col-lg-6 col-lg-pull-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Bill Summary
</h3>
</div>
<div class="col-lg-6 col-lg-pull-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Bill Summary
</h3>
</div>
<table class="table">
<tr>
<table class="table">
<tr>
<?php if ($bill_data['bill_type'] == 'quota') {
// The Customer is billed based on a pre-paid quota with overage in xB
$percent = round((($total_data) / $bill_data['bill_quota'] * 100), 2);
Expand Down Expand Up @@ -204,17 +204,17 @@ function print_port_list()

<?php }//end if
?>
</tr>
</table>
</div>
</div>
</div>
</tr>
</table>
</div>
</div>
</div>

<?php

$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
$rightnow = date(U);
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
$rightnow = date(U);

if ($vars['view'] == 'accurate') {
$bi = "<img src='billing-graph.php?bill_id=".$bill_id.'&amp;bill_code='.$_GET['bill_code'];
Expand Down Expand Up @@ -255,28 +255,28 @@ function print_port_list()
}//end if

?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Billing View</h3>
</div>
<?php echo $bi ?>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Billing View</h3>
</div>
<?php echo $bi ?>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">24 Hour View</h3>
</div>
<?php echo $di ?>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Monthly View</h3>
</div>
<?php echo $mi ?>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">24 Hour View</h3>
</div>
<?php echo $di ?>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Monthly View</h3>
</div>
<?php echo $mi ?>
</div>
<?php
} //end if
} //end if
} else {
include 'includes/error-no-perm.inc.php';
}//end if
Expand Down
20 changes: 13 additions & 7 deletions html/pages/bill/addoreditbill.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
<label class="col-sm-4 control-label" for="bill_type">Billing Type</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_cdr" value="cdr" <?php if ($bill_data['bill_type'] == 'cdr') {
echo "checked";
} ?> onchange="javascript: billType();" /> CDR 95th
<input type="radio" name="bill_type" id="bill_type_cdr" value="cdr"
<?php
if ($bill_data['bill_type'] == 'cdr') {
echo "checked";
}
?> onchange="javascript: billType();" /> CDR 95th
</label>
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_quota" value="quota" <?php if ($bill_data['bill_type'] == 'quota') {
echo "checked";
} ?> onchange="javascript: billType();" /> Quota
<input type="radio" name="bill_type" id="bill_type_quota" value="quota"
<?php
if ($bill_data['bill_type'] == 'quota') {
echo "checked";
}
?> onchange="javascript: billType();" /> Quota
</label>
</div>
</div>
Expand Down Expand Up @@ -86,7 +92,7 @@
<script type="text/javascript">
function billType() {
var selected = $('input[name=bill_type]:checked').val();

$('#cdrDiv').toggle(selected === 'cdr');
$('#quotaDiv').toggle(selected === 'quota');
}
Expand Down
2 changes: 1 addition & 1 deletion html/pages/bill/edit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function billType() {
<?php }
if (!$emptyCheck) { ?>
<div class="alert alert-info">There are no ports assigned to this bill</alert>
<?php } ?>
<?php } ?>

</div>

Expand Down
Loading

0 comments on commit d6db01a

Please sign in to comment.