Commit dd61fa6a authored by David Morley's avatar David Morley
Browse files

api's are in. no json but no one using it yet

parent 32d3cb8c
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<?php
//this is just a single api for a pod for the android app to get data
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$domain = explode('//',$_GET['url']);
$sql = "SELECT * FROM pods WHERE domain = '$domain[1]'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
echo "Status: " . $row["status"] . "<br>";
echo "Last Git Pull: " . $row["hgitdate"] . "<br>";
echo "Uptime This Month " . $row["uptimelast7"] . "<br>";
echo "Months Monitored: " . $row["monthsmonitored"] . "<br>";
echo "Response Time: " . $row["responsetimelast7"] . "<br>";
}
pg_free_result($result);
pg_close($dbh);
?>
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<?php
if ($_GET['key'] != "4r45tg") {exit;}
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
$i=0;
while ($row = pg_fetch_array($result)) {
$numrows = pg_num_rows($result);
if ($row["status"] == "up"){$status="Online";}else{$status="Offline";}
if ($row["secure"] == "true") {$method = "https://";$class="green";} else {$method = "http://";$class="red";}
if ($_GET['format'] == "json") {
//json output
} else {
//text output, formated for android app
echo $method.$row["domain"] ." - ".$status." Now - Up ".$row["uptimelast7"]." This Month";
if ($i < ($numrows -1)) {
echo ",";
}
$i++;
}
}
pg_free_result($result);
pg_close($dbh);
?>
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