View file m.xmyx.ru/user/blogs/index.php

File size: 37.47Kb
<?

/**
 * & Author   :: Igor Slepko
 * & Nick     :: Tw1nGo
 * & Contacts :: http://gix.su/user/Tw1nGo
 */

include_once $_SERVER['DOCUMENT_ROOT'] . '/sys/inc/home.php';
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';

// Если юзер в Бане
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0) != 0){
header('Location: /ban.php?'.SID);
exit;
}


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

switch ($act) {

// КАТЕГОРИИ
default:
if(!isset($_GET['Category'])){
$set['title'] = 'Блоги';
include_once H.'sys/inc/thead.php';
title();

?>
<div class="lc_br wbg font0 relative oh" id="header_path">  <a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>     <span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <a href="/user/blogs/">Блоги</a> </span>       </div>

<div class="wrapper-nobg">   
<form action="/user/blogs/" method="get">  
<table class="table__wrap search-wrap input-txt_grid"> <tbody><tr> 
<td class="input-txt_grid_input"> 
<div class="input-txt_wrapper_search relative"> <input class="input-txt" name="query" value="" maxlength="250" type="text"> </div> 
</td> 
<td class="input-txt_grid_sep"></td> 
<td class="input-txt_grid_btn"> <input class="search__btn" value="Найти" name="cfms" type="submit"> </td> 
</tr> </tbody></table>     
</form>   
</div>

<div class="tabs_block oh">    
<div class="tab_item left tab_active black" style="padding: 12px 9px 8px 9px">  Каналы  </div>   
<a href="/user/blogs/?List=0" class="tab_item left" style="padding: 12px 9px 8px 9px">  Популярные  </a>   
<a href="/user/blogs/?List=1" class="tab_item left" style="padding: 12px 9px 8px 9px">  Новые  </a>   
</div>
<?
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_dir` "),0);

if($k_post == 0){
?>
<div class="wrapper"> <div class="link"> Каналов нет. </div> </div>
<?
}
else{
?>
<div class="wrapper"> <div class="list f-c_fll">
<?
$q = mysql_query("SELECT * FROM `notes_dir` ORDER BY `id` ASC");

while ($post = mysql_fetch_assoc($q))
{

?>
<a href="?Category=<?= $post['id']?>" class="link  darkblue arrow    "> 
<span> 
<img src="/style/i/blogs/<?= $post['icon']?>" alt="" class="m">      <span class="m">  <?= text($post['name'])?> </span>          
</span>  
</a>
<?
}

?>
</div> </div>
<?
}
?>
<div class="lc_br wbg font0 relative oh" id="footer_path">  <a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>     <span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <a href="/user/blogs/">Блоги</a> </span>     </div>
<?
include_once H.'sys/inc/tfoot.php';
}
else{
// ЕСЛИ ВЫБРАЛИ КАНАЛ 

$uid_dir = intval($_GET['Category']);
$kanal = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes_dir` WHERE `id` = '".$uid_dir."' LIMIT 1"));

if(!$uid_dir || !$kanal){
$set['title'] = 'Ошибка!';
include_once H.'sys/inc/thead.php';
title();

?>
<div class="lc_br wbg font0 relative oh" id="header_path">  
<a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>
<span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">Ошибка</span> </span>
</div>
<div class="wrapper"> <div class="link"> Канал не найден. </div> </div>
<?
include_once H.'sys/inc/tfoot.php';
exit;
}

$set['title'] = 'Блоги';
include_once H.'sys/inc/thead.php';


if (isset($user))
{

// Лайк
if (isset($_GET['like'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['like'])."' LIMIT 1"));

// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '1')");

$mgs_like = "[b]".$user['nick']."[/b] понравился ваш блог!";
mysql_query("INSERT INTO `journal` (`user`, `time`, `act`, `opis`, `ank`, `url`) VALUES ('".$user['id']."', '".$time."', 'blogs', '".$mgs_like."', '".$blog['id_user']."', '/user/blogs/read/?id=".$blog['id']."')");

// Выводим в списке понравившихся в закладках
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmarks_like` WHERE `id_user` = '".$user['id']."' AND `id_object` = '".$blog['id']."' AND `type` = 'blog' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `bookmarks_like` (`type`,`id_object`, `id_user`, `time`) VALUES ('blog','$blog[id]', '$user[id]', '$time')");
}

}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Вы не можете голосовать за свои блоги.';
}
header("Location: ?Category=".$kanal['id']."");
exit;
}
// Дизлайк
if (isset($_GET['dlike'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['dlike'])."' LIMIT 1"));


// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '0')");
}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Вы не можете голосовать за свои блоги.';
}
header("Location: ?Category=".$kanal['id']."");
exit;
}

if(isset($_GET['sort'])){
	mysql_query("UPDATE `user` SET `blog_view` = '".($user['blog_view'] == 1 ? '0' : '1')."' WHERE `id` = '$user[id]'");
	header("Location: ?Category=".$kanal['id']."");
	exit;
}

}


title();

?>
<div class="lc_br wbg font0 relative oh" id="header_path">  
<a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>     
<span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <a href="/user/blogs/">Блоги</a> </span>       
<span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text"><?= text($kanal['name'])?></span> </span>
</div>

<div class="header upcs b">  <?= text($kanal['name'])?>  </div>
<?
$set['p_str'] = '10';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0' AND `id_dir` = '$kanal[id]'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

if(isset($user) && $user['level'] >= 3){
$komu_vidno = "";
}
else{
$komu_vidno = " AND `private` != '2'";
}

if(isset($user) && $k_post > 0){
?>
<div class="oh tool_block wrapper-nobg t_center">    
<!-- --> 
<span class="right">  
<span class="inl_bl" onclick="short_mode_switch();" style="cursor: pointer;">      
<span class="inl-link    link-grey c-grey">  
<!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Вид</span><!--    --><!-- --><!-- --><!-- -->
</span><!-- --> 
</span> 
</span> 
</div>
<div id="short_mode_switch" style="display: none"> 
<div class="wrapper">      
<a href="?Category=<?= $kanal['id']?>&sort" class="link -full   grey c-grey <?= ($user['blog_view'] == 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/short.png" alt="" class="m"> <!--   --><span class="m">Краткий вид</span><!--    --></span>  
</a>         
<a href="?Category=<?= $kanal['id']?>&sort" class="link -full   grey c-grey <?= ($user['blog_view'] != 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Расширенный вид</span><!--    --></span>  
</a>     
</div>
</div>  
<?
}


$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0' AND `id_dir` = '$kanal[id]'$komu_vidno ORDER BY `time` LIMIT $start, $set[p_str]");


if ($k_post == 0){
?>
<div class="wrapper"> <div class="link"> Блоги не найдены. </div> </div>
<?
}
else{

if(isset($user) && $user['blog_view'] == 1){
?>
<div class="wrapper bb0">
<?
}

while ($post = mysql_fetch_assoc($q))
{
$us_ank = get_user($post['id_user']);
$ank = get_user($post['id_user']);
$koment = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_komm` WHERE `id_notes` = '".$post['id']."'"), 0);
$kan_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes_dir` WHERE `id` = '".$post['id_dir']."' LIMIT 1"));
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);

$_msg = text($post['msg']);
if (iconv_strlen($_msg, 'UTF-8') > 50) {
        $_msg= iconv_substr($_msg, 0, 200, 'UTF-8');
        $_msg = $_msg.'...';
}


if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="wrapper bb0">
<?
}

?>
<div class="block bord-botm relative attaches_limiter"> 
<div class="oh">
<span class="right"> <span class="grey m"><?= vremja($post['time'])?></span>   </span>
<div class="grey"> <?= group($us_ank['id'])?> <?= unick($us_ank['id'])?> </div>     
<div class="cl pad_t_a"></div>  
<?
if ($post['file_ves'] != 0 && $post['file_raz'] != NULL && is_file(H."user/blogs/files/".$post['id'].".dat"))
{
if ($post['file_raz'] == 'png' || $post['file_raz'] == 'gif' || $post['file_raz'] == 'jpg' || $post['file_raz'] == 'jpeg')
{
?>
<div class="left t-padd_right">     
<div>  
<span class="short_attach">   
<div class="inl_bl">        
<span class="pr">   
<div class="inl_bl relative"> 
<img src="/user/blogs/file/<?= $post['id']?>.<?= $post['file_raz']?>" alt="" class="preview s81_80"  style="width:80px;height:80px;">   
</div>     
</span>             
</div>     
</span>  
</div>    
</div>
<?
}
}
?> 
<div class="oh"> 
<a class="arrow_link full_link" href="/user/blogs/read/?id=<?= $post['id']?>"> 
<b>  <?= text($post['name'])?>  </b> 
</a>  
<div> <?= $_msg?> </div>  
</div>   </div> 
<?
if($koment > 0 || $kan_post['name'] != null || $post['count'] > 0){
?>
<div>  
<div class="oh">   
<div class="oh cl grey pad_t_a" style="padding-top: 5px;">  
<?
if(isset($user) && $user['blog_view'] == 1 && $koment > 0){
?> 
<span class="left"> 
<img src="/style/i/comm_ico.png" class="m p16" alt=""> 
<span class="m"><?= $koment?></span> 
</span>  
<?
}
if($kan_post['name'] != null){
?> 
<span class="m <?= (isset($user) && $user['blog_view'] == 1 ? 'right' : '')?>"> <?= text($kan_post['name'])?> </span>  
<?
}
if(!isset($user) || $user['blog_view'] != 1){
if($post['count'] > 0){
?>
<span class="right"> <!--     --><img src="/style/i/eye.png" alt="" class="m"> <!--   --><span class="m"><?= $post['count']?></span><!--    --> </span>
<?
}
}
?> 
</div>  
<div class="cl"></div> </div> </div>    
<?
}
?>
<div class="cl"></div> 
</div>
<?


if(isset($user) && $user['id'] != $ank['id']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0) == 0){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down.png';
}
else{
if($us_like){
$ico_vote_up = 'vote_up_on.png';
$ico_vote_down = 'vote_down.png';
}elseif($us_dlike){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down_on.png';
}
}
}
elseif ($user['id'] == $ank['id'] || !isset($user)){
$ico_vote_up = 'vote_up_disabled.png';
$ico_vote_down = 'vote_down_disabled.png';
}

if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="oh bord-botm js-action_bar action-bar"> 
<table class="table__wrap table__wrap-fixed grey"> <tbody><tr>   
<td class="table__cell relative m"> 
<a href="/user/blogs/read/?id=<?= $post['id']?>" class="link" title="Обсудить"> 
<img src="/style/i/action_bar/comment.png" alt="" class="m">  
<span class="m grey <?= ($koment == 0 ? 'hide' : '')?>"><?= $koment?></span> 
</a> 
</td>
<td class="table__cell relative m"> 
<span>   
<span class="bmc t-padd_right"> 
<a href="?Category=<?= $kanal['id']?>&like=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_up?>" alt="" class="m p16"> </a>  
<span class="m <?= ($like == 0 ? 'hide' : '')?>"><?= $like?></span>  
</span>  
</span>  
</td>   
<td class="table__cell relative m bord-right0">
<span>   
<span class="bmc"> 
<a href="?Category=<?= $kanal['id']?>&dlike=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_down?>" alt="" class="m p16"> </a>  
<span class="m <?= ($dlike == 0 ? 'hide' : '')?>"><?= $dlike?></span>  
</span>   
</span>  
</td>  
</tr> </tbody></table>          
</div>

</div>
<?
}

}
if(isset($user) && $user['blog_view'] == 1){
?>
</div>
<?
}

if ($k_page > 1)str("?Category=".$kanal['id']."&amp;",$k_page,$page); // Вывод страниц

}

include_once H.'sys/inc/tfoot.php';
}


break;



// ПОПУЛЯРНЫЕ
case '0':
$set['title'] = 'Блоги';
include_once H.'sys/inc/thead.php';

if (isset($user))
{

// Лайк
if (isset($_GET['like'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['like'])."' LIMIT 1"));

// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '1')");

$mgs_like = "[b]".$user['nick']."[/b] понравился ваш блог!";
mysql_query("INSERT INTO `journal` (`user`, `time`, `act`, `opis`, `ank`, `url`) VALUES ('".$user['id']."', '".$time."', 'blogs', '".$mgs_like."', '".$blog['id_user']."', '/user/blogs/read/?id=".$blog['id']."')");

// Выводим в списке понравившихся в закладках
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmarks_like` WHERE `id_user` = '".$user['id']."' AND `id_object` = '".$blog['id']."' AND `type` = 'blog' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `bookmarks_like` (`type`,`id_object`, `id_user`, `time`) VALUES ('blog','$blog[id]', '$user[id]', '$time')");
}

}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Вы не можете голосовать за свои блоги.';
}
header("Location: ?List=0");
exit;
}
// Дизлайк
if (isset($_GET['dlike'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['dlike'])."' LIMIT 1"));


// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '0')");
}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Вы не можете голосовать за свои блоги.';
}
header("Location: ?List=0");
exit;
}

if(isset($_GET['sort'])){
	mysql_query("UPDATE `user` SET `blog_view` = '".($user['blog_view'] == 1 ? '0' : '1')."' WHERE `id` = '$user[id]'");
	header("Location: ?List=0");
	exit;
}

}

title();

if (isset($_GET['Filter']) && ($_GET['Filter'] == '0' || $_GET['Filter'] == '1' || $_GET['Filter'] == '2'))
{
if ($_GET['Filter'] == '0')
{
$_SESSION['diary_sort'] = 1;
}
else if ($_GET['Filter'] == '1')
{
$_SESSION['diary_sort'] = 2;
}
else if ($_GET['Filter'] == '2')
{
$_SESSION['diary_sort'] = 3;
}
/*
header("Location: /user/blogs/");
exit;
*/
}


?>
<div class="lc_br wbg font0 relative oh" id="header_path">  <a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>     <span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <a href="/user/blogs/">Блоги</a> </span>       </div>

<div class="wrapper-nobg">   
<form action="/user/blogs/" method="get">  
<table class="table__wrap search-wrap input-txt_grid"> <tbody><tr> 
<td class="input-txt_grid_input"> 
<div class="input-txt_wrapper_search relative"> <input class="input-txt" name="query" value="" maxlength="250" type="text"> </div> 
</td> 
<td class="input-txt_grid_sep"></td> 
<td class="input-txt_grid_btn"> <input class="search__btn" value="Найти" name="cfms" type="submit"> </td> 
</tr> </tbody></table>     
</form>   
</div>

