<?php

include '../system/start.php';
include '../system/functions.php';

$str['mesto'] = 'Все статусы';
$str['block'] = $set['site'].' / Все статусы';

include '../style/'.$style.'/head.php';
reg();

$id = abs(intval($_GET['id']));



switch ($act) {
	case 'del':
		$status = mysql_fetch_assoc(mysql_query("SELECT * FROM `statuses` WHERE `id` = '" . $id . "' AND `type` = 'status'"));
		
		if ($status['user'] == $user['id']) {
			mysql_query("DELETE FROM `statuses` WHERE `id` = '" . $id . "' AND `user` = '" . $user['id'] . "' AND `type` = 'status'");
			mysql_query("DELETE FROM `statuses` WHERE `refid` = '" . $id . "' AND `type` = 'komm'");
			echo 'Статус удален из истории!<br /><a href="all_status.php?id=' . $user['id'] . '">Назад</a>';
		} else {
			echo 'Недоступно!';
		}
	break;

default :
	$status = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $id . "'"));

	echo '<div class="where">Все статусы ' . $status['login'] . '</div>';
	
	$r = mysql_query("SELECT * FROM `statuses` WHERE `type` = 'status' AND `user` = '" . $status['id'] . "' ORDER by `time` DESC LIMIT " . $page . "," . $set['str'] . "");
	$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `statuses` WHERE `type` = 'status' AND `user` = '" . $status['id'] . "'"), 0);
	
	if ($total == 0)
		echo 'Статусов еще нет!';
		
	while ($e = mysql_fetch_assoc($r)) {
		
		$num_komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `statuses` WHERE `refid` = '" . $e['id'] . "' AND `type` = 'komm'"), 0);
		
		echo ($i % 2) ? '<div class="forum1">' : '<div class="forum2">';
		echo '<div class="status"><b><!-- clear --></b> ' . $e['text'] . ' (' . date("d.m.Y G:i", $e['time']) . ')</div>
		 <a href="komm.php?id=' . $e['id'] . '"><img class="ico" src="../style/'.$style.'/ico/comments.png" alt="" /> ' . $num_komm . '</a>';
		if ($e['user'] == $user['id'])
			echo ' <a href="?act=del&amp;id=' . $e['id'] . '"><img align="right" class="ico" src="../style/'.$style.'/ico/bdel.png" alt="" /></a>';
		echo '</div>';
		$i++;
	}
	
	if($total > $set['str'])
	{
		pages($page, $total, 'all_status.php?id='.$status['id'].'&amp;', $set['str']);
	}

}
echo '<div class="acln act"><hr>»<a href="../p/'.$user['login'].'">Моя страница</a> »<b>все статусы</b>';
include '../style/'.$style.'/foot.php';
?>