mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix coding style part 2
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
<?php
|
||||
|
||||
$where = "1";
|
||||
$where = '1';
|
||||
|
||||
if (is_numeric($_POST['device']))
|
||||
{
|
||||
$where .= ' AND E.host = ?';
|
||||
$param[] = $_POST['device'];
|
||||
if (is_numeric($_POST['device'])) {
|
||||
$where .= ' AND E.host = ?';
|
||||
$param[] = $_POST['device'];
|
||||
}
|
||||
|
||||
if ($_POST['string'])
|
||||
{
|
||||
$where .= " AND E.message LIKE ?";
|
||||
$param[] = "%".$_POST['string']."%";
|
||||
if ($_POST['string']) {
|
||||
$where .= ' AND E.message LIKE ?';
|
||||
$param[] = '%'.$_POST['string'].'%';
|
||||
}
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5') {
|
||||
$sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where";
|
||||
} else {
|
||||
$sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?";
|
||||
}
|
||||
else {
|
||||
$sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?";
|
||||
$param[] = $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
@@ -26,7 +25,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||
}
|
||||
|
||||
$count_sql = "SELECT COUNT(datetime) $sql";
|
||||
$total = dbFetchCell($count_sql,$param);
|
||||
$total = dbFetchCell($count_sql, $param);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
@@ -38,7 +37,7 @@ if (!isset($sort) || empty($sort)) {
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
if (isset($current)) {
|
||||
$limit_low = ($current * $rowCount) - ($rowCount);
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
|
||||
@@ -48,22 +47,28 @@ if ($rowCount != -1) {
|
||||
|
||||
$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql";
|
||||
|
||||
foreach (dbFetchRows($sql,$param) as $eventlog) {
|
||||
foreach (dbFetchRows($sql, $param) as $eventlog) {
|
||||
$dev = device_by_id_cache($eventlog['host']);
|
||||
if ($eventlog['type'] == "interface") {
|
||||
if ($eventlog['type'] == 'interface') {
|
||||
$this_if = ifLabel(getifbyid($eventlog['reference']));
|
||||
$type = "<b>".generate_port_link($this_if, makeshortif(strtolower($this_if['label'])))."</b>";
|
||||
} else {
|
||||
$type = "System";
|
||||
$type = '<b>'.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).'</b>';
|
||||
}
|
||||
|
||||
$response[] = array('datetime'=>$eventlog['humandate'],
|
||||
'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])),
|
||||
'type'=>$type,
|
||||
'message'=>htmlspecialchars($eventlog['message']));
|
||||
else {
|
||||
$type = 'System';
|
||||
}
|
||||
|
||||
$response[] = array(
|
||||
'datetime' => $eventlog['humandate'],
|
||||
'hostname' => generate_device_link($dev, shorthost($dev['hostname'])),
|
||||
'type' => $type,
|
||||
'message' => htmlspecialchars($eventlog['message']),
|
||||
);
|
||||
}
|
||||
|
||||
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user