index : website | |
Archlinux32 website - obsolete | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2019-05-22 14:07:32 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-05-22 14:07:32 +0200 |
commit | 41a90f24786bf28d787fd0cf8c5af18407524391 (patch) | |
tree | e99db37f7663134da980bb0fcd924e652aecd497 /lib | |
parent | 4b88074bdae7985c1a984dbc1cbef6c3eab9debe (diff) |
-rw-r--r-- | lib/format.php | 9 |
diff --git a/lib/format.php b/lib/format.php index 25748f0..f0f34b3 100644 --- a/lib/format.php +++ b/lib/format.php @@ -6,19 +6,19 @@ if (function_exists("export_as_requested")) include_once BASE . "/lib/http.php"; -function export_as_requested($content) { +function export_as_requested($content, $format = NULL) { if (isset($content["All"])) { $content["json"]=$content["All"]; $content["tsv"]=$content["All"]; unset($content["All"]); } - if (isset($content["json"]) && array_key_exists("json", $_GET)) { + if (isset($content["json"]) && ((empty($format) && array_key_exists("json", $_GET)) || ($format == 'json'))) { header ("Content-type: application/json"); print json_encode( $content["json"], JSON_UNESCAPED_SLASHES ); - } elseif (isset($content["tsv"]) && array_key_exists("tsv", $_GET)) { + } elseif (isset($content["tsv"]) && ((empty($format) && array_key_exists("tsv", $_GET)) || ($format == 'tsv'))) { header ("Content-type: text/tab-separated-values"); if (! array_key_exists("no-headers", $_GET)) print implode("\t",array_keys($content["tsv"][0])) . "\n"; @@ -32,6 +32,8 @@ function export_as_requested($content) { ) ); } else { + if (!empty($format)) + return false; throw_http_error( 406, "Not Acceptable", @@ -54,4 +56,5 @@ function export_as_requested($content) { ) ); } + return true; } |