Файл: public_html/admin/manage-articles.php
Строк: 313
<?php
error_reporting(E_ALL);
session_start();
include 'config.php';
echo dbconn();
include_once('pagination.class.php');
if (!isset($_SESSION['autoblg'])) {
header( 'Location: index.php' ) ;
}
if (isset($_GET['res'])) {
unset($_SESSION['autoblg']);
header( 'Location: index.php' ) ;
}
if (isset($_GET['del'])) {
$del = $_GET['del'];
mysql_query("Delete from rssarticles where id ='$del'");
$message = 'Article was successfully deleted';
}
if (isset($_POST['check_list'])) {
foreach($_POST['check_list'] as $checkbox) {
mysql_query("Delete from rssarticles where id ='$checkbox'");
}
$message = 'Articles successfully deleted';
}
if (isset($_POST['edita1'])) {
$edita1 = $_POST['edita1'];
$edita1 = str_replace(" ","-",$edita1);
$edita1 = str_replace(".","",$edita1);
$edita2 = $_POST['edita2'];
$edita3 = $_POST['edita3'];
mysql_query("UPDATE rssarticles set item_title='$edita1', item_content='$edita2' WHERE id='$edita3'");
$message = 'Article was successfully updated';
}
if(isset($_POST['editid'])) {
$editid = $_POST['editid'];
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$extensions = array("jpeg","jpg","png");
if(in_array($file_ext,$extensions )=== false){
$message = 'File Extension Is Not Valid';
}
if($file_size > 2097152) {
$message = 'File Size Is Too Large';
}
if(empty($errors)==true) {
$imagename = mysql_result(mysql_query("SELECT item_image FROM rssarticles WHERE id = '$editid'"), 0);
if ($file_name == '') {
$file_name = $imagename;
} else {
if ($imagename != '') {
//unlink('uploads/'.$imagename.'');
}
$randtime = time();
$file_name = ''.$randtime.'-'.$file_name.'';
}
move_uploaded_file($file_tmp,"uploads/".$file_name);
mysql_query("UPDATE rssarticles set item_image='<img src="admin/uploads/$file_name">' WHERE id='$editid'");
$message = 'Cover image was successfully updated';
}
}
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<title>Autoblog Admin</title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<link href="vendors/easypiechart/jquery.easy-pie-chart.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<link href="assets/demo_table.css" rel="stylesheet" media="screen">
<link href="assets/jquery.dataTables.css" rel="stylesheet" media="screen">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<style>
div.pagination {
padding: 3px;
margin: 3px;
text-align:center;
font-family:Tahoma,Helvetica,sans-serif;
font-size:.85em;
}
div.pagination a {
border: 1px solid #ccdbe4;
margin-right:3px;
padding:2px 8px;
background-position:bottom;
text-decoration: none;
color: #0061de;
}
div.pagination a:hover, div.pagination a:active {
border: 1px solid #2b55af;
background-image:none;
background-color:#3666d4;
color: #fff;
}
div.pagination span.current {
margin-right:3px;
padding:2px 6px;
font-weight: bold;
color: #000;
}
div.pagination span.disabled {
display:none;
}
div.pagination a.next{
border:2px solid #ccdbe4;
margin:0 0 0 10px;
}
div.pagination a.next:hover{
border:2px solid #2b55af;
}
div.pagination a.prev{
border:2px solid #ccdbe4;
margin:0 10px 0 0;
}
div.pagination a.prev:hover{
border:2px solid #2b55af;
}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="home.php">Autoblog Admin</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<li class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-user"></i> Admin <i class="caret"></i>
</a>
<ul class="dropdown-menu">
<li>
<a tabindex="-1" href="?res">Logout</a>
</li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li>
<a href="home.php"><i class="icon-chevron-right"></i> Manage Feeds</a>
</li>
<li class="active">
<a href="manage-articles.php"><i class="icon-chevron-right"></i> Manage Articles</a>
</li>
<li>
<a href="manage-categories.php"><i class="icon-chevron-right"></i> Manage Categories</a>
</li>
<li>
<a href="manage-ads.php"><i class="icon-chevron-right"></i> Manage Ads</a>
</li>
</ul>
</div>
<!--/span-->
<div class="span9" id="content">
<?php if (isset($message)) {
echo '<div class="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
'.$message.'
</div>';
}?>
<?php if (isset($_GET["success"])) { $success = $_GET["success"];?>
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
Article Updated!
</div>
<?php } ?>
<div class="row-fluid">
<div class="span5">
<form method="POST" class="form-search">
<input type="text" name="searchfeeds" class="input-medium search-query" value="<?php if (isset($_POST["searchfeeds"])) { echo $_POST["searchfeeds"]; } ?>">
<button type="submit" class="btn">Search Articles</button>
</form>
</div>
<div class="span1"> </div>
<div class="span3"> </div>
</div>
<div class="row-fluid">
<?php
$rss_sql=mysql_query("Select * from rssarticles");
$rss_count=mysql_num_rows($rss_sql);
if($rss_count==0)
{
?>
<div class="alert">
<strong>There are no categories to display yet! You can add one <a href="home.php">HERE</a></strong>
</div>
<?php } else { ?>
<form method="POST">
<table class="table table-bordered" id="example">
<thead>
<tr>
<th></th>
<th>Posted</th>
<th>Title</th>
<th>Status</th>
<th>Cover Photo</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
<?php
$items = 10;
$page = 1;
if(isset($_GET['page']) and is_numeric($_GET['page']) and $page = $_GET['page'])
$limit = " LIMIT ".(($page-1)*$items).",$items";
else
$limit = " LIMIT $items";
if (isset($_POST["searchfeeds"])) {
$feedsearch = $_POST["searchfeeds"];
$sqlStr = "SELECT * FROM rssarticles WHERE item_title LIKE '%$feedsearch%'";
$sqlStrAux = "SELECT count(*) as total FROM rssarticles WHERE item_title LIKE '%$feedsearch%'";
} else {
$sqlStr = "SELECT * FROM rssarticles ORDER BY id DESC";
$sqlStrAux = "SELECT count(*) as total FROM rssarticles";
}
$aux = Mysql_Fetch_Assoc(mysql_query($sqlStrAux));
$query = mysql_query($sqlStr.$limit);
if($aux['total']>0){
$p = new pagination;
$p->Items($aux['total']);
$p->limit($items);
$p->currentPage($page);
$p->calculate();
$p->changeClass("pagination");
while($rowfeeds = mysql_fetch_assoc($query)){
$idd = $rowfeeds["id"];
?>
<tr>
<td><input type="checkbox" class="check_list" name="check_list[]" value="<?php echo $rowfeeds["id"] ?>" /></td>
<td><?php echo $rowfeeds["item_date"] ?></td>
<td><?php echo str_replace("-"," ",$rowfeeds["item_title"]); ?></td>
<?php if ($rowfeeds["item_status"] == '1') { ?>
<td>Active</td>
<?php } else { ?>
<td>In-Active : No cover photo</td>
<?php } ?>
<?php if ($rowfeeds["item_image"] == '') { ?>
<td style="color:red">No Cover Photo</td>
<?php } else { ?>
<td style="color:green">Image Present</td>
<?php } ?>
<td style="width:25%"><a href="#edit-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-primary" data-toggle="modal" type="button">Edit Photo</a> <a href="#myModal-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-info" data-toggle="modal" type="button">Edit Article</a> <a href="?del=<?php echo $rowfeeds["id"] ?>" onclick="javascript:return confirm('Are you sure you want to delete this?')" class="btn btn-small btn-danger" type="button">Delete</a></td>
</tr>
<!-- EDIT ARTICLE -->
<div id="myModal-<?php echo $rowfeeds["id"] ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
<h3 id="myModalLabel">Edit Article</h3>
</div>
<div class="modal-body">
<form method="POST">
<fieldset>
<label>Article Title</label>
<input style="display:none" type="text" name="edita3" value="<?php echo $rowfeeds["id"] ?>">
<input type="text" name="edita1" value="<?php echo str_replace("-"," ",$rowfeeds["item_title"]); ?>">
</fieldset>
<fieldset>
<label>Article Content</label>
<textarea id="area1" style="width:250px" name="edita2"><?php echo $rowfeeds["item_content"] ?></textarea>
</fieldset>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" onclick="nicEditors.findEditor('area1').saveContent();">Edit Article</button>
</form>
</div>
</div>
<!-- EDIT ARTICLE END -->
<!-- ADD PHOTO -->
<div id="edit-<?php echo $rowfeeds["id"] ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
<h3 id="myModalLabel">Add Cover Photo</h3>
</div>
<div class="modal-body">
<form method="POST" enctype="multipart/form-data">
<fieldset>
<label>Cover Photo</label>
<input style="display:none" type="text" name="editid" value="<?php echo $rowfeeds["id"] ?>">
<input type="file" name="image" id="image">
</fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Add Cover Photo</button>
</form>
</div>
</div>
<!-- ADD PHOTO END -->
<?php } ?>
</tbody>
</table>
<button class="btn btn-info btn-block delbtn" id="delbtn" type="submit" onclick="javascript:return confirm('Are you sure you want to delete these articles?')">Delete Multiple Articles</button>
</form>
<?php
$p->show();
} else {
echo"There are no articles to display";
}
?>
<?php } ?>
</div>
</div>
</div>
<hr>
<footer>
<p>© <a href="http://wm-scripts.ru">Готовые сайты</a></p>
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="assets/scripts.js"></script>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
<script>
$('.delbtn').prop('disabled', true);
$('.check_list').change(function(){
$('.delbtn').prop('disabled', $('.check_list:checked').length == 0);
});
</script>
</body>
</html>