<html>
<head>
<title>IRC Bot</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);
// Opening the socket to the SwiftIRC network
$socket = fsockopen("irc.swiftirc.net", 6667);
// Send auth info
fputs($socket,"USER WhiteyBot combined-minds.net CM :`Whitey is the Owner\n");
fputs($socket,"NICK `WhiteyBot \n");
// Join channel
fputs($socket,"JOIN #weepee\n");
// Force an endless while
while(1) {
// Continue the rest of the script here
while($data = fgets($socket, 128)) {
echo nl2br($data);
flush();
// Separate all data
$ex = explode(' ', $data);
// Send PONG back to the server
if($ex[0] == "PING"){
fputs($socket, "PONG ".$ex[1]."\n");
}
}
}
?>
<?php
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
?>
</html>