
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();
if (!empty($_GET['id'])) {
$user = $function->getUsers($_GET['id'],NULL,NULL,1);
$user_details = $function->getUserDetails($_GET['id'],1);
}
if(isset($_POST['btnAddlatestnews']) && !empty($_POST)){
//print_r($_FILES); //exit;
$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']):"";
$error_msg = "";
$ipaddress = $function->getRealIpAddr();
$newfilename = uniqid('latestNews-',false);
$foldername = "../uploads/latest-news/";
$imggg = $function->uploadFile($newfilename, $foldername, 'file');
//print_r($imggg[2]); exit();
$pdodb = PDODB::getInstance();
//echo "cmdm"; exit;
$sql = "INSERT INTO tb_latest_news SET title='".$title."',descripation='".$descripation."',news_date='".$news_date."',file='".$imggg[2]."',ipaddress='".$ipaddress."'";
//print_r($sql); exit;
$result = $pdodb->query($sql);
//print_r($result); exit;
PDODB::closeInstance();
if($result) {
header("Location: latest-news.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 = 'latest-news'; 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>Add Latest News 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" placeholder="Enter 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"></textarea>
</div>
<div class="form-group">
<input type="date" name="news_date" id="news_date" class="form-control">
</div>
<div>
<button class="btn btn-sm btn-primary pull-right m-t-n-xs" name="btnAddlatestnews" id="btnAddlatestnews" 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="../img/350x250.png" 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">
</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">
$("#addnews").validate({
rules: {
title: {
required: true
},
news_date: {
required: true
},
file: {
required: true
}
},
messages: {
title: {
required: "Please Enter News Title"
},
news_date: {
required: "Please Enter the Date"
},
file: {
required: "Please Upload Photo"
}
},
submitHandler: function(form) {
form.submit();
}
});
</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