Guest User

xmap_inst.php

a guest
Dec 1st, 2013
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('memory_limit', '900M');
  4. ini_set('display_errors', '1');
  5.  
  6. $files = explode("\n", `dir /b /s *.xmap`);
  7. $token = "\x00\x00\x00\x00";
  8.  
  9. foreach ($files as $file)
  10. {
  11.     if (!is_file($file)) continue;
  12.     $handle = fopen($file, "r");
  13.     if ($handle !== false)
  14.     {
  15.         // skip header
  16.         fread($handle, 0x60);
  17.        
  18.         // read line
  19.         while ($line = fread($handle, 0x70))
  20.         {
  21.             // end of section?
  22.             if (substr($line, 0x20, 4) != $token) break;
  23.            
  24.             // parse
  25.             $x = array_pop(unpack("f", strrev(substr($line, 0x30, 4))));
  26.             $y = array_pop(unpack("f", strrev(substr($line, 0x34, 4))));
  27.             $z = array_pop(unpack("f", strrev(substr($line, 0x38, 4))));
  28.             $h = "0x" . strtoupper( bin2hex(substr($line, 0x24, 4)) );
  29.            
  30.             // print
  31.             printf("%.4f, %.4f, %.4f, %s\r\n", $x, $y, $z, $h);
  32.         }
  33.        
  34.         fclose($handle);
  35.     }
  36. }
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment