<?php

require_once '../incfiles/core.php';
require_once '../incfiles/func.php';
require_once '../incfiles/auth.php';
require_once '../incfiles/user.php';

if (empty($user_id)) {go(URL.'/');}

if ($user['notifications_journal'] > 0) mysql_query("UPDATE `users` SET `notifications_journal` = 0 WHERE `id` = '".$user_id."' LIMIT 1");
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `notifications` WHERE `type` != 'new_friend' AND `time` < '".(time()-3600*24*7)."' LIMIT 1"),0) == true) mysql_query("DELETE FROM `notifications` WHERE `type` != 'new_friend' AND `time` < '".(time()-3600*24*7)."'");

$title = 	lang('Мои Ответы','Мої Відповіді');
require_once '../incfiles/head.php';

echo '<div class="title">'.$title.'</div>';

	$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `notifications` WHERE `for_id` = '".$user_id."'"),0);
	if ($all == true)
	{
		$cp = ceil($all/10);
		$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
		$start = $p*10-10;

		$res = mysql_query("SELECT * FROM `notifications` WHERE `for_id` = '".$user_id."' ORDER by `time` DESC LIMIT $start,10");
		while ($arr = mysql_fetch_array($res))
		{
			echo notifications_journal($arr,'list');
		}
	
		navi($p,$cp,''.URL.'/user/journal.php?');
	}

require_once '../incfiles/foot.php';

?>