Example #1
0
function sidebar()
{
    $return .= "\n\t<h4>Music Library</h4>\n\t<dl>\n\t\t<dt>Tracks</dt>\n\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\n\t\t<dt>Artists</dt>\n\t\t<dd>" . number_format(Artists::count()) . "</dd>\n\t\t<dt>Albums</dt>\n\t\t<dd>" . number_format(Albums::count()) . "</dd>\n\t</dl>";
    function bytes($a)
    {
        $unim = array("B", "KB", "MB", "GB", "TB", "PB");
        $c = 0;
        while ($a >= 1024) {
            $c++;
            $a = $a / 1024;
        }
        return number_format($a, $c ? 2 : 0, ".", ",") . " " . $unim[$c];
    }
    $return .= "\n\t<h4>Archive Storage</h4>\n\t<dl>";
    foreach (Archives::get_all() as $archive) {
        $pc = (int) (100 - $archive->get_free_space() / $archive->get_total_space() * 100);
        if ($archive->get_free_space() > 536870912000.0) {
            $colour = "success";
        } else {
            if ($archive->get_free_space() > 214748364800.0) {
                $colour = "warning";
            } else {
                $colour = "danger";
            }
        }
        $return .= "\n\t\t<dt>" . $archive->get_name() . "</dt>\n\t\t<dd><div class=\"progress\" style=\"margin: 3px 0px; \"><div class=\"progress-bar progress-bar-" . $colour . "\" style=\"width: " . $pc . "%;\"></div></div></dd>\n\t\t<dd>" . bytes($archive->get_free_space()) . " free of " . bytes($archive->get_total_space()) . "</dd>";
    }
    $return .= "</dl>";
    return $return;
}