Просмотр файла modules/friends/index.php

Размер файла: 1.93Kb
<?php
if(!isset($user)) {
	header('location: /');
	exit;
}
if($db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount() != 0)
	{
		$friends_r = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount();
	}
else
	{
		$friends_r = $db->query("SELECT * FROM `friends` WHERE `user_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount();
	}
$title = $lang->word('friends');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('friends').' ('.$friends_r.')');

$pages = new Paginator($friends_r, $ames);
if($friends_r == 0)
	{
		$tpl->div('menu', $lang->word('friends_no'));
	}
else
	{
		if( $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount() !=0)
			{
				$friends_q = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1' ORDER BY friend_id DESC LIMIT $start, $ames");
			}
		else
			{
				$friends_q = $db->query("SELECT * FROM `friends` WHERE `user_id` = '". $user['id'] ."' AND `active` = '1' ORDER BY friend_id DESC LIMIT $start, $ames");
			}
		while($friends = $friends_q->fetch())
			{
				if($friends['user_id'] == $user['id']) 
				{
					$friend_id = $friends['friend_id'];
				} 
				else 
				{
					$friend_id = $friends['user_id'];
				}
				echo '<div class="menu">
						'.nick($friend_id).' [<a href="/friends/delete/'.$friends['id'].'">x</a>]
					</div>';
			}
		$pages->view('/friends/?');
	}
$tpl->div('block',    NAV.' <a href="/friends/requests">'.$lang->word('friends_requests').'</a> ('.$db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '0'")->rowCount().')<br/> '
					. NAV . ' <a href="/user/panel/">'.$lang->word('user_panel').'</a><br/> '
					. HICO. ' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>