File size: 1.97Kb
<?
if(!empty($id))
{
echo'<h3>Чат</h3>';
echo'
<form action="?" method="post" name="forma">
Сообщение:<br/>
<textarea cols="25" rows="3" id="comment" name="text"></textarea><br>
<input type="submit" value="Добавить"/><br/>
</form>';
if(isset($_GET['del']) and $admin==$id)
{
if(mysql_query("delete from sten where id='$_GET[del]'")){echo'Cообщение удалено';}
}
if ($_POST['text']!="")
{
$r_m=mysql_fetch_array(mysql_query("select * from `sten` where id_user='$id' ORDER BY `id` DESC LIMIT 1"));
if($r_m[text]==$_POST['text']){echo'Ваше сообщение повторяет предыдущее!';}
else
{
$data = $den.' '.$mesac.' '.$god.'г.<br/>'.$time;
if(mysql_query("insert into `sten`(`id_user`,`data`,`text`) values('$id','$data','".$_POST['text']."');")){echo "Сообщение добавлено!<br/>";} else {echo mysql_error();}
}
}
$max_mess_sten=30;
$page_sten=$_GET['page_sten'];
if(empty($page_sten)){$page_sten=0;}
$mess_sten = mysql_query("select * from `sten` ORDER BY `id` DESC LIMIT ".$page_sten." ,".$max_mess_sten."");
if(mysql_num_rows($mess_sten)==0){echo'<h3><center>Сообщений нет!</center></h3>';}
while ($mess_sten_array = mysql_fetch_array($mess_sten))
{
$sten_log = mysql_fetch_array(mysql_query("select * from `prof` where id='$mess_sten_array[id_user]'"));
echo '<br/><div class="a"><table width="100%"><tr><td valign="top" width="30%" align="left">';
photo_sten($sten_log[foto],$mess_sten_array[id_user]);
echo '<br/>';
echo'<a href="./anketa.php?id='.$mess_sten_array[id_user].'">'.$sten_log[name].' '.$sten_log[fam].'</a><br/>';
online($mess_sten_array[id_user]);
echo $mess_sten_array[data].'<br/>';
if($admin == $id){echo'<a href="./?del='.$mess_sten_array[id].'">Удалить</a><br/>';}
echo'</td><td>'.check($mess_sten_array[text]);
echo'</td></tr></table></div><br/>';
}
mess_str("sten",$max_mess_sten,$page_sten);
}
?>