Initial commit

This commit is contained in:
2024-06-01 22:48:57 +02:00
commit b570f3750c
12 changed files with 1219 additions and 0 deletions

BIN
public/error.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 MiB

56
public/index.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
use App\auth\Authenticator;
use App\download\DownloadHandler;
use App\login\LoginHandler;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run;
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../src/base.php';
require_once __DIR__.'/../config/config.php';
$environment = 'prod';
$whoops = new Run;
if ($environment === 'dev') {
$whoops->pushHandler(new PrettyPageHandler);
} else {
$whoops->pushHandler(function($e) {
handle_error($e);
die();
});
}
$whoops->register();
session_start();
// parse request uri
$uri = substr($_SERVER['REQUEST_URI'], strlen(BASE));
$split_uri = explode('/', explode('?', $uri)[0]);
array_splice($split_uri, 0, 1);
$authenticator = new Authenticator();
if (empty($split_uri[0])) {
\App\template\Error::printError(403);
die();
}
if (!$authenticator->isLoggedIn() && !($split_uri[0] === 'login')) {
$_SESSION['return_uri'] = ($uri !== '/favicon.ico') ? $uri : '/';
redirect('/login');
die();
}
if ($split_uri[0] === 'login') {
if ($authenticator->isLoggedIn()) {
redirect($_SESSION['return_uri']);
die();
}
$handler = new LoginHandler();
} else {
$handler = new DownloadHandler($split_uri[0]);
}
$handler->handle();