/** * Decrypts the packets received from the client on the first connection */ public function firstDecrypt($client, $data) { $firstClientKey = self::$clients[(int) UltimaPHP::$conf['server']['client']['major'] . (int) UltimaPHP::$conf['server']['client']['minor'] . (int) UltimaPHP::$conf['server']['client']['revision']][0]; $secondClientKey = self::$clients[(int) UltimaPHP::$conf['server']['client']['major'] . (int) UltimaPHP::$conf['server']['client']['minor'] . (int) UltimaPHP::$conf['server']['client']['revision']][1]; $len = strlen($data); for ($i = 0; $i < $len; $i++) { $data[$i] = self::$currentKey0 ^ $data[$i]; $oldkey0 = self::$currentKey0; $oldkey1 = self::$currentKey1; self::$currentKey0 = ($oldkey0 >> 1 | $oldkey1 << 31) ^ $secondClientKey; self::$currentKey1 = ((($oldkey1 >> 1 | $oldkey0 << 31) ^ $firstClientKey - 1) >> 1 | $oldkey0 << 31) ^ $firstClientKey; } return $data; }