@@ -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(); |
@@ -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 | } |
@@ -123,7 +123,8 @@ discard block |
||
| 123 | 123 | // can't build sql |
| 124 | 124 | return []; |
| 125 | 125 | } |
| 126 | - } else { |
|
| 126 | + } |
|
| 127 | + else { |
|
| 127 | 128 | $params = $this->params; |
| 128 | 129 | } |
| 129 | 130 | } |
@@ -134,7 +135,8 @@ discard block |
||
| 134 | 135 | $query = null; |
| 135 | 136 | if (count($tables) == 1) { |
| 136 | 137 | $query = DB::table($tables[0])->select('device_id')->distinct(); |
| 137 | - } else { |
|
| 138 | + } |
|
| 139 | + else { |
|
| 138 | 140 | $query = DB::table('devices')->select('devices.device_id')->distinct(); |
| 139 | 141 | |
| 140 | 142 | foreach ($tables as $table) { |
@@ -150,7 +152,8 @@ discard block |
||
| 150 | 152 | // match the device ids |
| 151 | 153 | if (is_null($params)) { |
| 152 | 154 | return $query->whereRaw($statement)->pluck('device_id'); |
| 153 | - } else { |
|
| 155 | + } |
|
| 156 | + else { |
|
| 154 | 157 | return $query->whereRaw($statement, $params)->pluck('device_id'); |
| 155 | 158 | } |
| 156 | 159 | } |
@@ -178,7 +181,8 @@ discard block |
||
| 178 | 181 | if (str_contains($pattern, 'macros.')) { |
| 179 | 182 | if (++$x < 30) { |
| 180 | 183 | $pattern = self::applyGroupMacros($pattern, $x); |
| 181 | - } else { |
|
| 184 | + } |
|
| 185 | + else { |
|
| 182 | 186 | return false; |
| 183 | 187 | } |
| 184 | 188 | } |
@@ -309,7 +313,8 @@ discard block |
||
| 309 | 313 | if (starts_with($cur, '%')) { |
| 310 | 314 | // table and column or macro |
| 311 | 315 | $out .= substr($cur, 1).' '; |
| 312 | - } elseif (substr($cur, -1) == '~') { |
|
| 316 | + } |
|
| 317 | + elseif (substr($cur, -1) == '~') { |
|
| 313 | 318 | // like operator |
| 314 | 319 | $content = $parts[++$i]; // grab the content so we can format it |
| 315 | 320 | |
@@ -320,14 +325,18 @@ discard block |
||
| 320 | 325 | |
| 321 | 326 | $out .= "LIKE('".$this->convertRegexToLike($content)."') "; |
| 322 | 327 | |
| 323 | - } elseif ($cur == '&&') { |
|
| 328 | + } |
|
| 329 | + elseif ($cur == '&&') { |
|
| 324 | 330 | $out .= 'AND '; |
| 325 | - } elseif ($cur == '||') { |
|
| 331 | + } |
|
| 332 | + elseif ($cur == '||') { |
|
| 326 | 333 | $out .= 'OR '; |
| 327 | - } elseif (in_array($cur, $ops)) { |
|
| 334 | + } |
|
| 335 | + elseif (in_array($cur, $ops)) { |
|
| 328 | 336 | // pass-through operators |
| 329 | 337 | $out .= $cur.' '; |
| 330 | - } else { |
|
| 338 | + } |
|
| 339 | + else { |
|
| 331 | 340 | // user supplied input |
| 332 | 341 | $out .= "'".trim($cur, '"\'')."' "; // TODO: remove trim, only needed with invalid input |
| 333 | 342 | } |
@@ -360,7 +369,8 @@ discard block |
||
| 360 | 369 | // add ends appropriately |
| 361 | 370 | if ($startAnchor && !$endAnchor) { |
| 362 | 371 | $pattern .= '%'; |
| 363 | - } elseif (!$startAnchor && $endAnchor) { |
|
| 372 | + } |
|
| 373 | + elseif (!$startAnchor && $endAnchor) { |
|
| 364 | 374 | $pattern = '%'.$pattern; |
| 365 | 375 | } |
| 366 | 376 | |