Files
CodePress/plugins/GeoIPInfo/GeoIPInfo.php
T
E.Noorlander 6d5ca7cab4 v2.6.1d (Lyra): Plugin i18n, plugin editor vernieuwd, media invoegen
Plugin internationalisatie: plugins hebben eigen language/ mappen. Systeem
plugins volgen admin taal (admin.php), content plugins volgen content taal
(site.php). Fallback chain: geselecteerd -> plugin default_language -> CMS
default. PluginManager/AdminPluginAPI/CMSAPI uitgebreid met
getPluginTranslations()/t(). plugin.json settings ondersteunen
label_key/help_key/option_label_key.

Plugin uniformiteit: alle 6 plugins hebben uniforme structuur (README.md,
assets/.gitkeep, language/nl|en/). plugins/README.md herschreven.
guide plugin-development.md (NL+EN) volledig herschreven.

Plugin editor vernieuwd: geneste bestandsbrowser zijbalk, nieuw bestand
aanmaken, uploaden naar assets/, verwijderen en verplaatsen. Nieuwe routes:
plugins-file-upload, plugins-file-delete, plugins-file-move. Path-traversal
bescherming + protected plugins geblokkeerd.

Media invoegen in editor: nieuw /admin/media-list JSON endpoint + herbruikbare
_media-modal.twig include. Plugin-context scant assets/ map. editor-toolbar.js
modeMap uitgebreid voor css/scss/js/json.

Plugin overzicht knoppen: alleen iconen met title/aria-label.

Tests: pentest 30/30, WCAG 2.1 AA 25/25.
2026-08-18 13:49:52 +00:00

68 lines
1.9 KiB
PHP

<?php
class GeoIPInfo
{
private ?PluginAPIInterface $api = null;
public function setAPI(PluginAPIInterface $api): void
{
$this->api = $api;
}
public function getConfig(): array
{
return [
'title' => 'GeoIP Info',
'type' => 'system',
];
}
/**
* Register admin menu items.
*/
public function getAdminMenu(): array
{
return [
[
'plugin' => 'GeoIPInfo',
'label' => 'GeoIP Info',
'label_key' => 'menu_label',
'route' => 'geoip-info',
'icon' => 'bi-globe2',
],
];
}
/**
* Register admin routes this plugin handles.
*/
public function getAdminRoutes(): array
{
return ['geoip-info'];
}
/**
* Handle admin route — render the admin page.
*/
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>';
}
}