@@ -26,13 +26,10 @@ |
||
| 26 | 26 | use Alert; |
| 27 | 27 | use DB; |
| 28 | 28 | use Log; |
| 29 | -use Validator; |
|
| 30 | - |
|
| 31 | 29 | use Pterodactyl\Models; |
| 32 | 30 | use Pterodactyl\Repositories\ServiceRepository; |
| 33 | 31 | use Pterodactyl\Exceptions\DisplayException; |
| 34 | 32 | use Pterodactyl\Exceptions\DisplayValidationException; |
| 35 | - |
|
| 36 | 33 | use Pterodactyl\Http\Controllers\Controller; |
| 37 | 34 | use Illuminate\Http\Request; |
| 38 | 35 | |
@@ -186,15 +186,15 @@ |
||
| 186 | 186 | 'user_editable' => '0', |
| 187 | 187 | 'required' => '0' |
| 188 | 188 | ]; |
| 189 | - foreach($request->except(['_token']) as $id => $val) { |
|
| 190 | - $data[str_replace($variable.'_', '', $id)] = $val; |
|
| 189 | + foreach ($request->except(['_token']) as $id => $val) { |
|
| 190 | + $data[str_replace($variable . '_', '', $id)] = $val; |
|
| 191 | 191 | } |
| 192 | 192 | $repo->update($variable, $data); |
| 193 | 193 | Alert::success('Successfully updated variable.')->flash(); |
| 194 | 194 | } catch (DisplayValidationException $ex) { |
| 195 | 195 | $data = []; |
| 196 | - foreach(json_decode($ex->getMessage(), true) as $id => $val) { |
|
| 197 | - $data[$variable.'_'.$id] = $val; |
|
| 196 | + foreach (json_decode($ex->getMessage(), true) as $id => $val) { |
|
| 197 | + $data[$variable . '_' . $id] = $val; |
|
| 198 | 198 | } |
| 199 | 199 | return redirect()->route('admin.services.option', [$service, $option])->withErrors((object) $data)->withInput(); |
| 200 | 200 | } catch (DisplayException $ex) { |
@@ -25,16 +25,12 @@ |
||
| 25 | 25 | namespace Pterodactyl\Http\Controllers\Admin; |
| 26 | 26 | |
| 27 | 27 | use Alert; |
| 28 | -use Settings; |
|
| 29 | -use Mail; |
|
| 30 | 28 | use Log; |
| 31 | 29 | use Pterodactyl\Models\User; |
| 32 | 30 | use Pterodactyl\Repositories\UserRepository; |
| 33 | 31 | use Pterodactyl\Models\Server; |
| 34 | - |
|
| 35 | 32 | use Pterodactyl\Exceptions\DisplayException; |
| 36 | 33 | use Pterodactyl\Exceptions\DisplayValidationException; |
| 37 | - |
|
| 38 | 34 | use Pterodactyl\Http\Controllers\Controller; |
| 39 | 35 | use Illuminate\Http\Request; |
| 40 | 36 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $query = User::select('users.*'); |
| 55 | 55 | if ($request->input('filter') && !is_null($request->input('filter'))) { |
| 56 | 56 | preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches); |
| 57 | - foreach($matches[0] as $match) { |
|
| 57 | + foreach ($matches[0] as $match) { |
|
| 58 | 58 | $match = str_replace('"', '', $match); |
| 59 | 59 | if (strpos($match, ':')) { |
| 60 | 60 | list($field, $term) = explode(':', $match); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $repo->delete($id); |
| 106 | 106 | Alert::success('Successfully deleted user from system.')->flash(); |
| 107 | 107 | return redirect()->route('admin.users'); |
| 108 | - } catch(DisplayException $ex) { |
|
| 108 | + } catch (DisplayException $ex) { |
|
| 109 | 109 | Alert::danger($ex->getMessage())->flash(); |
| 110 | 110 | } catch (\Exception $ex) { |
| 111 | 111 | Log::error($ex); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function getJson(Request $request) |
| 159 | 159 | { |
| 160 | - foreach(User::select('email')->get() as $user) { |
|
| 160 | + foreach (User::select('email')->get() as $user) { |
|
| 161 | 161 | $resp[] = $user->email; |
| 162 | 162 | } |
| 163 | 163 | return $resp; |
@@ -24,12 +24,8 @@ |
||
| 24 | 24 | namespace Pterodactyl\Http\Controllers\API; |
| 25 | 25 | |
| 26 | 26 | use Illuminate\Http\Request; |
| 27 | - |
|
| 28 | 27 | use Pterodactyl\Models; |
| 29 | -use Pterodactyl\Transformers\NodeTransformer; |
|
| 30 | -use Pterodactyl\Transformers\AllocationTransformer; |
|
| 31 | 28 | use Pterodactyl\Repositories\NodeRepository; |
| 32 | - |
|
| 33 | 29 | use Pterodactyl\Exceptions\DisplayValidationException; |
| 34 | 30 | use Pterodactyl\Exceptions\DisplayException; |
| 35 | 31 | use Dingo\Api\Exception\ResourceException; |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | * @Versions({"v1"}) |
| 221 | 221 | * @Response(200) |
| 222 | 222 | */ |
| 223 | - public function allocations(Request $request) |
|
| 224 | - { |
|
| 225 | - $allocations = Models\Allocation::all(); |
|
| 226 | - if ($allocations->count() < 1) { |
|
| 227 | - throw new NotFoundHttpException('No allocations have been created.'); |
|
| 228 | - } |
|
| 229 | - return $allocations; |
|
| 230 | - } |
|
| 223 | + public function allocations(Request $request) |
|
| 224 | + { |
|
| 225 | + $allocations = Models\Allocation::all(); |
|
| 226 | + if ($allocations->count() < 1) { |
|
| 227 | + throw new NotFoundHttpException('No allocations have been created.'); |
|
| 228 | + } |
|
| 229 | + return $allocations; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * List Node Allocation based on assigned to ID |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * @Versions({"v1"}) |
| 239 | 239 | * @Response(200) |
| 240 | 240 | */ |
| 241 | - public function allocationsView(Request $request, $id) |
|
| 242 | - { |
|
| 241 | + public function allocationsView(Request $request, $id) |
|
| 242 | + { |
|
| 243 | 243 | $query = Models\Allocation::where('assigned_to', $id)->get(); |
| 244 | 244 | try { |
| 245 | 245 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | try { |
| 103 | 103 | $node = new NodeRepository; |
| 104 | 104 | $new = $node->create($request->all()); |
| 105 | - return [ 'id' => $new ]; |
|
| 105 | + return ['id' => $new]; |
|
| 106 | 106 | } catch (DisplayValidationException $ex) { |
| 107 | 107 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
| 108 | 108 | } catch (DisplayException $ex) { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $node = Models\Node::where('id', $id); |
| 131 | 131 | |
| 132 | 132 | if (!is_null($request->input('fields'))) { |
| 133 | - foreach(explode(',', $request->input('fields')) as $field) { |
|
| 133 | + foreach (explode(',', $request->input('fields')) as $field) { |
|
| 134 | 134 | if (!empty($field)) { |
| 135 | 135 | $node->addSelect($field); |
| 136 | 136 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | return $this->response->noContent(); |
| 274 | 274 | } catch (DisplayException $ex) { |
| 275 | 275 | throw new ResourceException($ex->getMessage()); |
| 276 | - } catch(\Exception $e) { |
|
| 276 | + } catch (\Exception $e) { |
|
| 277 | 277 | throw new ServiceUnavailableHttpException('An error occured while attempting to delete this node.'); |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -24,12 +24,9 @@ |
||
| 24 | 24 | namespace Pterodactyl\Http\Controllers\API; |
| 25 | 25 | |
| 26 | 26 | use Illuminate\Http\Request; |
| 27 | - |
|
| 28 | 27 | use Log; |
| 29 | 28 | use Pterodactyl\Models; |
| 30 | -use Pterodactyl\Transformers\ServerTransformer; |
|
| 31 | 29 | use Pterodactyl\Repositories\ServerRepository; |
| 32 | - |
|
| 33 | 30 | use Pterodactyl\Exceptions\DisplayValidationException; |
| 34 | 31 | use Pterodactyl\Exceptions\DisplayException; |
| 35 | 32 | use Dingo\Api\Exception\ResourceException; |
@@ -66,11 +66,11 @@ |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | - * Create Server |
|
| 70 | - * |
|
| 71 | - * @Post("/servers") |
|
| 72 | - * @Versions({"v1"}) |
|
| 73 | - * @Response(201) |
|
| 69 | + * Create Server |
|
| 70 | + * |
|
| 71 | + * @Post("/servers") |
|
| 72 | + * @Versions({"v1"}) |
|
| 73 | + * @Response(201) |
|
| 74 | 74 | */ |
| 75 | 75 | public function create(Request $request) |
| 76 | 76 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | try { |
| 78 | 78 | $server = new ServerRepository; |
| 79 | 79 | $new = $server->create($request->all()); |
| 80 | - return [ 'id' => $new ]; |
|
| 80 | + return ['id' => $new]; |
|
| 81 | 81 | } catch (DisplayValidationException $ex) { |
| 82 | 82 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
| 83 | 83 | } catch (DisplayException $ex) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $query = Models\Server::where('id', $id); |
| 107 | 107 | |
| 108 | 108 | if (!is_null($request->input('fields'))) { |
| 109 | - foreach(explode(',', $request->input('fields')) as $field) { |
|
| 109 | + foreach (explode(',', $request->input('fields')) as $field) { |
|
| 110 | 110 | if (!empty($field)) { |
| 111 | 111 | $query->addSelect($field); |
| 112 | 112 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | return $this->response->noContent(); |
| 299 | 299 | } catch (DisplayException $ex) { |
| 300 | 300 | throw new ResourceException($ex->getMessage()); |
| 301 | - } catch(\Exception $e) { |
|
| 301 | + } catch (\Exception $e) { |
|
| 302 | 302 | throw new ServiceUnavailableHttpException('An error occured while attempting to delete this server.'); |
| 303 | 303 | } |
| 304 | 304 | } |
@@ -24,10 +24,7 @@ |
||
| 24 | 24 | namespace Pterodactyl\Http\Controllers\API; |
| 25 | 25 | |
| 26 | 26 | use Illuminate\Http\Request; |
| 27 | - |
|
| 28 | 27 | use Pterodactyl\Models; |
| 29 | -use Pterodactyl\Transformers\ServiceTransformer; |
|
| 30 | - |
|
| 31 | 28 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
| 32 | 29 | |
| 33 | 30 | /** |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $options = Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image')->where('parent_service', $service->id)->get(); |
| 57 | - foreach($options as &$opt) { |
|
| 57 | + foreach ($options as &$opt) { |
|
| 58 | 58 | $opt->variables = Models\ServiceVariables::where('option_id', $opt->id)->get(); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -23,11 +23,8 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | namespace Pterodactyl\Http\Controllers\API\User; |
| 25 | 25 | |
| 26 | -use Auth; |
|
| 27 | -use Dingo; |
|
| 28 | 26 | use Pterodactyl\Models; |
| 29 | 27 | use Illuminate\Http\Request; |
| 30 | - |
|
| 31 | 28 | use Pterodactyl\Http\Controllers\API\BaseController; |
| 32 | 29 | |
| 33 | 30 | class InfoController extends BaseController |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $servers = Models\Server::getUserServers(); |
| 38 | 38 | $response = []; |
| 39 | 39 | |
| 40 | - foreach($servers as &$server) { |
|
| 40 | + foreach ($servers as &$server) { |
|
| 41 | 41 | $response = array_merge($response, [[ |
| 42 | 42 | 'id' => $server->uuidShort, |
| 43 | 43 | 'uuid' => $server->uuid, |
@@ -27,7 +27,6 @@ |
||
| 27 | 27 | use Log; |
| 28 | 28 | use Pterodactyl\Models; |
| 29 | 29 | use Illuminate\Http\Request; |
| 30 | - |
|
| 31 | 30 | use Pterodactyl\Http\Controllers\API\BaseController; |
| 32 | 31 | |
| 33 | 32 | class ServerController extends BaseController |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $allocations = Models\Allocation::select('id', 'ip', 'port', 'ip_alias as alias')->where('assigned_to', $server->id)->get(); |
| 64 | - foreach($allocations as &$allocation) { |
|
| 64 | + foreach ($allocations as &$allocation) { |
|
| 65 | 65 | $allocation->default = ($allocation->id === $server->allocation); |
| 66 | 66 | unset($allocation->id); |
| 67 | 67 | } |
@@ -24,13 +24,9 @@ |
||
| 24 | 24 | namespace Pterodactyl\Http\Controllers\API; |
| 25 | 25 | |
| 26 | 26 | use Illuminate\Http\Request; |
| 27 | - |
|
| 28 | 27 | use Dingo\Api\Exception\ResourceException; |
| 29 | - |
|
| 30 | 28 | use Pterodactyl\Models; |
| 31 | -use Pterodactyl\Transformers\UserTransformer; |
|
| 32 | 29 | use Pterodactyl\Repositories\UserRepository; |
| 33 | - |
|
| 34 | 30 | use Pterodactyl\Exceptions\DisplayValidationException; |
| 35 | 31 | use Pterodactyl\Exceptions\DisplayException; |
| 36 | 32 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $query = Models\User::where('id', $id); |
| 84 | 84 | |
| 85 | 85 | if (!is_null($request->input('fields'))) { |
| 86 | - foreach(explode(',', $request->input('fields')) as $field) { |
|
| 86 | + foreach (explode(',', $request->input('fields')) as $field) { |
|
| 87 | 87 | if (!empty($field)) { |
| 88 | 88 | $query->addSelect($field); |
| 89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $user = $query->first(); |
| 99 | 99 | $userArray = $user->toArray(); |
| 100 | - $userArray['servers'] = Models\Server::select('id', 'uuid', 'node', 'suspended')->where('owner', $user->id)->get(); |
|
| 100 | + $userArray['servers'] = Models\Server::select('id', 'uuid', 'node', 'suspended')->where('owner', $user->id)->get(); |
|
| 101 | 101 | |
| 102 | 102 | return $userArray; |
| 103 | 103 | } catch (NotFoundHttpException $ex) { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | try { |
| 130 | 130 | $user = new UserRepository; |
| 131 | 131 | $create = $user->create($request->input('email'), $request->input('password'), $request->input('admin'), $request->input('custom_id')); |
| 132 | - return [ 'id' => $create ]; |
|
| 132 | + return ['id' => $create]; |
|
| 133 | 133 | } catch (DisplayValidationException $ex) { |
| 134 | 134 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
| 135 | 135 | } catch (DisplayException $ex) { |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | * Check if the provided user has TOTP enabled. |
| 142 | 142 | * |
| 143 | 143 | * @param \Illuminate\Http\Request $request |
| 144 | - * @return \Illuminate\Http\Response |
|
| 144 | + * @return \Illuminate\Http\JsonResponse |
|
| 145 | 145 | */ |
| 146 | 146 | public function checkTotp(Request $request) |
| 147 | 147 | { |
@@ -25,17 +25,11 @@ |
||
| 25 | 25 | namespace Pterodactyl\Http\Controllers\Auth; |
| 26 | 26 | |
| 27 | 27 | use Pterodactyl\Models\User; |
| 28 | - |
|
| 29 | 28 | use Auth; |
| 30 | 29 | use Alert; |
| 31 | -use Validator; |
|
| 32 | - |
|
| 33 | 30 | use Pterodactyl\Http\Controllers\Controller; |
| 34 | 31 | use PragmaRX\Google2FA\Google2FA; |
| 35 | 32 | use Illuminate\Http\Request; |
| 36 | -use Illuminate\Foundation\Auth\ThrottlesLogins; |
|
| 37 | -use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; |
|
| 38 | - |
|
| 39 | 33 | use Illuminate\Foundation\Auth\AuthenticatesUsers; |
| 40 | 34 | |
| 41 | 35 | class LoginController extends Controller |
@@ -117,9 +117,9 @@ |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Verify TOTP Token was Valid |
| 120 | - if(Auth::user()->use_totp === 1) { |
|
| 120 | + if (Auth::user()->use_totp === 1) { |
|
| 121 | 121 | $G2FA = new Google2FA(); |
| 122 | - if(is_null($request->input('totp_token')) || !$G2FA->verifyKey(Auth::user()->totp_secret, $request->input('totp_token'))) { |
|
| 122 | + if (is_null($request->input('totp_token')) || !$G2FA->verifyKey(Auth::user()->totp_secret, $request->input('totp_token'))) { |
|
| 123 | 123 | |
| 124 | 124 | if (!$lockedOut) { |
| 125 | 125 | $this->incrementLoginAttempts($request); |