Commit 5187a54c authored by David Morley's avatar David Morley

Vipul A M thx

parent 26799ae4
......@@ -40,61 +40,18 @@ echo "</feed>";
}
elseif ($_GET['format'] == "json") {
$i=0;
$sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,hgitdate,hgitref,pingdomurl,pingdomlast,monthsmonitored,uptimelast7,responsetimelast7,hruntime,hencoding,dateCreated,dateUpdated,dateLaststats,hidden FROM pods";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
$numrows = pg_num_rows($result);
//json output WIP
header('Content-type: application/json');
echo '{';
echo '"podcount": '.json_encode($numrows);
//
echo '"pods": [';
while ($row = pg_fetch_array($result)) {
echo '{';
echo '"url":"'.$method.$row["domain"].'",';
echo '"email":"private",';
echo '"whois":"'.$method.$row["whois"].'",';
echo '"city":"'.$method.$row["city"].'",';
echo '"state":"'.$method.$row["state"].'",';
echo '"country":"'.$method.$row["country"].'",';
echo '"latitude":"'.$method.$row["lat"].'",';
echo '"longitude":"'.$method.$row["long"].'",';
echo '"postalcode":"'.$method.$row["postalcode"].'",';
echo '"connection":"'.$method.$row["connection"].'",';
echo '"SSL Valid":"'.$method.$row["sslvalid"].'",';
echo '"secure":"'.$method.$row["secure"].'",';
echo '"status":"'.$method.$row["status"].'",';
echo '"ip":"'.$method.$row["ip"].'",';
echo '"ipv6":"'.$method.$row["ipv6"].'",';
echo '"Git Last":"'.$method.$row["hgitdate"].'",';
echo '"Git Rev":"'.$method.$row["hgitref"].'",';
echo '"Pingdom Url":"'.$method.$row["pingdomurl"].'",';
echo '"Pingdom Last":"'.$method.$row["pingdomlast"].'",';
echo '"Months Monitored":'.$method.$row["monthsmonitored"].',';
echo '"Uptime":"'.$method.$row["uptimelast7"].'",';
echo '"Responsetime":"'.$method.$row["responsetimelast7"].'",';
echo '"Server Runtime":"'.$method.$row["hruntime"].'",';
echo '"Server Encoding":"'.$method.$row["hencoding"].'",';
echo '"Date Added":"'.$method.$row["dateCreated"].'",';
echo '"Date Updated":"'.$method.$row["dateUpdated"].'",';
echo '"Date Stats Updated":"'.$method.$row["dateLaststats"].'",';
echo '"hidden":"'.$method.$row["hidden"].'"';
//
//
echo '}';
if ($i < ($numrows -1)) {
echo ',';
}
$i++;
}
echo ']';
echo '}';
//json output, thx Vipul A M for fixing this
header('Content-type: application/json');
$rows=array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
$obj->pods = $rows;
print json_encode($obj);
} else {
$i=0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY Hgitdate DESC, uptimelast7 DESC";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment