<?php

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';







if (isset($user))$user_blog=$user['id'];

if (isset($_GET['id']))$user_blog=intval($_GET['id']);



if (!isset($user_blog))

{

$set['title']='Ошибка';

include_once '../../sys/inc/thead.php';



$num = 0;



title();

aut();



echo "Нет такого пользователя";

echo"<div class='foot'>\n";

echo"<a href='index.php'>Заметки</a><br />\n";

echo"</div>\n";

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

exit();

}



$ank_user=get_user($user_blog);

if(!$ank_user)

{

$set['title']='Ошибка';

include_once '../../sys/inc/thead.php';



title();

aut();

echo "Нет такого пользователя";

echo"<div class='foot'>\n";

echo"<a href='index.php'>Заметки</a><br />\n";

echo"</div>\n";

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

exit();

}

function vyvod_text( $text, $maxwords = 21, $maxchar = 210 )

{

$sep=' ';

$sep2='...';

$words = split($sep,$text);

$char = iconv_strlen($text,'utf-8');

if (count($words) > $maxwords)

{

$text = join($sep, array_slice($words, 0, $maxwords));

}

if ( $char > $maxchar )

{

$text = iconv_substr( $text, 0, $maxchar, 'utf-8' );

}

return $text.$sep2;

}





$set['title']='Заметки-'.$ank_user['nick'].'';

include_once '../../sys/inc/thead.php';



err();

title();

aut();



if(isset($user))

{

echo'<div class="foot">';



echo "<a href=\"add.php\">Создать заметку</a><br />";

echo '</div>';

}

if($user['id'] == $user_blog) $where="WHERE `id_user` = '$user_blog'";

else $where="WHERE `privat` = '0' && `id_user` = '$user_blog'";





$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_list` $where"),0);

$k_page=k_page($k_post,$set['p_str']);

$page=page($k_page);

$start=$set['p_str']*$page-$set['p_str'];

echo "<table class='post'>\n";





if($k_post==0)

{

echo "   <tr>\n";

echo "  <td class='p_t'>\n";

echo "Нет заметок<br />";

echo "  </td>\n";

echo "   </tr>\n";

}



$res = mysql_query("select * from `blog_list` $where order by `time` desc LIMIT $start, $set[p_str];"); 

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





$ank=get_user($blog['id_user']);



echo "   <tr>\n";



echo "  <td class='p_t'>\n";

echo "- <a href='list.php?id=".$blog['id']."'>".output_text($blog['name'])."</a> <a href='komm.php?id=".$blog['id']."'>(".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_blog` = '$blog[id]'"),0).")</a>\n";



echo "  </td>\n";

echo "   </tr>\n";

echo "   <tr>\n";



if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";

echo "<a href='/info.php?id=".$ank['id']."'>".$ank['nick']."</a> ";

echo "".medal($ank['id'])." ".online($ank['id'])." (".vremja($blog['time']).")<br />\n";

echo"Просмотров ".$blog['count']."<br />\n";

echo vyvod_text(output_text($blog['msg'], 15, 150));

if (($user['level'] >= 2) || ($user['id'] ==$blog['id_user']))

{

echo "[<a href='edit.php?id=$blog[id]'>ред</a>] [<a href='edit.php?id=$blog[id]&amp;del'>удл</a>]";

}



echo "  </td>\n";

echo "   </tr>\n";

}

echo "</table>\n";



if (isset($user_blog)) $dop="id=$user_blog&amp;";

else $dop='';

if ($k_page>1)str('?'.$dop.'',$k_page,$page); // Вывод страниц





if(isset($user))

{

echo'<div class="foot">';



echo"<a href='index.php'>Заметки</a><br />\n";



echo '</div>';

}









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



?>