Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/ucuge (16-Aug @ 17:50)
Syntax Highlighted Code
- <?php
- // define your variables
- $host = "irc.ircworld.nl";
- $port=6667;
- $nick="SanBot";
- $ident="SanBot";
- $chan="#ibot";
- $readbuffer="";
- $realname = "Sanbot";
- $cmdprefix = ",";
- $irc = connect($host, $port);
- function connect($_host, $_port)
- {
- // open a socket connection to the IRC server
- if (!$connection) {
- echo "No connection\n";
- } else {
- echo "Connection Succesfull!\n";
- return $connection;
- }
- }
- // print the error if ther eis no connection
- if (!$irc) {
- echo "No connection\n";
- } else {
- // write data through the socket to join the channel
- // Continue the rest of the script here
- // Separate all data
- // Send PONG back to the server
- if($ex[0] == "PING"){
- }
- // DO something on the IRC server
- if ($command == $cmdprefix."sterf")
- {
- echo "QUIT :Goodbye!\r\n";
- }
- elseif($command == $cmdprefix."dood")
- {
- echo "QUIT :Goodbye!\r\n";
- }
- elseif($command == $cmdprefix."join")
- {
- }
- elseif($command == $cmdprefix."part")
- {
- }
- elseif($command == $cmdprefix."say")
- {
- }
- }
- }
- }
- ?>
Plain Code
<?php
// define your variables
$host = "irc.ircworld.nl";
$port=6667;
$nick="SanBot";
$ident="SanBot";
$chan="#ibot";
$readbuffer="";
$realname = "Sanbot";
$cmdprefix = ",";
$irc = connect($host, $port);
function connect($_host, $_port)
{
echo "Conneting to: ".$_host.":".$_port."\n";
// open a socket connection to the IRC server
$connection = fsockopen($_host, $_port, $erno, $errstr, 30);
if (!$connection) {
echo "No connection\n";
echo $errstr." (".$errno.")<br />\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.")<br />\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");
}
}
}
}
?>