<div class="tabs_block oh">    
<a href="/user/blogs/" class="tab_item left" style="padding: 12px 9px 8px 9px">  Каналы</a>      
<div class="tab_item left tab_active black" style="padding: 12px 9px 8px 9px">  Популярные    </div>
<a href="/user/blogs/?List=1" class="tab_item left" style="padding: 12px 9px 8px 9px">  Новые  </a>   
</div>

<div class="wrapper"> 
<table class="table__wrap table_no_borders nowrap"> <tbody><tr>  
<?
if (!isset($_SESSION['diary_sort']) || $_SESSION['diary_sort'] == NULL || $_SESSION['diary_sort'] == 0 || !is_numeric($_SESSION['diary_sort']) || !isset($user)){
?>
<td class="table__cell" width="33%">  <div class="link sub_selected b"> Новые   </div>  </td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=1&amp;List=0" class="link b"> За месяц   </a>  
</td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=2&amp;List=0" class="link b"> Все   </a>  
</td>  
<?
}
else{
if ($_SESSION['diary_sort'] == 1){
?>
<td class="table__cell" width="33%">  <div class="link sub_selected b"> Новые   </div>  </td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=1&amp;List=0" class="link b"> За месяц   </a>  
</td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=2&amp;List=0" class="link b"> Все   </a>  
</td> 
<?
}
else if ($_SESSION['diary_sort'] == 2){
?>
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=0&amp;List=0" class="link b"> Новые   </a>  
</td>  
<td class="table__cell" width="33%">  <div class="link sub_selected b"> За месяц   </div>  </td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=2&amp;List=0" class="link b"> Все   </a>  
</td>
<?
}
else if ($_SESSION['diary_sort'] == 3){
?>
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=0&amp;List=0" class="link b"> Новые   </a>  
</td>  
<td class="table__cell" width="33%">  
<a href="/user/blogs/?Filter=1&amp;List=0" class="link b"> За месяц   </a>  
</td>  
<td class="table__cell" width="33%">  <div class="link sub_selected b"> Все   </div>  </td>
<?
}

}
?>
</tr> </tbody></table> 
</div>
<?




