Линтовка
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of m3u.su project
|
||||
@@ -42,6 +43,7 @@ class ApiController extends BasicController
|
||||
if ($playlist['isOnline'] === true) {
|
||||
unset($playlist['content']);
|
||||
}
|
||||
|
||||
return $this->responseJson($response, 200, $playlist);
|
||||
} catch (PlaylistNotFoundException $e) {
|
||||
return $this->responseJsonError($response, 404, $e);
|
||||
@@ -65,7 +67,7 @@ class ApiController extends BasicController
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
$filePath = cache_path("qr-codes/$code.jpg");
|
||||
$filePath = cache_path("qr-codes/{$code}.jpg");
|
||||
if (file_exists($filePath)) {
|
||||
$raw = file_get_contents($filePath);
|
||||
} else {
|
||||
@@ -74,13 +76,14 @@ class ApiController extends BasicController
|
||||
'outputType' => QRCode::OUTPUT_IMAGE_JPG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
]);
|
||||
$data = config('app.mirror_url') ? mirror_url("$code.m3u") : base_url("$code.m3u");
|
||||
$data = config('app.mirror_url') ? mirror_url("{$code}.m3u") : base_url("{$code}.m3u");
|
||||
$raw = new QRCode($options)->render($data, $filePath);
|
||||
$raw = base64_decode(str_replace('data:image/jpg;base64,', '', $raw));
|
||||
}
|
||||
|
||||
$mime = mime_content_type($filePath);
|
||||
$response->getBody()->write($raw);
|
||||
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', $mime);
|
||||
}
|
||||
@@ -116,10 +119,11 @@ class ApiController extends BasicController
|
||||
function getSize(string $directory): int
|
||||
{
|
||||
$size = 0;
|
||||
foreach (glob($directory . '/*') as $path){
|
||||
foreach (glob($directory . '/*') as $path) {
|
||||
is_file($path) && $size += filesize($path);
|
||||
is_dir($path) && $size += getSize($path);
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user