<?PHP 
	include_once('./anema.inc.php');
	mt_srand((double)microtime()*1000000);
?>
<html>
<head>
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache">
	<meta http-equiv="Expires" content="0">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<?php
	print('<meta http-equiv="Refresh" content="10;URL=chat'.$ext.'?id='.$id.'&connexion='.$gconnexionid.'">');
	?>
</head>
<body onLoad="window.scroll(0,2000);" TOPMARGIN="0" MARGINHEIGHT="0" LEFTMARGIN="0" MARGINWIDTH="0" >

<font face="Arial, Helvetica, sans-serif" SIZE="2">

<?php

function lienHTML($chaine) { 
	return eregi_replace( '(http|https|ftp)://([[:alnum:]/\n+-=%&:_.~?]+[#[:alnum:]+]*)','<a href="\\1://\\2" target="_blank">\\1://\\2</a>',$chaine);
}
$db->query("SELECT * FROM connectes WHERE idSession='".$id."'");
$db->next_record();
$arrivee=$db->f(2);
$lignes=$db->f(4);
$bip=$db->f(5)==1;
if (isset($msg)) {
	$from=htmlentities(addslashes($db->f(1)));
	$from='<font color="#999999">'.date("H:i:s").'....'.$from.' : </font>';
	$msg=$from.$debutStyle.lienHTML(htmlentities($msg)).$finStyle;
	$ping=time();
	$db->query("INSERT INTO chat VALUES ('".$msg."','".$ping."')");
}
$db->query("SELECT * FROM chat WHERE ping>'".$arrivee."'");
$nombre=$db->num_rows();
$debut=($lignes<$nombre)?$nombre-$lignes:0;
$i=0;
 while ($db->next_record() ) {
	if ($i>=$debut) {
		print($db->f(0)."<br>\n");
	}
	$i++;
 }
if ($bip) {
	print('<script language="JavaScript">alert("Nouvel arrivant !");</script>\n');
	$db->query("UPDATE connectes SET bip='0' WHERE idSession='".$id."'");
}
?>
</font>

</body>
</html>