Apply fixes from StyleCI
[ci skip] [skip ci]
This commit is contained in:
parent
303e607f7d
commit
c0c4729698
23 changed files with 2275 additions and 2310 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
@ -29,7 +28,6 @@ class LoginController extends Controller
|
|||
*/
|
||||
public function login(Request $request, Response $response): Response
|
||||
{
|
||||
|
||||
$result = $this->database->query('SELECT `id`, `email`, `username`, `password`,`is_admin`, `active` FROM `users` WHERE `username` = ? OR `email` = ? LIMIT 1', [$request->getParam('username'), $request->getParam('username')])->fetch();
|
||||
|
||||
if (!$result || !password_verify($request->getParam('password'), $result->password)) {
|
||||
|
@ -75,5 +73,4 @@ class LoginController extends Controller
|
|||
$this->session->alert(lang('goodbye'), 'warning');
|
||||
return redirect($response, 'login.show');
|
||||
}
|
||||
|
||||
}
|
|
@ -37,5 +37,4 @@ class ThemeController extends Controller
|
|||
file_put_contents(BASE_DIR . 'static/bootstrap/css/bootstrap.min.css', file_get_contents($request->getParam('css')));
|
||||
return redirect($response, 'system');
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use ZipArchive;
|
||||
|
@ -147,5 +146,4 @@ class UpgradeController extends Controller
|
|||
|
||||
return json_decode($data);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@ class UploadController extends Controller
|
|||
*/
|
||||
public function upload(Request $request, Response $response): Response
|
||||
{
|
||||
|
||||
$json = [
|
||||
'message' => null,
|
||||
'version' => PLATFORM_VERSION,
|
||||
|
@ -127,7 +126,6 @@ class UploadController extends Controller
|
|||
}
|
||||
}
|
||||
$media->size = humanFileSize($size);
|
||||
|
||||
} catch (FileNotFoundException $e) {
|
||||
throw new NotFoundException($request, $response);
|
||||
}
|
||||
|
@ -170,7 +168,6 @@ class UploadController extends Controller
|
|||
}
|
||||
|
||||
if ($this->session->get('admin', false) || $user->id === $media->user_id) {
|
||||
|
||||
try {
|
||||
$this->storage->delete($media->storage_path);
|
||||
} catch (FileNotFoundException $e) {
|
||||
|
@ -196,7 +193,6 @@ class UploadController extends Controller
|
|||
*/
|
||||
public function getRawById(Request $request, Response $response, $args): Response
|
||||
{
|
||||
|
||||
$media = $this->database->query('SELECT * FROM `uploads` WHERE `id` = ? LIMIT 1', $args['id'])->fetch();
|
||||
|
||||
if (!$media) {
|
||||
|
@ -284,7 +280,6 @@ class UploadController extends Controller
|
|||
}
|
||||
|
||||
if ($this->session->get('admin', false) || $media->user_id === $this->session->get('user_id')) {
|
||||
|
||||
try {
|
||||
$this->storage->delete($media->storage_path);
|
||||
} catch (FileNotFoundException $e) {
|
||||
|
@ -333,7 +328,6 @@ class UploadController extends Controller
|
|||
$mime = $storage->getMimetype($media->storage_path);
|
||||
|
||||
if ($request->getParam('width') !== null && explode('/', $mime)[0] === 'image') {
|
||||
|
||||
$image = Image::make($storage->readStream($media->storage_path))
|
||||
->resizeCanvas(
|
||||
$request->getParam('width'),
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use App\Exceptions\UnauthorizedException;
|
||||
use Slim\Exception\NotFoundException;
|
||||
use Slim\Http\Request;
|
||||
|
@ -189,7 +188,6 @@ class UserController extends Controller
|
|||
]);
|
||||
|
||||
return redirect($response, 'user.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Database;
|
||||
|
||||
|
||||
use PDO;
|
||||
|
||||
class DB
|
||||
|
@ -99,7 +98,6 @@ class DB
|
|||
*/
|
||||
public static function driver(): string
|
||||
{
|
||||
|
||||
return self::getInstance()->getCurrentDriver();
|
||||
}
|
||||
|
||||
|
@ -109,7 +107,6 @@ class DB
|
|||
*/
|
||||
public static function raw(): PDO
|
||||
{
|
||||
|
||||
return self::getInstance()->getPdo();
|
||||
}
|
||||
|
||||
|
@ -125,5 +122,4 @@ class DB
|
|||
self::$username = $username;
|
||||
self::$password = $password;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Database\Queries;
|
||||
|
||||
|
||||
use App\Database\DB;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
use League\Flysystem\Filesystem;
|
||||
|
@ -144,7 +143,6 @@ class MediaQuery
|
|||
}
|
||||
$media->extension = pathinfo($media->filename, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,7 +216,6 @@ class MediaQuery
|
|||
public function getMedia()
|
||||
{
|
||||
return $this->media;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
|
|
|
@ -24,5 +24,4 @@ class AdminMiddleware extends Middleware
|
|||
|
||||
return $next($request, $response);
|
||||
}
|
||||
|
||||
}
|
|
@ -30,5 +30,4 @@ class AuthMiddleware extends Middleware
|
|||
|
||||
return $next($request, $response);
|
||||
}
|
||||
|
||||
}
|
|
@ -34,5 +34,5 @@ abstract class Middleware
|
|||
* @param Response $response
|
||||
* @param callable $next
|
||||
*/
|
||||
public abstract function __invoke(Request $request, Response $response, callable $next);
|
||||
abstract public function __invoke(Request $request, Response $response, callable $next);
|
||||
}
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Web;
|
||||
|
||||
|
||||
class Lang
|
||||
{
|
||||
|
||||
const DEFAULT_LANG = 'en';
|
||||
const LANG_PATH = __DIR__ . '../../resources/lang/';
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Web;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
class Session
|
||||
|
@ -112,5 +111,4 @@ class Session
|
|||
self::set('_flash', []);
|
||||
return $flash;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,6 @@ $app->group('', function () {
|
|||
})->add(AdminMiddleware::class);
|
||||
|
||||
$this->group('/user', function () {
|
||||
|
||||
$this->get('/create', UserController::class . ':create')->setName('user.create');
|
||||
$this->post('/create', UserController::class . ':store')->setName('user.store');
|
||||
$this->get('/{id}/edit', UserController::class . ':edit')->setName('user.edit');
|
||||
|
@ -51,7 +50,6 @@ $app->group('', function () {
|
|||
$this->post('/upload/{id}/unpublish', UploadController::class . ':togglePublish')->setName('upload.unpublish');
|
||||
$this->get('/upload/{id}/raw', UploadController::class . ':getRawById')->add(AdminMiddleware::class)->setName('upload.raw');
|
||||
$this->post('/upload/{id}/delete', UploadController::class . ':delete')->setName('upload.delete');
|
||||
|
||||
})->add(App\Middleware\CheckForMaintenanceMiddleware::class)->add(AuthMiddleware::class);
|
||||
|
||||
$app->get('/', DashboardController::class . ':redirects')->setName('root');
|
||||
|
|
|
@ -86,7 +86,6 @@ $container['database'] = function ($container) use (&$config) {
|
|||
};
|
||||
|
||||
$container['storage'] = function ($container) use (&$config) {
|
||||
|
||||
switch ($config['storage']['driver']) {
|
||||
case 'local':
|
||||
return new Filesystem(new Local($config['storage']['path']));
|
||||
|
@ -172,7 +171,6 @@ $container['phpErrorHandler'] = function ($container) {
|
|||
|
||||
$container['errorHandler'] = function ($container) {
|
||||
return function (Request $request, Response $response, Exception $exception) use (&$container) {
|
||||
|
||||
if ($exception instanceof MaintenanceException) {
|
||||
return $container->view->render($response->withStatus(503), 'errors/maintenance.twig');
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@ $container['view'] = function ($container) use (&$config) {
|
|||
};
|
||||
|
||||
$container['storage'] = function ($container) use (&$config) {
|
||||
|
||||
switch ($config['storage']['driver']) {
|
||||
case 'local':
|
||||
return new Filesystem(new Local($config['storage']['path']));
|
||||
|
@ -112,7 +111,8 @@ $container['storage'] = function ($container) use (&$config) {
|
|||
}
|
||||
};
|
||||
|
||||
function migrate($config) {
|
||||
function migrate($config)
|
||||
{
|
||||
$firstMigrate = false;
|
||||
if ($config['db']['connection'] === 'sqlite' && !file_exists(__DIR__ . '/../' . $config['db']['dsn'])) {
|
||||
touch(__DIR__ . '/../' . $config['db']['dsn']);
|
||||
|
@ -141,7 +141,6 @@ function migrate($config) {
|
|||
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$continue = false;
|
||||
$exists = false;
|
||||
|
||||
|
@ -154,7 +153,9 @@ function migrate($config) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ($continue) continue;
|
||||
if ($continue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = file_get_contents($file);
|
||||
try {
|
||||
|
@ -176,7 +177,6 @@ function migrate($config) {
|
|||
$app = new App($container);
|
||||
|
||||
$app->get('/', function (Request $request, Response $response) {
|
||||
|
||||
if (!extension_loaded('gd')) {
|
||||
$this->session->alert('The required "gd" extension is not loaded.', 'danger');
|
||||
}
|
||||
|
@ -293,7 +293,6 @@ $app->post('/', function (Request $request, Response $response) use (&$config) {
|
|||
|
||||
// Build the dns string and run the migrations
|
||||
try {
|
||||
|
||||
$dsn = $config['db']['connection'] === 'sqlite' ? __DIR__ . '/../' . $config['db']['dsn'] : $config['db']['dsn'];
|
||||
DB::setDsn($config['db']['connection'] . ':' . $dsn, $config['db']['username'], $config['db']['password']);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue