Файл: senk.php
Строк: 49
<?
include_once 'system/sys.php';
include 'system/funcs.php';
if(!$cms->us['id']){
header('location: /');
exit;
}
$us = DB::$dbs->queryFetch("SELECT * FROM `us` where `id` = ? limit 1",array(abs(intval($_GET['id']))));
if(!$us['id']){
header('location:/');
exit;
}
$posts = DB::$dbs->querySingle("SELECT count(`id`) from `senk` where (`".(isSet($_GET['komu']) ? 'us':'komu')."` = ?)",array($us['id']));
verh('Поблагодарили '.$us['nick'],$func->uNick($us['id']).' '.(isSet($_GET['komu']) ? 'поблагодарил':'поблагодарили').' '.$posts.' раз');
echo '<div class="list1"><a href="/senk'.$us['id'].'">Поблагодарили</a> | <a href="/senk'.$us['id'].'?komu">Поблагодарил</a></div>';
if($us['id']!=$cms->us['id']){
$flood = DB::$dbs->queryFetch("SELECT * from `senk` where (`us` = ? and `komu` = ?) order by `time` desc limit 1", array($cms->us['id'],$us['id']));
if(!$flood['id'] || (time()-$flood['time']) > 86400){
if(isSet($_GET['add']))
{
$why = secure($_POST['why']);
if(empty($why)){ echo'<div class="list1">Ошибка!</div>'; }else{
DB::$dbs->query("INSERT INTO `senk` set `us` = ?, `komu`= ?, `why` = ?,`time` = ?",array($cms->us['id'],$us['id'],$why,time()));
$value = '[url=/us'.$cms->us['id'].']'.$cms->us['nick'].'[/url] [url=/senk'.$us['id'].']поблагодарил[/url] вас!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?",array($value,time(),$us['id'],1)) or die(mysql_error());
header('location: /senk'.$us['id']);
}
}
echo '<div class="list1"><form action="/senk'.$us['id'].'?add" method="post">
За что:<br><textarea name="why"></textarea><br>
<input type="submit" value="Поблагодарить"/>
</form></div>';
}}
if($posts > 0){
$num = 10;
$total = intval(($posts - 1) / $num) + 1;
$page = abs(intval($_GET['page']));
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$senks = DB::$dbs->query("SELECT * FROM `senk` where (`".(isSet($_GET['komu']) ? 'us':'komu')."` = ?) order by `id` desc limit $start,$num",array($us['id']));
while($senk = $senks->fetch()){
echo '<div class="lst">'.(isSet($_GET['komu']) ? 'Кого: '.$func->uNick($senk['komu']):'Кто: '.$func->uNick($senk['us'])).' ('.t($senk['time']).')<br>За что: <b>'.$func->text($senk['why']).'</b></div>';
}
echo '<div class="lst">';
$func->page('/nar'.$us['id']);
echo '</div>';
}else{ echo '<div class="list1">Нет благодарностей!</div>'; }
echo '<div class="list1"><a href="/us'.$us['id'].'">В анкету '.$us['nick'].'</a></div>';
niz();
?>