@@ -20,7 +20,8 @@ |
||
| 20 | 20 | if (Auth::guard($guard)->guest()) { |
| 21 | 21 | if ($request->ajax() || $request->wantsJson()) { |
| 22 | 22 | return response('Unauthorized.', 401); |
| 23 | - } else { |
|
| 23 | + } |
|
| 24 | + else { |
|
| 24 | 25 | return redirect()->guest('login'); |
| 25 | 26 | } |
| 26 | 27 | } |
@@ -102,7 +102,8 @@ |
||
| 102 | 102 | } catch(\Exception $e) { |
| 103 | 103 | if(starts_with($e->getMessage(), 'unserialize():')) { |
| 104 | 104 | return $value; |
| 105 | - } else { |
|
| 105 | + } |
|
| 106 | + else { |
|
| 106 | 107 | throw $e; |
| 107 | 108 | } |
| 108 | 109 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * Update a notifications status. |
| 46 | 46 | * |
| 47 | - * @return \Illuminate\Http\Response |
|
| 47 | + * @return \Illuminate\Http\JsonResponse |
|
| 48 | 48 | */ |
| 49 | 49 | public function update($id, $action) |
| 50 | 50 | { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Create a new notification |
| 57 | 57 | * |
| 58 | - * @return \Illuminate\Http\Response |
|
| 58 | + * @return \Illuminate\Http\JsonResponse |
|
| 59 | 59 | */ |
| 60 | 60 | public function create(Request $request) |
| 61 | 61 | { |
@@ -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 | } |
@@ -76,7 +76,8 @@ |
||
| 76 | 76 | if ($type == 'settings-value') { |
| 77 | 77 | Settings::set($key, Input::get('value')); |
| 78 | 78 | return response('OK', 200); |
| 79 | - } elseif ($type == 'settings-array') { |
|
| 79 | + } |
|
| 80 | + elseif ($type == 'settings-array') { |
|
| 80 | 81 | $new = Input::get('value'); |
| 81 | 82 | $current = Settings::get($key); |
| 82 | 83 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * Store a newly created resource in storage. |
| 58 | 58 | * |
| 59 | 59 | * @param \Illuminate\Http\Request $request |
| 60 | - * @return \Illuminate\Http\Response |
|
| 60 | + * @return \Illuminate\Http\JsonResponse |
|
| 61 | 61 | */ |
| 62 | 62 | public function store(Request $request) |
| 63 | 63 | { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * Display the specified resource. |
| 71 | 71 | * |
| 72 | 72 | * @param int $id |
| 73 | - * @return \Illuminate\Http\Response |
|
| 73 | + * @return \Illuminate\Http\RedirectResponse |
|
| 74 | 74 | */ |
| 75 | 75 | public function show($id) |
| 76 | 76 | { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param \Illuminate\Http\Request $request |
| 96 | 96 | * @param int $id |
| 97 | - * @return \Illuminate\Http\Response |
|
| 97 | + * @return \Illuminate\Http\JsonResponse |
|
| 98 | 98 | */ |
| 99 | 99 | public function update(Request $request, $id) |
| 100 | 100 | { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * Remove the specified resource from storage. |
| 109 | 109 | * |
| 110 | 110 | * @param int $id |
| 111 | - * @return \Illuminate\Http\Response |
|
| 111 | + * @return \Illuminate\Http\JsonResponse |
|
| 112 | 112 | */ |
| 113 | 113 | public function destroy($id) |
| 114 | 114 | { |
@@ -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 | } |
@@ -203,7 +203,7 @@ |
||
| 203 | 203 | * Convert a v1 device group pattern to v2 style |
| 204 | 204 | * |
| 205 | 205 | * @param $pattern |
| 206 | - * @return array |
|
| 206 | + * @return string |
|
| 207 | 207 | */ |
| 208 | 208 | private function convertV1Pattern($pattern) |
| 209 | 209 | { |
@@ -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 | |
@@ -38,6 +38,9 @@ |
||
| 38 | 38 | return json_encode(self::generateMacroFilter('alert.macros.rule', self::generateTableFilter())); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $setting |
|
| 43 | + */ |
|
| 41 | 44 | private static function generateMacroFilter($setting, $filter = []) |
| 42 | 45 | { |
| 43 | 46 | foreach (Settings::get($setting, []) as $key => $value) { |
@@ -60,7 +60,6 @@ |
||
| 60 | 60 | /** |
| 61 | 61 | * Display the alerts widget. |
| 62 | 62 | * |
| 63 | - * @param AlertsDataTable $dataTable |
|
| 64 | 63 | * @param null $action |
| 65 | 64 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
| 66 | 65 | */ |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | if ($request->device_id) { |
| 53 | 53 | return $EventlogDataTable->forDevice($request->device_id) |
| 54 | 54 | ->render('widgets.eventlog', compact(['tableName', 'action'])); |
| 55 | - } else { |
|
| 55 | + } |
|
| 56 | + else { |
|
| 56 | 57 | return $EventlogDataTable->render('widgets.eventlog', compact(['tableName', 'action'])); |
| 57 | 58 | } |
| 58 | 59 | } |
@@ -95,7 +96,8 @@ discard block |
||
| 95 | 96 | $uptime = Settings::get('uptime_warning', 84600); |
| 96 | 97 | if ($request->user()->hasGlobalRead()) { |
| 97 | 98 | $devices = Device::where('ignore', '=', 0)->get(); |
| 98 | - } else { |
|
| 99 | + } |
|
| 100 | + else { |
|
| 99 | 101 | $devices = User::find($request->user()->user_id)->devices()->where('ignore', '=', 0)->get(); |
| 100 | 102 | } |
| 101 | 103 | $count = ['warn' => 0, 'up' => 0, 'down' => 0]; |
@@ -103,10 +105,12 @@ discard block |
||
| 103 | 105 | if ($device->status == 1) { |
| 104 | 106 | if (($device->uptime < $uptime) && ($device->uptime != '0')) { |
| 105 | 107 | $count['warn']++; |
| 106 | - } else { |
|
| 108 | + } |
|
| 109 | + else { |
|
| 107 | 110 | $count['up']++; |
| 108 | 111 | } |
| 109 | - } else { |
|
| 112 | + } |
|
| 113 | + else { |
|
| 110 | 114 | $count['down']++; |
| 111 | 115 | } |
| 112 | 116 | } |
@@ -137,7 +141,8 @@ discard block |
||
| 137 | 141 | $count['ports']['down'] = Port::isDown()->count(); |
| 138 | 142 | $count['ports']['ignored'] = Port::isIgnored()->count(); |
| 139 | 143 | $count['ports']['disabled'] = Port::isDisabled()->count(); |
| 140 | - } else { |
|
| 144 | + } |
|
| 145 | + else { |
|
| 141 | 146 | $user = User::find($request->user()->user_id); |
| 142 | 147 | |
| 143 | 148 | $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 | } |