<?php Output::http_error(404);
<?php Output::http_error(410);
<?php if (!Session::is_group_user("Importer")) { Output::http_error(403); } else { if (!isset($_REQUEST["filename"])) { die(json_encode(array("error" => "invalid input file"))); } $uploaded_file = utf8_decode(FILE_ROOT . "uploads/" . $_REQUEST["filename"]); if (!isset($_REQUEST["type"])) { $_REQUEST["type"] = "music"; } if (!isset($_REQUEST["title"]) || $_REQUEST["title"] === "") { die(json_encode(array("error" => "You must specify a title"))); } $current_archive = Archives::get_playin(); $path = is_dir($current_archive->get_localpath()) ? $current_archive->get_localpath() : (is_dir($current_archive->get_remotepath()) ? $current_archive->get_remotepath() : die(json_encode(array('error' => 'Playin archive inaccessible')))); if (!is_writable($path)) { die(json_encode(array("error" => "Audio archive is not writable"))); } $tempfile = tempnam(sys_get_temp_dir(), 'dps') . "." . pathinfo($uploaded_file, PATHINFO_EXTENSION); copy($uploaded_file, $tempfile); $md5 = md5_file($tempfile); $output = array(); # Execute SoX to convert our audio # Trim silence from beginning and end (1% volume threshold) # Convert to 44.1kHz 16-bit stereo for consistency # Normalise to -0.1dB # Save as flac in inbox exec("sox \"" . $tempfile . "\" -b 16 \"" . $path . "/inbox/" . $md5 . ".flac\" silence 1 0.1 -72d reverse silence 1 0.1 -72d reverse channels 2 rate 44100 gain -n -0.1 2>&1", $output); if (strpos(implode($output), "FAIL")) {