Файл: public_html/admin/manage-ads.php
Строк: 330
<?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'];
$adtype = mysql_result(mysql_query("SELECT type FROM ads WHERE id = '$del'"), 0);
if ($adtype == '2') {
$imagename = mysql_result(mysql_query("SELECT image FROM ads WHERE id = '$del'"), 0);
unlink('uploads/'.$imagename.'');
mysql_query("Delete from ads where id ='$del'");
$message = 'Ad was successfully deleted';
} else {
mysql_query("Delete from ads where id ='$del'");
$message = 'Ad was successfully deleted';
}
}
// ADD NEW IMAGE AD
if(isset($_POST['iadadd1'])) {
$iadadd1 = $_POST['iadadd1'];
$iadadd3 = $_POST['iadadd3'];
$iadadd4 = $_POST['iadadd4'];
$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) {
$randtime = time();
$file_name = ''.$randtime.'-'.$file_name.'';
move_uploaded_file($file_tmp,"uploads/".$file_name);
mysql_query("INSERT INTO ads (type, placement, image, title, link) VALUES('2', '$iadadd1', '$file_name', '$iadadd3', '$iadadd4')");
$message = 'Image ad successfully added';
}
}
// ADD NEW IMAGE AD END
// EDIT IMAGE AD
if(isset($_POST['eiadadd1'])) {
$eiadadd1 = $_POST['eiadadd1'];
$eiadadd2 = $_POST['eiadadd2'];
$eiadadd3 = $_POST['eiadadd3'];
$eiadadd4 = $_POST['eiadadd4'];
$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 image FROM ads WHERE id = '$eiadadd2'"), 0);
if ($file_name == '') {
$file_name = $imagename;
} else {
unlink('uploads/'.$imagename.'');
$randtime = time();
$file_name = ''.$randtime.'-'.$file_name.'';
}
move_uploaded_file($file_tmp,"uploads/".$file_name);
mysql_query("UPDATE ads set placement='$eiadadd1', image='$file_name', title='$eiadadd3', link='$eiadadd4' WHERE id='$eiadadd2'");
$message = 'Image ad successfully updated';
}
}
// EDIT IMAGE AD END
if (isset($_POST['adadd1'])) {
$adadd1 = $_POST['adadd1'];
$adadd2 = $_POST['adadd2'];
$adadd3 = $_POST['adadd3'];
mysql_query("INSERT INTO ads (type, placement, code, title) VALUES('1', '$adadd1', '$adadd2', '$adadd3')");
$message = 'Code ad successfully added';
}
if (isset($_POST['eadadd1'])) {
$eadadd1 = $_POST['eadadd1'];
$eadadd2 = $_POST['eadadd2'];
$eadadd3 = $_POST['eadadd3'];
mysql_query("UPDATE ads set placement='$eadadd1', code='$eadadd2' WHERE id='$eadadd3'");
$message = 'Code ad 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>
<a href="manage-categories.php"><i class="icon-chevron-right"></i> Manage Categories</a>
</li>
<li class="active">
<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 ads");
$rss_count=mysql_num_rows($rss_sql);
if($rss_count==0)
{
?>
<div class="alert">
<strong>There are no ads to display yet! You can add a code ad <a href="#addfeed" role="button" class="btn" data-toggle="modal">HERE</a> or a custom image ad <a href="#addfeed2" role="button" class="btn" data-toggle="modal">HERE</a></strong>
</div>
<?php } else { ?>
<a style="margin-bottom:20px;margin-right:20px" href="#addfeed" class="btn btn-success btn-small pull-right" data-toggle="modal" type="button">Add New Code Ad</a> <a style="margin-bottom:20px;margin-right:20px" href="#addfeed2" class="btn btn-info btn-small pull-right" data-toggle="modal" type="button">Add New Image Ad</a>
<table class="table table-bordered" id="example">
<thead>
<tr>
<th>Type</th>
<th>Placement</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
<?php
$resultrss = mysql_query("SELECT * FROM ads");
while($rowfeeds = mysql_fetch_array( $resultrss )) {
?>
<tr>
<?php if ($rowfeeds["type"] == '1') { ?>
<td>Code Block</td>
<?php } else { ?>
<td>Image Ad</td>
<?php } ?>
<?php if ($rowfeeds["placement"] == '1') { ?>
<td>Right Sidebar Of Article Page</td>
<?php } else { ?>
<td>Randomly in articles browse</td>
<?php } ?>
<td style="width:15%">
<?php if ($rowfeeds["type"] == '1') { ?>
<a href="#edit-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-primary" data-toggle="modal" type="button">Edit</a>
<?php } else { ?>
<a href="#editimage-<?php echo $rowfeeds["id"] ?>" class="btn btn-small btn-primary" data-toggle="modal" type="button">Edit</a>
<?php } ?>
<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</button>
</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">X</button>
<h3 id="myModalLabel">Edit Ad</h3>
</div>
<div class="modal-body">
<form method="POST">
<fieldset>
<label>Ad Type</label>
<input style="display:none" type="text" name="eadadd3" value="<?php echo $rowfeeds["id"] ?>">
<select name="eadadd1">
<?php if ($rowfeeds["placement"] == '1') { ?>
<option value="1" selected>On article right bar</option>
<?php } else { ?>
<option value="2" selected>Randomly in articles browse</option>
<?php } ?>
<option value="1">On article right bar</option>
<option value="2">Randomly in articles browse</option>
</select>
</fieldset>
<fieldset>
<label>Ad Code</label>
<textarea name="eadadd2"><?php echo $rowfeeds["code"] ?></textarea>
</fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Edit Ad Space</button>
</form>
</div>
</div>
<div id="editimage-<?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 New Image Ad</h3>
</div>
<div class="modal-body">
<form method="POST" enctype="multipart/form-data">
<fieldset>
<label>Add Placement</label>
<input style="display:none" type="text" name="eiadadd2" value="<?php echo $rowfeeds["id"] ?>">
<select name="eiadadd1">
<?php if ($rowfeeds["placement"] == '1') { ?>
<option value="1" selected>On article right bar</option>
<?php } else { ?>
<option value="2" selected>Randomly in articles browse</option>
<?php } ?>
<option value="1">On article right bar</option>
<option value="2">Randomly in articles browse</option>
</select>
</fieldset>
<fieldset>
<label>Ad Image</label>
<input type="file" name="image" id="image">
<img width="50px" src="uploads/<?php echo $rowfeeds["image"]?>">
</fieldset>
<fieldset>
<label>Ad Title</label>
<input type="text" name="eiadadd3" value="<?php echo $rowfeeds["title"]?>">
</fieldset>
<fieldset>
<label>Ad Link</label>
<input type="text" name="eiadadd4" value="<?php echo $rowfeeds["link"]?>">
</fieldset>
<fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Edit Image Ad Space</button>
</fieldset>
</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 Code Ad</h3>
</div>
<div class="modal-body">
<form method="POST">
<fieldset>
<label>Add Placement</label>
<select name="adadd1">
<option value="1">On article right bar</option>
<option value="2">Randomly in articles browse</option>
</select>
</fieldset>
<fieldset>
<label>Ad Code</label>
<textarea name="adadd2"></textarea>
</fieldset>
<fieldset>
<label>Ad Title</label>
<textarea name="adadd3"></textarea>
</fieldset>
<fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Add Code Ad Space</button>
</fieldset>
</form>
</div>
</div>
<div id="addfeed2" 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 Image Ad</h3>
</div>
<div class="modal-body">
<form method="POST" enctype="multipart/form-data">
<fieldset>
<label>Add Placement</label>
<select name="iadadd1">
<option value="1">On article right bar</option>
<option value="2">Randomly in articles browse</option>
</select>
</fieldset>
<fieldset>
<label>Ad Image</label>
<input type="file" name="image" id="image">
</fieldset>
<fieldset>
<label>Ad Title</label>
<input type="text" name="iadadd3">
</fieldset>
<fieldset>
<label>Ad Link</label>
<input type="text" name="iadadd4">
</fieldset>
<fieldset>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Add Image Ad Space</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>