Skip to content

Commit efda0dd

Browse files
DaneEverittStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent fc38b09 commit efda0dd

File tree

9 files changed

+97
-87
lines changed

9 files changed

+97
-87
lines changed

app/Console/Commands/CleanServiceBackup.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
4+
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
2323
*/
24+
2425
namespace Pterodactyl\Console\Commands;
2526

2627
use Carbon;
@@ -62,7 +63,7 @@ public function handle()
6263
{
6364
$files = Storage::files('services/.bak');
6465

65-
foreach($files as $file) {
66+
foreach ($files as $file) {
6667
$lastModified = Carbon::createFromTimestamp(Storage::lastModified($file));
6768
if ($lastModified->diffInMinutes(Carbon::now()) > 5) {
6869
$this->info('Deleting ' . $file);

app/Http/Controllers/Admin/PackController.php

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
4+
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -21,20 +21,19 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
2323
*/
24+
2425
namespace Pterodactyl\Http\Controllers\Admin;
2526

26-
use Alert;
2727
use DB;
2828
use Log;
29+
use Alert;
2930
use Storage;
30-
3131
use Pterodactyl\Models;
32-
use Pterodactyl\Repositories\ServiceRepository\Pack;
32+
use Illuminate\Http\Request;
33+
use Pterodactyl\Exceptions\DisplayException;
3334
use Pterodactyl\Http\Controllers\Controller;
35+
use Pterodactyl\Repositories\ServiceRepository\Pack;
3436
use Pterodactyl\Exceptions\DisplayValidationException;
35-
use Pterodactyl\Exceptions\DisplayException;
36-
37-
use Illuminate\Http\Request;
3837

3938
class PackController extends Controller
4039
{
@@ -52,14 +51,14 @@ protected function formatServices()
5251
)->join('services', 'services.id', '=', 'service_options.parent_service')->get();
5352

5453
$array = [];
55-
foreach($options as &$option) {
56-
if (!array_key_exists($option->p_service, $array)) {
54+
foreach ($options as &$option) {
55+
if (! array_key_exists($option->p_service, $array)) {
5756
$array[$option->p_service] = [];
5857
}
5958

6059
$array[$option->p_service] = array_merge($array[$option->p_service], [[
6160
'id' => $option->id,
62-
'name' => $option->name
61+
'name' => $option->name,
6362
]]);
6463
}
6564

@@ -69,17 +68,18 @@ protected function formatServices()
6968
public function listAll(Request $request)
7069
{
7170
return view('admin.services.packs.index', [
72-
'services' => Models\Service::all()
71+
'services' => Models\Service::all(),
7372
]);
7473
}
7574

7675
public function listByOption(Request $request, $id)
7776
{
7877
$option = Models\ServiceOptions::findOrFail($id);
78+
7979
return view('admin.services.packs.byoption', [
8080
'packs' => Models\ServicePack::where('option', $option->id)->get(),
8181
'service' => Models\Service::findOrFail($option->parent_service),
82-
'option' => $option
82+
'option' => $option,
8383
]);
8484
}
8585

@@ -91,7 +91,7 @@ public function listByService(Request $request, $id)
9191
'service_options.id',
9292
'service_options.name',
9393
DB::raw('(SELECT COUNT(id) FROM service_packs WHERE service_packs.option = service_options.id) AS p_count')
94-
)->where('parent_service', $id)->get()
94+
)->where('parent_service', $id)->get(),
9595
]);
9696
}
9797

@@ -108,9 +108,10 @@ public function create(Request $request)
108108
try {
109109
$repo = new Pack;
110110
$id = $repo->create($request->except([
111-
'_token'
111+
'_token',
112112
]));
113113
Alert::success('Successfully created new service!')->flash();
114+
114115
return redirect()->route('admin.services.packs.edit', $id)->withInput();
115116
} catch (DisplayValidationException $ex) {
116117
return redirect()->route('admin.services.packs.new', $request->input('option'))->withErrors(json_decode($ex->getMessage()))->withInput();
@@ -120,42 +121,46 @@ public function create(Request $request)
120121
Log::error($ex);
121122
Alert::danger('An error occured while attempting to add a new service pack.')->flash();
122123
}
124+
123125
return redirect()->route('admin.services.packs.new', $request->input('option'))->withInput();
124126
}
125127

126128
public function edit(Request $request, $id)
127129
{
128130
$pack = Models\ServicePack::findOrFail($id);
129131
$option = Models\ServiceOptions::select('id', 'parent_service', 'name')->where('id', $pack->option)->first();
132+
130133
return view('admin.services.packs.edit', [
131134
'pack' => $pack,
132135
'services' => $this->formatServices(),
133136
'files' => Storage::files('packs/' . $pack->uuid),
134137
'service' => Models\Service::findOrFail($option->parent_service),
135-
'option' => $option
138+
'option' => $option,
136139
]);
137140
}
138141

