View file xmyx.ru/notifi/index.php

File size: 6.45Kb
<?
include_once $_SERVER['DOCUMENT_ROOT'] . '/sys/inc/home.php';
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';
only_reg();

if (isset($_GET['high']))  {
  if (isset($user)) {
    $id = (int) $_GET['high'];
  	if (mysql_result(query("SELECT COUNT(*) FROM `notifi`  WHERE `id_user` = '$user[id]' AND `id` = '$id'"),0) == 1) {
    	query("DELETE FROM `notifi` WHERE `id_user` = '$user[id]' AND `id` = '$id' LIMIT 1");
    	header('Location: ?');
    	exit;
  	}
  }
}

function short_text($text, $words_count = 70, $break = '...') {
	$data = explode(' ', $text);
	$count = count($data);
	$data = array_slice($data, 0, $words_count);
	$text = implode(' ', $data);
	if ($count > $words_count)
		$text.= '...';
	return $text;
}

$act = isset ($_GET['act']) ? stripcslashes(htmlspecialchars($_GET['act'])) : '';

switch ($act) {

default:

$set['title'] = __('Уведомления');
include_once H.'sys/inc/thead.php';

shapka_VK(false, '', 'Уведомления');

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

?>
<div class="head_panel">    
<div class="hp_block tabs_block">
<ul class="tabs_list">    
<li><a class="tab_item tab_item_cur al_tab" href="?" data-header="Просмотренные">Просмотренные</a></li>   
<?
if($k_post_new > 0){
?> 
<li><a class="tab_item al_tab" href="?act=new" data-header="Новые">Новые <em class="tab_counter"><?= $k_post_new?></em></a></li>
<?
}
?>
</ul>
</div>
</div>

<div class="basisDefault">
<?
$friend_c = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0);  
$friend_c_post = mysql_query("SELECT * FROM `frends_new` WHERE `to` = '$user[id]' ORDER BY time DESC LIMIT 1");

if($friend_c > 0){
?>
<div class="basisDefault__row"><div class="friendRequestsPreview Pad">
<a class="friendRequestsPreview__content Row Row_go" href="/friends?act=notify">    
<div class="Row__go Icon Icon_chevron_right"></div> 
<?
while ($post_l = mysql_fetch_array($friend_c_post))
{
$p_ank = get_user($post_l['user']);  
$p_ank['nick'] = u_nick($p_ank['id']);
$count_pep_l = $friend_c - 1;
$count_pep = array('человек', 'человека', 'человек');
?>       
<div class="friendRequestsPreview__avatar "><?= avka50($p_ank['id'], 'Avatar Avatar_1 Avatar_size_m')?></div>
<div class="friendRequestsPreview__body">
<div class="friendRequestsPreview__title">Заявки в друзья</div>
<div class="friendRequestsPreview__description"><?= $p_ank['nick']?> 
<?
if($friend_c > 1){
?>
и еще <?= des2num($count_pep_l, $count_pep)?>
<?    
}
?>
</div>
</div>
<?
}
?>
</a>
</div></div>
<?
}





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

$set['p_str'] = '15';
$k_post = mysql_result(query("SELECT COUNT(*) FROM `notifi`  WHERE `id_user` = '$user[id]' AND `read` = '1'"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = query("SELECT * FROM `notifi` WHERE `id_user` = '$user[id]' AND `read` = '1' ORDER BY `time` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
?>
<div class="service_msg_box" style="border-bottom: 0;">
<div class="service_msg service_msg_null">У Вас нет уведомлений.</div>
</div>
<?
}
else{

?>
<div class="Pad__header Row"><h3 class="Pad__title">Просмотренные</h3></div>
<div class="Pad__content notificationList__items">
<?
while ($post = mysql_fetch_assoc($q)) {

$type = $post['type'];
$avtor = get_user($post['avtor']);
$avtor['nick'] = u_nick($avtor['id']);
  
if (is_file('inc/' . $type . '.php')) {
	require 'inc/' . $type . '.php';
} 
else{
	echo __('Плагин уведомления не найден, пожалуйста сообщите об этом администрации.');
?>
<br />Ошибка в плагине: <b><?= $type?></b>
<?
}

}
?>
</div>
<?
}

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

if ($k_page > 1) { 
  str_vk('/notifi/?', $k_page, $page); 
}

break;

case 'new':

$set['title'] = 'Новые уведомления';
include_once H.'sys/inc/thead.php';

shapka_VK(false, '', 'Уведомления');

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

?>
<div class="head_panel">    
<div class="hp_block tabs_block">
<ul class="tabs_list">    
<li><a class="tab_item al_tab" href="?" data-header="Просмотренные">Просмотренные</a></li>    
<?
if($k_post_new > 0){
?> 
<li><a class="tab_item tab_item_cur al_tab" href="?act=new" data-header="Новые">Новые <em class="tab_counter"><?= $k_post_new?></em></a></li>
<?
}
?>
</ul>
</div>
</div>

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

$set['p_str'] = '15';
$k_post = mysql_result(query("SELECT COUNT(*) FROM `notifi`  WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = query("SELECT * FROM `notifi` WHERE `id_user` = '$user[id]' AND `read` = '0' ORDER BY `time` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
?>
<div class="service_msg_box" style="border-bottom: 0;">
<div class="service_msg service_msg_null">У Вас нет новых уведомлений.</div>
</div>
<?
}
else{


?>

<div class="Pad__header Row"><h3 class="Pad__title">Новые уведомления</h3></div>
<div class="Pad__content notificationList__items">
<?
while ($post = mysql_fetch_assoc($q)) {

$type = $post['type'];
$avtor = get_user($post['avtor']);
$avtor['nick'] = u_nick($avtor['id']);
  
if (is_file('inc/' . $type . '.php')) {
	require 'inc/' . $type . '.php';
} 
else{
	echo __('Плагин уведомления не найден, пожалуйста сообщите об этом администрации.');
?>
<br />Ошибка в плагине: <b><?= $type?></b>
<?
}

if ($post['read'] == 0) {
	query("UPDATE `notifi` SET `read` = '1' WHERE `id` = '$post[id]' LIMIT 1");
}

}
?>
</div>
<?
}
?>
</div></div>
</div>
<?
if ($k_page > 1) { 
  str_vk('/notifi/?act=new&', $k_page, $page); 
}

break;
}

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