if(isset($user) && $user['level'] >= 2){
$komu_vidn = "";
$komu_vidn2 = "";
}
else{
$komu_vidn = " AND `private` != '2'";
$komu_vidn2 = " AND `private` != '2'";
}


$diary_time = time()-2592000;
$set['p_str'] = '10';

if (!isset($_SESSION['diary_sort']) || $_SESSION['diary_sort'] == NULL || $_SESSION['diary_sort'] == 0 || !is_numeric($_SESSION['diary_sort']) || !isset($user)){
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0'$komu_vidn ORDER BY `time`"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0'$komu_vidn ORDER BY `time` DESC LIMIT $start, $set[p_str]");
}
else{
if ($_SESSION['diary_sort'] == 1){
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0' AND `time`$komu_vidn2 ORDER BY `time`"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0' AND `time`$komu_vidn2 ORDER BY `time` DESC LIMIT $start, $set[p_str]");
}
else if ($_SESSION['diary_sort'] == 2){
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0' AND `time` > '".$diary_time."'$komu_vidn2 ORDER BY `time`,`count`"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0' AND `time` > '".$diary_time."'$komu_vidn2 ORDER BY `time`,`count` DESC LIMIT $start, $set[p_str]");
}
else if ($_SESSION['diary_sort'] == 3){
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0' AND `time`$komu_vidn2 ORDER BY `count`"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0' AND `time`$komu_vidn2 ORDER BY `count` DESC LIMIT $start, $set[p_str]");
}
}



