Файл: modules/friends/requests.php
Строк: 91
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
if (!User::logged())
{
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() ."', `request_id` = '/friends/'");
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() ."', `request_id` = '/friends/'");
header('location: /friends/');
// print_r($db->errorInfo());
exit;
}
$title = _t('friends_requests');
include_header($title);
$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">'. _t('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'] .'">'. _t('accept').'</a>][<a href="/friends/requests/'.$friends['user_id'].'?delete='. $friends['id'] .'">'. _t('delete').'</a>]
</div>';
}
$pages->view('/friends/requests/?');
}
echo '<div class="block">
'. img('users.png') .' <a href="/friends">'. _t('friends').'</a><br />
'. img('nav.png') .' <a href="/user/panel">'. _t('user_panel').'</a><br />
'. HICO .' <a href="/">'. _t('home').'</a><br />
</div>';
include_footer();
?>