Skip to content

Commit cd43627

Browse files
authored
Cleaning up (#477)
* add log entry Installation complete
1 parent 470bea4 commit cd43627

File tree

49 files changed

+479
-1118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+479
-1118
lines changed

app/ControllerFunctions/Install/PermissionsChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private function getPermission(string $folder, string $permissions)
5050
foreach (explode('|', $permissions) as $permission) {
5151
preg_match('/(!*)(.*)/', $permission, $f);
5252
$return <<= 1;
53-
$return |= !(($f[2](base_path($folder)) xor ($f[1] == '!')));
53+
$return |= !($f[2](base_path($folder)) xor ($f[1] == '!'));
5454
}
5555

5656
return $return;

app/ControllerFunctions/Install/RequirementsChecker.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function check(array $requirements)
6262
// @codeCoverageIgnoreEnd
6363
}
6464
break;
65+
66+
// @codeCoverageIgnoreStart
67+
default:
68+
break;
69+
// @codeCoverageIgnoreEnd
6570
}
6671
}
6772

@@ -90,14 +95,13 @@ public function checkPHPversion(string $minPhpVersion = null)
9095
) {
9196
$supported = true;
9297
}
93-
$phpStatus = [
98+
99+
return [
94100
'full' => $currentPhpVersion['full'],
95101
'current' => $currentPhpVersion['version'],
96102
'minimum' => $minVersionPhp,
97103
'supported' => $supported,
98104
];
99-
100-
return $phpStatus;
101105
}
102106

103107
/**

app/Exceptions/Handlers/InvalidPayload.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class InvalidPayload
1919
public function check($request, Throwable $exception)
2020
{
2121
return $exception instanceof DecryptException;
22-
// && $exception->getMessage() === 'The payload is invalid.';
23-
// && $exception->getMessage() === 'The MAC is invalid.';
2422
}
2523

2624
/**

app/Http/Controllers/DiagnosticsController.php

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -111,55 +111,25 @@ public function get_errors()
111111
}
112112

113113
// Extensions
114-
if (!extension_loaded('session')) {
115-
$errors[] = 'Error: PHP session extension not activated';
116-
}
117-
if (!extension_loaded('exif')) {
118-
$errors[] = 'Error: PHP exif extension not activated';
119-
}
120-
if (!extension_loaded('mbstring')) {
121-
$errors[] = 'Error: PHP mbstring extension not activated';
122-
}
123-
if (!extension_loaded('gd')) {
124-
$errors[] = 'Error: PHP gd extension not activated';
125-
}
126-
if (!extension_loaded('PDO')) {
127-
$errors[] = 'Error: PHP PDO extension not activated';
114+
$extensions = ['session', 'exif', 'mbstring', 'gd', 'PDO', 'json', 'zip'];
115+
116+
foreach ($extensions as $extension) {
117+
if (!extension_loaded($extension)) {
118+
$errors[] = 'Error: PHP ' . $extension . ' extension not activated';
119+
}
128120
}
129121
if (!extension_loaded('mysqli') && !DB::getDriverName() == 'pgsql') {
130122
$errors[] = 'Error: PHP mysqli extension not activated';
131123
}
132-
if (!extension_loaded('json')) {
133-
$errors[] = 'Error: PHP json extension not activated';
134-
}
135-
if (!extension_loaded('zip')) {
136-
$errors[] = 'Error: PHP zip extension not activated';
137-
}
138124

139125
// Permissions
140-
if (Helpers::hasPermissions(Storage::path('big')) === false) {
141-
$errors[]
142-
= 'Error: \'uploads/big\' is missing or has insufficient read/write privileges';
143-
}
144-
if (Helpers::hasPermissions(Storage::path('medium')) === false) {
145-
$errors[]
146-
= 'Error: \'uploads/medium\' is missing or has insufficient read/write privileges';
147-
}
148-
if (Helpers::hasPermissions(Storage::path('small')) === false) {
149-
$errors[]
150-
= 'Error: \'uploads/small\' is missing or has insufficient read/write privileges';
151-
}
152-
if (Helpers::hasPermissions(Storage::path('thumb')) === false) {
153-
$errors[]
154-
= 'Error: \'uploads/thumb\' is missing or has insufficient read/write privileges';
155-
}
156-
if (Helpers::hasPermissions(Storage::path('import')) === false) {
157-
$errors[]
158-
= 'Error: \'uploads/import\' is missing or has insufficient read/write privileges';
159-
}
160-
if (Helpers::hasPermissions(Storage::path('')) === false) {
161-
$errors[]
162-
= 'Error: \'uploads/\' is missing or has insufficient read/write privileges';
126+
$paths = ['big', 'medium', 'small', 'thumb', 'import', ''];
127+
128+
foreach ($paths as $path) {
129+
if (Helpers::hasPermissions(Storage::path($path)) === false) {
130+
$errors[]
131+
= 'Error: \'uploads/' . $path . '\' is missing or has insufficient read/write privileges';
132+
}
163133
}
164134
if (Helpers::hasPermissions(Storage::disk('dist')->path('user.css'))
165135
=== false

app/Http/Controllers/ImportController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ public function server(Request $request)
193193
case 't':
194194
$this->memLimit *= 1024 * 1024 * 1024 * 1024;
195195
break;
196+
default:
197+
$this->memLimit *= 1;
198+
break;
196199
// @codeCoverageIgnoreEnd
197200
}
198201
}
@@ -333,13 +336,13 @@ public function server_exec(string $path, $albumID, $delete_imported, $force_ski
333336
$ignore_file = false;
334337

335338
foreach ($ignore_list as $value_ignore) {
336-
if ($this->check_file_matches_pattern(basename($file), $value_ignore) == true) {
339+
if ($this->check_file_matches_pattern(basename($file), $value_ignore)) {
337340
$ignore_file = true;
338341
break;
339342
}
340343
}
341344

342-
if ($ignore_file == true) {
345+
if ($ignore_file) {
343346
$filesTotal--;
344347
continue;
345348
}
@@ -403,9 +406,10 @@ public function server_exec(string $path, $albumID, $delete_imported, $force_ski
403406
}
404407

405408
/**
406-
* @param array $my_array
409+
* @param string $pattern
410+
* @param string $filename
407411
*
408-
* @return string
412+
* @return bool
409413
*/
410414
private function check_file_matches_pattern(string $pattern, string $filename)
411415
{

app/Http/Controllers/Install/PermissionsController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public function __construct(PermissionsChecker $checker, DefaultConfig $config)
3232
*/
3333
public function view()
3434
{
35-
$permissions = $this->permissions->check(
35+
$perms = $this->permissions->check(
3636
$this->config->get_permissions()
3737
);
38-
// return $permissions;
38+
3939
return view('install.permissions', [
4040
'title' => 'Lychee-installer',
4141
'step' => 2,
42-
'permissions' => $permissions['permissions'],
43-
'errors' => $permissions['errors'],
42+
'permissions' => $perms['permissions'],
43+
'errors' => $perms['errors'],
4444
]);
4545
}
4646
}

app/Http/Controllers/Install/RequirementsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ public function view()
3737
$phpSupportInfo = $this->requirements->checkPHPversion(
3838
$this->config->get_core()['minPhpVersion']
3939
);
40-
$requirements = $this->requirements->check(
40+
$reqs = $this->requirements->check(
4141
$this->config->get_requirements()
4242
);
4343

4444
return view('install.requirements', [
4545
'title' => 'Lychee-installer',
4646
'step' => 1,
4747
'phpSupportInfo' => $phpSupportInfo,
48-
'requirements' => $requirements['requirements'],
49-
'errors' => $requirements['errors'] ?? null,
48+
'requirements' => $reqs['requirements'],
49+
'errors' => $reqs['errors'] ?? null,
5050
]);
5151
}
5252
}

