@@ -25,18 +25,14 @@ |
||
25 | 25 | |
26 | 26 | use Crypt; |
27 | 27 | use DB; |
28 | -use Debugbar; |
|
29 | 28 | use Validator; |
30 | 29 | use Log; |
31 | - |
|
32 | 30 | use Pterodactyl\Models; |
33 | 31 | use Pterodactyl\Services\UuidService; |
34 | 32 | use Pterodactyl\Services\DeploymentService; |
35 | 33 | use Pterodactyl\Notifications\ServerCreated; |
36 | 34 | use Pterodactyl\Events\ServerDeleted; |
37 | - |
|
38 | 35 | use Pterodactyl\Exceptions\DisplayException; |
39 | -use Pterodactyl\Exceptions\AccountNotFoundException; |
|
40 | 36 | use Pterodactyl\Exceptions\DisplayValidationException; |
41 | 37 | |
42 | 38 | class ServerRepository |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | 'custom_id' => 'sometimes|required|numeric|unique:servers,id', |
93 | 93 | ]); |
94 | 94 | |
95 | - $validator->sometimes('node', 'bail|required|numeric|min:1|exists:nodes,id', function ($input) { |
|
95 | + $validator->sometimes('node', 'bail|required|numeric|min:1|exists:nodes,id', function($input) { |
|
96 | 96 | return !($input->auto_deploy); |
97 | 97 | }); |
98 | 98 | |
99 | - $validator->sometimes('ip', 'required|ip', function ($input) { |
|
99 | + $validator->sometimes('ip', 'required|ip', function($input) { |
|
100 | 100 | return (!$input->auto_deploy && !$input->allocation); |
101 | 101 | }); |
102 | 102 | |
103 | - $validator->sometimes('port', 'required|numeric|min:1|max:65535', function ($input) { |
|
103 | + $validator->sometimes('port', 'required|numeric|min:1|max:65535', function($input) { |
|
104 | 104 | return (!$input->auto_deploy && !$input->allocation); |
105 | 105 | }); |
106 | 106 | |
107 | - $validator->sometimes('allocation', 'numeric|exists:allocations,id', function ($input) { |
|
107 | + $validator->sometimes('allocation', 'numeric|exists:allocations,id', function($input) { |
|
108 | 108 | return !($input->auto_deploy || ($input->port && $input->ip)); |
109 | 109 | }); |
110 | 110 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if (!isset($data['allocation'])) { |
145 | 145 | $allocation = Models\Allocation::where('ip', $data['ip'])->where('port', $data['port'])->where('node', $data['node'])->whereNull('assigned_to')->first(); |
146 | 146 | } else { |
147 | - $allocation = Models\Allocation::where('id' , $data['allocation'])->where('node', $data['node'])->whereNull('assigned_to')->first(); |
|
147 | + $allocation = Models\Allocation::where('id', $data['allocation'])->where('node', $data['node'])->whereNull('assigned_to')->first(); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $variables = Models\ServiceVariables::where('option_id', $data['option'])->get(); |
170 | 170 | $variableList = []; |
171 | 171 | if ($variables) { |
172 | - foreach($variables as $variable) { |
|
172 | + foreach ($variables as $variable) { |
|
173 | 173 | |
174 | 174 | // Is the variable required? |
175 | 175 | if (!$data['env_' . $variable->env_variable]) { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if (is_numeric($node->memory_overallocate)) { |
209 | 209 | $newMemory = $totals->memory + $data['memory']; |
210 | 210 | $memoryLimit = ($node->memory * (1 + ($node->memory_overallocate / 100))); |
211 | - if($newMemory > $memoryLimit) { |
|
211 | + if ($newMemory > $memoryLimit) { |
|
212 | 212 | throw new DisplayException('The amount of memory allocated to this server would put the node over its allocation limits. This node is allowed ' . ($node->memory_overallocate + 100) . '% of its assigned ' . $node->memory . 'Mb of memory (' . $memoryLimit . 'Mb) of which ' . (($totals->memory / $node->memory) * 100) . '% (' . $totals->memory . 'Mb) is in use already. By allocating this server the node would be at ' . (($newMemory / $node->memory) * 100) . '% (' . $newMemory . 'Mb) usage.'); |
213 | 213 | } |
214 | 214 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if (is_numeric($node->disk_overallocate)) { |
218 | 218 | $newDisk = $totals->disk + $data['disk']; |
219 | 219 | $diskLimit = ($node->disk * (1 + ($node->disk_overallocate / 100))); |
220 | - if($newDisk > $diskLimit) { |
|
220 | + if ($newDisk > $diskLimit) { |
|
221 | 221 | throw new DisplayException('The amount of disk allocated to this server would put the node over its allocation limits. This node is allowed ' . ($node->disk_overallocate + 100) . '% of its assigned ' . $node->disk . 'Mb of disk (' . $diskLimit . 'Mb) of which ' . (($totals->disk / $node->disk) * 100) . '% (' . $totals->disk . 'Mb) is in use already. By allocating this server the node would be at ' . (($newDisk / $node->disk) * 100) . '% (' . $newDisk . 'Mb) usage.'); |
222 | 222 | } |
223 | 223 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $environmentVariables = array_merge($environmentVariables, [ |
272 | 272 | 'STARTUP' => $data['startup'] |
273 | 273 | ]); |
274 | - foreach($variableList as $item) { |
|
274 | + foreach ($variableList as $item) { |
|
275 | 275 | $environmentVariables = array_merge($environmentVariables, [ |
276 | 276 | $item['env'] => $item['val'] |
277 | 277 | ]); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | 'port' => (int) $allocation->port |
307 | 307 | ], |
308 | 308 | 'ports' => [ |
309 | - (string) $allocation->ip => [ (int) $allocation->port ] |
|
309 | + (string) $allocation->ip => [(int) $allocation->port] |
|
310 | 310 | ], |
311 | 311 | 'env' => $environmentVariables, |
312 | 312 | 'memory' => (int) $server->memory, |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | DB::commit(); |
419 | 419 | return true; |
420 | 420 | } else { |
421 | - throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' + $res->getStatusCode()); |
|
421 | + throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' +$res->getStatusCode()); |
|
422 | 422 | } |
423 | 423 | } catch (\Exception $ex) { |
424 | 424 | DB::rollBack(); |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | $assignments = Models\Allocation::where('assigned_to', $server->id)->get(); |
585 | 585 | foreach ($assignments as &$assignment) { |
586 | 586 | if (array_key_exists((string) $assignment->ip, $additionalAssignments)) { |
587 | - array_push($additionalAssignments[ (string) $assignment->ip ], (int) $assignment->port); |
|
587 | + array_push($additionalAssignments[(string) $assignment->ip], (int) $assignment->port); |
|
588 | 588 | } else { |
589 | - $additionalAssignments[ (string) $assignment->ip ] = [ (int) $assignment->port ]; |
|
589 | + $additionalAssignments[(string) $assignment->ip] = [(int) $assignment->port]; |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | |
679 | 679 | $variableList = []; |
680 | 680 | if ($variables) { |
681 | - foreach($variables as &$variable) { |
|
681 | + foreach ($variables as &$variable) { |
|
682 | 682 | // Move on if the new data wasn't even sent |
683 | 683 | if (!isset($data[$variable->env_variable])) { |
684 | 684 | $variableList = array_merge($variableList, [[ |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $environmentVariables = array_merge($environmentVariables, [ |
731 | 731 | 'STARTUP' => $server->startup |
732 | 732 | ]); |
733 | - foreach($variableList as $item) { |
|
733 | + foreach ($variableList as $item) { |
|
734 | 734 | $environmentVariables = array_merge($environmentVariables, [ |
735 | 735 | $item['env'] => $item['val'] |
736 | 736 | ]); |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | // This is the one un-recoverable point where |
829 | 829 | // transactions will not save us. |
830 | 830 | $repository = new DatabaseRepository; |
831 | - foreach(Models\Database::select('id')->where('server_id', $server->id)->get() as &$database) { |
|
831 | + foreach (Models\Database::select('id')->where('server_id', $server->id)->get() as &$database) { |
|
832 | 832 | $repository->drop($database->id); |
833 | 833 | } |
834 | 834 |
@@ -25,10 +25,7 @@ |
||
25 | 25 | |
26 | 26 | use DB; |
27 | 27 | use Validator; |
28 | - |
|
29 | 28 | use Pterodactyl\Models; |
30 | -use Pterodactyl\Services\UuidService; |
|
31 | - |
|
32 | 29 | use Pterodactyl\Exceptions\DisplayException; |
33 | 30 | use Pterodactyl\Exceptions\DisplayValidationException; |
34 | 31 |
@@ -26,10 +26,7 @@ |
||
26 | 26 | use DB; |
27 | 27 | use Validator; |
28 | 28 | use Uuid; |
29 | - |
|
30 | 29 | use Pterodactyl\Models; |
31 | -use Pterodactyl\Services\UuidService; |
|
32 | - |
|
33 | 30 | use Pterodactyl\Exceptions\DisplayException; |
34 | 31 | use Pterodactyl\Exceptions\DisplayValidationException; |
35 | 32 |
@@ -25,10 +25,7 @@ |
||
25 | 25 | |
26 | 26 | use DB; |
27 | 27 | use Validator; |
28 | - |
|
29 | 28 | use Pterodactyl\Models; |
30 | -use Pterodactyl\Services\UuidService; |
|
31 | - |
|
32 | 29 | use Pterodactyl\Exceptions\DisplayException; |
33 | 30 | use Pterodactyl\Exceptions\DisplayValidationException; |
34 | 31 |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Creates a new subuser on the server. |
114 | - * @param integer $id The ID of the server to add this subuser to. |
|
114 | + * @param integer $sid The ID of the server to add this subuser to. |
|
115 | 115 | * @param array $data |
116 | 116 | * @throws DisplayValidationException |
117 | 117 | * @throws DisplayException |
@@ -215,7 +215,6 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * Revokes a users permissions on a server. |
217 | 217 | * @param integer $id The ID of the subuser row in MySQL. |
218 | - * @param array $data |
|
219 | 218 | * @throws DisplayValidationException |
220 | 219 | * @throws DisplayException |
221 | 220 | * @return void |
@@ -27,11 +27,9 @@ |
||
27 | 27 | use Settings; |
28 | 28 | use Validator; |
29 | 29 | use Mail; |
30 | - |
|
31 | 30 | use Pterodactyl\Models; |
32 | 31 | use Pterodactyl\Repositories\UserRepository; |
33 | 32 | use Pterodactyl\Services\UuidService; |
34 | - |
|
35 | 33 | use Pterodactyl\Exceptions\DisplayValidationException; |
36 | 34 | use Pterodactyl\Exceptions\DisplayException; |
37 | 35 |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $subuser->save(); |
157 | 157 | |
158 | 158 | $daemonPermissions = $this->coreDaemonPermissions; |
159 | - foreach($data['permissions'] as $permission) { |
|
159 | + foreach ($data['permissions'] as $permission) { |
|
160 | 160 | if (array_key_exists($permission, $this->permissions)) { |
161 | 161 | // Build the daemon permissions array for sending. |
162 | 162 | if (!is_null($this->permissions[$permission])) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | Mail::queue('emails.added-subuser', [ |
196 | 196 | 'serverName' => $server->name, |
197 | 197 | 'url' => route('server.index', $server->uuidShort), |
198 | - ], function ($message) use ($email) { |
|
198 | + ], function($message) use ($email) { |
|
199 | 199 | $message->to($email); |
200 | 200 | $message->from(Settings::get('email_from', env('MAIL_FROM')), Settings::get('email_sender_name', env('MAIL_FROM_NAME', 'Pterodactyl Panel'))); |
201 | 201 | $message->subject(Settings::get('company') . ' - Added to Server'); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | Models\Permission::where('user_id', $subuser->user_id)->where('server_id', $subuser->server_id)->delete(); |
288 | 288 | |
289 | 289 | $daemonPermissions = $this->coreDaemonPermissions; |
290 | - foreach($data['permissions'] as $permission) { |
|
290 | + foreach ($data['permissions'] as $permission) { |
|
291 | 291 | if (array_key_exists($permission, $this->permissions)) { |
292 | 292 | // Build the daemon permissions array for sending. |
293 | 293 | if (!is_null($this->permissions[$permission])) { |
@@ -97,7 +97,7 @@ |
||
97 | 97 | * |
98 | 98 | * @throws DisplayException |
99 | 99 | * @throws DisplayValidationException |
100 | - * @return void |
|
100 | + * @return boolean |
|
101 | 101 | */ |
102 | 102 | public function create($id, $data) |
103 | 103 | { |
@@ -25,9 +25,7 @@ |
||
25 | 25 | |
26 | 26 | use Cron; |
27 | 27 | use Validator; |
28 | - |
|
29 | 28 | use Pterodactyl\Models; |
30 | - |
|
31 | 29 | use Pterodactyl\Exceptions\DisplayValidationException; |
32 | 30 | use Pterodactyl\Exceptions\DisplayException; |
33 | 31 |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param integer $id |
119 | 119 | * @param array $data An array of columns and their associated values to update for the user. |
120 | - * @return boolean |
|
120 | + * @return boolean|null |
|
121 | 121 | */ |
122 | 122 | public function update($id, array $data) |
123 | 123 | { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * Deletes a user on the panel, returns the number of records deleted. |
155 | 155 | * |
156 | 156 | * @param integer $id |
157 | - * @return integer |
|
157 | + * @return boolean |
|
158 | 158 | */ |
159 | 159 | public function delete($id) |
160 | 160 | { |
@@ -25,17 +25,13 @@ |
||
25 | 25 | namespace Pterodactyl\Repositories; |
26 | 26 | |
27 | 27 | use DB; |
28 | -use Settings; |
|
29 | 28 | use Hash; |
30 | 29 | use Validator; |
31 | -use Mail; |
|
32 | 30 | use Carbon; |
33 | 31 | use Auth; |
34 | - |
|
35 | 32 | use Pterodactyl\Models; |
36 | 33 | use Pterodactyl\Services\UuidService; |
37 | 34 | use Pterodactyl\Notifications\AccountCreated; |
38 | - |
|
39 | 35 | use Pterodactyl\Exceptions\DisplayValidationException; |
40 | 36 | use Pterodactyl\Exceptions\DisplayException; |
41 | 37 |
@@ -164,7 +164,7 @@ |
||
164 | 164 | |
165 | 165 | // @TODO: this should probably be checked outside of this method because we won't always have Auth::user() |
166 | 166 | if(!is_null(Auth::user()) && Auth::user()->id === $id) { |
167 | - throw new DisplayException('Cannot delete your own account.'); |
|
167 | + throw new DisplayException('Cannot delete your own account.'); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | DB::beginTransaction(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | throw new DisplayValidationException($validator->errors()); |
139 | 139 | } |
140 | 140 | |
141 | - if(array_key_exists('password', $data)) { |
|
141 | + if (array_key_exists('password', $data)) { |
|
142 | 142 | $data['password'] = Hash::make($data['password']); |
143 | 143 | } |
144 | 144 | |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function delete($id) |
160 | 160 | { |
161 | - if(Models\Server::where('owner', $id)->count() > 0) { |
|
161 | + if (Models\Server::where('owner', $id)->count() > 0) { |
|
162 | 162 | throw new DisplayException('Cannot delete a user with active servers attached to thier account.'); |
163 | 163 | } |
164 | 164 | |
165 | 165 | // @TODO: this should probably be checked outside of this method because we won't always have Auth::user() |
166 | - if(!is_null(Auth::user()) && Auth::user()->id === $id) { |
|
166 | + if (!is_null(Auth::user()) && Auth::user()->id === $id) { |
|
167 | 167 | throw new DisplayException('Cannot delete your own account.'); |
168 | 168 | } |
169 | 169 |
@@ -36,6 +36,9 @@ |
||
36 | 36 | // |
37 | 37 | } |
38 | 38 | |
39 | + /** |
|
40 | + * @param string $error |
|
41 | + */ |
|
39 | 42 | public static function log(Request $request, $error = null, $authorized = false) |
40 | 43 | { |
41 | 44 | if ($request->bearerToken() && !empty($request->bearerToken())) { |
@@ -24,7 +24,6 @@ |
||
24 | 24 | namespace Pterodactyl\Services; |
25 | 25 | |
26 | 26 | use Log; |
27 | - |
|
28 | 27 | use Illuminate\Http\Request; |
29 | 28 | use Pterodactyl\Models\APILog; |
30 | 29 |
@@ -120,7 +120,7 @@ |
||
120 | 120 | * @param \Pterodactyl\Models\Node $node |
121 | 121 | * @param int $memory |
122 | 122 | * @param int $disk |
123 | - * @return bool Returns true if this information would not put the node over it's limit. |
|
123 | + * @return boolean|null Returns true if this information would not put the node over it's limit. |
|
124 | 124 | */ |
125 | 125 | protected static function checkNodeAllocation(Models\Node $node, $memory, $disk) |
126 | 126 | { |
@@ -24,7 +24,6 @@ |
||
24 | 24 | namespace Pterodactyl\Services; |
25 | 25 | |
26 | 26 | use DB; |
27 | - |
|
28 | 27 | use Pterodactyl\Models; |
29 | 28 | use Pterodactyl\Exceptions\DisplayException; |
30 | 29 |