Просмотр файла blogs.php

Размер файла: 44.43Kb
<?php

/*

 by don't give me name's
 icq 6146230, [email protected], i-am-dmitry.ru
 Version: 1.2.1
 name: Blogs
 place: blogs.php
 description: скрипт блогов для dcms 6.1 ( 6.x )

*/


include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

include 'blogs_config.php';

$p_str=$set['p_str'];

function head($title = 'Блоги'){
global $set,$user;
$set['title']=$title;
include_once 'sys/inc/thead.php';
title();
err();
aut();
}

function foot(){
global $set,$user,$conf;
include_once 'sys/inc/tfoot.php';
exit;
}


$act = (isset($_GET['act'])) ? htmlspecialchars($_GET['act']) : null;

switch($act) {

case 'see':

$uid = abs((int)$_GET['id']);

$option = mysql_fetch_array(mysql_query("
 select `blogs_title`.*, `user`.`nick`
 from `blogs_title`, `user`
 where `blogs_title`.`uid`='".$uid."' and `user`.`id`='".$uid."' ;"));

if ( empty($option) ) {
header('Location: blogs.php'); exit;
}

if ( !isset($user) && $option['see'] == 1 ) {
head();
echo '<div align="center">Пользователь предпочел закрыть блог от гостей</div>';
foot();
}

$page = ( isset($_GET['p']) ) ? abs((int)$_GET['p']) : 1;
$page = ( $page <= 1 ) ? 1 : $page;
$start = ( $page == 1 ) ? 0 : ($page-1)*$p_str;

$count = mysql_result(mysql_query("select count(`id`) from `blogs` where `uid`='".$uid."';"), 'count');
$all = ceil($count/$p_str);

if ( $page > $all && $all != 0 ) {
header("Location: blogs.php?act=see&id=".$uid."&p=".$all."&SESS=".session_id());
exit;
}

head();

echo '<div style="'.$DIV_STYLE.' text-align: center"><h4>Блог '.$option['nick'].'</h4></div>';
if ( $count != 0 ) {
$rating = mysql_fetch_array(mysql_query("select * from `blogs_rating` where `id_blog`='".$uid."'"));
echo '<div style="'.$DIV_STYLE.'">Рейтинг блога: +'.$rating['plus'].'|-'.$rating['minus'];
}
if ( isset($user) && $_SESSION['id_user'] != $uid && $count != 0 ) {
$test = explode('-', $rating['users']);
if ( !in_array($_SESSION['id_user'], $test) )
echo '<br /><a href="blogs.php?act=blog_up&amp;id='.$uid.'">[+]</a> / 
<a href="blogs.php?act=blog_down&amp;id='.$uid.'">[-]</a>';
}
echo '</div><hr />';

if ( $_SESSION['id_user'] == $uid ) {
echo '
<div style="'.$DIV_STYLE.'">Действия:<br />
<form action="blogs.php">
<select name="act">
<option value="add">Новая запись</option>
<option value="';
echo $option['see'] == 1 ? 'open">Открыть блог для гостей' : 'closed">Закрыть блог от гостей';
echo '</option>
</select>
<input type="hidden" name="p" value="'.$page.'" />
<input type="submit" value="Ok" /></form></div><br />';
}

if ( $count == 0 ) echo "<center>Нет записей (=</center><br />";

else {

switch($_GET['sort']) {
case 'date_asc':
$sort = 'date_asc';
$q = '`date` asc'; break;
case 'date_desc':
$sort = 'date_desc';
$q = '`date` desc'; break;
case 'rating_asc':
$sort = 'rating_asc';
$q = '`rating` asc'; break;
case 'rating_desc':
$sort = 'rating_desc';
$q = '`rating` desc'; break;
default: $sort = 'date_desc';
$q = '`date` desc';
}

$res = mysql_query("select `id`,`title`,`date`, `rating` from `blogs` where `uid`='".$uid."' order by ".$q." limit ".$start.",".$p_str.";"); 

while ( $data = mysql_fetch_array($res) )

echo '<div style="'.$DIV_STYLE.'">
<a href="blogs.php?act=rec&amp;id='.$data['id'].'">'.
$data['title'].'</a> ['.$data['rating'].']
<br />
<b>Дата:</b> '.vremja($data['date']).'</div><br />';

if ( $page > 1 ) echo "<a href=\"?act=see&amp;id=".$uid."&amp;p=".($page-1)."&amp;sort=".$sort."\">&lt;&lt;&lt;</a> ";
if ( $page < $all ) echo "<a href=\"?act=see&amp;id=".$uid."&amp;p=".($page+1)."&amp;sort=".$sort."\">&gt;&gt;&gt;</a> ";

$srt = array('date_asc'=>'Дате создания от старых',
'date_desc'=>'Дате создания от новых',
'rating_asc'=>'По рейтингу от меньшего',
'rating_desc'=>'По рейтингу от большего');

echo '
<hr />
Сортировать по:
<form action="blogs.php">
<select name="sort">';
echo '<option value="'.$sort.'">'.$srt[$sort].'</option>';
foreach ( $srt as $key=>$val ) if ( $key != $sort ) echo '<option value="'.$key.'">'.$val.'</option>';
echo '
</select>
<input type="hidden" name="p" value="'.$page.'" />
<input type="hidden" name="act" value="see" />
<input type="hidden" name="id" value="'.$uid.'" />
<input type="submit" value="Ok" />
</form><hr />';

}

echo "<br /><a href=\"blogs.php\">К блогам</a><br />";
foot();

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'addblog':

if ( !isset($user) ) {
header("Location: blogs.php");
exit;
}

head();

if ( mysql_fetch_array(mysql_query("select `uid` from `blogs_title` where `uid`='".$_SESSION['id_user']."';")) == false ) {
mysql_query("insert into `blogs_title` set `uid`='".$_SESSION['id_user']."', `date`='".time()."', `update`='0';");
mysql_query("insert into `blogs_rating` set `id_blog`='".$_SESSION['id_user']."';");
mysql_query("insert into `blogs_rating` set `id_record`='".$_SESSION['id_user']."';");
echo "<div align=\"center\">Ваш блог создан!<br /><a href=\"?act=see&amp;id=".$_SESSION['id_user']."\">Перейти</a></div>";
}
else echo "<div align=\"center\">У вас уже есть блог!<br /><a href=\"?act=see&amp;id=".$_SESSION['id_user']."\">Перейти</a></div>";

foot();

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'add':

if ( !isset($user) ) {
header("Location: blogs.php");
exit;
}

if ( mysql_fetch_array(mysql_query("select `uid` from `blogs_title` where `uid`='".$_SESSION['id_user']."';")) == false ) {
header('Location: blogs.php?act=addblog&SESS='.session_id()); exit;
}

if ( !isset($_POST['but']) && !isset($_POST['files']) ) {
head();
if(isset($_GET['l'])) echo "<center>Запись должна быть не менее 10 символов!</center><br />";
if(isset($_GET['m'])) echo "<center>Короткое настроение? (:</center><br />";
if(isset($_GET['t'])) echo "<center>Короткий заголовок!</center><br />";
if(isset($_GET['s'])) echo "<center>Файл слишком большой!</center><br />";
if(isset($_GET['u'])) echo "<center>Это не файлообменник! Unknown file!</center><br />";
if(isset($_GET['i'])) echo "<center>Файл с таким названием уже существует!</center><br />";
echo "<form action=\"?act=add\" method=\"post\">";
echo "Заголовок:<br />";
echo "<input type=\"text\" name=\"title\" /><br />";
echo "Настроение:<br />";
echo "<input type=\"text\" name=\"mood\" /><br />";
echo "Текст:<br />";
echo "<textarea name=\"text\" cols=\"20\" rows=\"3\"></textarea><br />";
if ($user['set_translit']==1) echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo "Не показывать гостям <input type=\"checkbox\" name=\"see\" value=\"1\" /><br />";
echo "<input type=\"submit\" name=\"but\" value=\"Добавить\" /></form><br />";
if ( isset($_SESSION['files']) && !empty($_SESSION['files']) ) {
echo "Прикрепленный файл ";
switch($_SESSION['files_type']) {
case 'video': echo "(видео)"; break;
case 'pic': echo "(картинка)"; break;
case 'sound': echo "(звук)"; break;}
echo ":<br />";
echo $_SESSION['files']." [<a href=\"?act=delfile\">delete</a>]<br />";
}
else {
echo "<form enctype=\"multipart/form-data\" action=\"?act=add\" method=\"post\">";
echo "Прикрепить файл(фото, видео, звук):<br /><input type=\"file\" name=\"file\" /><br />";
echo "<input type=\"submit\" name=\"files\" value=\"Прикрепить\" /></form>";
echo "<br /><div>*Можно загружать файлы следующих форматов: 3gp, mp4, avi, mp3, wav, amr, jpg, jpeg, bmp, png, gif.<br />";
echo "Максимальный размер файла ".$files_size."kb</div>";
}
echo "<br />&#187; <a href=\"?act=see&amp;id=".$_SESSION['id_user']."\">Назад</a>";
echo "<br />&#187; <a href=\"blogs.php\">К блогам</a><br />";
foot();
}
else {
if ( isset($_POST['files']) && isset($_FILES['file']['tmp_name']) ) { #start upload file

$_FILES['file']['name'] = retranslit($_FILES['file']['name']);
$_FILES['file']['name'] = str_replace(" ", "_", $_FILES['file']['name']);

$_FILES['file']['name'] = preg_replace("~(\.php(3|4|5)?|\.html?|\.dhtml?|\.phtml?|\.wmls?|\.xml|\.cgi|\.pl|\.inc)~ius", null, $_FILES['file']['name']);
$_FILES['file']['name'] = preg_replace("~(\\|/|:|\*|\?|\"|\'|<|>|\|)~", null, $_FILES['file']['name']);

if($_FILES['file']['error'] == 1 || $_FILES['file']['size']/1024 > $files_size){
unlink($_FILES['file']['tmp_name']);
header("Location: blogs.php?act=add&s&SESS=".session_id());
exit;
}

if($_FILES['file']['error'] == 0){
if(preg_match("~(\.3gp$|\.mp4$|\.avi$)~i", $_FILES['file']['name'])){
$_SESSION['files'] = $_FILES['file']['name'];
$_SESSION['files_type'] = 'video';
}
elseif(preg_match("~(\.jpg$|\.jpeg$|\.bmp$|\.png$|\.gif$)~i", $_FILES['file']['name'])){
$_SESSION['files'] = $_FILES['file']['name'];
$_SESSION['files_type'] = 'pic';
}
elseif(preg_match("~(\.mp3$|\.wav$|\.amr$)~i", $_FILES['file']['name'])){
$_SESSION['files'] = $_FILES['file']['name'];
$_SESSION['files_type'] = 'sound';
}
else{
header("Location: blogs.php?act=add&u&SESS=".session_id());
exit;
}

if(file_exists("blogs/".$_SESSION['files_type']."/".$_SESSION['id_user']."/".$_SESSION['files'])){
unlink($_FILES['file']['tmp_name'],$_SESSION['files'],$_SESSION['files_type']);
header("Location: blogs.php?act=add&i&SESS=".session_id());
exit;
}

chdir("blogs/".$_SESSION['files_type']);
if(!is_dir($_SESSION['id_user'])){
mkdir($_SESSION['id_user'],0777);
}

move_uploaded_file($_FILES['file']['tmp_name'], $_SESSION['id_user']."/".$_SESSION['files']);
header("Location: blogs.php?act=add&SESS=".session_id());
exit;
}
}


if ( isset($_POST['but']) ) {
$text = trim($_POST['text']);
$mood = trim($_POST['mood']);
$title = trim($_POST['title']);
if ( $_POST['translit']==1 ) {
$text = translit($text);
$mood = translit($mood);
$title = translit($title);
}
$text = mysql_escape_string(htmlspecialchars(stripslashes($text), ENT_QUOTES));
$mood = mysql_escape_string(htmlspecialchars(stripslashes($mood), ENT_QUOTES));
$title = mysql_escape_string(htmlspecialchars(stripslashes($title), ENT_QUOTES));
if ( strlen2($text) < 10 ){
header("Location: blogs.php?act=add&l&SESS=".session_id());
exit;
}
if ( strlen2($mood) < 3 ){
header("Location: blogs.php?act=add&m&SESS=".session_id());
exit;
}
if ( strlen2($title) < 4 ) {
header("Location: blogs.php?act=add&t&SESS=".session_id());
exit;
}

if ( mysql_result(mysql_query("select `id` from `blogs` where `uid`='".$_SESSION['id_user']."' and `text` like '".$text."';"),'id') != false ) {
header("Location: blogs.php?act=see&id=".$_SESSION['id_user']."&SESS=".session_id());
exit;
}

if(isset($_SESSION['files']) && file_exists("blogs/".$_SESSION['files_type']."/".$_SESSION['id_user']."/".$_SESSION['files'])){
$query = ",`".$_SESSION['files_type']."`='".$_SESSION['files']."'";
unset($_SESSION['files_type'],$_SESSION['files']);
}
else $query=null;

$see = $_POST['see'] == 1 ? 1 : 0;

$date = time();
mysql_query("insert into `blogs` set `uid`='".$_SESSION['id_user']."', `title`='".$title."', `date`='".$date."', `text`='".$text."', `mood`='".$mood."' ".$query.", `see`='".$see."';");
$rec = mysql_insert_id();
mysql_query("insert into `blogs_rating` set `id_record`='".$rec."', `minus`='0', `plus`='0';");
mysql_query("update `blogs_title` set `update`='".$date."' where `uid`='".$_SESSION['id_user']."' ;");
header("Location: blogs.php?act=rec&id=".$rec."&SESS=".session_id());
}
}

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'addfile':

if ( !isset($user) ) {
header("Location: blogs.php");
exit;
}

$id = abs((int)$_REQUEST['id']);
$data = mysql_fetch_array(mysql_query("select `uid`,`pic`,`sound`,`video` from `blogs` where `id`='".$id."';"));

if ( empty($data) ){
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}


if ( $data['uid'] != $_SESSION['id_user'] ) {
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}

if ( !empty($data['pic']) && !empty($data['video']) && !empty($data['sound']) ) {
head();
echo "<center>Вам некуда загружать файл!</center><br />";
foot();
}

if(!isset($_POST['but'])){
head();
if(isset($_GET['s'])) echo "<center>Файл слишком большой!</center><br />";
if(isset($_GET['u'])) echo "<center>Это не файлообменник! Unknown file!</center><br />";
if(isset($_GET['i'])) echo "<center>Файл с таким названием уже существует!</center><br />";
if(isset($_GET['t'])) echo "<center>У вас уже есть файл такого типа!</center><br />";
echo "<form enctype=\"multipart/form-data\" action=\"blogs.php?act=addfile\" method=\"post\">";
echo "Загрузить файл (";
if(empty($data['pic'])) echo "рисунок ";
if(empty($data['sound'])) echo "звук ";
if(empty($data['video'])) echo "видео";
echo "):<br /><input type=\"file\" name=\"file\" /><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
echo "<input type=\"submit\" name=\"but\" value=\"Загрузить\" /></form>";
echo "<br /><div>*Можно загружать файлы следующих форматов: 3gp, mp4, avi, mp3, wav, amr, jpg, jpeg, bmp, png, gif.<br />";
echo "Максимальный размер файла ".$files_size."kb</div><br />";
foot();
}
else{
if(isset($_FILES['file']['tmp_name'])){

$_FILES['file']['name'] = retranslit($_FILES['file']['name']);
$_FILES['file']['name'] = str_replace(" ", "_", $_FILES['file']['name']);

$_FILES['file']['name'] = preg_replace("~(\.php(3|4|5)?|\.html?|\.dhtml?|\.phtml?|\.wmls?|\.xml|\.cgi|\.pl|\.inc)~ius", null, $_FILES['file']['name']);
$_FILES['file']['name'] = preg_replace("~(\\|/|:|\*|\?|\"|\'|<|>|\|)~", null, $_FILES['file']['name']);

if($_FILES['file']['error'] == 1 || $_FILES['file']['size']/1024 > $files_size){
unlink($_FILES['file']['tmp_name']);
header("Location: blogs.php?act=addfile&id=".$id."&s&SESS=".session_id());
exit;
}

if($_FILES['file']['error'] == 0){
if(preg_match("~(\.3gp$|\.mp4$|\.avi$)~i", $_FILES['file']['name'])){
$file['name'] = $_FILES['file']['name'];
$file['type'] = 'video';
}
elseif(preg_match("~(\.jpg$|\.jpeg$|\.bmp$|\.png$|\.gif$)~i", $_FILES['file']['name'])){
$file['name'] = $_FILES['file']['name'];
$file['type'] = 'pic';
}
elseif(preg_match("~(\.mp3$|\.wav$|\.amr$)~i", $_FILES['file']['name'])){
$file['name'] = $_FILES['file']['name'];
$file['type'] = 'sound';
}
else{
unlink($_FILES['file']['tmp_name']);
header("Location: blogs.php?act=addfile&id=".$id."&u&SESS=".session_id());
exit;
}

if(file_exists("blogs/".$file['type']."/".$_SESSION['id_user']."/".$file['name'])){
unlink($_FILES['file']['tmp_name']);
header("Location: blogs.php?act=addfile&id=".$id."&i&SESS=".session_id());
exit;
}

if(!empty($data[$file['type']])){
header("Location: blogs.php?act=addfile&id=".$id."&t&SESS=".session_id());
exit;
}

chdir("blogs/".$file['type']);
if(!is_dir($_SESSION['id_user'])){
mkdir($_SESSION['id_user'],0777);
}

move_uploaded_file($_FILES['file']['tmp_name'],  $_SESSION['id_user']."/".$file['name']);
mysql_query("update `blogs` set `".$file['type']."`='".$file['name']."' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
}
}

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'rec':

$id = abs((int)$_GET['id']);
head();

$rec = mysql_fetch_array(mysql_query("select * from `blogs` where `id`='".$id."';"));
if ( empty($rec) ){
echo "<center>Нет такой записи!</center>";
}
else {

if ( !isset($user) && $rec['see'] == 1 ) {
echo '<div align="center">Пользователь предпочел скрыть запись от гостей</div>';
foot();
}

$data = mysql_fetch_array(mysql_query("
 select `users`, `plus`, `minus`,
 ( select `id` from `blogs` where `uid`='".$rec['uid']."' and `id` > '".$id."' order by `date` asc limit 1 ) `next`,
 ( select `id` from `blogs` where `uid`='".$rec['uid']."' and `id` < '".$id."' order by `date` desc limit 1 ) `prev`,
 ( select `nick` from `users` where `id`='".$rec['uid']."' ) `login`
 from `blogs_rating` where `id_record`='".$id."';"));

echo "<div style=\"".$DIV_STYLE." text-align: center\"><h4>Блог ".$data['login']."</h4></div>";

echo '<div style="'.$DIV_STYLE.' text-align: center">'.$rec['title'].'</div>';

echo "<div>Дата: ".vremja($rec['date'])."<br />";
echo '<div style="'.$DIV_STYLE.'">Рейтинг: +'.$data['plus'].'|-'.$data['minus'];
if ( $user && $_SESSION['id_user'] != $rec['uid'] ) {
$test = explode('-', $data['users']);
if ( !in_array($_SESSION['id_user'], $test) )
echo '<br /><a href="blogs.php?act=up&amp;id='.$id.'">[+]</a> / 
<a href="blogs.php?act=down&amp;id='.$id.'">[-]</a>';
}
echo '</div>';

echo "Настроение: ".esc(br(bbcode(smiles(links($rec['mood'])))))."<br />";

if(!empty($rec['pic']))
echo "<div><a href=\"blogs/pic/".$rec['uid']."/".$rec['pic']."\">
<img src=\"blogs/pic/".$rec['uid']."/".$rec['pic']."\" alt=\"".$rec['pic']."\" /></a> (".(round((filesize("blogs/pic/".$rec['uid']."/".$rec['pic'])/1024),2))."kb)</div>";

echo esc(br(bbcode(smiles(links($rec['text'])))))."</div>";

if(!empty($rec['add']))
echo "<div><b>Добавлено</b> (".vremja($rec['add_date'])."):<br />".esc(br(bbcode(smiles(links($rec['add'])))))."</div>";

if(!empty($rec['video']))
echo "<div><a href=\"blogs/video/".$rec['uid']."/".$rec['video']."\">Видео</a>
 (".$rec['video'].", ".(round((filesize("blogs/video/".$rec['uid']."/".$rec['video'])/1024),2))."kb)</div>";
 
if(!empty($rec['sound']))
echo "<div><a href=\"blogs/sound/".$rec['uid']."/".$rec['sound']."\">Звук</a>
 (".$rec['sound'].", ".(round((filesize("blogs/sound/".$rec['uid']."/".$rec['sound'])/1024),2))."kb)</div>";
 
if(!empty($rec['update']))
echo "<font color=\"red\">Изменено ".@mysql_result(mysql_query("select `nick` from `user` where `id`='".$rec['id_update']."';"),'nick')."
 | ".vremja($rec['update'])."</font><br />";

if ( $_SESSION['id_user'] == $rec['uid'] || $user['level'] > 2 ) {
echo "<br /><form action=\"blogs.php\">";
echo "Меню:</br />";
echo "<select name=\"act\">";
echo "<option value=\"edit\">Редактировать</option><option value=\"del\">Удалить</option>";
if($_SESSION['id_user']==$rec['uid'] && empty($rec['add'])) echo "<option value=\"toadd\">Добавить</option>";
if(empty($rec['pic']) && $_SESSION['id_user']==$rec['uid']) echo "<option value=\"addfile\">Добавить рисунок</option>";
if(!empty($rec['pic'])) echo "<option value=\"delp\">Удалить рисунок</option>";
if(empty($rec['video']) && $_SESSION['id_user']==$rec['uid']) echo "<option value=\"addfile\">Добавить видео</option>";
if(!empty($rec['video'])) echo "<option value=\"delv\">Удалить видео</option>";
if(empty($rec['sound']) && $_SESSION['id_user']==$rec['uid']) echo "<option value=\"addfile\">Добавить звук</option>";
if(!empty($rec['sound'])) echo "<option value=\"dels\">Удалить звук</option>";
echo "<option value=\"";
echo $rec['see'] == 1 ? 'open">Открыть запись для гостей' : 'closed">Закрыть запись от гостей';
echo "</option></select><input type=\"hidden\" name=\"id\" value=\"".$id."\" /><input type=\"submit\" value=\"Ok\" /></form><br />";
}
echo "&#187; <a href=\"?act=comm&amp;id=".$id."\">Комментарии</a> (";
echo mysql_result(mysql_query("select count(`id`) from `blogs_comments` where `record`='$id';"),'count').")<br />";
if ( !empty($data['prev']) ) echo "<a href=\"?act=rec&amp;id=".$data['prev']."\">Пред.запись</a> ";
if ( !empty($data['next']) ) echo "<a href=\"?act=rec&amp;id=".$data['next']."\">След.запись</a> ";
}

echo "<br />&#187; <a href=\"?act=see&amp;id=".$rec['uid']."\">Назад</a>";
echo "<br />&#187; <a href=\"blogs.php\">К блогам</a><br />";
foot();

break;

#-----------------------------------------------------------------------------------------------------------------------------------------------#

case 'comm':

$id = abs((int)$_GET['id']);

$data = mysql_fetch_array(mysql_query("select `id`, `uid`, `title`, `see` from `blogs` where `id`='".$id."';"));
if ( empty($data) ) {
head();
echo "<center>Нет такого блога!</center>";
foot();
}

if ( !isset($user) && $data['see'] == 1 ) {
head();
echo '<div align="center">Пользователь предпочел скрыть запись и комментарии от гостей</div>';
foot();
}

head();

echo "<div>".substr($data['title'],0,32)."</div><hr />";
if(isset($_GET['l'])) echo "<center>Комментарий слишком короткий!</center><br />";
if(isset($_GET['ok'])) echo "<center>Комментарий добавлен!</center><br />";

$page = isset($_REQUEST['p']) ? abs((int)$_REQUEST['p']) : 1;
$page = ( $page <= 1 ) ? 1 : $page;
$start = ( $page == 1 ) ? 0 : ($page-1)*$p_str;

$count = mysql_result(mysql_query("select count(`id`) from `blogs_comments` where `record`='".$id."';"), 'count');
$all = ceil($count/$p_str);

if ( $page > $all && $all != 0 ){
header("Location: blogs.php?act=comm&id=".$id."&p=".$all."&SESS=".session_id());
exit;
}

if ( $count == 0 ) echo "<center>Нет комментариев (=</center><br />";

else {

$res = mysql_query("select `blogs_comments`.*, `user`.*
 from `blogs_comments`, `user`
 where `record`='".$id."' and `user`.`id`=`blogs_comments`.`uid`
 order by `date` desc limit ".$start.",".$p_str.";");

while ( $comm = mysql_fetch_array($res) ) {

echo '<div><img src="style/themes/'.$set['set_them'].'/user/'.$comm['pol'].'.png" />
<a href="info.php?id='.$comm['uid'].'">'.$comm['nick'].'</a>'.online($comm['uid']).' 
('.vremja($comm['date']).')<br />
'.esc(br(bbcode(smiles(links($comm['text']))))).'</div>';
if ($user['level']>2)
echo "<a href=\"?act=delcomm&amp;id=".$comm['id']."&amp;c=".$id."\">Удалить</a><br />";

}

if ( $page > 1 ) echo "<a href=\"?act=comm&amp;id=".$id."&amp;p=".($page-1)."&id=".$id."\">Назад</a> ";
if ( $page < $all ) echo "<a href=\"?act=comm&amp;id=".$id."&amp;p=".($page+1)."&id=".$id."\">Далее</a> ";

}

if ( isset($user) ) {
echo "<hr /><form method=\"post\" action=\"?act=addcomm\">\n";
echo "Комментарий:<br /><textarea name=\"comm\"></textarea><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
if ($user['set_translit']==1) echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo "<input value=\"Отправить\" name=\"but\" type=\"submit\" />";
echo "</form>\n";
}

echo "<br />&#187; <a href=\"?act=rec&amp;id=".$id."\">К записи</a><br />";
echo "&#187; <a href=\"blogs.php?act=see&amp;id=".$data['uid']."\">В блог</a><br />";
foot();

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'addcomm':

if(!isset($user)){
header("Location: blogs.php");
exit;
}

$id = abs((int)$_POST['id']);
if(mysql_result(mysql_query("select count(`id`) from `blogs` where `id`='".$id."';"),'count')==0 || !isset($_POST['but'])){
header("Location: index.php");
exit;
}

if(!isset($_POST['but'])){
header("Location: index.php");
exit;
}

$comm = mysql_escape_string(htmlspecialchars(stripslashes(trim($_POST['comm'])), ENT_QUOTES));
if ( strlen2($comm) < 3 ) {
header("Location: blogs.php?act=comm&id=".$id."&l&SESS=".session_id());
exit;
}

if($_POST['translit']==1) $comm=translit($comm);
mysql_query("insert into `blogs_comments` set `record`='".$id."', `uid`='".$_SESSION['id_user']."', `date`='".time()."', `text`='".$comm."';");
header("Location: blogs.php?act=comm&id=".$id."&ok&SESS=".session_id());

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'delcomm':

if(!isset($user) || $user['level']<2){
header("Location: blogs.php");
exit;
}

$id = abs((int)$_GET['id']);
$comm = abs((int)$_GET['c']);

mysql_query("delete from `blogs_comments` where `id`='".$id."';");
header("Location: blogs.php?act=comm&id=".$comm."&SESS=".session_id());

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'del':

$id = abs((int)$_GET['id']);

list($uid) = mysql_fetch_array(mysql_query("select `uid` from `blogs` where `id`='".$id."';"));
if ( empty($uid) || ( $_SESSION['id_user'] != $uid && $user['level']<2 ) ) {
header("Location: blogs.php");
exit;
}

if ( !isset($_GET['yes']) ) {
head();
echo "<center>Вы уверены, что хотите удалить запись?<br />";
echo "[<a href=\"?act=del&amp;id=".$id."&amp;yes\">Да</a>] [<a href=\"?act=rec&id=".$id."\">отмена</a>]<br />";
foot();
}
else {
$files = mysql_fetch_array(mysql_query("select `pic`,`video`,`sound` from `blogs` where `id`='".$id."';"));
if(!empty($files['pic'])) unlink("blogs/pic/".$uid."/".$files['pic']);
if(!empty($files['video'])) unlink("blogs/video/".$uid."/".$files['video']);
if(!empty($files['sound'])) unlink("blogs/sound/".$uid."/".$files['sound']);
mysql_query("delete from `blogs` where `id`='".$id."';");
header("Location: blogs.php?act=see&id=".$uid."&SESS=".session_id());
exit;
}

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'delfile':

if(!isset($user) || !isset($_SESSION['files'])){
header("Location: blogs.php");
exit;
}

if ( file_exists("blogs/".$_SESSION['files_type']."/".$_SESSION['id_user']."/".$_SESSION['files']) ) {
unlink("blogs/".$_SESSION['files_type']."/".$_SESSION['id_user']."/".$_SESSION['files']);
unset($_SESSION['files'],$_SESSION['files_type']);
header("Location: blogs.php?act=add&SESS=".session_id());
exit;
}
header("Location: blogs.php?act=add&SESS=".session_id());

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'delp':

if(!isset($user) || $user['level']<2){
header("Location: blogs.php");
exit;
}

$id = abs((int)$_GET['id']);
$file = mysql_fetch_array(mysql_query("select `uid`,`pic` from `blogs` where `id`='".$id."';"));
if ( ( $file['uid'] != $_SESSION['id_user'] && $user['level']<2 ) || empty($file['pic']) || !file_exists("blogs/pic/".$file['uid']."/".$file['pic'])){
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
unlink("blogs/pic/".$file['uid']."/".$file['pic']);
mysql_query("update `blogs` set `pic`='' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'delv':

if(!isset($user) || $user['level']<2){
header("Location: blogs.php");
exit;
}

$id = abs((int)$_GET['id']);
$file = mysql_fetch_array(mysql_query("select `uid`,`video` from `blogs` where `id`='".$id."';"));
if ( ( $file['uid'] != $_SESSION['id_user'] && $user['level']<2 ) || empty($file['video']) || !file_exists("blogs/video/".$file['uid']."/".$file['video']) ) {
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
unlink("blogs/video/".$file['uid']."/".$file['video']);
mysql_query("update `blogs` set `video`='' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'dels':

if ( !isset($user) || $user['level']<2 ) {
header("Location: blogs.php");
exit;
}

$id = abs((int)$_GET['id']);
$file = mysql_fetch_array(mysql_query("select `uid`,`sound` from `blogs` where `id`='".$id."';"));
if ( ( $file['uid'] != $_SESSION['id_user'] && $user['level']<2 ) || empty($file['sound']) || !file_exists("blogs/sound/".$file['uid']."/".$file['sound']) ) {
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
unlink("blogs/sound/".$file['uid']."/".$file['sound']);
mysql_query("update `blogs` set `sound`='' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'edit':

$id = abs((int)$_REQUEST['id']);

$data = mysql_fetch_array(mysql_query("select * from `blogs` where `id`='".$id."';"));

if ( empty($data) ) {
head();
echo "<center>Нет такой записи!</center><br />";
foot();
}

$uid = $data['uid'];
if ( $_SESSION['id_user'] != $uid || $user['level'] < 2 ) {
header("Location: blogs.php");
exit;
}

if ( !isset($_POST['but']) ) {
head();
if(isset($_GET['l'])) echo "<center>Запись должна быть не менее 10 символов!</center><br />";
if(isset($_GET['m'])) echo "<center>Короткое настроение? (:</center><br />";
if(isset($_GET['a'])) echo "<center>Добавь больше символов (:</center><br />";
echo "<form action=\"?act=edit\" method=\"post\">";
echo "Заголовок:<br />";
echo "<input type=\"text\" name=\"title\" value=\"".$data['title']."\" /><br />";
echo "Настроение:<br />";
echo "<input type=\"text\" name=\"mood\" value=\"".$data['mood']."\" /><br />";
echo "Текст:<br />";
echo "<textarea name=\"text\" cols=\"20\" rows=\"3\">".$data['text']."</textarea><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
if(!empty($data['add'])){
echo "Добавлено:<br />";
echo "<textarea name=\"add\" cols=\"20\" rows=\"3\">".$data['add']."</textarea><br />";
}
if ($user['set_translit']==1) echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo "<input type=\"submit\" name=\"but\" value=\"Изменить\" /></form>";
echo "<br />&#187; <a href=\"?act=rec&amp;id=".$id."\">Назад</a><br />";
echo "<br />&#187; <a href=\"blogs.php\">К блогам</a><br />";
foot();
}
else {
$text = trim($_POST['text']);
$mood = trim($_POST['mood']);
$title = trim($_POST['title']);
if ( $_POST['translit'] == 1 ) {
$text = translit($text);
$mood = translit($mood);
$title = translit($title);
}
$text = mysql_escape_string(htmlspecialchars(stripslashes($text), ENT_QUOTES));
$mood = mysql_escape_string(htmlspecialchars(stripslashes($mood), ENT_QUOTES));
$title = mysql_escape_string(htmlspecialchars(stripslashes($title), ENT_QUOTES));

if ( strlen2($text) < 10 ) {
header("Location: blogs.php?act=edit&id=".$id."&l&SESS=".session_id());
exit;
}
if ( strlen2($mood) < 3 ) {
header("Location: blogs.php?act=edit&id=".$id."&m&SESS=".session_id());
exit;
}
if ( mysql_result(mysql_query("select `id` from `blogs` where `uid`='".$uid."' and `text` like ".$text.";"),'id') !=0 ) {
header("Location: blogs.php?act=see&id=".$uid."&SESS=".session_id());
exit;
}
$check_add = @mysql_result(mysql_query("select `add_date` from `blogs` where `id`='".$id."';"),'add_date');
if ( !empty($check_add) ) {
$add = trim($_POST['add']);
if ( strlen2($add) < 6 ) {
header("Location: blogs.php?act=edit&id=".$id."&a&SESS=".session_id());
exit;
}
if ( $_POST['translit'] == 1 ) $add = translit($add);
$add = mysql_escape_string(htmlspecialchars(stripslashes($add), ENT_QUOTES));
$query = "`add`='".$add."',";
}
else $query = null;


mysql_query("update `blogs` set `title`='".$title."', `text`='".$text."', ".$query." `mood`='".$mood."', `update`='".time()."', `id_update`='".$_SESSION['id_user']."' where `id`='".$id."' ;");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
}

break;

#------------------------------------------------------------------------------------------------------------------------------------------------#

case 'toadd':

if ( !isset($user) ) {
header("location: blogs.php");
exit;
}

$id = abs((int)$_REQUEST['id']);

$data = mysql_fetch_array(mysql_query("select `uid`,`text` from `blogs` where `id`='".$id."';"));

if ( empty($data) ) {
header("Location: blogs.php?SESS=".session_id());
exit;
}

if ( $_SESSION['id_user'] != $data['uid'] ) {
header("Location: blogs.php?SESS=".session_id());
exit;
}

if ( !isset($_POST['but']) ) {
head();

echo "Добавить к:<div>".esc(br(bbcode(smiles(links($data['title'])))))."</div><hr />";

if ( isset($_GET['l']) ) echo "<center>Что так мало дописываешь? (:</center><br />";

echo "<div><form action=\"?act=toadd\" method=\"post\">";
echo "Текст:<br />";
echo "<textarea name=\"add\" rows=\"3\" cols=\"20\"></textarea><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
if ( $user['set_translit'] == 1 ) echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo "<input type=\"submit\" name=\"but\" value=\"Добавить\" /></form></div>";
echo "<br />&#187; <a href=\"?act=rec&amp;id=".$id."\">Назад</a>";
echo "<br />&#187; <a href=\"blogs.php\">К блогам</a>";

foot();
}
else {
$add = trim($_POST['add']);
if ( strlen2($add) < 6 ) {
header("Location: blogs.php?act=toadd&id=".$id."&l&SESS=".session_id());
exit;
}
if ( $_POST['translit'] == 1 ) $add = translit($add);
$add = mysql_escape_string(htmlspecialchars(stripslashes($add), ENT_QUOTES));
mysql_query("update `blogs` set `add_date`='".time()."', `add`='".$add."' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
}

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'open':

# открытие (open) и закрытие (closed см.ниже) блога вцелом, либо одной записи.
# если есть айди записи, то проверяем хозяина ее (записи) и открываем/закрываем запись.
# иначе открываем/закрываем весь блог.

if ( isset($_GET['id']) ) {
$id = abs((int)$_GET['id']);
list($uid) = mysql_fetch_array(mysql_query("select `uid` from `blogs` where `id`='".$id."';"));
if ( $_SESSION['id_user'] != $uid || $user['level'] < 2 ) {
header("Location: blogs.php");
exit;
}
mysql_query("update `blogs` set `see`='0' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
else {
mysql_query("update `blogs_title` set `see`='0' where `uid`='".$_SESSION['id_user']."';");
header("Location: blogs.php?act=see&id=".$_SESSION['id_user']."&SESS=".session_id());
}

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'closed':

if ( isset($_GET['id']) ) {
$id = abs((int)$_GET['id']);
list($uid) = mysql_fetch_array(mysql_query("select `uid` from `blogs` where `id`='".$id."';"));
if ( $_SESSION['id_user'] != $uid || $user['level'] < 2 ) {
header("Location: blogs.php");
exit;
}
mysql_query("update `blogs` set `see`='1' where `id`='".$id."';");
header("Location: blogs.php?act=rec&id=".$id."&SESS=".session_id());
exit;
}
else {
mysql_query("update `blogs_title` set `see`='1' where `uid`='".$_SESSION['id_user']."';");
header("Location: blogs.php?act=see&id=".$_SESSION['id_user']."&SESS=".session_id());
}

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'blog_up':

if ( !isset($user) ) {
header('Location: blogs.php'); exit;
}

$id = abs((int)$_GET['id']);

$test = mysql_fetch_array(mysql_query("select `users`, `plus`, `minus` from `blogs_rating` where `id_blog`='".$id."';"));

if ( mysql_affected_rows() == false ) {
header('Location: blogs.php'); exit;
}

$users_test = explode('-', $test['users']);
if ( in_array($_SESSION['id_user'], $users_test) || $_SESSION['id_user'] == $id ) {
header('Location: blogs.php?act=see&id='.$id.'&SESS='.session_id()); exit;
}
else {
$users = empty($test['users']) ? $_SESSION['id_user'] : $test['users'].'-'.$_SESSION['id_user'];
mysql_query("update `blogs_rating` set `users`='".$users."', `plus`=plus+1 where `id_blog`='".$id."';");
$rating = ($test['plus']+1) - $test['minus'];
mysql_query("update `blogs_title` set `rating`='".$rating."' where `uid`='".$id."';");
}

header('Location: blogs.php?act=see&id='.$id.'&SESS='.session_id()); exit;

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'blog_down':

if ( !isset($user) ) {
header('Location: blogs.php'); exit;
}

$id = abs((int)$_GET['id']);

$test = mysql_fetch_array(mysql_query("select `users`, `plus`, `minus` from `blogs_rating` where `id_blog`='".$id."';"));

if ( mysql_affected_rows() == false ) {
header('Location: blogs.php'); exit;
}

$users_test = explode('-', $test['users']);
if ( in_array($_SESSION['id_user'], $users_test) || $_SESSION['id_user'] == $id ) {
header('Location: blogs.php?act=see&id='.$id.'&SESS='.session_id()); exit;
}
else {
$users = empty($test['users']) ? $_SESSION['id_user'] : $test['users'].'-'.$_SESSION['id_user'];
mysql_query("update `blogs_rating` set `users`='".$users."', `minus`=minus+1 where `id_blog`='".$id."';");
$rating = $test['plus'] - ($test['minus']+1);
mysql_query("update `blogs_title` set `rating`='".$rating."' where `uid`='".$id."';");
}

header('Location: blogs.php?act=see&id='.$id.'&SESS='.session_id()); exit;

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'up':

if ( !isset($user) ) {
header('Location: blogs.php'); exit;
}

$id = abs((int)$_GET['id']);

$test = mysql_fetch_array(mysql_query("select `users`, `plus`, `minus` from `blogs_rating` where `id_record`='".$id."';"));

if ( mysql_affected_rows() == false ) {
header('Location: blogs.php'); exit;
}

$users_test = explode('-', $test['users']);
if ( in_array($_SESSION['id_user'], $users_test) || $_SESSION['id_user'] == $id ) {
header('Location: blogs.php?act=rec&id='.$id.'&SESS='.session_id()); exit;
}
else {
$users = empty($test['users']) ? $_SESSION['id_user'] : $test['users'].'-'.$_SESSION['id_user'];
mysql_query("update `blogs_rating` set `users`='".$users."', `plus`=plus+1 where `id_record`='".$id."';");
$rating = ($test['plus']+1) - $test['minus'];
mysql_query("update `blogs` set `rating`='".$rating."' where `id`='".$id."';");
}

header('Location: blogs.php?act=rec&id='.$id.'&SESS='.session_id()); exit;

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

case 'down':

if ( !isset($user) ) {
header('Location: blogs.php'); exit;
}

$id = abs((int)$_GET['id']);

$test = mysql_fetch_array(mysql_query("select `users`, `plus`, `minus` from `blogs_rating` where `id_record`='".$id."';"));

if ( mysql_affected_rows() == false ) {
header('Location: blogs.php'); exit;
}

$users_test = explode('-', $test['users']);
if ( in_array($_SESSION['id_user'], $users_test) || $_SESSION['id_user'] == $id ) {
header('Location: blogs.php?act=rec&id='.$id.'&SESS='.session_id()); exit;
}
else {
$users = empty($test['users']) ? $_SESSION['id_user'] : $test['users'].'-'.$_SESSION['id_user'];
mysql_query("update `blogs_rating` set `users`='".$users."', `minus`=minus+1 where `id_record`='".$id."';");
$rating = $test['plus'] - ($test['minus']+1);
mysql_query("update `blogs` set `rating`='".$rating."' where `id`='".$id."';");
}

header('Location: blogs.php?act=rec&id='.$id.'&SESS='.session_id()); exit;

break;

#-------------------------------------------------------------------------------------------------------------------------------------------------#

default:

$page = isset($_GET['p']) ? abs((int)$_GET['p']) : 1;
$page = $page <= 1 ? 1 : $page;
$start = $page == 1 ? 0 : ($page-1)*$p_str;

$res = mysql_query("
 select count(`id`) `blogs`,
 ( select count(`id`) from `blogs` where `sound`<>'' ) `sounds`,
 ( select count(`id`) from `blogs` where `pic`<>'' ) `pic`,
 ( select count(`id`) from `blogs` where `video`<>'' ) `video`
 from `blogs_title`");

$blogs_counter = mysql_fetch_array($res);

$count = $blogs_counter['blogs'];
$all = ceil($count/$p_str);

if ( $page > $all && $all != 0 ) {
header('Location: blogs.php?p='.$all.'&SESS='.session_id()); exit;
}

head();

if ( isset($user) ) echo '<div><a href="blogs.php?act=addblog">Создать блог</a></div><br />';

if ( $count == 0 ) echo '<div align="center">Нет блогов.</div>';

else {

switch($_GET['sort']) {
case 'update_asc':
$sort = 'update_asc';
$q = '`update` asc'; break;
case 'update_desc':
$sort = 'update_desc';
$q = '`update` desc'; break;
case 'date_asc':
$sort = 'date_asc';
$q = '`update` asc'; break;
case 'date_desc':
$sort = 'date_desc';
$q = '`update` desc'; break;
case 'id_asc' :
$sort = 'id_asc';
$q = '`uid` asc'; break;
case 'id_desc' :
$sort = 'id_desc';
$q = '`uid` desc'; break;
case 'rating_asc':
$sort = 'rating_asc';
$q = '`rating` asc'; break;
case 'rating_desc':
$sort = 'rating_desc';
$q = '`rating` desc'; break;
default: $sort = 'update_desc';
$q = '`update` desc';
}

$res = mysql_query("select `blogs_title`.*, `user`.`nick` from `blogs_title`, `user`
where `user`.`id`=`blogs_title`.`uid` and `user`.`nick`<>'' order by `blogs_title`.".$q." limit ".$start.",".$p_str.";");

while ( $data = mysql_fetch_array($res) )

echo '<div style="'.$DIV_STYLE.'">
<a href="blogs.php?act=see&amp;id='.$data['uid'].'">Блог '.$data['nick'].'</a> ['.$data['rating'].']
<br />
<small>
Создан: '.vremja($data['date']).'<br />
Обновлен: '.vremja($data['update']).'
</small>
</div>';


if ( $page > 1 ) echo "<a href=\"blogs.php?p=".($page-1)."&amp;sort=".$sort."\">Назад</a> ";
if ( $page < $all ) echo "<a href=\"blogs.php?p=".($page+1)."&amp;sort=".$sort."\">Далее</a>";


$srt = array('update_asc'=>'Обновлениям от старых',
'update_desc'=>'Обновлениям от новых',
'date_asc'=>'Дате создания от старых',
'date_desc'=>'Дате создания от новых',
'id_asc'=>'По id от меньшего',
'id_desc'=>'По id от большего',
'rating_asc'=>'По рейтингу от меньшего',
'rating_desc'=>'По рейтингу от большего');

echo '
<hr />
Сортировать по:
<form action="blogs.php">
<select name="sort">';
echo '<option value="'.$sort.'">'.$srt[$sort].'</option>';
foreach ( $srt as $key=>$val ) if ( $key != $sort ) echo '<option value="'.$key.'">'.$val.'</option>';
echo '
</select>
<input type="hidden" name="p" value="'.$page.'" />
<input type="submit" value="Ok" />
</form><hr />';

echo "Блоггеров: ".$blogs_counter['blogs']."<br />";
echo "Звуков: ".$blogs_counter['sounds']."<br />";
echo "Рисунков: ".$blogs_counter['pic']."<br />";
echo "Видео: ".$blogs_counter['video']."<hr />";
}
foot();


}

?>