if(isset($user) && $k_post > 0){
?>
<div class="oh tool_block wrapper-nobg t_center">    
<!-- --> 
<span class="right">  
<span class="inl_bl" onclick="short_mode_switch();" style="cursor: pointer;">      
<span class="inl-link    link-grey c-grey">  
<!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Вид</span><!--    --><!-- --><!-- --><!-- -->
</span><!-- --> 
</span> 
</span> 
</div>
<div id="short_mode_switch" style="display: none"> 
<div class="wrapper">      
<a href="?List=0&sort" class="link -full   grey c-grey <?= ($user['blog_view'] == 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/short.png" alt="" class="m"> <!--   --><span class="m">Краткий вид</span><!--    --></span>  
</a>         
<a href="?List=0&sort" class="link -full   grey c-grey <?= ($user['blog_view'] != 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Расширенный вид</span><!--    --></span>  
</a>     
</div>
</div>  
<?
}




if ($k_post == 0){
?>
<div class="wrapper"> <div class="link"> Блоги не найдены. </div> </div>
<?
}
else{

if(isset($user) && $user['blog_view'] == 1){
?>
<div class="wrapper bb0">
<?
}

while ($post = mysql_fetch_assoc($q))
{
$us_ank = get_user($post['id_user']);
$ank = get_user($post['id_user']);
$koment = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_komm` WHERE `id_notes` = '".$post['id']."'"), 0);
$kan_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes_dir` WHERE `id` = '".$post['id_dir']."' LIMIT 1"));
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);

$_msg = text($post['msg']);
if (iconv_strlen($_msg, 'UTF-8') > 50) {
        $_msg= iconv_substr($_msg, 0, 200, 'UTF-8');
        $_msg = $_msg.'...';
}

if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="wrapper bb0">
<?
}

?>
<div class="block bord-botm relative attaches_limiter"> 
<div class="oh">
<span class="right"> <span class="grey m"><?= vremja($post['time'])?></span>   </span>
<div class="grey"> <?= group($us_ank['id'])?> <?= unick($us_ank['id'])?> </div>     
<div class="cl pad_t_a"></div>   
<?
if ($post['file_ves'] != 0 && $post['file_raz'] != NULL && is_file(H."user/blogs/files/".$post['id'].".dat"))
{
if ($post['file_raz'] == 'png' || $post['file_raz'] == 'gif' || $post['file_raz'] == 'jpg' || $post['file_raz'] == 'jpeg')
{
?>
<div class="left t-padd_right">     
<div>  
<span class="short_attach">   
<div class="inl_bl">        
<span class="pr">   
<div class="inl_bl relative"> 
<img src="/user/blogs/file/<?= $post['id']?>.<?= $post['file_raz']?>" alt="" class="preview s81_80"  style="width:80px;height:80px;">   
</div>     
</span>             
</div>     
</span>  
</div>    
</div>
<?
}
}
?>
<div class="oh"> 
<a class="arrow_link full_link" href="/user/blogs/read/?id=<?= $post['id']?>"> 
<b>  <?= text($post['name'])?>  </b> 
</a>  
<div> <?= $_msg?> </div>  
</div>   </div> 
<?
if($koment > 0 || $kan_post['name'] != null || $post['count'] > 0){
?>
<div>  
<div class="oh">   
<div class="oh cl grey pad_t_a" style="padding-top: 5px;">  
<?
if(isset($user) && $user['blog_view'] == 1 && $koment > 0){
?> 
<span class="left"> 
<img src="/style/i/comm_ico.png" class="m p16" alt=""> 
<span class="m"><?= $koment?></span> 
</span>  
<?
}
if($kan_post['name'] != null){
?> 
<span class="m <?= (isset($user) && $user['blog_view'] == 1 ? 'right' : '')?>"> <?= text($kan_post['name'])?> </span>  
<?
}
if(!isset($user) || $user['blog_view'] != 1){
if($post['count'] > 0){
?>
<span class="right"> <!--     --><img src="/style/i/eye.png" alt="" class="m"> <!--   --><span class="m"><?= $post['count']?></span><!--    --> </span>
<?
}
}
?> 
</div>  <div class="cl"></div> </div> </div>    
<?
}
?>
<div class="cl"></div> 
</div>
<?


