Esempio n. 1
0
 function getIndices($fd)
 {
     fseek($fd, 24, SEEK_SET);
     $i = 0;
     while (feof($fd) == FALSE) {
         $res[$i] = readLong($fd);
         $i++;
     }
     return $res;
 }
Esempio n. 2
0
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);
$cartridgeDesc = readAsciiz($informationHeaderContent, $currentIndex);
$startLocationDesc = readAsciiz($informationHeaderContent, $currentIndex);
$version = readAsciiz($informationHeaderContent, $currentIndex);
$author = readAsciiz($informationHeaderContent, $currentIndex);
$company = readAsciiz($informationHeaderContent, $currentIndex);
$device = readAsciiz($informationHeaderContent, $currentIndex);
$currentIndex += 4;
// LONG unkown value
$completionCode = readAsciiz($informationHeaderContent, $currentIndex);
echo "Reading Wherigo cartridge \"" . $cartridgeName . "\" (from file {$basename}.{$extension})\n";
/*
Esempio n. 3
0
function checkTTF($file)
{
    //Check if font license allows embedding
    $f = fopen($file, 'rb');
    if (!$f) {
        die('<b>Error:</b> Can\'t open ' . $file);
    }
    //Extract number of tables
    fseek($f, 4, SEEK_CUR);
    $nb = readShort($f);
    fseek($f, 6, SEEK_CUR);
    //Seek OS/2 table
    $found = false;
    for ($i = 0; $i < $nb; $i++) {
        if (fread($f, 4) == 'OS/2') {
            $found = true;
            break;
        }
        fseek($f, 12, SEEK_CUR);
    }
    if (!$found) {
        fclose($f);
        return;
    }
    fseek($f, 4, SEEK_CUR);
    $offset = readLong($f);
    fseek($f, $offset, SEEK_SET);
    //Extract fsType flags
    fseek($f, 8, SEEK_CUR);
    $fsType = readShort($f);
    $rl = ($fsType & 0x2) != 0;
    $pp = ($fsType & 0x4) != 0;
    $e = ($fsType & 0x8) != 0;
    fclose($f);
    if ($rl && !$pp && !$e) {
        echo '<b>Warning:</b> font license does not allow embedding';
    }
}
Esempio n. 4
0
function splitTracks($filename)
{
    //This function will export tracks from a users savedLines.sol file
    $file = fopen($filename, "r");
    skip($file, 2);
    // 00BF
    $fileSize = readLong($file);
    // File Size
    skip($file, 12);
    // T C S O 0004 0000 0000 000A
    if (readString($file, 9) == "undefined") {
        //Old version
        fclose($file);
        upgradeSol($filename);
        $file = fopen($filename, "r");
        skip($file, 2);
        // 00BF
        $fileSize = readLong($file);
        // File Size
        skip($file, 12);
        // T C S O 0004 0000 0000 000A
        if (readString($file, 9) != "undefined") {
            skip($file, 1);
            // s (from end of savedLines)
        } else {
            //Error: Unable to upgrade .sol
        }
    } else {
        skip($file, 1);
        // s (from end of savedLines)
    }
    skip($file, 4);
    // 0000 0000
    $currentTrack = -1;
    $trackNames = '';
    while (ftell($file) < $fileSize - 6) {
        $skipIt = false;
        $length = readShort($file);
        if ($length == 0) {
            if (readByte($file) == 9) {
                //End Array/Object
                $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 ($type == 1) {
                //Boolean (Show)
                skip($file, 1);
            }
            if ($type == 2) {
                //String
                $strlength = readShort($file);
                $value = readString($file, $strlength);
                $trackLengthOff[$currentTrack] = ftell($file) - $trackStartOff[$currentTrack] + 3;
                if ($name == 'label') {
                    $trackNames .= $value . chr(9);
                }
            }
            if ($type == 3) {
                //Object
                $currentTrack = (int) $name;
                $trackStartOff[$currentTrack] = ftell($file);
            }
            // Type 6: Undefined: Do Nothing
            if ($type == 8) {
                //Array
                $value = readLong($file);
            }
        }
    }
    $trackNames = substr($trackNames, 0, strlen($trackNames) - 1);
    $ret = '';
    for ($i = 0; $i < count($trackStartOff); $i++) {
        fseek($file, $trackStartOff[$i]);
        $bytes = fread($file, $trackLengthOff[$i]);
        for ($j = 0; $j > -1; $j++) {
            if (file_exists("tracks/" . $j . ".track") == false) {
                $wfile = fopen("tracks/" . $j . ".track", "w");
                $ret .= $j . chr(9);
                $mem = $j;
                break;
            }
        }
        fwrite($wfile, $bytes);
        fclose($wfile);
        $thisName = explode(chr(9), $trackNames);
        $thisName = $thisName[$i];
        addDetails($j, $thisName);
    }
    fclose($file);
    $ret = substr($ret, 0, strlen($ret) - 1);
    return $ret . chr(0) . $trackNames;
    //Returns an array containing the location of the tracks
}
Esempio n. 5
0
                 $trackName[$track] = $value;
                 break;
             }
         }
         if ($type == 3) {
             //Object
             $currentTrack = (int) $name;
             $trackStartOff[$currentTrack] = ftell($file);
         }
         // Type 6: Undefined: Do Nothing
         if ($type == 8) {
             //Array
             if ($name == "startLine") {
                 $startLine = true;
             }
             $value = readLong($file);
         }
     }
 }
 // End While
 $lineCount[$track] = $normLines[$track] + $accelLines[$track] + $backLines[$track];
 $erasedLines[$track] = $totalLines[$track] - $lineCount[$track];
 $views[$track] = getInfo($track, "views");
 $downloads[$track] = getInfo($track, "downloads");
 echo '<a href="track.php?id=' . $track . '">Track ID ' . $track . ': ' . $trackName[$track] . '</a><br />';
 echo 'Views: ' . getInfo($track, "views") . ' | Downloads: ' . getInfo($track, "downloads") . '<br />';
 echo 'Start Line: (' . (int) $startLinex[$track] . 'x, ' . (int) $startLiney[$track] . 'y)<br />';
 echo 'Track Dimensions: (' . round($highx - $lowx) . ' x ' . round($highy - $lowy) . ')<br />';
 echo 'Flipped Lines: ' . (int) $flippedLines[$track] . '<br />';
 if ($totalLines[$track] > 0) {
     echo 'Accuracy: <a href="#" title="Total Lines: ' . $totalLines[$track] . ', Erased Lines: ' . $erasedLines[$track] . ', Remaining Lines: ' . $lineCount[$track] . '">' . round(100 * (1 - $erasedLines[$track] / $totalLines[$track]), 2) . '%</a><br />';