| 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.php1 |
<?php
include('../config.php');
if(isset($_POST['sub']))
{
extract($_POST);
if(isset($_FILES['support_images']['name']))
{
$file_name_all="";
for($i=0; $i<count($_FILES['support_images']['name']); $i++)
{
$tmpFilePath = $_FILES['support_images']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$path = "article/"; // create folder
$name = $_FILES['support_images']['name'][$i];
$size = $_FILES['support_images']['size'][$i];
list($txt, $ext) = explode(".", $name);
$file= time().substr(str_replace(" ", "_", $txt), 0);
$info = pathinfo($file);
$filename = $file.".".$ext;
if(move_uploaded_file($_FILES['support_images']['tmp_name'][$i], $path.$filename))
{
date_default_timezone_set ("Asia/Calcutta");
$currentdate=date("d M Y");
$file_name_all.=$filename."*";
}
}
}
$filepath = rtrim($file_name_all, '*');
}
else
{
$filepath="";
}
$query=mysqli_query($link,"INSERT into image (`image`) VALUES('".addslashes($filepath)."'); ");
if($query)
{
header("location:".$_SERVER['PHP_SELF']);
}
}
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'/>" ?>
<input type="file" id="file" name="support_images[]" multiple accept="image/*" />
<input type="submit" name="sub" value="Upload!" />
</div>
<div class="clear"></div>
</div>
<?php
$view=mysqli_query($link,"select * from image");
while($row=mysqli_fetch_array($view))
{
$path=explode("*",$row['image']);
$i=count($path);
$file_path = 'article/';
for($j=0;$j<$i;$j++)
{
$src=$file_path.$path[$j];
// $img = $_FILES['img']['name'];
// if ($img) {
// $path = "article/" . time() . $img;
// move_uploaded_file($_FILES['img']['tmp_name'], $path);
// } else {
// $path = "article/no-image.png";
// }
?>
<div style="width:250px; float:left; height:150px; margin-top:20px; border:dashed 2px #0099FF;">
<img src="<?php echo $src; ?>" width="240" height="140">
</div>
<?php } } ?>
<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') ?>