Commit 26ea33f5 authored by noplanman's avatar noplanman Committed by GitHub

Merge pull request #66 from diasporg/fixsql

Fixsql
parents ba0fb1dd 6557bd37
db/api-more.php
\ No newline at end of file
<?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
//this is just a single api for a pod for the android app to get data
// Required parameters.
($_domain = $_GET['domain'] ?? null) || die('no domain given');
// Other parameters.
$_format = $_GET['format'] ?? '';
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,statsurl,monthsmonitored,uptime_alltime,responsetime,local_posts,comment_counts,date_created,date_updated,date_laststats,hidden FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($_format === 'json') {
echo json_encode($row);
} else {
echo 'Status: ' . $row['status'] . '<br>';
echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $row['uptime_alltime'] . '<br>';
echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>';
echo 'Response Time: ' . $row['responsetime'] . '<br>';
echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Location: ' . $row['country'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>';
echo 'Longitude: ' . $row['long'] . '<br>';
}
}
pg_free_result($result);
pg_close($dbh);
......@@ -21,7 +21,7 @@ if ($_format === 'georss') {
<link href="https://{$_SERVER['HTTP_HOST']}/"/>
EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$sql = "SELECT name,monthsmonitored,responsetime,uptime_alltime,dateupdated,score,secure,domain,country,lat,long FROM pods";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -32,12 +32,12 @@ 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['responsetimelast7'],
$row['uptimelast7'],
$row['responsetime'],
$row['uptime_alltime'],
$row['dateupdated'],
$row['score']
);
$scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
$scheme = $row['secure'] === 't' ? 'https://' : 'http://';
echo <<<EOF
<entry>
<title>{$scheme}{$row['domain']}</title>
......@@ -54,7 +54,7 @@ EOF;
}
echo '</feed>';
} elseif ($_format === 'json') {
$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';
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,statsurl,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';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -74,21 +74,19 @@ EOF;
}
} else {
$i = 0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$sql = "SELECT domain,uptime_alltime,country,status FROM pods";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
// $status = $row['status'] === 'up' ? 'Online' : 'Offline';
// $scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
// $class = $row['secure'] === 'true' ? 'green' : 'red';
$i++ > 0 && print ',';
printf(
'%1$s Up %2$s%% This Month - Located in: %3$s',
'%1$s is %2$s now - online %3$s%% This Month - Located in: %4$s',
$row['domain'],
$row['uptimelast7'],
$row['status'],
$row['uptime_alltime'],
$row['country']
);
}
......
......@@ -4,7 +4,7 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore";
$sql = "SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,secure,name,country,city,state,lat,long,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp,responsetime,dateupdated,ipv6,total_users,local_posts,comment_counts,statsurl,userrating,sslvalid FROM pods WHERE score < 50 ORDER BY weightedscore";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -39,7 +39,7 @@ $numrows = pg_num_rows($result);
$tt = 0;
while ($row = pg_fetch_array($result)) {
$tt++;
if ($row['secure'] === 'true') {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
......@@ -55,8 +55,8 @@ $numrows = pg_num_rows($result);
"\n" . '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 -20 to +20 this pod is a %6$s right now',
$pod_name,
$row['monthsmonitored'],
$row['responsetimelast7'],
$row['uptimelast7'],
$row['responsetime'],
$row['uptime_alltime'],
$row['dateupdated'],
$row['score']
);
......@@ -81,18 +81,18 @@ $numrows = pg_num_rows($result);
$classver = 'black';
}
echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
echo '<td>' . $row['uptimelast7'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>';
echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['uptime_alltime'] . '</td>';
echo '<td>' . $row['responsetime'] . '</td>';
echo '<td>' . ($row['signup'] === 't' ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['pingdomurl'], 'pingdom.com')) {
$moreurl = $row['pingdomurl'];
if (strpos($row['statsurl'], 'pingdom.com')) {
$moreurl = $row['statsurl'];
} else {
$moreurl = 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl'];
$moreurl = 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['statsurl'];
}
echo '<td><div title="Last Check ' . $row['dateupdated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>';
echo '<td>' . $row['score'] . '</td>';
......
......@@ -16,6 +16,10 @@ if (!($_email = $_POST['email'] ?? null)) {
$log->lwrite('no email given ' . $_domain);
die('no email given');
}
if (!($_terms = $_POST['terms'] ?? null)) {
$log->lwrite('terms link required ' . $_domain);
die('no terms link');
}
if (!$_url) {
$log->lwrite('no api given ' . $_domain);
die('no API key for your stats');
......@@ -29,7 +33,7 @@ if (strlen($_url) < 14) {
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain, pingdomurl FROM pods';
$sql = 'SELECT domain, statsurl FROM pods';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -38,7 +42,7 @@ while ($row = pg_fetch_array($result)) {
$log->lwrite('domain already exists ' . $_domain);
die('domain already exists');
}
if ($row['pingdomurl'] === $_url) {
if ($row['statsurl'] === $_url) {
$log->lwrite('API key already exists ' . $_domain);
die('API key already exists');
}
......@@ -77,8 +81,8 @@ if (stristr($output, 'nodeName')) {
$valid = true;
}
if ($valid) {
$sql = 'INSERT INTO pods (domain, pingdomurl, email) VALUES ($1, $2, $3)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email]);
$sql = 'INSERT INTO pods (domain, statsurl, email, terms) VALUES ($1, $2, $3, $4)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email, $_terms]);
$result || die('Error in SQL query: ' . pg_last_error());
$to = $adminemail;
......
<?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
//this is just a single api for a pod for the android app to get data
// Required parameters.
($_url = $_GET['url'] ?? null) || die('no url given');
// Other parameters.
$_format = $_GET['format'] ?? '';
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,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_url]);
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($_format === 'json') {
echo json_encode($row);
} else {
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>';
echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Country: ' . $row['country'] . '<br>';
echo 'Server State: ' . $row['state'] . '<br>';
echo 'Server City: ' . $row['city'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>';
echo 'Longitude: ' . $row['long'] . '<br>';
}
}
pg_free_result($result);
pg_close($dbh);
......@@ -10,14 +10,15 @@ $_delete = $_GET['delete'] ?? '';
$_weight = $_GET['weight'] ?? '';
$_email = $_GET['email'] ?? '';
$_oldemail = $_GET['oldemail'] ?? '';
$_pingdomurl = $_GET['pingdomurl'] ?? '';
$_statsurl = $_GET['statsurl'] ?? '';
$_terms = $_GET['terms'] ?? '';
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain,email,token,tokenexpire,pingdomurl,weight FROM pods WHERE domain = $1';
$sql = 'SELECT domain,email,token,tokenexpire,statsurl,weight,terms FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -38,8 +39,8 @@ while ($row = pg_fetch_array($result)) {
if ($_save === $row['token']) {
$_weight <= 10 || die('10 is max weight');
$sql = 'UPDATE pods SET email = $1, pingdomurl = $2, weight = $3 WHERE domain = $4';
$result = pg_query_params($dbh, $sql, [$_email, $_pingdomurl, $_weight, $_domain]);
$sql = 'UPDATE pods SET email = $1, statsurl = $2, weight = $3, terms = $4 WHERE domain = $5';
$result = pg_query_params($dbh, $sql, [$_email, $_statsurl, $_weight, $_terms, $_domain]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
......@@ -60,8 +61,9 @@ while ($row = pg_fetch_array($result)) {
echo '<input type="hidden" name="save" value="' . $_token . '">';
echo '<input type="hidden" name="token" value="' . $_token . '">';
echo '<input type="hidden" name="domain" value="' . $_domain . '">';
echo 'Stats Key <input type="text" size="50" name="pingdomurl" value="' . $row['pingdomurl'] . '"">Uptimerobot API key for this monitor<br>';
echo 'Stats Key <input type="text" size="50" name="statsurl" value="' . $row['statsurl'] . '"">Uptimerobot API key for this monitor<br>';
echo 'Email <input type="text" size="20" name="email" value="' . $row['email'] . '"><br>';
echo 'Terms Link <input type="text" size="20" name="terms" value="' . $row['terms'] . '"><br>';
echo 'Weight <input type="text" size="2" name="weight" value="' . $row['weight'] . '"> This lets you weight your pod lower on the list if you have too much trafic coming in, 10 is the norm use lower to move down the list.<br>';
echo '<input type="submit" name="submit">';
echo '</form><br><br><br>';
......
<?php
$systemTimeZone = system('date +%Z');
$systemTimeZone = exec('date +%Z');
// Required parameters.
($_domain = $_POST['domain'] ?? null) || die('no pod domain given');
......
ALTER TABLE pods ADD terms text, ADD sslexpire timestamp, ADD uptime_custom text, ADD dnssec boolean, ADD masterversion text, ADD shortversion text;
ALTER TABLE pods DROP Hgitdate, DROP Hgitref, DROP Hruntime, DROP Hencoding, DROP longversion, DROP ptr, DROP whois, DROP postalcode, DROP connection, DROP pingdomlast;
ALTER TABLE pods RENAME COLUMN pingdomurl TO statsurl;
ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp;
ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime;
ALTER TABLE pods RENAME COLUMN responsetimelast7 TO responsetime;
ALTER TABLE pods RENAME COLUMN dateUpdated TO date_updated;
ALTER TABLE pods RENAME COLUMN dateLaststats TO date_laststats;
ALTER TABLE pods RENAME COLUMN dateCreated TO date_created;
ALTER TABLE pods ALTER COLUMN ipv6 TYPE boolean USING ipv6::boolean;
ALTER TABLE pods ALTER hidden DROP DEFAULT;
ALTER TABLE pods ALTER COLUMN hidden TYPE boolean USING hidden::boolean;
ALTER TABLE pods ALTER COLUMN secure TYPE boolean USING secure::boolean;
ALTER TABLE pods ALTER COLUMN signup TYPE boolean USING signup::boolean;
DROP TABLE users;
CREATE TABLE apikeys (
key text,
email text,
usage int,
date_created timestamp DEFAULT current_timestamp
);
CREATE TABLE clicks (
domain text,
manualclick int,
autoclick int,
date_clicked timestamp DEFAULT current_timestamp
);
CREATE TABLE checks (
domain text,
online boolean,
error text,
date_checked timestamp DEFAULT current_timestamp
);
This diff is collapsed.
......@@ -3,52 +3,49 @@ CREATE TABLE pods (
domain text UNIQUE NOT NULL,
name text,
softwarename text,
masterversion text,
shortversion text,
score int DEFAULT 10,
weightedscore numeric(5,2) DEFAULT 10,
adminrating decimal DEFAULT 10,
userrating decimal DEFAULT 10,
whois text,
hidden text DEFAULT 'yes',
hidden boolean DEFAULT true,
ip text,
ptr text,
country text,
city text,
state text,
lat text,
long text,
connection text,
postalcode text,
email text,
ipv6 text,
secure text,
ipv6 boolean,
secure boolean,
sslvalid text,
Hgitdate text,
Hgitref text,
Hruntime text,
Hencoding text,
pingdomurl text,
pingdomlast text,
statsurl text,
monthsmonitored int,
signup int,
signup boolean,
total_users int,
active_users_halfyear int,
active_users_monthly int,
local_posts int,
uptimelast7 numeric(5,2),
uptime_alltime numeric(5,2),
uptime_custom text,
status text,
responsetimelast7 text,
responsetime text,
service_facebook boolean,
service_twitter boolean,
service_tumblr boolean,
service_wordpress boolean,
service_xmpp boolean,
token text,
tokenexpire timestamp,
terms text,
sslexpire timestamp,
dnssec boolean,
comment_counts int,
weight int DEFAULT 10,
xmpp boolean,
dateUpdated timestamp DEFAULT current_timestamp,
dateLaststats timestamp DEFAULT current_timestamp,
dateCreated timestamp DEFAULT current_timestamp
weight int DEFAULT 50,
date_updated timestamp DEFAULT current_timestamp,
date_laststats timestamp DEFAULT current_timestamp,
date_created timestamp DEFAULT current_timestamp
);
CREATE TABLE rating_comments (
id serial8 UNIQUE PRIMARY KEY,
......@@ -61,12 +58,24 @@ CREATE TABLE rating_comments (
userurl text,
date timestamp DEFAULT current_timestamp
);
CREATE TABLE users (
id serial8 UNIQUE PRIMARY KEY,
admin int NOT NULL,
username text UNIQUE NOT NULL,
password text NOT NULL,
userurl text,
userpod text,
dateCreated timestamp DEFAULT current_timestamp
CREATE TABLE apikeys (
key text,
email text,
usage int,
date_created timestamp DEFAULT current_timestamp
);
CREATE TABLE clicks (
domain text,
manualclick int,
autoclick int,
date_clicked timestamp DEFAULT current_timestamp
);
CREATE TABLE checks (
domain text,
online boolean,
error text,
date_checked timestamp DEFAULT current_timestamp
);
If new install import tables.sql
If upgrading migrations are:
migration00001.sql
......@@ -17,14 +17,24 @@ if ($_url) {
$row = pg_fetch_all($result);
$row || die('unknown url');
//Add click counter +1 for $row[0]['domain'] clicks in future, separate click table
$sql = 'INSERT INTO clicks (domain, manualclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$host, '1']);
$result || die('Error in SQL query: ' . pg_last_error());
header('Location:' . $_url);
} else {
$sql = 'SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1';
$sql = 'SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup ORDER BY RANDOM() LIMIT 1';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
$row = pg_fetch_all($result);
$scheme = $row[0]['secure'] === 'true' ? 'https://' : 'http://';
$scheme = $row[0]['secure'] === 't' ? 'https://' : 'http://';
$sql = 'INSERT INTO clicks (domain, autoclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$row[0]['domain'], '1']);
$result || die('Error in SQL query: ' . pg_last_error());
header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up');
}
pg_free_result($result);
pg_close($dbh);
......@@ -2,10 +2,7 @@ $(document).ready(function(){
$.facebox.settings.closeImage = 'bower_components/facebox/src/closelabel.png'
$.facebox.settings.loadingImage = 'bower_components/facebox/src/loading.gif'
$('a[rel*=facebox]').facebox()
$('#myTable').tablesorter();
});
$(function () {
$('#myTable').tablesorter()
$('[data-toggle="tooltip"]').tooltip()
})
});
......@@ -6,6 +6,7 @@ Create a monitor for your pod, then in "My Settings" create a monitor-specific A
<form action="https://<?php echo $_SERVER['HTTP_HOST'] ?>/db/add.php" method="post">
<label>Monitor API Key: <input type="text" name="url" class="xlarge span8" placeholder="m58978-80abdb799f6ccf15e3e4ttwe"> (don't copy the period on the end)</label><br>
<label>Pod Domain Name: <input type="text" name="domain" class="xlarge span4" placeholder="domain.com"></label><br>
<label>Pod Terms Link: <input type="text" name="terms" class="xlarge span4" value="/terms" placeholder="/terms"></label><br>
<label>Your Email: <input type="text" name="email" class="xlarge span4" placeholder="user@domain.com"></label><br>
<input type="submit" value="submit">
</form>
......@@ -56,7 +56,7 @@
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT * FROM rating_comments WHERE domain = $1';
$sql = 'SELECT admin,username,userurl,rating,comment,date,id FROM rating_comments WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
......
......@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY uptimelast7 DESC";
$sql = "SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,secure,name,country,city,state,lat,long,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp FROM pods WHERE NOT hidden AND signup ORDER BY uptime_alltime DESC";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -32,14 +32,12 @@ $numrows = pg_num_rows($result);
<?php
while ($row = pg_fetch_array($result)) {
if ($row['secure'] === 'true') {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'text-success';
//$tip="This pod uses SSL encryption for traffic.";
} else {
$scheme = 'http://';
$class = 'red';
//$tip="This pod does not offer SSL";
}
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES);
......@@ -48,12 +46,12 @@ $numrows = pg_num_rows($result);
$row['softwarename'],
$pod_name,
$row['monthsmonitored'],
$row['uptimelast7'],
$row['uptime_alltime'],
$row['score']
);
echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="' . $class . ' url" target="_self" href="/go.php?url=' . $scheme . $row['domain'] . '">' . $row['domain'] . '</a></div></td>';
echo '<td>' . $row['uptimelast7'] . '%</td>';
echo '<td>' . $row['uptime_alltime'] . '%</td>';
echo '<td data-toggle="tooltip" data-placement="bottom" title="active six months: ' . $row['active_users_halfyear'] . ', active one month: ' . $row['active_users_monthly'] . '">' . $row['active_users_halfyear'] . '</td>';
if ($country_code === $row['country']) {
echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="City: '. ($row['city'] ?? 'n/a') . ' State: ' . ($row['state'] ?? 'n/a') . '"><b>' . $row['country'] . '</b></td>';
......@@ -65,7 +63,7 @@ $numrows = pg_num_rows($result);
$row['service_twitter'] === 't' && print '<div class="smlogo smlogo-twitter" title="Publish to Twitter" alt="Publish to Twitter"></div>';
$row['service_tumblr'] === 't' && print '<div class="smlogo smlogo-tumblr" title="Publish to Tumblr" alt="Publish to Tumblr"></div>';
$row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress" title="Publish to Wordpress" alt="Publish to Wordpress"></div>';
$row['xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
$row['service_xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
echo '</td></tr>';
}
pg_free_result($result);
......
......@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC';
$sql = 'SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,secure,name,country,city,state,lat,long,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp,responsetime,date_updated,ipv6,total_users,local_posts,comment_counts,statsurl,userrating FROM pods pods ORDER BY uptime_alltime DESC';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -42,7 +42,7 @@ $numrows = pg_num_rows($result);
<tbody>
<?php
while ($row = pg_fetch_array($result)) {
if ($row['secure'] === 'true') {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
......@@ -52,7 +52,7 @@ $numrows = pg_num_rows($result);
$tip = 'This pod does not offer SSL';
}
$pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip .= "\n This {$row['softwarename']} pod {$pod_name} has been watched for {$row['monthsmonitored']} months with an overall uptime of {$row['uptimelast7']}% and a response time average today of {$row['responsetimelast7']}ms was last checked on {$row['dateupdated']}. ";
$tip .= "\n This {$row['softwarename']} pod {$pod_name} has been watched for {$row['monthsmonitored']} months with an overall uptime of {$row['uptime_alltime']}% and a response time average today of {$row['responsetime']}ms was last checked on {$row['dateupdated']}. ";
$tip .= "On a scale of 100 this pod is a {$row['score']} right now";
echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" class="' . $class . '" target="_self" href="/go.php?url=' . $scheme . $row['domain'] . '">' . $row['domain'] . '</a></td>';
......@@ -75,17 +75,17 @@ $numrows = pg_num_rows($result);
$classver = 'black';
}
echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>';
echo '<td>' . $row['uptimelast7'] . '%</td>';
echo '<td>' . $row['ipv6'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>';
echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['uptime_alltime'] . '%</td>';
echo '<td>' . ($row['ipv6'] === 't' ? 'Yes' : 'No') . '</td>';
echo '<td>' . $row['responsetime'] . '</td>';
echo '<td>' . ($row['signup'] === 't' ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['pingdomurl'], 'pingdom.com')) {
$moreurl = $row['pingdomurl'];
if (strpos($row['statsurl'], 'pingdom.com')) {
$moreurl = $row['statsurl'];
} else {
$moreurl = '/showstats.php?domain=' . $row['domain'];
}
......@@ -106,7 +106,7 @@ $numrows = pg_num_rows($result);
$row['service_twitter'] === 't' && print '<div class="smlogo smlogo-twitter"></div>';
$row['service_tumblr'] === 't' && print '<div class="smlogo smlogo-tumblr"></div>';
$row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></div>';
$row['xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
$row['service_xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
echo '</td></tr>';
}
pg_free_result($result);
......
......@@ -8,6 +8,9 @@ foreach ($csv as $cords) {
if ($cords[0] === $country_code) {
$lat = $cords[1];
$long = $cords[2];
} else {
$lat = 31;
$long = -99;
}
}
?>
......@@ -26,7 +29,7 @@ foreach ($csv as $cords) {
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$sql = "SELECT domain,signup,secure,name,lat,long,uptime_alltime,active_users_halfyear,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp FROM pods WHERE NOT hidden";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -41,17 +44,17 @@ foreach ($csv as $cords) {
$row['service_twitter'] === 't' && $feat .= '<div class="smlogo smlogo-twitter"></div>';
$row['service_tumblr'] === 't' && $feat .= '<div class="smlogo smlogo-tumblr"></div>';
$row['service_wordpress'] === 't' && $feat .= '<div class="smlogo smlogo-wordpress"></div>';
$row['xmpp'] === 't' && $feat .= '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
$row['service_xmpp'] === 't' && $feat .= '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
$pod_name = htmlentities($row['name'], ENT_QUOTES);
$scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
$signup = $row['signup'] === '1' ? 'yes' : 'no';
$scheme = $row['secure'] === 't' ? 'https://' : 'http://';
$signup = $row['signup'] === 't' ? 'yes' : 'no';
echo <<<EOF
{
'type': 'Feature',
'id': '1',
'properties' : {
'html': '{$pod_name}<br><a href="/go.php?url={$scheme}{$row['domain']}">Visit</a><br> Open Signup: {$signup}<br> Users: {$row['active_users_halfyear']}<br> Uptime: {$row['uptimelast7']}%<br> Services:{$feat}'
'html': '{$pod_name}<br><a href="/go.php?url={$scheme}{$row['domain']}">Visit</a><br> Open Signup: {$signup}<br> Users: {$row['active_users_halfyear']}<br> Uptime: {$row['uptime_alltime']}%<br> Services:{$feat}'
},
'geometry': {
'type': 'Point',
......
......@@ -10,13 +10,13 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT pingdomurl FROM pods WHERE domain = $1';
$sql = 'SELECT statsurl FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
$apikey = pg_fetch_all($result);
$upti = curl_init();
$key = $apikey[0]['pingdomurl'];
$key = $apikey[0]['statsurl'];
$data = ['all_time_uptime_ratio' => 1, 'format' => 'json', 'custom_uptime_ratios' => '7-30-60-90', 'response_times' => 1, 'response_times_average' => 86400, 'api_key' => $key, 'callback' => 'jsonpUptimeRobot'];
curl_setopt($upti, CURLOPT_URL, 'https://api.uptimerobot.com/v2/getMonitors');
curl_setopt($upti, CURLOPT_HEADER, 0);
......
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