diff --git a/admin.php b/admin.php index 02b4749..66476a8 100644 --- a/admin.php +++ b/admin.php @@ -1,6 +1,8 @@ prepare("UPDATE landing_settings SET value_en = :en, value_ar = :ar WHERE setting_key = :key"); + // Save text settings + $stmt = $pdo->prepare("INSERT INTO landing_settings (setting_key, value_en, value_ar) VALUES (:key, :en, :ar) ON DUPLICATE KEY UPDATE value_en = :en, value_ar = :ar"); foreach ($settings as $key => $values) { $stmt->execute([ 'key' => $key, @@ -16,6 +17,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' ]); } + // Save image settings + $upload_dir = __DIR__ . '/assets/images/uploads/'; + if (!is_dir($upload_dir)) { + mkdir($upload_dir, 0775, true); + } + + $sections = ['hero', 'courses', 'subjects', 'flow', 'plans']; + foreach ($sections as $sec) { + if (isset($_FILES['images']['error'][$sec]) && $_FILES['images']['error'][$sec] === UPLOAD_ERR_OK) { + $filename = time() . '_' . basename($_FILES['images']['name'][$sec]); + $target_file = $upload_dir . $filename; + if (move_uploaded_file($_FILES['images']['tmp_name'][$sec], $target_file)) { + $picture = 'assets/images/uploads/' . $filename; + $stmt->execute([ + 'key' => $sec . '_image', + 'en' => $picture, + 'ar' => $picture + ]); + } + } + } + header('Location: ' . app_url('admin.php', ['page' => 'landing', 'saved' => 1])); exit; } @@ -28,18 +51,43 @@ foreach ($all_settings as $row) { $settings[$row['setting_key']] = $row; } -$fields = [ - 'hero_eyebrow' => ['label' => 'Hero Eyebrow / النص الصغير في البداية', 'type' => 'text'], - 'hero_title' => ['label' => 'Hero Title / العنوان الرئيسي', 'type' => 'textarea'], - 'hero_desc' => ['label' => 'Hero Description / الوصف', 'type' => 'textarea'], - 'courses_eyebrow' => ['label' => 'Courses Eyebrow / نص قسم الدورات', 'type' => 'text'], - 'courses_title' => ['label' => 'Courses Title / عنوان قسم الدورات', 'type' => 'textarea'], - 'subjects_eyebrow' => ['label' => 'Subjects Eyebrow / نص قسم المواد', 'type' => 'text'], - 'subjects_title' => ['label' => 'Subjects Title / عنوان قسم المواد', 'type' => 'textarea'], - 'flow_eyebrow' => ['label' => 'Delivery Flow Eyebrow / نص قسم مسار التسليم', 'type' => 'text'], - 'flow_title' => ['label' => 'Delivery Flow Title / عنوان قسم مسار التسليم', 'type' => 'textarea'], - 'plans_eyebrow' => ['label' => 'Plans Eyebrow / نص قسم الخطط', 'type' => 'text'], - 'plans_title' => ['label' => 'Plans Title / عنوان قسم الخطط', 'type' => 'textarea'] +$sections = [ + 'hero' => [ + 'label' => 'Hero Section / القسم الأول', + 'fields' => [ + 'eyebrow' => ['label' => 'Eyebrow / النص الصغير', 'type' => 'text'], + 'title' => ['label' => 'Title / العنوان الرئيسي', 'type' => 'textarea'], + 'desc' => ['label' => 'Description / الوصف', 'type' => 'textarea'], + ] + ], + 'courses' => [ + 'label' => 'Courses Section / قسم الدورات', + 'fields' => [ + 'eyebrow' => ['label' => 'Eyebrow / النص الصغير', 'type' => 'text'], + 'title' => ['label' => 'Title / العنوان الرئيسي', 'type' => 'textarea'], + ] + ], + 'subjects' => [ + 'label' => 'Subjects Section / قسم المواد', + 'fields' => [ + 'eyebrow' => ['label' => 'Eyebrow / النص الصغير', 'type' => 'text'], + 'title' => ['label' => 'Title / العنوان الرئيسي', 'type' => 'textarea'], + ] + ], + 'flow' => [ + 'label' => 'Delivery Flow Section / قسم مسار التسليم', + 'fields' => [ + 'eyebrow' => ['label' => 'Eyebrow / النص الصغير', 'type' => 'text'], + 'title' => ['label' => 'Title / العنوان الرئيسي', 'type' => 'textarea'], + ] + ], + 'plans' => [ + 'label' => 'Plans Section / قسم الخطط', + 'fields' => [ + 'eyebrow' => ['label' => 'Eyebrow / النص الصغير', 'type' => 'text'], + 'title' => ['label' => 'Title / العنوان الرئيسي', 'type' => 'textarea'], + ] + ] ]; ?> @@ -48,7 +96,7 @@ $fields = [
= h(t('Customize the content of the landing page in English and Arabic.', 'تخصيص محتوى الصفحة الرئيسية باللغتين الإنجليزية والعربية.')) ?>
+= h(t('Customize the content of the landing page in English and Arabic. Grouped by sections.', 'تخصيص محتوى الصفحة الرئيسية باللغتين الإنجليزية والعربية. مجمعة حسب الأقسام.')) ?>
= h(t('Students compare monthly or yearly plans and pick the right access model.', 'يقارن الطلاب بين الخطط الشهرية والسنوية ويختارون نموذج الوصول المناسب.')) ?>
= h(t('The checkout form records student identity, language preference, and WhatsApp opt-in.', 'يسجل نموذج الدفع هوية الطالب وتفضيل اللغة وخيار الاشتراك في واتساب.')) ?>
You requested a password reset. Click the link below to reset it:
Link expires in 1 hour.
"; + + MailService::sendMail($email, "Password Reset", $htmlBody); + } + $success = t('If that email is in our system, you will receive a password reset link shortly.', 'إذا كان البريد الإلكتروني مسجلاً لدينا، ستتلقى رابطاً لإعادة تعيين كلمة المرور قريباً.'); + } + } elseif ($action === 'reset' && $token) { + $password = $_POST['password'] ?? ''; + $password_confirm = $_POST['password_confirm'] ?? ''; + + $stmt = db()->prepare("SELECT id FROM users WHERE reset_token = ? AND reset_expires > NOW()"); + $stmt->execute([$token]); + $user = $stmt->fetch(); + + if (!$user) { + $error = t('Invalid or expired token.', 'رمز غير صالح أو منتهي الصلاحية.'); + } elseif ($password !== $password_confirm) { + $error = t('Passwords do not match.', 'كلمتا المرور غير متطابقتين.'); + } else { + $hash = password_hash($password, PASSWORD_DEFAULT); + $update = db()->prepare("UPDATE users SET password = ?, reset_token = NULL, reset_expires = NULL WHERE id = ?"); + $update->execute([$hash, $user['id']]); + $success = t('Password updated successfully. You can now log in.', 'تم تحديث كلمة المرور بنجاح. يمكنك الآن تسجيل الدخول.'); + $action = 'done'; + } + } +} + +render_head(t('Reset Password', 'إعادة تعيين كلمة المرور')); +render_nav('login.php'); +?> += h(t('Enter your email to receive a reset link.', 'أدخل بريدك الإلكتروني لتلقي رابط إعادة التعيين.')) ?>
+ +