Exemplo n.º 1
0
 function formatOutputData($result)
 {
     if (Result::is_result($result)) {
         if (Result::is_ok($result)) {
             $result = Redirect::success();
         } else {
             $result = Redirect::failure();
         }
     }
     if ($result instanceof IActionCommand) {
         return $result->execute();
     }
     echo render_result($result);
 }
            $rowtitles = get_row_titles("playlist");
            // get rows of gd-table playlist
            if (in_array($path_params[2], $rowtitles)) {
                render_result(get_playlist($path_params[1], $path_params[2]), "playlists", $type);
                /* render explicit info of playlist given by id */
            } elseif ($path_params[2] == "tracks") {
                render_result(get_tracklist($path_params[1]), "playlists", $type);
                /* render tracklist from playlist given by id */
            } else {
                render_result(get_playlist($path_params[1]), "playlists", $type);
                /* render all infos of playlist given by id (if wrong info is ordered) */
            }
        } else {
            render_result(get_playlist($path_params[1]), "playlists", $type);
            /* render all infos of playlist given by id */
        }
    } else {
        render_result(get_playlist(), "playlists", $type);
        /* render list of all playlists */
    }
}
/* not implemented yet
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_playlist_entry($input),null,$type); /* create playlist entry */
/*}*/
mysql_close($database);
?>


Exemplo n.º 3
0
function render_result($data)
{
    if ($data !== null) {
        if (is_array($data)) {
            if (isset($data[Block::MARKER_KEY])) {
                $block_name = $data[Block::MARKER_KEY];
                $block = BlockFactory::create($block_name, $data);
                return $block->__toString();
            }
            if (isset($data[Layout::MARKER_KEY])) {
                $layout_name = $data[Layout::MARKER_KEY];
                //il layout ha bisogno della vista dell'albero ma forse la posso passare anche così
                $layout = LayoutFactory::create($layout_name, $data);
                return $layout->__toString();
            }
            $collected = "";
            foreach ($data as $k => $v) {
                $collected .= render_result($v);
            }
            return $collected;
        }
        //nel caso in cui non sia un blocco e non sia un layout stampo quello che trovo :)
        return $data;
    }
}
/ 
/
/* *************************************************/
require_once "include/includes.php";
$database = init_database();
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    if ($path_params[1] != null) {
        $rowtitles = get_row_titles("playerstate");
        // get rows of gd-table playerstate
        if (in_array($path_params[1], $rowtitles)) {
            render_result(get_playerstate($path_params[1]), "playerstate", $type);
            /* render explicit info of playerstate */
        } else {
            render_result(get_playerstate(), "playerstate", $type);
            /* render all infos of playerstate (wrong explicit info given) */
        }
    } else {
        render_result(get_playerstate(), "playerstate", $type);
        /* render all infos of playerstate */
    }
}
mysql_close($database);
                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 */
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // POST Request
    $input = file_get_contents("php://input");
    render_result(create_album_record($input), null, $type);
    /* create album entry */
}
mysql_close($database);
?>


/  created by Andreas Baierl, 25.11.2009
/  
/
/  query.php - 	get several meta infos from db-tables (get) 
/               
/
/* *************************************************/
require_once "include/includes.php";
$database = init_database();
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // POST Request
    $input = file_get_contents("php://input");
    set_headers($type);
    render_result(execute_query($input), null, $type);
    /* execute query */
}
mysql_close($database);
/* **************************************************
/  REST Webservice for GiantDisc
/  created by Andreas Baierl, 25.11.2009
/  
/
/  infos.php - 	get special infos from db (get) 
/               
/
/* *************************************************/
require_once "include/includes.php";
$database = init_database();
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        if ($path_params[1] == lasttnb) {
            render_result(get_lasttnb(), "infos", $type);
            /* render highest used tracknumber */
        }
    }
}
mysql_close($database);
Exemplo n.º 8
0
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        if ($path_params[1] == languages) {
            render_result(get_languages(), "meta", $type);
            /* render language table */
        }
        if ($path_params[1] == types) {
            render_result(get_types(), "meta", $type);
            /* render musictype table */
        }
        if ($path_params[1] == rating) {
            render_result(get_rating(), "meta", $type);
            /* render possible rating values */
        }
        if ($path_params[1] == quality) {
            render_result(get_quality(), "meta", $type);
            /* render possible quality values */
        }
        if ($path_params[1] == genres) {
            render_result(get_genres(), "meta", $type);
            /* render genre table */
        }
        if ($path_params[1] == source) {
            render_result(get_source(), "meta", $type);
            /* render source table */
        }
    }
}
mysql_close($database);
Exemplo n.º 9
0
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        if ($path_params[2] != null) {
            render_result(get_beitragdetails($path_params[1], $path_params[2]), "beitraege", $type);
            // Ressourcendarstellung
        } else {
            render_result(get_beitrag($path_params[1]), "beitraege", $type);
            // Ressourcendarstellung
        }
    } else {
        render_result(get_beitraege(), "beitraege", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 10
0
if (isset($_GET['search_sql'])) {
    $params["search_sql"] = $_GET['search_sql'];
}
// Andreas neu
if (isset($_GET['sort'])) {
    $params["sort"] = $_GET['sort'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_mitglied($path_params[1]), "mitglieder", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_mitglieder($params), "mitglieder", $type);
        // Listenressource
        //echo $params["search_sql"];
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
    // PUT Request
    $input = file_get_contents("php://input");
    render_result(create_mitglied($input), null, $type);
    // create track entry and copy file
}
mysql_close($database);
Exemplo n.º 11
0
/
/* *************************************************/
require_once "includes.php";
$database = init_database();
$param = null;
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_status($path_params[1]), "stati", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_stati(), "stati", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 12
0
/
/  id3.php - 	get id3/file-infos of tracks (get) 
/               
/
/* *************************************************/
require_once "include/includes.php";
$database = init_database();
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        if ($path_params[1] != null && $path_params[2] != null) {
            render_result(get_id3($path_params[1], $path_params[2]), "id3", $type);
            /* render explicit id3/file-info of track given by full pathname or id */
        } else {
            if ($path_params[1] != null) {
                render_result(get_id3($path_params[1]), "id3", $type);
                /* render all id3/file-infos of track given by full pathname or id (if already imported) */
            }
        }
    }
}
mysql_close($database);
Exemplo n.º 13
0
    $type = $_GET['type'];
}
if (isset($_GET['start'])) {
    $params["start"] = $_GET['start'];
}
if (isset($_GET['amt'])) {
    $params["amt"] = $_GET['amt'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_jubilar($path_params[1]), "jubilare", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_jubilare($params), "jubilare", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 14
0
        } 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);
