23-01-2026
This commit is contained in:
parent
07959c0ba2
commit
854ce02bf6
166 changed files with 32909 additions and 1262 deletions
87
public/_cabinet/go.php
Normal file
87
public/_cabinet/go.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/*
|
||||
Redirect-Script mit Datenbanklogging für Display-Footer-Inhalte
|
||||
Funktioniert sowohl in _display-b2in-eu als auch in _cabinet
|
||||
Aufruf via: https://cabinet.b2in.eu/go.php?z=abc123
|
||||
*/
|
||||
|
||||
// Datenbankverbindung direkt (ohne Laravel Bootstrap)
|
||||
// Lade .env Datei
|
||||
$envFile = __DIR__ . '/../../.env';
|
||||
if (file_exists($envFile)) {
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), '#') === 0) continue;
|
||||
if (strpos($line, '=') === false) continue;
|
||||
list($name, $value) = explode('=', $line, 2);
|
||||
$name = trim($name);
|
||||
$value = trim($value);
|
||||
if (!getenv($name)) {
|
||||
putenv("$name=$value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dbHost = getenv('DB_HOST') ?: 'mysql';
|
||||
$dbName = getenv('DB_DATABASE') ?: 'b2in';
|
||||
$dbUser = getenv('DB_USERNAME') ?: 'sail';
|
||||
$dbPass = getenv('DB_PASSWORD') ?: 'password';
|
||||
|
||||
$shortCode = isset($_GET['z']) ? $_GET['z'] : '';
|
||||
|
||||
if (empty($shortCode)) {
|
||||
http_response_code(404);
|
||||
echo "Kein Ziel angegeben.";
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// PDO-Verbindung zur Datenbank
|
||||
$pdo = new PDO("mysql:host={$dbHost};dbname={$dbName};charset=utf8mb4", $dbUser, $dbPass, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
|
||||
// Suche den Footer-Content mit diesem Short-Code
|
||||
$stmt = $pdo->prepare("SELECT * FROM display_footer_contents WHERE short_code = ? LIMIT 1");
|
||||
$stmt->execute([$shortCode]);
|
||||
$footerContent = $stmt->fetch();
|
||||
|
||||
if ($footerContent) {
|
||||
// Klicks erhöhen
|
||||
$updateStmt = $pdo->prepare("UPDATE display_footer_contents SET clicks = clicks + 1 WHERE id = ?");
|
||||
$updateStmt->execute([$footerContent['id']]);
|
||||
|
||||
// Optional: Logging in Datei
|
||||
$logEntry = date('Y-m-d H:i:s') . " - Code: {$shortCode} - Headline: {$footerContent['headline']} - URL: {$footerContent['url']}\n";
|
||||
@file_put_contents(__DIR__ . '/clicks.log', $logEntry, FILE_APPEND);
|
||||
|
||||
// Redirect zur Original-URL
|
||||
header("Location: " . $footerContent['url']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fallback: Alte Codes für Rückwärtskompatibilität
|
||||
$alteCodes = [
|
||||
't' => 'https://www.cabinet.de/bielefeld?utm_source=store_display&utm_medium=qr_code&utm_campaign=bielefeld_pos&utm_content=termin_buchung#c39393',
|
||||
't1' => 'https://www.cabinet.de/bielefeld?utm_source=store_display&utm_medium=qr_code&utm_campaign=bielefeld_pos&utm_content=termin_buchung#c39393',
|
||||
'p' => 'https://de.pinterest.com/cabinet_AG/',
|
||||
'i' => 'https://www.instagram.com/cabinet_schranksysteme/',
|
||||
'f' => 'https://de-de.facebook.com/cabinetschranksysteme/'
|
||||
];
|
||||
|
||||
if (isset($alteCodes[$shortCode])) {
|
||||
$logEntry = date('Y-m-d H:i:s') . " - Legacy Code: {$shortCode}\n";
|
||||
@file_put_contents(__DIR__ . '/clicks.log', $logEntry, FILE_APPEND);
|
||||
|
||||
header("Location: " . $alteCodes[$shortCode]);
|
||||
exit;
|
||||
}
|
||||
|
||||
http_response_code(404);
|
||||
echo "Ziel nicht gefunden.";
|
||||
} catch (PDOException $e) {
|
||||
error_log("Display Go.php Database Error: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo "Ein Fehler ist aufgetreten.";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue