index : archweb32 | |
Archlinux32 website | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-07-10 09:20:53 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-07-10 09:20:53 +0200 |
commit | 1bdfa0fa9de78c1139c300292d9d47e8e11d3ab0 (patch) | |
tree | 8a24676383624196f81a70f1a5241bcb8865d0e4 /lib | |
parent | 9722f5cd5e39e07113fc8aeb4e73ff180b85985f (diff) |
-rw-r--r-- | lib/format.php | 10 |
diff --git a/lib/format.php b/lib/format.php index c250c8a..8731eb0 100644 --- a/lib/format.php +++ b/lib/format.php @@ -8,23 +8,23 @@ require_once "../init.php"; include_once BASE . "/lib/http.php"; function export_as_requested($content) { - if (isset($_GET["json"])) { + if (isset($content["json"]) && isset($_GET["json"])) { header ("Content-type: application/json"); print json_encode( - $content, + $content["json"], JSON_UNESCAPED_SLASHES ); - } elseif (isset($_GET["tsv"])) { + } elseif (isset($content["tsv"]) && isset($_GET["tsv"])) { header ("Content-type: text/tab-separated-values"); if (! isset($_GET["no-headers"])) - print implode("\t",array_keys($content[0])) . "\n"; + print implode("\t",array_keys($content["tsv"][0])) . "\n"; print implode( "\n", array_map( function($row){ return implode("\t",$row); }, - $content + $content["tsv"] ) ); } else { |