<?php

// -----------------------------------------------------------------
// tady můžete nastavit práva (1 - 3)
// here you can set the rights (1 - 3)
if ($rights>=1):
// -----------------------------------------------------------------

if ($a=="delete_comment" AND $sql) {
echo "<div class=\"popup-success\">$lang_alert_success</div>";
}

?>

<h2><?php echo($lang_overview); ?></h2>

<table>
<tr>
<th colspan="4" class="table-title"><?php echo($lang_form_last_comments); ?></th>
</tr>
<tr>
<th style="width: 20%;"><?php echo($lang_form_article_title); ?></th>
<th style="width: 15%;">Nick</th>
<th style="width: 50%;">Text</th>
<th style="width: 15%;"><?php echo($lang_form_options); ?></th>
</tr>
<?php

$print=mysql_query("SELECT id, article, author, text, user, added FROM kcms_comments ORDER by added DESC LIMIT 0,3");
while (list($id, $article, $author, $text, $user, $added) = mysql_fetch_row($print)) {

$article=mysql_query("SELECT quick, title, section FROM kcms_articles WHERE id='$article'");
$article=mysql_fetch_array($article);

$section=mysql_query("SELECT quick, name FROM kcms_sections WHERE id='".$article["section"]."'");
$section=mysql_fetch_array($section);

if ($user==1) {

$author=mysql_query("SELECT login FROM kcms_users WHERE id='$author'");
$author=mysql_fetch_array($author);

}

echo "<tr>
<td><a href=\"/".$section["quick"]."/".$article["quick"]."/\" onclick=\"return !openWindow(this.href);\">".$article["title"]."</a> <em>(".$section["name"].")</em></td>
<td>";
if ($user==1) { echo "<a href=\"/profiles/".$author["login"]."/\">".$author["login"]."</a>"; } else { echo (stripslashes($author)); }
echo"</td>
<td>".date("d.m.Y, H:i", $added)."<br /><em>$text</em></td>
<td style=\"text-align: center;\"><input type=\"button\" value=\"$lang_button_delete\" onclick=\"if (!confirm('$lang_alert_sure')) return false; parent.location='./admin.php?a=delete_comment&amp;id=$id';\" /></td>
</tr>\n";

}

?>
</table>

<table>
<tr>
<th colspan="4" class="table-title"><?php echo($lang_form_most_viewed_articles); ?></th>
</tr>
<tr>
<th style="width: 50%;"><?php echo($lang_form_article_title); ?></th>
<th style="width: 15%;"><?php echo($lang_index_viewed); ?></th>
<th style="width: 15%;"><?php echo(ucfirst($lang_index_commented)); ?></th>
<th style="width: 20%;"><?php echo($lang_form_release_date); ?></th>
</tr>
<?php

$print=mysql_query("SELECT id, quick, title, section, views, published FROM kcms_articles WHERE published!='0' ORDER by views DESC LIMIT 0,5");
while (list($id, $quick, $title, $section, $views, $published) = mysql_fetch_row($print)) {

$comments=mysql_query("SELECT COUNT(*) AS id FROM kcms_comments WHERE article='$id'");
$comments=mysql_fetch_array($comments);

$section=mysql_query("SELECT quick, name FROM kcms_sections WHERE id='$section'");
$section=mysql_fetch_array($section);

echo "<tr>
<td><a href=\"/".$section["quick"]."/$quick/\" onclick=\"return !openWindow(this.href);\">$title</a> <em>(".$section["name"].")</em></td>
<td style=\"text-align: right;\">".$views."×</td>
<td style=\"text-align: right;\">".$comments["id"]."×</td>
<td style=\"text-align: right;\">".date("d.m.Y, H:i", $published)."</td>
</tr>\n";

}

?>
</table>

<?php else: $access_denied=1; endif; ?>