function trackToFlash($id)
{
    if (file_exists("tracks/" . $id . ".track")) {
        $file = fopen("tracks/" . $id . ".track", "r");
        $startLine = false;
        $final = "";
        $lineid = 0;
        while (ftell($file) < filesize("tracks/" . $id . ".track")) {
            $skipIt = false;
            $length = readShort($file);
            if ($length == 0) {
                if (readByte($file) == 9) {
                    //End Array/Object
                    $skipIt = true;
                    if ($startLine == true) {
                        $startLine = false;
                    }
                } else {
                    skip($file, -1);
                    //Invalid item of length 0
                    $skipIt = true;
                }
            }
            if ($skipIt == false) {
                $name = readString($file, $length);
                $type = readByte($file);
                if ($type == 0) {
                    //Double
                    if ($startLine == true) {
                        $append = "s";
                    } else {
                        $append = "l";
                    }
                    if ($name != 'level') {
                        $val = readDouble($file);
                        if ((string) $val == 'NAN') {
                            $val = 'undefined';
                        }
                        $final .= $append . $lineid . "_" . $name . "=" . $val . "&";
                    } else {
                        skip($file, 8);
                    }
                }
                if ($type == 1) {
                    //Boolean (Show)
                    skip($file, 1);
                }
                if ($type == 2) {
                    //String
                    $strlength = readShort($file);
                    skip($file, $strlength);
                }
                //Type 3 & 6 Do Nothing
                if ($type == 8) {
                    //Array
                    if ($name == "startLine") {
                        $startLine = true;
                    } else {
                        $lineid = (int) $name;
                    }
                    skip($file, 4);
                }
            }
        }
        fclose($file);
        $final = substr($final, 0, strlen($final) - 1);
        return $final;
    }
}
Example #2
0
        }
        unlink($tmpfile);
        return $returnCode;
    }
}
// Extraction information header (Name of cartridge, ...)
$INFORMATION_HEADER_OFFSET = OFFSET_FILE_HEADER + $nb * (LENGTH_OBJECT_ID + LENGTH_OBJECT_ADR);
$LENGTH_INFORMATION_HEADER_LENGTH_FIELD = 4;
$headerLentghBinary = substr($contents, $INFORMATION_HEADER_OFFSET, $LENGTH_INFORMATION_HEADER_LENGTH_FIELD);
$headerLength = hexdec(bin2hex($headerLentghBinary[3]) . bin2hex($headerLentghBinary[2]) . bin2hex($headerLentghBinary[1]) . bin2hex($headerLentghBinary[0]));
$informationHeaderContent = substr($contents, $INFORMATION_HEADER_OFFSET + $LENGTH_INFORMATION_HEADER_LENGTH_FIELD, $headerLength);
file_put_contents($basename . "_files/" . $basename . "_header.bin", $informationHeaderContent);
$currentIndex = 0;
$latitude = readDouble($informationHeaderContent, $currentIndex);
$longitude = readDouble($informationHeaderContent, $currentIndex);
$altitude = readDouble($informationHeaderContent, $currentIndex);
$downloadDate = readLong($informationHeaderContent, $currentIndex);
// seconds from 2004-02-10
$currentIndex += 4;
// LONG unkown value
$currentIndex += 2;
// SHORT id of splashscreen
$currentIndex += 2;
// SHORT id of icon
$type_of_cartridge = readAsciiz($informationHeaderContent, $currentIndex);
$playerName = readAsciiz($informationHeaderContent, $currentIndex);
$playerId = readLong($informationHeaderContent, $currentIndex);
$currentIndex += 4;
// LONG unkown value
$cartridgeName = readAsciiz($informationHeaderContent, $currentIndex);
$cartridgeGUID = readAsciiz($informationHeaderContent, $currentIndex);
Example #3
0
         if ($startLine == true) {
             $startLine = false;
         }
         $skipIt = true;
     } else {
         skip($file, -1);
         //Invalid item of length 0
         $skipIt = true;
     }
 }
 if ($skipIt == false) {
     $name = readString($file, $length);
     $type = readByte($file);
     if ($type == 0) {
         //Double
         $value = readDouble($file);
         if ($startLine == true) {
             if ($name == "0") {
                 $startLinex[$track] = $value;
             }
             if ($name == "1") {
                 $startLiney[$track] = $value;
             }
         } else {
             if ($name == "0" || $name == "2") {
                 if ($value < $lowx) {
                     $lowx = $value;
                 }
                 if ($value > $highx) {
                     $highx = $value;
                 }