139142
public function update(Request $request, $id)
140143
{
141-
if (!is_null($request->input('action_delete'))) {
144+
if (! is_null($request->input('action_delete'))) {
142145
try {
143146
$repo = new Pack;
144147
$repo->delete($id);
145148
Alert::success('The requested service pack has been deleted from the system.')->flash();
149+
146150
return redirect()->route('admin.services.packs');
147151
} catch (DisplayException $ex) {
148152
Alert::danger($ex->getMessage())->flash();
149153
} catch (\Exception $ex) {
150154
Log::error($ex);
151155
Alert::danger('An error occured while attempting to delete this pack.')->flash();
152156
}
157+
153158
return redirect()->route('admin.services.packs.edit', $id);
154159
} else {
155160
try {
156161
$repo = new Pack;
157162
$repo->update($id, $request->except([
158-
'_token'
163+
'_token',
159164
]));
160165
Alert::success('Service pack has been successfully updated.')->flash();
161166
} catch (DisplayValidationException $ex) {
@@ -164,6 +169,7 @@ public function update(Request $request, $id)
164169
Log::error($ex);
165170
Alert::danger('An error occured while attempting to add edit this pack.')->flash();
166171
}
172+
167173
return redirect()->route('admin.services.packs.edit', $id);
168174
}
169175
}
@@ -183,14 +189,14 @@ public function export(Request $request, $id, $files = false)
183189
'cpu' => $pack->build_cpu,
184190
'io' => $pack->build_io,
185191
'container' => $pack->build_container,
186-
'script' => $pack->build_script
187-
]
192+
'script' => $pack->build_script,
193+
],
188194
];
189195

190196
$filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
191197
if ((bool) $files) {
192198
$zip = new \ZipArchive;
193-
if (!$zip->open($filename, \ZipArchive::CREATE)) {
199+
if (! $zip->open($filename, \ZipArchive::CREATE)) {
194200
abort(503, 'Unable to open file for writing.');
195201
}
196202

@@ -207,16 +213,18 @@ public function export(Request $request, $id, $files = false)
207213
$fp = fopen($filename, 'a+');
208214
fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
209215
fclose($fp);
216+
210217
return response()->download($filename, 'pack-' . $pack->name . '.json', [
211-
'Content-Type' => 'application/json'
218+
'Content-Type' => 'application/json',
212219
])->deleteFileAfterSend(true);
213220
}
214221
}
215222

216-
public function uploadForm(Request $request, $for = null) {
223+
public function uploadForm(Request $request, $for = null)
224+
{
217225
return view('admin.services.packs.upload', [
218226
'services' => $this->formatServices(),
219-
'for' => $for
227+
'for' => $for,
220228
]);
221229
}
222230

@@ -225,9 +233,10 @@ public function postUpload(Request $request)
225233
try {
226234
$repo = new Pack;
227235
$id = $repo->createWithTemplate($request->except([
228-
'_token'
236+
'_token',
229237
]));
230238
Alert::success('Successfully created new service!')->flash();
239+
231240
return redirect()->route('admin.services.packs.edit', $id)->withInput();
232241
} catch (DisplayValidationException $ex) {
233242
return redirect()->back()->withErrors(json_decode($ex->getMessage()))->withInput();
@@ -237,6 +246,7 @@ public function postUpload(Request $request)
237246
Log::error($ex);
238247
Alert::danger('An error occured while attempting to add a new service pack.')->flash();
239248
}
249+
240250
return redirect()->back();
241251
}
242252
}

app/Http/Controllers/Admin/ServiceController.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Log;
2929
use Alert;
3030
use Storage;
31-
use Validator;
3231
use Pterodactyl\Models;
3332
use Illuminate\Http\Request;
3433
use Pterodactyl\Exceptions\DisplayException;
@@ -292,12 +291,13 @@ public function deleteVariable(Request $request, $service, $option, $variable)
292291
public function getConfiguration(Request $request, $serviceId)
293292
{
294293
$service = Models\Service::findOrFail($serviceId);
294+
295295
return view('admin.services.config', [
296296
'service' => $service,
297297
'contents' => [
298298
'json' => Storage::get('services/' . $service->file . '/main.json'),
299-
'index' => Storage::get('services/' . $service->file . '/index.js')
300-
]
299+
'index' => Storage::get('services/' . $service->file . '/index.js'),
300+
],
301301
]);
302302
}
303303

