?php require_once 'config/database.php'; require_once 'config/language.php'; // Initialize variables for form handling $success = false; $errors = []; // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { // CSRF Check $csrf_token = filter_input(INPUT_POST, 'csrf_token', FILTER_SANITIZE_SPECIAL_CHARS); if (!validateCSRFToken($csrf_token)) { $errors[] = t('csrf_error'); } $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS); $whatsapp = filter_input(INPUT_POST, 'whatsapp', FILTER_SANITIZE_SPECIAL_CHARS); $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $svc = filter_input(INPUT_POST, 'service', FILTER_SANITIZE_SPECIAL_CHARS); $subject = filter_input(INPUT_POST, 'subject', FILTER_SANITIZE_SPECIAL_CHARS); $message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_SPECIAL_CHARS); if (empty($name)) $errors[] = t('name_required'); if (empty($whatsapp)) $errors[] = t('whatsapp_required'); elseif (!preg_match('/^\+?[0-9]{10,15}$/', $whatsapp)) $errors[] = t('whatsapp_invalid'); if (empty($email)) $errors[] = t('email_required'); elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) $errors[] = t('email_invalid'); if (empty($svc)) $errors[] = t('service_required'); if (empty($message)) $errors[] = t('message_required'); if (empty($errors)) { try { $ip = $_SERVER['REMOTE_ADDR']; $ua = $_SERVER['HTTP_USER_AGENT']; $stmt = $db->prepare("INSERT INTO contact_form_submissions (name, whatsapp, email, service, subject, message, ip_address, user_agent) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$name, $whatsapp, $email, $svc, $subject, $message, $ip, $ua]); $success = true; } catch (PDOException $e) { $errors[] = t('error_occurred'); error_log("DB Error: " . $e->getMessage()); } } } // Fetch service $slug = isset($_GET['slug']) ? trim($_GET['slug']) : ''; $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (empty($slug) && empty($id)) { header('Location: services.php'); exit; } if (!empty($slug)) { $stmt = $db->prepare("SELECT * FROM services WHERE slug = ? AND language = ?"); $stmt->execute([$slug, $page_language]); } else { $stmt = $db->prepare("SELECT * FROM services WHERE id = ? AND language = ?"); $stmt->execute([$id, $page_language]); } $service = $stmt->fetch(); // ── Fallback: if DB is empty, serve from hardcoded map ────────────────── if (!$service) { $is_ar_fb = ($page_language === 'ar'); $fallback_map = [ 'paid-ads' => [ 'id'=>1,'slug'=>'paid-ads','language'=>$page_language, 'title' => $is_ar_fb ? 'إعلانات مدفوعة (Meta & Google)' : 'Paid Advertising (Meta & Google)', 'short_description' => $is_ar_fb ? 'حملات إعلانية مدروسة تستهدف عميلك الصح في الوقت الصح — نحسّن كل ريال تصرفه.' : 'Strategic ad campaigns targeting the right client at the right time — we optimize every pound you spend.', 'description' => $is_ar_fb ? "إعلانات Meta (فيسبوك وإنستاجرام) وGoogle Ads مصممة خصيصاً لقطاعك وجمهورك.\n\nبنبدأ بتحليل جمهورك المستهدف وتحديد أفضل منصة للوصول له، ثم نبني الحملات من الصفر بأقل تكلفة للنقرة وأعلى معدل تحويل.\n\nمش بنطلق إعلانات قبل اكتمال الهوية البصرية — لأن الإعلان على هوية ناقصة = حرق ميزانية." : "Meta Ads (Facebook & Instagram) and Google Ads designed specifically for your sector and audience.\n\nWe start by analyzing your target audience and identifying the best platform to reach them, then build campaigns from scratch with the lowest cost-per-click and highest conversion rate.\n\nWe never launch ads before your brand identity is complete — because advertising without a complete brand = burning budget.", 'icon'=>'bi-megaphone-fill','image'=>'','seo_keywords'=>'', ], 'seo' => [ 'id'=>2,'slug'=>'seo','language'=>$page_language, 'title' => $is_ar_fb ? 'سيو وظهور في محركات البحث' : 'SEO & Search Engine Visibility', 'short_description' => $is_ar_fb ? 'نخليك تظهر أول لما عميلك يدور على خدمتك — ظهور عضوي مستدام بدون إعلانات.' : 'Get you to appear first when your client searches for your service — sustainable organic visibility without ads.', 'description' => $is_ar_fb ? "SEO (تحسين محركات البحث) هو الاستثمار طويل المدى اللي بيخليك تظهر في أول نتائج جوجل بدون أي إعلانات مدفوعة.\n\nبنشتغل على: بحث الكلمات المفتاحية لقطاعك، تحسين on-page، بناء backlinks، تحسين سرعة الموقع، وإنشاء محتوى SEO متخصص.\n\nالنتيجة: ظهور مستدام يجيب عملاء 24/7 بدون تكلفة إعلانية مستمرة." : "SEO (Search Engine Optimization) is the long-term investment that puts you at the top of Google without any paid ads.\n\nWe work on: keyword research for your sector, on-page optimization, backlink building, site speed improvement, and creating specialized SEO content.\n\nThe result: sustainable visibility that brings clients 24/7 without ongoing ad costs.", 'icon'=>'bi-search','image'=>'','seo_keywords'=>'', ], 'branding' => [ 'id'=>3,'slug'=>'branding','language'=>$page_language, 'title' => $is_ar_fb ? 'هوية بصرية وتصميم' : 'Brand Identity & Design', 'short_description' => $is_ar_fb ? 'هوية تعكس احترافية شركتك — لوجو، ألوان، خطوط، وكل عناصر الهوية البصرية.' : 'An identity that reflects your company\'s professionalism — logo, colors, fonts, and all visual identity elements.', 'description' => $is_ar_fb ? "الهوية البصرية هي أول انطباع عن شركتك — ولازم تكون احترافية قبل أي إعلانات.\n\nبنقدملك: شعار (logo) بكل variants، دليل هوية بصرية كامل، قوالب السوشيال ميديا، بريد إلكتروني رسمي، ومواد تسويقية مطبوعة ورقمية.\n\nالهوية اللي بنبنيها بتكون foundation لكل حاجة تانية — الموقع، الإعلانات، والمحتوى." : "Brand identity is the first impression of your company — and it must be professional before any advertising.\n\nWe deliver: logo with all variants, complete visual identity guide, social media templates, official email design, and printed & digital marketing materials.\n\nThe brand we build becomes the foundation for everything else — website, ads, and content.", 'icon'=>'bi-palette-fill','image'=>'','seo_keywords'=>'', ], 'website' => [ 'id'=>4,'slug'=>'website','language'=>$page_language, 'title' => $is_ar_fb ? 'تطوير المواقع الإلكترونية' : 'Website Development', 'short_description' => $is_ar_fb ? 'موقع احترافي مُحسَّن SEO مصمم خصيصاً لقطاعك — مش قالب جاهز.' : 'Professional SEO-optimized website designed specifically for your sector — not a generic template.', 'description' => $is_ar_fb ? "موقعك هو ممثلك الرقمي اللي بيشتغل 24/7 — لازم يكون احترافي، سريع، ومُحسَّن لمحركات البحث.\n\nبنبني: مواقع custom (مش قوالب جاهزة)، صفحات هبوط (landing pages) لكل خدمة، تحسين SEO من اليوم الأول، وربط CRM وأتمتة التسويق.\n\nكل موقع بنبنيه مخصص 100% لطبيعة قطاعك وجمهورك المستهدف." : "Your website is your digital representative working 24/7 — it must be professional, fast, and SEO-optimized.\n\nWe build: custom websites (not templates), landing pages for each service, SEO optimization from day one, and CRM & marketing automation integration.\n\nEvery website we build is 100% customized for your sector and target audience.", 'icon'=>'bi-laptop','image'=>'','seo_keywords'=>'', ], 'social-media' => [ 'id'=>5,'slug'=>'social-media','language'=>$page_language, 'title' => $is_ar_fb ? 'إدارة السوشيال ميديا' : 'Social Media Management', 'short_description' => $is_ar_fb ? 'حضور منظم ومتسق على السوشيال ميديا يبني ثقة الجمهور ويجذب عملاء جدد.' : 'Organized, consistent social media presence that builds audience trust and attracts new clients.', 'description' => $is_ar_fb ? "إدارة السوشيال ميديا مش مجرد نشر صور — هي منظومة محتوى استراتيجي تبني علاقة مع جمهورك.\n\nبنقدملك: استراتيجية محتوى مخصصة، Content Calendar شهري، تصاميم احترافية، كتابة نصوص متخصصة، وتقرير أداء شهري.\n\nبنركز على LinkedIn للـ B2B، Facebook وInstagram للـ B2C، وTikTok للوعي بالعلامة التجارية." : "Social media management isn't just posting images — it's a strategic content system that builds a relationship with your audience.\n\nWe deliver: customized content strategy, monthly Content Calendar, professional designs, specialized copywriting, and monthly performance reports.\n\nWe focus on LinkedIn for B2B, Facebook & Instagram for B2C, and TikTok for brand awareness.", 'icon'=>'bi-instagram','image'=>'','seo_keywords'=>'', ], 'content-marketing' => [ 'id'=>6,'slug'=>'content-marketing','language'=>$page_language, 'title' => $is_ar_fb ? 'تسويق المحتوى وSEO' : 'Content Marketing & SEO', 'short_description' => $is_ar_fb ? 'محتوى متخصص يبني سمعتك كخبير في مجالك ويجذب عملاء قبل الإعلانات.' : 'Specialized content that builds your reputation as an expert and attracts clients before ads.', 'description' => $is_ar_fb ? "المحتوى هو الأساس اللي بيبني الثقة — مقالات، Reels، Explainer Videos، ودراسات حالة.\n\nبنبني لك: خطة محتوى متكاملة، مقالات SEO متخصصة في قطاعك، محتوى سوشيال يعكس خبرتك، وفيديوهات تسويقية تُقنع قبل ما العميل يتصل.\n\nالمحتوى الجيد هو اللي بيخليك تُغني عن بعض الإعلانات المدفوعة على المدى الطويل." : "Content is the foundation that builds trust — articles, Reels, Explainer Videos, and case studies.\n\nWe build: integrated content plan, SEO articles specialized in your sector, social content that reflects your expertise, and marketing videos that convince before the client calls.\n\nGood content is what allows you to reduce dependence on paid ads in the long run.", 'icon'=>'bi-pencil-square','image'=>'','seo_keywords'=>'', ], 'crm-automation' => [ 'id'=>7,'slug'=>'crm-automation','language'=>$page_language, 'title' => $is_ar_fb ? 'CRM وأتمتة التسويق' : 'CRM & Marketing Automation', 'short_description' => $is_ar_fb ? 'نظام متابعة تلقائي يحوّل الـ leads لعملاء — حتى لو أنت نايم.' : 'Automated follow-up system that converts leads into clients — even while you sleep.', 'description' => $is_ar_fb ? "CRM وأتمتة التسويق هي القلب اللي بيخلي كل حاجة تانية تشتغل بكفاءة.\n\nبنبني لك: نظام CRM مخصص لدورة البيع في قطاعك، Email sequences تلقائية، متابعة الـ leads، وربط الموقع بالـ CRM.\n\nالنتيجة: مفيش lead يضيع، ومتابعة تلقائية تحوّل المهتمين لعملاء فعليين." : "CRM and marketing automation is the engine that makes everything else work efficiently.\n\nWe build: CRM system customized for your sector's sales cycle, automated email sequences, lead follow-up, and website-CRM integration.\n\nThe result: no lead is lost, and automated follow-up converts interested prospects into actual clients.", 'icon'=>'bi-robot','image'=>'','seo_keywords'=>'', ], 'photography-video' => [ 'id'=>8,'slug'=>'photography-video','language'=>$page_language, 'title' => $is_ar_fb ? 'تصوير احترافي وفيديو تسويقي' : 'Professional Photography & Marketing Video', 'short_description' => $is_ar_fb ? 'صور وفيديوهات حقيقية تبني ثقة العملاء أكثر من أي محتوى مصنوع.' : 'Real photos and videos that build client trust more than any produced content.', 'description' => $is_ar_fb ? "المحتوى البصري الحقيقي هو أقوى أداة تسويقية — صور شركتك الحقيقية أكثر تأثيراً من أي Stock Images.\n\nبنقدملك: تصوير الشركة/المصنع/الفريق، جولات فيديو، Reels للسوشيال، و Explainer Videos تشرح خدماتك بشكل مبسط وجذاب.\n\nالمحتوى البصري الجيد يقنع العميل قبل ما يتصل بك." : "Real visual content is the most powerful marketing tool — real photos of your company are more impactful than any Stock Images.\n\nWe deliver: company/factory/team photography, video tours, social media Reels, and Explainer Videos that explain your services in a simple, engaging way.\n\nGood visual content convinces the client before they even call you.", 'icon'=>'bi-camera-video-fill','image'=>'','seo_keywords'=>'', ], ]; // Try to match by slug or by id if (!empty($slug) && isset($fallback_map[$slug])) { $service = $fallback_map[$slug]; } elseif (!empty($id)) { foreach ($fallback_map as $fb) { if ($fb['id'] === $id) { $service = $fb; break; } } } if (!$service) { header('Location: services.php'); exit; } // Fake empty related services and service_content for fallback $service_content = []; $related_services = array_values(array_filter($fallback_map, fn($s) => $s['id'] !== $service['id'])); $related_services = array_slice($related_services, 0, 3); } // Fetch service_content (features/process from structured table) // Only fetch from DB if service came from DB (not fallback) if (!isset($service_content)) { $stmt = $db->prepare("SELECT * FROM service_content WHERE service_id = ? AND language = ? ORDER BY content_type, order_index"); $stmt->execute([$service['id'], $page_language]); $service_content = $stmt->fetchAll(PDO::FETCH_GROUP); } // Fetch related services (only from DB if not already set by fallback) if (!isset($related_services)) { $stmt = $db->prepare("SELECT id, title, slug, short_description, icon FROM services WHERE id != ? AND language = ? ORDER BY order_index LIMIT 3"); $stmt->execute([$service['id'], $page_language]); $related_services = $stmt->fetchAll(); } $is_ar = ($page_language === 'ar'); $wa_text = urlencode($is_ar ? 'مرحباً، أريد الاستفسار عن خدمة: ' . $service['title'] : 'Hello, I am interested in your service: ' . $service['title']); $page_title = htmlspecialchars($service['title']) . ' — Sheen Marketing'; $page_description = htmlspecialchars(mb_substr(strip_tags($service['short_description'] ?? $service['title']), 0, 160)); $page_keywords = htmlspecialchars($service['seo_keywords'] ?? ''); $page_featured_image_url = !empty($service['image']) ? 'https://sheen.business/' . htmlspecialchars($service['image']) : null; include_once 'includes/header.php'; ?>