Файл: vk.com_vhllam/user/discussions/index.php
Строк: 240
<?
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&";
$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';
}
$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 class='cont'>";
echo "<img src='/style/icons/str2.gif' alt='*' /> <a href='/user/tape/'>Лента $lenta</a> |";
echo "<a href='/user/discussions/'> Обсуждения $discuss</a> |";
echo "<a href='/user/notification/'> Уведомления $k_notif</a>";
echo "</div>";
echo "<div class='gmenu'>- Сортировать: ";
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='err'>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=='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="x1">';
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="x2">';
echo " <b><font color='green'>$avtor[nick]</font></b> " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[<font color='green'>Ред.</font>]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($them['name'])."</b> <br />";
echo rez_text(bbcode(htmlspecialchars($them['text'])))."";
echo "</div>";
}else{
echo '<div class="x1">';
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="x1">';
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="x2">';
echo " <b><font color='green'>$avtor[nick]</font></b> " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[<font color='green'>Ред.</font>]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." » <b>".htmlspecialchars($notes['name'])."</b> <br />";
echo rez_text(htmlspecialchars($notes['msg']))."";
echo "</div>";
}else{
echo '<div class="x1">';
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="x1">';
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="x2">';
echo "<b><font color='green'>$avtor[nick]</font></b> " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[<font color='green'>Ред.</font>]</a>" : "") . " ".medal($avtor['id'])." ".online($avtor['id'])." » <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="x1">';
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="x1">';
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]&page=$pageEnd'>$name</a> ";
if ($post['count']>0)echo "<b><font color='red'>+$post[count]</font></b>";
echo "</div>";
echo '<div class="x2">';
echo "<b><font color='green'>$avtor[nick]</font></b> " . ($avtor['id'] != $user['id'] ? "<a href='user.settings.php?id=$avtor[id]'>[<font color='green'>Ред.</font>]</a>" : "") . " ".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>";
}else{
echo '<div class="x1">';
echo 'Файл уже удален =(';
echo " $s1 ".vremja($post['time'])." $s2 ";
echo "</div>";
}
}
}
if ($k_page>1)str('?'. $sort .'',$k_page,$page); // Вывод страниц
//-------------------------------------------------//
echo "<div class='cont'>";
echo "<a href='?read=all'><img src='/style/icons/ok.gif'> Отметить всё как прочитанное</a>";
echo "</div>";
echo "<div class='cont'>";
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';
?>