All pastes #792704 Raw Edit

Stuff

public php v1 · immutable
·published 2007-11-21 17:13 UTC
rendered paste body
<?php set_time_limit(0);class IRCConnect{        private $host = 'localhost';    private $port = 6667;    private $nick = 'fsockopen';    private $MySocket;    private $MyLogChan = '#0x586e.Logs';    private $AdminList = array();        public function __construct() {        $this->MySocket = fsockopen($this->host,$this->port);        $this->SendCommand('nick fsockopen');         $this->SendCommand('user fsockopen fsockopen fsockopen :PHP IRCConnect class');        $this->GetCommand();    }        public function SendCommand($MyCmd)    {        if (!empty($this->MySocket))        {            fputs($this->MySocket,$MyCmd.chr(10).chr(13));            echo '[<<] '.$MyCmd.chr(10).chr(13);        }    }        public function SendLog($MyText)    {        $this->SendCommand('PRIVMSG '.$this->MyLogChan.' :'.$MyText);    }        public function GetCommand()    {        while (1)        {        while ($MyData = fgets($this->MySocket,1024))        {        echo '[>>] '.$MyData.chr(10).chr(13);        flush();        $this->AnswerIt($MyData);         }        }    }        public function AnswerIt($MyData)    {        $MyData = str_replace(chr(10),'',$MyData);        $MyData = str_replace(chr(13),'',$MyData);        $MyDataExploded = explode(' ',$MyData);        $MyDataExp = explode(':',$MyData);        if ($MyDataExploded[1] == "313") {            array_push($this->AdminList,$MyDataExploded[3]);        }        if (substr($MyData,0,4) == "PING")         {            $this->SendCommand('PONG '.substr($MyData,5,strlen($MyData)));        } else if (ereg(':fsockopen MODE',$MyData))         {            $this->SendCommand('JOIN #0x586e');            $this->SendCommand('JOIN '.$this->MyLogChan);            $this->SendCommand('OPER xn foo');        } else if ($MyDataExploded[1] == "PRIVMSG")        {               $NName = explode('!',$MyDataExploded[0]);             if (!in_array(substr($NName[0],1,strlen($NName[0])),$this->AdminList))            {                $this->SendCommand('WHOIS '.substr($NName[0],1,strlen($NName[0])));            } else if (in_array(substr($NName[0],1,strlen($NName[0])),$this->AdminList))            {             if ($MyDataExploded[3] == ":!op")            {                 if (substr($MyDataExploded[4],0,1) == "#")                {                    $this->SendCommand('SAMODE '.$MyDataExploded[4].' +o '.substr($NName[0],1,strlen($NName[0])));                    $this->SendLog('ADMIN -> '.substr($NName[0],1,strlen($NName[0])).' -> SAMODE -> '.$MyDataExploded[4].' -> +o');                 } else                 {                    $this->SendCommand('SAMODE '.$MyDataExploded[2].' +o '.substr($NName[0],1,strlen($NName[0])));                    $this->SendLog('ADMIN -> '.substr($NName[0],1,strlen($NName[0])).' -> SAMODE -> '.$MyDataExploded[2].' -> +o');                }                  } else if ($MyDataExploded[3] == ":!join")            {                $this->SendCommand('JOIN '.$MyDataExploded[4]);            } else if ($MyDataExploded[3] == ":!raw")            {                $this->SendCommand(substr($MyDataExp[2],5,strlen($MyDataExp[2])));            } else if ($MyDataExploded[3] == ":!kill")            {                $MyLen = strlen($MyDataExploded[4]);                $NName = explode('!',$MyDataExploded[0]);                $this->SendCommand('KILL '.$MyDataExploded[4].' '.substr($MyDataExp[2],$MyLen + 7,strlen($MyDataExp[2])));                $this->SendLog('ADMIN -> '.substr($NName[0],1,strlen($NName[0])).' -> KILL -> '.$MyDataExploded[4].' -> '.substr($MyDataExp[2],$MyLen + 7,strlen($MyDataExp[2])));            }         }        }    }             }$IRCConnect = new IRCConnect();?>