Unverified Commit fa55c08f authored by dmorley's avatar dmorley

sql cleanup

parent ba0fb1dd
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,responsetimems,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,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['responsetimems'] . '<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 * FROM pods WHERE NOT hidden";
$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['responsetimems'],
$row['uptime_alltime'],
$row['dateupdated'],
$row['score']
);
$scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
$scheme = $row['secure'] ? '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,responsetimems,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,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,18 @@ EOF;
}
} else {
$i = 0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$sql = "SELECT domain,uptime_alltime,country FROM pods WHERE NOT hidden ORDER BY uptime_alltime DESC";
$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',
$row['domain'],
$row['uptimelast7'],
$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 * 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']) {
$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['responsetimems'],
$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['responsetimems'] . '</td>';
echo '<td>'; echo $row['signup'] ? 'Open' : 'Closed'; echo '</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>';
......
......@@ -29,7 +29,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 +38,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,7 +77,7 @@ if (stristr($output, 'nodeName')) {
$valid = true;
}
if ($valid) {
$sql = 'INSERT INTO pods (domain, pingdomurl, email) VALUES ($1, $2, $3)';
$sql = 'INSERT INTO pods (domain, statsurl, email) VALUES ($1, $2, $3)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email]);
$result || die('Error in SQL query: ' . pg_last_error());
......
<?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,14 @@ $_delete = $_GET['delete'] ?? '';
$_weight = $_GET['weight'] ?? '';
$_email = $_GET['email'] ?? '';
$_oldemail = $_GET['oldemail'] ?? '';
$_pingdomurl = $_GET['pingdomurl'] ?? '';
$_statsurl = $_GET['statsurl'] ?? '';
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 FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -38,8 +38,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 WHERE domain = $4';
$result = pg_query_params($dbh, $sql, [$_email, $_statsurl, $_weight, $_domain]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
......@@ -60,7 +60,7 @@ 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 '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">';
......
......@@ -46,11 +46,11 @@ $dbh || die('Error in connection: ' . pg_last_error());
//foreach pod check it and update db
if ($_domain) {
$sql = 'SELECT domain,pingdomurl,score,datecreated,weight FROM pods WHERE domain = $1';
$sql = 'SELECT domain,statsurl,score,datecreated,weight FROM pods WHERE domain = $1';
$sleep = '0';
$result = pg_query_params($dbh, $sql, [$_domain]);
} elseif (PHP_SAPI === 'cli') {
$sql = 'SELECT domain,pingdomurl,score,datecreated,adminrating,weight FROM pods';
$sql = 'SELECT domain,statsurl,score,datecreated,adminrating,weight FROM pods';
$sleep = '1';
$result = pg_query($dbh, $sql);
} else {
......@@ -254,15 +254,14 @@ while ($row = pg_fetch_all($result)) {
}
}
echo '<br>';
$connection = '';
$pingdomdate = date('Y-m-d H:i:s');
if (strpos($row[$i]['pingdomurl'], 'pingdom.com')) {
if (strpos($row[$i]['statsurl'], 'pingdom.com')) {
//curl the pingdom page
$ping = curl_init();
$thismonth = '/' . date('Y') . '/' . date('m');
curl_setopt($ping, CURLOPT_URL, $row[$i]['pingdomurl'] . $thismonth);
curl_setopt($ping, CURLOPT_URL, $row[$i]['statsurl'] . $thismonth);
if ($debug) {
echo $row[$i]['pingdomurl'] . $thismonth;
echo $row[$i]['statsurl'] . $thismonth;
}
curl_setopt($ping, CURLOPT_POST, 0);
curl_setopt($ping, CURLOPT_HEADER, 1);
......@@ -308,7 +307,7 @@ while ($row = pg_fetch_all($result)) {
} else {
//do uptimerobot API instead
$ping = curl_init();
curl_setopt($ping, CURLOPT_URL, 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=' . $row[$i]['pingdomurl']);
curl_setopt($ping, CURLOPT_URL, 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=' . $row[$i]['statsurl']);
curl_setopt($ping, CURLOPT_POST, 0);
curl_setopt($ping, CURLOPT_HEADER, 0);
curl_setopt($ping, CURLOPT_RETURNTRANSFER, 1);
......@@ -377,10 +376,10 @@ while ($row = pg_fetch_all($result)) {
$timenow = date('Y-m-d H:i:s');
$sql = 'UPDATE pods SET Hgitdate = $1, Hencoding = $2, secure = $3, hidden = $4, Hruntime = $5, Hgitref = $6, ip = $7, ipv6 = $8, monthsmonitored = $9,
uptimelast7 = $10, status = $11, dateLaststats = $12, dateUpdated = $13, responsetimelast7 = $14, score = $15, adminrating = $16, country = $17, city = $18,
state = $19, lat = $20, long = $21, postalcode=\'\', connection = $22, whois = $23, userrating = $24, longversion = $25, shortversion = $26,
uptime_alltime = $10, status = $11, dateLaststats = $12, dateUpdated = $13, responsetimems = $14, score = $15, adminrating = $16, country = $17, city = $18,
state = $19, lat = $20, long = $21, connection = $22, whois = $23, userrating = $24, longversion = $25, shortversion = $26,
masterversion = $27, signup = $28, total_users = $29, active_users_halfyear = $30, active_users_monthly = $31, local_posts = $32, name = $33,
comment_counts = $35, service_facebook = $36, service_tumblr = $37, service_twitter = $38, service_wordpress = $39, weightedscore = $40, xmpp = $41, softwarename = $42, sslvalid = $43
comment_counts = $35, service_facebook = $36, service_tumblr = $37, service_twitter = $38, service_wordpress = $39, weightedscore = $40, service_xmpp = $41, softwarename = $42, sslvalid = $43
WHERE domain = $34';
$result = pg_query_params($dbh, $sql, [$gitdate, $encoding, $secure, $hidden, $runtime, $gitrev, $ipnum, $ipv6, $months, $uptime, $live, $pingdomdate, $timenow, $responsetime, $score, $adminrating, $country, $city, $state, $lat, $long, $dver, $whois, $userrating, $xdver, $dver, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $domain, $comment_counts, $service_facebook, $service_tumblr, $service_twitter, $service_wordpress, $weightedscore, $service_xmpp, $softwarename, $outputsslerror]);
$result || die('Error in SQL query3: ' . pg_last_error());
......
......@@ -3,49 +3,51 @@ 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 'yes',
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,
responsetimems 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,
weight int DEFAULT 50,
dateUpdated timestamp DEFAULT current_timestamp,
dateLaststats timestamp DEFAULT current_timestamp,
dateCreated timestamp DEFAULT current_timestamp
......@@ -61,12 +63,4 @@ 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
);
......@@ -20,11 +20,11 @@ if ($_url) {
//Add click counter +1 for $row[0]['domain'] clicks in future, separate click table
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'] ? 'https://' : 'http://';
header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up');
}
......@@ -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()
})
});
......@@ -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 * FROM pods WHERE adminrating <> -1 AND 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']) {
$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 * FROM 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']) {
$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['responsetimems']}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>'; echo $row['ipv6'] ? 'Yes' : 'No'; echo '</td>';
echo '<td>' . $row['responsetimems'] . '</td>';
echo '<td>'; echo $row['signup'] ? 'Open' : 'Closed'; echo '</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 * 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'] ? 'https://' : 'http://';
$signup = $row['signup'] ? '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