prepare('SELECT id, name, aion_char_id FROM member_characters WHERE user_id = ?'); $stmt->execute([$userId]); $raidsInput = is_array($_POST['raids'] ?? null) ? $_POST['raids'] : []; $scoreInput = is_array($_POST['gs'] ?? null) ? $_POST['gs'] : []; $powerInput = is_array($_POST['cp'] ?? null) ? $_POST['cp'] : []; $noteInput = is_array($_POST['note'] ?? null) ? $_POST['note'] : []; $entries = []; foreach ($stmt->fetchAll() as $character) { $id = (int) $character['id']; $raids = array_values(array_intersect(array_keys(SANCTUARY_RAIDS), is_array($raidsInput[$id] ?? null) ? $raidsInput[$id] : [])); if (!$raids) { continue; } $score = sanctuary_number_input($scoreInput[$id] ?? '', SANCTUARY_GEARSCORE_MAX); $power = sanctuary_number_input($powerInput[$id] ?? '', SANCTUARY_POWER_MAX); if ($score === false) { $errors[] = $character['name'] . ': Der Gearscore muss eine Zahl bis ' . number_format(SANCTUARY_GEARSCORE_MAX, 0, ',', '.') . ' sein.'; } if ($power === false) { $errors[] = $character['name'] . ': Die Kampfkraft muss eine ganze Zahl sein, z. B. 98986.'; } $note = is_string($noteInput[$id] ?? null) ? trim((string) preg_replace('/\s+/u', ' ', $noteInput[$id])) : ''; $entries[$id] = [ 'raids' => $raids, 'gearscore' => $score === false ? null : $score, 'combat_power' => $power === false ? null : $power, 'note' => mb_substr($note, 0, SANCTUARY_NOTE_MAX), ]; } if (!$entries) { $errors[] = 'Wähle bei mindestens einem Charakter ein Refugium aus.'; } if (!$windows && !$errors) { $errors[] = 'Trage mindestens ein Zeitfenster ein – Wochentag, Beginn und Ende.'; } if ($errors) { set_flash('error', implode(' ', array_unique($errors))); redirect('/sanctuary.php#mein-eintrag'); } sanctuary_save($userId, $windows, $entries); set_flash('success', 'Gespeichert – du stehst jetzt im Refugien-Planer. Der Eintrag gilt ' . SANCTUARY_EXPIRE_DAYS . ' Tage, danach bitte kurz bestätigen.'); redirect('/sanctuary.php');