Файл: modules/user/blag.php
Строк: 37
<?php
if(isset($user)) {
if ($db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->rowCount() == 0)
{
header('Location: /');
exit();
}
$usr = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->fetch();
$locate = 'in_profile';
$title = 'Благодарности';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Благодарности пользователя - <b>'.$usr['nick'].'</b>');
$bl_q = $db->query("SELECT * FROM `blag` WHERE `user_id` = '". $user['id'] ."' AND `user_blag` = '". abs(intval($_GET['user_id'])) ."' ORDER BY id DESC LIMIT 1");
while($bl = $bl_q->fetch()) {
$time = $bl['time'] + 2592000;
}
if(isset($_POST['send']) && !empty($_POST['text'])) {
$text = substr(input($_POST['text']), 0, 500);
if($user['id'] != abs(intval($_GET['user_id'])) && time() > $time) {
$db->query("INSERT INTO `blag`(`user_id`, `time`, `text`, `user_blag`) VALUES('". $user['id'] ."', '". time() ."', '". $text ."', '". $usr['id'] ."')");
}
echo '<div class="menu">Вы поблагодарили пользователя<br /><a href="/user/blag.php?user_id='.$usr['id'].'">Продолжить</a></div>';
$tpl->div('block', img('nav.png') .'<a href="/user/'.$usr['id'].'/">'. $lang->word('back') .'</a><br/>'
. HICO. ' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
if(isset($user) && $user['id'] != abs(intval($_GET['user_id'])) && time() > $time) {
echo '<div class="menu"><b>Сообщение</b>:
<form action="" method="post">
<textarea name="text"></textarea><br/>
<input name="send" type="submit" value="Поблагодарить" />
</form>
</div>';
}
$blag = $db->query("SELECT * FROM `blag` WHERE `user_blag` = '". $usr['id'] ."'")->rowCount();
$pages = new Paginator($blag, $ames);
if($blag == 0) {
$tpl->div('menu', '<center>Нет благодарностей</center>');
} else {
$b_q = $db->query("SELECT * FROM `blag` WHERE `user_blag` = '". $usr['id'] ."' ORDER BY time DESC LIMIT $start, $ames");
while($b = $b_q->fetch()) {
$tpl->div('post', ''.nick($b['user_id']) .' ('. rtime($b['time']) .')<br/><b>Текст:</b> '. output($b['text']) .'');
}
$pages->view('/user/blag.php?user_id='. $usr['id'] .'&');
}
$tpl->div('block', img('nav.png') .'<a href="/user/'.$usr['id'].'/">'. $lang->word('back') .'</a><br/>'
. HICO. ' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
} else { go('/'); }
?>