2 set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../src/');
3 $fullUri = $_SERVER['REQUEST_URI'];
4 $path = $_SERVER['REDIRECT_URL'];
5 $dataDir = __DIR__ . '/../data/';
7 if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token=0') {
8 //initial login for "internet radio" and podcasts
10 header('Content-type: text/html');
11 readfile($dataDir . 'initial-login.xml');
13 } else if ($fullUri == '/RadioNativeLogin.php') {
14 //initial login for "My noxon"
15 //this one wants CamelCased tags
16 header('Content-type: text/html');
17 readfile($dataDir . 'login-mynoxon.xml');
19 } else if ($path == '/setupapp/radio567/asp/BrowseXPA/LoginXML.asp') {
21 header('Content-type: text/xml');
22 sendList('internetradio');
24 } else if ($path == '/setupapp/radio567/asp/BrowseXPA/navXML.asp') {
26 require_once 'podcasts.php';
29 } else if (substr($path, 0, 9) == '/podcasts') {
30 require_once 'podcasts.php';
33 } else if ($path == '/RadioNative.php') {
35 header('Content-type: text/xml');
38 } else if ($path == '/setupapp/radio567/asp/BrowseXML/FavXML.asp') {
39 //Internet Radio Station favorites favorited on device
40 } else if ($path == '/RadioNativeFavorites.php') {
41 //Favorites, defined via web interface
42 } else if (substr($path, 0, 9) == '/play-url') {
43 //play a given URL, but first follow all redirects
44 //noxon iRadio Cube does not like too many redirections
45 // 3 redirects did not work.
47 header('HTTP/1.0 301 Moved Permanently');
48 header('Location: ' . getFinalUrl($url));
51 sendList(ltrim($path, '/'));
55 function getFinalUrl($url)
57 $ctx = stream_context_set_default(
58 array('http' => array('method' => 'HEAD'))
60 //get_headers follows redirects automatically
61 $headers = get_headers($url, 1);
62 if ($headers !== false && isset($headers['Location'])) {
63 return end($headers['Location']);
69 function sendList($path)
73 if (isset($_GET['startitems'])) {
74 $startitems = (int) $_GET['startitems'];
76 if (isset($_GET['enditems'])) {
77 $enditems = (int) $_GET['enditems'];
80 header('Content-type: text/xml');
82 <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
84 <ItemCount>-1</ItemCount>
86 <ItemType>Message</ItemType>
87 <Message>$path</Message>
90 <ItemType>Dir</ItemType>
92 <UrlDir>http://radio567.vtuner.com/$path</UrlDir>
93 <UrlDirBackUp>http://radio5672.vtuner.com/$path</UrlDirBackUp>
100 function sendMessage($msg)
102 header('Content-type: text/xml');
103 $xMsg = htmlspecialchars($msg);
105 <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
108 <ItemType>Message</ItemType>
109 <Message>$xMsg</Message>
116 function sendListItems($listItems)
118 $xml = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
119 $xml .= '<ListOfItems>' . "\n";
120 foreach ($listItems as $item) {
121 $xml .= $item . "\n";
123 $xml .= "</ListOfItems>\n";
125 header('Content-type: text/xml');