<?
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/adm_check.php';
include_once '../../sys/inc/user.php';
$my = null;$frend = null;$all = null;
if (isset($_GET['read']) && $_GET['read']=='all')
{
if (isset($user))
{
mysql_query("UPDATE `discussions` SET `count` = '0' WHERE `id_user` = '$user[id]'");
msg('Список непрочитанных очищен');
}
}
if (isset($_GET['delete']) && $_GET['delete']=='all')
{
if (isset($user))
{
mysql_query("DELETE FROM `discussions` WHERE `id_user` = '$user[id]'");
msg('Список обсуждений удален');
}
}
//------------------------like к статусу-------------------------//
if (isset($_GET['likestatus']))
{
$status=mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id` = '".intval($_GET['likestatus'])."' LIMIT 1"));
$ank=get_user(intval($_GET['likestatus']));
if (isset($user) && $user['id']!=$ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]' AND `id_user` = '$user[id]' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `status_like` (`id_user`, `time`, `id_status`) values('$user[id]', '$time', '$status[id]')");
######################Лента
$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '".$user['id']."' AND `i` = '1'");
while ($f = mysql_fetch_array($q))
{
$a=get_user($f['frend']);
mysql_query("INSERT INTO `tape` (`id_user`,`ot_kogo`, `avtor`, `type`, `time`, `id_file`) values('$a[id]', '$user[id]', '$status[id_user]', 'status_like', '$time', '$status[id]')");
}
#######################Конец
header("Location: ?page=".intval($_GET['page'])."&likeok");
}
}
//----------------------------------------------------------------//
$set['title']='Обсуждения';
include_once '../../sys/inc/thead.php';
title();
err();
aut();
if (isset($_GET['likeok']))
msg('Ваш голос успешно засчитан');
if (isset($_GET['order']) && $_GET['order']=='my')
{
$order = "AND `avtor` = '$user[id]'";
$sort = "order=my&";
$my = 'activ';
}
else if (isset($_GET['order']) && $_GET['order']=='frends')
{
$order = "AND `avtor` != '$user[id]'";
$sort = "order=frends&";
$frend = 'activ';
}
else
{
$order = null;
$sort = null;
$all = 'activ';
}
echo "<div id='comments' class='menu'>";
echo "<div class='webmenu'>";
echo "<a href='?' class='$all'>Все</a>";
echo "</div>";
echo "<div class='webmenu last'>";
echo "<a href='?order=my' class='$my'>Мои</a>";
echo "</div>";
echo "<div class='webmenu last'>";
echo "<a href='?order=frends' class='$frend'>Друзья</a>";
echo "</div>";
echo "</div>";
echo "<div class='foot'>";
echo "<a href='?read=all'><img src='/style/icons/ok.gif'> Отметить всё как прочитанное</a>";
echo "</div>";
if (isset($user))
{
$num=0;
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$user[id]' $order"),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 `discussions` WHERE `id_user` = '$user[id]' $order ORDER BY `time` DESC LIMIT $start, $set[p_str]");
if ($k_post==0)
{
echo " <div class='main'>\n";
echo "Нет новых обсуждений\n";
echo " </div>\n";
}
while ($post = mysql_fetch_assoc($q))
{
$type = $post['type'];
$avtor = get_user($post['avtor']);
if ($post['count']>0)
{
$s1 = "<font color='red'>";
$s2 = "</font>";
}else{
$s1 = null;
$s2 = null;
}
if ($type=='status' && $post['avtor']!=$user['id']) // статусы
{
$name = 'Статус друга';
}
else if ($type=='status' && $post['avtor']==$user['id'])
{
$name = 'Ваш статус';
}
else if ($type=='foto' && $post['avtor']!=$user['id']) // фото
{
$name = 'Фотография друга';
}
else if ($type=='foto' && $post['avtor']==$user['id'])
{
$name = 'Ваше фото';
}
else if ($type=='notes' && $post['avtor']!=$user['id']) // дневники
{
$name = 'Дневник друга';
}
else if ($type=='notes' && $post['avtor']==$user['id'])
{
$name = 'Ваш дневник';
}
else if ($type=='them' && $post['avtor']!=$user['id']) // форум
{
$name = 'Форум | Тема друга';
}
else if ($type=='them' && $post['avtor']==$user['id'])
{
$name = 'Форум | Ваша тема';
}
else if ($type=='obmen' && $post['avtor']!=$user['id']) // обмен
{
$name = 'Обменник | Файл друга';
}
else if ($type=='obmen' && $post['avtor']==$user['id'])
{
$name = 'Обменник | Ваш файл';
}
########################################Статусы начало
if ($type=='status')
{
$status=mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id` = '".$post['id_sim']."' LIMIT 1"));
if ($status['id']){
echo '<div class="nav1">';
echo "<img src='/style/icons/comment.png' alt=''/> <a href='/user/status/komm.php?id=$status[id]'>$s1 $name $s2</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="nav2">';
echo " <b><font color='green'>$avtor[nick]</font></b> ".medal($avtor['id'])." ".online($avtor['id'])." <br />";
echo "".output_text($status['msg'])."<br />";
echo "<a href='/user/status/komm.php?id=$status[id]'><img src='/style/icons/bbl4.png' alt=''/> " . mysql_result(mysql_query("SELECT COUNT(*) FROM `status_komm` WHERE `id_status` = '$status[id]'"),0) . "</a>";
$l=mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]'"),0);
if (isset($user) && $user['id']!=$avtor['id']){
if ($user['id']!=$avtor['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]' AND `id_user` = '$user[id]' LIMIT 1"),0)==0){
echo " <a href='?likestatus=$status[id]&page=$page'><img src='/style/icons/like.gif' alt=''/>Класс!</a> • ";
$like = $l;
}else{
echo " <img src='/style/icons/like.gif' alt=''/> Вы и ";
$like = $l-1;
}
}else{
echo " <img src='/style/icons/like.gif' alt=''/> ";
$like = $l;
}
echo "<a href='/user/status/like.php?id=$status[id]'>$like чел.</a>";
echo "</div>";
}
}
#########################################Статусы конец
########################################Форум начало
if ($type=='them')
{
$them=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_t` WHERE `id` = '".$post['id_sim']."' LIMIT 1"));
$razdel=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_r` WHERE `id` = '$them[id_razdel]' LIMIT 1"));
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '$razdel[id_forum]' LIMIT 1"));
if ($them['id']){
echo '<div class="nav1">';
echo "<img src='/style/icons/pencil_go.png' alt=''/> <a href='/plugins/forum/$forum[id]/$razdel[id]/$them[id]/'>$s1 $name $s2</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="nav2">';
echo " <b><font color='green'>$avtor[nick]</font></b> ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($them['name'])."</b><br />";
echo rez_text(bbcode(htmlspecialchars($them['text'])))."";
echo "</div></div>";
}
}
#########################################Форум конец
########################################Дневники начало
if ($type=='notes')
{
$notes=mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '".$post['id_sim']."' LIMIT 1"));
if ($notes['id']){
echo '<div class="nav1">';
echo "<img src='/style/icons/dnev.png' alt=''/> <a href='/plugins/notes/list.php?id=$notes[id]'>$s1 $name $s2</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="nav2">';
echo " <b><font color='green'>$avtor[nick]</font></b> ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($notes['name'])."</b><br />";
if ($notes['type']==0)
{
echo rez_text(bbcode(htmlspecialchars($notes['msg'])))."";
}
else if ($notes['type']==1)
{
$q3=mysql_query("SELECT * FROM `notes_image` WHERE `id_notes` = '".intval($notes['id'])."' ORDER BY `id` limit 3");
while ($post3 = mysql_fetch_assoc($q3))
{
echo "<a href='/sys/notes/$notes[id]/$post3[url].jpg'><img style=' max-width:48px; margin:3px;' src='/sys/notes/pr_$notes[id]/$post3[url].jpg' alt=''/></a>\n";
}
}
echo "</div>";
}
}
#########################################Дневники конец
########################################Фотографии начало
if ($type=='foto')
{
$foto=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '".$post['id_sim']."' LIMIT 1"));
$gallery=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '".$foto['id_gallery']."' LIMIT 1"));
if ($foto['id']){
echo '<div class="nav1">';
echo "<img src='/style/icons/camera.png' alt=''/> <a href='/foto/$avtor[id]/$gallery[id]/komm/$foto[id]/'>$s1 $name $s2</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="nav2">';
echo "<b><font color='green'>$avtor[nick]</font></b> ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($foto['name'])."</b><br />";
echo "<a href='/foto/$avtor[id]/$gallery[id]/$foto[id]/' title='$foto[name]'>
<img style=' max-width:48px; margin:3px;' src='/foto/foto48/$foto[id].$foto[ras]' alt='$foto[name]' /></a>\n";
echo "</div>";
}
}
#########################################Фотографии конец
########################################Обмен начало
if ($type=='obmen')
{
$file=mysql_fetch_assoc(mysql_query("SELECT * FROM `obmennik_files` WHERE `id` = '".$post['id_sim']."' LIMIT 1"));
$dir=mysql_fetch_assoc(mysql_query("SELECT * FROM `obmennik_dir` WHERE `id` = '".$file['id_dir']."' LIMIT 1"));
if ($file['id']){
echo '<div class="nav1">';
echo "<img src='/style/icons/disk.png' alt=''/> <a href='/obmen$dir[dir]".urlencode($file['id']).".$file[ras]?showinfo'>$s1 $name $s2</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="nav2">';
echo "<b><font color='green'>$avtor[nick]</font></b> ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($file['name'])."</b><br />";
if ($file['opis'])echo rez_text(bbcode(htmlspecialchars($file['opis'])))."<br />";
echo "<img src='/style/icons/files.png' alt=''/> <a href='/obmen$dir[dir]".urlencode($file['id']).".$file[ras]'>Скачать</a> ";
echo "</div>";
}
}
#########################################Обмен конец
}
if ($k_page>1)str('?'. $sort .'',$k_page,$page); // Вывод страниц
//------------------------alex-borisi-------------------------//
echo "<div class='foot'>";
echo "<a href='?delete=all'><img src='/style/icons/delete.gif'> Удалить все обсуждения</a>";
echo "</div>";
echo "<div class='foot'>\n";
echo "« <a href='/info.php'>Моя страничка</a><br />\n";
echo "</div>\n";
}
include_once '../../sys/inc/tfoot.php';
?>