137 lines
5.7 KiB
PHP
137 lines
5.7 KiB
PHP
<?php
|
|
/*************************************************************
|
|
# 076 License
|
|
|
|
Copyright (c) テクニカル諏訪子
|
|
|
|
Permission is hereby granted to any person obtaining a copy of the software
|
|
Little Beast (the "Software") to use, modify, merge, copy, publish, distribute,
|
|
sublicense, and/or sell copies of the Software, subject to the following conditions:
|
|
|
|
1. **Origin Attribution**:
|
|
- You must not misrepresent the origin of the Software; you must not claim
|
|
you created the original Software.
|
|
- If the Software is used in a product, you must either:
|
|
a. Provide clear attribution in the product's documentation, user interface,
|
|
or other visible areas, **OR**
|
|
b. Pay the original developers a fee they specify in writing.
|
|
2. **Usage Restriction**:
|
|
- The Software, or any derivative works, dependencies, or libraries
|
|
incorporating it, must not be used for censorship or to suppress freedom of
|
|
speech, expression, or creativity. Prohibited uses include, but are not
|
|
limited to:
|
|
- Censorship of so-called "hate speech", visuals, non-mainstream opinions,
|
|
ideas, or objective reality.
|
|
- Tools or systems designed to restrict access to information or
|
|
artistic works.
|
|
3. **Notice Preservation**:
|
|
- This license and the above copyright notice must remain intact in all copies
|
|
of the source code.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
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\Op;
|
|
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', 'robots.txt', Home::class.'@robots'),
|
|
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');
|
|
}
|
|
|
|
if (OPENPROVIDER_ENABLED) {
|
|
$routes[] = Route::add('GET', 'openprovider', Op::class.'@index');
|
|
$routes[] = Route::add('GET', 'openprovider/listinvoices', Op::class.'@opListInvoices');
|
|
$routes[] = Route::add('GET', 'openprovider/listpayments', Op::class.'@opListPayments');
|
|
$routes[] = Route::add('GET', 'openprovider/listtransactions', Op::class.'@opListTransactions');
|
|
$routes[] = Route::add('GET', 'openprovider/listcustomers', Op::class.'@opListCustomers');
|
|
$routes[] = Route::add('GET', 'openprovider/createcustomer', Op::class.'@opCreateCustomer');
|
|
$routes[] = Route::add('GET', 'openprovider/deletecustomer/{handle}', Op::class.'@opDeleteCustomer');
|
|
$routes[] = Route::add('GET', 'openprovider/getcustomer/{handle}', Op::class.'@opGetCustomer');
|
|
$routes[] = Route::add('GET', 'openprovider/listtlds', Op::class.'@opListTlds');
|
|
$routes[] = Route::add('GET', 'openprovider/gettld/{tld}', Op::class.'@opGetTld');
|
|
$routes[] = Route::add('GET', 'openprovider/checkdomain', Op::class.'@opCheckDomainAvailable');
|
|
$routes[] = Route::add('GET', 'openprovider/getdomainprices', Op::class.'@opGetDomainPrices');
|
|
$routes[] = Route::add('GET', 'openprovider/listdnszones', Op::class.'@opListDns');
|
|
$routes[] = Route::add('GET', 'openprovider/getdns/{domain}', Op::class.'@opGetDns');
|
|
}
|
|
|
|
$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);
|