PHP-Code:
<?PHP
class Irc {
var $RemoteHost;
var $Nick;
var $Port;
var $ircsocket;
function Irc ( $RemoteHost, $Nick, $Port = 6667 )
{
set_time_limit(0);
ob_end_flush();
$this->RemoteHost = $RemoteHost;
$this->Nick = $Nick;
$this->Port = $Port;
$this->Connect();
}
function Connect()
{
$this->ircsocket = fsockopen ($this->remotehost, $this->remoteport) ;
if (! $this->ircsocket) {
die ("Error connecting to host.");
}
fputs ($this->ircsocket, "USER ".$this->Nick." 66.119.161.165 irc.tooltime.net :Nice Guy\r\n");
fputs ($this->ircsocket, "NICK ".$this->Nick."\r\n");
}
function Encoden()
{
while (!feof($this->ircsocket))
{
$incoming = fgets ($this->ircsocket, 1024);
$incoming = str_replace( "\r", "", $incoming);
$incoming = str_replace("\n", "", $incoming);
if (substr($incoming, 0, 1) == ":") {
$prefix = substr ($incoming, 0, strpos($incoming, ' '));
$incoming = substr ($incoming, strpos($incoming, ' ') + 1);
} else {
$prefix = "";
}
$command = substr ($incoming, 0, strpos($incoming, ' '));
$incoming = substr ($incoming, strpos($incoming, ' ') + 1);
$params = explode (" ", $incoming);
if ($command == "PING") fputs($this->ircsocket, "PONG $incoming\r\n");
// Weiterverarbeitung der Informationen in $prefix, $incomming, $params
// Aufruf von Methoden, die das Script erledigen soll
if ($command == "367")
{
$this->MsgSenden("MBH-^Fight^","Danke für das Tutorial");
fputs($this->ircsocket, "QUIT Unexpected\r\n");
}
}
fputs($this->ircsocket, "QUIT Unexpected\r\n");
}
function SocketSchreiben ($Nachricht)
{
fputs ($this->ircsocket, $Nachricht."\r\n");
}
function MsgSenden($Target, $Text)
{
$this->SocketSchreiben("PRIVMSG ".$Target." :".$Text);
}
};
$Irc = new Irc("de.quakenet.org","TestNick");
$Irc->Encoden();
?>
Kommentar