X-Git-Url: https://git.cweiske.de/noxon-gateway.git/blobdiff_plain/931d5803649e32b043d7af9034dde326ddb1fefa..4233101d0f4a9ce02d399e98ea97ceade9ce42a5:/www/index.php
diff --git a/www/index.php b/www/index.php
index cc0be0e..8b803db 100644
--- a/www/index.php
+++ b/www/index.php
@@ -1,44 +1,46 @@
&1', $output, $retVal);
+
+ if ($retVal == 0) {
+ addTextLines($listItems, $output);
+ } else {
+ $listItems[] = getMessageItem('Error executing script');
+ addTextLines($listItems, $output);
+ }
+}
+
+function sendTextFile($path)
+{
+ global $varDir;
+ $listItems = array();
+ addPreviousItem($listItems, $path);
+
+ $lines = file($varDir . $path);
+ addTextLines($listItems, $lines);
+ sendListItems($listItems);
+}
+
+function addTextLines(&$listItems, $lines)
+{
+ foreach ($lines as $line) {
+ $line = trim($line);
+ if ($line != '') {
+ $listItems[] = getDisplayItem($line);
+ }
+ }
+}
+
+function getDisplayItem($line)
+{
+ $line = preg_replace('#\s+#', ' ', $line);
+ return '- '
+ . 'Display'
+ . '' . utf8_decode(htmlspecialchars($line)) . ''
+ . '
';
+}
+
+function getDirItem($title, $urlPath)
+{
+ global $host1, $host2;
+ return '- '
+ . 'Dir'
+ . '' . utf8_decode(htmlspecialchars($title)) . ''
+ . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . ''
+ . '' . $host2 . utf8_decode(htmlspecialchars($urlPath)) . ''
+ . '
';
+}
+
+function getEpisodeItem($title, $fullUrl, $desc, $type)
+{
+ return '- '
+ . 'ShowEpisode'
+ . '' . utf8_decode(htmlspecialchars($title)) . ''
+ . '' . $fullUrl . ''
+ . '' . utf8_decode(htmlspecialchars($desc)) . ''
+ . '' . $type . ''
+ . '
';
+}
+
+function getPodcastItem($title, $urlPath)
+{
+ global $host1;
+ return '- '
+ . 'ShowOnDemand'
+ . '' . utf8_decode(htmlspecialchars($title)) . ''
+ . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . ''
+ . '
';
+}
+
+function getMessageItem($msg)
+{
+ return '- '
+ . 'Message'
+ . '' . utf8_decode(htmlspecialchars($msg)) . ''
+ . '
';
+}
+
+function getPreviousItem($urlPath)
+{
+ global $host1, $host2;
+ return '- '
+ . 'Previous'
+ . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . ''
+ . '' . $host1 . utf8_decode(htmlspecialchars($urlPath)) . ''
+ . '
';
+}
+
+function addPreviousItem(&$listItems, $urlPath)
+{
+ $parentDir = dirname($urlPath) . '/';
+ if ($parentDir == '/') {
+ return;
+ }
+ $listItems[] = getPreviousItem($parentDir);
+}
function getFinalUrl($url)
{
@@ -65,8 +257,12 @@ function getFinalUrl($url)
return $url;
}
+function sendMessage($msg)
+{
+ sendListItems(array(getMessageItem($msg)));
+}
-function sendList($path)
+function sendListItems($listItems)
{
$startitems = 1;
$enditems = 10;
@@ -76,54 +272,17 @@ function sendList($path)
if (isset($_GET['enditems'])) {
$enditems = (int) $_GET['enditems'];
}
+ //TODO: limit list
- header('Content-type: text/xml');
- echo <<
-
- -1
- -
- Message
- $path
-
- -
- Dir
- $path
- http://radio567.vtuner.com/$path
- http://radio5672.vtuner.com/$path
-
-
-
-XML;
-}
-
-function sendMessage($msg)
-{
- header('Content-type: text/xml');
- $xMsg = htmlspecialchars($msg);
- echo <<
-
- -
- Message
- $xMsg
-
-
-
-XML;
-}
-
-function sendListItems($listItems)
-{
$xml = '' . "\n";
+ $xml .= '' . "\n";
$xml .= '' . "\n";
foreach ($listItems as $item) {
$xml .= $item . "\n";
}
$xml .= "\n";
-
+
header('Content-type: text/xml');
echo $xml;
}
-
?>