Seite 1 von 2

Chat

Verfasst: 27.10.2005 17:53
von damnpunk
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

Verfasst: 27.10.2005 18:29
von fanrpg
*glaskugelreib*...

*nochmalreib* ...

*undwieder* ...

Ist wohl kaputt

Im Ernst:

Ohne Quellcode/SQL Struktur kann dir hier niemand helfen.
Keiner kann dir sagen wie das funktioniert wie der Funktioniert ausser er kennt zufällig den Chat und hat den Quellcode.

Verfasst: 27.10.2005 19:30
von Jensemann
Du könntest die Seite in einem Script per HTTP anfragen (file_get_contents()) und den String zwischen den <strong> Tags herausparsen (preg_match())..

Siehe PHP Manual.

Verfasst: 27.10.2005 20:42
von damnpunk
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>

Verfasst: 27.10.2005 21:38
von fanrpg
poste mal die datei
inc/func.user.php
Dort wird $user_num genreriert dann kann man dir ne MySQL Query schreiben der das anbfragt (oder auch nicht, weiss nicht wie der Chat das macht)

Verfasst: 29.10.2005 02:52
von damnpunk
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);
}
?>

Verfasst: 29.10.2005 11:48
von fanrpg

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);
Und die gesamanzahl der User kannst du dann so ausgeben:

Code: Alles auswählen

echo $user_num;
Und DEINETABELLE musst du in das ändern wie die Tabelle heisst wo die user drin stehen.

[/code]

Verfasst: 01.11.2005 22:37
von damnpunk
dank dir, ich werd mal gucken, ob ich es hinbekomme.

Verfasst: 08.11.2005 16:15
von wortner
Wo kann man sich denn einen chat holen?

Verfasst: 10.11.2005 12:32
von Systron
hier bekommst du ein irc chatmod (ich glaub, derzeit das beste) http://pjirc4phpbb.earlsoft.co.uk