@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $file->dirname = (in_array($file->dirname, ['.', './', '/'])) ? null : trim($file->dirname, '/') . '/'; |
| 100 | 100 | |
| 101 | - $res = $this->client->request('GET', '/server/file/stat/' . rawurlencode($file->dirname.$file->basename) , [ |
|
| 101 | + $res = $this->client->request('GET', '/server/file/stat/' . rawurlencode($file->dirname . $file->basename), [ |
|
| 102 | 102 | 'headers' => $this->headers |
| 103 | 103 | ]); |
| 104 | 104 | |
| 105 | 105 | $stat = json_decode($res->getBody()); |
| 106 | - if($res->getStatusCode() !== 200 || !isset($stat->size)) { |
|
| 106 | + if ($res->getStatusCode() !== 200 || !isset($stat->size)) { |
|
| 107 | 107 | throw new DisplayException('The daemon provided a non-200 error code on stat lookup: HTTP\\' . $res->getStatusCode()); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | throw new DisplayException('That file is too large to open in the browser, consider using a SFTP client.'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $res = $this->client->request('GET', '/server/file/f/' . rawurlencode($file->dirname.$file->basename) , [ |
|
| 118 | + $res = $this->client->request('GET', '/server/file/f/' . rawurlencode($file->dirname . $file->basename), [ |
|
| 119 | 119 | 'headers' => $this->headers |
| 120 | 120 | ]); |
| 121 | 121 | |
| 122 | 122 | $json = json_decode($res->getBody()); |
| 123 | - if($res->getStatusCode() !== 200 || !isset($json->content)) { |
|
| 123 | + if ($res->getStatusCode() !== 200 || !isset($json->content)) { |
|
| 124 | 124 | throw new DisplayException('The daemon provided a non-200 error code: HTTP\\' . $res->getStatusCode()); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $res = $this->client->request('POST', '/server/file/save', [ |
| 153 | 153 | 'headers' => $this->headers, |
| 154 | 154 | 'json' => [ |
| 155 | - 'path' => rawurlencode($file->dirname.$file->basename), |
|
| 155 | + 'path' => rawurlencode($file->dirname . $file->basename), |
|
| 156 | 156 | 'content' => $content |
| 157 | 157 | ] |
| 158 | 158 | ]); |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | ]); |
| 184 | 184 | |
| 185 | 185 | $json = json_decode($res->getBody()); |
| 186 | - if($res->getStatusCode() !== 200) { |
|
| 186 | + if ($res->getStatusCode() !== 200) { |
|
| 187 | 187 | throw new DisplayException('An error occured while attempting to save this file. ' . $res->getBody()); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Iterate through results |
| 191 | 191 | $files = []; |
| 192 | 192 | $folders = []; |
| 193 | - foreach($json as &$value) { |
|
| 193 | + foreach ($json as &$value) { |
|
| 194 | 194 | |
| 195 | 195 | if ($value->directory === true) { |
| 196 | 196 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | 'listen' => $node->daemonListen, |
| 166 | 166 | 'ssl' => [ |
| 167 | 167 | 'enabled' => ($node->scheme === 'https'), |
| 168 | - 'certificate' => '/etc/letsencrypt/live/' . $node->fqdn .'/fullchain.pem', |
|
| 168 | + 'certificate' => '/etc/letsencrypt/live/' . $node->fqdn . '/fullchain.pem', |
|
| 169 | 169 | 'key' => '/etc/letsencrypt/live/' . $node->fqdn . '/privkey.pem', |
| 170 | 170 | ], |
| 171 | 171 | ], |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | DB::beginTransaction(); |
| 200 | 200 | |
| 201 | 201 | try { |
| 202 | - foreach($allocations as $rawIP => $ports) { |
|
| 202 | + foreach ($allocations as $rawIP => $ports) { |
|
| 203 | 203 | try { |
| 204 | 204 | $setAlias = null; |
| 205 | 205 | $parsedIP = Network::parse($rawIP); |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | throw $ex; |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - foreach($parsedIP as $ip) { |
|
| 215 | - foreach($ports as $port) { |
|
| 214 | + foreach ($parsedIP as $ip) { |
|
| 215 | + foreach ($ports as $port) { |
|
| 216 | 216 | if (!is_int($port) && !preg_match('/^(\d{1,5})-(\d{1,5})$/', $port)) { |
| 217 | 217 | throw new DisplayException('The mapping for ' . $port . ' is invalid and cannot be processed.'); |
| 218 | 218 | } |
| 219 | 219 | if (preg_match('/^(\d{1,5})-(\d{1,5})$/', $port, $matches)) { |
| 220 | - foreach(range($matches[1], $matches[2]) as $assignPort) { |
|
| 220 | + foreach (range($matches[1], $matches[2]) as $assignPort) { |
|
| 221 | 221 | $alloc = Models\Allocation::firstOrNew([ |
| 222 | 222 | 'node' => $node->id, |
| 223 | 223 | 'ip' => $ip, |
@@ -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])) { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $validator->after(function($validator) use ($data) { |
| 129 | 129 | if (array_key_exists('allowed_ips', $data) && !empty($data['allowed_ips'])) { |
| 130 | - foreach(explode("\n", $data['allowed_ips']) as $ip) { |
|
| 130 | + foreach (explode("\n", $data['allowed_ips']) as $ip) { |
|
| 131 | 131 | $ip = trim($ip); |
| 132 | 132 | try { |
| 133 | 133 | Network::parse($ip); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | $totalPermissions = 0; |
| 163 | 163 | if (isset($data['permissions'])) { |
| 164 | - foreach($data['permissions'] as $permNode) { |
|
| 164 | + foreach ($data['permissions'] as $permNode) { |
|
| 165 | 165 | if (!strpos($permNode, ':')) continue; |
| 166 | 166 | |
| 167 | 167 | list($toss, $permission) = explode(':', $permNode); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($this->user->root_admin === 1 && isset($data['adminPermissions'])) { |
| 181 | - foreach($data['adminPermissions'] as $permNode) { |
|
| 181 | + foreach ($data['adminPermissions'] as $permNode) { |
|
| 182 | 182 | if (!strpos($permNode, ':')) continue; |
| 183 | 183 | |
| 184 | 184 | list($toss, $permission) = explode(':', $permNode); |
@@ -157,7 +157,7 @@ |
||
| 157 | 157 | )); |
| 158 | 158 | |
| 159 | 159 | DB::commit(); |
| 160 | - } catch(\Exception $ex) { |
|
| 160 | + } catch (\Exception $ex) { |
|
| 161 | 161 | DB::rollback(); |
| 162 | 162 | throw $ex; |
| 163 | 163 | } |
@@ -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 | |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | $sz = explode(',', 'B,KB,MB,GB'); |
| 63 | 63 | $factor = floor((strlen($bytes) - 1) / 3); |
| 64 | 64 | |
| 65 | - return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)).' '.$sz[$factor]; |
|
| 65 | + return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . $sz[$factor]; |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -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 | |
@@ -91,25 +91,25 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if (is_null($this->option('dbhost'))) { |
| 94 | - $variables['DB_HOST'] = $this->anticipate('Database Host', [ 'localhost', '127.0.0.1', env('DB_HOST') ], env('DB_HOST')); |
|
| 94 | + $variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', env('DB_HOST')], env('DB_HOST')); |
|
| 95 | 95 | } else { |
| 96 | 96 | $variables['DB_HOST'] = $this->option('dbhost'); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if (is_null($this->option('dbport'))) { |
| 100 | - $variables['DB_PORT'] = $this->anticipate('Database Port', [ 3306, env('DB_PORT') ], env('DB_PORT')); |
|
| 100 | + $variables['DB_PORT'] = $this->anticipate('Database Port', [3306, env('DB_PORT')], env('DB_PORT')); |
|
| 101 | 101 | } else { |
| 102 | 102 | $variables['DB_PORT'] = $this->option('dbport'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | if (is_null($this->option('dbname'))) { |
| 106 | - $variables['DB_DATABASE'] = $this->anticipate('Database Name', [ 'pterodactyl', 'homestead', ENV('DB_DATABASE') ], env('DB_DATABASE')); |
|
| 106 | + $variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', ENV('DB_DATABASE')], env('DB_DATABASE')); |
|
| 107 | 107 | } else { |
| 108 | 108 | $variables['DB_DATABASE'] = $this->option('dbname'); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (is_null($this->option('dbuser'))) { |
| 112 | - $variables['DB_USERNAME'] = $this->anticipate('Database Username', [ ENV('DB_DATABASE') ], env('DB_USERNAME')); |
|
| 112 | + $variables['DB_USERNAME'] = $this->anticipate('Database Username', [ENV('DB_DATABASE')], env('DB_USERNAME')); |
|
| 113 | 113 | } else { |
| 114 | 114 | $variables['DB_USERNAME'] = $this->option('dbuser'); |
| 115 | 115 | } |