File manager - Edit - /home/webapp69.cm.in.th/u69319090041/Shop41/includes/footer.php
Back
</div> <!-- End Container --> <?php // กำหนดค่า Default ที่สวยงามและมีข้อมูลครบถ้วนสำหรับ Footer 4 คอลัมน์ $defaultFooterData = [ 'about' => [ 'title' => '👕 41SHOP', 'description' => 'ร้านค้าออนไลน์ที่รวบรวมสินค้าคุณภาพดีที่สุด จัดส่งไว บริการด้วยใจ มั่นใจได้ 100%', 'socials' => [ ['icon' => '<i class="fab fa-facebook fs-5"></i>', 'url' => '#'], ['icon' => '<i class="fab fa-instagram fs-5"></i>', 'url' => '#'], ['icon' => '<i class="fab fa-line fs-5"></i>', 'url' => '#'] ] ], 'links1' => [ 'title' => 'ลิงก์ด่วน (Quick Links)', 'links' => [ ['text' => 'หน้าแรก', 'url' => SITE_URL . '/index.php'], ['text' => 'สินค้าทั้งหมด', 'url' => SITE_URL . '/shop.php'], ['text' => 'ตะกร้าสินค้า', 'url' => SITE_URL . '/cart.php'], ['text' => 'ติดต่อเรา', 'url' => '#'] ] ], 'links2' => [ 'title' => 'ช่วยเหลือ (Support)', 'links' => [ ['text' => 'นโยบายการจัดส่ง', 'url' => '#'], ['text' => 'การเปลี่ยน/คืนสินค้า', 'url' => '#'], ['text' => 'ข้อตกลงและเงื่อนไข', 'url' => '#'], ['text' => 'นโยบายความเป็นส่วนตัว', 'url' => '#'] ] ], 'contact' => [ 'title' => 'ติดต่อเรา (Contact Us)', 'lines' => [ '<i class="fas fa-map-marker-alt me-2 text-primary"></i> 123 เขตช้อปปิ้ง กรุงเทพฯ 10110', '<i class="fas fa-envelope me-2 text-primary"></i> support@41shop.com', '<i class="fas fa-phone me-2 text-primary"></i> 02-123-4567' ] ] ]; $footerData = $defaultFooterData; try { $db = function_exists('getDBConnection') ? getDBConnection() : null; if ($db) { $stmt = $db->query("SELECT setting_value FROM system_settings WHERE setting_key = 'footer_config'"); $res = $stmt->fetchColumn(); if ($res) { $parsed = json_decode($res, true); if(is_array($parsed) && isset($parsed['about'])) { $footerData = $parsed; } } } } catch (Exception $e) {} $isAdmin = function_exists('isAdmin') ? isAdmin() : false; ?> <footer class="mt-5 py-5 border-top" style="background-color: #f8f9fa;"> <div class="container" id="footer-container"> <div class="row g-4"> <!-- Col 1: About --> <div class="col-lg-4 col-md-6 position-relative footer-col-hover"> <div class="d-flex align-items-center mb-3 justify-content-between"> <h5 class="fw-bold text-primary mb-0"><?php echo htmlspecialchars($footerData['about']['title']); ?></h5> <?php if($isAdmin): ?> <button class="btn btn-sm btn-outline-secondary rounded-circle p-1 edit-footer-btn shadow-sm" onclick="openFooterModal('about')" title="แก้ไขส่วนนี้"><i class="fas fa-pencil-alt" style="font-size: 12px;"></i></button> <?php endif; ?> </div> <p class="text-muted small lh-lg pe-lg-4"><?php echo htmlspecialchars($footerData['about']['description']); ?></p> <div class="d-flex gap-3 mt-3"> <?php if(!empty($footerData['about']['socials'])): foreach($footerData['about']['socials'] as $soc): ?> <a href="<?php echo htmlspecialchars($soc['url']); ?>" class="text-muted text-decoration-none footer-social-icon" target="_blank"> <?php echo $soc['icon']; ?> </a> <?php endforeach; endif; ?> </div> </div> <!-- Col 2: Quick Links --> <div class="col-lg-2 col-md-6 position-relative footer-col-hover"> <div class="d-flex align-items-center mb-3 justify-content-between"> <h6 class="fw-bold mb-0 text-dark"><?php echo htmlspecialchars($footerData['links1']['title']); ?></h6> <?php if($isAdmin): ?> <button class="btn btn-sm btn-outline-secondary rounded-circle p-1 edit-footer-btn shadow-sm" onclick="openFooterModal('links1')" title="แก้ไขส่วนนี้"><i class="fas fa-pencil-alt" style="font-size: 12px;"></i></button> <?php endif; ?> </div> <ul class="list-unstyled small mb-0 lh-lg"> <?php if(!empty($footerData['links1']['links'])): foreach($footerData['links1']['links'] as $link): ?> <li class="mb-2"><a href="<?php echo htmlspecialchars($link['url']); ?>" class="text-muted text-decoration-none footer-link-hover"><?php echo htmlspecialchars($link['text']); ?></a></li> <?php endforeach; endif; ?> </ul> </div> <!-- Col 3: Support Links --> <div class="col-lg-3 col-md-6 position-relative footer-col-hover"> <div class="d-flex align-items-center mb-3 justify-content-between"> <h6 class="fw-bold mb-0 text-dark"><?php echo htmlspecialchars($footerData['links2']['title']); ?></h6> <?php if($isAdmin): ?> <button class="btn btn-sm btn-outline-secondary rounded-circle p-1 edit-footer-btn shadow-sm" onclick="openFooterModal('links2')" title="แก้ไขส่วนนี้"><i class="fas fa-pencil-alt" style="font-size: 12px;"></i></button> <?php endif; ?> </div> <ul class="list-unstyled small mb-0 lh-lg"> <?php if(!empty($footerData['links2']['links'])): foreach($footerData['links2']['links'] as $link): ?> <li class="mb-2"><a href="<?php echo htmlspecialchars($link['url']); ?>" class="text-muted text-decoration-none footer-link-hover"><?php echo htmlspecialchars($link['text']); ?></a></li> <?php endforeach; endif; ?> </ul> </div> <!-- Col 4: Contact --> <div class="col-lg-3 col-md-6 position-relative footer-col-hover"> <div class="d-flex align-items-center mb-3 justify-content-between"> <h6 class="fw-bold mb-0 text-dark"><?php echo htmlspecialchars($footerData['contact']['title']); ?></h6> <?php if($isAdmin): ?> <button class="btn btn-sm btn-outline-secondary rounded-circle p-1 edit-footer-btn shadow-sm" onclick="openFooterModal('contact')" title="แก้ไขส่วนนี้"><i class="fas fa-pencil-alt" style="font-size: 12px;"></i></button> <?php endif; ?> </div> <ul class="list-unstyled small mb-0 text-muted lh-lg"> <?php if(!empty($footerData['contact']['lines'])): foreach($footerData['contact']['lines'] as $line): ?> <li class="mb-2"><?php echo $line; // Allow HTML for icons ?></li> <?php endforeach; endif; ?> </ul> </div> </div> <div class="text-center mt-5 pt-4 border-top text-secondary small d-flex flex-column flex-md-row justify-content-between align-items-center"> <p class="mb-0">© <?php echo date('Y'); ?> <?php echo htmlspecialchars(explode(' ', $footerData['about']['title'])[0]); ?>. All Rights Reserved.</p> <div class="mt-2 mt-md-0"> <img src="https://upload.wikimedia.org/wikipedia/commons/b/b5/PayPal.svg" height="20" class="me-2" alt="PayPal" style="opacity: 0.6;"> <img src="https://upload.wikimedia.org/wikipedia/commons/a/a4/Mastercard_2019_logo.svg" height="20" class="me-2" alt="Mastercard" style="opacity: 0.6;"> <img src="https://upload.wikimedia.org/wikipedia/commons/5/5e/Visa_Inc._logo.svg" height="15" alt="Visa" style="opacity: 0.6;"> </div> </div> </div> </footer> <style> /* Footer Custom Styles */ .footer-link-hover { transition: color 0.2s ease; } .footer-link-hover:hover { color: var(--bs-primary) !important; text-decoration: underline !important; } .footer-social-icon { transition: transform 0.2s, color 0.2s; display: inline-block; } .footer-social-icon:hover { color: var(--bs-primary) !important; transform: translateY(-3px); } .edit-footer-btn { opacity: 0; transition: opacity 0.2s ease; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; } .footer-col-hover:hover .edit-footer-btn { opacity: 1; } </style> <?php if($isAdmin): ?> <!-- Footer Edit Modal --> <div class="modal fade" id="footerEditModal" tabindex="-1" aria-hidden="true"> <div class="modal-dialog modal-lg modal-dialog-centered"> <div class="modal-content border-0 shadow-lg rounded-4"> <div class="modal-header bg-primary text-white rounded-top-4 border-0"> <h5 class="modal-title fw-bold"><i class="fas fa-edit me-2"></i> จัดการข้อมูล Footer</h5> <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body p-4"> <input type="hidden" id="edit-col-key"> <div class="mb-3"> <label class="form-label fw-bold text-dark">หัวข้อคอลัมน์ (Title)</label> <input type="text" id="edit-col-title" class="form-control rounded-3"> </div> <!-- สำหรับ About --> <div class="mb-3" id="edit-col-desc-group" style="display: none;"> <label class="form-label fw-bold text-dark">คำอธิบายร้านค้า</label> <textarea id="edit-col-desc" class="form-control rounded-3" rows="3"></textarea> </div> <!-- Dynamic Items (Links, Socials, Lines) --> <div class="mb-3"> <div class="d-flex justify-content-between align-items-center mb-2"> <label class="form-label fw-bold text-dark mb-0" id="edit-items-label">รายการ</label> <button class="btn btn-sm btn-outline-primary rounded-pill px-3" onclick="addFooterItem()"> <i class="fas fa-plus me-1"></i> เพิ่มรายการ </button> </div> <div id="edit-items-container" class="d-flex flex-column gap-2 bg-light p-3 rounded-3 border"></div> </div> </div> <div class="modal-footer border-0 pt-0 pb-4 px-4"> <button type="button" class="btn btn-light rounded-pill px-4" data-bs-dismiss="modal">ยกเลิก</button> <button type="button" class="btn btn-primary rounded-pill px-4" onclick="saveFooterData()" id="saveFooterBtn"> <i class="fas fa-save me-1"></i> บันทึกการเปลี่ยนแปลง </button> </div> </div> </div> </div> <script> let fullFooterData = <?php echo json_encode($footerData, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); ?>; let currentEditCol = null; function openFooterModal(colKey) { currentEditCol = colKey; const data = fullFooterData[colKey]; document.getElementById('edit-col-key').value = colKey; document.getElementById('edit-col-title').value = data.title || ''; const descGroup = document.getElementById('edit-col-desc-group'); const descInput = document.getElementById('edit-col-desc'); const container = document.getElementById('edit-items-container'); container.innerHTML = ''; if (colKey === 'about') { descGroup.style.display = 'block'; descInput.value = data.description || ''; document.getElementById('edit-items-label').innerText = 'โซเชียลมีเดีย (HTML Icon | URL)'; if(data.socials) { data.socials.forEach((item, idx) => { container.innerHTML += createItemRow('socials', item.icon, item.url, idx); }); } } else if (colKey === 'contact') { descGroup.style.display = 'none'; document.getElementById('edit-items-label').innerText = 'ข้อมูลการติดต่อ (รองรับ HTML Icon)'; if(data.lines) { data.lines.forEach((line, idx) => { container.innerHTML += createItemRow('lines', line, '', idx); }); } } else { descGroup.style.display = 'none'; document.getElementById('edit-items-label').innerText = 'รายการลิงก์ (ข้อความ | URL)'; if(data.links) { data.links.forEach((item, idx) => { container.innerHTML += createItemRow('links', item.text, item.url, idx); }); } } const modal = new bootstrap.Modal(document.getElementById('footerEditModal')); modal.show(); } function escapeHtml(unsafe) { return (unsafe || '').toString() .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function createItemRow(type, val1, val2, idx) { if (type === 'lines') { return ` <div class="d-flex gap-2 footer-item-row align-items-center"> <i class="fas fa-grip-vertical text-muted cursor-move"></i> <input type="text" class="form-control item-val1 rounded-3" value="${escapeHtml(val1)}" placeholder="ข้อความ หรือ โค้ด HTML"> <button class="btn btn-outline-danger rounded-3 px-3" onclick="this.parentElement.remove()" title="ลบ"><i class="fas fa-trash"></i></button> </div>`; } else { return ` <div class="d-flex gap-2 footer-item-row align-items-center"> <i class="fas fa-grip-vertical text-muted cursor-move"></i> <input type="text" class="form-control item-val1 rounded-3" value="${escapeHtml(val1)}" placeholder="${type==='socials'?'HTML Icon':'ข้อความลิงก์'}"> <input type="text" class="form-control item-val2 rounded-3" value="${escapeHtml(val2)}" placeholder="URL"> <button class="btn btn-outline-danger rounded-3 px-3" onclick="this.parentElement.remove()" title="ลบ"><i class="fas fa-trash"></i></button> </div>`; } } function addFooterItem() { const container = document.getElementById('edit-items-container'); const idx = container.children.length; if (currentEditCol === 'about') { container.innerHTML += createItemRow('socials', '<i class="fas fa-link fs-5"></i>', '#', idx); } else if (currentEditCol === 'contact') { container.innerHTML += createItemRow('lines', '', '', idx); } else { container.innerHTML += createItemRow('links', 'ลิงก์ใหม่', '#', idx); } } async function saveFooterData() { const title = document.getElementById('edit-col-title').value; let newData = { title: title }; if (currentEditCol === 'about') { newData.description = document.getElementById('edit-col-desc').value; newData.socials = []; document.querySelectorAll('#edit-items-container .footer-item-row').forEach(row => { const icon = row.querySelector('.item-val1').value; const url = row.querySelector('.item-val2').value; if(icon) newData.socials.push({icon, url}); }); } else if (currentEditCol === 'contact') { newData.lines = []; document.querySelectorAll('#edit-items-container .footer-item-row').forEach(row => { const line = row.querySelector('.item-val1').value; if(line) newData.lines.push(line); }); } else { newData.links = []; document.querySelectorAll('#edit-items-container .footer-item-row').forEach(row => { const text = row.querySelector('.item-val1').value; const url = row.querySelector('.item-val2').value; if(text) newData.links.push({text, url}); }); } fullFooterData[currentEditCol] = newData; const btn = document.getElementById('saveFooterBtn'); btn.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i> กำลังบันทึก...'; btn.disabled = true; try { const response = await fetch('<?php echo SITE_URL; ?>/ajax/update_footer.php', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(fullFooterData) }); // Handle 404 if ajax moved if (response.status === 404) { const fallbackRes = await fetch('<?php echo SITE_URL; ?>/ajax/update_footer.php', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(fullFooterData) }); if(fallbackRes.ok) { location.reload(); return; } } const text = await response.text(); try { const result = JSON.parse(text); if(result.success) { location.reload(); } else { alert('เกิดข้อผิดพลาดในการบันทึก: ' + (result.error || 'Unknown error')); } } catch(e) { console.error("JSON Parse error:", text); alert('การตอบกลับจากเซิร์ฟเวอร์ผิดพลาด'); } } catch(err) { console.error(err); alert('เกิดข้อผิดพลาดในการเชื่อมต่อกับเซิร์ฟเวอร์'); } finally { btn.innerHTML = '<i class="fas fa-save me-1"></i> บันทึกการเปลี่ยนแปลง'; btn.disabled = false; } } </script> <?php endif; ?> <!-- AI Assistant Widget --> <div id="ai-chat-widget" style="position: fixed; bottom: 25px; right: 25px; z-index: 9999;"> <!-- Chat Button --> <button id="ai-toggle-btn" class="btn btn-primary rounded-circle shadow-lg d-flex align-items-center justify-content-center" style="width: 60px; height: 60px; font-size: 26px; border: none; background: linear-gradient(135deg, #6366f1, #a855f7); transition: transform 0.3s ease;"> 🤖 </button> <!-- Chat Box Window --> <div id="ai-chat-box" class="card shadow-lg d-none" style="position: absolute; bottom: 75px; right: 0; width: 350px; max-width: 90vw; height: 460px; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);"> <div class="card-header text-white d-flex justify-content-between align-items-center py-3" style="background: linear-gradient(135deg, #6366f1, #a855f7);"> <div class="d-flex align-items-center gap-2"> <span style="font-size: 20px;">🤖</span> <div> <h6 class="mb-0 fw-bold">ผู้ช่วยตอบคำถาม AI</h6> <small style="font-size: 11px; opacity: 0.85;">สอบถามวิธีเปิดร้านค้า / แนะนำระบบ</small> </div> </div> <button type="button" id="ai-close-btn" class="btn-close btn-close-white" style="font-size: 12px;"></button> </div> <div id="ai-messages" class="card-body overflow-auto p-3 d-flex flex-column gap-2" style="background-color: var(--bg-color, #f8f9fa); height: 330px;"> <div class="bg-white p-3 rounded-3 shadow-sm border border-light text-dark" style="max-width: 88%; border-bottom-left-radius: 2px !important; font-size: 14px;"> สวัสดีครับ/ค่ะ! 🙋♂️ มีข้อสงสัยเกี่ยวกับการใช้งาน หรืออยาก <strong>"เปิดร้านค้าขายของ"</strong> ในระบบ สอบถามได้เลยครับ! </div> </div> <div class="card-footer bg-white p-2 border-top"> <form id="ai-form" class="d-flex gap-2"> <input type="text" id="ai-input" class="form-row form-control form-control-sm border-0 bg-light rounded-pill px-3" placeholder="พิมพ์คำถาม..." required style="font-size: 13px;"> <button type="submit" class="btn btn-primary btn-sm rounded-circle px-2" style="width: 34px; height: 34px; background: linear-gradient(135deg, #6366f1, #a855f7); border: none;"> 🚀 </button> </form> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { const toggleBtn = document.getElementById('ai-toggle-btn'); const closeBtn = document.getElementById('ai-close-btn'); const chatBox = document.getElementById('ai-chat-box'); const form = document.getElementById('ai-form'); const input = document.getElementById('ai-input'); const messages = document.getElementById('ai-messages'); if(toggleBtn && chatBox) { toggleBtn.addEventListener('click', () => { chatBox.classList.toggle('d-none'); if(!chatBox.classList.contains('d-none')) { input.focus(); } }); closeBtn.addEventListener('click', () => chatBox.classList.add('d-none')); form.addEventListener('submit', async function(e) { e.preventDefault(); const text = input.value.trim(); if(!text) return; // แสดงข้อความฝั่งผู้ใช้ const userDiv = document.createElement('div'); userDiv.className = 'ms-auto bg-primary text-white p-3 rounded-3 shadow-sm'; userDiv.style.cssText = 'max-width: 85%; border-bottom-right-radius: 2px !important; font-size: 14px;'; userDiv.textContent = text; messages.appendChild(userDiv); input.value = ''; messages.scrollTop = messages.scrollHeight; // Indicator กำลังคิด const loadingDiv = document.createElement('div'); loadingDiv.className = 'bg-white p-2 rounded-3 shadow-sm border border-light text-muted small'; loadingDiv.style.cssText = 'max-width: 70%; font-size: 12px;'; loadingDiv.innerHTML = '🤖 AI กำลังพิมพ์...'; messages.appendChild(loadingDiv); messages.scrollTop = messages.scrollHeight; try { const res = await fetch('<?php echo SITE_URL; ?>/ajax/ai_chat.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: text }) }); const data = await res.json(); messages.removeChild(loadingDiv); const aiDiv = document.createElement('div'); aiDiv.className = 'bg-white p-3 rounded-3 shadow-sm border border-light text-dark'; aiDiv.style.cssText = 'max-width: 88%; border-bottom-left-radius: 2px !important; font-size: 14px; white-space: pre-wrap;'; aiDiv.innerHTML = data.reply ? data.reply.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') : 'ขออภัยครับ เกิดข้อผิดพลาด'; messages.appendChild(aiDiv); } catch (err) { messages.removeChild(loadingDiv); const errDiv = document.createElement('div'); errDiv.className = 'bg-danger text-white p-2 rounded-3 small'; errDiv.textContent = 'เกิดข้อผิดพลาดในการเชื่อมต่อ'; messages.appendChild(errDiv); } messages.scrollTop = messages.scrollHeight; }); } }); </script> <!-- Bootstrap 5 JS Bundle --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script src="<?php echo SITE_URL; ?>/assets/js/main.js"></script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings