function parents($parent=0,$left=0) {
global $tags;
for ($i=0;$i<=count($tags[$parent])-1;$i++) {
$result_minus = mysql_query("SELECT sum(ocenka=1), sum(ocenka=0) FROM ocenka_comment WHERE comment_id='".$tags[$parent][$i][0]."' LIMIT 1");
$ocenka_com=mysql_fetch_array($result_minus);
if ($tags[$parent][$i][2]=='Incognito') $tags[$parent][$i][2]='<font color="#cc1111">Incognito</font>';
echo '<div align="right" style="margin:0px 0px 0px '.$left.'px;">';
echo '<br><table border="0" width="95%" style="border: 1px solid #4874a3;" bgcolor="#fffabc"><tr>';
echo '<td align="left" style="padding:5px 5px 5px 5px;">';
echo '<div id="m'.$tags[$parent][$i][0].'"></div><b>'.$tags[$parent][$i][2].'</b></td>';
echo '<td width="140">';
echo '<span style="font-size:12px;">('.$tags[$parent][$i][3].')</span></td>';
echo '<td width="20" >';
echo '<form method="POST" action="'.$_SESSION[mess_url].'#m'.$tags[$parent][$i][0].'">';
echo '<input type="hidden" name="comment_id" value="'.$tags[$parent][$i][0].'">';
echo '<input type="hidden" name="ocenka" value="1">';
echo '<input type="image" src="comm_up.gif" title="Хороший комментарий" align="middle">';
echo '</form></td>';
echo '<td width="5"><b>'.($ocenka_com[0]-$ocenka_com[1]).'</b></td>';
echo '<td width="20">';
echo '<form method="POST" action="'.$_SESSION[mess_url].'#m'.$tags[$parent][$i][0].'">';
echo '<input type="hidden" name="comment_id" value="'.$tags[$parent][$i][0].'">';
echo '<input type="hidden" name="ocenka" value="0">';
echo '<input type="image" src="comm_down.gif" title="Плохой комментарий" align="middle">';
echo '</form></td></tr></table>';
echo '<table border="0" width="95%" style="border: 1px solid #eeeeee;"bgcolor="#f0fff0">';
echo '<tr><td width="100"><img src="'.$ava_user[$tags[$parent][$i][2]].'">';
echo '<td>';
if (($ocenka_com[0]-$ocenka_com[1])<0)
echo '<div><a href="javscript://" class="spoiler_link">Показать / скрыть плохой комментарий</a><div class="spoiler_body">'.wordwrap(nl2br($tags[$parent][$i][1]), 70, "\n", 1).'</div></div>';
else echo wordwrap(nl2br($tags[$parent][$i][1]), 70, "\n", 1);
echo '</td></tr></table>';
echo '<div align="center" style="width:100px; border: 1px solid #000;"><span class="size14" onClick="comm_on(0,'.$tags[$parent][$i][0].','.$tags[$parent][$i][4].')">Ответить</span></div>';
if (isset($tags[ $tags[$parent][$i][0] ])) parents($tags[$parent][$i][0],20);
echo '</div>';
}
}
$result = mysql_query("SELECT * FROM comment WHERE theme='".$_SESSION[mess_url]."' and moderation=1 and first_parent=0 ORDER BY id", $db);
$number = mysql_num_rows($result);
$zapros='';
for ($n=1; $n<=$number; $n++) {
$parents[$n]=mysql_fetch_array($result);
$zapros.=$parents[$n][id].','.$parents[$n][id].',';
}
$zapros=substr($zapros, 0, -1);
$result = mysql_query("SELECT * FROM comment WHERE theme='".$_SESSION[mess_url]."' and moderation=1 and (id IN(".$zapros.") or first_parent IN(".$zapros."))", $db);
$number = mysql_num_rows($result);
if ($number>0) {
while ($comments=mysql_fetch_assoc($result)) $tags[(int)$comments['parent_id']][]=array((int)$comments['id'], $comments['message'], $comments['login'], $comments['date'], $comments['plus'], $comments['minus'], $comments['first_parent']);
echo parents().'</div>';
echo '<div style="padding:3px;margin-top:10px; border-top:3px solid #09C;">
<p align="center"><strong>Последние комментарии посетителей:</strong></p><br></div>';
}