Initial dev export (exclude uploads/runtime)

This commit is contained in:
AudioCore Bot
2026-03-04 20:46:11 +00:00
commit b2afadd539
120 changed files with 20410 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace Modules\Plugins;
use Core\Http\Response;
use Core\Services\Auth;
use Core\Services\Plugins;
use Core\Views\View;
class PluginsController
{
private View $view;
public function __construct()
{
$this->view = new View(__DIR__ . '/views');
}
public function index(): Response
{
if ($guard = $this->guard()) {
return $guard;
}
Plugins::sync();
return new Response($this->view->render('admin/index.php', [
'title' => 'Plugins',
'plugins' => Plugins::all(),
]));
}
public function toggle(): Response
{
if ($guard = $this->guard()) {
return $guard;
}
$slug = trim((string)($_POST['slug'] ?? ''));
$enabled = isset($_POST['enabled']) && $_POST['enabled'] === '1';
if ($slug !== '') {
Plugins::toggle($slug, $enabled);
}
return new Response('', 302, ['Location' => '/admin/plugins']);
}
private function guard(): ?Response
{
if (!Auth::check()) {
return new Response('', 302, ['Location' => '/admin/login']);
}
if (!Auth::hasRole(['admin'])) {
return new Response('', 302, ['Location' => '/admin']);
}
return null;
}
}

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
use Core\Http\Router;
use Modules\Plugins\PluginsController;
require_once __DIR__ . '/PluginsController.php';
return function (Router $router): void {
$controller = new PluginsController();
$router->get('/admin/plugins', [$controller, 'index']);
$router->post('/admin/plugins/toggle', [$controller, 'toggle']);
};

View File

@@ -0,0 +1,55 @@
<?php
$pageTitle = $title ?? 'Plugins';
$plugins = $plugins ?? [];
ob_start();
?>
<section class="admin-card">
<div class="badge">Plugins</div>
<div style="display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px;">
<div>
<h1 style="font-size:28px; margin:0;">Plugins</h1>
<p style="color: var(--muted); margin-top:6px;">Enable or disable optional features.</p>
</div>
</div>
<?php if (!$plugins): ?>
<div style="margin-top:18px; color: var(--muted); font-size:13px;">No plugins found in <code>/dev/plugins</code>.</div>
<?php else: ?>
<div style="margin-top:18px; display:grid; gap:12px;">
<?php foreach ($plugins as $plugin): ?>
<div class="admin-card" style="padding:16px; display:grid; gap:10px;">
<div style="display:flex; align-items:flex-start; justify-content:space-between; gap:16px;">
<div>
<div style="font-size:18px; font-weight:600;">
<?= htmlspecialchars((string)($plugin['name'] ?? ''), ENT_QUOTES, 'UTF-8') ?>
</div>
<div style="font-size:12px; color: var(--muted); margin-top:4px;">
<?= htmlspecialchars((string)($plugin['description'] ?? ''), ENT_QUOTES, 'UTF-8') ?>
</div>
<div style="margin-top:8px; font-size:12px; color: var(--muted); display:flex; gap:14px; flex-wrap:wrap;">
<span>Slug: <?= htmlspecialchars((string)($plugin['slug'] ?? ''), ENT_QUOTES, 'UTF-8') ?></span>
<span>Version: <?= htmlspecialchars((string)($plugin['version'] ?? ''), ENT_QUOTES, 'UTF-8') ?></span>
<?php if (!empty($plugin['author'])): ?>
<span>Author: <?= htmlspecialchars((string)$plugin['author'], ENT_QUOTES, 'UTF-8') ?></span>
<?php endif; ?>
</div>
</div>
<form method="post" action="/admin/plugins/toggle" style="display:flex; align-items:center; gap:10px;">
<input type="hidden" name="slug" value="<?= htmlspecialchars((string)($plugin['slug'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
<?php if (!empty($plugin['is_enabled'])): ?>
<input type="hidden" name="enabled" value="0">
<button type="submit" class="btn outline small">Disable</button>
<?php else: ?>
<input type="hidden" name="enabled" value="1">
<button type="submit" class="btn small">Enable</button>
<?php endif; ?>
</form>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<?php
$content = ob_get_clean();
require __DIR__ . '/../../../admin/views/layout.php';