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;
}
}