Esempio n. 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;
}
Esempio n. 2
0
<?php

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") {