Файл: public_html/admin/manage-categories.php
Строк: 170
<?php
error_reporting(E_ALL);
session_start();
include 'config.php';
echo dbconn();
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'];
$catname = mysql_result(mysql_query("SELECT cat FROM cats WHERE id = '$del'"), 0);
mysql_query("Delete from cats where id ='$del'");
mysql_query("Delete from rssarticles where item_category_id ='$catname'");
$message = 'Category was successfully deleted';
}
if (isset($_POST['cattitle'])) {
$cattitle = $_POST['cattitle'];
mysql_query("INSERT INTO cats (cat) VALUES('$cattitle')");
$message = 'Category was successfully created';
}
if (isset($_POST['editid'])) {
$efeedtitle = $_POST['edittitle'];
$efeedid = $_POST['editid'];
$catname = mysql_result(mysql_query("SELECT cat FROM cats WHERE id = '$efeedid'"), 0);
mysql_query("UPDATE cats set cat='$efeedtitle' WHERE id='$efeedid'");
mysql_query("UPDATE rssarticles set item_category_id='$efeedtitle' WHERE item_category_id='$catname'");
$message = 'Category 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>
</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>
<a href="manage-articles.php"><i class="icon-chevron-right"></i> Manage Articles</a>
</li>
<li class="active">
<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>';
}?>
<div class="row-fluid">
<?php
$rss_sql=mysql_query("Select * from cats");
$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="#addfeed" role="button" class="btn" data-toggle="modal">HERE</a></strong>
</div>
<?php } else { ?>
<a style="margin-bottom:20px" href="#addfeed" class="btn btn-success btn-small pull-right" data-toggle="modal" type="button">Add Category</a>
<table class="table table-bordered" id="example">
<thead>
<tr>
<th>Category</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
<?php
$resultrss = mysql_query("SELECT * FROM cats ORDER BY cat");
while($rowfeeds = mysql_fetch_array( $resultrss )) { ?>
<tr>
<td><?php echo $rowfeeds["cat"] ?></td>
<td style="width:15%"><a href="#edit-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-primary" data-toggle="modal" type="button">Edit</a> <a href="?del=<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-danger" onclick="javascript:return confirm('Are you sure you want to delete this?')" type="button">Delete</a></td>
</tr>
<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">×</button>
<h3 id="myModalLabel">Edit Cat</h3>
</div>
<div class="modal-body">
<form method="POST">
<fieldset>
<label>Category</label>
<input style="display:none" type="text" name="editid" value="<?php echo $rowfeeds["id"] ?>">
<input type="text" name="edittitle" value="<?php echo $rowfeeds["cat"] ?>">
</fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Edit Category</button>
</form>
</div>
</div>
<?php } ?>
</tbody>
</table>
<?php } ?>
</div>
<div id="addfeed" 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 A New Category</h3>
</div>
<div class="modal-body">
<form method="POST">
<fieldset>
<label>Category Name</label>
<input type="text" name="cattitle" placeholder="">
</fieldset>
<fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Add Category</button>
</fieldset>
</form>
</div>
</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="assets/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#example').dataTable();
} );
</script>
</body>
</html>