예제 #1
0
<?php

if (isset($_REQUEST['refer']) && Session::is_user()) {
    $refer = preg_replace('/\\&/', '?', $_REQUEST["refer"], 1);
    header("Location: " . LINK_ABS . $refer);
}
MainTemplate::set_feature_image(LINK_ABS . "img/homepage.png");
echo "\n\t\t<script type=\"text/javascript\">\n\t\t\$(function () {\n\t\t\t\$('#username').focus();\n\t\t\t\$('.form-signin').submit(function(event) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t\$('#submit').button('loading');\n\t\t\t\t\$('.help-inline').remove();\n\t\t\t\t\$.post('ajax/login.php', \$(this).serialize(), function(data) {\n\t\t\t\t\tif(data == \"success\") { \n\t\t\t\t\t\tlocation.reload()\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$('#submit').after('<span class=\"help-inline\">'+data+'</span>');\n\t\t\t\t\t\t\$('#submit').button('reset');\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t});\n\t\t});\n\t\t</script>";
$feature = "\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-sm-8\">\n\t\t\t\t\t<h1>Digiplay <small>by Radio Warwick</small></h1>\n\t\t\t\t\t<p>A magical software suite run by miniature elves, which is amazing because elves are already very small by their nature.</p>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t" . (Session::is_user() ? "\n\t\t\t\t\t<h2>Common Tasks</h2>\n\t\t\t\t\t<a href=\"music/upload/\" class=\"btn btn-primary btn-large btn-block\">Upload Audio &raquo;</a>\n\t\t\t\t\t<a href=\"playlists/\" class=\"btn btn-primary btn-large btn-block\">Edit Playlists &raquo;</a>\n\t\t\t\t\t<a href=\"sustainer/\" class=\"btn btn-primary btn-large btn-block\">Schedule Prerecorded Content &raquo;</a>\n\t\t\t\t\t<a href=\"faults/\" class=\"btn btn-primary btn-large btn-block\">Report a Fault &raquo;</a>\n\t\t\t\t\t" . (Session::is_group_user("Studio Admin") ? "<a href=\"reset.php\" class=\"btn btn-primary btn-large btn-block\">Reset Playout Systems &raquo;</a>" : "") . "\n\t\t\t\t" : "\n\t\t\t\t\t<form class=\"form-signin\" action=\"ajax/login.php\" method=\"post\">\n\t\t\t\t\t\t<div class=\"form-group" . (isset($_REQUEST['refer']) ? " has-error" : "") . "\">\n\t\t\t\t\t\t\t<input id=\"username\" name=\"username\" type=\"text\" class=\"form-control input-lg\" placeholder=\"Username\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"form-group" . (isset($_REQUEST['refer']) ? " has-error" : "") . "\">\n\t\t\t\t\t\t\t<input id=\"password\" name=\"password\" type=\"password\" class=\"form-control input-lg\" placeholder=\"Password\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"btn btn-lg " . (isset($_REQUEST['refer']) ? "btn-danger" : "btn-primary") . " btn-block\" id=\"submit\" name=\"submit\" value=\"Log In\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t") . "\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t";
MainTemplate::set_feature_html($feature);
echo "<div class=\"row\">\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Music Library</h2>\n\t\t\t\t<dl>\n\t\t\t\t\t<dt>Tracks Stored</dt>\n\t\t\t\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\n\t\t\t\t\t<dt>Length of Tracks</dt>\n\t\t\t\t\t<dd>" . Time::format_pretty(Tracks::get_total_length()) . "</dd>\n\t\t\t\t\t<dt>Playlisted Tracks</dt>\n\t\t\t\t\t<dd>" . (count(Tracks::get_playlisted()) - count(Tracks::get_playlisted(Playlists::get(0)))) . "</dd>\n\t\t\t\t</dl>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Sustainer Service</h2>\n\t\t\t\t<dl>\n\t\t\t\t\t<dt>Tracks on Sustainer</dt>\n\t\t\t\t\t<dd>" . Sustainer::get_total_tracks() . "</dd>\n\t\t\t\t\t<dt>Length of Sustainer Playlist</dt>\n\t\t\t\t\t<dd>" . Sustainer::get_total_length_formatted() . "</dd>\n\t\t\t\t</dl>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "sustainer/\">" . Bootstrap::glyphicon("headphones") . "Now playing</a>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "playlists/detail/0\">" . Bootstrap::glyphicon("list") . "View playlist</a>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Newest Tracks</h2>";
$tracks = Tracks::get_newest(4);
echo "<table class=\"table table-striped table-hover table-condensed\" cellspacing=\"0\">";
foreach ($tracks as $track) {
    echo "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=\"icon\">\n\t\t\t\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\n\t\t\t\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"title\">" . $track->get_title() . " by " . $track->get_artists_str() . "</td>\n\t\t\t\t\t</tr>";
}
echo "\n\t\t\t\t</table>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "music/\">" . Bootstrap::glyphicon("chevron-right") . "More</a>\n\t\t\t</div>\n\t\t</div>";
if (Session::is_user()) {
    $lastlogin = Session::get_lastlogin();
    if ($lastlogin) {
        echo "<p class=\"text-success\">You last logged in: " . strftime("%A %e %B %G %H:%M", $lastlogin) . "</p>";
    } else {
        echo "<p class=\"text-success\">You've never logged in before! Welcome to the Digiplay Web Management System.</p>";
    }
    echo "<h4>Tracks of the Day:</h4><ul>";
    $tracks = Tracks::get_tracks_of_the_day(3);
    foreach ($tracks as $track) {
        echo "<li><a href=\"music/detail/" . $track->get_id() . "\">" . $track->get_artists_str() . " - " . $track->get_title() . "</a></li>";
    }
    echo "</ul>";
}