Unverified Commit 07a6e946 authored by dmorley's avatar dmorley
Browse files

remove http and pingdom

parent aa8a179e
...@@ -13,7 +13,7 @@ require_once __DIR__ . '/config.php'; ...@@ -13,7 +13,7 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $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'; $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';
$result = pg_query_params($dbh, $sql, [$_domain]); $result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
......
...@@ -21,7 +21,7 @@ if ($_format === 'georss') { ...@@ -21,7 +21,7 @@ if ($_format === 'georss') {
<link href="https://{$_SERVER['HTTP_HOST']}/"/> <link href="https://{$_SERVER['HTTP_HOST']}/"/>
EOF; EOF;
$sql = "SELECT name,monthsmonitored,responsetime,uptime_alltime,dateupdated,score,secure,domain,country,lat,long FROM pods"; $sql = "SELECT name,monthsmonitored,responsetime,uptime_alltime,dateupdated,score,domain,country,lat,long FROM pods";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -37,10 +37,9 @@ EOF; ...@@ -37,10 +37,9 @@ EOF;
$row['dateupdated'], $row['dateupdated'],
$row['score'] $row['score']
); );
$scheme = $row['secure'] === 't' ? 'https://' : 'http://';
echo <<<EOF echo <<<EOF
<entry> <entry>
<title>{$scheme}{$row['domain']}</title> <title>https://{$row['domain']}</title>
<link href="{$scheme}{$row['domain']}"/> <link href="{$scheme}{$row['domain']}"/>
<id>urn:{$row['domain']}</id> <id>urn:{$row['domain']}</id>
<summary>Pod Location is: {$row['country']} <summary>Pod Location is: {$row['country']}
...@@ -54,7 +53,7 @@ EOF; ...@@ -54,7 +53,7 @@ EOF;
} }
echo '</feed>'; echo '</feed>';
} elseif ($_format === 'json') { } elseif ($_format === 'json') {
$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'; $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,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 = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
......
...@@ -4,7 +4,7 @@ require_once __DIR__ . '/config.php'; ...@@ -4,7 +4,7 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$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"; $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,stats_apikey,userrating,sslvalid FROM pods WHERE score < 50 ORDER BY weightedscore";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -39,19 +39,10 @@ $numrows = pg_num_rows($result); ...@@ -39,19 +39,10 @@ $numrows = pg_num_rows($result);
$tt = 0; $tt = 0;
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$tt++; $tt++;
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'green';
$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']); $verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip .= sprintf( $tip = sprintf(
"\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', "\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, $pod_name,
$row['monthsmonitored'], $row['monthsmonitored'],
...@@ -61,7 +52,7 @@ $numrows = pg_num_rows($result); ...@@ -61,7 +52,7 @@ $numrows = pg_num_rows($result);
$row['score'] $row['score']
); );
echo '<tr><td><a class="' . $class . '" target="_self" href="' . $scheme . $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>'; echo '<tr><td><a class="green" target="_self" href="https://' $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>';
if (stristr($row['shortversion'], 'head')) { if (stristr($row['shortversion'], 'head')) {
$version = '.dev'; $version = '.dev';
...@@ -89,10 +80,10 @@ $numrows = pg_num_rows($result); ...@@ -89,10 +80,10 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>'; echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>'; echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['statsurl'], 'pingdom.com')) { if (strpos($row['stats_apikey'], 'pingdom.com')) {
$moreurl = $row['statsurl']; $moreurl = $row['stats_apikey'];
} else { } else {
$moreurl = 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['statsurl']; $moreurl = 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['stats_apikey'];
} }
echo '<td><div title="Last Check ' . $row['dateupdated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>'; 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>'; echo '<td>' . $row['score'] . '</td>';
......
...@@ -33,7 +33,7 @@ if (strlen($_url) < 14) { ...@@ -33,7 +33,7 @@ if (strlen($_url) < 14) {
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain, statsurl FROM pods'; $sql = 'SELECT domain, stats_apikey FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -42,7 +42,7 @@ while ($row = pg_fetch_array($result)) { ...@@ -42,7 +42,7 @@ while ($row = pg_fetch_array($result)) {
$log->lwrite('domain already exists ' . $_domain); $log->lwrite('domain already exists ' . $_domain);
die('domain already exists'); die('domain already exists');
} }
if ($row['statsurl'] === $_url) { if ($row['stats_apikey'] === $_url) {
$log->lwrite('API key already exists ' . $_domain); $log->lwrite('API key already exists ' . $_domain);
die('API key already exists'); die('API key already exists');
} }
...@@ -59,29 +59,14 @@ curl_setopt($chss, CURLOPT_NOBODY, 0); ...@@ -59,29 +59,14 @@ curl_setopt($chss, CURLOPT_NOBODY, 0);
$outputssl = curl_exec($chss); $outputssl = curl_exec($chss);
curl_close($chss); curl_close($chss);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $_domain . '/nodeinfo/1.0');
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch);
curl_close($ch);
$valid = false; $valid = false;
if (stristr($outputssl, 'nodeName')) { if (stristr($outputssl, 'nodeName')) {
$log->lwrite('Your pod has ssl and is valid ' . $_domain); $log->lwrite('Your pod has ssl and is valid ' . $_domain);
echo 'Your pod has ssl and is valid<br>'; echo 'Your pod has ssl and is valid<br>';
$valid = true; $valid = true;
} }
if (stristr($output, 'nodeName')) {
$log->lwrite('Your pod does not have ssl but is a valid pod ' . $_domain);
echo 'Your pod does not have ssl but is a valid pod<br>';
$valid = true;
}
if ($valid) { if ($valid) {
$sql = 'INSERT INTO pods (domain, statsurl, email, terms) VALUES ($1, $2, $3, $4)'; $sql = 'INSERT INTO pods (domain, stats_apikey, email, terms) VALUES ($1, $2, $3, $4)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email, $_terms]); $result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email, $_terms]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -104,7 +89,7 @@ if ($valid) { ...@@ -104,7 +89,7 @@ if ($valid) {
pg_close($dbh); pg_close($dbh);
} else { } else {
$log->lwrite('Could not validate your pod on http or https, check your setup! ' . $_domain); $log->lwrite('Could not validate your pod, check your setup! ' . $_domain);
echo 'Could not validate your pod on http or https, check your setup!<br>Take a look at <a href="https://' . $_domain . '/nodeinfo/1.0">your /nodeinfo</a>'; echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="https://' . $_domain . '/nodeinfo/1.0">your /nodeinfo</a>';
} }
$log->lclose(); $log->lclose();
...@@ -10,7 +10,7 @@ $_delete = $_GET['delete'] ?? ''; ...@@ -10,7 +10,7 @@ $_delete = $_GET['delete'] ?? '';
$_weight = $_GET['weight'] ?? ''; $_weight = $_GET['weight'] ?? '';
$_email = $_GET['email'] ?? ''; $_email = $_GET['email'] ?? '';
$_oldemail = $_GET['oldemail'] ?? ''; $_oldemail = $_GET['oldemail'] ?? '';
$_statsurl = $_GET['statsurl'] ?? ''; $_stats_apikey = $_GET['stats_apikey'] ?? '';
$_terms = $_GET['terms'] ?? ''; $_terms = $_GET['terms'] ?? '';
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
...@@ -18,7 +18,7 @@ require_once __DIR__ . '/../config.php'; ...@@ -18,7 +18,7 @@ require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain,email,token,tokenexpire,statsurl,weight,terms FROM pods WHERE domain = $1'; $sql = 'SELECT domain,email,token,tokenexpire,stats_apikey,weight,terms FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]); $result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -39,8 +39,8 @@ while ($row = pg_fetch_array($result)) { ...@@ -39,8 +39,8 @@ while ($row = pg_fetch_array($result)) {
if ($_save === $row['token']) { if ($_save === $row['token']) {
$_weight <= 10 || die('10 is max weight'); $_weight <= 10 || die('10 is max weight');
$sql = 'UPDATE pods SET email = $1, statsurl = $2, weight = $3, terms = $4 WHERE domain = $5'; $sql = 'UPDATE pods SET email = $1, stats_apikey = $2, weight = $3, terms = $4 WHERE domain = $5';
$result = pg_query_params($dbh, $sql, [$_email, $_statsurl, $_weight, $_terms, $_domain]); $result = pg_query_params($dbh, $sql, [$_email, $_stats_apikey, $_weight, $_terms, $_domain]);
if (!$result) { if (!$result) {
die('Error in SQL query: ' . pg_last_error()); die('Error in SQL query: ' . pg_last_error());
} }
...@@ -61,7 +61,7 @@ while ($row = pg_fetch_array($result)) { ...@@ -61,7 +61,7 @@ while ($row = pg_fetch_array($result)) {
echo '<input type="hidden" name="save" value="' . $_token . '">'; echo '<input type="hidden" name="save" value="' . $_token . '">';
echo '<input type="hidden" name="token" value="' . $_token . '">'; echo '<input type="hidden" name="token" value="' . $_token . '">';
echo '<input type="hidden" name="domain" value="' . $_domain . '">'; echo '<input type="hidden" name="domain" value="' . $_domain . '">';
echo 'Stats Key <input type="text" size="50" name="statsurl" value="' . $row['statsurl'] . '"">Uptimerobot API key for this monitor<br>'; echo 'Stats Key <input type="text" size="50" name="stats_apikey" value="' . $row['stats_apikey'] . '"">Uptimerobot API key for this monitor<br>';
echo 'Email <input type="text" size="20" name="email" value="' . $row['email'] . '"><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 '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 '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>';
......
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 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 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 pingdomurl TO stats_apikey;
ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp; ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp;
ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime; ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime;
ALTER TABLE pods RENAME COLUMN responsetimelast7 TO responsetime; ALTER TABLE pods RENAME COLUMN responsetimelast7 TO responsetime;
......
...@@ -46,11 +46,11 @@ $dbh || die('Error in connection: ' . pg_last_error()); ...@@ -46,11 +46,11 @@ $dbh || die('Error in connection: ' . pg_last_error());
//foreach pod check it and update db //foreach pod check it and update db
if ($_domain) { if ($_domain) {
$sql = 'SELECT domain,statsurl,score,date_created,weight FROM pods WHERE domain = $1'; $sql = 'SELECT domain,stats_apikey,score,date_created,weight FROM pods WHERE domain = $1';
$sleep = '0'; $sleep = '0';
$result = pg_query_params($dbh, $sql, [$_domain]); $result = pg_query_params($dbh, $sql, [$_domain]);
} elseif (PHP_SAPI === 'cli') { } elseif (PHP_SAPI === 'cli') {
$sql = 'SELECT domain,statsurl,score,date_created,adminrating,weight FROM pods'; $sql = 'SELECT domain,stats_apikey,score,date_created,adminrating,weight FROM pods';
$sleep = '1'; $sleep = '1';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
} else { } else {
...@@ -147,25 +147,10 @@ while ($row = pg_fetch_all($result)) { ...@@ -147,25 +147,10 @@ while ($row = pg_fetch_all($result)) {
$outputsslerror = curl_error($chss); $outputsslerror = curl_error($chss);
curl_close($chss); curl_close($chss);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $domain . '/nodeinfo/1.0');
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 9);
curl_setopt($ch, CURLOPT_TIMEOUT, 9);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch);
curl_close($ch);
if ($debug) { if ($debug) {
echo 'not-e';
print $output;
}
if ($debug) {
echo 'e';
var_dump($outputssl); var_dump($outputssl);
} }
if (!$output && !$outpulssl && !$domain) { if (!$outpulssl && !$domain) {
continue; continue;
echo 'no connection to pod'; echo 'no connection to pod';
...@@ -182,7 +167,7 @@ while ($row = pg_fetch_all($result)) { ...@@ -182,7 +167,7 @@ while ($row = pg_fetch_all($result)) {
$result = pg_query_params($dbh, $sql, [$domain, true]); $result = pg_query_params($dbh, $sql, [$domain, true]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
} elseif ($output) { } else {
$secure = 'false'; $secure = 'false';
$outputresults = $output; $outputresults = $output;
} }
...@@ -223,7 +208,6 @@ while ($row = pg_fetch_all($result)) { ...@@ -223,7 +208,6 @@ while ($row = pg_fetch_all($result)) {
$score = $score - 1; $score = $score - 1;
$dver = '.connect error'; $dver = '.connect error';
$shortversion = 0; $shortversion = 0;
//no diaspora cookie on either, lets set this one as hidden and notify someone its not really a pod
//could also be a ssl pod with a bad cert, I think its ok to call that a dead pod now //could also be a ssl pod with a bad cert, I think its ok to call that a dead pod now
} }
$signup = $registrations_open; $signup = $registrations_open;
...@@ -265,59 +249,8 @@ while ($row = pg_fetch_all($result)) { ...@@ -265,59 +249,8 @@ while ($row = pg_fetch_all($result)) {
} }
echo '<br>'; echo '<br>';
$statslastdate = date('Y-m-d H:i:s'); $statslastdate = date('Y-m-d H:i:s');
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]['statsurl'] . $thismonth);
if ($debug) {
echo $row[$i]['statsurl'] . $thismonth;
}
curl_setopt($ping, CURLOPT_POST, 0);
curl_setopt($ping, CURLOPT_HEADER, 1);
curl_setopt($ping, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ping, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ping, CURLOPT_NOBODY, 0);
curl_setopt($ping, CURLOPT_MAXCONNECTS, 5);
curl_setopt($ping, CURLOPT_FOLLOWLOCATION, true);
$pingdom = curl_exec($ping);
$info = curl_getinfo($ping);
curl_close($ping);
if ($debug) {
echo '<br>Pingdom code: ' . $info['http_code'] . '<br>';
}
if ($info['http_code'] == 200) {
//response time
preg_match_all('/<h3>Avg. resp. time this month<\/h3>
<p class="large">(.*?)</', $pingdom, $matcheach);
$responsetime = $matcheach[1][0];
//months monitored
preg_match_all('/"historySelect">\s*(.*?)\s*<\/select/is', $pingdom, $matchhistory);
$implodemonths = implode(' ', $matchhistory[1]);
preg_match_all('/<option(.*?)/s', $implodemonths, $matchdates);
$months = isset($matchdates[0]) ? count($matchdates[0]) : 0;
//uptime %
preg_match_all('/<h3>Uptime this month<\/h3>\s*<p class="large">(.*?)%</', $pingdom, $matchper);
$uptime = isset($matchper[1][0]) ? preg_replace('/,/', '.', $matchper[1][0]) : 0;
$statslastdate = date('Y-m-d H:i:s');
if (strpos($pingdom, "class=\"up\"")) {
$status = 'up';
} elseif (strpos($pingdom, "class=\"down\"")) {
$status = 'down';
} elseif (strpos($pingdom, "class=\"paused\"")) {
$status = 'paused';
} else {
$status = 'error';
$score = $score - 2;
}
} else {
//pingdom url is <> 200 so stats are gone, lower score
$score = $score - 2;
}
} else {
//do uptimerobot API instead
$ping = curl_init(); $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]['statsurl']); curl_setopt($ping, CURLOPT_URL, 'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=' . $row[$i]['stats_apikey']);
curl_setopt($ping, CURLOPT_POST, 0); curl_setopt($ping, CURLOPT_POST, 0);
curl_setopt($ping, CURLOPT_HEADER, 0); curl_setopt($ping, CURLOPT_HEADER, 0);
curl_setopt($ping, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ping, CURLOPT_RETURNTRANSFER, 1);
...@@ -362,7 +295,6 @@ while ($row = pg_fetch_all($result)) { ...@@ -362,7 +295,6 @@ while ($row = pg_fetch_all($result)) {
if ($uptimerobotstat == 'fail' || $status <> 'Up') { if ($uptimerobotstat == 'fail' || $status <> 'Up') {
$score = $score - 2; $score = $score - 2;
} }
}
if ($softwarename == 'diaspora') { if ($softwarename == 'diaspora') {
$masterversion = $dmasterversion; $masterversion = $dmasterversion;
} elseif ($softwarename == 'friendica') { } elseif ($softwarename == 'friendica') {
......
...@@ -20,7 +20,7 @@ CREATE TABLE pods ( ...@@ -20,7 +20,7 @@ CREATE TABLE pods (
ipv6 boolean, ipv6 boolean,
secure boolean, secure boolean,
sslvalid text, sslvalid text,
statsurl text, stats_apikey text,
monthsmonitored int, monthsmonitored int,
signup boolean, signup boolean,
total_users int, total_users int,
......
...@@ -23,18 +23,17 @@ if ($_url) { ...@@ -23,18 +23,17 @@ if ($_url) {
header('Location:' . $_url); header('Location:' . $_url);
} else { } else {
$sql = 'SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup ORDER BY RANDOM() LIMIT 1'; $sql = 'SELECT domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup ORDER BY RANDOM() LIMIT 1';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
$scheme = $row[0]['secure'] === 't' ? 'https://' : 'http://';
$sql = 'INSERT INTO clicks (domain, autoclick) VALUES ($1, $2)'; $sql = 'INSERT INTO clicks (domain, autoclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$row[0]['domain'], '1']); $result = pg_query_params($dbh, $sql, [$row[0]['domain'], '1']);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up'); header('Location: https://' $row[0]['domain'] . '/users/sign_up');
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? ''; ...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$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"; $sql = "SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,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 = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -32,13 +32,6 @@ $numrows = pg_num_rows($result); ...@@ -32,13 +32,6 @@ $numrows = pg_num_rows($result);
<?php <?php
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'text-success';
} else {
$scheme = 'http://';
$class = 'red';
}
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']); $verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip = sprintf( $tip = sprintf(
...@@ -49,7 +42,7 @@ $numrows = pg_num_rows($result); ...@@ -49,7 +42,7 @@ $numrows = pg_num_rows($result);
$row['uptime_alltime'], $row['uptime_alltime'],
$row['score'] $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 '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="' . $class . ' url" target="_self" href="/go.php?url=https://' $row['domain'] . '">' . $row['domain'] . '</a></div></td>';
echo '<td>' . $row['uptime_alltime'] . '%</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>'; 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>';
......
...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? ''; ...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$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'; $sql = 'SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,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,stats_apikey,userrating FROM pods pods ORDER BY uptime_alltime DESC';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
...@@ -42,20 +42,11 @@ $numrows = pg_num_rows($result); ...@@ -42,20 +42,11 @@ $numrows = pg_num_rows($result);
<tbody> <tbody>
<?php <?php
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
} else {
$scheme = 'http://';
$class = 'red';
$tip = 'This pod does not offer SSL';
}
$pod_name = htmlentities($row['name'], ENT_QUOTES); $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['uptime_alltime']}% and a response time average today of {$row['responsetime']}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"; $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>'; echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" class="' . $class . '" target="_self" href="/go.php?url=https://' $row['domain'] . '">' . $row['domain'] . '</a></td>';
if ($row['shortversion'] > $row['masterversion']) { if ($row['shortversion'] > $row['masterversion']) {
$version = $row['shortversion']; $version = $row['shortversion'];
...@@ -84,8 +75,8 @@ $numrows = pg_num_rows($result); ...@@ -84,8 +75,8 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>'; echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>'; echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['statsurl'], 'pingdom.com')) { if (strpos($row['stats_apikey'], 'pingdom.com')) {
$moreurl = $row['statsurl']; $moreurl = $row['stats_apikey'];
} else { } else {
$moreurl = '/showstats.php?domain=' . $row['domain']; $moreurl = '/showstats.php?domain=' . $row['domain'];
} }
......
...@@ -29,7 +29,7 @@ foreach ($csv as $cords) { ...@@ -29,7 +29,7 @@ foreach ($csv as $cords) {
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");