<?include('header.php');

if(!(isset($_SESSION["username"]) && isset($_SESSION["password"])))
{
	?>
	<script type="text/javascript">
	location.replace("login.php");
	</script>
	<noscript>
	<meta http-equiv="refresh" content="0; url=login.php">
	</noscript>
	<?
	exit();
}

$user=text($_SESSION["username"]);

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

<?
$adse=intval($_GET["ad"]);
$res1=mysql_query("select * from forum where id='$adse' and tema='1'");
$row1=mysql_fetch_assoc($res1);

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

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

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

$ogl44t=$row1t["ogl"];
$id44t=$row1t["id"];
?>

<img style="vertical-align: middle;" src="images/f_st.png" border="0" align="absmiddle"> <a href="forum.php"><b>Форумы</b></a>
<img style="vertical-align: middle;" src="images/f_st.png" border="0" align="absmiddle"> <a href="forum1.php?ad=<?=$id44t?>"><b><?=$ogl44t?></b></a>
<img style="vertical-align: middle;" src="images/f_st.png" border="0" align="absmiddle"> <a href="forum1.php?ad=<?=$id44t?>"><b><?=$ogl44?></b></a>
<img style="vertical-align: middle;" src="images/f_st.png" border="0" align="absmiddle"> <b>Новое сообщение</b><br><br>
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<td align="right"></td>
</tr>
</thead>
</table>
<?

$whois=mysql_query("SELECT * FROM forum WHERE id='$adse' and ban_forum='1'");
$whois=mysql_fetch_assoc($whois);
if($whois["ban_forum"]=='1')
{
echo "<div class=error>Тема Закрыта. </div>";
include('footer.php');
exit;
}

$username=text($_SESSION["username"]);
$whois=mysql_query("SELECT * FROM tb_users WHERE username='$username'");
$whois=mysql_fetch_assoc($whois);
if($whois['ban_forum']==1 or $st_users[$duser["ball_status"]]["comm_forum"] == 0){echo '<div class=error>шибка! Доступ ограничен!</div>'; include('footer.php'); exit;}

if($_POST["action2"]=="add13")
{

          require_once('bbcode.php');

        $descr = bbcod(strip_tags($_POST["message1"]), true, true);



	$author=$user;
	$data=date("d.m.Y в H:i");


// Вырезаем html тэги

	if ($descr==""){echo "<div class=error>&nbsp;Указаны не все параметры</div>"; include('footer.php'); exit();}
	if( strtolower($_POST['code'])!= strtolower($_SESSION['logcaptcha']) OR !isset($_SESSION["logcaptcha"]))
{echo "<div class=error>Неверно введён проверочный код!</div>";
include('footer.php');
exit;}
unset($_SESSION["logcaptcha"]);


$date = time();
$sql44="INSERT INTO forum (user, text, ogl, razdel, status, data, tema) VALUES ('$author','$descr','$ogl44','$razdel','$id44','$data','0')";
mysql_query($sql44);
mysql_query("UPDATE forum SET date=$date WHERE status = '$id44' and tema = '1'");
mysql_query("UPDATE tb_users SET post_forum=post_forum+1 WHERE username='$username'");

		echo "<div class=good>Сообщение добавлено</div>";
echo '
<script type="text/javascript">document.location.href="forum2.php?ad='.$id44.'";</script>
<noscript><meta http-equiv="refresh" content="0; url=forum2.php?ad='.$id44.'"></noscript>
';

	}
	include("copilca/css.php");

?>

<div class='navil'>
<script type="text/javascript" src="js/bbcod.js"></script>

<form id="comment" method="POST" action="">
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
</table>
<input name="status" type="hidden" value="comment">
<table border="0" width="90%" align="center">
<tr>
<td align="left" colspan="2" style="padding-bottom:3px;font-size:11px;">
<b>Форма для отправки сообщений:</b>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="padding-bottom:3px;font-size:11px;">
<b style="color:#dd0000;"><?=$errcom?></b>
</td>
</tr>
<td align="left" border:1px solid #c0c0c0;">
<span class="btn-bold" title="Выделить жирным" value=" B " onclick="insert_comm('[b]','[/b]')" type="button"></span>
<span  class="btn-italic" title="Выделить курсивом" value=" I " onclick="insert_comm('[i]','[/i]')" type="button"></span>
<span  class="btn-uline" title="Выделить подчёркиванием" value=" U " onclick="insert_comm('[u]','[/u]')" type="button"></span>
</td>
<td align="right" border:1px solid #c0c0c0;">
<table>
 <td class="smile"><input style="background: url('copilca/smile/1.gif');border:0;height: 18px;width:18px;" onclick="insert_comm('',':-_')" type="button"></td>
 <td class="smile"><input style="background: url('copilca/smile/2.gif');border:0;height: 23px;width:26px;" onclick="insert_comm('',':-8')" type="button"></td>
 <td class="smile"><input style="background: url('copilca/smile/3.gif');border:0;height: 22px;width:24px;" onclick="insert_comm('',':-(')" type="button"></td>
 <td class="smile"><input style="background: url('copilca/smile/4.gif');border:0;height: 25px;width:25px;" onclick="insert_comm('',':~)')" type="button"></td>
 <td class="smile"><input style="background: url('copilca/smile/5.gif');border:0;height: 20px;width:20px;" onclick="insert_comm('',':-9')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/6.gif');border:0;height: 27px;width:20px;" onclick="insert_comm('','8-)')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/7.gif');border:0;height: 20px;width:20px;" onclick="insert_comm('','9-)')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/8.gif');border:0;height: 22px;width:31px;" onclick="insert_comm('','10-)')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/9.gif');border:0;height: 24px;width:31px;" onclick="insert_comm('','11-)')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/10.gif');border:0;height: 27px;width:47px;" onclick="insert_comm('','12-)')" type="button"></td>
<td class="smile"><input style="background: url('copilca/smile/11.gif');border:0;height: 23px;width:26px;" onclick="insert_comm('','13-)')" type="button"></td>
</table>
</td>

<tr>
<td align="center" colspan="2">
<textarea id="comess" name="message1" rows=0 class="comtextur"></textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="padding-top:3px;">
<font color="#dd0000"><b>Введите код:</b></font> <img src="logincap.php" align="absmiddle"> <input type='text' size='3' maxlength='4' name='code' autocomplete="off" onChange="getZakaz(this.form)" value="">
<input type="submit"  value="Написать" class="ok_wm" >
<input type=hidden value="add13" name="action2">
</td>
</tr>
</table>
</div>
<?include ('footer.php'); ?>


