rendered paste body<?
include("commands.php");
error_reporting(E_ALL);
class mainSock {
var $sock;
var $newsock;
function sockCreate($address, $port) {
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($this->sock, $address, $port);
socket_listen($this->sock, 3);
socket_set_block($this->sock);
}
function output($output) {
print_r($output);
}
function __destruct() {
@socket_close($this->sock);
@socket_close($this->newsock);
$data = null;
$newdata = null;
$test = null;
$nick = null;
}
}
$mainSock = new mainSock();
$mainSock->sockCreate('38.100.235.137','3913');
while ($mainSock->newsock = socket_accept($mainSock->sock)) {
while ($mainSock->newsock !== false) {
$data = socket_read($mainSock->newsock, 4000);
$newdata = $data."\n";
echo $data;
$test = explode(" ", $newdata);
if ($test[0] == "USER") {
$user = $test[1];
$address = str_replace("\"", "",$test[3]);
$ident = $curNick."!~".$user."@".$address;
}
if ($test[0] == "NICK") {
$nick = $test[1];
if (preg_match("/^:/", $nick))
{
$nick = str_replace(":", "", $nick);
echo $nick."YAA";
$commands->nickChange($curNick, $nick, $mainSock->newsock, $user, $address);
$curNick = $nick;
} else {
$curNick = $nick;
}
$mainSock->output($nick);
}
$mainSock->output($test);
$commands = new commands();
$commands->say("Hello", $nick, $mainSock->newsock);
if ($test[0] == "QUIT") {
$quitReason = explode(":", $newdata);
$commands->quit($quitReason[1], $ident, $mainSock->newsock);
unset($mainSock); die();
}
}
}
?>