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

View file

@ -0,0 +1,6 @@
<?php
$this->layout('partials/file/list', [
'title' => '選擇設定檔',
'nav' => 'configurations',
'list' => $list ?? [],
]);

View file

@ -0,0 +1,6 @@
<?php
$this->layout('partials/file/not-found', [
'title' => '檢視設定檔',
'nav' => 'configurations',
'list' => $list ?? [],
]);

View file

@ -0,0 +1,9 @@
<?php
$this->layout('partials/file/view', [
'title' => '檢視設定檔',
'nav' => 'configurations',
'list' => $list ?? [],
'file' => $file ?? '',
'type' => $type ?? 'plaintext',
'content' => $content ?? '',
]);

68
templates/index.php Normal file
View file

@ -0,0 +1,68 @@
<?php $this->layout('template', ['title' => '首頁']) ?>
<div class="card m-3 mt-5 mx-auto w-fit-content">
<div class="card-body">
<div class="d-flex justify-content-center flex-column flex-lg-row">
<div class="mx-2">伺服器狀態:<code><?= $this->e($status ?? '') ?></code></div>
<?php if (isset($query)): ?>
<?php if (isset($query['version']) && isset($query['version']['name'])): ?>
<div class="mx-2">伺服器版本:<code><?= $this->e($query['version']['name']) ?></code></div>
<?php endif ?>
<?php if (isset($query['players'])): ?>
<?php if (isset($query['players']['online']) && isset($query['players']['max'])): ?>
<div class="mx-2">
線上人數:
<code><?= $this->e($query['players']['online']) ?></code>
/
<code><?= $this->e($query['players']['max']) ?></code>
</div>
<?php endif ?>
<?php if (isset($query['players']['sample']) && count($query['players']['sample']) > 0): ?>
<ul class="mx-2 list-group list-group-horizontal-lg">
<?php foreach ($query['players']['sample'] as $player) : ?>
<li class="py-0 list-group-item"><code><?= $this->e($player['name']) ?></code></li>
<?php endforeach ?>
</ul>
<?php endif ?>
<?php endif ?>
<?php endif ?>
</div>
<?php if (isset($isStarting) && $isStarting): ?>
<div class="alert alert-success my-3 mx-auto d-table" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor"
class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img"
aria-label="Success:">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</svg>
已送出伺服器啟動訊號。
</div>
<?php else: ?>
<?php if (isset($status) && $status === 'exited'): ?>
<form method="POST">
<button class="btn btn-primary btn-block" name="start" type="submit">啟動伺服器</button>
</form>
<?php endif ?>
<?php endif ?>
</div>
</div>
<div class="card m-3 mx-auto w-fit-content">
<div class="card-body">
<p class="fs-5">【更新紀錄】</p>
<ul class="list-group">
<li class="list-group-item">
<p>首頁現在可以看到伺服器版本與線上人數等資訊了。</p>
<p>更新日期2022/07/05 02:02:02</p>
</li>
<li class="list-group-item">
<p>首頁現在可以看到伺服器狀態了,也可以從首頁直接啟動伺服器。</p>
<p>更新日期2022/07/04 16:52:30</p>
</li>
<li class="list-group-item">
<p>查看檔案功能已移至新的網址,請透過上方選單進入。</p>
<p>更多其他功能將陸續推出,敬請期待。</p>
<p>更新日期2022/07/04 13:44:30</p>
</li>
</ul>
</div>
</div>

8
templates/login.php Normal file
View file

@ -0,0 +1,8 @@
<?php $this->layout('template', ['title' => '登入系統', 'noStatus' => true]) ?>
<p class="lead">您尚未登入,請點選下方按鈕進行登入。</p>
<?php if (empty($authUrl)): ?>
<a href="/login.php" class="btn btn-lg btn-warning btn-block">登入連結載入失敗,按此重新載入</a>
<?php else: ?>
<a href="<?= $this->e($authUrl) ?>" class="btn btn-lg btn-primary btn-block">透過 Discord 帳號登入</a>
<?php endif ?>

View file

@ -0,0 +1,6 @@
<?php $this->layout('template', ['title' => '登出確認', 'noStatus' => true]) ?>
<p class="lead">您確定要登出嗎?</p>
<form action="/logout.php" method="POST">
<button name="logout" type="submit" class="btn btn-lg btn-danger btn-block">確定登出</button>
</form>

View file

@ -0,0 +1,3 @@
<?php $this->layout('template', ['title' => '登出成功', 'noStatus' => true]) ?>
您已成功登出,<a href="/">按此重新登入</a>

6
templates/logs/list.php Normal file
View file

@ -0,0 +1,6 @@
<?php
$this->layout('partials/file/list', [
'title' => '選擇日誌檔案',
'nav' => 'logs',
'list' => $list ?? [],
]);

View file

@ -0,0 +1,6 @@
<?php
$this->layout('partials/file/not-found', [
'title' => '檢視日誌',
'nav' => 'logs',
'list' => $list ?? [],
]);

9
templates/logs/view.php Normal file
View file

