Размер файла: 6.13Kb
<?php
// by Mike O. (mides), coolcms.org
$title = 'Блоги';
require_once '../includes/sys.php';
require_once '../includes/header.php';
$type = 'blogs';
switch ($act) {
default:
echo '<div class="title">Блоги';
if ($u['id']) {
echo ' (<a href="blog.php">написать</a>)';
}
echo '</div><div class="body">';
if ($u['id']) {
echo 'Мои: <a href="index.php?act=my">записи</a>, <a href="index.php?act=comm_by&id='.$u['id'].'">комментарии</a><br />';
}
echo 'Новые: <a href="index.php?act=top&sort=time">записи</a>, <a href="index.php?act=comm_new">комментарии</a></div>';
$cats_r = mysql_query("SELECT * FROM `blogs_cats` ORDER BY `name`");
$mysql_num_rows = mysql_num_rows($cats_r);
if ($mysql_num_rows) {
while ($cat = mysql_fetch_assoc($cats_r)) {
$blogs = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs` WHERE `id_cat` = '$cat[id]'"), 0);
$blogs_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs` WHERE `id_cat` = '$cat[id]' and `time` > '".(time()-86400)."'"), 0);
$blogs_new2 = '';
if ($blogs_new) {
$blogs_new2 = '<span style="color:green">+'.$blogs_new.'</span>';
}
echo '<div class="row"><a href="index.php?act=cat&id='.$cat['id'].'">'.$cat['name'].' ('.$blogs.') '.$blogs_new2.'</a></div>';
}
} else {
echo '<div class="body"><hr>Разделы не созданы<hr></div>';
}
echo '<div class="body"><a href="index.php?act=top">Топ записей</a></div>';
break;
case 'cat':
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `blogs_cats` WHERE `id` = '$id'"));
if ($cat['id']) {
echo '<div class="title"><a href="?">'.$lang['blogs'].'</a>» '.$cat['name'].'</div><div class="list">';
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs` WHERE `id_cat` = '$id'"), 0);
if ($total > 0) {
$pages = ceil($total / $config['onpage']);
if ($page > $pages or $page == 0) {
$page = 1;
}
$begin = ($page - 1) * $config['onpage'];
$blogs_r = mysql_query("SELECT * FROM `blogs` WHERE `id_cat` = '$id' ORDER BY `time` DESC LIMIT $begin, $config[onpage]");
while ($blog = mysql_fetch_assoc($blogs_r)) {
echo '<div class="row">';
if ($blog['time'] > (TIME - 86400)) {
echo '<b>';
}
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs_comm` WHERE `id_blogs` = '$blog[id]'"), 0);
echo '<a href="?act=view&id='.$blog['id'].'">'.$blog['name'].' ('.date('d.m.y, H:i', $blog['time']).')<br />'.$lang['comments'].': '.$comm.'<br /></a>';
if ($blog['time'] > (TIME - 86400)) {
echo '</b>';
}
echo '</div>';
}
} else {
echo $lang['there_is_nothing_yet'];
}
echo '<div class="body">';
navig($page, '?act=cat&id='.$id.'&', $pages);
echo '<a href="?">'.$lang['blogs'].'</a>» '.$cat['name'].'</div>';
} else {
redirect('?');
}
break;
case 'view':
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `blogs` WHERE `id` = '$id'"));
if ($blog['id']) {
$cat = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `blogs_cats` WHERE `id` = '$blog[id_cat]'"));
echo '<div class="title"><a href="?act=cat&id='.$blog['id_cat'].'">'.$cat['name'].'</a>» '.$blog['name'];
if (access(2)) {
echo ' (<a href="blog.php?act=note_edit&id='.$blog['id'].'">ред</a>';
if (access(3)) {
echo ', <a href="blog.php?act=note_del&id='.$blog['id'].'">del</a>';
}
echo ')';
}
echo '</div><div class="body">';
echo bb($blog['text']).'<br />';
echo '<br />'.$lang['composed_by'].': <a href="../other/profile.php?id='.$blog['id_user'].'">'.username($blog['id_user'], 2).'</a> ('.date('d.m.y, H:i', $blog['time']).')<br />';
echo 'Рейтинг: <a href="?act=rate&id='.$blog['id'].'"><image src="../images/arrow_down.png" alt="arrow_down" /></a><b>'.$blog['rating'].'</b><a href="?act=rate&id='.$blog['id'].'&ok=1""><image src="../images/arrow_up.png" alt="arrow_up" /></a><br />';
$seen_r = mysql_query("SELECT `id` FROM `seen` WHERE `type` = 'blog' AND `id_data` = '$blog[id]' AND `id_user` = '$u[id]'");
if (!mysql_num_rows($seen_r)) {
mysql_query("INSERT INTO `seen` SET `type` = 'blog', `id_data` = '$blog[id]', `id_user` = '$u[id]'");
mysql_query("UPDATE `blogs` SET `views` = (`views`+1) WHERE `id` = '$blog[id]'");
}
echo 'Просмотров: '.$blog['seen'].'<br />';
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs_comm` WHERE `id_blogs` = '$blog[id]'"), 0);
echo '<a href="?act=comm&id='.$blog['id'].'">'.$lang['comments'].'</a> ('.$comm.')<br />';
if ($u['id']) echo '<br />'.$lang['copy_link'].':<br /><input name="copy_link" type="text" value="'.HTTPHOME.'/blogs/?act=view&id='.$blog['id'].'" /><br />';
echo $lang['bb_code_forum'].':<br /><input name="bb_code" type="text" value="[url='.HTTPHOME.'/blogs/?act=view&id='.$blog['id'].']'.$blog['name'].'[/url]" /><br />';
echo '<br /><a href="?act=cat&id='.$blog['id_cat'].'">'.$cat['name'].'</a>» '.$blog['name'].'</div>';
} else {
redirect('?');
}
break;
case 'rate':
require_once '../includes/rate.php';
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 'comm_by':
require_once '../includes/comm_by.php';
break;
case 'comm_new':
require_once '../includes/comm_new.php';
break;
case 'top':
require_once '../includes/top.php';
break;
case 'my':
require_once '../includes/my.php';
break;
}
require_once '../includes/tail.php';
?>