Chat
Chat
Ich habe mir einen Chat besorgt, der hauptsächlich auf php basiert. Dazu brauch ich mal bitte Hilfe.
Ich würde gerne die Zeile "There are XX persons in the chat at the moment:" auf meiner Hauptseite integrieren, nur weiß ich nicht, wie ich das schaffe. Kann mir da bitte jemand helfen?
Die Zeile stammt hier her: http://web208.silverline-s19.de/chat/index.php
Die Main Page befindet sich bei mir im Root und der Chat im Ordner "chat", falls das für euch von Bedeutung ist!
Danke!
MfG Dennis
Ich würde gerne die Zeile "There are XX persons in the chat at the moment:" auf meiner Hauptseite integrieren, nur weiß ich nicht, wie ich das schaffe. Kann mir da bitte jemand helfen?
Die Zeile stammt hier her: http://web208.silverline-s19.de/chat/index.php
Die Main Page befindet sich bei mir im Root und der Chat im Ordner "chat", falls das für euch von Bedeutung ist!
Danke!
MfG Dennis
Sorry...also hier der Quellcode der index.php vom Chat:
Code: Alles auswählen
<?
header("Expires: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
include('./config/database.php'); # Read Database-Variables
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
#if ($cfg['MySQL']) {
switch(false){
case($db = @mysql_connect($cfg['server'],$cfg['user'],$cfg['password'])):
$mysqlERROR = mysql_error();
break;
case($dat = @mysql_select_db($cfg['database'],$db)):
$mysqlERROR = mysql_error();
break;
}
if(!$mysqlERROR) {
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
include('./inc/func.get_config.php'); # Read Configuration-Data
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
if ($cfg['chatopen'] == '1') { # -- if chat is open
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
include('./inc/func.user.php'); # Get User-Management-Function
## """"" INCLUDE """"""""""""""""""""""""""""""""""""""""""""
# variable $user_num comes from func.user.php
$text = "There are $user_num persons in the chat at the moment:";
$link = '<a href="javascript:" onClick="openchat();">[ open ZZ:FlashChat ]</a>';
} else { #- if chat is closed
$text = 'The chat is closed at the moment !';
}
@mysql_close($db);
} else {
$text = '<table cellpadding="4" cellspacing="2"><tr>
<td height="30" align="center" style="border: 1px solid #FF6600">
<font color="#FF6600"><b>MySQL Connection failed !</b></font>
</td></tr>
<tr><td align="center" nowrap style="border: 1px solid #666666">
<br>Wrong MySQL connection variables in the config file \'database.php\' !<br><br>
<table width="100%" bgcolor="#ECECEC"><tr><td align="center">
MySQL-ERROR:<br><b><i>'.$mysqlERROR.'</i></b>
</td></tr></table>
</td></tr></table>';
}# END IF CONNECT
#} else {
# $text = 'The MySQL connection variable $cfg[MySQL] does NOT exist in the config file !';
#}# END IF SERVER + USER + PASSWORD
?>
<html>
<head>
<title>ZZ:FlashChat - Start</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="download.zehnet.de">
<meta name="description" content="ZZ:FlashChat is a simple MySQL-based Chat Program with Flash-Interface,
No annoying page refreshes, No cookies, No applets are required ! (http://download.zehnet.de)">
<meta name="keywords" content="download.zehnet.de, Chat, Flash, PHP, MySQL, Script, Free">
<link href="./inc/styles.php?c=<? echo $cfg['bgcolor'].'|'.$cfg['obcolor'].'|'.$cfg['hlcolor'] ?>" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript"><!--
function openchat() {
window.open('login.php','chat','resizable=yes,scrollbars=no,width=650,height=500');
}
//--></SCRIPT>
</head>
<body scroll=no>
<table width="100%" height="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<strong><? echo $text ?></strong><br>
<br>
<? echo $link ?>
</td>
</tr>
</table>
<!-- ZZ:FlashChat by http://download.zehnet.de -->
</body>
</html>
ok, hier ist die inc/func.user.php:
Code: Alles auswählen
<?
# -- USER-MANAGEMENT---------------------------------------------
# this function is used in: index.php, func.login.php
$time = time();
# -- delete all kicked & banned users and users that are still listed after chat was closed last time
$sql = 'DELETE FROM '. $cfg['userdat'] .' WHERE timestamp<'.($time-$cfg['timeout']);
mysql_query($sql, $db);
# delete messages which are older than timelimit
$sql = 'DELETE FROM '.$cfg['msgdat'].' WHERE time<'.($time - ($cfg['minremain'] * 60));
$result = mysql_query($sql, $db);
# -- Get all users which are currently online and chatting
$sql = 'SELECT user FROM '.$cfg['userdat'].' WHERE status=0';
$result = mysql_query($sql, $db);
$user_num = mysql_num_rows($result);
# -- Get number messages currently shown in the chat
$sql = 'SELECT ID FROM '.$cfg['msgdat'];
$result = mysql_query($sql, $db);
$msg_num = mysql_num_rows($result);
# -- killmessages function: if active
# -- delete all remaining messages if there is no user left in the chat and messages are still in the table
if($cfg['killmessages'] && $msg_num!=0 && $user_num==0) {
$sql = 'DELETE FROM '. $cfg['msgdat'];
mysql_query($sql, $db);
$killed=1;
}
# -- if no messages are left in the message-table reset Autoindex to 1
if($msg_num==0 || $killed==1){
$sql = 'ALTER TABLE ' . $cfg['msgdat'] . ' AUTO_INCREMENT=1';
mysql_query($sql, $db);
}
?>
Code: Alles auswählen
$sql = 'SELECT `user` FROM `DEINETABELLE` WHERE status=0';
$result = mysql_query($sql) or die(mysql_error());
$user_num = mysql_num_rows($result);
Code: Alles auswählen
echo $user_num;
[/code]
hier bekommst du ein irc chatmod (ich glaub, derzeit das beste) http://pjirc4phpbb.earlsoft.co.uk