- Bug: dashboard toonde 0 content (AdminPluginAPI::getContentDir() gaf relatief pad terug zonder normalisatie) - Dynamische pad-resolutie: PluginAPIInterface uitgebreid met getProjectRoot/getContentDir/getPluginsDir/getVersionInfo; CMSAPI en AdminPluginAPI implementeren deze universeel - public/index.php media-serving gebruikt $config['content_dir'] i.p.v. hardcoded /content - Navigation en Logs plugins halen paden via de API i.p.v. hardcoded dirname(__DIR__) - WordPress-stijl docblocks toegevoegd voor alle classes, methods, properties en functies (~450 docblocks, @since 2.6.5) - Security: hardcoded plaintext-wachtwoord 'admin' verwijderd uit AdminAuth.php; bij eerste installatie wordt een cryptografisch veilig wachtwoord gegenereerd (random_bytes, 16 tekens) en eenmalig op het inlogscherm getoond - Security: git-geschiedenis schoongemaakt (admin.json, admin.json.example, admin-console/config/admin.json verwijderd uit alle commits; filter-branch over alle branches + tags, gc --prune --aggressive) - README.md, README.en.md, AGENTS.md bijgewerkt - Test-scripts bijgewerkt naar clean-URL structuur + actuele ARIA-waarden - Versie verhoogd naar 2.6.5 - Tests: pentest 29/29, WCAG 25/25, functioneel 16/16, enhanced 25/25
107 lines
3.0 KiB
PHP
107 lines
3.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* GeoIPInfo plugin: toont geografische informatie op basis van IP-adres.
|
|
*
|
|
* Systeem-plugin die een admin-pagina biedt met het IP-adres van de bezoeker
|
|
* en het bijbehorende land via de GeoIP-dienst.
|
|
*
|
|
* @since 2.6.5
|
|
*/
|
|
class GeoIPInfo
|
|
{
|
|
/**
|
|
* Plugin-API instantie voor communicatie met de CMS-core.
|
|
*
|
|
* @since 2.6.5
|
|
* @var PluginAPIInterface|null
|
|
*/
|
|
private ?PluginAPIInterface $api = null;
|
|
|
|
/**
|
|
* Stelt de Plugin-API instantie in.
|
|
*
|
|
* @since 2.6.5
|
|
* @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.5
|
|
* @return array<string, mixed> Plugin-configuratie met title en type.
|
|
*/
|
|
public function getConfig(): array
|
|
{
|
|
return [
|
|
'title' => 'GeoIP Info',
|
|
'type' => 'system',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Geeft de admin-menu-items voor deze plugin terug.
|
|
*
|
|
* @since 2.6.5
|
|
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
|
*/
|
|
public function getAdminMenu(): array
|
|
{
|
|
return [
|
|
[
|
|
'plugin' => 'GeoIPInfo',
|
|
'label' => 'GeoIP Info',
|
|
'label_key' => 'menu_label',
|
|
'route' => 'geoip-info',
|
|
'icon' => 'bi-globe2',
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Geeft de admin-routes terug die deze plugin afhandelt.
|
|
*
|
|
* @since 2.6.5
|
|
* @return array<int, string> Lijst met admin-route namen.
|
|
*/
|
|
public function getAdminRoutes(): array
|
|
{
|
|
return ['geoip-info'];
|
|
}
|
|
|
|
/**
|
|
* Verwerkt een admin-route en toont de GeoIP-info-pagina.
|
|
*
|
|
* Bepaalt het IP-adres van de bezoeker en toont het land en de vlag.
|
|
*
|
|
* @since 2.6.5
|
|
* @param string $route De af te handelen admin-route.
|
|
* @return void
|
|
*/
|
|
public function handleAdminRoute(string $route): void
|
|
{
|
|
$ip = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';
|
|
$geoip = new GeoIP();
|
|
$countryCode = $geoip->lookupCountry($ip);
|
|
$country = GeoIP::getCountryName($countryCode);
|
|
$flag = GeoIP::getCountryFlagEmoji($countryCode);
|
|
|
|
$t = $this->api ? $this->api->getPluginTranslations('GeoIPInfo') : [];
|
|
$tr = function (string $key) use ($t): string {
|
|
return $t[$key] ?? $key;
|
|
};
|
|
|
|
echo '<h2 class="mb-4"><i class="bi bi-globe2"></i> ' . htmlspecialchars($tr('page_title')) . '</h2>';
|
|
echo '<div class="card shadow-sm"><div class="card-body">';
|
|
echo '<table class="table table-sm">';
|
|
echo '<tr><td>' . htmlspecialchars($tr('ip_address')) . '</td><td><code>' . htmlspecialchars($ip) . '</code></td></tr>';
|
|
echo '<tr><td>' . htmlspecialchars($tr('country')) . '</td><td>' . $flag . ' ' . htmlspecialchars($country) . '</td></tr>';
|
|
echo '</table>';
|
|
echo '</div></div>';
|
|
}
|
|
} |