Commit 1cbf1b34 authored by dmorley's avatar dmorley Committed by GitHub

Deadpods (#138)

* remove old delete, show alive pods

* cleanup go and crawler (pod json data gone)

* if it was up and is up then update data, else keep old stats data

* allow for the weird frendica dev code to not delist you for now, needs a better long term solution for this weird versioning

* cleanup

* just a hair better for mobile/tablet use on the graph
parent 37ccff13
<?php
use RedBeanPHP\R;
defined('PODUPTIME') || die();
try {
$pods = R::getAll('
SELECT domain, masterversion, shortversion, monthsmonitored, score, signup, name, uptime_alltime, active_users_halfyear, active_users_monthly, latency, date_updated, total_users, local_posts, comment_counts, stats_apikey, sslvalid
FROM pods
WHERE score < 50
ORDER BY weightedscore ASC
');
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
?>
<meta property="og:title" content="<?php echo count($pods); ?> #Diaspora Pods listed, Come see the privacy aware social network."/><?php echo count($pods); ?> pods that are open for signup now.
<meta charset="utf-8">
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<div class="table-responsive">
<table class="table table-striped table-sm tablesorter-bootstrap table-hover tfont">
<thead>
<tr>
<th>Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
<th>Version<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th>
<th>Uptime<a class="tipsy" title="Percent of the time the pod is online for <?php echo date('F') ?>.">?</a></th>
<th>ms</th>
<th>Signups</th>
<th>Total<a class="tipsy" title="Number of total users on this pod.">?</a></th>
<th>Active 6<a class="tipsy" title="Number of users active last 6 months on this pod.">?</a></th>
<th>Active 1<a class="tipsy" title="Number of users active last 1 month on this pod.">?</a></th>
<th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th>
<th>Comm<a class="tipsy" title="Number of total comments on this pod.">?</a></th>
<th>Month<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a></th>
<th>Sc<a class="tipsy" title="System Score on a 100 scale.">?</a></th>
<th>conn<a class="tipsy" title="">?</a></th>
<th>Delete?<a class="tipsy" title="Delete this pod from DB?">?</a></th>
</tr>
</thead>
<tbody>
<?php
$tt = 0;
foreach ($pods as $pod) {
$tt++;
$verdiff = (int) str_replace('.', '', $pod['masterversion']) - (int) str_replace('.', '', $pod['shortversion']);
$pod_name = htmlentities($pod['name'], ENT_QUOTES);
$tip = sprintf(
'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['monthsmonitored'],
$pod['latency'],
$pod['uptime_alltime'],
$pod['date_updated'],
$pod['score']
);
echo '<tr><td><a class="text-success" target="_self" href="https://' . $pod['domain'] . '">' . $pod['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>';
if (stristr($pod['shortversion'], 'head')) {
$version = '.dev';
$pre = 'This pod runs pre release development code';
} elseif (!$pod['shortversion']) {
$version = '0';
$pre = 'This pod runs unknown code';
} else {
$version = $pod['shortversion'];
$pre = 'This pod runs production code';
}
if ($pod['shortversion'] === $pod['masterversion'] && $pod['shortversion'] !== '') {
$classver = 'text-success';
} elseif ($verdiff > 6) {
$classver = 'text-warning';
} else {
$classver = 'black';
}
echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $pod['shortversion'] . ' master version is: ' . $pod['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
echo '<td>' . $pod['uptime_alltime'] . '</td>';
echo '<td>' . $pod['latency'] . '</td>';
echo '<td>' . ($pod['signup'] ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $pod['total_users'] . '</td>';
echo '<td>' . $pod['active_users_halfyear'] . '</td>';
echo '<td>' . $pod['active_users_monthly'] . '</td>';
echo '<td>' . $pod['local_posts'] . '</td>';
echo '<td>' . $pod['comment_counts'] . '</td>';
echo '<td><div title="Last Check ' . $pod['date_updated'] . '" class="tipsy">' . $pod['monthsmonitored'] . '</div></td>';
echo '<td>' . $pod['score'] . '</td>';
echo '<td><div class="tipsy" title="' . $pod['sslvalid'] . '">con info</td>';
?>
<td>
<form method="post" action="db/kill.php" target="_blank">
<input type="hidden" name="domain" value="<?php echo $pod['domain']; ?>">
<input type="hidden" name="adminkey" value="<?php echo $_COOKIE['adminkey']; ?>">
<label>Comments<input name="comments" value="<?php echo $pod['sslvalid']; ?>" size="10"></label>
<label><input type="radio" name="action" value="warn">warn</label>
<label><input type="radio" name="action" value="delete">delete</label>
<input type="submit" value="Process">
</form>
</td>
<?php
echo '</tr>';
}
?>
</tbody>
</table>
</div>
......@@ -16,8 +16,6 @@ $pgpass = '';
$pgdb = '';
//admin email for forms
$adminemail = '';
//admin key for deleting pods, set this as a cookie on your own
$adminkey = '';
//DNS server for dnssec testing
$dnsserver = '';
//CA for curl to use - suggest wget http://curl.haxx.se/ca/cacert.pem as they pull from mozilla if you use a system CA then certs like wosign and startssl will be valid but users will be unable to connect to them
......
<?php
use RedBeanPHP\R;
// Required parameters.
($_domain = $_POST['domain'] ?? null) || die('no pod domain given');
($_adminkey = $_POST['adminkey'] ?? null) || die('no admin key given');
($_action = $_POST['action'] ?? null) || die('no action selected');
// Other parameters.
$_comments = $_POST['comments'] ?? '';
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php';
$adminkey === $_adminkey || die('admin key mismatch');
define('PODUPTIME', microtime(true));
// Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try {
$pod = R::getRow('SELECT id, email FROM pods WHERE domain = ?', [$_domain]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
if ($pod) {
$email = $pod['email'];
if ($_action === 'delete') {
R::trash('pods', $pod['id']);
if ($email) {
$to = $email;
$headers = ['From: ' . $adminemail, 'Cc: ' . $adminemail];
$subject = 'Pod deleted from ' . $_SERVER['HTTP_HOST'];
$message = 'Pod ' . $_domain . ' was deleted from ' . $_SERVER['HTTP_HOST'] . ' as it was dead on the list. ' . $_comments . ' Feel free to add back at any time.';
@mail($to, $subject, $message, implode("\r\n", $headers));
}
} elseif ($_action === 'warn') {
if ($email) {
$to = $email;
$headers = ['From: ' . $adminemail, 'Cc: ' . $adminemail];
$subject = 'Pod removal warning from ' . $_SERVER['HTTP_HOST'];
$message = 'Pod ' . $_domain . ' is on the list to be deleted now because: ' . $_comments . ".\r\nPlease let me know if you need help fixing before it is removed.";
@mail($to, $subject, $message, implode("\r\n", $headers));
}
}
}
......@@ -23,7 +23,7 @@ R::usePartialBeans(true);
try {
$sql = '
SELECT domain, score, date_created, adminrating, weight, hidden, podmin_notify, email, masterversion, shortversion
SELECT domain, score, date_created, adminrating, weight, hidden, podmin_notify, email, masterversion, shortversion, status
FROM pods
';
......@@ -50,6 +50,7 @@ foreach ($pods as $pod) {
$notify = $pod['podmin_notify'];
$masterv = $pod['masterversion'];
$shortv = $pod['shortversion'];
$dbstatus = $pod['status'];
try {
$ratings = R::getAll('
......@@ -122,14 +123,15 @@ foreach ($pods as $pod) {
$service_wordpress = false;
if (json_last_error() === 0) {
(!$jsonssl->software->version) || $score += 1;
$service_facebook = in_array('facebook', $jsonssl->services->outbound, true);
$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);
if (is_array($jsonssl->services->outbound)) {
$service_facebook = in_array('facebook', $jsonssl->services->outbound, true);
$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);
}
}
if ($jsonssl !== null) {
$status = PodStatus::Up;
try {
$c = R::dispense('checks');
......@@ -144,6 +146,8 @@ foreach ($pods as $pod) {
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$status = PodStatus::Up;
}
if (!$jsonssl) {
......@@ -161,7 +165,6 @@ foreach ($pods as $pod) {
}
$score -= 1;
$shortversion = '0.error';
$status = PodStatus::Down;
}
......@@ -229,7 +232,8 @@ foreach ($pods as $pod) {
_debug('Masterversion', $masterversion);
$masterversioncheck = explode('.',$masterversion);
$shortversioncheck = explode('.',$shortversion);
if (($masterversioncheck[1] - $shortversioncheck[1]) > 1) {
if (($masterversioncheck[1] - $shortversioncheck[1]) > 1 && strpos($shortversion,'dev') !== false) {
//dev search added to address frendica using very odd versioning for dev code, we should look to pull dev versions and use them rather than assume dev is always ahead of prod code
_debug('Outdated', 'Yes');$score -= 2;
}
......@@ -276,25 +280,27 @@ foreach ($pods as $pod) {
$p['lat'] = $lat;
$p['long'] = $long;
$p['userrating'] = $user_rating;
$p['shortversion'] = $shortversion;
$p['masterversion'] = $masterversion;
$p['signup'] = $signup;
$p['total_users'] = $total_users;
$p['active_users_halfyear'] = $active_users_halfyear;
$p['active_users_monthly'] = $active_users_monthly;
$p['local_posts'] = $local_posts;
$p['name'] = $name;
$p['comment_counts'] = $comment_counts;
$p['service_facebook'] = $service_facebook;
$p['service_tumblr'] = $service_tumblr;
$p['service_twitter'] = $service_twitter;
$p['service_wordpress'] = $service_wordpress;
$p['service_xmpp'] = $service_xmpp;
$p['weightedscore'] = $weightedscore;
$p['softwarename'] = $softwarename;
$p['sslvalid'] = $outputsslerror;
$p['dnssec'] = $dnssec;
$p['sslexpire'] = $sslexpire;
if ($dbstatus == 1 & $status = PodStatus::Up) {
$p['shortversion'] = $shortversion;
$p['signup'] = $signup;
$p['total_users'] = $total_users;
$p['active_users_halfyear'] = $active_users_halfyear;
$p['active_users_monthly'] = $active_users_monthly;
$p['local_posts'] = $local_posts;
$p['name'] = $name;
$p['comment_counts'] = $comment_counts;
$p['service_facebook'] = $service_facebook;
$p['service_tumblr'] = $service_tumblr;
$p['service_twitter'] = $service_twitter;
$p['service_wordpress'] = $service_wordpress;
$p['service_xmpp'] = $service_xmpp;
$p['softwarename'] = $softwarename;
}
R::store($p);
} catch (\RedBeanPHP\RedException $e) {
......
......@@ -27,7 +27,8 @@ try {
SELECT domain
FROM pods
WHERE signup
AND score > 90
AND uptime_alltime > 96
AND monthsmonitored > 2
AND pods.masterversion = shortversion
ORDER BY random()
LIMIT 1
......
......@@ -18,12 +18,11 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$lastfile = 'db/last.data';
$detailedview = isset($_GET['detailedview']);
$mapview = isset($_GET['mapview']);
$cleanup = isset($_GET['cleanup']);
$statsview = isset($_GET['statsview']);
$podmin = isset($_GET['podmin']);
$podminedit = isset($_GET['podminedit']);
$edit = isset($_GET['edit']);
$simpleview = !($detailedview || $mapview || $cleanup || $podmin || $podminedit || $statsview);
$simpleview = !($detailedview || $mapview || $podmin || $podminedit || $statsview);
?>
<!doctype html>
<html lang="en">
......@@ -133,8 +132,6 @@ $navs = [
include_once __DIR__ . '/podminedit.php';
} elseif ($edit) {
include_once __DIR__ . '/db/edit.php';
} elseif ($cleanup) {
include_once __DIR__ . '/cleanup.php';
} else {
include_once __DIR__ . '/show.php';
}
......
<?php
require_once __DIR__ . '/config.php';
//grab pods from the-federation
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, 'https://the-federation.info/pods.json');
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 19);
curl_setopt($chss, CURLOPT_TIMEOUT, 19);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($chss);
curl_close($chss);
$json = json_decode($output);
foreach($json->pods as $mydata) {
$addjson = exec('php-cgi db/add.php domain='.$mydata->host);
echo $addjson;
}
//local json from a diaspora pod json dump /admin_panel/pod/export
$string = file_get_contents("pods.json");
$json_a = json_decode($string, true);
foreach ($json_a as $pod => $host) {
$addlocal = exec('php-cgi db/add.php domain='.$host['pod']['host']);
echo $addlocal;
$json = json_decode(file_get_contents('https://the-federation.info/pods.json'));
foreach($json->pods as $poddata) {
echo exec("php-cgi db/add.php domain={$poddata->host}") . "\r\n";
}
......@@ -8,9 +8,9 @@ try {
$pods = R::getAll('
SELECT domain, dnssec, podmin_statement, sslexpire, 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, latency, date_updated, ipv6, total_users, local_posts, comment_counts, userrating, status
FROM pods
WHERE uptime_alltime > 50
WHERE status < ?
ORDER BY weightedscore DESC
');
', [PodStatus::System_Deleted]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
......@@ -81,7 +81,7 @@ try {
echo '<td>' . ($pod['comment_counts'] > 0 ? $pod['comment_counts'] : '') . '</td>';
echo '<td><div title="Last Check ' . $pod['date_updated'] . '" data-toggle="tooltip" data-placement="bottom">' . $pod['monthsmonitored'] . '</div></td>';
echo '<td><a rel="facebox" href="rate.php?domain=' . $pod['domain'] . '">' . $pod['userrating'] . '</a></td>';
echo '<td>' . $pod['score'] . '</td>';
echo '<td><div title="Pod Status is: ' . PodStatus::getKey((int)$pod['status']) . '" data-toggle="tooltip" data-placement="bottom">' . $pod['score'] . '</div></td>';
echo '<td>' . ($pod['dnssec'] ? '&#10003;' : '') . '</td>';
if ($country_code === $pod['country']) {
echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="City: ' . ($pod['city'] ?? 'n/a') . ' State: ' . ($pod['state'] ?? 'n/a') . '"><b>' . $pod['country'] . '</b></td>';
......
......@@ -12,8 +12,8 @@
</div>
<br>
<div class="row">
<div class="col-lg-12 text-center">Average Network User Growth<br>
<canvas id="user_growth" width="1000" height="100"></canvas>
<div class="col text-center">Average Network User Growth<br>
<center><canvas id="user_growth" width="1000" height="300"></canvas></center>
</div>
</div>
</div>
......@@ -12,9 +12,9 @@ try {
sum(total_users) AS users,
round(avg(uptime_alltime),2) AS uptime
FROM pods
WHERE NOT hidden
WHERE status < ?
GROUP BY softwarename
');
', [PodStatus::System_Deleted]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
......@@ -68,14 +68,14 @@ try {
fill: false,
borderColor: "#2ecc71",
backgroundColor: "#2ecc71",
borderWidth: 4,
pointHoverRadius: 6
borderWidth: 2,
pointHoverRadius: 2
}
]
},
options: {
responsive: true,
maintainAspectRatio: true
responsive: false,
maintainAspectRatio: false
}
});
}
......
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