Peticiones

RadioBOSS Song Request demo Back‘; exit(“$msg $back_link”); } $type = isset($_POST[‘type’]) ? $_POST[‘type’] : ”; if ($type === ”) { echo ‘
‘; } elseif ($type === ‘request’) { //requested artist $artist = mb_strtolower(trim($_POST[‘artist’])); if ($artist === ”) { $artist = false; } //requested title $title = mb_strtolower(trim($_POST[‘title’])); if ($title === ”) { $title = false; } if (($artist === false) && ($title === false)) { result(‘No artist or title entered.’); } //load library $library_raw = HTTPGet(“$rb_api&action=library&filename=” . urlencode($rb_library)); if ($library_raw === false) { $err = ‘Song request failed: unable to load music library.’; if ($show_errors) { $err .= ‘ Error: ‘ . $last_err; } result($err); } //parse XML data $xml = simplexml_load_string($library_raw); if ($xml === false) { result(‘Song request failed: unable to parse music library XML data.’); } $fn = false; //search requested song in a music library foreach ($xml as $x) { if ($x->getName() !== ‘Track’) { continue; } $found = (($artist === false) || (mb_strtolower((string)$x[‘artist’]) === $artist)) && (($title === false) || (mb_strtolower((string)$x[‘title’]) === $title)); if ($found) { $fn = (string)$x[‘filename’]; break; } } //song found, add to requested songs list in RadioBOSS if ($fn !== false) { $msg = isset($_POST[‘message’]) ? $_POST[‘message’] : ”; $res = HTTPGet(“$rb_api&action=songrequest&filename=” . urlencode($fn) . ‘&message=’ . urlencode($msg)); if ($res === ‘OK’) { result(‘Song requested successfully!’); } else { $err = ‘An error occurred while adding song request.’; if ($show_errors) { $err .= ‘ Error: ‘ . $last_err; } result($err); } } else { result(‘Requested song not found in the music library.’); } } ?>