BLACKSITE
:
216.73.216.62
:
147.93.18.13 / vinyasaweddings.com
:
Linux srv667811 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
:
/
var
/
www
/
insonohearing
/
admin
/
Upload File:
files >> /var/www/insonohearing/admin/edit_page.php
<?php require __DIR__ . '/../db.php'; $id = $_GET['id'] ?? null; if (!$id) { echo "Invalid Page ID"; exit; } // Fetch page details $stmt = $conn->prepare("SELECT * FROM landing_pages WHERE id = ?"); $stmt->execute([$id]); $page = $stmt->fetch(PDO::FETCH_ASSOC); if (!$page) { echo "Page not found"; exit; } // Fetch FAQs $faqStmt = $conn->prepare("SELECT * FROM faqs WHERE landing_page_id = ?"); $faqStmt->execute([$id]); $faqs = $faqStmt->fetchAll(PDO::FETCH_ASSOC); $productStmt = $conn->query("SELECT id, name FROM products"); $allProducts = $productStmt->fetchAll(PDO::FETCH_ASSOC); // Convert stored product_ids to array $selectedProductIds = explode(',', $page['product_ids']); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $page_heading = $_POST['page_heading']; $slug = $_POST['slug']; $hero_content = $_POST['hero_content']; $about_header = $_POST['about_header']; $about_detail = $_POST['about_detail']; // Handle about image $imagePath = $page['about_image']; if (!empty($_FILES['about_image']['name'])) { $uploadDir = 'uploads/'; if (!is_dir($uploadDir)) mkdir($uploadDir); $filename = time() . '_' . basename($_FILES['about_image']['name']); $targetFile = $uploadDir . $filename; if (move_uploaded_file($_FILES['about_image']['tmp_name'], $targetFile)) { $imagePath = 'uploads/' . $filename; } } $product_heading = $_POST['product_heading']; $product_ids = isset($_POST['product_ids']) ? implode(',', $_POST['product_ids']) : ''; // Update landing page $updateStmt = $conn->prepare("UPDATE landing_pages SET page_heading = ?, slug = ?, hero_content = ?, about_header = ?, about_detail = ?, about_image = ?, product_heading = ?, product_ids = ? WHERE id = ?"); $updateStmt->execute([$page_heading, $slug, $hero_content, $about_header, $about_detail, $imagePath, $product_heading, $product_ids, $id]); // Delete old FAQs and insert new $conn->prepare("DELETE FROM faqs WHERE landing_page_id = ?")->execute([$id]); if (!empty($_POST['faq'])) { foreach ($_POST['faq'] as $faq) { $question = $faq['question']; $answer = $faq['answer']; $conn->prepare("INSERT INTO faqs (landing_page_id, question, answer) VALUES (?, ?, ?)") ->execute([$id, $question, $answer]); } } echo "<script>alert('Page Updated!'); window.location.href='index.php?page=allpage';</script>"; exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Edit Landing Page</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jodit/build/jodit.min.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jodit/build/jodit.min.css"> <link rel="icon" href="https://insonohearing.com/assets_b/img/favicon-32x32.png" type="image/png" sizes="32x32"> <link rel="icon" href="https://insonohearing.com/assets_b/img/favicon-32x32.png" type="image/png" sizes="16x16"> <style> .faq-item { margin-bottom: 1rem; padding: 1rem; border: 1px solid #ddd; border-radius: 8px; background: #f9f9f9; } </style> </head> <body> <div class="container mt-4 mb-5"> <h3 class="mb-4">Edit Landing Page</h3> <form method="POST" action="" enctype="multipart/form-data"> <div class="mb-3"> <label>Page Heading</label> <input type="text" class="form-control" name="page_heading" value="<?= htmlspecialchars($page['page_heading']) ?>" required> </div> <div class="mb-3"> <label>Slug (URL)</label> <input type="text" class="form-control" name="slug" value="<?= htmlspecialchars($page['slug']) ?>" required> </div> <div class="mb-3"> <label>Hero Section Content</label> <textarea id="heroEditor" name="hero_content"><?= htmlspecialchars($page['hero_content']) ?></textarea> </div> <hr> <h5 class="mb-3">About Section</h5> <div class="mb-3"> <label>About Header</label> <input type="text" class="form-control" name="about_header" value="<?= htmlspecialchars($page['about_header']) ?>"> </div> <div class="mb-3"> <label>About Detail</label> <textarea id="aboutEditor" name="about_detail"><?= htmlspecialchars($page['about_detail']) ?></textarea> </div> <div class="mb-3"> <label>About Image</label> <input type="file" class="form-control" name="about_image" accept="image/*" onchange="previewImage(event)"> <?php if ($page['about_image']): ?> <img id="imagePreview" src="../<?= $page['about_image'] ?>" class="img-fluid mt-2" style="max-height: 200px;"> <?php else: ?> <img id="imagePreview" src="#" alt="Image Preview" class="img-fluid mt-2" style="display:none; max-height: 200px;"> <?php endif; ?> </div> <hr> <hr> <h5 class="mb-3">Products Section</h5> <div class="mb-3"> <label>Product Heading</label> <input type="text" class="form-control" name="product_heading" value="<?= htmlspecialchars($page['product_heading'] ?? '') ?>"> </div> <div class="mb-3"> <label>Select Products to Show</label> <select name="product_ids[]" class="form-select" multiple> <?php foreach ($allProducts as $product): ?> <option value="<?= $product['id'] ?>" <?= in_array($product['id'], $selectedProductIds) ? 'selected' : '' ?>> <?= htmlspecialchars($product['name']) ?> </option> <?php endforeach; ?> </select> <small class="text-muted">Hold Ctrl (Windows) or Cmd (Mac) to select multiple products</small> </div> <h5 class="mb-3">FAQ Section</h5> <div id="faqContainer"> <?php foreach ($faqs as $index => $faq): ?> <div class="faq-item" id="faq-<?= $index ?>"> <div class="mb-2"> <label>Question</label> <input type="text" class="form-control" name="faq[<?= $index ?>][question]" value="<?= htmlspecialchars($faq['question']) ?>" required> </div> <div class="mb-2"> <label>Answer</label> <textarea class="form-control" name="faq[<?= $index ?>][answer]" required><?= htmlspecialchars($faq['answer']) ?></textarea> </div> <button type="button" class="btn btn-sm btn-danger" onclick="removeFAQ(<?= $index ?>)">Remove</button> </div> <?php endforeach; ?> </div> <button type="button" class="btn btn-outline-primary mb-3" onclick="addFAQ()">+ Add FAQ</button> <button type="submit" class="btn btn-success w-100">Update Page</button> </form> </div> <script> const heroEditor = new Jodit("#heroEditor"); const aboutEditor = new Jodit("#aboutEditor"); let faqIndex = <?= count($faqs) ?>; function addFAQ() { const container = document.getElementById('faqContainer'); const faqHTML = ` <div class="faq-item" id="faq-${faqIndex}"> <div class="mb-2"> <label>Question</label> <input type="text" class="form-control" name="faq[${faqIndex}][question]" required> </div> <div class="mb-2"> <label>Answer</label> <textarea class="form-control" name="faq[${faqIndex}][answer]" required></textarea> </div> <button type="button" class="btn btn-sm btn-danger" onclick="removeFAQ(${faqIndex})">Remove</button> </div> `; container.insertAdjacentHTML('beforeend', faqHTML); faqIndex++; } function removeFAQ(index) { const el = document.getElementById(`faq-${index}`); if (el) el.remove(); } function previewImage(event) { const image = document.getElementById('imagePreview'); image.src = URL.createObjectURL(event.target.files[0]); image.style.display = 'block'; } </script> </body> </html>