diff --git a/api.php b/api.php
index 102f04b3fc06d33987a3432363175cf3ea0b0ba5..fe2e2ad73149e5a7aff0f35ae6b2938f1a0931f6 100644
--- a/api.php
+++ b/api.php
@@ -53,7 +53,7 @@ EOF;
}
echo '';
} elseif ($_format === 'json') {
- $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';
+ $sql = 'SELECT id,domain,status,secure,score,signup,userrating,adminrating,city,state,country,lat,long,ip,ipv6,stats_apikey,monthsmonitored,uptime_alltime,responsetime,local_posts,comment_counts,date_created,date_updated,date_laststats,hidden,terms,sslexpire,uptime_custom,dnssec,softwarename,total_users,local_posts,comment_counts,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp FROM pods';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
diff --git a/backup/.gitkeep b/backup/.gitkeep
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/db/add.php b/db/add.php
index fb3cd064497aaa1a6beff8a574334d450097b6a5..0956be8beac45d47e2d66f959fa61399dc09bc4f 100644
--- a/db/add.php
+++ b/db/add.php
@@ -53,7 +53,7 @@ curl_setopt($chss, CURLOPT_NOBODY, 0);
$outputssl = curl_exec($chss);
curl_close($chss);
-if (stristr($outputssl, 'nodeName')) {
+if (stristr($outputssl, 'openRegistrations')) {
$log->lwrite('Your pod has ssl and is valid ' . $_domain);
echo 'Your pod has ssl and is valid
';
diff --git a/db/migration00001.sql b/db/migration00001.sql
index 93a8614e64ff43300e57209b2966b94288f5e070..28a3a4ddb388420e00804a4adfb4cbe4ab3ae666 100644
--- a/db/migration00001.sql
+++ b/db/migration00001.sql
@@ -40,5 +40,6 @@ CREATE TABLE checks (
domain text,
online boolean,
error text,
+ ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp
);
diff --git a/db/pull.php b/db/pull.php
index 5464208708256106e84f8226d43df256cd1c6c24..a2b509642efe47a1a89adceede2c15197f1fac31 100644
--- a/db/pull.php
+++ b/db/pull.php
@@ -12,42 +12,42 @@ require_once __DIR__ . '/../config.php';
//get master code version for diaspora pods
$mv = curl_init();
curl_setopt($mv, CURLOPT_URL, 'https://raw.githubusercontent.com/diaspora/diaspora/master/config/defaults.yml');
-curl_setopt($mv, CURLOPT_POST, 0);
-curl_setopt($mv, CURLOPT_HEADER, 0);
curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($mv, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt($mv, CURLOPT_NOBODY, 0);
$outputmv = curl_exec($mv);
curl_close($mv);
-preg_match('/number: "(.*?)"/', $outputmv, $version);
-$dmasterversion = trim($version[1], '"');
+$dmasterversion = preg_match('/number:.*"(.*)"/', $outputmv, $version) ? $version[1] : '';
_debug('Diaspora Masterversion', $dmasterversion);
-//get master code version for freindica pods
+//get master code version for friendica pods
$mv = curl_init();
curl_setopt($mv, CURLOPT_URL, 'https://raw.githubusercontent.com/friendica/friendica/master/boot.php');
-curl_setopt($mv, CURLOPT_POST, 0);
-curl_setopt($mv, CURLOPT_HEADER, 0);
curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($mv, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt($mv, CURLOPT_NOBODY, 0);
$outputmv = curl_exec($mv);
curl_close($mv);
-preg_match('/FRIENDICA_VERSION\', \'(.*?)\'/', $outputmv, $version);
-$fmasterversion = trim($version[1], '"');
+$fmasterversion = preg_match('/define.*\'FRIENDICA_VERSION\'.*\'(.*)\'/', $outputmv, $version) ? $version[1] : '';
_debug('Friendica Masterversion: ' . $fmasterversion);
+//get master code version for hubzilla pods
+$mv = curl_init();
+curl_setopt($mv, CURLOPT_URL, 'https://raw.githubusercontent.com/redmatrix/hubzilla/master/boot.php');
+curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, 5);
+curl_setopt($mv, CURLOPT_RETURNTRANSFER, 1);
+$outputmv = curl_exec($mv);
+curl_close($mv);
+$hmasterversion = preg_match('/define.*\'STD_VERSION\'.*\'(.*)\'/', $outputmv, $version) ? $version[1] : '' ;
+_debug('Hubzilla Masterversion: ' . $hmasterversion);
+
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
//foreach pod check it and update db
if ($_domain) {
$sql = 'SELECT domain,stats_apikey,score,date_created,adminrating,weight FROM pods WHERE domain = $1';
- //$sleep = '0';
$result = pg_query_params($dbh, $sql, [$_domain]);
} elseif (PHP_SAPI === 'cli') {
$sql = 'SELECT domain,stats_apikey,score,date_created,adminrating,weight FROM pods';
- //$sleep = '1';
$result = pg_query($dbh, $sql);
} else {
die('No valid input');
@@ -84,53 +84,44 @@ while ($row = pg_fetch_assoc($result)) {
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, 'https://' . $domain . '/nodeinfo/1.0');
- curl_setopt($chss, CURLOPT_POST, 0);
- curl_setopt($chss, CURLOPT_HEADER, 0);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 9);
curl_setopt($chss, CURLOPT_TIMEOUT, 9);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($chss, CURLOPT_NOBODY, 0);
curl_setopt($chss, CURLOPT_CERTINFO, 1);
- curl_setopt($chss, CURLOPT_VERBOSE, 1);
$outputssl = curl_exec($chss);
$outputsslerror = curl_error($chss);
$info = curl_getinfo($chss, CURLINFO_CERTINFO);
- $sslexpire = $info[0]['Expire date'];
+ $ttl = curl_getinfo($chss, CURLINFO_CONNECT_TIME);
+ $sslexpire = $info[0]['Expire date'] ?? null;
curl_close($chss);
_debug('Nodeinfo output', $outputssl, true);
_debug('Nodeinfo output error', $outputsslerror, true);
-
+ _debug('Cert expire date', $sslexpire);
+ _debug('TTL', $ttl);
+
//get new json from nodeinfo
$jsonssl = json_decode($outputssl);
- if (!$jsonssl && !$domain) {
- continue;
- /*echo 'no connection to pod';
+ if (!$jsonssl) {
+ _debug('Connection', 'Can not connect to pod');
- $sql = 'INSERT INTO checks (domain, online, error) VALUES ($1, $2, $3)';
- $result = pg_query_params($dbh, $sql, [$domain, false, $outputsslerror]);
- $result || die('Error in SQL query: ' . pg_last_error());*/
+ $sql_errors = 'INSERT INTO checks (domain, online, error, ttl) VALUES ($1, $2, $3, $4)';
+ $result_errors = pg_query_params($dbh, $sql_errors, [$domain, 0, $outputsslerror, $ttl]);
+ $result_errors || die('Error in SQL query: ' . pg_last_error());
}
- $sql_checks = 'INSERT INTO checks (domain, online) VALUES ($1, $2)';
- $result_checks = pg_query_params($dbh, $sql_checks, [$domain, true]);
- $result_checks || die('Error in SQL query: ' . pg_last_error());
-
- $signup = false;
if ($jsonssl !== null) {
- $score += 1;
-
- var_dump($jsonssl);
- if ($jsonssl->openRegistrations === true) {
- $signup = true;
- }
+ $sql_checks = 'INSERT INTO checks (domain, online, ttl) VALUES ($1, $2, $3)';
+ $result_checks = pg_query_params($dbh, $sql_checks, [$domain, 1, $ttl]);
+ $result_checks || die('Error in SQL query: ' . pg_last_error());
+
+ (!$jsonssl->software->version) || $score += 1;
$xdver = $jsonssl->software->version ?? 0;
$dverr = explode('-', trim($xdver));
$shortversion = $dverr[0];
_debug('Version code', $shortversion);
- $shortversion || $score -= 2;
-
+ $signup = ($jsonssl->openRegistrations === true);
$softwarename = $jsonssl->software->name ?? 'null';
$name = $jsonssl->metadata->nodeName ?? 'null';
$total_users = $jsonssl->usage->users->total ?? 0;
@@ -142,23 +133,28 @@ while ($row = pg_fetch_assoc($result)) {
$service_twitter = in_array('twitter', $jsonssl->services->outbound, true);
$service_tumblr = in_array('tumblr', $jsonssl->services->outbound, true);
$service_wordpress = in_array('wordpress', $jsonssl->services->outbound, true);
- $service_xmpp = $jsonssl->metadata->xmppChat === true;
+ $service_xmpp = $jsonssl->metadata->xmppChat === true ?? false;
} else {
$score -= 1;
$dver = '.connect error';
$shortversion = 0;
- //could also be a ssl pod with a bad cert, I think its ok to call that a dead pod now
}
_debug('Signup Open', $signup);
- $ip6 = exec(escapeshellcmd('dig +nocmd ' . $domain . ' aaaa +noall +short'));
+ $ip6 = exec(escapeshellcmd('dig @74.82.42.42 +nocmd ' . $domain . ' aaaa +noall +short'));
$iplookup = [];
- exec(escapeshellcmd('delv ' . $domain), $iplookup);
- $dnssec = in_array('; fully validated', $iplookup);
- preg_match('/A(.*)/', $iplookup[1], $version);
- $ip = trim($version[1]);
+ exec(escapeshellcmd('delv @74.82.42.42 ' . $domain), $iplookup);
+ if ($iplookup) {
+ _debug('Iplookup', $iplookup, true);
+ $dnssec = in_array('; fully validated', $iplookup) ?? false ;
+ $getaonly = array_values(preg_grep('/A\s.*/', $iplookup));
+ preg_match('/A\s(.*)/', $getaonly[0], $version);
+ $ip = trim($version[1]);
+ }
+ $ip || $score -= 2;
$ipv6 = strpos($ip6, ':') !== false;
_debug('IP', $ip);
+ _debug('IPv6', $ip6);
$location = geoip_record_by_name($ip);
_debug('Location', $location, true);
@@ -174,48 +170,43 @@ while ($row = pg_fetch_assoc($result)) {
$statslastdate = date('Y-m-d H:i:s');
$ping = curl_init();
curl_setopt($ping, CURLOPT_URL, 'https://api.uptimerobot.com/getMonitors?format=json&noJsonCallback=1&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=' . $row['stats_apikey']);
- curl_setopt($ping, CURLOPT_POST, 0);
- curl_setopt($ping, CURLOPT_HEADER, 0);
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);
$uptr = json_decode(curl_exec($ping));
curl_close($ping);
_debug('Uptime Robot', $uptr, true);
- $uptr || $score -= 2;
-
- $responsetime = $uptr->monitors->monitor{'0'}->responsetime{'0'}->value;
- $uptimerobotstat = $uptr->stat;
- $uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio;
- $uptime_custom = $uptr->monitors->monitor{'0'}->customuptimeratio;
- $diff = (new DateTime())->diff(new DateTime($dateadded));
- $months = $diff->m + ($diff->y * 12);
- if ($uptr->monitors->monitor{'0'}->status == 2) {
- $status = 'Up';
- }
- if ($uptr->monitors->monitor{'0'}->status == 0) {
- $status = 'Paused';
- }
- if ($uptr->monitors->monitor{'0'}->status == 1) {
- $status = 'Not Checked Yet';
- }
- if ($uptr->monitors->monitor{'0'}->status == 8) {
- $status = 'Seems Down';
- }
- if ($uptr->monitors->monitor{'0'}->status == 9) {
- $status = 'Down';
- }
- if ($uptr) {
- $statslastdate = date('Y-m-d H:i:s');
+
+ if ($uptr->stat === 'ok') {
+ $responsetime = $uptr->monitors->monitor{'0'}->responsetime{'0'}->value ?? 'n/a';
+ $uptimerobotstat = $uptr->stat;
+ $uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio;
+ $uptime_custom = $uptr->monitors->monitor{'0'}->customuptimeratio;
+ $diff = (new DateTime())->diff(new DateTime($dateadded));
+ $months = $diff->m + ($diff->y * 12);
+ if ($uptr->monitors->monitor{'0'}->status == 2) {
+ $status = 'Up';
+ }
+ if ($uptr->monitors->monitor{'0'}->status == 0) {
+ $status = 'Paused';
+ }
+ if ($uptr->monitors->monitor{'0'}->status == 1) {
+ $status = 'Not Checked Yet';
+ }
+ if ($uptr->monitors->monitor{'0'}->status == 8) {
+ $status = 'Seems Down';
+ }
+ if ($uptr->monitors->monitor{'0'}->status == 9) {
+ $status = 'Down';
+ }
+ $statslastdate = date('Y-m-d H:i:s');
}
- ($uptimerobotstat !== 'fail' && $status === 'Up') || $score -= 2;
if ($softwarename === 'diaspora') {
$masterversion = $dmasterversion;
} elseif ($softwarename === 'friendica') {
$masterversion = $fmasterversion;
+ } elseif ($softwarename === 'redmatrix') {
+ $masterversion = $hmasterversion;
}
$hidden = $score <= 70;
_debug('Hidden', $hidden ? 'yes' : 'no');
@@ -236,7 +227,7 @@ while ($row = pg_fetch_assoc($result)) {
_debug('Score out of 100', $score);
echo 'Success';
-
+
echo $newline;
echo $newline;
}
diff --git a/db/tables.sql b/db/tables.sql
index 7923c10dec3c20ab4ca357fbc21c61b19c370d49..f327734e3d4806e2173ec787ca7d03c0e9180b10 100644
--- a/db/tables.sql
+++ b/db/tables.sql
@@ -76,6 +76,7 @@ CREATE TABLE checks (
domain text,
online boolean,
error text,
+ ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp
);
diff --git a/showmap.php b/showmap.php
index 72cc21cec08e1dba9acbe4b6a7fc3eb33a85b6ab..8f80ed63051affea6217265fbc9e49cb64c66be9 100644
--- a/showmap.php
+++ b/showmap.php
@@ -69,7 +69,7 @@ EOF;
maxZoom: 18,
attribution: '© Mapbox © OpenStreetMap Improve this map'
});
- var map = L.map('map', {zoom: 5, center: [, ]}).addLayer(tiles);
+ var map = L.map('map', {zoom: 3, center: [, ]}).addLayer(tiles);
var markers = L.markerClusterGroup({
maxClusterRadius: 2, animateAddingMarkers: true, iconCreateFunction: function (cluster) {
return new L.DivIcon({html: '' + cluster.getChildCount() + '', className: 'mycluster', iconSize: L.point(35, 35)});