PSR2 Cleanup: /html edition

Travis tests for code conformance. Ignore warnings for now.
Fixed all errors, left most warnings.
This commit is contained in:
Tony Murray
2016-08-18 20:28:22 -05:00
parent f0c82498b5
commit 8c639aa5a4
468 changed files with 6605 additions and 7629 deletions

View File

@@ -15,23 +15,20 @@ if ($_GET['string']) {
if ($_SESSION['userlevel'] >= '5') {
$query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC";
}
else {
} else {
$query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC";
$param[] = $_SESSION['user_id'];
}
if (isset($_GET['start']) && is_numeric($_GET['start'])) {
$start = mres($_GET['start']);
}
else {
} else {
$start = 0;
}
if (isset($_GET['results']) && is_numeric($_GET['results'])) {
$numresults = mres($_GET['results']);
}
else {
} else {
$numresults = 250;
}
@@ -45,20 +42,16 @@ foreach (dbFetchRows($full_query, $param) as $alert_entry) {
if ($alert_state == '0') {
$glyph_color = 'green';
$text = 'Ok';
}
else if ($alert_state == '1') {
} elseif ($alert_state == '1') {
$glyph_color = 'red';
$text = 'Alert';
}
else if ($alert_state == '2') {
} elseif ($alert_state == '2') {
$glyph_color = 'lightgrey';
$text = 'Ack';
}
else if ($alert_state == '3') {
} elseif ($alert_state == '3') {
$glyph_color = 'orange';
$text = 'Worse';
}
else if ($alert_state == '4') {
} elseif ($alert_state == '4') {
$glyph_color = 'khaki';
$text = 'Better';
}
@@ -92,8 +85,7 @@ EOD;
foreach ($data as $log) {
if ($log[3] == 'Alert') {
$tr_col = '#d39392';
}
else {
} else {
$tr_col = '#bbd392';
}

View File

@@ -19,69 +19,67 @@ $where = '';
foreach ($vars as $var => $value) {
if ($value != '') {
switch ($var) {
case 'hostname':
$where .= ' AND D.hostname LIKE ?';
$param[] = '%'.$value.'%';
break;
case 'hostname':
$where .= ' AND D.hostname LIKE ?';
$param[] = '%'.$value.'%';
break;
case 'location':
$where .= ' AND D.location LIKE ?';
$param[] = '%'.$value.'%';
break;
case 'location':
$where .= ' AND D.location LIKE ?';
$param[] = '%'.$value.'%';
break;
case 'device_id':
$where .= ' AND D.device_id = ?';
$param[] = $value;
break;
case 'device_id':
$where .= ' AND D.device_id = ?';
$param[] = $value;
break;
case 'deleted':
case 'ignore':
if ($value == 1) {
$where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0';
}
break;
case 'deleted':
case 'ignore':
if ($value == 1) {
$where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0';
}
break;
case 'disable':
case 'ifSpeed':
if (is_numeric($value)) {
case 'disable':
case 'ifSpeed':
if (is_numeric($value)) {
$where .= " AND I.$var = ?";
$param[] = $value;
}
break;
case 'ifType':
$where .= " AND I.$var = ?";
$param[] = $value;
}
break;
break;
case 'ifType':
$where .= " AND I.$var = ?";
$param[] = $value;
break;
case 'ifAlias':
case 'port_descr_type':
$where .= " AND I.$var LIKE ?";
$param[] = '%'.$value.'%';
break;
case 'ifAlias':
case 'port_descr_type':
$where .= " AND I.$var LIKE ?";
$param[] = '%'.$value.'%';
break;
case 'errors':
if ($value == 1) {
$where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')";
}
break;
case 'errors':
if ($value == 1) {
$where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')";
}
break;
case 'state':
if ($value == 'down') {
$where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?';
$param[] = 'up';
$param[] = 'down';
}
else if ($value == 'up') {
$where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'";
$param[] = 'up';
$param[] = 'up';
}
else if ($value == 'admindown') {
$where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0';
$param[] = 'down';
}
break;
case 'state':
if ($value == 'down') {
$where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?';
$param[] = 'up';
$param[] = 'down';
} elseif ($value == 'up') {
$where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'";
$param[] = 'up';
$param[] = 'up';
} elseif ($value == 'admindown') {
$where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0';
$param[] = 'down';
}
break;
}//end switch
}//end if
}//end foreach
@@ -95,53 +93,53 @@ list($format, $subformat) = explode('_', $vars['format']);
$ports = dbFetchRows($query, $param);
switch ($vars['sort']) {
case 'traffic':
$ports = array_sort($ports, 'ifOctets_rate', SORT_DESC);
break;
case 'traffic':
$ports = array_sort($ports, 'ifOctets_rate', SORT_DESC);
break;
case 'traffic_in':
$ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC);
break;
case 'traffic_in':
$ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC);
break;
case 'traffic_out':
$ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC);
break;
case 'traffic_out':
$ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC);
break;
case 'packets':
$ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC);
break;
case 'packets':
$ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC);
break;
case 'packets_in':
$ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC);
break;
case 'packets_in':
$ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC);
break;
case 'packets_out':
$ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC);
break;
case 'packets_out':
$ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC);
break;
case 'errors':
$ports = array_sort($ports, 'ifErrors_rate', SORT_DESC);
break;
case 'errors':
$ports = array_sort($ports, 'ifErrors_rate', SORT_DESC);
break;
case 'speed':
$ports = array_sort($ports, 'ifSpeed', SORT_DESC);
break;
case 'speed':
$ports = array_sort($ports, 'ifSpeed', SORT_DESC);
break;
case 'port':
$ports = array_sort($ports, 'ifDescr', SORT_ASC);
break;
case 'port':
$ports = array_sort($ports, 'ifDescr', SORT_ASC);
break;
case 'media':
$ports = array_sort($ports, 'ifType', SORT_ASC);
break;
case 'media':
$ports = array_sort($ports, 'ifType', SORT_ASC);
break;
case 'descr':
$ports = array_sort($ports, 'ifAlias', SORT_ASC);
break;
case 'descr':
$ports = array_sort($ports, 'ifAlias', SORT_ASC);
break;
case 'device':
default:
$ports = array_sort($ports, 'hostname', SORT_ASC);
case 'device':
default:
$ports = array_sort($ports, 'hostname', SORT_ASC);
}//end switch
$csv[] = array(