82 lines
2.5 KiB
PHP
82 lines
2.5 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.DIRECTORY_SEPARATOR.'/autoload.php';
|
|
|
|
use Std\Lib\Route;
|
|
|
|
use Site\Controller\Atom;
|
|
use Site\Controller\Fediverse;
|
|
use Site\Controller\Home;
|
|
use Site\Controller\Notfound;
|
|
use Site\Controller\Page;
|
|
use Site\Controller\User;
|
|
|
|
define('ROOT', realpath(__DIR__));
|
|
|
|
include(ROOT.'/config/config.php');
|
|
if (DEBUG_MODE) {
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', 1);
|
|
}
|
|
include(ROOT.'/util.php');
|
|
|
|
$routes = [
|
|
Route::add('GET', 'blog/{page}', Home::class.'@article'),
|
|
Route::add('GET', 'about', Page::class.'@about'),
|
|
Route::add('GET', 'monero', Page::class.'@monero'),
|
|
Route::add('GET', 'secret', Page::class.'@secret'),
|
|
];
|
|
|
|
if (ACTIVITYPUB_ENABLED) {
|
|
$routes[] = Route::add('GET', '.well-known/webfinger', Home::class.'@apfinger');
|
|
$routes[] = Route::add('GET', 'ap/following', Fediverse::class.'@apfollowing');
|
|
$routes[] = Route::add('GET', 'ap/followers', Fediverse::class.'@apfollowers');
|
|
$routes[] = Route::add('GET', 'ap/outbox', Fediverse::class.'@apoutbox');
|
|
$routes[] = Route::add('GET', 'ap/activities/create/{uuid}',
|
|
Fediverse::class.'@apactivity');
|
|
$routes[] = Route::add('POST', 'ap/inbox', Fediverse::class.'@apinbox');
|
|
$routes[] = Route::add('GET', 'ap/actor', Fediverse::class.'@apactor');
|
|
}
|
|
|
|
if (AUTH_ENABLED) {
|
|
$routes[] = Route::add('POST', 'login', User::class.'@login');
|
|
$routes[] = Route::add('GET', 'login', User::class.'@login');
|
|
if (AUTH_REGISTER_ENABLED) {
|
|
$routes[] = Route::add('POST', 'register', User::class.'@register');
|
|
$routes[] = Route::add('GET', 'register', User::class.'@register');
|
|
}
|
|
$routes[] = Route::add('GET', 'logout', User::class.'@logout');
|
|
$routes[] = Route::add('GET', 'profile/{name}', User::class.'@profile');
|
|
|
|
$routes[] = Route::add('GET', 'memberonly', Page::class.'@memberonly');
|
|
$routes[] = Route::add('GET', 'staffonly', Page::class.'@staffonly');
|
|
}
|
|
|
|
if (ATOM_ENABLED) {
|
|
$routes[] = Route::add('GET', 'blog.atom', Atom::class.'@feed');
|
|
}
|
|
|
|
$routes[] = Route::add('GET', '', Home::class.'@show');
|
|
|
|
Route::init($routes);
|
|
Route::setFallback([new Notfound(), 'show']);
|
|
|
|
$uri = urldecode($_SERVER['REQUEST_URI']);
|
|
|
|
// .xhtmlで終わるURLのリダイレクト処理
|
|
if (preg_match('/(.+)\.xhtml$/', $uri, $matches)) {
|
|
// 末尾の.xhtmlを取り除く
|
|
$newUri = $matches[1];
|
|
header('HTTP/1.1 301 Moved Permanently');
|
|
header('Location: ' . $newUri);
|
|
exit();
|
|
}
|
|
|
|
$uri = urldecode($_SERVER['REQUEST_URI']);
|
|
if ($uri == '/index.php' || $uri == '/index.html') {
|
|
header('Location: /');
|
|
exit();
|
|
}
|
|
|
|
Route::dispatch($uri);
|