Файл: spuff.ru/codes/index.php
Строк: 84
<?php
$title = 'Полезные куски кода';
require_once '../includes/sys.php';
require_once '../includes/header.php';
$type = 'blogs';
switch ($act) {
default:
echo '<div class="title"><b>Полезные куски кода</b>';
echo '</div>';
if ($u['id']){
echo'<div class="rega"><b><a href="add.php">Добавить код</a></b></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="raz"><image src="../images/page_white_code.png" alt="arrow_down" /> <a href="index.php?act=cat&id='.$cat['id'].'">'.$cat['name'].'</a> <b>('.$blogs.') '.$blogs_new2.'</b></div>';
}
} else {
echo '<div class="body">Разделы не созданы</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="?"><b>Полезные куски кода</b></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="raz">';
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 '<image src="../images/ups.png" alt="arrow_down" /> <a href="?act=view&id='.$blog['id'].'">'.$blog['name'].'</a> ('.date('d.m.y, H:i', $blog['time']).')';
if ($blog['time'] > (TIME - 86400)) {
echo '</b>';
}
echo '</div>';
}
} else {
echo '<div class="body">Раздел пуст</div>';
}
echo '<div class="">';
navig($page, '?act=cat&id='.$id.'&', $pages);
} 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"><font color="black"><a href="?act=cat&id='.$blog['id_cat'].'">'.$cat['name'].'</a>» '.$blog['name'];
if (access(2)) {
echo ' (<a href="add.php?act=note_edit&id='.$blog['id'].'">ред</a>';
if (access(3)) {
echo ', <a href="add.php?act=note_del&id='.$blog['id'].'">del</a></font>';
}
echo ')';
}
echo '</div>';
echo '<div class="lst"><b>Описание:</b><br/>'.bb($blog['opisanie']).'</div>';
echo '</div><div class="lst">';
echo '<b>Код:<br/></b>';
echo nl2br('<code>'.$blog['text'].'</code>').'</div>';
echo '<div class="raz"><b>Добавил:</b> <a href="../other/profile.php?id='.$blog['id_user'].'">'.username($blog['id_user'],2).'</a> ('.date('d.m.y, H:i', $blog['time']).')<br /></div>';
echo '<b><div class="raz">Рейтинг:</b> <b> ('.$blog['rating'].')</b>'; if ($u['id'] != 0){echo '<a href="?act=rate&id='.$blog['id'].'"><font color="red">-1</font></a>/<a href="?act=rate&id='.$blog['id'].'&ok=1""><font color="green">+1 </font></a>';} echo '</div>';
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs_comm` WHERE `id_blogs` = '$blog[id]'"), 0);
echo '<div class="raz"><a href="?act=comm&id='.$blog['id'].'"><b>Комментарии</b></a> ('.$comm.')<br /></div>';
echo '<div class="raz"><a href="?act=copy&id='.$blog['id'].'">Копировать код</a></div>';
echo '<div class="raz"><b>Скопировать ссылку:</b><br /><input name="copy_link" type="text" value="'.HTTPHOME.'/codes/?act=view&id='.$blog['id'].'" /><br />';
echo '<b>BB-код для форума:</b><br/><input name="bb_code" type="text" value="[url='.HTTPHOME.'/codes/?act=view&id='.$blog['id'].']'.$blog['name'].'[/url]" /></div>';
} else {
redirect('?');
}
break;
case 'copy':
$code=mysql_fetch_assoc(mysql_query("SELECT * FROM `blogs` WHERE `id` ='$id'"));
if ($code['id']){
echo '<div class="title"><a href="?act=view&id='.$code['id'].'">'.$code['name'].'</a> » Копировать код</div>';
echo '<div class="raz"><b>Скопировать код:</b><br/><input type="text" value="'.$code['text'].'"></div>';
}
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';
?>