} if ($type == 2) { //String $slength = toShort(fread($file, 2)); if ($slength > 0) { $value = fread($file, $slength); } //echo '<br />String ' . $name . ' = ' . $value; } if ($type == 6) { //Undefined //echo '<br />Undefined ' . $name; } if ($type == 8) { //Array $value = toLong(fread($file, 4)); if ($name == "startLine") { $startLine = true; } //echo '<br />Array ' . $name . '(' . $value . ') {'; } } } fclose($file); ?> <!-- <input type="button" value="Random" onclick="num = Math.round(Math.random()*<?php echo $inc; ?> ); document.getElementById(num).className = 'o';"> --> <script type="text/javascript" language="javascript">
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 } } } }