if(isset($user) && $user['id'] != $ank['id']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0) == 0){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down.png';
}
else{
if($us_like){
$ico_vote_up = 'vote_up_on.png';
$ico_vote_down = 'vote_down.png';
}elseif($us_dlike){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down_on.png';
}
}
}
elseif ($user['id'] == $ank['id'] || !isset($user)){
$ico_vote_up = 'vote_up_disabled.png';
$ico_vote_down = 'vote_down_disabled.png';
}

if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="oh bord-botm js-action_bar action-bar"> 
<table class="table__wrap table__wrap-fixed grey"> <tbody><tr>   
<td class="table__cell relative m"> 
<a href="/user/blogs/read/?id=<?= $post['id']?>" class="link" title="Обсудить"> 
<img src="/style/i/action_bar/comment.png" alt="" class="m">  
<span class="m grey <?= ($koment == 0 ? 'hide' : '')?>"><?= $koment?></span> 
</a> 
</td>
<td class="table__cell relative m"> 
<span>   
<span class="bmc t-padd_right"> 
<a href="?List=0&like=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_up?>" alt="" class="m p16"> </a>  
<span class="m <?= ($like == 0 ? 'hide' : '')?>"><?= $like?></span>  
</span>  
</span>  
</td>   
<td class="table__cell relative m bord-right0">
<span>   
<span class="bmc"> 
<a href="?List=0&dlike=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_down?>" alt="" class="m p16"> </a>  
<span class="m <?= ($dlike == 0 ? 'hide' : '')?>"><?= $dlike?></span>  
</span>   
</span>  
</td>  
</tr> </tbody></table>          
</div>

</div>
<?
}

}
if(isset($user) && $user['blog_view'] == 1){
?>
</div>
<?
}


if ($k_page > 1)str("?List=0&amp;",$k_page,$page); // Вывод страниц

}

include_once H.'sys/inc/tfoot.php';


break;



// НОВЫЕ

case '1':
$set['title'] = 'Блоги';
include_once H.'sys/inc/thead.php';


