Server : LiteSpeed System : Linux in-mum-web1112.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64 User : u451330669 ( 451330669) PHP Version : 8.2.27 Disable Function : NONE Directory : /home/u451330669/domains/thedeepenterprise.com/public_html/admin/ |
<?php
require('top.inc.php');
$categories_id='';
$name='';
$qty='';
$image='';
$short_desc='';
$description='';
$meta_title ='';
$meta_desc ='';
$meta_keyword='';
$multipleImageArr=[];
$msg='';
$image_required='required';
if(isset($_GET['pi']) && $_GET['pi']>0){
$pi=get_safe_value($con,$_GET['pi']);
$delete_sql="delete from product_images where id='$pi'";
mysqli_query($con,$delete_sql);
}
if(isset($_GET['id']) && $_GET['id']!=''){
$image_required='';
$id=get_safe_value($con,$_GET['id']);
$res=mysqli_query($con,"select * from product where id='$id'");
$check=mysqli_num_rows($res);
if($check>0){
$row=mysqli_fetch_assoc($res);
$categories_id=$row['categories_id'];
$name=$row['name'];
$qty=$row['qty'];
$short_desc=$row['short_desc'];
$description=$row['description'];
$meta_title=$row['meta_title'];
$meta_desc=$row['meta_desc'];
$meta_keyword=$row['meta_keyword'];
$image=$row['image'];
$resMultipleImage=mysqli_query($con,"select id,product_images from product_images where product_id='$id'");
if(mysqli_num_rows($resMultipleImage)>0){
$jj=0;
while($rowMultipleImage=mysqli_fetch_assoc($resMultipleImage)){
$multipleImageArr[$jj]['product_images']=$rowMultipleImage['product_images'];
$multipleImageArr[$jj]['id']=$rowMultipleImage['id'];
$jj++;
}
}
}else{
header('location:product.php');
die();
}
}
if(isset($_POST['submit'])){
$categories_id=get_safe_value($con,$_POST['categories_id']);
$name=get_safe_value($con,$_POST['name']);
$qty=get_safe_value($con,$_POST['qty']);
$short_desc=get_safe_value($con,$_POST['short_desc']);
$description=get_safe_value($con,$_POST['description']);
$meta_title=get_safe_value($con,$_POST['meta_title']);
$meta_desc=get_safe_value($con,$_POST['meta_desc']);
$meta_keyword=get_safe_value($con,$_POST['meta_keyword']);
$res=mysqli_query($con,"select product.* from product where id='$id'");
$check=mysqli_num_rows($res);
if($check>0){
if(isset($_GET['id']) && $_GET['id']!=''){
$getData=mysqli_fetch_assoc($res);
if($id==$getData['id']){
}else{
$msg="Product already exist";
}
}else{
$msg="Product already exist";
}
}
if(isset($_GET['id']) && $_GET['id']==0){
if($_FILES['image']['type']!='image/png' && $_FILES['image']['type']!='image/jpg' && $_FILES['image']['type']!='image/jpeg' && $_FILES['image']['type']!='image/webp' ){
$msg="Please select only png,jpg and jpeg image formate";
}
}else{
if($_FILES['image']['type']!=''){
if($_FILES['image']['type']!='image/png' && $_FILES['image']['type']!='image/jpg' && $_FILES['image']['type']!='image/jpeg' && $_FILES['image']['type']!='image/webp'){
$msg="Please select only png,jpg and jpeg image formate";
}
}
}
if(isset($_FILES['product_images'])){
foreach($_FILES['product_images']['type'] as $key=>$val){
if($_FILES['product_images']['type'][$key]!=''){
if($_FILES['product_images']['type'][$key]!='image/png' && $_FILES['product_images']['type'][$key]!='image/jpg' && $_FILES['product_images']['type'][$key]!='image/jpeg' && $_FILES['product_images']['type'][$key]!='image/webp'){
$msg="Please select only png,jpg and jpeg image formate in multipel product images";
}
}
}
}
if($msg==''){
if(isset($_GET['id']) && $_GET['id']!=''){
if($_FILES['image']['name']!=''){
$image=rand(111111111,999999999).'_'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'],PRODUCT_IMAGE_SERVER_PATH.$image);
$update_sql="update product set categories_id='$categories_id',name='$name',qty='$qty',short_desc='$short_desc',description='$description',meta_title='$meta_title',meta_desc='$meta_desc',meta_keyword='$meta_keyword',image='$image' where id='$id'";
}else{
$update_sql="update product set categories_id='$categories_id',name='$name',qty='$qty',short_desc='$short_desc',description='$description',meta_title='$meta_title',meta_desc='$meta_desc',meta_keyword='$meta_keyword' where id='$id'";
}
mysqli_query($con,$update_sql);
}else{
$image=rand(111111111,999999999).'_'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'],PRODUCT_IMAGE_SERVER_PATH.$image);
mysqli_query($con,"insert into product(categories_id,name,qty,short_desc,description,meta_title,meta_desc,meta_keyword,status,image) values('$categories_id','$name','$qty','$short_desc','$description','$meta_title','$meta_desc','$meta_keyword',1,'$image')");
$id=mysqli_insert_id($con);
}
/*Product Multiple Images Start*/
if(isset($_GET['id']) && $_GET['id']!=''){
foreach($_FILES['product_images']['name'] as $key=>$val){
if($_FILES['product_images']['name'][$key]!=''){
if(isset($_POST['product_images_id'][$key])){
$image=rand(111111111,999999999).'_'.$_FILES['product_images']['name'][$key];
move_uploaded_file($_FILES['product_images']['tmp_name'][$key],PRODUCT_MULTIPLE_IMAGE_SERVER_PATH.$image);
mysqli_query($con,"update product_images set product_images='$image' where id='".$_POST['product_images_id'][$key]."'");
}else{
$image=rand(111111111,999999999).'_'.$_FILES['product_images']['name'][$key];
move_uploaded_file($_FILES['product_images']['tmp_name'][$key],PRODUCT_MULTIPLE_IMAGE_SERVER_PATH.$image);
mysqli_query($con,"insert into product_images(product_id,product_images) values('$id','$image')");
}
}
}
}else{
if(isset($_FILES['product_images']['name'])){
foreach($_FILES['product_images']['name'] as $key=>$val){
if($_FILES['product_images']['name'][$key]!=''){
$image=rand(111111111,999999999).'_'.$_FILES['product_images']['name'][$key];
move_uploaded_file($_FILES['product_images']['tmp_name'][$key],PRODUCT_MULTIPLE_IMAGE_SERVER_PATH.$image);
mysqli_query($con,"insert into product_images(product_id,product_images) values('$id','$image')");
}
}
}
}
/*Product Multiple Images End*/
header('location:product.php');
die();
}
}
?>
<div class="content pb-0">
<div class="animated fadeIn">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header"><strong>News</strong><small> Form</small></div>
<form method="post" enctype="multipart/form-data">
<div class="card-body card-block">
<div class="form-group">
<label for="categories" class=" form-control-label">Categories</label>
<select class="form-control" name="categories_id">
<option>Select Category</option>
<?php
$res=mysqli_query($con,"select id,categories from categories order by categories asc");
while($row=mysqli_fetch_assoc($res)){
if($row['id']==$categories_id){
echo "<option selected value=".$row['id'].">".$row['categories']."</option>";
}else{
echo "<option value=".$row['id'].">".$row['categories']."</option>";
}
}
?>
</select>
</div>
<div class="form-group">
<label>name</label>
<input class="form-control" type="text" name="name" type="text" placeholder="First Name" value="<?php echo $name?>">
</div>
<div class="form-group">
<div class="row" id="image_box">
<div class="col-lg-10">
<label for="categories" class=" form-control-label">Image</label>
<input type="file" name="image" class="form-control" <?php echo $image_required?>>
<?php
if($image!=''){
echo "<a target='_blank' href='".PRODUCT_IMAGE_SITE_PATH.$image."'><img width='150px' src='".PRODUCT_IMAGE_SITE_PATH.$image."'/></a>";
}
?>
</div>
<div class="col-lg-2">
<label for="categories" class=" form-control-label"></label>
<button id="" type="button" class="btn btn-lg btn-info btn-block" onclick="add_more_images()">
<span id="payment-button-amount">Add Image</span>
</button>
</div>
<?php
if(isset($multipleImageArr[0])){
foreach($multipleImageArr as $list){
echo '<div class="col-lg-6" style="margin-top:20px;" id="add_image_box_'.$list['id'].'"><label for="categories" class=" form-control-label">Image</label><input type="file" name="product_images[]" class="form-control" ><a href="manage_product.php?id='.$id.'&pi='.$list['id'].'" style="color:white;"><button type="button" class="btn btn-lg btn-danger btn-block"><span id="payment-button-amount"><a href="manage_product.php?id='.$id.'&pi='.$list['id'].'" style="color:white;">Remove</span></button></a>';
echo "<a target='_blank' href='".PRODUCT_MULTIPLE_IMAGE_SITE_PATH.$list['product_images']."'><img width='150px' src='".PRODUCT_MULTIPLE_IMAGE_SITE_PATH.$list['product_images']."'/></a>";
echo '<input type="hidden" name="product_images_id[]" value="'.$list['id'].'"/></div>';
}
}
?>
</div>
</div>
<div class="form-group">
<label for="cname" class=" form-control-label">Short Description</label>
<textarea name="short_desc" placeholder="Enter product short description" class="form-control" ><?php echo $short_desc?></textarea>
</div>
<div class="form-group">
<label for="categories_id" class=" form-control-label" for="cname" >Description</label>
<textarea name="description" placeholder="Enter product description" class="form-control" ><?php echo $description?></textarea>
</div>
<div class="form-group">
<label for="categories_id" class=" form-control-label">meta_title</label>
<input type="text" name="meta_title" placeholder="Enter title" class="form-control" value="<?php echo $meta_title?>">
</div>
<div class="form-group">
<label>Meta Tag</label>
<input class="form-control" type="text" name="qty"placeholder="Meta tag" value="<?php echo $qty?>">
</div>
<div class="form-group">
<label for="categories_id" class=" form-control-label">Meta_keyword</label>
<input type="text" name="meta_keyword" placeholder="Enter Meta_keyword" class="form-control" value="<?php echo $meta_keyword?>">
</div>
<div class="form-group">
<label for="categories_id" class=" form-control-label">Meta_desc</label>
<input type="text" name="meta_desc" placeholder="Enter Descri..." class="form-control" value="<?php echo $meta_desc?>">
</div>
<button id="payment-button" name="submit" type="submit" class="btn btn-lg btn-info btn-block">
<span id="payment-button-amount">Submit</span>
</button>
<div class="field_error"><?php echo $msg?></div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</script>
<!-- My Account End --><script type="text/javascript">
var total_image=1;
function add_more_images(){
total_image++;
var php='<div class="col-lg-6" style="margin-top:20px;" id="add_image_box_'+total_image+'"><label for="categories" class=" form-control-label">Image</label><input type="file" name="product_images[]" class="form-control" required><button type="button" class="btn btn-lg btn-danger btn-block" onclick=remove_image("'+total_image+'")><span id="payment-button-amount">Remove</span></button></div>';
jQuery('#image_box').append(php);
}
function remove_image(id){
jQuery('#add_image_box_'+id).remove();
}
</script>
<script src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
CKEDITOR.editorConfig = function (config) {
config.language = 'es';
config.uiColor = '#F7B42C';
config.height = 300;
config.toolbarCanCollapse = true;
};
CKEDITOR.replace('description');
CKEDITOR.editorConfig = function (config) {
config.language = 'es';
config.uiColor = '#F7B42C';
config.height = 300;
config.toolbarCanCollapse = true;
};
CKEDITOR.replace('short_desc');
</script>
<?php
require('footer.inc.php');
?>