Şuanki Dizin: /home/wwwdreamtechnolo/public_html/newsatarabca.com/admin/ |
Şuanki Dosya : /home/wwwdreamtechnolo/public_html/newsatarabca.com/admin/contact.php |
<?php require_once("lib/functions.php"); $db = new login_function(); $flag = 0; $actual_image_name=""; $success_msg = 0; $image_error = ""; $succ_flag = 0; $department_error = ""; $department = ""; $semester = ""; $semester_error = ""; $s_date = Date("d-m-Y"); $description = ""; $succ_flag = 0; $f_name = ""; $designation = ""; $email_id = ""; $contact = ""; $departments = ""; $semesters = ""; 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['add_btn'])) { $department = $_POST['department']; $semester = $_POST['semster']; $f_name = $_POST['f_name']; $designation = $_POST['designation']; $contact = $_POST['contact']; $email_id = $_POST['email_id']; if($department == 'Select Department') { $department_error ="Please select Department"; $flag = 1; } if($semester == 'Select Semester') { $semester_error = "Please select Semester"; $flag = 1; } $valid_formats = array("jpg","png","gif","bmp","jpeg","pdf","JPEG","JPG","BMP","PNG","GIF","PDF"); 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) { $db->add_contact_details($department,$semester,$actual_image_name,$f_name,$designation,$contact,$email_id); $succ_flag = 1 ; $department = ""; $semester = ""; $f_name = ""; $designation = ""; $contact = ""; $email_id = ""; } } if(isset($_GET['delete_id']) AND (isset($_GET['image']))) { $del_id = $_GET['delete_id']; $iname = $_GET['image']; $db->delete_contact_details($del_id); unlink('../gallery/'.$name); header("Location:/admin/contact.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"> Contact Directory </h1> <?php if($succ_flag == 1) { ?> <div class="alert alert-success"> Saved Successfully. </div> <?php } ?> <?php if($success_msg == 2) { ?> <div class="alert alert-danger"> Deleted Successfully. </div> <?php } ?> </div> </div> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading"> Contact Directory </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> Select Department </label> <select class="form-control" name="department"> <?php if($department != "") { ?> <option value="<?php echo $department; ?>"> <?php echo $department; ?> </option> <?php } ?> <option value="Select Department">Select Department</option> <?php $report_details = $db->get_all_department(); if(!empty($report_details)) { $counter =0; foreach($report_details as $record) { $id = $report_details[$counter][0]; $department_name= $report_details[$counter][1]; ?> <option value="<?php echo $department_name; ?>"><?php echo $department_name; ?></option> <?php $counter++; } } ?> </select> <span style="color:red;"><?php echo $department_error; ?></span> </div> <div class="form-group"> <label> Select Semester </label> <select class="form-control" name="semster"> <?php if($semester != "") { ?> <option value="<?php echo $semester; ?>"> <?php echo $semester; ?> </option> <?php } ?> <option value="Select Semester">Select Semester</option> <?php $report_details = $db->get_all_semester(); if(!empty($report_details)) { $counter =0; foreach($report_details as $record) { $id = $report_details[$counter][0]; $semester_name = $report_details[$counter][1]; ?> <option value="<?php echo $semester_name; ?>"><?php echo $semester_name; ?></option> <?php $counter++; } } ?> </select> <span style="color:red;"><?php echo $semester_error; ?></span> </div> <div class="form-group"> <label> Profile </label> <input class="form-control" placeholder="Select Date" name="picture" type="file" required > </div> <div class="form-group"> <label> Name </label> <input class="form-control" placeholder="Enter Name" name="f_name" type="text" required value="<?php echo $f_name; ?>"> </div> <div class="form-group"> <label> Designation </label> <input class="form-control" placeholder="Enter Designation" name="designation" type="text" required value="<?php echo $designation; ?>"> </div> <div class="form-group"> <label> Contact No </label> <input class="form-control" placeholder="Enter Contact No" name="contact" type="text" required value="<?php echo $contact; ?>"> </div> <div class="form-group"> <label> Email Id </label> <input class="form-control" placeholder="Enter Email Id" name="email_id" type="text" required value="<?php echo $email_id; ?>"> </div> <button type="submit" class="btn btn-success" name="add_btn">Submit</button> <br /><br /> </form> </div> <div class="row"> <?php if(isset($_POST['search_btn'])) { $departments = $_POST['department']; $semesters = $_POST['semster']; } ?> <form method="post"> <div class="col-lg-12"> <div class="col-lg-3"> <select class="form-control" name="department"> <?php if($department != "") { ?> <option value="<?php echo $department; ?>"> <?php echo $department; ?> </option> <?php } ?> <option value="Select Department">Select Department</option> <?php $report_details = $db->get_all_department(); if(!empty($report_details)) { $counter =0; foreach($report_details as $record) { $id = $report_details[$counter][0]; $department_name= $report_details[$counter][1]; ?> <option value="<?php echo $department_name; ?>"><?php echo $department_name; ?></option> <?php $counter++; } } ?> </select> </div> <div class="col-lg-3"> <select class="form-control" name="semster"> <?php if($semester != "") { ?> <option value="<?php echo $semester; ?>"> <?php echo $semester; ?> </option> <?php } ?> <option value="Select Semester">Select Semester</option> <?php $report_details = $db->get_all_semester(); if(!empty($report_details)) { $counter =0; foreach($report_details as $record) { $id = $report_details[$counter][0]; $semester_name = $report_details[$counter][1]; ?> <option value="<?php echo $semester_name; ?>"><?php echo $semester_name; ?></option> <?php $counter++; } } ?> </select> </div> <div class="col-lg-3"> <button type="submit" class="btn btn-success" name="search_btn"> Search </button><br /> </div> </form> <div class="col-lg-12"> <br /><br /> <div class="panel panel-default"> <div class="panel-heading"> Contact 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 width="100">Department</th> <th width="100">Semester</th> <th width="100">Profile</th> <th width="100">Name</th> <th width="100">Designation</th> <th width="100">Contact No</th> <th width="100">Email Id</th> <th width="50">Action</th> <th width="50">Action</th> </tr> </thead> <tbody> <?php $report_details = $db->get_all_contact_details($departments,$semesters); if(!empty($report_details)) { $counter =0; foreach($report_details as $record) { $id = $report_details[$counter][0]; $department = $report_details[$counter][1]; $semester = $report_details[$counter][2]; $image = $report_details[$counter][3]; $name = $report_details[$counter][4]; $designation = $report_details[$counter][5]; $contact = $report_details[$counter][6]; $email_id = $report_details[$counter][7]; ?> <tr> <td><?php echo $counter+1; ?></td> <td><?php echo $department; ?></td> <td><?php echo $semester; ?></td> <?php if($image != "") { list($txt, $ext) = explode(".", $image); if($ext=="pdf") { ?> <td><a href="/gallery/<?php echo $image; ?>" target="_blank"><img src="/images/pdfimg.jpg" height="50px" width="50px" title="view"></a></td> <?php } else { ?> <td> <a href="/gallery/<?php echo $image; ?>" target="_blank"><img src="/gallery/<?php echo $image; ?>" height="50px" width="50px" title="view"></a></td> <?php } ?> <?php } else { ?> <td><img src="/images/no_image_available.png" style="height:90px;width:90px;" /></td> <?php } ?> <td><?php echo $name; ?></td> <td><?php echo $designation; ?></td> <td><?php echo $contact; ?></td> <td><?php echo $email_id; ?></td> <td><a href="/admin/edit-contact.php?up_id=<?php echo $id;?>">Edit</a></td> <td><a href="/admin/contact.php?delete_id=<?php echo $id;?>&image=<?php echo $image; ?>" onclick="return confirm('Are you sure?');">Delete</a></td> </tr> <?php $counter ++; } }else { ?> <td colspan="7">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>
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