first commit

This commit is contained in:
小喵 2022-07-11 18:09:15 +08:00 committed by Ming Tsay
commit db313f5eef
Signed by: mt
GPG key ID: 2BCF198BD3341FB3
47 changed files with 2006 additions and 0 deletions

15
webroot/auth.php Normal file
View file

@ -0,0 +1,15 @@
<?php
use MingTsay\Akanyan\App;
require_once __DIR__ . '/../vendor/autoload.php';
if (($_GET['source'] ?? '') !== 'discord' || empty($_GET['code'])) {
http_response_code(403);
exit;
}
App::auth($_GET['code']);
header('location: /');
http_response_code(302);

1
webroot/bootstrap Symbolic link
View file

@ -0,0 +1 @@
../vendor/twbs/bootstrap/dist/

View file

@ -0,0 +1,10 @@
<?php
use MingTsay\Akanyan\App;
use MingTsay\Akanyan\ConfigFilesViewer;
require_once __DIR__ . '/../../vendor/autoload.php';
App::requireAllowed();
App::render('configurations/list', ['list' => ConfigFilesViewer::list()]);

View file

@ -0,0 +1,27 @@
<?php
use MingTsay\Akanyan\App;
use MingTsay\Akanyan\ConfigFilesViewer;
require_once __DIR__ . '/../../vendor/autoload.php';
App::requireAllowed();
$file = $_GET['file'] ?? '';
$content = ConfigFilesViewer::read($file);
$list = ConfigFilesViewer::list();
if ($content === null)
App::render('configurations/not-found', [
'list' => $list,
]);
App::render('configurations/view', [
'list' => $list,
'file' => $file,
'content' => $content,
'type' => [
'json' => 'json',
'properties' => '.properties',
][pathinfo($file, PATHINFO_EXTENSION)],
]);

1
webroot/font-awesome Symbolic link
View file

@ -0,0 +1 @@
../vendor/components/font-awesome/

23
webroot/index.php Normal file
View file

@ -0,0 +1,23 @@
<?php
use MingTsay\Akanyan\App;
use MingTsay\Akanyan\Minecraft;
require_once __DIR__ . '/../vendor/autoload.php';
App::requireAllowed();
$status = exec('sudo -u mt docker inspect -f \'{{.State.Status}}\' akanyan-server-1');
// start the server
$isStarting = isset($_POST['start']);
if ($isStarting) exec('sudo -u mt docker start akanyan-server-1');
// get query
$query = $status === 'running' ? Minecraft::query() : null;
App::render('index', [
'status' => $status,
'isStarting' => $isStarting,
'query' => $query,
]);

8
webroot/login.php Normal file
View file

@ -0,0 +1,8 @@
<?php
use MingTsay\Akanyan\App;
require_once __DIR__ . '/../vendor/autoload.php';
App::requireNonAuth();
App::render('login', ['authUrl' => App::authUrl()]);

14
webroot/logout.php Normal file
View file

@ -0,0 +1,14 @@
<?php
use MingTsay\Akanyan\App;
require_once __DIR__ . '/../vendor/autoload.php';
App::requireAuth();
if (isset($_POST['logout'])) {
App::unsetU();
App::render('logout/success');
}
App::render('logout/form');

10
webroot/logs/list.php Normal file
View file

@ -0,0 +1,10 @@
<?php
use MingTsay\Akanyan\App;
use MingTsay\Akanyan\LogsViewer;
require_once __DIR__ . '/../../vendor/autoload.php';
App::requireAllowed();
App::render('logs/list', ['list' => LogsViewer::list()]);

23
webroot/logs/view.php Normal file
View file

@ -0,0 +1,23 @@
<?php
use MingTsay\Akanyan\App;
use MingTsay\Akanyan\LogsViewer;
require_once __DIR__ . '/../../vendor/autoload.php';
App::requireAllowed();
$file = $_GET['file'] ?? '';
$content = LogsViewer::read($file);
$list = LogsViewer::list();
if ($content === null)
App::render('configurations/not-found', [
'list' => $list,
]);
App::render('logs/view', [
'list' => $list,
'file' => $file,
'content' => $content,
]);

36
webroot/style.css Normal file
View file

@ -0,0 +1,36 @@
html,
body {
height: 100%;
width: 100%;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 8px;
padding-bottom: 8px;
background-color: #f5f5f5;
}
main {
flex-grow: 1;
height: 0;
width: 100%;
overflow-y: scroll;
}
pre.file-content {
background-color: white;
text-align: left;
padding: 8px;
width: 100%;
overflow-x: scroll;
white-space: pre-wrap;
word-wrap: break-word;
}
.w-fit-content {
width: fit-content !important;
}