@ -0,0 +1,9 @@
<?php
$this->layout('partials/file/view', [
'title' => '檢視日誌',
'nav' => 'logs',
'list' => $list ?? [],
'file' => $file ?? '',
'type' => $type ?? 'plaintext',
'content' => $content ?? '',
]);

View file

@ -0,0 +1,12 @@
<?php $this->layout('template', ['title' => $title ?? null, 'nav' => $nav ?? null]) ?>
<div class="list-group text-start mt-5 mx-auto w-fit-content">
<div class="list-group-item">請選擇檔案:</div>
<?php if (isset($list) && is_array($list)): ?>
<?php foreach ($list as $file): ?>
<a class="list-group-item list-group-item-action" href="view.php?file=<?= $this->e($file) ?>">
<?= $this->e($file) ?>
</a>
<?php endforeach ?>
<?php endif ?>
</div>

View file

@ -0,0 +1,35 @@
<?php $this->layout('template', ['title' => $title ?? null, 'nav' => $nav ?? null]) ?>
<div class="m-5">
<div class="dropdown">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="file-selector"
data-bs-toggle="dropdown" aria-expanded="false">
請選擇檔案
</button>
<ul class="dropdown-menu" aria-labelledby="file-selector">
<?php if (isset($list) && is_array($list)): ?>
<?php foreach ($list as $filename): ?>
<li>
<?php if (isset($file) && $file === $filename): ?>
<a class="dropdown-item active" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>*
</a>
<?php else: ?>
<a class="dropdown-item" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>
</a>
<?php endif ?>
</li>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
<div class="alert alert-warning mt-5 m-auto d-table" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor"
class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img"
aria-label="Warning:">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>
檔案不存在,請從上方選單選取欲查看之檔案。
</div>
</div>

View file

@ -0,0 +1,39 @@
<?php $this->layout('template', ['title' => $title ?? null, 'nav' => $nav ?? null]) ?>
<?php $this->push('styles') ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css"/>
<?php $this->end() ?>
<?php $this->push('scripts') ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
<!--suppress JSUnresolvedVariable -->
<script>hljs.highlightAll()</script>
<?php $this->end() ?>
<div class="dropdown my-2">
<button class="btn btn-outline-secondary dropdown-toggle"
type="button"
id="file-selector"
data-bs-toggle="dropdown"
aria-expanded="false">
<?= $this->e($file ?? '') ?>
</button>
<ul class="dropdown-menu" aria-labelledby="file-selector">
<?php if (isset($list) && is_array($list)): ?>
<?php foreach ($list as $filename): ?>
<li>
<?php if (isset($file) && $file === $filename): ?>
<a class="dropdown-item active" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>
</a>
<?php else: ?>
<a class="dropdown-item" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>
</a>
<?php endif ?>
</li>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
<pre class="file-content"><code class="language-<?= $this->e($type ?? 'plaintext') ?>"><?= $this->e($content ?? '') ?></code></pre>

View file

@ -0,0 +1,56 @@
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<div class="navbar-brand">功能選單</div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav"
aria-controls="nav" aria-expanded="false" aria-label="顯示/隱藏選單">
<i class="fa-solid fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="nav">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a
<?php if (isset($nav) && $nav === 'index'): ?>
class="nav-link active"
aria-current="page"
<?php else: ?>
class="nav-link"
<?php endif ?>
href="/index.php"
>
<i class="fa-solid fa-house"></i>
首頁
</a>
</li>
<li class="nav-item">
<a
<?php if (isset($nav) && $nav === 'configurations'): ?>
class="nav-link active"
aria-current="page"
<?php else: ?>
class="nav-link"
<?php endif ?>
href="/configurations/list.php"
>
<i class="fa-solid fa-file-code"></i>
檢視設定檔
</a>
</li>
<li class="nav-item">
<a
<?php if (isset($nav) && $nav === 'logs'): ?>
class="nav-link active"
aria-current="page"
<?php else: ?>
class="nav-link"
<?php endif ?>
href="/logs/list.php"
>
<i class="fa-solid fa-file-lines"></i>
檢視日誌
</a>
</li>
</ul>
</div>
</div>
</nav>
<div>您已使用 <code><?= $this->e($whoami ?? '') ?></code> 登入,點選此處以<a href="/logout.php">登出系統</a>。</div>

23
templates/template.php Normal file
View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title><?= $this->e($title ?? '無標題網頁') ?></title>
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/font-awesome/css/all.min.css"/>
<link rel="stylesheet" href="/style.css"/>
<?= $this->section('styles') ?>
</head>
<body class="text-center">
<h1 class="h3 mb-3 font-weight-normal"><?= $this->e($title ?? '無標題網頁') ?></h1>
<?php if (isset($isLogin) && $isLogin && (!isset($noStatus) || !$noStatus)): ?>
<?php $this->insert('partials/menu', ['nav' => $nav ?? '']) ?>
<?php endif ?>
<main><?= $this->section('content') ?></main>
<footer class="my-2 text-muted">Copyright &copy; 2022 Ming Tsay. All rights reserved.</footer>
<script src="/bootstrap/js/bootstrap.bundle.min.js"></script>
<?= $this->section('scripts') ?>
</body>
</html>