File size: 4.42Kb
<?php
// by Mike O. (mides), coolcms.org
$title = 'Новости';
require_once '../includes/sys.php';
require_once '../includes/header.php';
$type = 'news';
switch ($act) {
default:
echo '<div class="title">'.$lang['news'].'</div><div class="body">';
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news`"), 0);
if ($total > 0) {
$pages = ceil($total / $config['onpage']);
if ($page > $pages or $page == 0) {
$page = 1;
}
$begin = ($page - 1) * $config['onpage'];
$news_r = mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT $begin, $config[onpage]");
while ($news = mysql_fetch_assoc($news_r)) {
if (!isset($num) ) $num = 1;
$num++;
$row_class = (!($num % 2)) ? 'row1' : 'row2';
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news_comm` WHERE `id_news` = '$news[id]'"), 0);
echo '<a href="index.php?act=view&id='.$news['id'].'"><b>'.$news['name'].'</b></a>: '.ccdate($news['time']).'<br />'.bb($news['text']).'<br /><a href="index.php?act=comm&id='.$news['id'].'">'.$lang['comments'].'</a> ('.$comm.')<hr>';
}
navig($page, '?', $pages);
}
echo '</div>';
break;
case 'comm':
require_once '../includes/comm.php';
break;
case 'comm_add':
require_once '../includes/comm_add.php';
break;
case 'comm_reply':
require_once '../includes/comm_reply.php';
break;
case 'comm_edit':
require_once '../includes/comm_edit.php';
break;
case 'comm_del':
require_once '../includes/comm_del.php';
break;
case 'view':
$news_r = mysql_query("SELECT * FROM `news` WHERE `id` = '$id'");
$news = mysql_fetch_assoc($news_r);
if ($news['id']) {
tp($news['name'].': '.ccdate($news['time'], 0));
echo '<div class="body">';
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news_comm` WHERE `id_news` = '$id'"), 0);
echo bb($news['text']).'<br /><a href="index.php?act=comm&id='.$news['id'].'">'.$lang['all_comments'].'</a> ('.$comm.')';
// comments
echo '</div><div class="title"><i>'.$lang['recent_comments'].'</i></div><div class="body">';
$count_comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news_comm` WHERE `id_news` = '$id'"), 0);
if ($count_comm > 0) {
$comm_r = mysql_query("SELECT * FROM `news_comm` WHERE `id_news` = '$id' ORDER BY `time` DESC LIMIT 5");
while ($comm = mysql_fetch_assoc($comm_r)) {
if (!isset($num) ) $num = 1;
$num++;
$row_class = (!($num % 2)) ? 'row1' : 'row2';
//echo '<div class="'.$row_class.'">';
echo '<a href="../other/profile.php?id='.$comm['id_user'].'">'.username($comm['id_user'], 2).'</a> '.ccdate($comm['time'], $comm['id_user']).' <a href="?act=comm_reply&id='.$comm['id'].'">'.$lang['re'].'</a>';
if ($u['access'] > 0 or $u['id'] and $u['id'] == $comm['id_user'] and time() - $comm['time'] < $config['edit_time']) echo '|<a href="?act=comm_edit&id='.$comm['id'].'">'.$lang['edit'].'</a>';
if ($u['access'] > 0) echo '|<a href="?act=comm_del&id='.$comm['id'].'">DEL</a>';
echo '<br />'.bb($comm['text']);
if ($comm['edit_by']) echo '<br />_______<br /><span style="font-size: 10px;">'.$lang['edited_by'].': '.username($comm['edit_by'], 0).' ('.ccdate($comm['edit_time'], 0).' )</span>';
echo '<hr>';
}
} else {
echo $lang['no_comments_yet'];
}
if ($u['id']) {
echo '
<form name="form" action="?act=comm_add&id='.$id.'" method="post">
'.bbpanel('form', 'text').'<textarea name="text" cols="" rows="3"></textarea>';
echo '<input name="" type="submit" value="Ok">
</form>
<br />';
}
echo '<a href="?">Новости</a>» '.$news['name'].'</div>';
} else {
redirect('?');
}
break;
}
require_once '../includes/tail.php';
?>