\n"; } else { echo "Connection Succesfull!\n"; return $connection; } } // print the error if ther eis no connection if (!$irc) { echo "No connection\n"; echo $errstr." (".$errno.")
\n"; } else { // write data through the socket to join the channel fwrite($irc, "NICK ".$nick."\r\n"); fwrite($irc, "USER ".$ident." ".$host." bla :".$realname."\r\n"); fwrite($irc, "PRIVMSG nickserv :identify *******\r\n"); fwrite($irc, "JOIN :".$chan."\r\n"); while (!feof($irc)) { // Continue the rest of the script here while(trim($data = fgets($irc, 128))) { echo $data."\n"; flush(); // Separate all data $ex = explode(' ', $data); // Send PONG back to the server if($ex[0] == "PING"){ fputs($irc, "PONG ".$ex[1]."\n"); } // DO something on the IRC server $command = str_replace(chr(58), '', $ex[3]); if ($command == $cmdprefix."sterf") { echo "QUIT :Goodbye!\r\n"; fputs($irc, "QUIT :Goodbye!\r\n"); } elseif($command == $cmdprefix."dood") { echo "QUIT :Goodbye!\r\n"; fputs($irc, "QUIT :Goodbye!\r\n"); } elseif($command == $cmdprefix."join") { echo "JOIN ".$ex[4]."\r\n"; fputs($irc, "JOIN ".$ex[4]."\r\n"); } elseif($command == $cmdprefix."part") { echo "PART ".$ex[4]."\r\n"; fputs($irc, "PART ".$ex[4]."\r\n"); } elseif($command == $cmdprefix."say") { echo "PRIVMSG ".$ex[4]." :".$ex[5]." ".$ex[6]."\r\n"; fputs($irc, "PRIVMSG ".$ex[4]." :".$ex[5]." ".$ex[6]."\r\n"); } } } } ?>