<?



/*



=======================================



Обсуждения для Dcms-Social



Автор: Искатель



---------------------------------------



Этот скрипт распостроняется по лицензии



движка Dcms-Social. 



При использовании указывать ссылку на



оф. сайт http://dcms-social.ru



---------------------------------------



Контакты



ICQ: 587863132



http://dcms-social.ru



=======================================



*/



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]'");



	$_SESSION['message'] = 'Список непрочитанных очищен';



	header("Location: ?");



	exit;



}



}







if (isset($_GET['delete']) && $_GET['delete']=='all')



{



if (isset($user))



{



	mysql_query("DELETE FROM `discussions` WHERE `id_user` = '$user[id]'");



	$_SESSION['message'] = 'Список обсуждений очищен';



	header("Location: ?");



	exit;



}



}







//------------------------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'])."");



}



}



//----------------------------------------------------------------//











if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions`  WHERE `id_user` = '$user[id]' AND `count` > '0' AND `avtor` = '$user[id]'"),0) > 0)



$count_my = " <img src='/style/icons/tochka.png' alt='*'/>";



else



$count_my = null;







if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions`  WHERE `id_user` = '$user[id]' AND `count` > '0' AND `avtor` <> '$user[id]'"),0) > 0)



$count_f = " <img src='/style/icons/tochka.png' alt='*'/>";



else



$count_f = null;















$set['title']='Обсуждения';



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



title();



err();



aut();











if (isset($_GET['order']) && $_GET['order']=='my')



{



	$order = "AND `avtor` = '$user[id]'";



	$sort = "order=my&amp;";



	$my = 'activ';



}



else if (isset($_GET['order']) && $_GET['order']=='frends')



{



	$order = "AND `avtor` != '$user[id]'";



	$sort = "order=frends&amp;";



	$frend = 'activ';



}



else



{



	$order = null;



	$sort = null;



	$all = 'activ';



}















$k_notif = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); // Уведомления







if ($k_notif > 0)$k_notif = '<font color=red>('.$k_notif.')</font>';



else $k_notif = null;







$discuss = mysql_result(mysql_query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "),0); // Обсуждения







if ($discuss > 0)$discuss = '<font color=red>('.$discuss.')</font>';



else $discuss = null;







$lenta = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "),0); // Лента







if ($lenta > 0)$lenta = '<font color=red>('.$lenta.')</font>';



else $lenta = null;











echo "<div id='comments' class='menus'>";



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



echo "<a href='/user/tape/'>Лента $lenta</a>";



echo "</div>"; 



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



echo "<a href='/user/discussions/' class='activ'>Обсуждения $discuss</a>";



echo "</div>"; 



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



echo "<a href='/user/notification/'>Уведомления $k_notif</a>";



echo "</div>"; 



echo "</div>";







	echo "<div class='foot'>Сортировать: ";



	echo "<a href='?' > Все </a>  |  ";



	echo " <a href='?order=my' > Мои$count_my </a>  |  ";



	echo " <a href='?order=frends' > Друзья$count_f </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='mess'>\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 "  $s1 ".vremja($post['time'])." $s2 ";



	echo "<img src='/style/icons/comment.png' alt='*'/> <a href='/user/status/komm.php?id=$status[id]'>$name</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> " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[!]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." <br />";



	echo '<div class="st_1"></div>';	



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



	echo "".output_text($status['msg'])."<br />";



	echo "</div>";



	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]&amp;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>";



}else{



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



	echo 'Статус уже удален =(';



	echo "  $s1 ".vremja($post['time'])." $s2 ";



	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 "  $s1 ".vremja($post['time'])." $s2 ";



	echo "<img src='/style/icons/forum.png' alt='*'/> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=$pageEnd'>$name</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>  " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[!]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." &raquo; <b>".htmlspecialchars($them['name'])."</b>  <br />";







	echo rez_text(bbcode(htmlspecialchars($them['text']))).""; 







	echo "</div>";



}else{



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



	echo 'Тема уже удалена =(';



	echo "  $s1 ".vremja($post['time'])." $s2 ";



	echo "</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 "  $s1 ".vremja($post['time'])." $s2 ";



	echo "<img src='/style/icons/dnev.png' alt=''/> <a href='/plugins/notes/list.php?id=$notes[id]'>$name</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>  " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[!]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." &raquo; <b>".htmlspecialchars($notes['name'])."</b>  <br />";







	echo rez_text(htmlspecialchars($notes['msg'])).""; 







	echo "</div>";



}else{



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



	echo 'Дневник уже удален =(';



	echo "  $s1 ".vremja($post['time'])." $s2 ";



	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 "  $s1 ".vremja($post['time'])." $s2 ";



	echo "<img src='/style/icons/camera.png' alt=''/> <a href='/foto/$avtor[id]/$gallery[id]/$foto[id]/?page=$pageEnd'>$name</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>  " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[!]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." &raquo; <b>".htmlspecialchars($foto['name'])."</b><br />";



	echo "  <br />



	<img style=' max-width:48px; margin:3px;' src='/foto/foto50/$foto[id].$foto[ras]' alt='$foto[name]' /> \n";







	echo "</div>";







}else{



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



	echo 'Фото уже удалено =(';



	echo "  $s1 ".vremja($post['time'])." $s2 ";



	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 "  $s1 ".vremja($post['time'])." $s2 ";



	echo "  <img src='/style/icons/disk.png' alt=''/> <a href='/user/personalfiles/$file[id_user]/$file[my_dir]/?id_file=$file[id]&amp;page=$pageEnd'>$name</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>  " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[!]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." &raquo; <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>";







}else{



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



	echo 'Файл уже удален =(';



	echo "  $s1 ".vremja($post['time'])." $s2 ";



	echo "</div>";



}



}















}







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











//------------------------alex-borisi-------------------------//



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



	echo "<a href='?read=all'><img src='/style/icons/ok.gif'> Отметить всё как прочитанное</a>";



	echo "</div>"; 



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



	echo "<a href='?delete=all'><img src='/style/icons/delete.gif'> Удалить все обсуждения</a> | <a href='settings.php'>Настройки</a>";



	echo "</div>"; 



}



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



?>