Commit daff2ab0 authored by David Morley's avatar David Morley Committed by GitHub

v1 api back to legacy (#95)

parent d44b0412
......@@ -21,7 +21,7 @@ if ($_format === 'georss') {
<link href="https://{$_SERVER['HTTP_HOST']}/"/>
EOF;
$sql = "SELECT name,monthsmonitored,responsetime,uptime_alltime,date_updated,score,domain,country,lat,long FROM pods";
$sql = "SELECT name,monthsmonitored,responsetimelast7,uptimelast7,dateupdated,score,domain,country,lat,long FROM pods_apiv1";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -32,9 +32,9 @@ EOF;
'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of 100 this pod is a %6$s right now',
$pod_name,
$row['monthsmonitored'],
$row['responsetime'],
$row['uptime_alltime'],
$row['date_updated'],
$row['responsetimelast7'],
$row['uptimelast7'],
$row['dateupdated'],
$row['score']
);
echo <<<EOF
......@@ -53,7 +53,7 @@ EOF;
}
echo '</feed>';
} elseif ($_format === 'json') {
$sql = 'SELECT id,domain,status,secure,score,signup,userrating,adminrating,city,state,country,lat,long,ip,ipv6,stats_apikey,monthsmonitored,uptime_alltime,responsetime,local_posts,comment_counts,date_created,date_updated,date_laststats,hidden,terms,sslexpire,uptime_custom,dnssec,softwarename,total_users,local_posts,comment_counts,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp FROM pods';
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods_apiv1';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -73,7 +73,7 @@ EOF;
}
} else {
$i = 0;
$sql = "SELECT domain,uptime_alltime,country,status FROM pods";
$sql = "SELECT domain,uptimelast7,country FROM pods_apiv1";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -82,10 +82,9 @@ EOF;
$i++ > 0 && print ',';
printf(
'%1$s is %2$s now - online %3$s%% This Month - Located in: %4$s',
'%1$s Up %2$s%% This Month - Located in: %3$s',
$row['domain'],
$row['status'],
$row['uptime_alltime'],
$row['uptimelast7'],
$row['country']
);
}
......
......@@ -8,12 +8,12 @@
// Other parameters.
$_format = $_GET['format'] ?? '';
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,stats_apikey,monthsmonitored,uptime_alltime,responsetime,local_posts,comment_counts,date_created,date_updated,date_laststats,hidden FROM pods WHERE domain = $1';
$sql = 'SELECT hgitdate,id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods_apiv1 WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -23,9 +23,9 @@ while ($row = pg_fetch_array($result)) {
} else {
echo 'Status: ' . $row['status'] . '<br>';
echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $row['uptime_alltime'] . '<br>';
echo 'Uptime This Month ' . $row['uptimelast7'] . '<br>';
echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>';
echo 'Response Time: ' . $row['responsetime'] . '<br>';
echo 'Response Time: ' . $row['responsetimelast7'] . '<br>';
echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Location: ' . $row['country'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>';
......
DROP TABLE pods_apiv1;
CREATE TABLE pods_apiv1 AS SELECT * FROM pods;
ALTER TABLE pods_apiv1 RENAME COLUMN stats_apikey TO pingdomurl;
ALTER TABLE pods_apiv1 RENAME COLUMN service_xmpp TO xmpp;
ALTER TABLE pods_apiv1 RENAME COLUMN uptime_alltime TO uptimelast7;
ALTER TABLE pods_apiv1 RENAME COLUMN responsetime TO responsetimelast7;
ALTER TABLE pods_apiv1 RENAME COLUMN date_updated TO dateUpdated;
ALTER TABLE pods_apiv1 RENAME COLUMN date_laststats TO dateLaststats;
ALTER TABLE pods_apiv1 RENAME COLUMN date_created TO dateCreated;
ALTER TABLE pods_apiv1 ALTER COLUMN ipv6 TYPE text USING ipv6::text;
ALTER TABLE pods_apiv1 ALTER hidden DROP DEFAULT;
ALTER TABLE pods_apiv1 ALTER COLUMN hidden TYPE text USING hidden::text;
ALTER TABLE pods_apiv1 ALTER COLUMN secure TYPE text USING secure::text;
ALTER TABLE pods_apiv1 ALTER COLUMN signup TYPE text USING signup::text;
ALTER TABLE pods_apiv1 ADD Hgitdate text, ADD Hgitref text, ADD Hruntime text, ADD Hencoding text, ADD longversion text, ADD ptr text, ADD whois text, ADD postalcode text, ADD connection text, ADD pingdomlast text;
ALTER TABLE pods_apiv1 DROP terms, DROP sslexpire, DROP dnssec, DROP masterversion, DROP shortversion, DROP publickey;
UPDATE pods_apiv1 SET hgitdate = 'unsupported';
......@@ -2,3 +2,7 @@ If new install import tables.sql
If upgrading migrations are:
migration00001.sql
To support the original apiv1 you should run:
pods_apiv1.sql
into your db daily at least.
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