File: /home/httpd/html/nyloncams.com/public_html/admin/user_comments.php
<?
require "db.php";
if (!is_numeric($_GET['id'])) {
exit();
}
$id = (int) $_GET['id'];
if ($_POST['list']) {
foreach ($_POST['list'] as $i) {
if (is_numeric($i)) {
dbQuery("DELETE FROM `comments` WHERE `record_num` = '$i' AND `userid` = '$id'");
}
}
}
$row = dbrow("SELECT * FROM `users` WHERE `record_num` = '$id'");
$page = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 1;
$max_results = (isset($_GET['setmax']) && $_GET['setmax'] > 0) ? (int) $_GET['setmax'] : 100;
$from = ($page * $max_results) - $max_results;
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="user_comments.php?id=<? echo $row['record_num']; ?>">Latest Comments - <? echo $row['username']; ?></a></span>
</div>
</div>
<div class="content-outer">
<h2>User<strong>Comments - <? echo $row['username']; ?></strong></h2>
<div class="notification info">This page contains the most recent comments posted on your site by <? echo $row['username']; ?></div>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" class="form" novalidate autocomplete="off">
<?
$result_count = dbValue("SELECT COUNT(*) FROM `comments` WHERE `userid` = '$id'",false);
$result = dbQuery("SELECT `comments`.*, `content`.`title`, `content`.`record_num` AS `contrec` FROM `comments`, `content` WHERE `comments`.`content` = `content`.`record_num` AND `comments`.`userid` = '$id' ORDER BY `timestamp` DESC LIMIT $from, $max_results",false);
$total_results = count($result_count);
$total_pages = ceil($total_results / $max_results);
?>
<table class="pagetable">
<thead>
<tr>
<th>Name</td>
<th>Video</td>
<th>Comment</td>
<th></td>
<th style="width:50px">
<label for="check-select-all-1" class="checkbox">
<input type="checkbox" name="select_all" value="1" data-items="list[]" id="check-select-all-1">
<i></i>
</label>
</th>
</tr>
</thead>
<tbody>
<? if (count($result) == 0) { ?>
<tr><td colspan="5"><div class="notification alert">No comments found</div></td></tr>
<? } else { ?>
<? foreach($result as $row) { ?>
<tr>
<td><? echo $row['name']; ?></td>
<td><a href="edit_content.php?id=<? echo $row['contrec']; ?>"><? echo strlen($row['title']) > 25 ? substr($row['title'], 0, 25) . "..." : $row['title']; ?></a></td>
<td><? echo $row['comment']; ?></td>
<td class="options">
<a href="edit_comment.php?id=<? echo $row['record_num']; ?>" class="btn btn-xs btn-orange" title="Edit comment"><i class="ion ion-edit icon-edit"></i></a>
</td>
<td>
<label class="checkbox">
<input type="checkbox" name="list[]" value="<? echo $row['record_num']; ?>" id="ids-<? echo $row['record_num']; ?>"><i></i>
</label>
</td>
</tr>
<? } ?>
<? } ?>
<tr class="item submit">
<td colspan="5">
<? if (count($result) > 0) { ?>
<button type="submit" class="btn action-delete">Delete Selected</button>
<? } ?>
</td>
</tr>
</tbody>
</table>
</form>
<div id="adminPagination"><?php echo showAdminPagination($total_pages); ?></div>
</div>
</div>
</div>
<? require "footer.php"; ?>