Esempio n. 1
0
function mOctets($p)
{
    $packed = mUInt32(count($p));
    for ($i = 0; $i < count($p); $i++) {
        $packed .= mByte($p[$i]);
    }
    return $packed;
}
Esempio n. 2
0
 function getrolename($id)
 {
     //figure out how far off role ID is from account ID
     $offset = $id % 8;
     $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if ($sock) {
         if (socket_connect($sock, GAMEDBDH, GAMEDBDP)) {
             socket_set_block($sock);
             $data = mUInt32(3032) . mByte(8) . mShort(32768) . mShort(0x25) . mInt($id - $offset);
             //hexdump($data);
             socket_send($sock, $data, 8192, 0);
             socket_recv($sock, $buf, 8192, 0);
             //hexdump($buf);
             socket_set_nonblock($sock);
             socket_close($sock);
             //for some reason the number of names
             //doesn't always stay in the same spot
             $pos11 = ord(substr($buf, 11, 1));
             $pos12 = ord(substr($buf, 12, 1));
             if ($pos11 == 0) {
                 $namelen = $pos12;
                 $pholder = 17;
             } else {
                 $namelen = $pos11;
                 $pholder = 16;
             }
             for ($i = 0; $i < $namelen; $i++) {
                 $thisnamelen = ord(substr($buf, $pholder, 1));
                 $names[] = iconv("UCS-2LE", "UTF-8", substr($buf, $pholder + 1, $thisnamelen));
                 //+1 is because it needs to advance one to get where the name starts
                 //+$thisnamelen pushes it all the way to end of name
                 //+4 then skips over the 'useless' bytes to get next name length
                 $pholder += 1 + $thisnamelen + 4;
             }
             if ($names[$offset] != "") {
                 return $names[$offset];
             }
         }
     }
     return "Unable to retrieve";
 }