<?php
session_start();
include ('../config.php');
include ('secureadmin.php');
include ('paginator.php');
$sitequery = 'select * from settings;';
$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
$siteinfo = mysql_fetch_array($siteresult);
$sitetitle = $siteinfo['title'];
$siteurl = $siteinfo['url'];
$adminquery = 'select * from admins;';
$adminresults = mysql_query($adminquery,$connection) or die(mysql_error());
$admininfo = mysql_fetch_array($adminresults);
$adminemail = $admininfo['email'];
require_once ('../comments/classes/DB.class.php');
/* DB config */
$db_config = array("db_name" => $db_name,
"db_user" => $dbusername,
"db_pass" => $dbpassword,
"db_host" => $server );
$db = new DB($db_config);
$db->connect();
if ($_GET['switcher'] == "off") {
$sql = "UPDATE `settings` SET commentmod = 1";
$query = mysql_query($sql);
}
if ($_GET['switcher'] == "on") {
$sql = "UPDATE `settings` SET commentmod = 0";
$query = mysql_query($sql);
}
/* Check if the form has been submitted */
if(isset($_POST['accion'])){
/* Setup some variables/arrays */
$action['result'] = null;
$comments = $_POST['comment'];
/* Quick/simple validation */
if(empty($comments))
$action['result'] = 'error';
if($action['result'] != 'error'){
$n = count($comments);
for($i=0; $i < $n; $i++)
{
/* Delete the comment */
mysql_query("DELETE FROM comments WHERE id = '".$comments[$i]."'");
}
}
}
$metatitle = "Comments to Review - Admin Control Panel";
include ('includes/document_head.php');
?>
<div id="wrapper">
<?php include 'includes/topbar.php'?>
<?php include 'includes/sidebar.php'?>
<div class="main_container container_16 clearfix">
<?php
// Setup pagination controls
$rowsquery = "SELECT * FROM comments WHERE accepted = true ORDER BY created_at DESC";
$rowsresults = mysql_query($rowsquery,$connection) or die(mysql_error());
$rows_results = mysql_num_rows($rowsresults);
$pages = new Paginator;
$pages->urlparam = "?";
$pages->items_total = $rows_results;
$pages->mid_range = 9;
$pages->paginate();
if ($pages->items_total) {
$query = "SELECT * FROM comments WHERE accepted = true ORDER BY created_at DESC ".$pages->limit;
} else {
$query = "SELECT * FROM comments WHERE accepted = true ORDER BY created_at DESC";
}
$articleresults = mysql_query($query,$connection) or die(mysql_error());
$num_results = mysql_num_rows($articleresults);
// for display of page #
$pagenum = $_GET['page'];
if (!$pagenum)
$pagenum = 1;
?>
<div class="flat_area grid_16">
<h2>Active Comments</h2>
<p>These comments are currently displaying across your directory.</p>
<p><b>HINT:</b> Hover your mouse over the comment excerpt to view the full comment text</p>
<?php
if ($commentmod == 0) { ?>
<p><a style="text-decoration: underline;" href="comments.php?switcher=off"><b>Turn OFF Comment Moderation</b></a> -- Comments are currently setup to be reviewed before they're activated.</p>
<?php } else { ?>
<p><a style="text-decoration: underline;" href="comments.php?switcher=on"><b>Turn ON Comment Moderation</b></a> -- Comments are currently setup to go live without admin review.</p>
<?php } ?>
<br/>
<form action="" method="post">
<table width="100%" class="listing">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Author</th>
<th>Excerpt</th>
<th>Post</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($articleresults)) {
?>
<tr id="comment<?php echo $row['id'] ?>">
<td valign="top"><input type="checkbox" name="comment[]" value="<?php echo $row['id'] ?>" /></td>
<td valign="top"><?php echo date('F j, Y', strtotime($row['created_at'])) ?></td>
<td valign="top"><a href="mailto:<?php echo $row['email'] ?>"><?php echo $row['author'] ?></a></td>
<td><?php $removeitems = array("<p>", "</p>", "<div>", "</div>");// keep listings clean of unclosed tags
$excerpt = $row['comment'];
echo "<span title=\"".str_replace($removeitems, "", $excerpt)."\">".str_replace($removeitems, "", substr($excerpt, 0 , 45))."</span>"; ?></td>
<?php $titlequery = "select * from articles where id=".$row['post_id'];
$titleresult = mysql_query($titlequery,$connection) or die(mysql_error());
$titleinfo = mysql_fetch_assoc($titleresult);?>
<td valign="top"><a href="<?php echo $siteurl; ?>/article.php?id=<?php echo $row['post_id']; ?>"><?php echo $titleinfo['title'] ?></a></td>
</tr>
<?php } ?>
</tbody>
</table>
<br/>
<?php
//display pagination
echo "<div style=\"float:right; font-weight: bold;\"> (Page ".$pagenum.") ".$pages->display_pages()."</div><br/>";
?>
<div class="bulk-actions">
<input type="submit" value="Delete Selected" name="accion" class="button_colour round_all" />
</div>
</form>
</div>
<?php include 'includes/closing_items.php'?>