<?php
	require("__include-common.php");
	require("../account/__logincheck.php");

	$con = my_mysql_connect(_DB_SCHEMA);

	if ($_GET['it'] <> '0') {
		$sql = 'select * from v_messages where ADDDATE(c_registtime, INTERVAL '.$_GET['it'].' HOUR) > NOW() order by id_messages asc';
	} else {
		$sql = 'select * from v_messages order by id_messages asc';
	}
	$rs = my_mysql_query($sql);
	$row = mysql_num_rows($rs);
	if ($row == 0) {
		exit;
	}
	if ($row > $_GET['cn']) {
		$startline = $row - $_GET['cn'];
	} else {
		$startline = 0;
	}
?>
	<table id="chat_view_table" cellspacing=0>
<?php
	mysql_data_seek($rs, $startline);
	while ($rec=mysql_fetch_array($rs)) {
?>
		<tr>
		<td class="chat_view_handle" style="background-color: <?= $rec['c_body_background_color'] ?>"><?= my_htmlspecialchars($rec['c_handle']) ?></td>
		<td class="chat_view_message" style="background-color: <?= $rec['c_body_background_color'] ?>"><?= ins_br(my_htmlspecialchars($rec['c_message'])) ?></td>
		<td class="chat_view_time" style="background-color: <?= $rec['c_body_background_color'] ?>"><?= date_from_mysql("H:i:s m/d", $rec['c_registtime']) ?></td>
		</tr>
<?php
	}
?>
	</table>
<?php
	$con = mysql_close($con);
?>
