function announce_songs($songlist_struct)
{
    global $REL_PATH;
    $ts = time();
    $prefs_struct = get_opentape_prefs();
    $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
    $version_struct = $json->encode($songlist_struct[get_tape_path()]);
    $data = http_build_query(array('version' => constant("VERSION"), 'url' => get_base_url(), 'songs' => $version_struct));
    $result = do_post_request(constant("ANNOUNCE_SONGS_URL"), $data, null);
    if (!strcmp($result, "OK")) {
    } else {
        error_log("Failed to announce songs to " . constant("ANNOUNCE_SONGS_URL") . " result was: " . $result);
    }
    $prefs_struct['last_announce_songs'] = $ts;
    if (write_opentape_prefs($prefs_struct)) {
        return $prefs_struct;
    } else {
        false;
    }
}
Beispiel #2
0
<?php

// in progress
require_once "opentape_common.php";
$songlist_struct = scan_songs();
$songlist_struct_original = $songlist_struct;
$prefs_struct = get_opentape_prefs();
// Yes, this is the wrong way to build an XML file.
// But you know what? It works, and we still have time
// to go out for drinks after this is built.
header("Content-type: application/rss+xml; charset=UTF-8");
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<rss version="2.0">' . "\n";
echo '<channel>' . "\n";
echo '<title>';
if (isset($prefs_struct['banner'])) {
    echo $prefs_struct['banner'];
} else {
    echo 'Opentape!';
}
echo '</title>' . "\n";
echo '<description>' . "\n";
if (isset($prefs_struct['caption'])) {
    echo ' ' . htmlentities($prefs_struct['caption']);
} else {
    echo ' ' . count($songlist_struct) . "songs, " . get_total_runtime_string();
}
echo '</description>' . "\n";
echo '<link>' . get_base_url() . '</link>' . "\n";
foreach ($songlist_struct as $pos => $row) {
    if (!is_file(constant("SONGS_PATH") . $row['filename'])) {