Curiosity is insubordination in its purest form. -Vladimir Nabokov

jueves, 16 de marzo de 2006

Mostrar nicks conectados a un canal IRC con PHP

He programado este codigo PHP para mostrar los usuarios conectados a un canal del IRC.
<?php
// botbc 2.0 Por vlan7
// http://www.vlan7.org

$servidor = 'dune.irc-hispano.org';
$puerto = 6667;
$nick = 'botbc';
$host = 'www.vlan7.org';
$canal='#canal';

$con = array();

$con['socket'] = fsockopen($servidor, $puerto);

if (!$con['socket']) {
print ("No se ha podido conectar con $servidor en el puerto $puerto");
} else {
fputs($con['socket'], "USER $nick $host $host ".$nick."\n\r");
fputs($con['socket'], "NICK $nick ".$host."\n\r");

$salir=false;
$eof=false;
while ((!$eof) && (!$salir)) {
$con['buffer']['linea'] = trim(fgets($con['socket'], 1024));

if(substr($con['buffer']['linea'], strpos($con['buffer']['linea'], 'End of /WHO list'))=='End of /WHO list') {
fclose($con['socket']);
$salir=true;
}

if(substr($con['buffer']['linea'], 0, strlen($servidor)+5) == ':'.$servidor.' 352') {
$nicks = explode(" ", $con['buffer']['linea']);
print "$nicks[7] ";
}

if(substr($con['buffer']['linea'], 0, 6) == 'PING :') {
fputs($con['socket'], "PONG :".substr($con['buffer']['linea'],6)."\n\r");
fputs($con['socket'], "WHO ". $canal ."\n\r");
}
if(!salir) {
$eof=feof($con['socket']);
}
}
}
?>

Related Posts by Categories



0 comentarios :