Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/ifaqo (16-Aug @ 17:18)
Syntax Highlighted Code
- <?php
- //(Re)Connect function need to be fixed!
- // define your variables
- $host = "irc.ircworld.nl";
- $port=6667;
- $nick="SanBot";
- $ident="SanBot";
- $chan="#ibot";
- $readbuffer="";
- $realname = "Sanbot";
- $cmdprefix = ",";
- $autoreconnect = 1;
- $is_connected = 0;
- $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")
- {
- }
- elseif($command == $cmdprefix."join")
- {
- }
- }
- }
- }
- ?>
Plain Code
<?php
//(Re)Connect function need to be fixed!
// define your variables
$host = "irc.ircworld.nl";
$port=6667;
$nick="SanBot";
$ident="SanBot";
$chan="#ibot";
$readbuffer="";
$realname = "Sanbot";
$cmdprefix = ",";
$autoreconnect = 1;
$is_connected = 0;
$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");
while (!feof($irc)) {
// Continue the rest of the script here
while($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(array(chr(10), chr(13),chr(58)), '', $ex[3]);
if ($command == $cmdprefix."sterf")
{
fputs($irc, "QUIT Goodbye! \n");
}
elseif($command == $cmdprefix."join")
{
fputs($irc, "JOIN ".$ex[4]);
}
}
}
}
?>