Esempio n. 1
0
 if ($length == 0) {
     if (ord(fread($file, 1)) == 9) {
         if ($startLine == true) {
             $startLine = false;
         }
         $skip = true;
     } else {
         fseek($file, ftell($file) - 1);
     }
 }
 if ($skip == false) {
     $name = fread($file, $length);
     $type = ord(fread($file, 1));
     if ($type == 0) {
         //Number
         $value = toDouble(fread($file, 8));
         if ($name == "0") {
             $x1 = $value;
         }
         if ($name == "1") {
             $y1 = $value;
             if ($startLine == true && $showStart == true) {
                 echo '<div class="r" style="font-weight: bold; left: ' . round(($x1 - $offx) / $ratio - 2 + $sx) . 'px; top: ' . round(($y1 - $offy) / $ratio - 6 + $sy) . 'px;">(S)</div>' . $nl;
                 //imagestring($img, 2, ($x1 - $offx) / $ratio - 2, ($y1 - $offy) / $ratio - 6, "S", $colorAccel);
                 //imageellipse($img, ($x1 - $offx) / $ratio, ($y1 - $offy) / $ratio, 12, 12, $colorAccel);
             }
         }
         if ($name == "2") {
             $x2 = $value;
         }
         if ($name == "3") {
Esempio n. 2
0
function getInfo($id, $infoname, $infotype = 2, $method = "sql")
{
    if ($method == "sql") {
        //More efficient database method
        $result = mysql_query("SELECT * FROM tracks WHERE id=" . $id);
        $tdata = mysql_fetch_array($result);
        return $tdata[$infoname];
    } else {
        //Raw data method (CAUTION values are not stored this way anymore as of 10/18/2007 with the exception of label)
        //This function will get the first item's value whose name is $infoname and type is $infotype
        if (file_exists("tracks/" . $id . ".track")) {
            $contents = file_get_contents("tracks/" . $id . ".track");
            $pos = strpos($contents, $infoname) + strlen($infoname);
            $type = toByte(substr($contents, $pos, 1));
            $pos++;
            if ($infotype == $type) {
                if ($type == 0) {
                    return toDouble(substr($contents, $pos, 8));
                } elseif ($type == 1) {
                    return toBoolean(substr($contents, $pos, 1));
                } elseif ($type == 2) {
                    $strlength = toShort(substr($contents, $pos, 2));
                    return substr($contents, $pos + 2, $strlength);
                } elseif ($type == 3) {
                    return true;
                } elseif ($type == 6) {
                    return true;
                } elseif ($type == 8) {
                    return toLong(substr($contents, $pos, 4));
                }
                //Return number of items in array
            }
        }
    }
}