Exemplo n.º 15
0
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        if ($path_params[2] == "mitglieder") {
            render_result(get_strassenmitglieder($path_params[1]), "strassen", $type);
            // Ressourcendarstellung
        } else {
            render_result(get_strasse($path_params[1]), "strassen", $type);
            // Ressourcendarstellung
        }
    } else {
        render_result(get_strassen(), "strassen", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 16
0
/  created by Andreas Baierl, 09.02.2010
/  
/
/  statistik.php -	get Ressource: GET ".../statistik"
/					
/					
/
/* *************************************************/
require_once "includes.php";
$database = init_database();
$params = null;
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_statistik2($path_params[1]), "mitglieder", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_statistik($params), "statistik", $type);
        // Listenressource
    }
}
mysql_close($database);
Exemplo n.º 17
0
<?php

/* **************************************************
/  REST Webservice for GiantDisc
/  created by Andreas Baierl, 25.11.2009
/  
/
/  inbox.php - 	get inbox files and directories (get) 
/
/
/* *************************************************/
require_once "include/includes.php";
$database = init_database();
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    render_result(read_inbox(), "inbox", $type);
    /* render inbox directories and files (.mp3) */
}
mysql_close($database);
Exemplo n.º 18
0
/
/* *************************************************/
require_once "includes.php";
$database = init_database();
$param = null;
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_route($path_params[1]), "route", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_routen(), "routen", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 19
0
/
/* *************************************************/
require_once "includes.php";
$database = init_database();
$param = null;
if (isset($_GET['type'])) {
    $type = $_GET['type'];
}
// Check for the path elements
$path = $_SERVER[PATH_INFO];
if ($path != null) {
    $path_params = spliti("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // GET Request
    set_headers($type);
    if ($path_params[1] != null) {
        render_result(get_ort($path_params[1]), "orte", $type);
        // Ressourcendarstellung
    } else {
        render_result(get_orte(), "orte", $type);
        // Listenressource
    }
}
/* not used
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_route($input),null,$type); // create track entry and copy file 
}
*/
mysql_close($database);
Exemplo n.º 20
0
if (isset($_REQUEST['sSearch']) && '' != $_REQUEST['sSearch']) {
    $stext = addslashes($_REQUEST['sSearch']);
    $params["search_sql"] = ' WHERE ';
    $params["search_sql"] .= "vname like '{$stext}%' or nname like '{$stext}%' or strname like '{$stext}%' or ortname like '{$stext}%'";
}
// Andreas neu
// $params["scol_name"] = $cols[(int)$params["scol"]];
$result = "";
$i = 0;
$mitglieder = json_decode(send_request('mitglieder.php/', 'get', $params));
$result["iTotalRecords"] = $mitglieder->count_all;
$result["iTotalDisplayRecords"] = $mitglieder->count_query;
//$result["count_listed"] = $mitglieder->count_listed;
foreach ($mitglieder->mitglieder as $value) {
    $id = $value->id;
    $mitglied = json_decode(send_request('/mitglieder.php/' . $id, 'get'));
    $result["aaData"][$i][0] = $mitglied->ID;
    $result["aaData"][$i][1] = $mitglied->Nachname;
    $result["aaData"][$i][2] = $mitglied->Vorname;
    $result["aaData"][$i][3] = $mitglied->Strasse;
    $result["aaData"][$i][4] = $mitglied->Hausnummer;
    $result["aaData"][$i][5] = $mitglied->PLZ;
    $result["aaData"][$i][6] = $mitglied->Ort;
    $result["aaData"][$i][7] = $mitglied->Ortsteil;
    $result["aaData"][$i][8] = format_date($mitglied->Geburtsdatum);
    $result["aaData"][$i][9] = "<a href='mitglied.php?id=" . $mitglied->ID . "'>Edit</a>";
    $i++;
}
set_headers();
render_result($result);