getMessage()); } // Initialize variables $address = null; $phone1 = null; $phone2 = null; $email = null; $working_hours = null; $footer_logo = null; $facebook_url = null; $twitter_url = null; $instagram_url = null; $youtube_url = null; $footer_content = null; $map_embed_url = null; // Variable for Map URL $site_title = null; // Site title (auto) // -------- Fetch site configuration from site_config -------- if ($db instanceof PDO) { try { // Try query WITH site_title (if column exists) $stmt = $db->prepare(" SELECT address, phone1, phone2, email, working_hours, footer_logo, facebook_url, twitter_url, instagram_url, youtube_url, map_embed_url, site_title FROM site_config WHERE id = 1 LIMIT 1 "); $stmt->execute(); $site_config = $stmt->fetch(PDO::FETCH_ASSOC); } catch (Exception $e) { // Fallback: query WITHOUT site_title if column doesn't exist logError("site_config fetch with site_title failed, retrying without column: " . $e->getMessage()); $site_config = null; try { $stmt = $db->prepare(" SELECT address, phone1, phone2, email, working_hours, footer_logo, facebook_url, twitter_url, instagram_url, youtube_url, map_embed_url FROM site_config WHERE id = 1 LIMIT 1 "); $stmt->execute(); $site_config = $stmt->fetch(PDO::FETCH_ASSOC); } catch (Exception $e2) { logError("Error fetching site_config in footer: " . $e2->getMessage()); } } if (!empty($site_config)) { $address = $site_config['address'] ?? null; $phone1 = $site_config['phone1'] ?? null; $phone2 = $site_config['phone2'] ?? null; $email = $site_config['email'] ?? null; $working_hours = $site_config['working_hours'] ?? null; $footer_logo = !empty($site_config['footer_logo']) ? (defined('SITE_URL') ? SITE_URL : '') . '/img/site_config/' . $site_config['footer_logo'] : null; $facebook_url = $site_config['facebook_url'] ?? null; $twitter_url = $site_config['twitter_url'] ?? null; $instagram_url = $site_config['instagram_url'] ?? null; $youtube_url = $site_config['youtube_url'] ?? null; $map_embed_url = $site_config['map_embed_url'] ?? null; $site_title = $site_config['site_title'] ?? null; } } // -------- site_title: safe fallback chain -------- if (!$site_title) { if (defined('SITE_TITLE') && SITE_TITLE) { $site_title = SITE_TITLE; } else { $host = null; if (defined('SITE_URL') && SITE_URL) { $host = parse_url(SITE_URL, PHP_URL_HOST); } if (!$host && !empty($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } $site_title = $host ? preg_replace('/^www\./i', '', $host) : 'Website'; } } // -------- Fetch footer content from footer_settings for about_ndf -------- if ($db instanceof PDO) { try { $stmt = $db->prepare("SELECT content FROM footer_settings WHERE section_name = 'about_ndf' AND status = 'active' LIMIT 1"); $stmt->execute(); $footer_text = $stmt->fetch(PDO::FETCH_ASSOC); if ($footer_text) { $footer_content = htmlspecialchars_decode($footer_text['content'], ENT_QUOTES); } } catch (Exception $e) { logError("Error fetching footer text from footer_settings: " . $e->getMessage()); } } ?>