errorInput('No URL given as command line parameter');
}
$pageUrl = $argv[1];
- } else {
- if (!isset($_SERVER['CONTENT_TYPE'])) {
- errorInput('Content type header missing');
- } else if ($_SERVER['CONTENT_TYPE'] != 'text/plain') {
- errorInput('Content type is not text/plain but ' . $_SERVER['CONTENT_TYPE']);
- }
+ } else if (!isset($_SERVER['CONTENT_TYPE'])) {
+ errorInput('Content type header missing');
+ } else if ($_SERVER['CONTENT_TYPE'] == 'text/plain') {
+ //Android app
$pageUrl = file_get_contents('php://input');
+ } else if ($_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded') {
+ //Web form
+ if (!isset($_POST['url'])) {
+ errorInput('"url" POST parameter missing');
+ }
+ $pageUrl = $_POST['url'];
+ } else {
+ errorInput('Content type is not text/plain but ' . $_SERVER['CONTENT_TYPE']);
}
+
$parts = parse_url($pageUrl);
if ($parts === false) {
errorInput('Invalid URL in POST data');
ini_set('track_errors', 1);
$xml = @file_get_contents($dreamboxUrl . '/web/session');
if ($xml === false) {
+ if (!isset($http_response_header)) {
+ errorOut(
+ 'Error fetching dreambox web interface token: '
+ . $GLOBALS['lastError']
+ );
+ }
+
list($http, $code, $message) = explode(
' ', $http_response_header[0], 3
);
);
}
}
+
+function errorHandlerStore($number, $message, $file, $line)
+{
+ $GLOBALS['lastError'] = $message;
+ return false;
+}
+$GLOBALS['lastError'] = null;
?>