File manager - Edit - /home/webapp69.cm.in.th/u69319090033/Shop/tools_backup/fix.php
Back
<?php $lines = file('app.js'); // Reads into array, preserving newlines at the end of each line $replacement = <<<EOT function saveProductForm(e, productId) { e.preventDefault(); if (!STATE.currentUser || STATE.currentUser.role !== 'admin') { showToast('ไม่มีสิทธิ์ดำเนินการนี้', 'error'); return; } const name = document.getElementById('pm-name').value.trim(); const category = document.getElementById('pm-category').value; const badge = document.getElementById('pm-badge').value; const price = parseFloat(document.getElementById('pm-price').value); const originalPrice = document.getElementById('pm-original-price').value ? parseFloat(document.getElementById('pm-original-price').value) : null; const image = document.getElementById('pm-image').value.trim() || 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=800'; const description = document.getElementById('pm-description').value.trim(); if (productId) { const p = STATE.products.find(p => p.id === productId); if (p) { p.name = name; p.category = category; p.badge = badge || null; if (badge === 'sale') p.badgeText = 'ลด 50%'; else if (badge === 'new') p.badgeText = 'มาใหม่'; else if (badge === 'hot') p.badgeText = 'ขายดี'; else p.badgeText = null; p.price = price; p.originalPrice = originalPrice; p.image = image; p.description = description; } showToast('แก้ไขข้อมูลสินค้าเรียบร้อยแล้ว', 'success'); } else { const newId = STATE.products.length ? Math.max(...STATE.products.map(p => p.id)) + 1 : 1; let badgeText = null; if (badge === 'sale') badgeText = 'ลด 50%'; else if (badge === 'new') badgeText = 'มาใหม่'; else if (badge === 'hot') badgeText = 'ขายดี'; STATE.products.push({ id: newId, category, name, description, price, originalPrice, rating: 5.0, sold: 0, badge: badge || null, badgeText, image, reviewsCount: 0 }); showToast('เพิ่มสินค้าใหม่เรียบร้อยแล้ว', 'success'); } localStorage.setItem('goodboyshop_products', JSON.stringify(STATE.products)); closeModal('auth-modal'); renderProducts(); const adminContent = document.getElementById('admin-tab-content'); if (adminContent && typeof _renderAdminProductsTab === 'function') { _renderAdminProductsTab(adminContent); } } function renderProfileView(tab = 'info') { EOT; $replacement_lines = explode("\n", $replacement); // add newlines back foreach ($replacement_lines as &$line) { $line .= "\n"; } array_splice($lines, 1021, 5, $replacement_lines); file_put_contents('app.js', implode("", $lines)); echo "Fixed app.js\n";
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings