All pastes #422819 Raw Edit

Stuff

public php v1 · immutable
·published 2007-04-03 18:44 UTC
rendered paste body
<?php	//Config Variables	$CONFIG['server'] = 'xxxx';	$CONFIG['nick'] = 'xxxx';	$CONFIG['port'] = '6667';	$CONFIG['channel'] = 'xxxx';	$CONFIG['name'] = 'xxxx';	?><?php/* Connect to the irc server */$con['socket'] = fsockopen($CONFIG['server'], $CONFIG['port']);/* Check that we have connected */if (!$con['socket']) {    print ("Could not connect to: ". $CONFIG['server'] ." on port ". $CONFIG['port']);} else {    /* Send the username and nick */    cmd_send("USER ". $CONFIG['nick']. " codedemons.net codedemons.net :". $CONFIG['name']);    cmd_send("NICK ". $CONFIG['nick']. " codedemons.net");/* Here is the loop. Read the incoming data (from the socket connection) */while (!feof($con['socket'])){    /* Think of $con['buffer']['all'] as a line of chat messages.    We are getting a 'line' and getting rid of whitespace around it. */    $con['buffer']['all'] = trim(fgets($con['socket'], 4096));    /* Print the line/buffer to the console    I used <- to identify incoming data, -> for outgoing. This is so that    you can identify messages that appear in the console. */    print date("[d/m @ H:i]")."<- ".$con['buffer']['all'] ."n";    /* If the server is PINGing, then PONG. This is to tell the server that    we are still here, and have not lost the connection */    if(substr($con['buffer']['all'], 0, 6) == 'PING :') {        /* PONG : is followed by the line that the server        sent us when PINGing */        cmd_send('PONG :'.substr($con['buffer']['all'], 6));        /* If this is the first time we have reached this point,        then JOIN the channel */        if ($firstTime == true){            cmd_send("JOIN ". $CONFIG['channel']);            /* The next time we get here, it will NOT be the firstTime */            $firstTime = false;        }        /* Make sure that we have a NEW line of chats to analyse. If we don't, there is no need to parse the data again */    } elseif ($old_buffer != $con['buffer']['all']) {    /* This is where you would analyze the data, and act accordingly. */    }}}?> <?php$old_buffer = $con['buffer']['all'];?>