stdin['stdin']['buffer']); $buffer = trim(fread(STDIN, 1500)); return $buffer; unset($buffer); } } class socket { public $host; public $port; public $socket; public function __construct() { list($this->host, $this->port) = func_get_args(); if (!is_null($this->host) || !is_null($this->port)) { if (($this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { if (socket_connect($this->socket, $this->host, $this->port)) { echo 'Socket created, locked and loaded... on ' . $this->host . ':' . $this->port . ' [' . $this->socket . ']' . "\n"; return true; } else { return false; } } } } public function stream() { $read = array(&$this->socket); $write = NULL; $except = NULL; $buffer = NULL; socket_set_nonblock($this->socket); socket_select($read, $write, $except, 0); $buffer = trim(socket_read($this->socket, 2048, PHP_NORMAL_READ)); return $buffer; unset($buffer); } } class internet_relay_chat extends socket { public $host; public $port; public $socket; public $pass; public $nick; public $user; public $realname; public function __construct() { list($this->host, $this->port, $this->socket, $this->pass, $this->nick, $this->user, $this->realname) = func_get_args(); if (is_resource($this->socket)) { print('Connection to ' . $this->host . ' on port ' . $this->port . ' was successful ' . '[' . $this->socket . ']' . "\n"); socket_write($this->socket, 'NICK ' . $this->nick . "\n"); socket_write($this->socket, 'USER ' . $this->user . ' 2 3: ' . $this->realname . "\n"); socket_write($this->socket, 'JOIN ' . '#atomiku' . "\n"); } else { print('Connection to ' . $this->host . ' on port ' . $this->port . ' failed ' . '[' . $this->socket . ']' . "\n"); } } public function interpret() { } } $stdin = new stdin; var_dump($stdin); $socket = new socket('athena.irc.atomiku.com', '6667'); //athena.irc.atomiku.com var_dump($socket); $irc_bot = new internet_relay_chat($socket->host, $socket->port, $socket->socket, NULL, 'Mini', 'barryd.it', 'Gorge Washington'); var_dump($irc_bot); while(true){ //var_dump($stdin); /* if (($tmp['socket'] = $socket->stream()) != NULL) { echo $tmp['socket']['stream']; if (substr($tmp['socket'], 0, 4) == 'PING' ) { print("[-]Ping " . substr($tmp['socket'], 5) . "\r\n"); socket_write($socket->socket, 'PONG ' . substr($tmp['socket'], 5) . ''); } if (eregi("!we", $tmp['socket']['stream'])) { socket_write($socket->socket, 'PRIVMSG ' . '#atomiku' . ' :weeeeeeeeeeee' . "\n"); } } */ $tmp['stdin'] = $stdin->stream(); $tmp['socket'] = $socket->stream(); echo $tmp['stdin'] . "\n"; socket_write($socket->socket, $tmp['stdin'] . "\n"); echo $tmp['socket'] . "\n"; if (substr($tmp['socket'], 0, 4) == 'PING' ) { print("[-]Ping " . substr($tmp['socket'], 5) . "\r\n"); socket_write($socket->socket, 'PONG ' . substr($tmp['socket'], 5) . ''); } /* if (eregi("!we", $tmp['socket'])) { socket_write($socket->socket, 'PRIVMSG ' . '#atomiku' . ' :weeeeeeeeeeee' . "\n"); } */ unset($tmp); } ?>