Commit fe62158f authored by noplanman's avatar noplanman Committed by GitHub

Merge pull request #84 from diasporg/pullfix

fix some pull issues
parents ca63e4a0 b5168a9b
......@@ -53,7 +53,7 @@ EOF;
}
echo '</feed>';
} 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());
......
......@@ -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<br>';
......
......@@ -40,5 +40,6 @@ CREATE TABLE checks (
domain text,
online boolean,
error text,
ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp
);
......@@ -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;
}
......
......@@ -76,6 +76,7 @@ CREATE TABLE checks (
domain text,
online boolean,
error text,
ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp
);
......@@ -69,7 +69,7 @@ EOF;
maxZoom: 18,
attribution: '<a href="https://www.mapbox.com/about/maps/" target="_blank">&copy; Mapbox &copy; OpenStreetMap</a> <a class="mapbox-improve-map" href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>'
});
var map = L.map('map', {zoom: 5, center: [<?php echo $lat; ?>, <?php echo $long; ?>]}).addLayer(tiles);
var map = L.map('map', {zoom: 3, center: [<?php echo $lat; ?>, <?php echo $long; ?>]}).addLayer(tiles);
var markers = L.markerClusterGroup({
maxClusterRadius: 2, animateAddingMarkers: true, iconCreateFunction: function (cluster) {
return new L.DivIcon({html: '<b class="icon">' + cluster.getChildCount() + '</b>', className: 'mycluster', iconSize: L.point(35, 35)});
......
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