$value) { if (is_string($value)) { $siteConfig[$key] = htmlspecialchars_decode($value, ENT_QUOTES); } } } catch (PDOException $e) { $error = "Database error: " . htmlspecialchars($e->getMessage()); logError($error); } // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update') { if (!verifyCSRF($_POST['csrf_token'])) { $error = "Invalid CSRF token."; logError($error); } else { $site_title = sanitizeInput($_POST['site_title'], false); $site_subtitle = sanitizeInput($_POST['site_subtitle'], false); $meta_title = sanitizeInput($_POST['meta_title'], false); $meta_description = sanitizeInput($_POST['meta_description'], false); $meta_keywords = sanitizeInput($_POST['meta_keywords'], false); $meta_author = sanitizeInput($_POST['meta_author'], false); $address = sanitizeInput($_POST['address'], false); $phone1 = sanitizeInput($_POST['phone1'], false); $phone2 = !empty($_POST['phone2']) ? sanitizeInput($_POST['phone2'], false) : null; $email = sanitizeInput($_POST['email'], false); $working_hours = sanitizeInput($_POST['working_hours'], false); $facebook_url = !empty($_POST['facebook_url']) ? sanitizeInput($_POST['facebook_url'], false) : '#'; $twitter_url = !empty($_POST['twitter_url']) ? sanitizeInput($_POST['twitter_url'], false) : '#'; $instagram_url = !empty($_POST['instagram_url']) ? sanitizeInput($_POST['instagram_url'], false) : '#'; $youtube_url = !empty($_POST['youtube_url']) ? sanitizeInput($_POST['youtube_url'], false) : '#'; $website_url = !empty($_POST['website_url']) ? sanitizeInput($_POST['website_url'], false) : '#'; $map_embed_url = !empty($_POST['map_embed_url']) ? trim($_POST['map_embed_url']) : null; $footer_logo = $siteConfig['footer_logo'] ?? null; $header_logo = $siteConfig['header_logo'] ?? null; $site_icon = $siteConfig['site_icon'] ?? null; if ($map_embed_url) { logError('Raw map_embed_url input: ' . $map_embed_url); if (preg_match('/