&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 sendMessage($msg) { sendListItems(array(getMessageItem($msg))); } function sendListItems($listItems) { $startitems = 1; $enditems = 10; if (isset($_GET['startitems'])) { $startitems = (int) $_GET['startitems']; } if (isset($_GET['enditems'])) { $enditems = (int) $_GET['enditems']; } //TODO: limit list $xml = '' . "\n"; $xml .= '' . "\n"; $xml .= '' . "\n"; foreach ($listItems as $item) { $xml .= $item . "\n"; } $xml .= "\n"; header('Content-type: text/xml'); echo $xml; } ?>