| 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/admin/ |
| Current File : /home/udaipurk/public_html/websites/samaj/samaj/admin/article.php |
<?php
include('../config.php');
if (isset($_POST['submit'])) {
$a_id = $_POST['a_id'];
$am_id = $_POST['am_id'];
$title = $_POST['title'];
$short_des = $_POST['short_des'];
$long_des = $_POST['long_des'];
$rdate = date("d-m-Y");
$img = $_FILES['img']['name'];
if ($img) {
$path = "article/" . time() . $img;
move_uploaded_file($_FILES['img']['tmp_name'], $path);
} else {
$path = "article/no-image.png";
}
if (!$a_id) {
$query = mysqli_query($link,"INSERT INTO article (am_id,title,short_des,long_des,rdate,photo) VALUES ('$am_id','$title','$short_des','$long_des','$rdate','$path')");
}
if ($a_id) {
if ($img) {
$query = mysqli_query($link,"update article set am_id='$am_id',title='$title',short_des='$short_des',long_des='$long_des',photo='$path' where a_id='$a_id'");
} else {
$query = mysqli_query($link,"update article set am_id='$am_id',title='$title',short_des='$short_des',long_des='$long_des' where a_id='$a_id'");
}
}
if ($query) {
header("location:article.php?err=1");
} else {
header("location:article.php?err=2");
}
}
// <--Delete Query-->
if (isset($_GET['did'])) {
$did = $_GET['did'];
$query = "delete from article where a_id='$did'";
$result = mysqli_query($link,$query);
if ($result)
header('location:article.php?err=1');
else
header('location:article.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
}
}
if (isset($_GET['cid'])) {
$cid = $_GET['cid'];
$query = "select * from article where a_id='$cid'";
$res = mysqli_query($link,$query);
$row = mysqli_fetch_array($res);
global $row;
}
$query_id= "select a_id,title,am_id from article where am_id = 0";
$res_id = mysqli_query($link,$query_id);
//$getid = mysqli_fetch_row($res_id);
/*Modified on 09/12/2015 by Raj Kumawat*/
//print_r($getid);
// <--End Code-->
?>
<form id="validation" action="article.php" method="POST" enctype="multipart/form-data">
<div class="row-fluid">
<div class="span6">
<div class="head">
<div class="isw-list"></div>
<h1>Add New Article </h1>
<div class="clear"></div>
</div>
<div class="block-fluid">
<input type="hidden" name="a_id" value="<?php global $row; echo $row['a_id']; ?>" />
<div class="row-form">
<div class="span3">Article Name</div>
<div class="span9">
<!--<input type="text" id="sub_title" name="sub_title" value="<?php //global $row; echo $row['sub_title']; ?>" class='validate[required]'>-->
<select id="am_id" name="am_id" value="<?php global $row; echo $row['am_id']; ?>" >
<option value = '0' <?php if($row['am_id'] == 0){ echo "selected = 'selected'";} ?>>New Article</option>
<?php global $row;
while (($getid = mysqli_fetch_row($res_id)) != null)
{
echo "<option value = '{$getid[0]}'";
if ($getid[0] != 0 ){
if ($getid[0] == $row['am_id']) {
echo "selected = 'selected'";
}
}
echo ">{$getid[1]}</option>";
}
?>
</select>
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span3">Article Title</div>
<div class="span9">
<input type="text" id="title" name="title" value="<?php global $row; echo $row['title']; ?>" class='validate[required]'>
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span3">Short Description</div>
<div class="span9">
<input type="text" id="short_des" name="short_des" value="<?php global $row;
echo $row['short_des']; ?>" class='validate[required]'>
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span12">
<div class="head">
<h1>Long Description</h1>
<div class="clear"></div>
</div>
<div class="block-fluid" id="wysiwyg_container">
<textarea id="wysiwyg" name="long_des" style="height: 300px;"><?php global $row;
echo $row['long_des']; ?></textarea>
</div>
</div>
<div class="clear"></div>
</div>
<div class="row-form">
<div class="span3">Article Image:</div>
<div class="span9">
<?php echo "<input type='file' name='img' value='" . $row['photo'] . "' id='user'/>" ?>
</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>Articles</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_r">
<thead>
<tr>
<th width="">id</th>
<th width="">Title</th>
<th width="">Short description</th>
<th width="">Date</th>
<th width="">Image</th>
<th width="">Edit</th>
<th width="">Delete</th>
</tr></thead><tbody>
<?php
include('../config.php');
$query = "select * from article order by a_id desc";
$res = mysqli_query($link,$query);
while ($row = mysqli_fetch_array($res)) {
$id = $row['a_id'];
$s = substr($row['short_des'], 0, 28);
echo"
<tr>
<td>$row[a_id]</td>
<td>$row[title]</td>
<td>$s..</td>
<td>$row[rdate]</td>
<td><img src='$row[photo]' style='width:50px;height:50px'/></td>
<td><a href='article.php?cid=$id'><img src='img/b_edit.png'/></a></td>
<td><a href='article.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>
<script>
$(document).ready(function () {
$(".confirm").easyconfirm();
$("#alert").click(function () {
alert("You approved the action");
});
});
</script>
<?php include('footer.php') ?>