Created to be used for connecting to IRC clients using PHP on a UNIX system.
<?php
function phpbot($server, $port, $user, $nick, $realname, $channel) {
$sockname = fsockopen($server, $port, $errno, $errstr) or exit($errno . " " . $errstr);
$repeat = 0;
while (($sockread = fgets($sockname, 512))) {
$sockread = explode(" ", $sockread);
if (!$repeat) {
fputs($sockname, "NICK " . $nick . "\r\n");
fputs($sockname, "USER " . $user . " \"\" \"\" :" . $realname . "\r\n");
}
else if ($sockread[0] == "PING") {
fputs($sockname, "PONG :" . $sockread[1] . "\r\n");
}
else if ($sockread[1] == "001") {
fputs($sockname, "JOIN " . $channel . "\r\n");
}
else if (fnmatch("43?", $sockread[1])) {
fputs($sockname, "NICK " . $nick . str_repeat(mt_rand(0, 9), 3) . "\r\n");
}
$repeat++;
}
}
?>
<?php
if(!function_exists(\'fnmatch\')) {
function fnmatch($pattern, $string) {
return preg_match(\"#^\".strtr(preg_quote($pattern, \'#\'), array(\'\\' => \'.\', \'\?\' => \'.\')).\"$#i\", $string);
}// end
}// end if
?>
this is the function i have to override the fnmatch. however all it does is have phpbot join the channel.