Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie
This commit is contained in:
+50
-2
@@ -1,14 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Logs plugin: toont admin- en request-logs in het beheer.
|
||||
*
|
||||
* Systeem-plugin die logbestanden uitleest en in een tabel toont,
|
||||
* met tabbladen voor admin-logs en request-logs.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Logs
|
||||
{
|
||||
/**
|
||||
* Plugin-API instantie voor communicatie met de CMS-core.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginAPIInterface|null
|
||||
*/
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
/**
|
||||
* Stelt de Plugin-API instantie in.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param PluginAPIInterface $api De Plugin-API instantie.
|
||||
* @return void
|
||||
*/
|
||||
public function setAPI(PluginAPIInterface $api): void
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> Plugin-configuratie met title, viewable en type.
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
@@ -18,6 +45,12 @@ class Logs
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de admin-menu-items voor deze plugin terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
||||
*/
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
$config = $this->getPluginConfig();
|
||||
@@ -38,7 +71,12 @@ class Logs
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this plugin's runtime config (defaults + overrides).
|
||||
* Haalt de runtime-configuratie van deze plugin op (standaardwaarden plus overrides).
|
||||
*
|
||||
* Leest standaardwaarden uit plugin.json en overschrijft deze met config.json.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> De samengevoegde plugin-configuratie.
|
||||
*/
|
||||
private function getPluginConfig(): array
|
||||
{
|
||||
@@ -64,6 +102,16 @@ class Logs
|
||||
return array_merge($defaults, $overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verwerkt een admin-route en toont de logs-pagina.
|
||||
*
|
||||
* Leest de geselecteerde log, parset de regels en toont deze in een tabel
|
||||
* met tabbladen voor admin- en request-logs.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $action De uit te voeren actie.
|
||||
* @return string|null De HTML-uitvoer van de logs-pagina, of null.
|
||||
*/
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
$config = $this->getPluginConfig();
|
||||
@@ -78,7 +126,7 @@ class Logs
|
||||
};
|
||||
|
||||
$tab = $_GET['tab'] ?? 'admin';
|
||||
$logDir = dirname(__DIR__, 2) . '/admin/storage/logs';
|
||||
$logDir = ($this->api ? $this->api->getProjectRoot() : dirname(__DIR__, 2)) . '/admin/storage/logs';
|
||||
$logFile = $tab === 'requests' ? $logDir . '/requests.log' : $logDir . '/admin.log';
|
||||
|
||||
$logs = [];
|
||||
|
||||
Reference in New Issue
Block a user