Файл: forum/theme.php
Строк: 40
<?php
include_once '../system/head.php';
$id=protect(intval($_GET['id']));
$total=mysql_fetch_assoc(mysql_query("select * from `themes` where `id`='$id' limit 1"));
if($total['id']){
if(!empty($_POST['text'])){
$text=nl2br(smiles(bb_code(protect($_POST['text']))));
if($total['status']>0 and $user){
if($time-$user['flood']>40){
mysql_query("INSERT INTO `posts` SET `id_theme` = '$id',`id_forum`= '$total[id_forum]',
`author_id` = '$user[id]',`text` = '$text',`time` = '".time()."',`status`='1' ");
mysql_query("update `user` set `flood`='$time', `balans`=`balans`+1, `posts`=`posts`+1 where `id`='$user[id]'");
echo'<div class="menu">Сообщение добавлено -> <a href="/forum/theme.php?id='.$id.'&page=end">Далее</a></div>';
}else{echo'<div class="menu">Разрешено писать раз в 40 секунд</div>';}
}else{echo'<div class="menu">Ошибка</div>';}
}else{
$razd=mysql_fetch_array(mysql_query("select * from `forum` where `id`='$total[id_forum]'"));
echo'<div class="head"><a href="/forum">Форум</a> / <a href="/forum/forum.php?id='.$total['id_forum'].'">'.$razd['name'].'</a> / '.$total['name'].'</div>';
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `id_theme`='$id'"),0);
$k_page=k_page($k_post,$set['p_str']);$page=page($k_page);$start=$set['p_str']*$page-$set['p_str'];
$sql=mysql_query("select * from `posts` where `id_theme`='$id' order by `time` asc limit $start, $set[p_str]");
while($res=mysql_fetch_array($sql)){
$author = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$res[author_id]' "));
echo'<div class="menu">
<b>'.$start++.' <a href="/profile'.$res['author_id'].'">'.$author['login'].'</a> ['.$author['posts'].']</b>';
if($user['level']=='1')echo' <a href="/?mode=admin&fid=del_post&id='.$res['id'].'">[x]</a> ';
if($user and $total['status']>0)
echo'<a onclick="document.getElementById('text').value=''.$author['login'].', '">[Отв]</a>
<a onclick="document.getElementById('text').value='[quote]От : '.$author[login].' | '.$res['text'].'[/quote] '">[Цит]</a>';
echo'<br /><small>'.clock($res['time']).'</small><br />
'.$res['text'].'</div>';
}
if($total['status']>0 and $user){
if(($time-$user['flood']>40)){
echo '<div class="menu">
<form action="#" method="POST">
Собщение: <br />
<textarea name="text" rows="3" cols="25" id="text"></textarea><br />
<input type="submit" value="Отправить" />
</form></div><div class="menu">
<a href="/info.php?mod=bb_code">BB коды</a> | <a href="/info.php?mod=smiles">Смайлы</a></div>
<div class="menu">
<input name="link" value="http://'.$_SERVER['HTTP_HOST'].'/forum/theme.php?id='.$id.'" type="text"/><br/>
</div>';
}else{echo'<div class="citatka">Чтобы написать, подождите '.(40-($time-$user['flood'])).' cek.</div>';}
}
if ($k_page>1){str('?id='.$id.'&',$k_page,$page);}
}
}else{echo'<div class="menu">Такой темы не существует</div>';}
require_once '../system/foot.php';
?>