| Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64 Path : /home/udaipurk/public_html/websites/samaj/samaj/ |
| Current File : //home/udaipurk/public_html/websites/samaj/samaj/scheduler.php |
<?php
include('config.php');
// <--Insert and Update Code-->
if (isset($_POST['submit'])) {
$cal_id = $_POST['cal_id'];
$title = $_POST['title'];
$img1=$_FILES['img']['name'];
$img = preg_replace('/[^a-zA-Z0-9_.]/', '', $img1);;
$path = "upload/calender/".time().$img;
move_uploaded_file($_FILES['img']['tmp_name'], $path);
$file1 = $_FILES['file']['name'];
$file = preg_replace('/[^a-zA-Z0-9_.]/', '', $file1);
$path1 = "upload/calender/pdf/".time().$file;
move_uploaded_file($_FILES['file']['tmp_name'], $path1);
if (!$cal_id) {
if ($img) {
if($file){
$query = "insert into calender (title,image,file)values('$title','$path','$path1')";
}else{
$query = "insert into calender (title,image)values('$title','$path')";
}
}else{
if($file){
$query = "insert into calender (title,file)values('$title','$path1')";
}else{
$query = "insert into calender (title)values('$title')";
}
}
$result = $db->query($query);
}
if ($cal_id) {
if ($img) {
if($file){
$query = "update calender set title='$title',image='$path',file='$path1' where cal_id='$cal_id'";
}else{
$query = "update calender set title='$title',image='$path' where cal_id='$cal_id'";
}
} else {
if($file){
$query = "update calender set title='$title',file='$path1' where cal_id='$cal_id'";
}else{
$query = "update calender set title='$title' where cal_id='$cal_id'";
}
}
$result = $db->query($query);
}
if ($result)
header('location:scheduler.php?err=1');
else
header('location:scheduler.php?err=2');
}
// <--End Code-->
// <--Delete Query-->
if (isset($_GET['did'])) {
$did = $_GET['did'];
if ($did) {
$query = "delete from calender where cal_id='$did'";
$result = $db->query($query);
if ($result)
header('location:scheduler.php?err=1');
else
header('location:scheduler.php?err=2');
}
}
// <--End Code-->
// <--main Page-->
include('header.php');
if (isset($_GET['err'])) {
$msg = $_GET['err'];
if ($msg == 1) {
?>
<div class="alert alert-success">
<h4>Success!</h4>
You successfully Submitted.
</div>
<?php
}
if ($msg == 2) {
?>
<div class="alert alert-error">
<h4>Fail!</h4>
Not submitted Successfully.
</div>
<?php
}
}
// <--Edit Query-->
if (isset($_GET['cid'])) {
$cid = $_GET['cid'];
if ($cid) {
$res = $db->get_row("select * from calender where cal_id='$cid'");
}
}
// <--End Code-->
?>
<form id="validation" action="scheduler.php" method="POST" enctype="multipart/form-data">
<div class="row-fluid">
<div class="span6">
<div class="head">
<div class="isw-list"></div>
<h1>Calender</h1>
<div class="clear"></div>
</div>
<div class="block-fluid">
<div>
<div class="span3"></div>
<div class="span9">
<input type="hidden" name="cal_id" value="<?php global $res;
if ($res) {
echo $res->cal_id;
} else {
echo "";
} ?>" />
</div>
</div>
<div class="row-form">
<div class="span3">Title of Calender</div>
<div class="span9">
<input type='text' name='title' value='<?php global $res;
if ($res) {
echo $res->title;
} else {
echo "";
} ?>' id='user' class='validate[required]'>
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span3">Display Image:</div>
<div class="span9">
<input type='file' name='img' />
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span3">Pdf Link:</div>
<div class="span9">
<input type='file' name='file' />
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span9">
<input value="Submit" type="submit" name="submit" id="user"/>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</form>
<div class="span6">
<div class="head">
<div class="isw-target"></div>
<h1>Calender</h1>
<div class="clear"></div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="head">
<div class="clear"></div>
</div>
<div class="block-fluid table-sorting">
<table cellpadding="0" cellspacing="0" width="100%" class="table" id="tSortable_cl">
<thead>
<tr>
<th width="">id</th>
<th width="">Title</th>
<th width="">Image</th>
<th width="">Edit</th>
<th width="">Delete</th>
</tr></thead><tbody>
<?php
include('config.php');
$result = $db->get_results("select * from calender");
if ($result) {
foreach ($result as $res) {
$id = $res->cal_id;
echo"
<tr>
<td>$res->cal_id</td>
<td>$res->title</td>
<td><img src='$res->image' style='width:50px; height:50px' ></td>
<td><a href='scheduler.php?cid=$id'><img src='img/b_edit.png'/></a></td>
<td><a href='scheduler.php?did=$id' class='confirm'><img src='img/b_drop.png'/></a></td>
</tr>";
}
}
?>
</tbody></table>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
</form>
<script>
$(document).ready(function () {
$("#tSortable_cl").dataTable({"iDisplayLength": 5, "aLengthMenu": [5,10,15,25], "sPaginationType": "full_numbers"});
$(".confirm").easyconfirm();
$("#alert").click(function () {
alert("You approved the action");
});
});
</script>
<?php include('footer.php'); ?>