All pastes #273022 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-09 14:38 UTC
rendered paste body
<?php

$bot = array();
$bot['nickname'] = 'UberBot';
$bot['realname'] = 'Mr. UberBot';
$bot['ident']    = 'uberbot';
$bot['hostname'] = '127.0.0.1';
$bot['server']   = 'irc.ircworld.nl';
$bot['poort']    = 6667;
$bot['kanaal']   = '#ubernet';

if (!$bot['socket']=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) {
  die("De socket kon niet worden aangemaakt.");
}
if (!socket_bind($bot['socket'],$bot['hostname'])) {
  die("Kon de verbinding niet koppelen aan <b>".$bot['hostname']."</b>. Misschien fout?");
}
if (!socket_connect($bot['socket'],$bot['server'],$bot['poort'])) {
  die("Kon geen verbinding maken met de server: <b>".$bot['server']."</b>. Misschien fout?");
}

function sockwrite($data){
    global $bot;
    socket_write($bot['socket'],$data."\r\n");
}

sockwrite("USER ".$bot['ident']." ".$bot['hostname']." ".$bot['server']." :".$bot['realname']);
sockwrite("NICK ".$bot['nickname']);

$channel = 0; // Deze var komt later wel terug :)
while ($data=@socket_read($bot['socket'],65000,PHP_NORMAL_READ)) {
    if($data == "\n") continue;
// De data die we binnen krijgen, splitten we alvast op voor het makkelijk aanspreken.
    $edata = explode(" ",$data);
    for($i=0; isset($edata[$i]); $i++) {
        $edata[$i]=trim($edata[$i]);
    }
// De variable $channel die net is geset, gaan we nou controleren.
    if ($channel == "0") {
// De variable is nog 0, we moeten nog een kanaal in !
        sockwrite("JOIN ".$bot['kanaal']);
        $channel = 1;
    }
// Hier is er een PING binnengekomen. Deze gaan we antwoorden met PONG
    if($edata[0] == "PING") {
        sockwrite("PONG ".$edata[1]);
    }

// Hier komen alle scripts te staan.
    require('scripts.php');
}

?>