@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace App\Http\Controllers\General; |
| 27 | 27 | |
| 28 | +use App\DataTables\General\ArpDataTable; |
|
| 28 | 29 | use App\DataTables\General\IPv4DataTable; |
| 29 | 30 | use App\DataTables\General\IPv6DataTable; |
| 30 | 31 | use App\DataTables\General\MacDataTable; |
| 31 | -use App\DataTables\General\ArpDataTable; |
|
| 32 | 32 | use App\Http\Controllers\Controller; |
| 33 | 33 | use Illuminate\Http\Request; |
| 34 | 34 | |
@@ -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(); |
@@ -25,7 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace App\DataTables; |
| 27 | 27 | |
| 28 | -use App\Models\DeviceGroup; |
|
| 29 | 28 | use App\Models\Device; |
| 30 | 29 | |
| 31 | 30 | class DeviceDataTable extends BaseDataTable |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace App\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use App\DataTables\DeviceDataTable; |
| 6 | -use App\DataTables\DeviceGroupDataTable; |
|
| 7 | 6 | use App\Models\DeviceGroup; |
| 8 | 7 | use Dingo\Api\Http; |
| 9 | 8 | use Dingo\Api\Routing\Helpers; |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace App\Api\Controllers; |
| 4 | 4 | |
| 5 | 5 | use DB; |
| 6 | -use App\Http\Requests; |
|
| 7 | 6 | use Illuminate\Http\Request; |
| 8 | 7 | |
| 9 | 8 | class ApiController extends Controller |
@@ -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 | } |
@@ -144,7 +144,8 @@ discard block |
||
| 144 | 144 | $query = null; |
| 145 | 145 | if (count($tables) == 1) { |
| 146 | 146 | $query = DB::table($tables[0])->select('device_id'); |
| 147 | - } else { |
|
| 147 | + } |
|
| 148 | + else { |
|
| 148 | 149 | $query = DB::table('devices')->select('devices.device_id')->distinct(); |
| 149 | 150 | |
| 150 | 151 | foreach ($tables as $table) { |
@@ -221,14 +222,16 @@ discard block |
||
| 221 | 222 | if (starts_with($cur, '%')) { |
| 222 | 223 | // table and column |
| 223 | 224 | $out .= substr($cur, 1).' '; |
| 224 | - } elseif (substr($cur, -1) == '~') { |
|
| 225 | + } |
|
| 226 | + elseif (substr($cur, -1) == '~') { |
|
| 225 | 227 | // like operator |
| 226 | 228 | $content = $parts[++$i]; // grab the content so we can format it |
| 227 | 229 | |
| 228 | 230 | if (str_contains($content, '@')) { |
| 229 | 231 | // contains wildcard |
| 230 | 232 | $content = str_replace('@', '%', $content); |
| 231 | - } else { |
|
| 233 | + } |
|
| 234 | + else { |
|
| 232 | 235 | // assume substring |
| 233 | 236 | $content = '%'.$content.'%'; |
| 234 | 237 | } |
@@ -240,14 +243,18 @@ discard block |
||
| 240 | 243 | |
| 241 | 244 | $out .= "LIKE('".$content."') "; |
| 242 | 245 | |
| 243 | - } elseif ($cur == '&&') { |
|
| 246 | + } |
|
| 247 | + elseif ($cur == '&&') { |
|
| 244 | 248 | $out .= 'AND '; |
| 245 | - } elseif ($cur == '||') { |
|
| 249 | + } |
|
| 250 | + elseif ($cur == '||') { |
|
| 246 | 251 | $out .= 'OR '; |
| 247 | - } elseif (in_array($cur, $ops)) { |
|
| 252 | + } |
|
| 253 | + elseif (in_array($cur, $ops)) { |
|
| 248 | 254 | // passthrough operators |
| 249 | 255 | $out .= $cur.' '; |
| 250 | - } else { |
|
| 256 | + } |
|
| 257 | + else { |
|
| 251 | 258 | // user supplied input |
| 252 | 259 | $out .= "'".trim($cur, '"\'')."' "; // TODO: remove trim, only needed with invalid input |
| 253 | 260 | } |