2018-04-28 12:20:07 +00:00
|
|
|
<?php
|
2018-11-11 16:02:50 +00:00
|
|
|
// Auth routes
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\AdminController;
|
2019-11-20 17:46:47 +00:00
|
|
|
use App\Controllers\ClientController;
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\DashboardController;
|
|
|
|
use App\Controllers\LoginController;
|
2019-11-20 17:46:47 +00:00
|
|
|
use App\Controllers\MediaController;
|
2019-09-17 20:12:06 +00:00
|
|
|
use App\Controllers\ThemeController;
|
|
|
|
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) {
|
|
|
|
$group->get('/home[/page/{page}]', [DashboardController::class, 'home'])->setName('home');
|
2019-11-13 15:23:10 +00:00
|
|
|
$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) {
|
|
|
|
$group->get('/home/switchView', [DashboardController::class, 'switchView'])->setName('switchView');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->get('/system/deleteOrphanFiles', [AdminController::class, 'deleteOrphanFiles'])->setName('system.deleteOrphanFiles');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->get('/system/themes', [ThemeController::class, 'getThemes'])->setName('theme');
|
|
|
|
$group->post('/system/theme/apply', [ThemeController::class, 'applyTheme'])->setName('theme.apply');
|
2019-01-24 20:48:22 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->post('/system/lang/apply', [AdminController::class, 'applyLang'])->setName('lang.apply');
|
2019-08-20 12:56:41 +00:00
|
|
|
|
2019-11-14 23:56:25 +00:00
|
|
|
$group->post('/system/customHead', [AdminController::class, 'applyCustomHead'])->setName('customHead.apply');
|
|
|
|
|
2019-11-12 23:13:23 +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-12 23:13:23 +00:00
|
|
|
$group->get('/system', [AdminController::class, 'system'])->setName('system');
|
2019-01-13 20:27:10 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->get('/users[/page/{page}]', [UserController::class, 'index'])->setName('user.index');
|
|
|
|
})->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-01-13 20:27:10 +00:00
|
|
|
|
2019-11-12 23:13:23 +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');
|
|
|
|
})->add(AdminMiddleware::class);
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2019-11-12 23:13:23 +00:00
|
|
|
$group->get('/profile', [UserController::class, 'profile'])->setName('profile');
|
|
|
|
$group->post('/profile/{id}', [UserController::class, 'profileEdit'])->setName('profile.update');
|
|
|
|
$group->post('/user/{id}/refreshToken', [UserController::class, 'refreshToken'])->setName('refreshToken');
|
2019-11-20 17:46:47 +00:00
|
|
|
$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
|
|
|
|
2019-11-20 17:46: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');
|
|
|
|
$group->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-12 23:13:23 +00:00
|
|
|
$app->get('/', [DashboardController::class, 'redirects'])->setName('root');
|
|
|
|
$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-12 23:13:23 +00:00
|
|
|
$app->post('/upload', [UploadController::class, 'upload'])->setName('upload');
|
2019-09-17 20:12:06 +00:00
|
|
|
|
2019-11-20 17:46: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');
|