if ($path_params[1] != null) {
        if ($path_params[1] == "artists") {
            if ($path_params[2] != null) {
                render_result(get_artist("album", $path_params[2]), "artists", $type);
            } else {
                render_result(get_artist("album"), "artists", $type);
            }
        } else {
            if ($path_params[2] != null) {
                $rowtitles = get_row_titles("album");
                // get rows of gd-table album
                if (in_array($path_params[2], $rowtitles)) {
                    render_result(get_album($path_params[1], $path_params[2]), "albums", $type);
                    /* render explicit info of album given by cddbid */
                } elseif ($path_params[2] == "tracks") {
                    render_result(get_track(null, null, $path_params[1]), "albums", $type);
                    /* render tracklist from album given by cddbid */
                } else {
                    render_result(get_album($path_params[1]), "albums", $type);
                    /* render all infos of album given by cddbid (if wrong info is ordered) */
                }
            } else {
                render_result(get_album($path_params[1]), "albums", $type);
                /* render all infos of album given by cddbid */
            }
        }
    } else {
        render_result(get_album(), "albums", $type);
        /* render list of all albums */
    }
}
        } else {
            if ($path_params[2] != null) {
                $rowtitles = get_row_titles("tracks");
                // get rows of gd-table tracks
                if (in_array($path_params[2], $rowtitles)) {
                    render_result(get_track($path_params[1], $path_params[2]), "tracks", $type);
                    /* render explicit info of track given by id */
                } elseif ($path_params[2] == "audio") {
                    get_audio_data($path_params[1]);
                    /* deliver binary audio-data of track given by id */
                } else {
                    render_result(get_track($path_params[1]), "tracks", $type);
                    /* render all infos of track given by id (if wrong info is ordered) */
                }
            } else {
                render_result(get_track($path_params[1]), "tracks", $type);
                /* render all infos of track given by id */
            }
        }
    } else {
        render_result(get_track(), "tracks", $type);
        /* render all infos of all tracks */
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // POST Request
    $input = file_get_contents("php://input");
    render_result(create_track_record($input), null, $type);
    /* create track entry and copy file */
}
mysql_close($database);
function write_tracklist($tracklist, $artist = null, $title = null, $cddbid = null)
{
    global $trackrow_param;
    print "<table class='tracklist' borders='0'>";
    write_track_table_head($trackrow_param);
    if ($tracklist) {
        print "<tbody>";
        foreach ($tracklist as $track) {
            if (isset($artist)) {
                if (preg_match("/^" . stripslashes($artist) . "/i", $track->artist)) {
                    $json = json_decode(get_track($track->id));
                    print "<tr>";
                    write_trackrow($json, $trackrow_param);
                    print "</tr>";
                }
            } elseif (isset($title)) {
                if (preg_match("/^" . stripslashes($title) . "/i", $track->title)) {
                    $json = json_decode(get_track($track->id));
                    print "<tr>";
                    write_trackrow($json, $trackrow_param);
                    print "</tr>";
                }
            } else {
                $json = json_decode(get_track($track->id));
                print "<tr>";
                write_trackrow($json, $trackrow_param);
                print "</tr>";
            }
        }
        print "</tbody>";
    }
    print "</table>";
}
Beispiel #4
0
    ob_start();
}
$r = $_REQUEST['r'];
$x = $_REQUEST['x'];
$y = $_REQUEST['y'];
$detail = $_REQUEST['detail'];
$dup = array();
$found = 0;
if ($r > 100) {
    ajaxerr("too big range");
}
if ($r == 0) {
    ajaxerr("empty");
}
$data = get_waypoint($x, $y, $r, $detail);
$trk_data = get_track($x, $y, $r, $detail);
// 整理一下 data
if ($data === false || count($data) == 0 && count($trk_data) == 0) {
    header('Access-Control-Allow-Origin: *');
    ajaxerr("empty result");
}
if (empty($detail) || $detail == 0) {
    // 傳回高度
    $twDEM_path = "../db/DEM/twdtm_asterV2_30m.tif";
    $ele = get_elev($twDEM_path, $y, $x, 1);
    header('Access-Control-Allow-Origin: *');
    ajaxok(array("wpt" => $data, "trk" => $trk_data, "ele" => $ele));
} else {
    // web page
    echo "<html>";
    echo "<head><title>TWMAP waypoint detail</title><meta charset=\"UTF-8\">";