예제 #1
0
<?php

Output::set_template();
if (isset($_REQUEST["key"])) {
    $location = Locations::get_by_key($_REQUEST["key"]);
    $key = $_REQUEST["key"];
} else {
    if (isset($_REQUEST["location"])) {
        $location = Locations::get_by_id($_REQUEST["location"]);
        $key = $location->get_key();
    } else {
        exit("No location specified!");
    }
}
switch ($_REQUEST["action"]) {
    case "check-next":
        $next = Configs::get(NULL, $location, "next_on_showplan")->get_val();
        if ($next == "") {
            echo json_encode(array("response" => "false"));
        } else {
            echo json_encode(array("response" => "true", "md5" => $next));
        }
        break;
    case "load-player":
        $config = Configs::get(NULL, $location, "next_on_showplan");
        $audio = Audio::get_by_md5($config->get_val());
        $config->set_val("");
        echo json_encode(array("response" => "success", "title" => $audio->get_title(), "artist" => $audio->get_artists_str()));
        break;
}
예제 #2
0
session_start();
Errors::start();
if (!function_exists('http_response_code')) {
    function http_response_code($code = NULL)
    {
        header(':', true, $code);
    }
}
if (!Session::is_user() && (substr(LINK_FILE, 0, 4) == "ajax" && LINK_FILE != "ajax/login.php")) {
    http_response_code(403);
    exit(json_encode(array("error" => "Your session has timed out, or you have logged out in another tab. Please log in again.")));
}
if (substr(LINK_FILE, 0, 6) == "studio") {
    MainTemplate::set_barebones(true);
    if (isset($_REQUEST["key"])) {
        if (is_null(Locations::get_by_key($_REQUEST["key"]))) {
            exit("Sorry, you provided an invalid security key.");
        }
    } else {
        Output::require_user();
    }
}
if (LINK_FILE != "index.php" && LINK_FILE != "ajax/login.php" && substr(LINK_FILE, 0, 6) != "studio" && substr(LINK_FILE, 0, 5) != "audio") {
    Output::require_user();
}
if (Session::is_developer()) {
    ini_set("display_errors", "1");
    ini_set("display_startup_errors", "1");
    ini_set("html_errors", "1");
    ini_set("docref_root", "http://www.php.net/");
    ini_set("error_prepend_string", "<div class=\"alert alert-error\">");
예제 #3
0
Output::set_template();
if (is_numeric($_GET["id"])) {
    $audio = Audio::get_by_id($_GET["id"]);
} else {
    $audio = Audio::get_by_md5($_GET["id"]);
}
$filetypes = array("mp3" => "audio/mpeg", "flac" => "audio/flac", "wav" => "audio/wav");
if (array_key_exists($_GET["filetype"], $filetypes)) {
    $filetype = $_GET["filetype"];
    $mimetype = $filetypes[$_GET["filetype"]];
} else {
    exit(http_response_code(400));
}
if (!Session::is_group_user("Music Admin")) {
    if (!isset($_GET["key"]) || is_null(Locations::get_by_key($_GET["key"]))) {
        exit(http_response_code(401));
    }
}
$md5 = $audio->get_md5();
$fl = substr($md5, 0, 1);
header("Content-type: " . $filetype);
header("accept-ranges: bytes");
if ($filetype == "flac") {
    header("Content-Length: " . filesize($audio->get_archive()->get_localpath() . "/" . $fl . "/" . $md5 . ".flac"));
}
if ($filetype == "mp3") {
    header("Content-Length: " . 32000 * $audio->get_length());
}
if ($filetype == "wav") {
    header("Content-Length: " . 176426 * $audio->get_length());