<?php
##############################################################################################
# #
# chat_online.php #
# * ------------------- #
# * begin : Saturday, February 11, 2006 #
# * copyright : (C) 2004-2008 CompWebChess2 Development Team #
# * support : http://www.compwebchess.com/cms/index.php #
# * VERSION: : $Id: chat_online.php,v 1.3 2008/11/13 20:11:43 nelson8317 Exp $ #
# #
##############################################################################################
# This program is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software Foundation; #
# either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; if not, write to: #
# #
# Free Software Foundation, Inc., #
# 59 Temple Place, Suite 330, #
# Boston, MA 02111-1307 USA #
##############################################################################################
session_start();
/* load settings */
if (!isset($_CONFIG))
require_once './includes/config.inc.php';
/* define constants */
require_once './includes/chessconstants.inc.php';
/* include outside functions */
if (!isset($_CHESSUTILS))
require_once './includes/chessutils.inc.php';
require_once './includes/gui.inc.php';
require_once './includes/chessdb.inc.php';
require_once './includes/move.inc.php';
require_once './includes/undo.inc.php';
/* allow WebChess to be run on PHP systems < 4.1.0, using old http vars */
fixOldPHPVersions();
/* check session status */
require_once './includes/sessioncheck.inc.php';
/* if this page is accessed directly (ie: without going through login), */
/* player is logged off by default */
if (!isset($_SESSION['playerID']))
$_SESSION['playerID'] = -1;
/* debug flag */
define ("DEBUG", 0);
/* connect to database */
require_once './includes/connectdb.inc.php';
/* Language selection */
require_once "languages/english/strings.inc.php";
?><html>
<head>
<!-- Automatischer Refresh in Sekunden -->
<META HTTP-EQUIV=Refresh CONTENT="10; URL=chat_online.php">
<title><?php echo "$CFG_SITE_NAME";?> - Public Chat Room</title>
<link rel="stylesheet" href="./themes/<?=$_SESSION["pref_colortheme"]?>/styles.css" type="text/css">
<style>
TABLE {font-size:12; font-family: verdana;}
</style>
</head>
<body class='TD' leftmargin="0" topmargin="0">
<?
echo "
<table class='STATUSTABLE' border='0' width='100%' cellpadding='0' cellspacing='0'> ";
?>
<tr>
<td class='TD' style="text-align: left">
<font face="Verdana" size="2">
<?
// User Online Management
// By Thomas M?ller (thomas@fivedigital.net)
// Five Digital (http://www.fivedigital.net)
$minutes = 5; // Anzahl der Minuten die ein User als inaktiv Online gilt
$minutes = $minutes * 60;
$playerID = $_SESSION['playerID'];
$time = time();
$tmp = mysql_query("SELECT time FROM chat_online WHERE playerID='$playerID'");
$tmp = mysql_fetch_array($tmp);
$tmp = $tmp['time'];
if ($tmp) {
mysql_query("UPDATE chat_online SET time = '$time' WHERE playerID='$playerID'");
}
// Neuer User
else {
$pl = mysql_query("SELECT * FROM players WHERE playerID='".$_SESSION['playerID']."'");
$me = mysql_fetch_array($pl);
mysql_query("INSERT INTO chat_online VALUES ('$playerID', '$time')");
$msg = $me['nick'] . "event-enter";
mysql_query("insert into testchat (fromID,msg,gameID) VALUES ('0','$msg','".$_SESSION[gameID]."')");
}
$deltime = $time - $minutes;
// Inaktive User l?schen
mysql_query("DELETE FROM chat_online WHERE time < '$deltime'");
// XXX Betrit den Chat l?schen
$minutes = 60; // Anzahl der Minuten die Messages gel?scht werden
$minutes = $minutes * 60;
$deltime = $time - $minutes;
mysql_query("DELETE FROM testchat WHERE UNIX_TIMESTAMP(hora) < '$deltime' AND fromID = '0'");
$p = mysql_query("SELECT c.playerID, p.* from chat_online c
LEFT JOIN players p
ON p.playerID = c.playerID");
while($ids = mysql_fetch_array($p))
{
echo "<b>" . $ids['nick'] . "</b><br /> ";
} // while
// Ende User Online Management
?>
</font>
</td>
</tr>
</table>
</body>
</html>