IRC Besucherzahl

D@Sh

Newbie
Registriert
Apr. 2003
Beiträge
4
Guten Morgen

Ich habe da mal eine frage! ihr habt ja auf Computerbase die Besucheranzahl und wie viele im IRC sind, und genau das würde ich gerne wissen i wo man das Script bekommen kann.
 
Also über Google habe ich nichts gefunden und im Forum auch nichts
 
Folgendes selbstgeschriebenes Script verwenden wir auf CB:

PHP:
#!/usr/bin/php
<?php
// IRC-Config
$conf['irc_server'] = "de.quakenet.org";
$conf['irc_port'] = "6667";
$conf['irc_identd'] = "meinbot";
$conf['irc_host'] = "meinedomain.de";
$conf['irc_nickname'] = "MeinBot4";
$conf['irc_realname'] = "Mein netter Bot";
$conf['irc_channel'] = "#computerbase";

$fp = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
if ( $fp == false ) die();
if ( socket_connect( $fp, $conf['irc_server'], $conf['irc_port'] ) == false ) die();

socket_write( $fp, "USER $conf[irc_identd] $conf[irc_host] $conf[irc_server] :$conf[irc_realname]\n\r" );
socket_write( $fp, "NICK $conf[irc_nickname]\r\n" );
get_response(); // Auf PING antworten
socket_write( $fp, "LIST $conf[irc_channel]\r\n" );
socket_write( $fp, "QUIT\r\n" );
get_response();
socket_close( $fp );

function get_response() {
	global $fp, $conf, $glob;

	// Nach "NOTICE" muss das LIST-Kommando gesendet werden, daher vorerst abbrechen
	while( !stristr( $response, "NOTICE $conf[irc_nickname] :on" ) ) {
		if ( !$response = socket_read( $fp, 1024 ) ) die();
		
		// Debug Ausgabe
		echo $response;

		// Eventuell auf PING antworten
		if ( substr( $response, 0, 4 ) == "PING" ) {
			socket_write( $fp, str_replace( "PING", "PONG", $response ) );
		}

		// Antwort auf LIST-Kommando auswerten
		if ( preg_match( "/(.*?)".preg_quote( "$conf[irc_nickname] $conf[irc_channel]" )." ([\d]+)/s", $response, $array ) > 0 ) {
			$users = mysql_escape_string( $array[2] );
			
			// Hier jetzt $users irgendwo (Datenbank, Dateisystem, ...) abspeichern
			echo $users;
		}
	}
}
?>
 
gibts dafür ne Möglichkeit, wenn mein PHP die socket-Befehle nicht unterstützt?
 
Zurück
Oben