if (isset($user))
{

// Лайк
if (isset($_GET['like'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['like'])."' LIMIT 1"));

// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '1')");

$mgs_like = "[b]".$user['nick']."[/b] понравился ваш блог!";
mysql_query("INSERT INTO `journal` (`user`, `time`, `act`, `opis`, `ank`, `url`) VALUES ('".$user['id']."', '".$time."', 'blogs', '".$mgs_like."', '".$blog['id_user']."', '/user/blogs/read/?id=".$blog['id']."')");

// Выводим в списке понравившихся в закладках
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmarks_like` WHERE `id_user` = '".$user['id']."' AND `id_object` = '".$blog['id']."' AND `type` = 'blog' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `bookmarks_like` (`type`,`id_object`, `id_user`, `time`) VALUES ('blog','$blog[id]', '$user[id]', '$time')");
}

}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Голосование запрещено.';
}
header("Location: ?List=1");
exit;
}
// Дизлайк
if (isset($_GET['dlike'])){
$blog = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".intval($_GET['dlike'])."' LIMIT 1"));


// Запрещаем нам!
if ($user['id'] != $blog['id_user']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$blog['id']."' LIMIT 1"),0) == 0){
mysql_query("INSERT INTO `notes_like` (`id_notes`, `id_user`, `like`) VALUES ('$blog[id]', '$user[id]', '0')");
}
else{
$_SESSION['err'] = 'Вы уже голосовали за блог.';
}
}
else{
$_SESSION['err'] = 'Голосование запрещено.';
}
header("Location: ?List=1");
exit;
}

if(isset($_GET['sort'])){
	mysql_query("UPDATE `user` SET `blog_view` = '".($user['blog_view'] == 1 ? '0' : '1')."' WHERE `id` = '$user[id]'");
	header("Location: ?List=1");
	exit;
}

}


title();

if(isset($user) && $user['level'] >= 3){
$komu_vidn3 = "";
}
else{
$komu_vidn3 = " AND `private` != '2'";
}


$set['p_str'] = '10';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_comm` = '0'$komu_vidn3 ORDER BY `time`"), 0);

?>
<div class="lc_br wbg font0 relative oh" id="header_path">  <a href="/" style="font-size:0;"> <img src="/style/i/lb/home.png" alt=""> </a>     <span class="lc_brw"> <img src="/style/i/lb/sep.png" alt="" class="lc_br_sep"> <a href="/user/blogs/">Блоги</a> </span>       </div>

<div class="wrapper-nobg">   
<form action="/user/blogs/" method="get">  
<table class="table__wrap search-wrap input-txt_grid"> <tbody><tr> 
<td class="input-txt_grid_input"> 
<div class="input-txt_wrapper_search relative"> <input class="input-txt" name="query" value="" maxlength="250" type="text"> </div> 
</td> 
<td class="input-txt_grid_sep"></td> 
<td class="input-txt_grid_btn"> <input class="search__btn" value="Найти" name="cfms" type="submit"> </td> 
</tr> </tbody></table>     
</form>   
</div>

<div class="tabs_block oh">    
<a href="/user/blogs/" class="tab_item left" style="padding: 12px 9px 8px 9px">  Каналы</a>      
<a href="/user/blogs/?List=0" class="tab_item left" style="padding: 12px 9px 8px 9px">  Популярные  </a>   
<div class="tab_item left tab_active black" style="padding: 12px 9px 8px 9px">  Новые  </div>  
</div>
<?

if(isset($user) && $k_post > 0){
?>
<div class="wrapper block oh">    
<!-- --> 
<span class="right">  
<span class="inl_bl" onclick="short_mode_switch();" style="cursor: pointer;">      
<span class="inl-link    link-grey c-grey">  
<!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Вид</span><!--    --><!-- --><!-- --><!-- -->
</span><!-- --> 
</span> 
</span> 
</div>
<div id="short_mode_switch" style="display: none"> 
<div class="wrapper">      
<a href="?List=1&sort" class="link -full   grey c-grey <?= ($user['blog_view'] == 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/short.png" alt="" class="m"> <!--   --><span class="m">Краткий вид</span><!--    --></span>  
</a>         
<a href="?List=1&sort" class="link -full   grey c-grey <?= ($user['blog_view'] != 1 ? 'b form-checkbox_checked' : '')?>"> 
<span><!--     --><img src="/style/i/ico/extended.png" alt="" class="m"> <!--   --><span class="m">Расширенный вид</span><!--    --></span>  
</a>     
</div>
</div>  
<?
}

$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `notes` WHERE `id_comm` = '0'$komu_vidn3 ORDER BY `time` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0){
?>
<div class="wrapper"> <div class="link"> Блоги не найдены. </div> </div>
<?
}
else{

if(isset($user) && $user['blog_view'] == 1){
?>
<div class="wrapper bb0">
<?
}

while ($post = mysql_fetch_assoc($q))
{
$us_ank = get_user($post['id_user']);
$ank = get_user($post['id_user']);
$koment = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_komm` WHERE `id_notes` = '".$post['id']."'"), 0);
$kan_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notes_dir` WHERE `id` = '".$post['id_dir']."' LIMIT 1"));
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_like = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$us_dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);

$_msg = text($post['msg']);
if (iconv_strlen($_msg, 'UTF-8') > 50) {
        $_msg= iconv_substr($_msg, 0, 200, 'UTF-8');
        $_msg = $_msg.'...';
}


if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="wrapper bb0">
<?
}

