var $soc = null; #http://pastebin.com/wavQVZCf var $packet = array(); var $k = "248435010"; //k value for userID function reconnect(){ //Reconnects bots $this->connect($this->ip,$this->port); $this->join($this->roomID); while($this->read()!="DIED"); } function connect($ip, $port) { //Connects bots if($this->soc!=null) socket_close($this->soc); $this->soc = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); if(!$this->soc)$this->port(); if(!socket_connect($this->soc,$ip,$port))$this->port(); } function port(){ //Loads bots from the ports $this->port++; if ($this->port>10049) $this->port=10039; $this->reconnect(); } function join($room) { //Joins the room $this->send(''); $this->read(); $this->send(''); $this->port(); $this->roomID = $roomID; } function send($message) { echo "\nBot connected."; socket_write($this->soc, $message."\0", strlen($message)+1); } function read($parse=true) { //Read function $res = rtrim(socket_read($this->soc, 4096)); echo "\Bot connected."; if(strpos(strtolower($res),"ailed"))$this->port(); if(!$res) return "DIED"; $this->lastPacket = $res; if($res{strlen($res)-1}!='>') {$res.=$this->read(false);} if($parse)$this->parse($res); return $res; } function parse($packet) { $packet=str_replace('+','@più@',str_replace(' ="',' @=@"',$packet)); if(substr_count($packet,'>')>1) $packet = explode('/>',$packet); foreach((Array)$packet as $p) { $p = trim($p); if(strlen($p)<5) return; $type = trim(strtolower(substr($p,1,strpos($p.' ',' ')))); $p = trim(str_replace("<$type",'',str_replace('/>','',$p))); parse_str(str_replace('"','',str_replace('" ','&',str_replace('="','=',str_replace('&','__38',$p)))),$this->packet[$type]); foreach($this->packet[$type] as $k=>$v) { $this->packet[$type][$k] = str_replace('@più@','+',str_replace('@=@','=',str_replace('__38','&',$v))); } } } } $bot = new Wuggy(); $bot->reconnect(); ?>