<?php
include('../global.php');
header('Refresh: 5');
  
echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Chat frame</title>
<meta http-equiv="Content-Language" content="cs">
<meta http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
</head><body>');
  
if(array_key_exists('nick',$_GET)) 
{
  $_SESSION['nick'] = $_GET['nick'];  
  include_once('webchatsend.php');
  Send('Alive','');  
} 
 
$List = array();
echo('<table style="height: 100; font-family: Arial;" width="100%" cellspacing="0" cellpadding="2" border="1" bgcolor="#d0d0d0"><tr><td bgcolor="#ffffff" width="90%" valign="top" style="font-size: 14px;">');

$DbResult = $Database->select('sunrisechat_history','*,UNIX_TIMESTAMP(time)',' roomtype=0 ORDER BY time DESC LIMIT 0,24');
while($List[] = $DbResult->fetch_array());
array_pop($List);
$List = array_reverse($List);
foreach($List as $Row)
{
  $Text = htmlspecialchars($Row['text']);
  if(substr($Text,0,strlen($_SESSION['nick'])) == $_SESSION['nick']) $Text = '<strong>&lt;'.$Row['nick'].'&gt; '.$Text.'</strong>';
  else $Text = '&lt;'.$Row['nick'].'&gt; '.$Text;
  echo('['.date('H:i:s',$Row['UNIX_TIMESTAMP(time)']).'] <span style="color: #'.dechex($Row['color']).'">'.$Text.'</span><br>');
}
echo('</td></tr></table>
</body></html>');
?>
