Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
        $_POST['banner'] = stripslashes($_POST['banner']);
        $_POST['caption'] = stripslashes($_POST['caption']);
        $_POST['color'] = stripslashes($_POST['color']);
    }
    $prefs_struct['banner'] = $_POST['banner'];
    $prefs_struct['caption'] = $_POST['caption'];
    $prefs_struct['color'] = $_POST['color'];
    if (write_opentape_prefs($prefs_struct)) {
        echo '{"status":true,"command":"' . $command . '","debug":""}';
    } else {
        echo '{"status":false,"command":"' . $command . '","debug":""}';
    }
} elseif (!strcmp($command, "set_option")) {
    $prefs_struct = get_opentape_prefs();
    // maybe should check if the key is a valid data item type, to prevent
    // some kind of sizing attack... though checking for login does well.
    foreach ($args as $key => $data) {
        if (!strcmp($data, "on") || !strcmp($data, "true") || $data === true || $data == 1) {
            $prefs_struct[$key] = 1;
        } else {
            $prefs_struct[$key] = 0;
        }
    }
    if (write_opentape_prefs($prefs_struct)) {
        echo '{"status":true,"command":"' . $command . '","debug":""}';
    } else {
        echo '{"status":false,"command":"' . $command . '","debug":""}';
    }
} else {
    echo '{"status":false,"command":"' . $command . '","debug":""}';
}