mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
Added EmailObfuscator class (src/EmailObfuscator.php) that converts email addresses to HTML decimal entities (e.g. foo@...) so browsers render them correctly but bots and scrapers see gibberish. Methods: - email($addr): obfuscate for display in HTML content - mailto($addr): return obfuscated mailto: href - obfuscateHtml($html): post-process rendered HTML to obfuscate all mailto: links (used after Parsedown/Markdown rendering) Applied to: - partage/index.php: mailto link at top + error scenarios via _flash_contact flag rendered in form.php (outside htmlspecialchars to avoid double-escape) - admin/acces.php: request email mailto links - admin/file-access.php: request email mailto links - public/about.php: contact email mailto links - public/tfe.php: author contact mailto links - AboutController: Parsedown output post-processing - LicenceController: Parsedown output post-processing - Dispatcher::render(): require_once EmailObfuscator for all public views Also fixed _flash_contact session flag in form.php partial to show contact email line on share link validation errors (separate from flash_error/warning to bypass htmlspecialchars double-escaping).
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
||
|
||
require_once APP_ROOT . '/src/Database.php';
|
||
require_once APP_ROOT . '/src/Parsedown.php';
|
||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||
|
||
class LicenceController
|
||
{
|
||
public static function create(): self
|
||
{
|
||
return new self();
|
||
}
|
||
|
||
public function handle(): array
|
||
{
|
||
try {
|
||
$db = Database::getInstance();
|
||
$dbPage = $db->getPage('licenses');
|
||
$content = $dbPage ? $dbPage['content'] : '';
|
||
$pageTitle = $dbPage ? $dbPage['title'] : 'Licences';
|
||
} catch (Exception $e) {
|
||
ErrorHandler::log('licence_page', $e);
|
||
$content = '';
|
||
$pageTitle = 'Licences';
|
||
}
|
||
|
||
$pd = new Parsedown();
|
||
$pd->setSafeMode(true);
|
||
$html = EmailObfuscator::obfuscateHtml($pd->text($content));
|
||
|
||
return [
|
||
'content' => $content,
|
||
'html' => $html,
|
||
'pageTitle' => $pageTitle . ' – XAMXAM',
|
||
'metaDescription' => "Informations sur les licences d'utilisation des mémoires publiés sur XAMXAM, le répertoire des TFE de l'erg.",
|
||
'currentNav' => 'licence',
|
||
'extraCss' => ['/assets/css/apropos.css'],
|
||
'bodyClass' => 'apropos-body',
|
||
];
|
||
}
|
||
}
|