<?include('header.php');
$user=text($_SESSION["username"]);

require('karera/setup_status.php');
?>
<div class="menucenter">

<?
$adse=intval($_GET["ad"]);

$sql="SELECT * FROM tb_users WHERE username='$user'";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);


$res17=mysql_query("select * from forum where id='$adse'");
$row17=mysql_fetch_assoc($res17);

if(mysql_num_rows($res17) != 1){
echo "<div class=error>Указанная статья не найдена</div>";
include('footer.php');
exit;
}


$ogl8=substr($row17["text"], 0, 20);
$ogl7=$row17["ogl"];
$razdel=$row17["razdel"];

$res1=mysql_query("select * from forum_tema where id='$razdel'");
$row1=mysql_fetch_assoc($res1);

$ogl44=$row1["ogl"];
$id44=$row1["id"];

?>
 <img src="images/f_st.png" border="0" align='absmiddle'> <a href="forum.php"><b>Форумы</b></a>

 <img src="images/f_st.png" border="0" align='absmiddle'> <a href="forum1.php?ad=<?=$id44?>"> <b><?=$ogl44?></b></a>
<img src="images/f_st.png" border="0" align='absmiddle'><b> <?=$ogl7?></b>
<? $whois=mysql_query("SELECT * FROM forum WHERE id='$adse'");
$whois=mysql_fetch_assoc($whois);
if($whois["ban_forum"]=='0' or $st_users[$duser["ball_status"]]["comm_forum"] == 0)
{
?>
<?if(isset($_SESSION["username"]) && isset($_SESSION["password"])){?>
<a href="forum4.php?ad=<?=$adse?>" class="mesega">Ответить</a>
<? }}else{ ?>
<br /><br /><div class=error>Тема закрыта для комментирования</div>
<?
} ?>

<center>
<br>
<?
$datenorm = DATE("d.m.Yг. в H:i");
if(isset($_POST["unbanned"]) )
{
$baname=text($_POST["username"]);
$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois["user_status"]=='user')
{
echo "<div class=error>Вы не являетесь администратором проекта!</div>";
include('footer.php');
exit;
}
mysql_query("INSERT INTO forum_ban (user,moder,date,ban) VALUES('$baname','$username','$datenorm','Разблокирован')") or die(mysql_error());
mysql_query("UPDATE tb_users SET ban_forum='0' WHERE username='$baname'");
echo "<div class=good>Пользователь разблокирован!</div>";
}
if(isset($_POST["banned"]) )
{
$baname=text($_POST["username"]);
$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois["user_status"]=='user')
{
echo "<div class=error>Вы не являетесь администратором проекта!</div>";
include('footer.php');
exit;
}
mysql_query("INSERT INTO forum_ban (user,moder,date,ban) VALUES('$baname','$username','$datenorm','Заблокирован')") or die(mysql_error());
require('karera/setup_ball.php');
$timenow=time();
mysql_query("UPDATE tb_users SET ban_forum='1', ball=ball+'".$ball["ban_forum"]."' WHERE username='$baname'");
mysql_query("INSERT INTO tb_infoball (user, date, ball, referer, mesage) VALUES('$baname', '$timenow', '".$ball["ban_forum"]."', '---', 'Вы были забанены на форуме')") or die(mysql_error());
echo "<div class=good>Пользователь заблокирован!</div>";
}

if(isset($_POST["delete"]))
{
$delid=intval($_POST["id"]);
$res=mysql_fetch_assoc(mysql_query("SELECT * from forum where razdel='$id44' and status='$adse' and id='$delid'"));
$userp=$res["user"];
$textmes=$res["text"];
$username=$_SESSION["username"];
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois["user_status"]=='user')
{
echo "<div class=error>Вы не являетесь администратором проекта!</div>";
include('footer.php');
exit;
}
mysql_query("INSERT INTO forum_mes (user,text,date,moder) VALUES('$userp','$textmes','$datenorm','$username')") or die(mysql_error());
mysql_query("DELETE FROM forum where id='$delid'");
echo "<div class=good>Комментарий успешно удалён!</div>";
}


