<?php


//Datenbank verbindung
$dbhost = "mysql2fda.netcup.net";
$dbuser = "k25330_pracreutz";
$dbpassword = "be4K8DSASDA2y";
$dbname = "k25330_pracreutz";


$organisationsname = "Praxis Creutzburg";
$organisationsurl = "https://www.praxis-creutzburg.de/";

$con = new mysqli($dbhost,$dbuser,$dbpassword,$dbname);		
$con->set_charset('utf8mb4');

// SQL Datum festlegen
$sqltoday = date("Y-m-d");
$currentDate = new DateTime();
//Use the subtract function to subtract a DateInterval
$yesterdayTime = $currentDate->sub(new DateInterval('P1D'));
//Get yesterday date
$sqlyesterday = $yesterdayTime->format('Y-m-d');
$yesterday = $sqlyesterday;
#$sqlyesterday = date("Y-m-d", strtotime("-1 day", $sqltoday ));
#$yesterday = Date('Y-m-d', strtotime('-1 day'));
#$yesteryesterday = Date('Y-m-d', strtotime('-2 days'));
$yesterdayTime = $currentDate->sub(new DateInterval('P1D'));
//Get yesterday date
$yesteryesterday = $yesterdayTime->format('Y-m-d');

$pdo = new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8mb4", $dbuser, $dbpassword,
    [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    ]);


#Laufband
$ids = [6,7,8,9,10,11];

$placeholders = implode(',', array_fill(0, count($ids), '?'));
$stmt = $pdo->prepare("
    SELECT inhaltid, inhalt
    FROM webseiteninhalt
    WHERE inhaltid IN ($placeholders)
");
$stmt->execute($ids);

$laufband = [];

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $laufband[$row['inhaltid']] = strip_tags($row['inhalt']);
}

// Zugriff:
$Laufband1 = $laufband[6]  ?? '';
$Laufband2 = $laufband[7]  ?? '';
$Laufband3 = $laufband[8]  ?? '';
$Laufband4 = $laufband[9]  ?? '';
$Laufband5 = $laufband[10] ?? '';
$Laufband6 = $laufband[11] ?? '';


session_set_cookie_params([
  'lifetime' => 60*60*24*30,
  'path' => '/',
  'secure' => true,      // nur wenn HTTPS (sollte bei dir so sein)
  'httponly' => true,
  'samesite' => 'Lax',
]);

ini_set('session.use_strict_mode', '1');
ini_set('session.cookie_secure', '1');   // bei HTTPS
ini_set('session.cookie_httponly', '1');

session_start();
