true, 'data' => Photo::all($albumId, $favOnly, $search)]); exit; case 'albums': echo json_encode(['success' => true, 'data' => Album::all()]); exit; case 'quotes': echo json_encode(['success' => true, 'data' => Quote::all()]); exit; case 'milestones': echo json_encode(['success' => true, 'data' => Milestone::all()]); exit; case 'stats': echo json_encode(['success' => true, 'data' => Photo::getStats()]); exit; case 'like_photo': $id = (int)($_GET['id'] ?? 0); $likes = Photo::incrementLike($id); echo json_encode(['success' => true, 'likes' => $likes]); exit; case 'toggle_fav': $id = (int)($_GET['id'] ?? 0); Photo::toggleFavorite($id); echo json_encode(['success' => true]); exit; case 'delete_photo': $id = (int)($_GET['id'] ?? 0); Photo::delete($id); echo json_encode(['success' => true]); exit; case 'delete_album': $id = (int)($_GET['id'] ?? 0); Album::delete($id); echo json_encode(['success' => true]); exit; case 'delete_quote': $id = (int)($_GET['id'] ?? 0); Quote::delete($id); echo json_encode(['success' => true]); exit; case 'delete_milestone': $id = (int)($_GET['id'] ?? 0); Milestone::delete($id); echo json_encode(['success' => true]); exit; case 'upload_photo': if ($_SERVER['REQUEST_METHOD'] !== 'POST') { throw new Exception('متد نامعتبر است'); } if (empty($_FILES['photo']) || $_FILES['photo']['error'] !== UPLOAD_ERR_OK) { throw new Exception('لطفاً یک فایل تصویر معتبر انتخاب کنید'); } $file = $_FILES['photo']; $allowed = ['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'image/svg+xml']; $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $file['tmp_name']); finfo_close($finfo); if (!in_array($mime, $allowed)) { throw new Exception('فرمت فایل پشتیبانی نمی‌شود (فقط JPG، PNG، WEBP، GIF)'); } $ext = pathinfo($file['name'], PATHINFO_EXTENSION); if (!$ext) $ext = 'jpg'; $filename = 'photo_' . time() . '_' . bin2hex(random_bytes(4)) . '.' . $ext; $target = __DIR__ . '/uploads/' . $filename; if (!move_uploaded_file($file['tmp_name'], $target)) { throw new Exception('خطا در انتقال فایل ذخیره‌سازی'); } $albumId = (int)($_POST['album_id'] ?? 1); $title = trim($_POST['title'] ?? 'خاطره جدید'); $caption = trim($_POST['caption'] ?? ''); $ageTag = trim($_POST['age_tag'] ?? '۳ سالگی'); $photoDate = $_POST['photo_date'] ?? date('Y-m-d'); $photoId = Photo::create($albumId, $title, 'uploads/' . $filename, $caption, $ageTag, $photoDate); echo json_encode(['success' => true, 'photo_id' => $photoId]); exit; case 'create_album': $title = trim($_POST['title'] ?? ''); if (!$title) throw new Exception('عنوان آلبوم الزامی است'); $description = trim($_POST['description'] ?? ''); $icon = trim($_POST['icon'] ?? '🎈'); $color = trim($_POST['color'] ?? '#3b82f6'); $albumId = Album::create($title, $description, $icon, $color); echo json_encode(['success' => true, 'album_id' => $albumId]); exit; case 'create_quote': $quote = trim($_POST['quote'] ?? ''); if (!$quote) throw new Exception('متن جمله الزامی است'); $ageTag = trim($_POST['age_tag'] ?? '۳ سالگی'); $context = trim($_POST['context'] ?? ''); $saidDate = $_POST['said_date'] ?? date('Y-m-d'); $id = Quote::create($quote, $ageTag, $context, $saidDate); echo json_encode(['success' => true, 'quote_id' => $id]); exit; case 'create_milestone': $title = trim($_POST['title'] ?? ''); if (!$title) throw new Exception('عنوان دستاورد الزامی است'); $description = trim($_POST['description'] ?? ''); $ageTag = trim($_POST['age_tag'] ?? '۳ سالگی'); $icon = trim($_POST['icon'] ?? '🌟'); $milestoneDate = $_POST['milestone_date'] ?? date('Y-m-d'); $id = Milestone::create($title, $description, $ageTag, $icon, $milestoneDate); echo json_encode(['success' => true, 'milestone_id' => $id]); exit; default: echo json_encode(['success' => false, 'error' => 'مسیر یافت نشد']); exit; } } catch (Throwable $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); exit; } } // Initial Data for HTML Render $albums = Album::all(); $stats = Photo::getStats(); ?> آلبوم خاطرات حامد کوچولو 🎈 پسر ۳ ساله
🎈
🧸
🚗
🎨
👶

آلبوم خاطرات حامد کوچولو 🎈

گنجینه عکس‌ها، خنده‌های شیرین، اولین حرف‌ها و لحظات ناب رشد پسر ۳ ساله ما 💖

🎂 ۳ سال و ۲ ماهه (متولد تابستان ۱۴۰۲)
📸 عکس شیرین
📂 آلبوم موضوعی
💬 جمله بامزه
🌟 دستاورد رشد