All pastes #988716 Raw Edit

Something

public text v1 · immutable
#988716 ·published 2008-04-17 20:39 UTC
rendered paste body
<?

class main {
	public $connections = 0;
	public $bots;
	public $bot;


        function addbot($localhost, $remotehost, $port, $nick, $user, $real) {
                echo "New connection: " . $nick . " at connection ID #" . $this->connections . "\r\n";

		$this->bots[$this->connections] = array( $localhost, $remotehost, $port, $nick, $user, $real );
		echo "This bot is " . $this->bots[$this->connections][4] . "\r\n";
		$this->connections += 1;

                return 1;
        }

	function connect() {

		for ($x = 0; $x < $this->connections; $x++) {
			$this->bot[$x] = new connection;
			$this->bot[$x]->newc(0, $this->bots[$x][0], $this->bots[$x][1], $this->bots[$x][2], $this->bots[$x][3], $this->bots[$x][4], $this->bots[$x][5]);
			$this->bot[$x]->readdata();
		}

		while (1) {
			for ($x = 0; $x < $this->connections; $x++) {
				$this->bot[$x]->readdata();
			}
		}

	}

}

class connection {
	public $socket;

	function newc($id, $localhost, $remotehost, $port, $nick, $user, $real) {
		$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
		socket_bind($this->socket, $localhost);
		socket_connect($this->socket, $remotehost, $port);

		socket_write($this->socket, "USER " . $real . " " . $localhost . " " . $real . " " . $real . "\r\n");
		socket_write($this->socket, "NICK " . $nick . "\r\n");

		socket_write($this->socket, "JOIN #annihilation\r\n");

		$this->readdata;
	}

	function readdata() {
		if ($rdata = trim(socket_read($this->socket, 128))) {
			echo $rdata . "\r\n";
			flush();

			$ex = explode(" ", $rdata, 4);
			$message = $ex[3];
			$mess = explode(" ", $ex[3]);
			echo "MESSAGE " . $message . "\r\n";

			if($ex[0] == "PING"){
				socket_write($this->socket, "PONG " . $ex[1] . "\r\n");
			}
		}
	}

}

$IRC = new main;

$IRC->addbot('89.46.37.183', 'irc.deltaanime.net', 6667, '[1]Catlin', 'Catlin', 'Catlin');
$IRC->addbot('89.46.37.198', 'irc.deltaanime.net', 6667, '[2]Catlin', 'Catlin', 'Catlin');
$IRC->addbot('89.46.37.199', 'irc.deltaanime.net', 6667, '[3]Catlin', 'Catlin', 'Catlin');
$IRC->addbot('89.46.37.200', 'irc.deltaanime.net', 6667, '[4]Catlin', 'Catlin', 'Catlin');
$IRC->addbot('89.46.37.201', 'irc.deltaanime.net', 6667, '[5]Catlin', 'Catlin', 'Catlin');
$IRC->addbot('89.46.37.202', 'irc.deltaanime.net', 6667, '[6]Catlin', 'Catlin', 'Catlin');


$IRC->connect();

?>