$num = 15;
$upag = "forum2.php?ad=".$adse."&";
$page = (isset($_GET['n']))? intval($_GET['n']) : 1 ;
$numpag = mysql_num_rows(mysql_query("SELECT `id` FROM `forum` WHERE `razdel`='$id44' and `status`='$adse'"));
$np =$numpag;
$obpag = intval(($np - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $obpag) $page = $obpag;
$nach = $page * $num - $num;
include("navi.php");
$user=text($_SESSION["username"]);
$tabla = mysql_query("SELECT * FROM forum where razdel='$id44' and status='$adse'  order by forum.id asc LIMIT $nach, $num");

while ($row = mysql_fetch_assoc($tabla)) {
$id=$row["id"];
$userr=$row["user"];
$text=$row["text"];
$ogl=$row["ogl"];
$data=$row["data"];
$data1=$row["data1"];
$img=$row["img"];
$chetat=$row["chetat"];

$sq1="SELECT * FROM tb_users where username='$userr'";
$iq1=mysql_query($sq1);
$ro1=mysql_fetch_assoc($iq1);
$ava=$ro1["avatar"];
$post_forum=$ro1["post_forum"];
$user=$row["user"];
$userer=$row["user"];
$res2=mysql_query("select user_status from tb_users where username='$user'");
$res2=mysql_result($res2,0,0);
$name = mysql_num_rows(mysql_query("SELECT * FROM users_online WHERE user='$user'"));
if($name==1) { $online="<span style='color: green'>on-line</span>";}else{ $online="<span style='color: red'>off-line</span>"; }
if($res2=='user') { $cvet='#FFEBCD'; $moderus='';}
if($res2=='admin') { $cvet='#f5f5b5'; $moderus='<div style="font-size:11px;color: #228B22;text-shadow:0px 1px 0px #fff;">&#10003; Менеджер</div>';}
if($res2=='moder') { $cvet='#f5f5b5'; $moderus='<div style="font-size:11px;color: #A06150;text-shadow:0px 1px 0px #fff;">&#10003; Модератор</div>';}
$ball=round($ro1["ball"],2);
require_once('bbcode.php');?>
<script type='text/javascript' src='js/bbcod.js'></script>
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-top:5px;'>
<thead style='background:<?=$cvet ?>'>
<tr>
<td align='left' width='90%' style='color:red; border:solid 1px #F2C0A6; border-right:solid 0px #F2C0A6; font:11px Tahoma; padding:3px; padding-left:5px;'>
<?=$user;?> [<?=$data;?> <?=$data1;?>]</td>
<td align='right' style='color:red; border:solid 1px #F2C0A6; border-right:solid 0px <?=$cvet ?>; border-left:solid 0px #F2C0A6; font:11px Tahoma; padding:3px; padding-left:5px;'>
<?
$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if(($whois["user_status"]=='admin') or ($whois["user_status"]=='moder'))
{
$userava=$row["user"];
$avas=mysql_query("select ban_forum from tb_users where username='$userava'");
$avas=mysql_fetch_assoc($avas);
if($avas["ban_forum"]==0) { ?>
<form action="" method="POST">
<input type='hidden' name="banned" />
<input type='hidden' name="username" value="<?=$userava;?>" /><input type="image" src="images/delete_user.png" alt="блок" title="Заблокировать" style="border:none;padding:0px;"></form>
<? } else { ?>
<form action="" method="POST">
<input type='hidden' name="unbanned" />
<input type='hidden' name="username" value="<?=$userava;?>" /><input type="image" src="images/now_user.png" alt="блок" title="Разблокировать" style="border:none;padding:0px;"></form>
<?}}?>
</td>
<td align='right' style='color:red; border:solid 1px #F2C0A6; border-left:solid 0px #F2C0A6; font:11px Tahoma; padding:3px; padding-left:5px;'>
<?
$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if(($whois["user_status"]=='admin') or ($whois["user_status"]=='moder'))
{ ?>
<form action="" method="POST">
<input type=hidden name="delete">
<input type=hidden name="id" value="<?=$row["id"];?>">
<input type="image" src="images/delete.png" alt="блок" title="Удалить" style="border:none;padding:0px;"></form>
<?
} ?>
</td>
</tr>
</thead>
</table>
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td align='center' width='85px' valign='top' style='border-left:solid 1px #ddd;'>
<left>
<a href='wall.php?user=<?=$userr;?>'>
<div align='center' style='background: url(../images/avbg.png) no-repeat; padding: 2px 0px 0px 0px; width: 78px; height:67px;'>
<img src='avp/<?=$ava;?>' border='0' width='62px' height='62px' title='Стена пользователя'>
</div></a>
<?=$online?><br />
<?=$moderus;?>
</td>
<td colspan='2' align='left' valign='top' style='border-right:solid 1px #ddd;padding:10px;padding-bottom:2px;'>
<?
if($chetat!='')
{
$mass=explode(":~:", $chetat);
echo"<span class='citatf'>$mass[0]</span><span class='citatmes'>$mass[1]</span>";
}
echo"$text"; ?>
<? $whois=mysql_query("SELECT * FROM forum WHERE id='$adse'");
$whois=mysql_fetch_assoc($whois);
if($whois["ban_forum"]=='0')
{ ?>
<table width='470px'>
<tr>
<td align='right' style='border:none;'>
<a href="forum5.php?ad=<?=$adse?>&user=<?=$userr?>&us=<?=$id?>" class="textfor" style="width:60px;">Цитировать</a>
</td>
</tr>
</table>
<? } ?>
</td>
</tr>

<? } ?>
</tbody>
</table>
</center>

<br />
<table width='100%'>
<tr>
<td style='font-size:11px;'>
<img src="images/f_st.png" border="0" align='absmiddle'> <a href="forum.php"><b>Форумы</b></a>
<img src="images/f_st.png" border="0" align='absmiddle'> <a href="forum1.php?ad=<?=$id44?>"> <b><?=$ogl44?></b></a>
<img src="images/f_st.png" border="0" align='absmiddle'><b> <?=$ogl7?></b>
</td>

<? $whois=mysql_query("SELECT * FROM forum WHERE id='$adse'");
$whois=mysql_fetch_assoc($whois);
if($whois["ban_forum"]=='0')
{ ?>
<td align='right'>
<?if(isset($_SESSION["username"]) && isset($_SESSION["password"])){?>
<a href="forum4.php?ad=<?=$adse?>" class="mesega">Ответить</a>
<? } ?>
</td>
<? }?>


<tr></table>
<center><img src="images/verx.png" border="0" align='absmiddle'> <a href='#top' title='Подняться наверх'><b>Подняться наверх!</b></a></center>
<? include('footer.php'); ?>


