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

Размер файла: 2.34Kb
<?php


if (!isset($user))
{
    header('Location: /');
	exit;
}

if(isset($_GET['accept']) && $db->query("SELECT * FROM `friends` WHERE `id` = '". abs(intval($_GET['accept'])) ."' AND `friend_id` = '". $user['id'] ."'")->rowCount() != 0) 
	{
		$db->query("UPDATE `friends` SET `active` = '1' WHERE `id` = '". abs(intval($_GET['accept'])) ."'");
		$db->query("INSERT INTO `notify` SET `user_id` = '". abs(intval($_GET['id'])) ."', `from_id` ='". $user['id'] ."', `type` = 'notify_verify_friend', `read` = '0', `time` = '". time() ."'");
		header('location: /friends/');
		exit;
	}
elseif(isset($_GET['delete']) && $db->query("SELECT * FROM `friends` WHERE `id` = '". abs(intval($_GET['delete'])) ."' AND `friend_id` = '". $user['id'] ."'")->rowCount() != 0) 
	{
		$db->query("DELETE FROM `friends` WHERE `id` = '". abs(intval($_GET['delete'])) ."' LIMIT 1");
		$db->query("INSERT INTO `notify` SET `user_id` = '". abs(intval($_GET['id'])) ."', `from_id` ='". $user['id'] ."', `type` = 'notify_unverify_friend', `read` = '0', `time` = '". time() ."'");
		header('location: /friends/');
		// print_r($db->errorInfo());
		exit;
	}
		
$title = $lang->word('friends_requests');
require_once(SYS .'/view/header.php');


$friends_r = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '".$user['id']."' AND `active` = '0'")->rowCount();
$pages = new Paginator($friends_r, $ames);

if ($friends_r == 0)
{
    echo '<div class="menu">'. $lang->word('no_friends_requests').'</div>';
}
else
{
    $friends_q = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '$user[id]' AND `active` = '0' LIMIT $start, $ames");

    while ($friends = $friends_q->fetch())
    {
		echo '<div class="menu">
        '. nick($friends['user_id']) .'<br />
        [<a href="/friends/requests/'.$friends['user_id'].'?accept='. $friends['id'] .'">'. $lang->word('accept').'</a>][<a href="/friends/requests/'.$friends['user_id'].'?delete='. $friends['id'] .'">'. $lang->word('delete').'</a>]
        </div>';
    }

    $pages->view('/friends/requests/?');
}

echo '<div class="block">
'. img('users.png') .' <a href="/friends">'. $lang->word('friends').'</a><br />
'. img('nav.png') .' <a href="/user/panel">'. $lang->word('user_panel').'</a><br />
'. HICO .' <a href="/">'. $lang->word('home').'</a><br />
</div>';

require_once(SYS .'/view/footer.php');
?>