Advertisement
Protocol_

Fix :: MhX

Apr 15th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.73 KB | None | 0 0
  1. <? require_once('Pickle.php');
  2. class ErrorFIX extends Pickle {
  3.     function connect($username, $password, $server = -1, $debug = false) {
  4.         $this->username = $username;
  5.         if ($server != null)
  6.             $this->server = $server;
  7.         if (!is_numeric($this->server)) {
  8.             $this->servername = $this->server;
  9.             $this->server = $this->serverId($this->server);
  10.         } else {
  11.             $this->servername = $this->serverName($this->server);
  12.         }
  13.         if ($this->server < 0) return 1;
  14.  
  15.         echo '|' , chr(8);
  16.         $data = $this->initCon();
  17.         $randKey = stribet($data, '<k>', '</k>');
  18.         echo '/' , chr(8);
  19.         $key = $this->generateKey($password, $randKey, true);
  20.         fwrite($this->sock, '<msg t=\'sys\'><body action=\'login\' r=\'0\'><login z=\'' . LOGIN_ZONE . '\'><nick><![CDATA[' . strtolower($username) . ']]></nick><pword><![CDATA[' . $key . ']]></pword></login></body></msg>' . chr(0));
  21.  
  22.         $data = $this->readPacket();
  23.         if (stripos($data, 'xt%e')) {
  24.             $this->error = stribet($data, '%xt%e%-1%', '%');
  25.             $this->errort = $this->errors[$this->error];
  26.             $this->run = false;
  27.             $this->connect($this->username,$password,$this->server,false);
  28.             return $this->error;
  29.         }
  30.  
  31.         $data = str_replace('|%', '%', $data);
  32.         $packet = ($this->decodePacket($data));
  33.         $packet = $packet[0];
  34.         $servlist = $packet[7];
  35.         $servlist = explode("|", $servlist);
  36.         $this->serverlist = array();
  37.         foreach ($servlist as $server) {
  38.             $dataserv = explode(",", $server);
  39.             $this->serverlist[$dataserv[0]] = $dataserv[1];
  40.         }
  41.         if($this->serverlist[$this->server]>=6){ $this->connect($this->username,$password,$this->server,false); return 103;  }
  42.         unset($server);
  43.         $this->PlayerID = stribet($data, '%xt%l%-1%', '%');
  44.         $strUnkown = stribet($data, '%xt%l%-1%' . $this->PlayerID . '%', '%');
  45.         $lkey = stribet($data, '%xt%l%-1%' . $this->PlayerID . '%' . $strUnkown . '%', '%');
  46.         fclose($this->sock);
  47.         echo '-' . chr(8);
  48.  
  49.         $data = $this->initCon($this->servers[$this->server]['ip'], $this->servers[$this->server]['port']);
  50.         $randKey = stribet($data, '<k>', '</k>');
  51.         $key = $this->generateKey($lkey, $randKey);
  52.         echo '\\' . chr(8);
  53.         fwrite($this->sock, '<msg t=\'sys\'><body action=\'login\' r=\'0\'><login z=\'' . SERVER_ZONE . '\'><nick><![CDATA[' . strtolower($username) . ']]></nick><pword><![CDATA[' . $key . ']]></pword></login></body></msg>' . chr(0));
  54.         fwrite($this->sock, '%xt%s%j#js%-1%' . $this->PlayerID . '%' . $lkey . '%en%' . chr(0));
  55.         $data = $this->readPacket();
  56.         while (stripos($data, '%xt%jr%') == false && stripos($data, '%xt%lp') == false) $data .= $this->readPacket();
  57.         $packets = $this->decodePacket($data);
  58.         $packet = $this->packetInArray('lp', $packets);
  59.         $this->objPlayer = $this->loadPlayer($packet[2], true, $packet);
  60.         $packet = $this->packetInArray('jr', $packets);
  61.         $this->intRoomID = $packet[1];
  62.         $this->extRoomID = $packet[2];
  63.         $this->arrPlayers = array();
  64.         $this->room = array();
  65.         $this->room[$this->extRoomID] = array();
  66.         foreach ($packet as $key => $player) {
  67.             if (!($key <= 4)) {
  68.                 $id = '|' . $player;
  69.                 $id = stribet($id, '|', '|');
  70.                 try {
  71.                     $this->arrPlayers[$id] = $this->loadPlayer($player);
  72.                     $this->room[$this->extRoomID][$id] = $this->arrPlayers[$id];
  73.                 }
  74.                 catch (PCLException $e) {
  75.                     echo $e;
  76.                 }
  77.             }
  78.         }
  79.         echo "|" . chr(8);
  80.         fwrite($this->sock, '%xt%s%i#gi%-1%' . chr(0));
  81.         fwrite($this->sock, '%xt%s%b#gb%-1%' . chr(0));
  82.         fwrite($this->sock, '%xt%s%n#gn%-1%' . chr(0));
  83.         fwrite($this->sock, '%xt%s%l#mst%-1%' . chr(0));
  84.         fwrite($this->sock, '%xt%s%p#pgu%-1%' . chr(0));
  85.         fwrite($this->sock, '%xt%s%u#glr%-1%' . chr(0));
  86.         echo '/' . chr(8);
  87.         echo 'Successfully connected to ' , $this->servername , "\n";
  88.         $this->run = true;
  89.         return -1;
  90.     }
  91.     function __destruct(){
  92.     $this->disconnect();
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement