View file VK_dlja_DS_wmzo_ru/user/tape/index.php

File size: 5.75Kb
<?

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;

only_reg();
	
/* Класс к статусу */

if (isset($_GET['likestatus']))
{

	// Статус пользователя
	$status = mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id` = '".intval($_GET['likestatus'])."' LIMIT 1"));
	$ank = get_user($status['id_user']);
	if ($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']);
			
			$lentaSet = mysql_fetch_array(mysql_query("SELECT * FROM `tape_set` WHERE `id_user` = '".$a['id']."' LIMIT 1")); // Общая настройка ленты
			if ($a['id'] != $ank['id'] && $f['lenta_status_like']==1 && $lentaSet['lenta_status_like']==1)
			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']));
		exit;
	}
}


$set['title']='Лента';
include_once '../../sys/inc/thead.php';

/*
===============================
Очищение списка непрочитанных
===============================
*/
if (isset($_GET['read']) && $_GET['read']=='all')
{
	if (isset($user))
	{
		mysql_query("UPDATE `tape` SET `read` = '1' WHERE `id_user` = '$user[id]'");
		$_SESSION['message'] = 'Список непрочитанных очищен';
		header("Location: ?page=".intval($_GET['page'])."");
		exit;
	}
}


/*
===============================
Полная очистка ленты
===============================
*/
if (isset($_GET['delete']) && $_GET['delete']=='all')
{
	if (isset($user))
	{
		mysql_query("DELETE FROM `tape` WHERE `id_user` = '$user[id]'");
		$_SESSION['message'] = 'Лента успешно очищена';
		header("Location: ?");
		exit;
	}
}
title();
err();
aut();


?>
<link type="text/css" rel="stylesheet" href="/style/tape_vk.css?835">
<?

$k_notif = mysql_result(query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); 

if ($k_notif > 0)
$k_notif = '<em class="Tw1nGo7">' . $k_notif . '</em>';
else 
$k_notif = null;

$discuss = mysql_result(query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "), 0); 

if ($discuss > 0)
$discuss = '<em class="Tw1nGo7">' . $discuss . '</em>';
else 
$discuss = null;

$lenta = mysql_result(query("SELECT COUNT(`read`) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "), 0); 

if ($lenta > 0)
$lenta = '<em class="Tw1nGo7">' . $lenta . '</em>';
else 
$lenta = null;

?>
<div class="Tw1nGo1">    
<div class="Tw1nGo2 Tw1nGo3">
<ul class="Tw1nGo4">  
<li><a class="Tw1nGo5 Tw1nGo6 al_tab" href="/user/tape/" data-header="Лента">Лента <?= $lenta?></a></li> 
<li><a class="Tw1nGo5 al_tab" href="/user/discussions/" data-header="Обсуждения">Обсуждения <?= $discuss?></a></li>  
<li><a class="Tw1nGo5 al_tab" href="/user/notification/" data-header="Уведомления">Уведомления <?= $k_notif?></a></li>   
</ul>
</div>
</div>

<div class="basisDefault">
<div class="basisDefault__row">
<div class="notificationList notificationList_type_viewed Tw1nGo8" data-id="viewed">
<?


$set['p_str'] = 10;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `tape`  WHERE `id_user` = '$user[id]' "),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page-$set['p_str'];

if ($k_post > 0) {
?>
<div class="Pad__header Row">
<h3 class="Pad__title">В ленте: <b><?= $k_post?></b></h3>
<a class="Pad__corner" href="settings.php">Настройки</a>
</div>
<?
}


?>
<div class="Pad__content notificationList__items">
<?

$q = mysql_query("SELECT * FROM `tape` WHERE `id_user` = '$user[id]' 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']);
	$name = null;
	
	if ($post['read'] == 0)
	{
		$s1 = "<font color='red'>";
		$s2 = "</font>";
		mysql_query("UPDATE `tape` SET `read` = '1' WHERE `id` = '$post[id]'");
	}
	else
	{
		$s1 = null;
		$s2 = null;
	}

	/*
	===============================
	Помечаем сообщение прочитанным
	===============================
	*/	

	
	
	$d = opendir('inc/');

	while($dname = readdir($d))
	{
		if ($dname != '.' && $dname != '..')
		{
			include 'inc/' . $dname;
		}
	}
	
}

?>
</div>
</div></div>
</div>
<?

if ($k_page > 1)str('?',$k_page,$page); 


if ($k_post > 0) 
{
?>
<div class="Pad__header Row">
<a class="Pad__corner tape_views" href="?read=all">  Отметить всё как прочитанное</a>
</div>
<div class="Pad__header Row" style="border-top: 1px solid #e9e9e9;">
<a class="Pad__corner tape_dell" href="?delete=all">  Очистить ленту</a>
</div>
<?
}

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