?>
<div class="block bord-botm relative attaches_limiter"> 
<div class="oh">
<span class="right"> <span class="grey m"><?= vremja($post['time'])?></span>   </span>
<div class="grey"> <?= group($us_ank['id'])?> <?= unick($us_ank['id'])?> </div>     
<div class="cl pad_t_a"></div>  
<?
if ($post['file_ves'] != 0 && $post['file_raz'] != NULL && is_file(H."user/blogs/files/".$post['id'].".dat"))
{
if ($post['file_raz'] == 'png' || $post['file_raz'] == 'gif' || $post['file_raz'] == 'jpg' || $post['file_raz'] == 'jpeg')
{
?>
<div class="left t-padd_right">     
<div>  
<span class="short_attach">   
<div class="inl_bl">        
<span class="pr">   
<div class="inl_bl relative"> 
<img src="/user/blogs/file/<?= $post['id']?>.<?= $post['file_raz']?>" alt="" class="preview s81_80"  style="width:80px;height:80px;">   
</div>     
</span>             
</div>     
</span>  
</div>    
</div>
<?
}
}
?> 
<div class="oh"> 
<a class="arrow_link full_link" href="/user/blogs/read/?id=<?= $post['id']?>"> 
<b>  <?= text($post['name'])?>  </b> 
</a>  
<div> <?= $_msg?> </div>  
</div>   </div> 
<?
if($koment > 0 || $kan_post['name'] != null || $post['count'] > 0){
?>
<div>  
<div class="oh">   
<div class="oh cl grey pad_t_a" style="padding-top: 5px;">  
<?
if(isset($user) && $user['blog_view'] == 1 && $koment > 0){
?> 
<span class="left"> 
<img src="/style/i/comm_ico.png" class="m p16" alt=""> 
<span class="m"><?= $koment?></span> 
</span>  
<?
}
if($kan_post['name'] != null){
?> 
<span class="m <?= (isset($user) && $user['blog_view'] == 1 ? 'right' : '')?>"> <?= text($kan_post['name'])?> </span>  
<?
}
if(!isset($user) || $user['blog_view'] != 1){
if($post['count'] > 0){
?>
<span class="right"> <!--     --><img src="/style/i/eye.png" alt="" class="m"> <!--   --><span class="m"><?= $post['count']?></span><!--    --> </span>
<?
}
}
?> 
</div>  
<div class="cl"></div> </div> </div>    
<?
}
?>
<div class="cl"></div> 
</div>
<?


if(isset($user) && $user['id'] != $ank['id']){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$post['id']."' LIMIT 1"),0) == 0){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down.png';
}
else{
if($us_like){
$ico_vote_up = 'vote_up_on.png';
$ico_vote_down = 'vote_down.png';
}elseif($us_dlike){
$ico_vote_up = 'vote_up.png';
$ico_vote_down = 'vote_down_on.png';
}
}
}
elseif ($user['id'] == $ank['id'] || !isset($user)){
$ico_vote_up = 'vote_up_disabled.png';
$ico_vote_down = 'vote_down_disabled.png';
}

if(!isset($user) || $user['blog_view'] != 1){
?>
<div class="oh bord-botm js-action_bar action-bar"> 
<table class="table__wrap table__wrap-fixed grey"> <tbody><tr>   
<td class="table__cell relative m"> 
<a href="/user/blogs/read/?id=<?= $post['id']?>" class="link" title="Обсудить"> 
<img src="/style/i/action_bar/comment.png" alt="" class="m">  
<span class="m grey <?= ($koment == 0 ? 'hide' : '')?>"><?= $koment?></span> 
</a> 
</td>         
<td class="table__cell relative m"> 
<span>   
<span class="bmc t-padd_right"> 
<a href="?List=1&like=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_up?>" alt="" class="m p16"> </a>  
<span class="m <?= ($like == 0 ? 'hide' : '')?>"><?= $like?></span>  
</span>  
</span>  
</td>   
<td class="table__cell relative m bord-right0">
<span>   
<span class="bmc"> 
<a href="?List=1&dlike=<?= $post['id']?>" class="arrow_link m"> <img src="/style/i/action_bar/<?= $ico_vote_down?>" alt="" class="m p16"> </a>  
<span class="m <?= ($dlike == 0 ? 'hide' : '')?>"><?= $dlike?></span>  
</span>   
</span>  
</td>  
</tr> </tbody></table>          
</div>

</div>
<?
}

}
if(isset($user) && $user['blog_view'] == 1){
?>
</div>
<?
}


if ($k_page > 1)str("?List=1&amp;",$k_page,$page); // Вывод страниц

}



include_once H.'sys/inc/tfoot.php';

break;
}