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
            }
        }
    }
}
function toByte($value)
{
    if (is_array($value)) {
        foreach ($value as &$val) {
            $val = toByte($val);
        }
        return $value;
    } else {
        $value = (int) $value;
        $value = $value > 255 ? 255 : $value;
        return $value < 0 ? 0 : $value;
    }
}
Example #3
0
                        <svg data-color="ffffff"></svg>
                    </div>
                
                </div>
            </div>
            
            <div class="col-md-6">
                <div class="stats">
                    <?php 
$hdd = $host->hdd();
$numHdd = count($hdd);
$percentHdd = 0;
$total = 0;
foreach ($hdd as $disk) {
    $percentHdd = $percentHdd + $disk['percentage'];
    $total = $total + toByte($disk['total']);
}
$average = $percentHdd / $numHdd;
?>
                    <div class="text">
                        <h3>HDD</h3>
                        <?php 
echo sprintf(lang::get('hdd_avail'), byteToSize($total));
?>
                    </div>
                    
                    <div class="circle" data-color="2f323a">
                        <div><?php 
echo $average;
?>
%</div>