summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zoom.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/zoom.php b/zoom.php
index 39381a7..c36c2c5 100644
--- a/zoom.php
+++ b/zoom.php
@@ -193,22 +193,23 @@ if ( !isset($name) || !$name ) {
);
}
}
+
if ($type == "json") {
- // Displays the output as json
+ // Displays the output as json (TODO : why not use json_encode)
+ header('Content-Type: application/json');
+
$json = "{";
- $json .= '"package": "' . $name ."\", ";
- $json .= '"branch": [';
+ $json .= '"package":"' . $name ."\",";
+ $json .= '"branch":[';
$cnt = 0;
foreach ($packages as $package) {
$cnt += 1;
$json .= "{";
- $json .= '"'. $package->repo_main .'": ';
+ $json .= '"'. $package->repo_main .'":"';
if ($package->epoch) {
- $json .= '"'.$package->epoch.'" ';
- } else {
- $json .= '"'.$package->ver."-".$package->rel.'" ';
+ $json .= $package->epoch.':';
}
- $json .= "}";
+ $json .= $package->ver."-".$package->rel.'"}';
if ($cnt != count($packages)) {
$json .= ",";
}
@@ -217,17 +218,17 @@ if ($type == "json") {
echo $json;
} else if ($type == "text") {
// Displays the output as text
+ header('Content-Type: text/plain');
+
$text = 'package: ' . $name ." \n";
$cnt = 0;
foreach ($packages as $package) {
$cnt += 1;
$text .= $package->repo_main .': ';
if ($package->epoch) {
- $text .= $package->epoch;
- } else {
- $text .= $package->ver."-".$package->rel;
+ $text .= $package->epoch.':';
}
- $text .= "\n";
+ $text .= $package->ver."-".$package->rel."\n";
}
echo $text;
} else {