Socket = fsockopen($this->Host, $this->Port); if(!$this->Socket) die(sprintf(CONNECTION_ERROR, $this->Host, $this->Port)); else { $this->WelcomeMessage = trim(fgets($this->Socket, 1000)); fputs($this->Socket, 'USER '.$this->UserName."\n"); fputs($this->Socket, 'PASS '.$this->Password."\n"); $Line = fgets($this->Socket, 1000); if($Line == "-No such user.\r\n") die(NO_SUCH_USER); if($Line == "-Wrong pass.\r\n") die(WRONG_PASS); if($Line == "-Not enough privileges.\r\n") die(NOT_ENOUGH_PRIVILEGES); if($Line != "+Logged in.\r\n") die(AUTH_ERROR.': '.$Line); stream_get_line($this->Socket, 1000, 'mangos>'); } } function Close() { fclose($this->Socket); } function Execute($Command) { fputs($this->Socket, $Command."\n"); stream_get_line($this->Socket, 1000, 'mangos>'); $Data = stream_get_line($this->Socket, 100000, 'mangos>'); return($Data); } }