From fa55c08fe3088878345b85493a570eda6d2f65e3 Mon Sep 17 00:00:00 2001 From: dmorley Date: Wed, 11 Jan 2017 19:24:23 -0500 Subject: [PATCH] sql cleanup --- api-more.php | 37 ++++++++++++++++++++++++++++++++++++- api.php | 17 +++++++---------- cleanup.php | 20 ++++++++++---------- db/add.php | 6 +++--- db/api-more.php | 38 -------------------------------------- db/edit.php | 10 +++++----- db/pull.php | 19 +++++++++---------- db/tables.sql | 38 ++++++++++++++++---------------------- go.php | 4 ++-- js/podup.js | 7 ++----- show.php | 12 +++++------- showfull.php | 20 ++++++++++---------- showmap.php | 13 ++++++++----- showstats.php | 4 ++-- 14 files changed, 115 insertions(+), 130 deletions(-) mode change 120000 => 100644 api-more.php delete mode 100644 db/api-more.php diff --git a/api-more.php b/api-more.php deleted file mode 120000 index a6b383f..0000000 --- a/api-more.php +++ /dev/null @@ -1 +0,0 @@ -db/api-more.php \ No newline at end of file diff --git a/api-more.php b/api-more.php new file mode 100644 index 0000000..cbade8f --- /dev/null +++ b/api-more.php @@ -0,0 +1,36 @@ +'; + echo 'Last Git Pull: ' . $row['hgitdate'] . '
'; + echo 'Uptime This Month ' . $row['uptime_alltime'] . '
'; + echo 'Months Monitored: ' . $row['monthsmonitored'] . '
'; + echo 'Response Time: ' . $row['responsetimems'] . '
'; + echo 'User Rating: ' . $row['userrating'] . '
'; + echo 'Server Location: ' . $row['country'] . '
'; + echo 'Latitude: ' . $row['lat'] . '
'; + echo 'Longitude: ' . $row['long'] . '
'; + } +} +pg_free_result($result); +pg_close($dbh); diff --git a/api.php b/api.php index 8a00058..4df25a9 100644 --- a/api.php +++ b/api.php @@ -21,7 +21,7 @@ if ($_format === 'georss') { 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 << {$scheme}{$row['domain']} @@ -54,7 +54,7 @@ EOF; } echo ''; } 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'] ); } diff --git a/cleanup.php b/cleanup.php index 4fdf2b4..080d6c8 100644 --- a/cleanup.php +++ b/cleanup.php @@ -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 '
' . $version . '
'; - echo '' . $row['uptimelast7'] . ''; - echo '' . $row['responsetimelast7'] . ''; - echo '' . ($row['signup'] === '1' ? 'Open' : 'Closed') . ''; + echo '' . $row['uptime_alltime'] . ''; + echo '' . $row['responsetimems'] . ''; + echo ''; echo $row['signup'] ? 'Open' : 'Closed'; echo ''; echo '' . $row['total_users'] . ''; echo '' . $row['active_users_halfyear'] . ''; echo '' . $row['active_users_monthly'] . ''; echo '' . $row['local_posts'] . ''; echo '' . $row['comment_counts'] . ''; - 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 ''; echo '' . $row['score'] . ''; diff --git a/db/add.php b/db/add.php index 2fe1253..b0c76db 100644 --- a/db/add.php +++ b/db/add.php @@ -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()); diff --git a/db/api-more.php b/db/api-more.php deleted file mode 100644 index 989b2de..0000000 --- a/db/api-more.php +++ /dev/null @@ -1,38 +0,0 @@ -'; - echo 'Last Git Pull: ' . $row['hgitdate'] . '
'; - echo 'Uptime This Month ' . $row['uptimelast7'] . '
'; - echo 'Months Monitored: ' . $row['monthsmonitored'] . '
'; - echo 'Response Time: ' . $row['responsetimelast7'] . '
'; - echo 'User Rating: ' . $row['userrating'] . '
'; - echo 'Server Country: ' . $row['country'] . '
'; - echo 'Server State: ' . $row['state'] . '
'; - echo 'Server City: ' . $row['city'] . '
'; - echo 'Latitude: ' . $row['lat'] . '
'; - echo 'Longitude: ' . $row['long'] . '
'; - } -} -pg_free_result($result); -pg_close($dbh); diff --git a/db/edit.php b/db/edit.php index 3943526..5cbefd3 100644 --- a/db/edit.php +++ b/db/edit.php @@ -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 ''; echo ''; echo ''; - echo 'Stats Key Uptimerobot API key for this monitor
'; + echo 'Stats Key Uptimerobot API key for this monitor
'; echo 'Email
'; echo '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.
'; echo ''; diff --git a/db/pull.php b/db/pull.php index 9c1a558..938b1b9 100644 --- a/db/pull.php +++ b/db/pull.php @@ -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 '
'; - $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()); diff --git a/db/tables.sql b/db/tables.sql index 474c9f6..c61ff45 100644 --- a/db/tables.sql +++ b/db/tables.sql @@ -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 -); + diff --git a/go.php b/go.php index 4e93b64..e67231b 100644 --- a/go.php +++ b/go.php @@ -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'); } diff --git a/js/podup.js b/js/podup.js index b170b59..b98b3cb 100644 --- a/js/podup.js +++ b/js/podup.js @@ -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() -}) +}); diff --git a/show.php b/show.php index e69e301..ec41509 100644 --- a/show.php +++ b/show.php @@ -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);
' . $row['domain'] . '
'; - echo '' . $row['uptimelast7'] . '%'; + echo '' . $row['uptime_alltime'] . '%'; echo '' . $row['active_users_halfyear'] . ''; if ($country_code === $row['country']) { echo '' . $row['country'] . ''; @@ -65,7 +63,7 @@ $numrows = pg_num_rows($result); $row['service_twitter'] === 't' && print ''; $row['service_tumblr'] === 't' && print ''; $row['service_wordpress'] === 't' && print ''; - $row['xmpp'] === 't' && print ''; + $row['service_xmpp'] === 't' && print ''; echo ''; } pg_free_result($result); diff --git a/showfull.php b/showfull.php index 12dbc2f..3f23efd 100644 --- a/showfull.php +++ b/showfull.php @@ -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); ' . $row['domain'] . ''; @@ -75,17 +75,17 @@ $numrows = pg_num_rows($result); $classver = 'black'; } echo '
' . $version . '
'; - echo '' . $row['uptimelast7'] . '%'; - echo '' . $row['ipv6'] . ''; - echo '' . $row['responsetimelast7'] . ''; - echo '' . ($row['signup'] === '1' ? 'Open' : 'Closed') . ''; + echo '' . $row['uptime_alltime'] . '%'; + echo ''; echo $row['ipv6'] ? 'Yes' : 'No'; echo ''; + echo '' . $row['responsetimems'] . ''; + echo ''; echo $row['signup'] ? 'Open' : 'Closed'; echo ''; echo '' . $row['total_users'] . ''; echo '' . $row['active_users_halfyear'] . ''; echo '' . $row['active_users_monthly'] . ''; echo '' . $row['local_posts'] . ''; echo '' . $row['comment_counts'] . ''; - 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 ''; $row['service_tumblr'] === 't' && print ''; $row['service_wordpress'] === 't' && print ''; - $row['xmpp'] === 't' && print ''; + $row['service_xmpp'] === 't' && print ''; echo ''; } pg_free_result($result); diff --git a/showmap.php b/showmap.php index 64184e3..7154908 100644 --- a/showmap.php +++ b/showmap.php @@ -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 .= ''; $row['service_tumblr'] === 't' && $feat .= ''; $row['service_wordpress'] === 't' && $feat .= ''; - $row['xmpp'] === 't' && $feat .= ''; + $row['service_xmpp'] === 't' && $feat .= ''; $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 <<Visit
Open Signup: {$signup}
Users: {$row['active_users_halfyear']}
Uptime: {$row['uptimelast7']}%
Services:{$feat}' + 'html': '{$pod_name}
Visit
Open Signup: {$signup}
Users: {$row['active_users_halfyear']}
Uptime: {$row['uptime_alltime']}%
Services:{$feat}' }, 'geometry': { 'type': 'Point', diff --git a/showstats.php b/showstats.php index c0eab17..5f2fce2 100644 --- a/showstats.php +++ b/showstats.php @@ -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); -- GitLab