Apply fixes from StyleCI (#12124)

This commit is contained in:
Jellyfrog
2020-09-21 15:59:34 +02:00
committed by GitHub
parent 0d56bbd946
commit 29f45ca352
816 changed files with 5038 additions and 5038 deletions

View File

@@ -16,12 +16,12 @@
use App\Models\Port;
use Illuminate\Database\Eloquent\ModelNotFoundException;
$pagetitle[] = "Ports";
$pagetitle[] = 'Ports';
// Set Defaults here
if (! isset($vars['format'])) {
$vars['format'] = "list_basic";
$vars['format'] = 'list_basic';
}
$displayLists = '';
@@ -29,17 +29,17 @@ $displayLists .= '<span style="font-weight: bold;">Ports lists</span> &#187; ';
$menu_options = ['basic' => 'Basic', 'detail' => 'Detail'];
$sep = "";
$sep = '';
foreach ($menu_options as $option => $text) {
$displayLists .= $sep;
if ($vars['format'] == "list_" . $option) {
if ($vars['format'] == 'list_' . $option) {
$displayLists .= '<span class="pagemenu-selected">';
}
$displayLists .= '<a href="' . generate_url($vars, ['format' => "list_" . $option]) . '">' . $text . '</a>';
if ($vars['format'] == "list_" . $option) {
$displayLists .= '<a href="' . generate_url($vars, ['format' => 'list_' . $option]) . '">' . $text . '</a>';
if ($vars['format'] == 'list_' . $option) {
$displayLists .= '</span>';
}
$sep = " | ";
$sep = ' | ';
}
$displayLists .= '&nbsp;&nbsp;<span style="font-weight: bold;">Graphs</span> &#187;&nbsp;';
@@ -48,7 +48,7 @@ $menu_options = ['bits' => 'Bits',
'nupkts' => 'Non-Unicast Packets',
'errors' => 'Errors', ];
$sep = "";
$sep = '';
foreach ($menu_options as $option => $text) {
$displayLists .= $sep;
if ($vars['format'] == 'graph_' . $option) {
@@ -58,13 +58,13 @@ foreach ($menu_options as $option => $text) {
if ($vars['format'] == 'graph_' . $option) {
$displayLists .= '</span>';
}
$sep = " | ";
$sep = ' | ';
}
$displayLists .= '<div style="float: right;">';
$displayLists .= '<a href="csv.php/report=' . generate_url($vars, ['format' => '']) . '" title="Export as CSV" target="_blank" rel="noopener">Export CSV</a> | <a href="' . generate_url($vars) . '" title="Update the browser URL to reflect the search criteria.">Update URL</a> | ';
if (isset($vars['searchbar']) && $vars['searchbar'] == "hide") {
if (isset($vars['searchbar']) && $vars['searchbar'] == 'hide') {
$displayLists .= '<a href="' . generate_url($vars, ['searchbar' => '']) . '">Search</a>';
} else {
$displayLists .= '<a href="' . generate_url($vars, ['searchbar' => 'hide']) . '">Search</a>';
@@ -72,7 +72,7 @@ if (isset($vars['searchbar']) && $vars['searchbar'] == "hide") {
$displayLists .= ' | ';
if (isset($vars['bare']) && $vars['bare'] == "yes") {
if (isset($vars['bare']) && $vars['bare'] == 'yes') {
$displayLists .= '<a href="' . generate_url($vars, ['bare' => '']) . '">Header</a>';
} else {
$displayLists .= '<a href="' . generate_url($vars, ['bare' => 'yes']) . '">Header</a>';
@@ -85,7 +85,7 @@ $displayLists .= '<a href="ports/deleted=yes/purge=all" title="Delete ports"> Pu
$displayLists .= '</div>';
if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars['searchbar'])) {
if ((isset($vars['searchbar']) && $vars['searchbar'] != 'hide') || ! isset($vars['searchbar'])) {
$output = "<div class='pull-left'>";
$output .= "<form method='post' action='' class='form-inline' role='form'>";
$output .= addslashes(csrf_field());
@@ -95,72 +95,72 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars
$output .= "<option value=''>All Devices</option>";
if (Auth::user()->hasGlobalRead()) {
$results = dbFetchRows("SELECT `device_id`,`hostname`, `sysName` FROM `devices` ORDER BY `hostname`");
$results = dbFetchRows('SELECT `device_id`,`hostname`, `sysName` FROM `devices` ORDER BY `hostname`');
} else {
$results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` ORDER BY `hostname`", [Auth::id()]);
$results = dbFetchRows('SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` ORDER BY `hostname`', [Auth::id()]);
}
foreach ($results as $data) {
if ($data['device_id'] == $vars['device_id']) {
$deviceselected = "selected";
$deviceselected = 'selected';
} else {
$deviceselected = "";
$deviceselected = '';
}
$ui_device = strlen(format_hostname($data)) > 15 ? substr(format_hostname($data), 0, 15) . "..." : format_hostname($data);
$output .= "<option value='" . $data['device_id'] . "' " . $deviceselected . ">" . $ui_device . "</option>";
$ui_device = strlen(format_hostname($data)) > 15 ? substr(format_hostname($data), 0, 15) . '...' : format_hostname($data);
$output .= "<option value='" . $data['device_id'] . "' " . $deviceselected . '>' . $ui_device . '</option>';
}
if (! Auth::user()->hasGlobalRead()) {
$results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysName` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` ORDER BY `hostname`", [Auth::id()]);
$results = dbFetchRows('SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysName` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` ORDER BY `hostname`', [Auth::id()]);
} else {
$results = [];
}
foreach ($results as $data) {
if ($data['device_id'] == $vars['device_id']) {
$deviceselected = "selected";
$deviceselected = 'selected';
} else {
$deviceselected = "";
$deviceselected = '';
}
$output .= "<option value='" . $data['device_id'] . "' " . $deviceselected . ">" . format_hostname($data) . "</option>";
$output .= "<option value='" . $data['device_id'] . "' " . $deviceselected . '>' . format_hostname($data) . '</option>';
}
$output .= "</select>&nbsp;";
$output .= '</select>&nbsp;';
if (strlen($vars['hostname'])) {
$hasvalue = "value='" . $vars['hostname'] . "'";
} else {
$hasvalue = "";
$hasvalue = '';
}
$output .= "<input type='text' name='hostname' id='hostname' title='Hostname' class='form-control input-sm' " . $hasvalue . " placeholder='Hostname'>";
$output .= "</div>&nbsp;";
$output .= '</div>&nbsp;';
switch ($vars['state']) {
case "up":
$isup = "selected";
$isdown = "";
$admindown = "";
case 'up':
$isup = 'selected';
$isdown = '';
$admindown = '';
break;
case "down":
$isup = "";
$isdown = "selected";
$admindown = "";
case 'down':
$isup = '';
$isdown = 'selected';
$admindown = '';
break;
case "admindown":
$isup = "";
$isdown = "";
$admindown = "selected";
case 'admindown':
$isup = '';
$isdown = '';
$admindown = 'selected';
break;
}
$output .= "<div class='form-group'>";
$output .= "<select name='state' id='state' class='form-control input-sm'>";
$output .= "<option value=''>All States</option>";
$output .= "<option value='up' " . $isup . ">Up</option>";
$output .= "<option value='down' " . $isdown . ">Down</option>";
$output .= "<option value='admindown' " . $admindown . ">Shutdown</option>";
$output .= "</select>&nbsp;";
$output .= "<option value='up' " . $isup . '>Up</option>';
$output .= "<option value='down' " . $isdown . '>Down</option>';
$output .= "<option value='admindown' " . $admindown . '>Shutdown</option>';
$output .= '</select>&nbsp;';
$output .= "<select name='ifSpeed' id='ifSpeed' class='form-control input-sm'>";
$output .= "<option value=''>All Speeds</option>";
@@ -174,16 +174,16 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars
foreach ($ifSpeed as $data) {
if ($data['ifSpeed']) {
if ($data['ifSpeed'] == $vars['ifSpeed']) {
$speedselected = "selected";
$speedselected = 'selected';
} else {
$speedselected = "";
$speedselected = '';
}
$output .= "<option value='" . $data['ifSpeed'] . "'" . $speedselected . ">" . humanspeed($data['ifSpeed']) . "</option>";
$output .= "<option value='" . $data['ifSpeed'] . "'" . $speedselected . '>' . humanspeed($data['ifSpeed']) . '</option>';
}
}
$output .= "</select>&nbsp;";
$output .= "</div>";
$output .= '</select>&nbsp;';
$output .= '</div>';
$output .= "<div class='form-group'>";
$output .= "<select name='ifType' id='ifType' class='form-control input-sm'>";
$output .= "<option value=''>All Media</option>";
@@ -197,22 +197,22 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars
foreach ($ifType as $data) {
if ($data['ifType']) {
if ($data['ifType'] == $vars['ifType']) {
$dataselected = "selected";
$dataselected = 'selected';
} else {
$dataselected = "";
$dataselected = '';
}
$output .= "<option value='" . clean_bootgrid($data['ifType']) . "' " . $dataselected . ">" . clean_bootgrid($data['ifType']) . "</option>";
$output .= "<option value='" . clean_bootgrid($data['ifType']) . "' " . $dataselected . '>' . clean_bootgrid($data['ifType']) . '</option>';
}
}
$output .= "</select>&nbsp;";
$output .= '</select>&nbsp;';
$output .= "<select name='port_descr_type' id='port_descr_type' class='form-control input-sm'>";
$output .= "<option value=''>All Port Types</option>";
if (Auth::user()->hasGlobalRead()) {
$sql = "SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr_type` ORDER BY `port_descr_type`";
$sql = 'SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr_type` ORDER BY `port_descr_type`';
} else {
$sql = "SELECT `port_descr_type` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `port_descr_type` ORDER BY `port_descr_type`";
$sql = 'SELECT `port_descr_type` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `port_descr_type` ORDER BY `port_descr_type`';
$param[] = [Auth::id(), Auth::id()];
}
$port_descr_type = Port::select('port_descr_type')
@@ -224,25 +224,25 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars
foreach ($port_descr_type as $data) {
if ($data['port_descr_type']) {
if ($data['port_descr_type'] == $vars['port_descr_type']) {
$portdescrib = "selected";
$portdescrib = 'selected';
} else {
$portdescrib = "";
$portdescrib = '';
}
$output .= "<option value='" . clean_bootgrid($data['port_descr_type']) . "' " . $portdescrib . ">" . ucfirst(clean_bootgrid($data['port_descr_type'])) . "</option>";
$output .= "<option value='" . clean_bootgrid($data['port_descr_type']) . "' " . $portdescrib . '>' . ucfirst(clean_bootgrid($data['port_descr_type'])) . '</option>';
}
}
$output .= "</select>&nbsp;";
$output .= "</div>";
$output .= '</select>&nbsp;';
$output .= '</div>';
$output .= "<div class='form-group'>";
if (strlen($vars['ifAlias'])) {
$ifaliasvalue = "value='" . $vars['ifAlias'] . "'";
}
$output .= "</div>";
$output .= '</div>';
$output .= "</div>";
$output .= '</div>';
$output .= "<div style='text-align:left;'>";
$output .= "<input title='Port Description' type='text' name='ifAlias' id='ifAlias' class='form-control input-sm' " . $ifaliasvalue . " placeholder='Port Description'>&nbsp;";
@@ -254,61 +254,61 @@ if ((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || ! isset($vars
$location_id = $location_row['id'];
if ($location) {
if ($location_id == $vars['location']) {
$locationselected = "selected";
$locationselected = 'selected';
} else {
$locationselected = "";
$locationselected = '';
}
$ui_location = strlen($location) > 15 ? substr($location, 0, 15) . "..." : $location;
$output .= "<option value='$location_id' $locationselected>" . clean_bootgrid($ui_location) . "</option>";
$ui_location = strlen($location) > 15 ? substr($location, 0, 15) . '...' : $location;
$output .= "<option value='$location_id' $locationselected>" . clean_bootgrid($ui_location) . '</option>';
}
}
$output .= "</select>&nbsp;";
$output .= '</select>&nbsp;';
if ($vars['ignore']) {
$ignorecheck = "checked";
$ignorecheck = 'checked';
} else {
$ignorecheck = "";
$ignorecheck = '';
}
if ($vars['disabled']) {
$disabledcheck = "checked";
$disabledcheck = 'checked';
} else {
$disabledcheck = "";
$disabledcheck = '';
}
if ($vars['deleted']) {
$deletedcheck = "checked";
$deletedcheck = 'checked';
} else {
$deletedcheck = "";
$deletedcheck = '';
}
$output .= "<label for='ignore'>Ignored</label>&nbsp;";
$output .= "<input type='checkbox' id='ignore' name='ignore' value='1' " . $ignorecheck . ">&nbsp;";
$output .= "<input type='checkbox' id='ignore' name='ignore' value='1' " . $ignorecheck . '>&nbsp;';
$output .= "<label for='disabled'>Disabled</label>&nbsp;";
$output .= "<input type='checkbox' id='disabled' name='disabled' value='1' " . $disabledcheck . ">&nbsp;";
$output .= "<input type='checkbox' id='disabled' name='disabled' value='1' " . $disabledcheck . '>&nbsp;';
$output .= "<label for='deleted'>Deleted</label>&nbsp;";
$output .= "<input type='checkbox' id='deleted' name='deleted' value='1' " . $deletedcheck . ">&nbsp;";
$output .= "<input type='checkbox' id='deleted' name='deleted' value='1' " . $deletedcheck . '>&nbsp;';
$output .= "<button type='submit' class='btn btn-default btn-sm'>Search</button>&nbsp;";
$output .= "<a class='btn btn-default btn-sm' href='" . generate_url(['page' => 'ports', 'section' => $vars['section'], 'bare' => $vars['bare']]) . "' title='Reset critera to default.'>Reset</a>";
$output .= "</div>";
$output .= '</div>';
$output .= "</form>";
$output .= "</div>";
$output .= '</form>';
$output .= '</div>';
}
$param = [];
if (! isset($vars['ignore'])) {
$vars['ignore'] = "0";
$vars['ignore'] = '0';
}
if (! isset($vars['disabled'])) {
$vars['disabled'] = "0";
$vars['disabled'] = '0';
}
if (! isset($vars['deleted'])) {
$vars['deleted'] = "0";
$vars['deleted'] = '0';
}
$where = '';
@@ -316,40 +316,40 @@ $ignore_filter = 0;
$disabled_filter = 0;
foreach ($vars as $var => $value) {
if ($value != "") {
if ($value != '') {
switch ($var) {
case 'hostname':
$where .= " AND D.hostname LIKE ?";
$param[] = "%" . $value . "%";
$where .= ' AND D.hostname LIKE ?';
$param[] = '%' . $value . '%';
break;
case 'location':
if (is_int($value)) {
$where .= " AND L.id = ?";
$where .= ' AND L.id = ?';
$param[] = $value;
} else {
$where .= " AND L.location LIKE ?";
$param[] = "%" . $value . "%";
$where .= ' AND L.location LIKE ?';
$param[] = '%' . $value . '%';
}
break;
case 'device_id':
$where .= " AND D.device_id = ?";
$where .= ' AND D.device_id = ?';
$param[] = $value;
break;
case 'deleted':
if ($value == 1 || $value == 'yes') {
$where .= " AND `I`.`deleted` = 1";
$where .= ' AND `I`.`deleted` = 1';
$ignore_filter = 1;
}
break;
case 'ignore':
if ($value == 1 || $value == 'yes') {
$where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0";
$where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0';
$ignore_filter = 1;
}
break;
case 'disabled':
if ($value == 1 || $value == 'yes') {
$where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0";
$where .= ' AND `I`.`disabled` = 1 AND `I`.`deleted` = 0';
$disabled_filter = 1;
}
break;
@@ -366,7 +366,7 @@ foreach ($vars as $var => $value) {
case 'ifAlias':
case 'port_descr_type':
$where .= " AND I.$var LIKE ?";
$param[] = "%" . $value . "%";
$param[] = '%' . $value . '%';
break;
case 'errors':
if ($value == 1 || $value == 'yes') {
@@ -374,17 +374,17 @@ foreach ($vars as $var => $value) {
}
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 = ?";
$param[] = "up";
$param[] = "up";
} elseif ($value == "admindown") {
$where .= " AND I.ifAdminStatus = ? AND D.ignore = 0";
$param[] = "down";
if ($value == 'down') {
$where .= ' AND I.ifAdminStatus = ? AND I.ifOperStatus = ?';
$param[] = 'up';
$param[] = 'down';
} elseif ($value == 'up') {
$where .= ' AND I.ifAdminStatus = ? AND I.ifOperStatus = ?';
$param[] = 'up';
$param[] = 'up';
} elseif ($value == 'admindown') {
$where .= ' AND I.ifAdminStatus = ? AND D.ignore = 0';
$param[] = 'down';
}
break;
case 'purge':
@@ -409,10 +409,10 @@ foreach ($vars as $var => $value) {
}
if ($ignore_filter == 0 && $disabled_filter == 0) {
$where .= " AND `I`.`ignore` = 0 AND `I`.`disabled` = 0 AND `I`.`deleted` = 0";
$where .= ' AND `I`.`ignore` = 0 AND `I`.`disabled` = 0 AND `I`.`deleted` = 0';
}
$query = "SELECT * FROM `ports` AS I, `devices` AS D LEFT JOIN `locations` AS L ON D.location_id = L.id WHERE I.device_id = D.device_id" . $where . " " . $query_sort;
$query = 'SELECT * FROM `ports` AS I, `devices` AS D LEFT JOIN `locations` AS L ON D.location_id = L.id WHERE I.device_id = D.device_id' . $where . ' ' . $query_sort;
$row = 1;
[$format, $subformat] = explode('_', basename($vars['format']));