app/Http/Controllers/LogController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class LogController extends Controller
1717
*/
1818
public function list($order = 'DESC')
1919
{
20-
$logs = Logs::orderBy('id', $order)->get();
21-
22-
return $logs;
20+
return Logs::orderBy('id', $order)->get();
2321
}
2422

2523
/**

app/Http/Controllers/PhotoController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public function getArchive(Request $request)
695695
$response = new BinaryFileResponse($url);
696696
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $file);
697697
} else {
698-
$response = new StreamedResponse(function () use ($request, $photoIDs, &$extract_names) {
698+
$response = new StreamedResponse(function () use ($request, $photoIDs) {
699699
$options = new \ZipStream\Option\Archive();
700700
$options->setEnableZip64(Configs::get_value('zip64', '1') === '1');
701701
$zip = new ZipStream(null, $options);

app/Http/Controllers/SettingsController.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,6 @@ public function setImageOverlayType(Request $request)
265265
'image_overlay_type' => 'required|string',
266266
]);
267267

268-
// in theory this code is not needed anymore as the check is done within the set
269-
// $overlays = ['exif', 'desc', 'takedate'];
270-
// $found = false;
271-
// $i = 0;
272-
// while (!$found && $i < count($overlays)) {
273-
// if ($overlays[$i] === $request['image_overlay_type']) {
274-
// $found = true;
275-
// }
276-
// $i++;
277-
// }
278-
// if (!$found) {
279-
// Logs::error(__METHOD__, __LINE__,
280-
// 'Could not find the submitted overlay type');
281-
//
282-
// return Response::error('Could not find the submitted overlay type');
283-
// }
284-
285268
return (Configs::set('image_overlay_type',
286269
$request['image_overlay_type'])) ? 'true' : 'false';
287270
}

0 commit comments

Comments
 (0)