| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/arni-solutions.de/web/terminal/ |
Upload File : |
<?php
/**
* Werbemittel: Klick-Zähler + Weiterleitung (serverseitiges Tracking).
*
* GET ad-click.php?v=<view_token>&term=<hash>&id=<werbemittel>&pl=<platzierung>
*
* Wird als Link-Ziel der Bild-Anzeigen genutzt und ersetzt den Shortcode
* {{CLICK_URL}} in HTML-Werbemitteln. Zählt in crm_ad_stats (tagesgenau je
* Platzierung) und leitet dann auf den im CRM hinterlegten Ziel-Link um.
*/
require __DIR__ . '/config.inc.php';
$viewToken = (string)($_GET['v'] ?? '');
$termHash = (string)($_GET['term'] ?? '');
$adId = max(0, (int)($_GET['id'] ?? 0));
$pl = (string)($_GET['pl'] ?? '');
$db = term_db();
if (!term_terminal_grants_for($db, $viewToken, $termHash)) { http_response_code(403); exit; }
if (!$adId || !in_array($pl, ['pinnwand', 'comments', 'video'], true)) { http_response_code(404); exit; }
try {
$st = $db->prepare('SELECT target_url FROM crm_ads WHERE id = ? AND is_active = 1');
$st->execute([$adId]);
$target = (string)$st->fetchColumn();
} catch (Throwable $e) {
$target = ''; // CRM-Tabellen (noch) nicht vorhanden
}
if (!preg_match('~^https?://~i', $target)) { http_response_code(404); exit; }
try {
$db->prepare('INSERT INTO crm_ad_stats (ad_id, day, placement, clicks) VALUES (?, CURDATE(), ?, 1)
ON DUPLICATE KEY UPDATE clicks = clicks + 1')->execute([$adId, $pl]);
} catch (Throwable $e) { /* Zählung darf die Weiterleitung nie verhindern */ }
header('Location: ' . $target, true, 302);