<center>
<p>&nbsp;</p>
<table style="width:100%;" cellpadding="0" cellspacing="0"><tr><td style="width:70%;background-color : #FFF9F0;"><?php
if (!empty($_POST['comment_is']) and ($_POST['comment_is']<>'комментарий')){
	if ($_POST['code_comment']<>$_SESSION['code']){
		echo '<center><p><span class="div_bbig">Введенный вами код неверен</span></p></center>';
	}else{
		if ($_SESSION['IsEnter'] == 1){
			$_POST['comment_login'] = $_SESSION['IsMyLogin'];
		}else{
			if ($_POST['comment_login']=='' or $_POST['comment_login']=='Ваш ник'){$_POST['comment_login'] = 'Гость';}else{
				$_POST['comment_login'] = addslashes(htmlspecialchars($_POST['comment_login']));
				$_SESSION['cmt_login'] = $_POST['comment_login'];
			}
		}
		$_POST['comment_is'] = addslashes(htmlspecialchars($_POST['comment_is']));
		$_POST['comment_is'] = str_replace("\r\n", "<br />", $_POST['comment_is']);
				
		mysql_select_db('onestyle_w');
		$query = "insert into octblTag_" . $_GET['d'] . " (c_word_id, c_nick, c_comment, c_date, c_reg) values (" . $_GET['u'] . ", '" . $_POST['comment_login'] . "', '" . $_POST['comment_is'] . "', '" . date('j.m.Y, H:i:s') . "', ";
		if ($_SESSION['IsEnter'] == 1){$query .= "1)";}else{$query .= "0)";}
		$result = mysql_query($query) or print("облом, но все-таки: <br />");
		mysql_select_db('onestyle_testmy');
		echo '<center><p><span class="div_bbig">Ваш комментарий добавлен</span></p></center>';
	}
}else{
	echo '<center><p><span class="div_bbig">Вы еще не добавили комментарий</span></p></center>';
}
?></td><td rowspan="2"><FORM style="position:relative;top:-2px;" class="sm" METHOD="POST" id="add_comment" action="<?php echo $_SERVER['REQUEST_URI'] . "#add_comment";?>">
<center><textarea class="cwidth" style="background-color : #FFF9F0;border: 0px none transparent;border-bottom: 1px solid #FCCE92;" rows="7" name="comment_is">комментарий</textarea>
<div class="p_block rgt">
<?php
if ($_SESSION['IsEnter'] == 1){
	echo "Ник: " . "<pre style='display:inline;'>" . $_SESSION['IsMyLogin'] . "</pre>";
}else{
?>
<input class="cinline input_or" size="40" maxlength="40" type="text" name="comment_login" value="<?php if (isset($_SESSION['cmt_login'])){echo $_SESSION['cmt_login'];}else{ echo "Ваш ник";} ?>" />
<?php } ?>
</div></center>
<table><tr><td><img src="code.php"></td>
<td class="sm">Введите цифры: <input class="cinline" type="text" size="4" maxlength="4" name="code_comment">
<input type="Submit" name="comment_Send" value="Добавить">
</td></tr></table>
</FORM>
<div class="pg10 sm">
<?php
	if ($i > 5){
		include "../ggl_ref_200.php";
	}
?>
</div></td></tr><tr><td style="border-right: 3px solid #FFF9F0;border-bottom: 3px solid #FFF9F0;border-left: 3px solid #FFF9F0;">
<div class="black_block cntr" style="color:#FCCE92;"><span class="div_bbig">Комментарии</span> <a class="a_tags" title="Комментарии к другим записям" href="forcomment.php?d=<?php echo $_GET['d'];?>&u=<?php echo $_GET['u']?>">[ другие ]</a></div>
<?php
mysql_select_db('onestyle_w');
$query = "select * from octblTag_" . $_GET['d'] . " where c_word_id= " . $_GET['u'] .  " ORDER BY commentid asc";

$result = mysql_query($query);
$z = mysql_num_rows($result);
$num_result = $z;

$i = 0;
if ($num_result){
	echo '<div class="black_block_c">';
	for ($i=0; $i<$num_result; $i++){
		$row = mysql_fetch_array($result);?>
<div class="bl_w sm">
<?php
echo $i + 1;
?>
:
<span class="div_bbig">
[<?php echo $row['c_date']; ?>]&nbsp;&nbsp;</span><?php 
if ($row['c_reg'] == 1){echo "<span class='sm' style='color:navy;'>[ reg ]</span> ";}
echo "<pre style='display:inline;'>" . $row['c_nick'] . "</pre>"; ?></div>
<div class="tfont pg10"><span><?php
echo $row['c_comment'] . '<p>&nbsp;</p></span></div>'; 
	}
	echo '</div>';
}else{
	echo '<p class="cntr">Комментариев нет</p>';
}
mysql_select_db('onestyle_testmy');
?>
<div class="black_block">
<span id="result_bar">Всего: <?php echo $z; ?>&nbsp;&nbsp;&nbsp;&nbsp;</span>
</div>
</td></tr></table>
</center>