@@ -306,17 +306,19 @@ public function postConfiguration(Request $request, $serviceId)
306306
try {
307307
$repo = new ServiceRepository\Service;
308308
$repo->updateFile($serviceId, $request->except([
309-
'_token'
309+
'_token',
310310
]));
311+
311312
return response('', 204);
312313
} catch (DisplayException $ex) {
313314
return response()->json([
314-
'error' => $ex->getMessage()
315+
'error' => $ex->getMessage(),
315316
], 503);
316317
} catch (\Exception $ex) {
317318
Log::error($ex);
319+
318320
return response()->json([
319-
'error' => 'An error occured while attempting to save the file.'
321+
'error' => 'An error occured while attempting to save the file.',
320322
], 503);
321323
}
322324
}

app/Http/Routes/AdminRoutes.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function map(Router $router)
148148
]);
149149

150150
$router->post('/new/option-details', [
151-
'uses' => 'Admin\ServersController@postNewServerOptionDetails'
151+
'uses' => 'Admin\ServersController@postNewServerOptionDetails',
152152
]);
153153
// End Assorted Page Helpers
154154

@@ -380,11 +380,11 @@ public function map(Router $router)
380380

381381
$router->get('/service/{id}/configuration', [
382382
'as' => 'admin.services.service.config',
383-
'uses' => 'Admin\ServiceController@getConfiguration'
383+
'uses' => 'Admin\ServiceController@getConfiguration',
384384
]);
385385

386386
$router->post('/service/{id}/configuration', [
387-
'uses' => 'Admin\ServiceController@postConfiguration'
387+
'uses' => 'Admin\ServiceController@postConfiguration',
388388
]);
389389

390390
$router->get('/service/{service}/option/new', [
@@ -435,45 +435,45 @@ public function map(Router $router)
435435
'middleware' => [
436436
'auth',
437437
'admin',
438-
'csrf'
439-
]
438+
'csrf',
439+
],
440440
], function () use ($router) {
441441
$router->get('/new/{option?}', [
442442
'as' => 'admin.services.packs.new',
443-
'uses' => 'Admin\PackController@new'
443+
'uses' => 'Admin\PackController@new',
444444
]);
445445
$router->post('/new', [
446-
'uses' => 'Admin\PackController@create'
446+
'uses' => 'Admin\PackController@create',
447447
]);
448448
$router->get('/upload/{option?}', [
449449
'as' => 'admin.services.packs.uploadForm',
450-
'uses' => 'Admin\PackController@uploadForm'
450+
'uses' => 'Admin\PackController@uploadForm',
451451
]);
452452
$router->post('/upload', [
453-
'uses' => 'Admin\PackController@postUpload'
453+
'uses' => 'Admin\PackController@postUpload',
454454
]);
455455
$router->get('/', [
456456
'as' => 'admin.services.packs',
457-
'uses' => 'Admin\PackController@listAll'
457+
'uses' => 'Admin\PackController@listAll',
458458
]);
459459
$router->get('/for/option/{option}', [
460460
'as' => 'admin.services.packs.option',
461-
'uses' => 'Admin\PackController@listByOption'
461+
'uses' => 'Admin\PackController@listByOption',
462462
]);
463463
$router->get('/for/service/{service}', [
464464
'as' => 'admin.services.packs.service',
465-
'uses' => 'Admin\PackController@listByService'
465+
'uses' => 'Admin\PackController@listByService',
466466
]);
467467
$router->get('/edit/{pack}', [
468468
'as' => 'admin.services.packs.edit',
469-
'uses' => 'Admin\PackController@edit'
469+
'uses' => 'Admin\PackController@edit',
470470
]);
471471
$router->post('/edit/{pack}', [
472-
'uses' => 'Admin\PackController@update'
472+
'uses' => 'Admin\PackController@update',
473473
]);
474474
$router->get('/edit/{pack}/export/{archive?}', [
475475
'as' => 'admin.services.packs.export',
476-
'uses' => 'Admin\PackController@export'
476+
'uses' => 'Admin\PackController@export',
477477
]);
478478
});
479479
}

app/Models/Checksum.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
4+
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,13 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
2323
*/
24+
2425
namespace Pterodactyl\Models;
2526

2627
use Illuminate\Database\Eloquent\Model;
2728

2829
class Checksum extends Model
2930
{
30-
3131
/**
3232
* The table associated with the model.
3333
*
@@ -48,7 +48,6 @@ class Checksum extends Model
4848
* @var array
4949
*/
5050
protected $casts = [
51-
'service' => 'integer'
51+
'service' => 'integer',
5252
];
53-
5453
}

0 commit comments

Comments
 (0)