<?php

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

if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
	$id = abs(intval($_GET['id']));
	$result = mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."' LIMIT 1");
	if (mysql_num_rows($result) == true)
	{
		$arr_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."' LIMIT 1"));
	}
	else
	{
		go(URL.'/');
	}
}
else
{
	go(URL.'/');
}

$title = $arr_user['login'].' :: Интересные записи';
require_once '../incfiles/head.php';

$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blog_like` WHERE `user_id` = '".$arr_user['id']."'"),0);
if ($arr_user['count_like_blog'] != $all) mysql_query("UPDATE `users` SET `count_like_blog` = '".$all."' WHERE `id` = '".$arr_user['id']."' LIMIT 1");
echo '<div class="title">Интересные записи<div class="right">'.$arr_user['count_like_blog'].'</div></div>';

	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 `blog_like` WHERE `user_id` = '".$arr_user['id']."' ORDER by `time` DESC LIMIT $start, 10");
		while ($arr = mysql_fetch_array($res))
		{
			$array = mysql_fetch_array(mysql_query("SELECT * FROM `blog` WHERE `id` = '".$arr['fid']."' LIMIT 1"));
			echo '<div class="block2">';
			echo user_name($arr_user['id']).'<br/>'.vtime($arr['time']).'<div class="text"><div class="hide_text"> </div><ul>'.text($array['text']).'</ul></div><div class="right">';

			if (!empty($user_id) && $user_id != $arr_user['id'])
			{
				if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blog_like` WHERE `fid` = '".$array['id']."' AND `user_id` = '".$user_id."'"),0) == false) echo '<span id="'.$arr['id'].'"><a class="'.$arr['id'].'" href="'.URL.'/blog/like.php?id='.$array['id'].'"><img src="'.URL.'/design/img/like.png"/> <b>'.$array['clike'].'</b></a></span>';
				else echo '<img src="'.URL.'/design/img/ok.png"/> <b>'.$array['clike'].'</b>';
			}
			else
			{
				echo '<img src="'.URL.'/design/img/like.png"/> <b>'.$array['clike'].'</b>';
			}
			echo '</div><a href="'.URL.'/blog/post.php?id='.$array['id'].'">Читать&gt;&gt;</a> <img src="'.URL.'/design/img/comm.png"/> <b>'.$array['comm'].'</b>
			</div>';

?>
<script>
$('#<?echo $arr['id'];?> a').click(function (){ 
var href = $(this).attr('href'); 
$('#<?echo $arr['id'];?>').load(href); 
return false; 
});
</script>
<?
		}
	}

	navi($p,$cp,'/blog/like_blog.php?id='.$arr_user['id'].'&');

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


?>