Файл: public_html/messlist.php
Строк: 112
<?
session_start();
if(!(isset($_SESSION["username"]) && isset($_SESSION["password"])))
{
echo "<img src="images/error.png" align="middle"> <span style="color:#ff0000"><b>Для доступа к этому разделу необходимо авторизоваться</b></span><br><br>";
exit();
}
$nameus=$_SESSION["username"];
$urlpage='ЧАТ';
require('config.php');
$uo_sessionTime = 1;
error_reporting(E_ERROR | E_PARSE);
$uo_ip = $_SERVER['REMOTE_ADDR'];
$uo_query = "DELETE FROM users_online WHERE unix_timestamp() - lastvisit >= $uo_sessionTime * 60";
mysql_query($uo_query);
$uo_query = "SELECT lastvisit FROM users_online WHERE visitor = '$uo_ip'";
$uo_result = mysql_query($uo_query);
if(mysql_num_rows($uo_result) == 0) {
$uo_query = "INSERT INTO users_online (visitor,lastvisit,user,urlpage) VALUES('$uo_ip', unix_timestamp(), '$nameus', '$urlpage')";
mysql_query($uo_query);
} else {
$uo_query = "UPDATE users_online SET lastvisit = unix_timestamp(), urlpage='$urlpage', user='$nameus' WHERE visitor = '$uo_ip'";
mysql_query($uo_query);
}
mysql_close($con);
?>
<script language=javascript>
if(self==parent) self.window.location='chat.php';
</script>
<script type="text/javascript">
setTimeout('location.replace("messlist.php")', 10000);
</script>
<noscript>
<meta http-equiv="refresh" content="10; url=messlist.php">
</noscript>
<script language=javascript>
function pasteNick(nick)
{
parent.chatform.frmmessadd.mess.value=parent.chatform.frmmessadd.mess.value+nick;
parent.chatform.frmmessadd.mess.focus();
}
</script>
<?
if($_POST["action"]=="delmess")
{
$id=$_POST["id"];
require('config.php');
mysql_query("delete from tb_chat where id='$id'");
mysql_close($con);
echo "<font color=#00cc00><b>Сообщение удалено</b></font><br>";
}
function smile($message)
{
$smiles[]="angel"; $smiles[]="smile"; $smiles[]="sadness"; $smiles[]="wink"; $smiles[]="tongue";
$smiles[]="glasses"; $smiles[]="laugh"; $smiles[]="shy"; $smiles[]="wonder"; $smiles[]="kiss";
$smiles[]="tears"; $smiles[]="anger"; $smiles[]="music"; $smiles[]="flower";
$smiles[]="THUMBS UP"; $smiles[]="cool"; $smiles[]="DONT_KNOW";
for($i=0;$i<=16;$i++)
{
$message=str_ireplace("*".$smiles[$i]."*","<img src="smilies/".$smiles[$i].".gif" align="middle" border="0">",$message);
}
return $message;
}
require('config.php');
$user=$_SESSION["username"];
$res=mysql_query("select chatmoder from tb_users where username='$user'");
$res=mysql_fetch_array($res);
$moder=$res["chatmoder"];
$res=mysql_query("select * from tb_chat order by id desc limit 20");
while($row=mysql_fetch_array($res))
{
$id=$row["id"];
$user=$row["user"];
$res1=mysql_query("select count(id) from tb_chatban where user='$user'");
$res1=mysql_result($res1,0,0);
if($res1<1)
{
$mess=$row["message"];
$mess=smile($mess);
$dt=date("d.m.Y H:i", $row["data"]);
$res2=mysql_query("select user_status,chatmoder from tb_users where username='$user'");
$res2=mysql_fetch_array($res2);
$us=$res2["user_status"];
$cm=$res2["chatmoder"];
if($us=='user') if($cm=='0') { $cvet='333333'; }else{ $cvet='0000ff'; }
if($us=='admin') $cvet='ff0000';
if($us=='') $cvet='cccccc';
if($moder=='0')
{
echo "<table align=left><tr><td><span style="font-size: 16px; color: #$cvet"><b><a href="javascript: pasteNick('$user');">
<img src="../images/edit.png" align="middle"></a> $user </b></span></td>
<td><span style="font-size: 12px; color: #333;"><b>($dt)</b></span></td><td>
<span style="font-size: 14px; color: #000000"><b>: </b></span></td></tr></table><br><br>
<table width=100% style="border-bottom:2px solid #ccc"><tr><td align=left><span style="font-size: 14px; color: #000000">
$mess</span></td></tr></table>";
}else{
echo "<table align=left><tr><td><span style="font-size: 16px; color: #$cvet"><b><a href="javascript: pasteNick('$user');">
<img src="../images/edit.png" align="middle"></a> $user </b></div></span></td>
<td><span style="font-size: 12px; color: #333;"><b>($dt)</b></span></td><td><form action="" method=post>
<input type=hidden value="delmess" name="action">
<input type=hidden value="$id" name="id">
<input type=submit value="Удалить сообщение">
</form></td><td>
<span style="font-size: 14px; color: #000000"><b>: </b></span></td></tr></table><br><br>
<table width=100% style="border-bottom:2px solid #ccc"><tr><td align=left><span style="font-size: 14px; color: #000000">
$mess</span></td></tr></table>";
}
}
}
mysql_close($con);
?>