Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /home/wwwdreamtechnolo/public_html/balajimall.com/admin/
Dosya Yükle :
Şuanki Dosya : /home/wwwdreamtechnolo/public_html/balajimall.com/admin/edit-product-images.php

<?php
	require_once("../lib/functions.php");
	$db = new login_function();
	$flag = 0;
	$profile = "";
	$image_error = "";
	$flag = 0;
	$success_flag = 0;
	
	if(!isset($_SESSION['current_login_admin']))
	{
		header("Location:/admin/index.php");
	}
	if(isset($_SESSION['current_login_admin']))
	{
		$email	=	$_SESSION['current_login_admin'];
	}
	if(isset($_GET['insert_id']))
	{
		$insert_id	=	$_GET['insert_id'];
		$_SESSION['current_update_id'] = $insert_id;
	}
	 else if(isset($_SESSION['current_update_id']))
	{
		$insert_id	= $_SESSION['current_update_id'];
	}
		if(isset($_POST['picture_btn']))
		{
			$valid_formats = array("jpg","png","gif","bmp","jpeg","JPEG","JPG","BMP","PNG","GIF");
	
			if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
			{	
				$name 				= 	$_FILES['product']['name'];
				$size 				= 	$_FILES['product']['size'];

				if(strlen($name))
					{				
						list($txt, $ext) = explode(".", $name);
						
						if(in_array($ext,$valid_formats))
						{
							$files	=	array();

							function generateRandomString($length = 10) {
								$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
								$charactersLength = strlen($characters);
								$randomString = '';
								for ($i = 0; $i < $length; $i++) 
								{
									$randomString .= $characters[rand(0, $charactersLength - 1)];
								}
								return $randomString;
							}
							
							$current_random_string = generateRandomString();
							
							$product = $current_random_string.".".strtolower($ext);						

							$tmp = $_FILES['product']['tmp_name'];
							
							$img_Dir = "../product/";
							
							if(!file_exists($img_Dir))
							{
								mkdir($img_Dir);
							}
							
							if(move_uploaded_file($tmp,$img_Dir.$product))
							{
								
							}
							else
							{
								$image_error	=	"failed" ;
								$flag				=	1;
							}	
						}
						else
						{
							$image_error	= "Invalid file format";
							$flag				=	1;	
						}	
					}	
					else
					{
						$flag	=	1;
					}
			}
			if($flag == 0)
			{
				if($db->add_product_image($insert_id,$product))
				{
					$success_flag = 1;
				}
			}
		}
	if(isset($_GET['image_id']))
	{
		$image_id	=	$_GET['image_id'];
		$image_name = $db->get_product_image_name($image_id);
		unlink('../product/'.$image_name);
		$db->delete_product_image_info($image_id);
		header("Location:edit-product-images.php");
		$success_msg	=	2;
	}
?>
<?php
	require_once('header.php');
?>

	<div id="page-wrapper">
	<div class="row">
	<div class="col-lg-12">
	<h1 class="page-header">Update Product Image</h1>
	<?php
	if($success_flag == 1)
	{
	?>
	<div class="alert alert-success">
	Product Updated Successfully.
	</div>
	<?php
	}
	?>



	</div>

	</div>

	<div class="row">
	<div class="col-lg-12">
	<a href="product-report.php"><-- Back To Report</a><br /><br />
	<div class="panel panel-default">
	<div class="panel-heading">
	Update Product Image
	</div>
	<div class="panel-body">
	<div class="row">
	<div class="col-lg-6">
		<form role="form" method="post" enctype="multipart/form-data">
			<div class="form-group">
				<label>Product Image</label>
			
				<input class="form-control"  name="product" type="file" required>
				<span class="error_indicator"><?php echo $image_error; ?></span>

			</div>	
	  
		  <button type="submit" class="btn btn-success" name="picture_btn"> Product Image </button>	<br /><br />
		</form>
	</div>
	<div class="col-lg-6">
	</div>
	<div class="col-lg-12">
	<?php
		$report_details = $db->get_all_product_image_by_id($insert_id);
			if(!empty($report_details))
			{
				
				$counter =0;
				foreach($report_details as $record)
				{
					$id				=	$report_details[$counter][0];
					$images			=	$report_details[$counter][1];
	?>
	<div style="display:inline-table">
	<?php
	if($images!='')
	{
		
	?>
		<img src="../product/<?php echo $images; ?>" style="height:100px;width:100px;border:1px solid #666;margin:5px;padding:5px;"><br />
	<?php
	}
	else
	{
		
	?>
		<img src="../product/no_image_available.png" style="height:100px;width:100px;border:1px solid #666;margin:5px;padding:5px;"><br />
	<?php
	}
	?>
	<center><a href="edit-product-images.php?image_id=<?php echo $id; ?>" >Remove</a></center>
	</div>
	<?php
	$counter ++;
			}
	}
	else
	{
	?>
	<img src="../product/no_image_available.png" style="height:100px;width:100px;border:1px solid #666;margin:5px;padding:5px;"><br />
	<?php
	}
	?>


	</div>

	</div>

	</div>

	</div>

	</div>

	</div>


	</div>
    

</body>

</html>

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4