2018-04-28 12:20:07 +00:00
|
|
|
<?php
|
2019-11-20 17:49:31 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
// Auth routes
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\AdminController;
|
2020-02-26 17:26:19 +00:00
|
|
|
use App\Controllers\Auth\RegisterController;
|
2019-11-20 17:46:47 +00:00
|
|
|
use App\Controllers\ClientController;
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\DashboardController;
|
2020-02-26 11:22:25 +00:00
|
|
|
use App\Controllers\ExportController;
|
2020-02-26 17:26:19 +00:00
|
|
|
use App\Controllers\Auth\LoginController;
|
2019-11-20 17:46:47 +00:00
|
|
|
use App\Controllers\MediaController;
|
2020-02-26 11:22:25 +00:00
|
|
|
use App\Controllers\ProfileController;
|
2020-02-25 20:54:54 +00:00
|
|
|
use App\Controllers\SettingController;
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\UpgradeController;
|
|
|
|
use App\Controllers\UploadController;
|
|
|
|
use App\Controllers\UserController;
|
|
|
|
use App\Middleware\AdminMiddleware;
|
|
|
|
use App\Middleware\AuthMiddleware;
|
|
|
|
use App\Middleware\CheckForMaintenanceMiddleware;
|
2019-11-12 23:13:23 +00:00
|
|
|
use Slim\Routing\RouteCollectorProxy;
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
global $app;
|
|
|
|
$app->group('', function (RouteCollectorProxy $group) {
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/home[/page/{page}]', [DashboardController::class, 'home'])->setName('home');
|
|
|
|
$group->get('/upload', [UploadController::class, 'webUpload'])->setName('upload.web');
|
2018-04-28 12:20:07 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->group('', function (RouteCollectorProxy $group) {
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/home/switchView', [DashboardController::class, 'switchView'])->setName('switchView');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/system/deleteOrphanFiles', [AdminController::class, 'deleteOrphanFiles'])->setName('system.deleteOrphanFiles');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2020-02-25 20:54:54 +00:00
|
|
|
$group->get('/system/themes', [AdminController::class, 'getThemes'])->setName('theme');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2020-02-25 20:54:54 +00:00
|
|
|
$group->post('/system/settings/save', [SettingController::class, 'saveSettings'])->setName('settings.save');
|
2019-11-14 23:56:25 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->post('/system/upgrade', [UpgradeController::class, 'upgrade'])->setName('system.upgrade');
|
|
|
|
$group->get('/system/checkForUpdates', [UpgradeController::class, 'checkForUpdates'])->setName('system.checkForUpdates');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/system', [AdminController::class, 'system'])->setName('system');
|
2019-01-13 20:27:10 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/users[/page/{page}]', [UserController::class, 'index'])->setName('user.index');
|
2019-11-12 23:13:23 +00:00
|
|
|
})->add(AdminMiddleware::class);
|
2019-01-13 20:27:10 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->group('/user', function (RouteCollectorProxy $group) {
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->get('/create', [UserController::class, 'create'])->setName('user.create');
|
|
|
|
$group->post('/create', [UserController::class, 'store'])->setName('user.store');
|
|
|
|
$group->get('/{id}/edit', [UserController::class, 'edit'])->setName('user.edit');
|
|
|
|
$group->post('/{id}', [UserController::class, 'update'])->setName('user.update');
|
|
|
|
$group->get('/{id}/delete', [UserController::class, 'delete'])->setName('user.delete');
|
2019-11-12 23:13:23 +00:00
|
|
|
})->add(AdminMiddleware::class);
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2020-02-26 11:22:25 +00:00
|
|
|
$group->get('/profile', [ProfileController::class, 'profile'])->setName('profile');
|
|
|
|
$group->post('/profile/{id}', [ProfileController::class, 'profileEdit'])->setName('profile.update');
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->post('/user/{id}/refreshToken', [UserController::class, 'refreshToken'])->setName('refreshToken');
|
|
|
|
$group->get('/user/{id}/config/sharex', [ClientController::class, 'getShareXConfig'])->setName('config.sharex');
|
|
|
|
$group->get('/user/{id}/config/script', [ClientController::class, 'getBashScript'])->setName('config.script');
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2020-02-26 11:22:25 +00:00
|
|
|
$group->get('/user/{id}/export', [ExportController::class, 'downloadData'])->setName('export.data');
|
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$group->post('/upload/{id}/publish', [MediaController::class, 'togglePublish'])->setName('upload.publish');
|
|
|
|
$group->post('/upload/{id}/unpublish', [MediaController::class, 'togglePublish'])->setName('upload.unpublish');
|
|
|
|
$group->get('/upload/{id}/raw', [MediaController::class, 'getRawById'])->add(AdminMiddleware::class)->setName('upload.raw');
|
2019-11-21 17:08:57 +00:00
|
|
|
$group->map(['GET', 'POST'], '/upload/{id}/delete', [MediaController::class, 'delete'])->setName('upload.delete');
|
2019-09-17 20:12:06 +00:00
|
|
|
})->add(App\Middleware\CheckForMaintenanceMiddleware::class)->add(AuthMiddleware::class);
|
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$app->get('/', [DashboardController::class, 'redirects'])->setName('root');
|
2020-02-26 17:26:19 +00:00
|
|
|
$app->get('/register', [RegisterController::class, 'registerForm'])->setName('register.show');
|
|
|
|
$app->post('/register', [RegisterController::class, 'register'])->setName('register');
|
2020-02-27 14:18:01 +00:00
|
|
|
$app->get('/activate/{activateToken}', [RegisterController::class, 'activateUser'])->setName('activate');
|
2019-11-21 17:00:47 +00:00
|
|
|
$app->get('/login', [LoginController::class, 'show'])->setName('login.show');
|
|
|
|
$app->post('/login', [LoginController::class, 'login'])->setName('login');
|
|
|
|
$app->map(['GET', 'POST'], '/logout', [LoginController::class, 'logout'])->setName('logout');
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$app->post('/upload', [UploadController::class, 'upload'])->setName('upload');
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2019-11-21 17:00:47 +00:00
|
|
|
$app->get('/{userCode}/{mediaCode}', [MediaController::class, 'show'])->setName('public');
|
|
|
|
$app->get('/{userCode}/{mediaCode}/delete/{token}', [MediaController::class, 'show'])->setName('public.delete.show')->add(CheckForMaintenanceMiddleware::class);
|
|
|
|
$app->post('/{userCode}/{mediaCode}/delete/{token}', [MediaController::class, 'deleteByToken'])->setName('public.delete')->add(CheckForMaintenanceMiddleware::class);
|
|
|
|
$app->get('/{userCode}/{mediaCode}/raw[.{ext}]', [MediaController::class, 'getRaw'])->setName('public.raw');
|
|
|
|
$app->get('/{userCode}/{mediaCode}/download', [MediaController::class, 'download'])->setName('public.download');
|