Vitalik 1 月之前
父節點
當前提交
41d49e017e

+ 19 - 0
bin/migrate.php

@@ -215,6 +215,25 @@ try {
     $db->execute($slotsProviderIndexSQL);
     echo "✓ Slots table indexes checked/created\n";
     
+    // Migration: Create authors table
+    $authorsTableSQL = "
+        CREATE TABLE IF NOT EXISTS authors (
+        id INTEGER PRIMARY KEY AUTOINCREMENT,
+        name VARCHAR(255) NOT NULL,
+        image VARCHAR(255) NULL,
+        description TEXT NULL,
+        social_links JSON NULL,
+        created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+        updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
+    )";
+    $db->execute($authorsTableSQL);
+    echo "✓ Authors table checked/created\n";
+    
+    // Create index for authors
+    $authorsNameIndexSQL = "CREATE INDEX IF NOT EXISTS idx_authors_name ON authors(name)";
+    $db->execute($authorsNameIndexSQL);
+    echo "✓ Authors table index checked/created\n";
+    
     echo "Migration completed successfully!\n";
     
 } catch (Exception $e) {

+ 2 - 0
public/index.php

@@ -8,6 +8,8 @@ $page = match (true) {
   ('/admin/' === $requestUri) => 'admin/index.php',
   ('/admin/pages/' === $requestUri) => 'admin/pages.php',
   ('/admin/slots/' === $requestUri) => 'admin/slots.php',
+  ('/admin/authors/' === $requestUri) => 'admin/authors.php',
+  ('/editor/uploads/' === $requestUri) => 'upload.php',
   ('/verstka/' === $requestUri) => 'verstka.php',
   (preg_match('#^/redirect/([\w-]+)/$#', $requestUri, $matches) === 1) => 'redirect.php',
   default => '404.php',

+ 30 - 248
public/js/admin/scripts.js

@@ -3,44 +3,41 @@ document.addEventListener('DOMContentLoaded', function() {
         license_key: 'gpl',
         remove_script_host: false,
         relative_urls: false,  
-        entity_encoding: 'raw', // Записывает символы как есть
-        valid_elements: '*[*]', // Разрешает любые элементы и атрибуты
-        content_css: false,     // Отключает внешнюю CSS-стилизацию
+        entity_encoding: 'raw',
+        valid_elements: '*[*]',
+        content_css: false,
         force_br_newlines: true,
-        //force_p_newlines: true,
-        entities: '160,nbsp', // Мини
+        entities: '160,nbsp',
         remove_linebreaks: false,
-        selector: '.secondary-content', // Ваши текстовые области
-        encoding: 'UTF-8',      // Указывает кодировку 
-        plugins: 'image link media code table lists', // Подключены плагины для изображений, таблиц, списков
-        toolbar: 'undo redo | styleselect | bold italic | bullist numlist | alignleft aligncenter alignright alignjustify | outdent indent | link image media table | code', // Добавлены кнопки для списков
-        menubar: 'file edit view insert format tools table help', // Включаем меню с таблицами
-        contextmenu: 'table', // Контекстное меню для работы с таблицами
-        images_upload_url: '/admin/upload.php', // URL для загрузки изображений
-        automatic_uploads: true, // Автоматическая загрузка изображений
-        file_picker_types: 'image', // Включаем выбор файлов
-        images_reuse_filename: true, // Сохраняем оригинальное название файла
+        selector: '.secondary-content',
+        encoding: 'UTF-8',
+        plugins: 'image link media code table lists',
+        toolbar: 'undo redo | styleselect | bold italic | bullist numlist | alignleft aligncenter alignright alignjustify | outdent indent | link image media table | code',
+        menubar: 'file edit view insert format tools table help',
+        contextmenu: 'table',
+        images_upload_url: '/editor/uploads/',
+        automatic_uploads: true,
+        file_picker_types: 'image',
+        images_reuse_filename: true,
         paste_as_text: true,
         setup: function (editor) {
-            // Обработка перед сохранением
-            editor.on('SaveContent', function (e) {
-                e.content = e.content.replace(/<img([^>]*?)src=/g, '<img$1class="lazy" data-src=');
-            });
-    
-            // Обработка контента при загрузке в редактор
-            editor.on('BeforeSetContent', function (e) {
-                e.content = e.content.replace(/<img([^>]*?)src=/g, '<img$1class="lazy" data-src=');
+            editor.on('GetContent', function (e) {
+                e.content = e.content.replace(/<img([^>]*?)>/g, function(match, attrs) {
+                    if (!attrs.includes('loading=')) {
+                        return match.replace('>', ' loading="lazy">');
+                    }
+                    return match;
+                });
             });
         },
         table_default_attributes: {
-            border: '1', // Граница таблицы по умолчанию
+            border: '1',
         },
         table_default_styles: {
-            width: '100%', // Ширина таблицы по умолчанию
-            borderCollapse: 'collapse', // Границы объединяются
+            width: '100%',
+            borderCollapse: 'collapse',
         },
         file_picker_callback: function(callback, value, meta) {
-            // Если это изображение, открываем стандартный файловый выбор
             if (meta.filetype === 'image') {
                 const input = document.createElement('input');
                 input.setAttribute('type', 'file');
@@ -50,13 +47,13 @@ document.addEventListener('DOMContentLoaded', function() {
                     const formData = new FormData();
                     formData.append('file', file);
     
-                    fetch('/admin/upload.php', {
+                    fetch('/editor/uploads/', {
                         method: 'POST',
                         body: formData
                     })
                     .then(response => response.json())
                     .then(result => {
-                        callback(result.location); // URL изображения
+                        callback(result.location);
                     })
                     .catch(() => alert('Ошибка при загрузке изображения.'));
                 };
@@ -68,19 +65,15 @@ document.addEventListener('DOMContentLoaded', function() {
         table { border-collapse: collapse; width: 100%; }
         th, td { border: 1px solid #ddd; padding: 8px; }
         th { background-color: #f2f2f2; text-align: left; }
-    ` // Добавлены стили для таблиц
+    `
     });
 });
 
-
-
-// Выбор цвета-------------------------
+// Color picker functionality
 document.addEventListener('DOMContentLoaded', function () {
-    // Получаем все элементы input с классами inp-color и inp-color-text
     const colorPickers = document.querySelectorAll('.inp-color');
     const textInputs = document.querySelectorAll('.inp-color-text');
 
-    // Синхронизация inp-color -> inp-color-text
     colorPickers.forEach(colorPicker => {
         colorPicker.addEventListener('input', function () {
             const textInput = this.nextElementSibling;
@@ -90,22 +83,18 @@ document.addEventListener('DOMContentLoaded', function () {
         });
     });
 
-    // Синхронизация inp-color-text -> inp-color
     textInputs.forEach(textInput => {
         textInput.addEventListener('input', function () {
             const colorPicker = this.previousElementSibling;
             if (colorPicker && colorPicker.classList.contains('inp-color')) {
-                // Проверяем, что введенное значение является валидным цветом в формате HEX
                 if (/^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(this.value)) {
                     colorPicker.value = this.value;
                 }
             }
         });
 
-        // Проверяем и синхронизируем значение при загрузке страницы
         const colorPicker = textInput.previousElementSibling;
         if (colorPicker && colorPicker.classList.contains('inp-color')) {
-            // Проверяем, что значение в текстовом поле валидное
             if (/^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(textInput.value)) {
                 colorPicker.value = textInput.value;
             }
@@ -113,20 +102,7 @@ document.addEventListener('DOMContentLoaded', function () {
     });
 });
 
-
-// function addRepeaterItem(type) {
-//     const container = document.getElementById(`${type}-items`);
-//     const index = container.children.length;
-//     const html = `
-//         <div class="repeater-item">
-//             <input type="text" name="items[${index}][question]" placeholder="Question">
-//             <input type="text" name="items[${index}][answer]" placeholder="Answer">
-//             <button type="button" onclick="this.parentElement.remove()">Remove</button>
-//         </div>`;
-//     container.insertAdjacentHTML('beforeend', html);
-// }
-
-
+// Casino repeater functionality
 function addCasinoItem() {
     const container = document.getElementById('casinoRepeater');
     const tpl = document.getElementById('casinoTemplate').content.cloneNode(true);
@@ -196,7 +172,6 @@ document.addEventListener('DOMContentLoaded', function() {
         return div;
     }
 
-    // Accordion functionality
     function initAccordion() {
         const items = container.querySelectorAll('.casino-item');
 
@@ -208,9 +183,7 @@ document.addEventListener('DOMContentLoaded', function() {
 
             if (!header || !toggleBtn || !content) return;
 
-            // Toggle accordion
             const toggleAccordion = (e) => {
-                // Не закрывать если клик по drag handle
                 if (e.target.closest('.drag-handle')) {
                     return;
                 }
@@ -228,7 +201,6 @@ document.addEventListener('DOMContentLoaded', function() {
 
             header.addEventListener('click', toggleAccordion);
 
-            // Запрет на перетаскивание при клике на header (кроме drag-handle)
             header.addEventListener('mousedown', (e) => {
                 if (!e.target.closest('.drag-handle')) {
                     item.setAttribute('draggable', 'false');
@@ -239,13 +211,11 @@ document.addEventListener('DOMContentLoaded', function() {
                 item.setAttribute('draggable', 'true');
             });
 
-            // Drag только за handle
             dragHandle.addEventListener('mousedown', (e) => {
                 e.stopPropagation();
                 item.setAttribute('draggable', 'true');
             });
 
-            // Обновление заголовка при изменении Casino title
             const headingInput = item.querySelector('.heading');
             if (headingInput) {
                 headingInput.addEventListener('input', function() {
@@ -266,13 +236,11 @@ document.addEventListener('DOMContentLoaded', function() {
 
             const dragHandle = item.querySelector('.drag-handle');
 
-            // Drag только при клике на handle
             dragHandle.addEventListener('mousedown', function(e) {
                 item.setAttribute('draggable', 'true');
             });
 
             item.addEventListener('dragstart', function(e) {
-                // Проверяем что перетаскивание началось с drag-handle
                 if (!e.target.querySelector('.drag-handle')) {
                     e.preventDefault();
                     return;
@@ -352,17 +320,14 @@ document.addEventListener('DOMContentLoaded', function() {
         }, { offset: Number.NEGATIVE_INFINITY }).element;
     }
 
-    // Инициализация при загрузке
     initAccordion();
     initDragAndDrop();
     updateOrderNumbers();
 
-    // Слушаем событие удаления элемента
     container.addEventListener('itemRemoved', function() {
         updateOrderNumbers();
     });
 
-    // Переопределяем addCasinoItem для инициализации drag&drop на новых элементах
     window.originalAddCasinoItem = window.addCasinoItem;
     window.addCasinoItem = function() {
         if (window.originalAddCasinoItem) {
@@ -378,187 +343,4 @@ document.addEventListener('DOMContentLoaded', function() {
             updateOrderNumbers();
         }, 10);
     };
-});
-
-
-const pageSelect = document.getElementById('page-select');
-if (pageSelect) {
-    pageSelect.addEventListener('change', function () {
-        const selected = this.value;
-        const blocks = document.querySelectorAll('.page-block');
-
-        blocks.forEach(block => {
-            if (block.classList.contains(selected)) {
-                block.style.display = 'block';
-            } else {
-                block.style.display = 'none';
-            }
-        });
-    });
-}
-
-// Tab switching functionality for new admin interface
-function switchTab(tabName) {
-    // Hide all tab contents
-    const contents = document.querySelectorAll('.tab-content');
-    contents.forEach(content => content.classList.remove('active'));
-    
-    // Remove active class from all tabs
-    const tabs = document.querySelectorAll('.tab');
-    tabs.forEach(tab => tab.classList.remove('active'));
-    
-    // Show selected tab content
-    document.getElementById(tabName + '-tab').classList.add('active');
-    
-    // Add active class to clicked tab
-    event.target.classList.add('active');
-}
-
-// Repeater functionality for new admin interface
-function addRepeaterItem(type) {
-    const container = document.getElementById(`${type}-items`);
-    const index = container.children.length;
-
-    const html = `
-        <div class="repeater-item" style="margin-bottom: 15px; padding: 15px; border: 1px solid #ddd;">
-            ${type === 'menu' ? `
-                <input type="text" name="repeaters[${type}][${index}][title]" placeholder="Menu Title" style="width: 100%; margin-bottom: 10px;">
-                <input type="text" name="repeaters[${type}][${index}][anchor]" placeholder="Anchor Link (#id)" style="width: 100%; margin-bottom: 10px;">
-            ` : `
-                <input type="text" name="repeaters[${type}][${index}][question]" placeholder="Question" style="width: 100%; margin-bottom: 10px;">
-                <textarea name="repeaters[${type}][${index}][answer]" placeholder="Answer" style="width: 100%; margin-bottom: 10px;"></textarea>
-            `}
-            <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px;">Remove</button>
-        </div>`;
-    container.insertAdjacentHTML('beforeend', html);
-}
-
-function removeRepeaterItem(button) {
-    button.parentElement.remove();
-}
-
-function addCasinoItem() {
-    const container = document.getElementById('casino-items');
-    const index = container.children.length;
-
-    const html = `
-        <div class="casino-item" style="margin-bottom: 20px; padding: 15px; border: 1px solid #ddd;">
-            <h4>Casino Item #${index + 1}</h4>
-            <input type="text" name="repeaters[casino_list][${index}][heading]" placeholder="Casino Name" style="width: 100%; margin-bottom: 10px;">
-            <input type="text" name="repeaters[casino_list][${index}][text]" placeholder="Bonus Text" style="width: 100%; margin-bottom: 10px;">
-            <input type="text" name="repeaters[casino_list][${index}][button]" placeholder="Button Text" style="width: 100%; margin-bottom: 10px;">
-            <input type="file" name="casino_image_${index}" style="margin-bottom: 10px;">
-            <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px;">Remove</button>
-        </div>`;
-    container.insertAdjacentHTML('beforeend', html);
-}
-
-function addHreflangItem() {
-    const container = document.getElementById('hreflang-items');
-    const index = container.children.length;
-
-    const html = `
-        <div style="margin-bottom: 15px; padding: 15px; border: 1px solid #ddd;">
-            <div style="display: grid; grid-template-columns: 1fr 1fr auto; gap: 15px; align-items: center;">
-                <div>
-                    <label style="display: block; margin-bottom: 5px; font-weight: bold;">Hreflang</label>
-                    <input type="text" name="seo[hreflang][${index}][hreflang]" placeholder="en, es, fr, etc." style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
-                </div>
-                <div>
-                    <label style="display: block; margin-bottom: 5px; font-weight: bold;">Href URL</label>
-                    <input type="text" name="seo[hreflang][${index}][href]" placeholder="https://example.com/en/" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
-                </div>
-                <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 8px 12px; border-radius: 4px; margin-top: 25px;">Remove</button>
-            </div>
-        </div>`;
-    container.insertAdjacentHTML('beforeend', html);
-}
-
-// Load existing data for new admin interface
-function loadExistingData() {
-    const menuItems = window.menuItems || [];
-    const faqItems = window.faqItems || [];
-    const casinoItems = window.casinoItems || [];
-    const hreflangItems = window.hreflangItems || [];
-
-    // Load existing menu items
-    menuItems.forEach((item, index) => {
-        if (item && item.title) {
-            const container = document.getElementById('menu-items');
-            if (container) {
-                const html = `
-                    <div class="repeater-item" style="margin-bottom: 15px; padding: 15px; border: 1px solid #ddd;">
-                        <input type="text" name="repeaters[menu][${index}][title]" value="${item.title}" placeholder="Menu Title" style="width: 100%; margin-bottom: 10px;">
-                        <input type="text" name="repeaters[menu][${index}][anchor]" value="${item.anchor || ''}" placeholder="Anchor Link (#id)" style="width: 100%; margin-bottom: 10px;">
-                        <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px;">Remove</button>
-                    </div>`;
-                container.insertAdjacentHTML('beforeend', html);
-            }
-        }
-    });
-
-    // Load existing FAQ items
-    faqItems.forEach((item, index) => {
-        if (item && item.question) {
-            const container = document.getElementById('faq-items');
-            if (container) {
-                const html = `
-                    <div class="repeater-item" style="margin-bottom: 15px; padding: 15px; border: 1px solid #ddd;">
-                        <input type="text" name="repeaters[faq][${index}][question]" value="${item.question}" placeholder="Question" style="width: 100%; margin-bottom: 10px;">
-                        <textarea name="repeaters[faq][${index}][answer]" placeholder="Answer" style="width: 100%; margin-bottom: 10px;">${item.answer || ''}</textarea>
-                        <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px;">Remove</button>
-                    </div>`;
-                container.insertAdjacentHTML('beforeend', html);
-            }
-        }
-    });
-
-    // Load existing casino items
-    casinoItems.forEach((item, index) => {
-        if (item && item.heading) {
-            const container = document.getElementById('casino-items');
-            if (container) {
-                const html = `
-                    <div class="casino-item" style="margin-bottom: 20px; padding: 15px; border: 1px solid #ddd;">
-                        <h4>${item.heading}</h4>
-                        <input type="text" name="repeaters[casino_list][${index}][heading]" value="${item.heading}" placeholder="Casino Name" style="width: 100%; margin-bottom: 10px;">
-                        <input type="text" name="repeaters[casino_list][${index}][text]" value="${item.text || ''}" placeholder="Bonus Text" style="width: 100%; margin-bottom: 10px;">
-                        <input type="text" name="repeaters[casino_list][${index}][button]" value="${item.button || ''}" placeholder="Button Text" style="width: 100%; margin-bottom: 10px;">
-                        <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px;">Remove</button>
-                    </div>`;
-                container.insertAdjacentHTML('beforeend', html);
-            }
-        }
-    });
-
-    // Load existing hreflang items
-    hreflangItems.forEach((item, index) => {
-        if (item && (item.hreflang || item.href)) {
-            const container = document.getElementById('hreflang-items');
-            if (container) {
-                const html = `
-                    <div style="margin-bottom: 15px; padding: 15px; border: 1px solid #ddd;">
-                        <div style="display: grid; grid-template-columns: 1fr 1fr auto; gap: 15px; align-items: center;">
-                            <div>
-                                <label style="display: block; margin-bottom: 5px; font-weight: bold;">Hreflang</label>
-                                <input type="text" name="seo[hreflang][${index}][hreflang]" value="${item.hreflang || ''}" placeholder="en, es, fr, etc." style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
-                            </div>
-                            <div>
-                                <label style="display: block; margin-bottom: 5px; font-weight: bold;">Href URL</label>
-                                <input type="text" name="seo[hreflang][${index}][href]" value="${item.href || ''}" placeholder="https://example.com/en/" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
-                            </div>
-                            <button type="button" onclick="removeRepeaterItem(this)" style="background: #dc3545; color: white; border: none; padding: 8px 12px; border-radius: 4px; margin-top: 25px;">Remove</button>
-                        </div>
-                    </div>`;
-                container.insertAdjacentHTML('beforeend', html);
-            }
-        }
-    });
-}
-
-// Initialize on DOM ready (for new admin interface)
-if (document.readyState === 'loading') {
-    document.addEventListener('DOMContentLoaded', loadExistingData);
-} else {
-    loadExistingData();
-}
+});

二進制
public/media/3861988_bf23eec6.jpg


二進制
public/media/Capture-2025-05-13-130007.png


二進制
public/media/Capture-2025-06-26-151206.png


二進制
public/media/Velobet.png


二進制
public/media/backgroun-calc-baner.jpg


+ 183 - 0
resources/view/admin/authors/form.php

@@ -0,0 +1,183 @@
+<?php
+ob_start();
+?>
+
+<div class="min-h-screen bg-gray-50 py-6" x-data="authorForm">
+    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
+        <!-- Header -->
+        <div class="mb-8">
+            <div class="md:flex md:items-center md:justify-between">
+                <div class="flex-1 min-w-0">
+                    <h2 class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate">
+                        <?= $action === 'create' ? 'Add New Author' : 'Edit Author' ?>
+                    </h2>
+                    <p class="mt-1 text-sm text-gray-500">
+                        <?= $action === 'create' ? 'Create a new author profile' : 'Update author information' ?>
+                    </p>
+                </div>
+            </div>
+        </div>
+
+        <!-- Success/Error Messages -->
+        <?php if (isset($success)): ?>
+            <div class="mb-6 bg-green-50 border border-green-200 rounded-md p-4">
+                <div class="flex">
+                    <div class="flex-shrink-0">
+                        <svg class="h-5 w-5 text-green-400" viewBox="0 0 20 20" fill="currentColor">
+                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
+                        </svg>
+                    </div>
+                    <div class="ml-3">
+                        <p class="text-sm font-medium text-green-800"><?= htmlspecialchars($success) ?></p>
+                    </div>
+                </div>
+            </div>
+        <?php endif; ?>
+
+        <?php if (isset($error)): ?>
+            <div class="mb-6 bg-red-50 border border-red-200 rounded-md p-4">
+                <div class="flex">
+                    <div class="flex-shrink-0">
+                        <svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
+                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
+                        </svg>
+                    </div>
+                    <div class="ml-3">
+                        <p class="text-sm font-medium text-red-800"><?= htmlspecialchars($error) ?></p>
+                    </div>
+                </div>
+            </div>
+        <?php endif; ?>
+
+        <!-- Form -->
+        <form method="POST" enctype="multipart/form-data" class="space-y-6">
+            <input type="hidden" name="action" value="<?= $action ?>">
+            <?php if ($action === 'edit'): ?>
+                <input type="hidden" name="id" value="<?= $author['id'] ?>">
+            <?php endif; ?>
+
+            <div class="bg-white shadow rounded-lg">
+                <div class="px-6 py-4 border-b border-gray-200">
+                    <h3 class="text-lg font-medium text-gray-900">Author Information</h3>
+                    <p class="mt-1 text-sm text-gray-500">Basic information about the author.</p>
+                </div>
+
+                <div class="px-6 py-4 space-y-6">
+                    <!-- Author Name -->
+                    <div>
+                        <label for="name" class="block text-sm font-medium text-gray-700 mb-2">Author Name *</label>
+                        <input type="text" name="name" id="name" required
+                               value="<?= htmlspecialchars($author['name'] ?? '') ?>" 
+                               class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
+                               placeholder="Enter author name">
+                    </div>
+
+                    <!-- Image Upload -->
+                    <div>
+                        <label for="image" class="block text-sm font-medium text-gray-700 mb-2">Author Photo</label>
+                        <div class="flex items-center space-x-4">
+                            <?php if (!empty($author['image'])): ?>
+                                <div class="flex-shrink-0">
+                                    <img src="/<?= htmlspecialchars($author['image']) ?>" alt="Current image" class="h-20 w-20 rounded-full object-cover border border-gray-300">
+                                </div>
+                            <?php endif; ?>
+                            <div class="flex-1">
+                                <input type="file" name="image_upload" id="image_upload" accept="image/*"
+                                       class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
+                                <input type="hidden" name="current_image" value="<?= htmlspecialchars($author['image'] ?? '') ?>">
+                                <p class="mt-1 text-xs text-gray-500">Upload a photo for the author profile</p>
+                            </div>
+                        </div>
+                    </div>
+
+                    <!-- Description -->
+                    <div>
+                        <label for="description" class="block text-sm font-medium text-gray-700 mb-2">Description</label>
+                        <textarea name="description" id="description" rows="4"
+                                  class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
+                                  placeholder="Author bio and description"><?= htmlspecialchars($author['description'] ?? '') ?></textarea>
+                    </div>
+                </div>
+            </div>
+
+            <!-- Social Media Links -->
+            <div class="bg-white shadow rounded-lg">
+                <div class="px-6 py-4 border-b border-gray-200">
+                    <h3 class="text-lg font-medium text-gray-900">Social Media Links</h3>
+                    <p class="mt-1 text-sm text-gray-500">Add social media profiles for this author.</p>
+                </div>
+
+                <div class="px-6 py-4">
+                    <div class="space-y-4">
+                        <template x-for="(link, index) in socialLinks" :key="index">
+                            <div class="flex items-center space-x-4 p-4 border border-gray-200 rounded-lg">
+                                <div class="flex-1">
+                                    <label class="block text-sm font-medium text-gray-700 mb-1">Platform</label>
+                                    <input type="text" :name="'social_links[' + index + '][platform]'" x-model="link.platform"
+                                           class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
+                                           placeholder="e.g. Twitter, Facebook, LinkedIn">
+                                </div>
+                                <div class="flex-1">
+                                    <label class="block text-sm font-medium text-gray-700 mb-1">URL</label>
+                                    <input type="url" :name="'social_links[' + index + '][url]'" x-model="link.url"
+                                           class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
+                                           placeholder="https://...">
+                                </div>
+                                <button type="button" @click="removeSocialLink(index)"
+                                        class="mt-6 px-3 py-2 text-sm font-medium text-red-600 hover:text-red-800 border border-red-300 rounded-md hover:bg-red-50">
+                                    Remove
+                                </button>
+                            </div>
+                        </template>
+
+                        <button type="button" @click="addSocialLink()"
+                                class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
+                            <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                                <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
+                            </svg>
+                            Add Social Link
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <!-- Form Actions -->
+            <div class="flex justify-between pt-6 border-t border-gray-200">
+                <a href="/admin/authors/" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
+                    <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                        <path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0L2.586 11H9a1 1 0 010 2H2.586l3.707 3.707a1 1 0 01-1.414 1.414l-5.414-5.414a1 1 0 010-1.414L4.879 6.879a1 1 0 011.414 1.414L2.586 11H9a1 1 0 010 2H2.586l3.707 3.707z" clip-rule="evenodd"/>
+                    </svg>
+                    Back to List
+                </a>
+
+                <button type="submit" class="inline-flex items-center px-6 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
+                    <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                        <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
+                    </svg>
+                    <?= $action === 'create' ? 'Create Author' : 'Update Author' ?>
+                </button>
+            </div>
+        </form>
+    </div>
+</div>
+
+<script>
+document.addEventListener('alpine:init', () => {
+    Alpine.data('authorForm', () => ({
+        socialLinks: <?= json_encode($author['social_links'] ?? [['platform' => '', 'url' => '']]) ?>,
+        
+        addSocialLink() {
+            this.socialLinks.push({ platform: '', url: '' });
+        },
+        
+        removeSocialLink(index) {
+            this.socialLinks.splice(index, 1);
+        }
+    }));
+});
+</script>
+
+<?php
+$content = ob_get_clean();
+include __DIR__ . '/../partials/layout.php';
+?>

+ 171 - 0
resources/view/admin/authors/list.php

@@ -0,0 +1,171 @@
+<?php
+ob_start();
+?>
+
+<div class="min-h-screen bg-gray-50 py-6">
+    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
+        <!-- Header -->
+        <div class="md:flex md:items-center md:justify-between mb-8">
+            <div class="flex-1 min-w-0">
+                <h2 class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate">
+                    Author Management
+                </h2>
+                <p class="mt-1 text-sm text-gray-500">
+                    Manage authors and their social media profiles
+                </p>
+            </div>
+            <div class="mt-4 flex md:mt-0 md:ml-4">
+                <a href="/admin/authors/?action=create" 
+                   class="ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
+                    <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                        <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
+                    </svg>
+                    Add New Author
+                </a>
+            </div>
+        </div>
+
+        <!-- Success/Error Messages -->
+        <?php if (isset($success)): ?>
+            <div class="mb-6 bg-green-50 border border-green-200 rounded-md p-4">
+                <div class="flex">
+                    <div class="flex-shrink-0">
+                        <svg class="h-5 w-5 text-green-400" viewBox="0 0 20 20" fill="currentColor">
+                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
+                        </svg>
+                    </div>
+                    <div class="ml-3">
+                        <p class="text-sm font-medium text-green-800"><?= htmlspecialchars($success) ?></p>
+                    </div>
+                </div>
+            </div>
+        <?php endif; ?>
+
+        <?php if (isset($error)): ?>
+            <div class="mb-6 bg-red-50 border border-red-200 rounded-md p-4">
+                <div class="flex">
+                    <div class="flex-shrink-0">
+                        <svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
+                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
+                        </svg>
+                    </div>
+                    <div class="ml-3">
+                        <p class="text-sm font-medium text-red-800"><?= htmlspecialchars($error) ?></p>
+                    </div>
+                </div>
+            </div>
+        <?php endif; ?>
+
+        <!-- Authors Table -->
+        <div class="bg-white shadow overflow-hidden sm:rounded-md">
+            <div class="px-4 py-5 sm:px-6 border-b border-gray-200">
+                <h3 class="text-lg leading-6 font-medium text-gray-900">All Authors</h3>
+                <p class="mt-1 max-w-2xl text-sm text-gray-500">A list of all authors in the system.</p>
+            </div>
+            
+            <?php if (empty($authors)): ?>
+                <div class="text-center py-12">
+                    <svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
+                        <path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
+                    </svg>
+                    <h3 class="mt-2 text-sm font-medium text-gray-900">No authors</h3>
+                    <p class="mt-1 text-sm text-gray-500">Get started by creating a new author.</p>
+                    <div class="mt-6">
+                        <a href="/admin/authors/?action=create" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
+                            <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                                <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
+                            </svg>
+                            Add Author
+                        </a>
+                    </div>
+                </div>
+            <?php else: ?>
+                <div class="overflow-x-auto">
+                    <table class="min-w-full divide-y divide-gray-200">
+                        <thead class="bg-gray-50">
+                            <tr>
+                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
+                                    Author
+                                </th>
+                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
+                                    Description
+                                </th>
+                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
+                                    Social Links
+                                </th>
+                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
+                                    Created
+                                </th>
+                                <th scope="col" class="relative px-6 py-3">
+                                    <span class="sr-only">Actions</span>
+                                </th>
+                            </tr>
+                        </thead>
+                        <tbody class="bg-white divide-y divide-gray-200">
+                            <?php foreach ($authors as $author): ?>
+                                <tr class="hover:bg-gray-50">
+                                    <td class="px-6 py-4 whitespace-nowrap">
+                                        <div class="flex items-center">
+                                            <?php if (!empty($author['image'])): ?>
+                                                <div class="flex-shrink-0 h-10 w-10">
+                                                    <img class="h-10 w-10 rounded-full object-cover" src="/<?= htmlspecialchars($author['image']) ?>" alt="<?= htmlspecialchars($author['name']) ?>">
+                                                </div>
+                                            <?php else: ?>
+                                                <div class="flex-shrink-0 h-10 w-10 bg-gray-300 rounded-full flex items-center justify-center">
+                                                    <svg class="h-6 w-6 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
+                                                    </svg>
+                                                </div>
+                                            <?php endif; ?>
+                                            <div class="ml-4">
+                                                <div class="text-sm font-medium text-gray-900"><?= htmlspecialchars($author['name']) ?></div>
+                                            </div>
+                                        </div>
+                                    </td>
+                                    <td class="px-6 py-4">
+                                        <div class="text-sm text-gray-900 max-w-xs truncate">
+                                            <?= htmlspecialchars($author['description'] ?? 'No description') ?>
+                                        </div>
+                                    </td>
+                                    <td class="px-6 py-4 whitespace-nowrap">
+                                        <div class="flex space-x-2">
+                                            <?php if (!empty($author['social_links'])): ?>
+                                                <?php foreach ($author['social_links'] as $link): ?>
+                                                    <a href="<?= htmlspecialchars($link['url']) ?>" target="_blank" 
+                                                       class="text-blue-600 hover:text-blue-800 text-sm">
+                                                        <?= htmlspecialchars($link['platform']) ?>
+                                                    </a>
+                                                <?php endforeach; ?>
+                                            <?php else: ?>
+                                                <span class="text-gray-400 text-sm">No links</span>
+                                            <?php endif; ?>
+                                        </div>
+                                    </td>
+                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+                                        <?= date('M j, Y', strtotime($author['created_at'])) ?>
+                                    </td>
+                                    <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
+                                        <div class="flex items-center justify-end space-x-2">
+                                            <a href="/admin/authors/?action=edit&id=<?= $author['id'] ?>" 
+                                               class="text-blue-600 hover:text-blue-900 font-medium">Edit</a>
+                                            <form method="POST" class="inline" onsubmit="return confirm('Are you sure you want to delete this author?');">
+                                                <input type="hidden" name="action" value="delete">
+                                                <input type="hidden" name="id" value="<?= $author['id'] ?>">
+                                                <button type="submit" class="text-red-600 hover:text-red-900 font-medium ml-2">Delete</button>
+                                            </form>
+                                        </div>
+                                    </td>
+                                </tr>
+                            <?php endforeach; ?>
+                        </tbody>
+                    </table>
+                </div>
+            <?php endif; ?>
+        </div>
+    </div>
+</div>
+
+<?php
+$content = ob_get_clean();
+include __DIR__ . '/../partials/layout.php';
+?>

+ 8 - 1
resources/view/admin/partials/sidebar.php

@@ -8,9 +8,10 @@
         <div class="px-4 space-y-1">
 <?php
 $currentUri = $_SERVER['REQUEST_URI'];
-$isIndex = (strpos($currentUri, '/admin/pages/') === false && strpos($currentUri, '/admin/slots/') === false && strpos($currentUri, '/admin/') !== false);
+$isIndex = (strpos($currentUri, '/admin/pages/') === false && strpos($currentUri, '/admin/slots/') === false && strpos($currentUri, '/admin/authors/') === false && strpos($currentUri, '/admin/') !== false);
 $isPages = (strpos($currentUri, '/admin/pages/') !== false);
 $isSlots = (strpos($currentUri, '/admin/slots/') !== false);
+$isAuthors = (strpos($currentUri, '/admin/authors/') !== false);
 ?>
             <a href="/admin/" class="<?= $isIndex ? 'group flex items-center px-3 py-2 text-sm font-medium rounded-lg text-blue-700 bg-blue-50 border-r-4 border-blue-700' : 'group flex items-center px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-50 transition-colors' ?>">
                 <svg class="mr-3 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
@@ -30,6 +31,12 @@ $isSlots = (strpos($currentUri, '/admin/slots/') !== false);
                 </svg>
                 Casino Slots
             </a>
+            <a href="/admin/authors/" class="<?= $isAuthors ? 'group flex items-center px-3 py-2 text-sm font-medium rounded-lg text-blue-700 bg-blue-50 border-r-4 border-blue-700' : 'group flex items-center px-3 py-2 text-sm font-medium rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-50 transition-colors' ?>">
+                <svg class="mr-3 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
+                    <path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd"/>
+                </svg>
+                Authors
+            </a>
         </div>
     </nav>
 </div>

+ 100 - 0
src/Models/Author.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Models;
+
+class Author
+{
+    private $db;
+
+    public function __construct()
+    {
+        $this->db = \App\Database::getInstance();
+    }
+
+    public function getAll()
+    {
+        $authors = $this->db->fetchAll("SELECT * FROM authors ORDER BY created_at DESC");
+        
+        foreach ($authors as &$author) {
+            if (!empty($author['social_links'])) {
+                $author['social_links'] = json_decode($author['social_links'], true);
+            }
+        }
+        
+        return $authors;
+    }
+
+    public function getById($id)
+    {
+        $author = $this->db->fetchOne("SELECT * FROM authors WHERE id = ?", [$id]);
+        
+        if ($author && !empty($author['social_links'])) {
+            $author['social_links'] = json_decode($author['social_links'], true);
+        }
+        
+        return $author;
+    }
+
+    public function create($data)
+    {
+        $socialLinks = '';
+        if (isset($data['social_links']) && is_array($data['social_links'])) {
+            $socialLinks = json_encode($data['social_links']);
+        }
+
+        $this->db->execute("
+            INSERT INTO authors (name, image, description, social_links, created_at) 
+            VALUES (?, ?, ?, ?, datetime('now'))
+        ", [
+            $data['name'] ?? '',
+            $data['image'] ?? '',
+            $data['description'] ?? '',
+            $socialLinks
+        ]);
+
+        return $this->db->lastInsertId();
+    }
+
+    public function update($id, $data)
+    {
+        $socialLinks = '';
+        if (isset($data['social_links']) && is_array($data['social_links'])) {
+            $socialLinks = json_encode($data['social_links']);
+        }
+
+        return $this->db->execute("
+            UPDATE authors 
+            SET name = ?, image = ?, description = ?, social_links = ?, updated_at = datetime('now')
+            WHERE id = ?
+        ", [
+            $data['name'] ?? '',
+            $data['image'] ?? '',
+            $data['description'] ?? '',
+            $socialLinks,
+            $id
+        ]);
+    }
+
+    public function delete($id)
+    {
+        return $this->db->execute("DELETE FROM authors WHERE id = ?", [$id]);
+    }
+
+    public function search($query)
+    {
+        $searchTerm = '%' . $query . '%';
+        $authors = $this->db->fetchAll("
+            SELECT * FROM authors 
+            WHERE name LIKE ? OR description LIKE ?
+            ORDER BY created_at DESC
+        ", [$searchTerm, $searchTerm]);
+        
+        foreach ($authors as &$author) {
+            if (!empty($author['social_links'])) {
+                $author['social_links'] = json_decode($author['social_links'], true);
+            }
+        }
+        
+        return $authors;
+    }
+}

+ 112 - 0
src/Pages/admin/authors.php

@@ -0,0 +1,112 @@
+<?php
+
+use App\Models\Author;
+
+$authorModel = new Author();
+$action = $_GET['action'] ?? 'list';
+$id = $_GET['id'] ?? null;
+
+// Handle form submissions
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+    $data = $_POST;
+    
+    // Handle image upload
+    if (!empty($_FILES['image_upload']['name'])) {
+        $uploadedImage = uploadImage($_FILES['image_upload']);
+        if ($uploadedImage) {
+            $data['image'] = $uploadedImage;
+        }
+    } else {
+        // Keep current image if no new upload
+        $data['image'] = $data['current_image'] ?? '';
+    }
+    
+    // Handle social links
+    if (isset($data['social_links']) && is_array($data['social_links'])) {
+        // Filter out empty social links
+        $socialLinks = array_filter($data['social_links'], function($link) {
+            return !empty($link['platform']) && !empty($link['url']);
+        });
+        $data['social_links'] = array_values($socialLinks); // Reindex array
+    }
+    
+    // Get action from form data
+    $formAction = $data['action'] ?? $action;
+    
+    try {
+        switch ($formAction) {
+            case 'create':
+            case 'edit':
+                if ($formAction === 'create') {
+                    $authorId = $authorModel->create($data);
+                    $success = "Author created successfully!";
+                } else {
+                    $authorModel->update($id, $data);
+                    $authorId = $id;
+                    $success = "Author updated successfully!";
+                }
+                header("Location: /admin/authors/?action=edit&id=" . $authorId);
+                exit;
+                break;
+                
+            case 'delete':
+                if ($id) {
+                    $authorModel->delete($id);
+                    $success = "Author deleted successfully!";
+                    $action = 'list';
+                }
+                break;
+        }
+    } catch (Exception $e) {
+        $error = "Error: " . $e->getMessage();
+    }
+}
+
+// Get data for different actions
+switch ($action) {
+    case 'create':
+    case 'new':
+        $author = [
+            'name' => '',
+            'image' => '',
+            'description' => '',
+            'social_links' => []
+        ];
+        $action = 'create';
+        break;
+        
+    case 'edit':
+        if (!$id) {
+            $action = 'list';
+            break;
+        }
+        
+        $author = $authorModel->getById($id);
+        if (!$author) {
+            $error = "Author not found!";
+            $action = 'list';
+            break;
+        }
+        break;
+        
+    case 'list':
+    default:
+        $authors = $authorModel->getAll();
+        $action = 'list';
+        break;
+}
+
+// Determine which template to use
+$template = match($action) {
+    'list' => 'admin/authors/list.php',
+    'create', 'edit' => 'admin/authors/form.php',
+    default => 'admin/authors/list.php'
+};
+
+return ViewRender($template, [
+    'action' => $action,
+    'authors' => $authors ?? [],
+    'author' => $author ?? null,
+    'success' => $success ?? null,
+    'error' => $error ?? null
+]);

+ 22 - 0
src/Pages/upload.php

@@ -0,0 +1,22 @@
+<?php
+
+header('Content-Type: application/json');
+
+if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+    http_response_code(405);
+    return json_encode(['error' => 'Method not allowed']);
+}
+
+if (!isset($_FILES['file'])) {
+    http_response_code(400);
+    return json_encode(['error' => 'No file uploaded']);
+}
+
+$uploadedImage = uploadImage($_FILES['file']);
+
+if ($uploadedImage) {
+    return json_encode(['location' => "/$uploadedImage"]);
+} else {
+    http_response_code(400);
+    return json_encode(['error' => 'Failed to upload image. Please check file format and size.']);
+}