rendered paste body<?
include("commands.php");
error_reporting(E_ALL);
class mainSock {
public $sock;
public $newsock;
public $ifbind = null;
function sockCreate($address,$port) {
$this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($this->ifbind == null) {
$this->ifbind = socket_bind($this->sock, $address, $port);
}
socket_listen($this->sock, 3);
socket_set_block($this->sock);
}
function output($output) {
print_r($output);
}
function cleanup() {
socket_close($mainSock->newsock);
socket_close( $mainSock->sock);
$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);
$mainSock->output($test);
$nick = $test[1];
$mainSock->output($nick);
$commands = new commands();
if ($test[0] == "QUIT") {
$mainSock->cleanup();
die();
}
}
$commands->say("Hello", $nick, $mainSock->newsock);
}
?>