
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
include '../includes/settings/constant.php';
//include '../includes/settings/db.php';
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
if (!empty($_SESSION['adminId']) && !empty($_SESSION['admin_role_id'])) {
if($_SESSION['admin_role_id']==1){
//header("Location: index.php");
}elseif($_SESSION['admin_role_id']==2){
header("Location: ../dashboard/index.php");
}
}else{
header("Location: ../index.php");
exit();
}
$function = new FUNCTIONS();
//$id=$_GET['id'];
$upcoming = $function->getUpcomingevent($_GET['id'],1);
$gallerydata = $function->getGallery($id=NULL,$status=1,$orderBy='DESC');
//print_r($news); exit;
if(isset($_POST['btneditlatestnews']) && !empty($_POST)){
//print_r($_FILES); exit;
$foldername = "../uploads/upcoming-event/";
$oldfile = $_POST['oldfile'];
$id=$_GET['id'];
$title = !empty($_POST['title'])?trim($_POST['title']):"";
$title = htmlentities($title, ENT_QUOTES);
$file = $_FILES['file'];
$descripation = !empty($_POST['descripation'])?trim($_POST['descripation']):"";
$descripation = htmlentities($descripation, ENT_QUOTES);
$news_date = !empty($_POST['news_date'])?trim($_POST['news_date']):"";
$gallery_link = !empty($_POST['gallery_link'])?trim($_POST['gallery_link']):"";
$error_msg = "";
$ipaddress = $function->getRealIpAddr();
if (!empty($file['name'])) {
$newfilename = uniqid('upcomingEvent-',false);
$foldername = "../uploads/upcoming-event/";
$imggg = $function->uploadFile($newfilename, $foldername, 'file');
//print_r($imggg[2]); //exit();
//print_r($foldername.$oldfile); //exit;
if($imggg[2]){
unlink($foldername.$oldfile); //remove the file
}
$oldfile = $imggg[2];
}
//print_r($oldfile);
$pdodb = PDODB::getInstance();
//echo "cmdm"; exit;
$sql = "UPDATE tb_upcoming_event SET title='".$title."',descripation='".$descripation."',news_date='".$news_date."',gallery_link='".$gallery_link."',file='".$oldfile."',ipaddress='".$ipaddress."' WHERE id = '".$id."'";
//print_r($sql); exit;
$result = $pdodb->query($sql);
//print_r($result); exit;
PDODB::closeInstance();
if($result) {
header("Location: upcoming-events.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'upcoming-events'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>Edit Events Form</h2>
</div>
<div class="col-lg-2">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title back-change">
<!-- <h5>Image cropper <small>http://fengyuanchen.github.io/cropper/</small></h5> -->
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">Config option 1</a>
</li>
<li><a href="#">Config option 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="row">
<form method="POST" action="" enctype="multipart/form-data" id="addnews">
<div class="col-sm-6 b-r">
<div class="form-group"><label>Title</label> <input type="text" value="<?=!empty($upcoming[0]['title'])?$upcoming[0]['title']:'';?>" name="title" id="title" class="form-control">
</div>
<div class="form-group"><label>Descripation</label> <textarea class="form-control" rows="5" id="comment" name="descripation"><?=!empty($upcoming[0]['descripation'])?$upcoming[0]['descripation']:'';?></textarea>
</div>
<div class="form-group"><label>Date</label>
<input type="date" value="<?=!empty($upcoming[0]['news_date'])?$upcoming[0]['news_date']:'';?>" name="news_date" id="news_date" class="form-control">
</div>
<div class="form-group"><label>Select Gallery</label>
<select class="form-control" name="gallery_link" id="gallery_link">
<option value=""> ----Please Select----- </option>
<?php for($i=0;$i<count($gallerydata);$i++){ ?>
<option <?=($upcoming[0]['gallery_link']==$gallerydata[$i]['title'])?'selected':'';?> value="<?=$gallerydata[$i]['title'];?>"><?=$gallerydata[$i]['title'];?></option>
<?php } ?>
</select>
</div>
<div>
<button class="btn btn-sm btn-primary pull-right m-t-n-xs" name="btneditlatestnews" id="btneditlatestnews" type="submit"><strong>Submit</strong></button>
</div>
</div>
<div class="col-md-6">
<h4>Preview image</h4>
<div class="img-preview img-preview-sm" style="margin-bottom: 10px;"><img alt="Image Display Here" id="test" src="../uploads/upcoming-event/<?=$upcoming[0]['file'];?>" style="min-width: 0px !important; min-height: 0px !important; max-width: none !important; max-height: none !important; width: 250px; height: 167px; margin-left: -25px; margin-top: -22px;"></div>
<form id="form1" runat="server">
<input type="file" id="file" class="btn btn-primary" onchange="readURL(this);" name="file">
<input type="hidden" name="oldfile" id="oldfile" value="<?=$upcoming[0]['file'];?>">
</form>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<script>
function tossterMsgAlert(msg='Welcome',title='') {
toastr.options = {
closeButton: true,
//debug: false,
newestOnTop: false,
//progressBar: false,
positionClass: 'toast-top-center',
preventDuplicates: true,
//onclick: null,
//showDuration: 300,
//hideDuration: 1000,
timeOut: 2000,
//extendedTimeOut: 1000,
//showEasing: 'swing',
//hideEasing: 'linear',
//showMethod: 'fadeIn',
hideMethod: 'fadeOut'
};
toastr.warning(title,msg);
}
</script>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#test').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
};
</script>
</body>
</html>


PK 99