@@ -82,7 +82,8 @@ discard block |
||
| 82 | 82 | $uptime = Settings::get('uptime_warning', 84600); |
| 83 | 83 | if ($request->user()->hasGlobalRead()) { |
| 84 | 84 | $devices = Device::where('ignore', '=', 0)->get(); |
| 85 | - } else { |
|
| 85 | + } |
|
| 86 | + else { |
|
| 86 | 87 | $devices = User::find($request->user()->user_id)->devices()->where('ignore', '=', 0)->get(); |
| 87 | 88 | } |
| 88 | 89 | $count = ['warn' => 0, 'up' => 0, 'down' => 0]; |
@@ -90,10 +91,12 @@ discard block |
||
| 90 | 91 | if ($device->status == 1) { |
| 91 | 92 | if (($device->uptime < $uptime) && ($device->uptime != '0')) { |
| 92 | 93 | $count['warn']++; |
| 93 | - } else { |
|
| 94 | + } |
|
| 95 | + else { |
|
| 94 | 96 | $count['up']++; |
| 95 | 97 | } |
| 96 | - } else { |
|
| 98 | + } |
|
| 99 | + else { |
|
| 97 | 100 | $count['down']++; |
| 98 | 101 | } |
| 99 | 102 | } |
@@ -122,7 +125,8 @@ discard block |
||
| 122 | 125 | $count['ports']['down'] = Port::isDown()->count(); |
| 123 | 126 | $count['ports']['ignored'] = Port::isIgnored()->count(); |
| 124 | 127 | $count['ports']['disabled'] = Port::isDisabled()->count(); |
| 125 | - } else { |
|
| 128 | + } |
|
| 129 | + else { |
|
| 126 | 130 | $user = User::find($request->user()->user_id); |
| 127 | 131 | |
| 128 | 132 | $count['devices']['total'] = $user->devices()->count(); |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | public function show(Request $request, $id) |
| 75 | 75 | { |
| 76 | - $widget = Widgets::find($id); |
|
| 76 | + $widget = Widgets::find($id); |
|
| 77 | 77 | return array('widget' => $widget); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -195,7 +195,8 @@ |
||
| 195 | 195 | $user = \Auth::user(); |
| 196 | 196 | if (!is_null($user) && $user->isAdmin()) { |
| 197 | 197 | return false; |
| 198 | - } else { |
|
| 198 | + } |
|
| 199 | + else { |
|
| 199 | 200 | return 'auth'; |
| 200 | 201 | } |
| 201 | 202 | } |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
| 20 | 20 | */ |
| 21 | - public function index(DeviceDataTable $dataTable, $group_id=-1) |
|
| 21 | + public function index(DeviceDataTable $dataTable, $group_id = -1) |
|
| 22 | 22 | { |
| 23 | 23 | $group_name = ""; |
| 24 | - if($group_id >= 0) { |
|
| 24 | + if ($group_id >= 0) { |
|
| 25 | 25 | $dataTable->addScope(new \App\DataTables\Scopes\DeviceGroup($group_id)); |
| 26 | 26 | $group_name = DeviceGroup::find($group_id)->name; |
| 27 | 27 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $related = $this->getRelation('deviceCountRelation')->first(); |
| 94 | 94 | |
| 95 | 95 | // then return the count directly |
| 96 | - return ($related) ? (int)$related->count : 0; |
|
| 96 | + return ($related) ? (int) $related->count : 0; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | foreach (Settings::get('alert.macros.group', []) as $macro => $value) { |
| 179 | - $value = str_replace(['%', '&&', '||'], ['', 'AND', 'OR'], $value); // this might need something more complex |
|
| 179 | + $value = str_replace(['%', '&&', '||'], ['', 'AND', 'OR'], $value); // this might need something more complex |
|
| 180 | 180 | if (!str_contains($macro, ' ')) { |
| 181 | 181 | $pattern = str_replace('macros.'.$macro, '('.$value.')', $pattern); |
| 182 | 182 | } |
@@ -145,7 +145,8 @@ discard block |
||
| 145 | 145 | $query = null; |
| 146 | 146 | if (count($tables) == 1) { |
| 147 | 147 | $query = DB::table($tables[0])->select('device_id')->distinct(); |
| 148 | - } else { |
|
| 148 | + } |
|
| 149 | + else { |
|
| 149 | 150 | $query = DB::table('devices')->select('devices.device_id')->distinct(); |
| 150 | 151 | |
| 151 | 152 | foreach ($tables as $table) { |
@@ -185,7 +186,8 @@ discard block |
||
| 185 | 186 | if (str_contains($pattern, 'macros.')) { |
| 186 | 187 | if (++$x < 30) { |
| 187 | 188 | $pattern = self::applyGroupMacros($pattern, $x); |
| 188 | - } else { |
|
| 189 | + } |
|
| 190 | + else { |
|
| 189 | 191 | return false; |
| 190 | 192 | } |
| 191 | 193 | } |
@@ -249,7 +251,8 @@ discard block |
||
| 249 | 251 | if (starts_with($cur, '%')) { |
| 250 | 252 | // table and column or macro |
| 251 | 253 | $out .= substr($cur, 1).' '; |
| 252 | - } elseif (substr($cur, -1) == '~') { |
|
| 254 | + } |
|
| 255 | + elseif (substr($cur, -1) == '~') { |
|
| 253 | 256 | // like operator |
| 254 | 257 | $content = $parts[++$i]; // grab the content so we can format it |
| 255 | 258 | |
@@ -260,14 +263,18 @@ discard block |
||
| 260 | 263 | |
| 261 | 264 | $out .= "LIKE('".$this->convertRegexToLike($content)."') "; |
| 262 | 265 | |
| 263 | - } elseif ($cur == '&&') { |
|
| 266 | + } |
|
| 267 | + elseif ($cur == '&&') { |
|
| 264 | 268 | $out .= 'AND '; |
| 265 | - } elseif ($cur == '||') { |
|
| 269 | + } |
|
| 270 | + elseif ($cur == '||') { |
|
| 266 | 271 | $out .= 'OR '; |
| 267 | - } elseif (in_array($cur, $ops)) { |
|
| 272 | + } |
|
| 273 | + elseif (in_array($cur, $ops)) { |
|
| 268 | 274 | // pass-through operators |
| 269 | 275 | $out .= $cur.' '; |
| 270 | - } else { |
|
| 276 | + } |
|
| 277 | + else { |
|
| 271 | 278 | // user supplied input |
| 272 | 279 | $out .= "'".trim($cur, '"\'')."' "; // TODO: remove trim, only needed with invalid input |
| 273 | 280 | } |
@@ -300,7 +307,8 @@ discard block |
||
| 300 | 307 | // add ends appropriately |
| 301 | 308 | if ($startAnchor && !$endAnchor) { |
| 302 | 309 | $pattern .= '%'; |
| 303 | - } elseif (!$startAnchor && $endAnchor) { |
|
| 310 | + } |
|
| 311 | + elseif (!$startAnchor && $endAnchor) { |
|
| 304 | 312 | $pattern = '%'.$pattern; |
| 305 | 313 | } |
| 306 | 314 | |