Commit a18b81d4 authored by dmorley's avatar dmorley
Browse files

Merge branch 'develop' into 'master'

2.6.0 release merge

See merge request !236
parents 431043d0 87b18790
Pipeline #1457 passed with stage
in 2 minutes and 45 seconds
...@@ -9,6 +9,30 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ...@@ -9,6 +9,30 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
### Fixed ### Fixed
### Security ### Security
## [2.6.0] - 2019-04-13
:exclamation: DB migrations required! (see [SQL migration script][2.6.0-sql-migration])
### Added
- store protocols that pods support
- hide software names you don't want on table/go - leaving in stats for now
### Changed
- add.php test for pod meta like update.php
- use meta table for updating monthly stats not the diasp.org hack
### Deprecated
### Removed
### Fixed
- init call on new setup sets up the needed items
- missing tables.sql item from version 2.5.2
- missing table on tables.sql
- link to osada repo updated
- use any valid nodeinfo pod
- softwares are in config.php now so it is not hardcoded to add and update git repos
- some UI issues with more than 1000 pods listed
- uptime and growth charts per pod to be unlimited timespan
- use dig command vs delv as ecdsa keys are not being detected properly by delv
- stats page human readabe dates/times
- system deleted fix
### Security
## [2.5.2] - 2019-01-29 ## [2.5.2] - 2019-01-29
:exclamation: DB migrations required! (see [SQL migration script][2.5.2-sql-migration]) :exclamation: DB migrations required! (see [SQL migration script][2.5.2-sql-migration])
### Added ### Added
...@@ -153,6 +177,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ...@@ -153,6 +177,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
### Fixed ### Fixed
- Fix ipv6 - Fix ipv6
[2.6.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.5.2-2.6.0.sql
[2.5.2-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.5.0-2.5.2.sql [2.5.2-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.5.0-2.5.2.sql
[2.5.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.4.1-2.5.0.sql [2.5.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.4.1-2.5.0.sql
[2.4.1-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.4.0-2.4.1.sql [2.4.1-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.4.0-2.4.1.sql
...@@ -161,6 +186,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ...@@ -161,6 +186,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
[2.2.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.1.4-2.2.0.sql [2.2.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.1.4-2.2.0.sql
[Unreleased]: https://git.feneas.org/diasporg/Poduptime/compare/master...develop [Unreleased]: https://git.feneas.org/diasporg/Poduptime/compare/master...develop
[2.6.0]: https://git.feneas.org/diasporg/Poduptime/compare/2.5.2...2.6.0
[2.5.2]: https://git.feneas.org/diasporg/Poduptime/compare/2.5.1...2.5.2 [2.5.2]: https://git.feneas.org/diasporg/Poduptime/compare/2.5.1...2.5.2
[2.5.1]: https://git.feneas.org/diasporg/Poduptime/compare/2.5.0...2.5.1 [2.5.1]: https://git.feneas.org/diasporg/Poduptime/compare/2.5.0...2.5.1
[2.5.0]: https://git.feneas.org/diasporg/Poduptime/compare/2.4.2...2.5.0 [2.5.0]: https://git.feneas.org/diasporg/Poduptime/compare/2.4.2...2.5.0
......
...@@ -8,7 +8,7 @@ Environmental items you need (debian based system assumed): ...@@ -8,7 +8,7 @@ Environmental items you need (debian based system assumed):
OS Dependencies: OS Dependencies:
``` ```
php7.2 php7.2-curl php7.2-pgsql php7.2-bcmath php-geoip php7.2-cli php7.2-common php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer php7.2 php7.2-curl php7.2-pgsql php7.2-bcmath php-geoip php7.2-cli php7.2-common php7.2-fpm php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer
``` ```
Yarn is a separate install: https://yarnpkg.com Yarn is a separate install: https://yarnpkg.com
...@@ -41,10 +41,14 @@ Import database schema ...@@ -41,10 +41,14 @@ Import database schema
psql -U podupuser podupdb < db/tables.sql psql -U podupuser podupdb < db/tables.sql
``` ```
Configure your webserver (nginx example)
```
see file http-server-config.example
```
1. Edit `config.php` to add your DB and file settings 1. Edit `config.php` to add your DB and file settings
2. Touch add.log in location you configured in config.php 2. Create your backup folder
3. Create your backup folder 3. Add a pod and run `php db/update.php init`
4. Add a pod and run `php db/update.php init`
# To Use: # To Use:
...@@ -65,7 +69,6 @@ psql -U podupuser podupdb < db/migrations/xxx.sql (see db/migrations/README.md f ...@@ -65,7 +69,6 @@ psql -U podupuser podupdb < db/migrations/xxx.sql (see db/migrations/README.md f
# Status # Status
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e4fdde7b4ec34c56a86938d3ba6e3983)](https://www.codacy.com/app/diasporg/Poduptime?utm_source=git.feneas.org&amp;utm_medium=referral&amp;utm_content=diasporg/Poduptime&amp;utm_campaign=Badge_Grade)
[![pipeline status](https://git.feneas.org/diasporg/Poduptime/badges/develop/pipeline.svg)](https://git.feneas.org/diasporg/Poduptime/commits/develop) [![pipeline status](https://git.feneas.org/diasporg/Poduptime/badges/develop/pipeline.svg)](https://git.feneas.org/diasporg/Poduptime/commits/develop)
[![coverage report](https://git.feneas.org/diasporg/Poduptime/badges/develop/coverage.svg)](https://git.feneas.org/diasporg/Poduptime/commits/develop) [![coverage report](https://git.feneas.org/diasporg/Poduptime/badges/develop/coverage.svg)](https://git.feneas.org/diasporg/Poduptime/commits/develop)
......
...@@ -46,16 +46,16 @@ ...@@ -46,16 +46,16 @@
}, },
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",
"version": "1.1.3", "version": "1.1.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/ca-bundle.git", "url": "https://github.com/composer/ca-bundle.git",
"reference": "8afa52cd417f4ec417b4bfe86b68106538a87660" "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/8afa52cd417f4ec417b4bfe86b68106538a87660", "url": "https://api.github.com/repos/composer/ca-bundle/zipball/558f321c52faeb4828c03e7dc0cfe39a09e09a2d",
"reference": "8afa52cd417f4ec417b4bfe86b68106538a87660", "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
"ssl", "ssl",
"tls" "tls"
], ],
"time": "2018-10-18T06:09:13+00:00" "time": "2019-01-28T09:30:10+00:00"
}, },
{ {
"name": "detectlanguage/detectlanguage", "name": "detectlanguage/detectlanguage",
...@@ -807,16 +807,16 @@ ...@@ -807,16 +807,16 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v4.2.2", "version": "v4.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0" "reference": "23fd7aac70d99a17a8e6473a41fec8fab3331050"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/939fb792d73f2ce80e6ae9019d205fc480f1c9a0", "url": "https://api.github.com/repos/symfony/translation/zipball/23fd7aac70d99a17a8e6473a41fec8fab3331050",
"reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0", "reference": "23fd7aac70d99a17a8e6473a41fec8fab3331050",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -876,7 +876,7 @@ ...@@ -876,7 +876,7 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00" "time": "2019-01-27T23:11:39+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
......
...@@ -49,4 +49,30 @@ return [ ...@@ -49,4 +49,30 @@ return [
//detectlanguage.com api key //detectlanguage.com api key
'dlkey' => '', 'dlkey' => '',
//softwares and git repos we support
'softwares' => [
'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'friendica' => ['repo' => 'friendica/friendica', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'hubzilla' => ['repo' => 'hubzilla%2fcore', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'],
'pleroma' => ['repo' => 'pleroma%2fpleroma', 'gitsite' => 'git.pleroma.social', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'socialhome' => ['repo' => 'socialhome%2fsocialhome', 'gitsite' => 'git.feneas.org', 'gittype' => 'gitlab', 'devbranch' => ''],
'social-relay' => ['repo' => 'jaywink%2fsocial-relay', 'gitsite' => 'git.feneas.org', 'gittype' => 'gitlab', 'devbranch' => ''],
'writefreely' => ['repo' => 'writeas/writefreely', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'ganggo' => ['repo' => 'ganggo%2fganggo', 'gitsite' => 'git.feneas.org', 'gittype' => 'gitlab', 'devbranch' => ''],
'funkwhale' => ['repo' => 'funkwhale%2ffunkwhale', 'gitsite' => 'code.eliotberriot.com', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'osada' => ['repo' => 'zot%2fosada', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'],
'funkwhale' => ['repo' => 'funkwhale%2ffunkwhale', 'gitsite' => 'dev.funkwhale.audio', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'gnusocial' => ['repo' => 'gnu%2fgnu-social', 'gitsite' => 'git.gnu.io', 'gittype' => 'gitlab', 'devbranch' => 'nightly'],
'pixelfed' => ['repo' => 'pixelfed/pixelfed', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'dev'],
'wordpress' => ['repo' => 'Wordpress/Wordpress', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'misskey' => ['repo' => 'syuilo/misskey', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'speechmore' => ['repo' => 'speechmore%2fspeechmore', 'gitsite' => 'gitlab.fancy.org.uk', 'gittype' => 'gitlab', 'devbranch' => ''],
'peertube' => ['repo' => 'Chocobozzz/PeerTube', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'plume' => ['repo' => 'Plume-org/Plume', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'rustodon' => ['repo' => 'rustodon/rustodon', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
],
//hidden software word strings from table view - %(one)% OR %(one|two|three)%
'hidden-softwares' => '%(relay)%',
]; ];
...@@ -173,7 +173,7 @@ a { ...@@ -173,7 +173,7 @@ a {
text-decoration: none; text-decoration: none;
transition: background-color .3s; transition: background-color .3s;
cursor: pointer; cursor: pointer;
width: 170px; width: 200px;
height: 30px; height: 30px;
} }
...@@ -225,7 +225,7 @@ a { ...@@ -225,7 +225,7 @@ a {
.loadingtable { .loadingtable {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: #fff; background-color: rgba(78,137,164,.8);
position: fixed; position: fixed;
margin: 0; margin: 0;
padding: 0; padding: 0;
...@@ -233,20 +233,26 @@ a { ...@@ -233,20 +233,26 @@ a {
} }
.signal { .signal {
border: 5px solid #333; border: 6px solid #ffffff;
border-radius: 30px; border-radius: 50px;
height: 30px; height: 40px;
left: 20%; left: 5%;
margin: -15px 0 0 -15px; margin: -20px 0 0 -20px;
opacity: 0; opacity: 0;
position: absolute; position: absolute;
top: 20%; top: 24%;
width: 30px; width: 40px;
animation: pulsate 2s ease-in-out;
animation: pulsate 1s ease-out;
animation-iteration-count: infinite; animation-iteration-count: infinite;
} }
.loadingmessage {
left: 1%;
position: absolute;
top: 19%;
color: #ffffff;
}
@keyframes pulsate { @keyframes pulsate {
0% { 0% {
transform: scale(.1); transform: scale(.1);
...@@ -286,3 +292,7 @@ a { ...@@ -286,3 +292,7 @@ a {
} }
.tooltip { pointer-events: none; } .tooltip { pointer-events: none; }
.navbar-custom {
background-color: rgba(78,137,164,.4);
}
...@@ -82,13 +82,20 @@ EOF; ...@@ -82,13 +82,20 @@ EOF;
} }
if (!$stop) { if (!$stop) {
$link = 'https://' . $_domain . '/nodeinfo/1.0'; $nodeinfo_meta = curl("https://{$_domain}/.well-known/nodeinfo");
$nodeinfo = curl('https://' . $_domain . '/.well-known/nodeinfo');
if ($info = json_decode($nodeinfo['body'] ?: '', true)) { // Default link to fetch node info.
$link = max($info['links'])['href']; $nodeinfo_url = "https://{$_domain}/nodeinfo/1.0";
if ($info = json_decode($nodeinfo_meta['body'] ?: '', true)) {
if (count($info['links'], COUNT_RECURSIVE) === 2) {
$nodeinfo_url = $info['links']['href'];
} else {
$nodeinfo_url = max($info['links'])['href'];
}
} }
$output = curl($link, true); $output = curl($nodeinfo_url, true);
if ($output['body'] && stripos($output['body'], 'openRegistrations') !== false) { if ($output['body'] && stripos($output['body'], 'openRegistrations') !== false) {
echo 'Your pod has ssl and is valid<br>'; echo 'Your pod has ssl and is valid<br>';
...@@ -125,6 +132,6 @@ if (!$stop) { ...@@ -125,6 +132,6 @@ if (!$stop) {
echo 'Data successfully inserted! Your pod will be checked and live on the list in a few hours!'; echo 'Data successfully inserted! Your pod will be checked and live on the list in a few hours!';
} else { } else {
echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="' . $link . '">your /nodeinfo</a>'; echo 'Could not validate your pod, check your setup!<br>Take a look at your <a href="' . $nodeinfo_url . '">nodeinfo</a>';
} }
} }
ALTER TABLE pods ADD protocols jsonb;
\ No newline at end of file
...@@ -32,6 +32,7 @@ CREATE TABLE pods ( ...@@ -32,6 +32,7 @@ CREATE TABLE pods (
latency smallint, latency smallint,
service_xmpp boolean, service_xmpp boolean,
services jsonb, services jsonb,
protocols jsonb,
token text, token text,
publickey text, publickey text,
tokenexpire timestamp, tokenexpire timestamp,
...@@ -96,6 +97,16 @@ CREATE TABLE masterversions ( ...@@ -96,6 +97,16 @@ CREATE TABLE masterversions (
date_checked timestamp DEFAULT current_timestamp date_checked timestamp DEFAULT current_timestamp
); );
CREATE TABLE monthlystats (
id serial8 UNIQUE PRIMARY KEY,
total_users int,
total_posts int,
total_comments int,
total_pods int,
total_uptime int,
date_checked timestamp DEFAULT current_timestamp
);
CREATE TABLE meta ( CREATE TABLE meta (
id serial8 UNIQUE PRIMARY KEY, id serial8 UNIQUE PRIMARY KEY,
name text, name text,
...@@ -110,3 +121,4 @@ INSERT INTO meta (name) VALUES('federation_updated'); ...@@ -110,3 +121,4 @@ INSERT INTO meta (name) VALUES('federation_updated');
INSERT INTO meta (name) VALUES('statstable_updated'); INSERT INTO meta (name) VALUES('statstable_updated');
INSERT INTO meta (name) VALUES('backup'); INSERT INTO meta (name) VALUES('backup');
INSERT INTO meta (name) VALUES('pods_updated'); INSERT INTO meta (name) VALUES('pods_updated');
INSERT INTO meta (name) VALUES('sitemap_updated');
\ No newline at end of file
...@@ -15,31 +15,15 @@ if (!is_cli()) { ...@@ -15,31 +15,15 @@ if (!is_cli()) {
exit; exit;
} }
$softwares = [ $softwares = c('softwares');
'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'friendica' => ['repo' => 'friendica/friendica', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'hubzilla' => ['repo' => 'hubzilla%2fcore', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'],
'pleroma' => ['repo' => 'pleroma%2fpleroma', 'gitsite' => 'git.pleroma.social', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'socialhome' => ['repo' => 'jaywink/socialhome', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'social-relay' => ['repo' => 'jaywink/social-relay', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'writefreely' => ['repo' => 'writeas/writefreely', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'ganggo' => ['repo' => 'ganggo%2fganggo', 'gitsite' => 'git.feneas.org', 'gittype' => 'gitlab', 'devbranch' => ''],
'funkwhale' => ['repo' => 'funkwhale%2ffunkwhale', 'gitsite' => 'code.eliotberriot.com', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'osada' => ['repo' => 'macgirvin%2fosada', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'],
];
$opts = [
'http' => ['method' => 'GET', 'header' => ['User-Agent: Poduptime']],
];
foreach ($softwares as $software => $details) { foreach ($softwares as $software => $details) {
if ($details['gittype'] === 'github') { if ($details['gittype'] === 'github') {
$context = stream_context_create($opts); $rjson = curl('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/releases/latest');
$releasejson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/releases/latest', false, $context)); $releasejson = json_decode($rjson['body'] ?: '');
if ($details['devbranch']) { if ($details['devbranch']) {
$commitjson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/commits/' . $details['devbranch'], false, $context)); $cjson = curl('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/commits/' . $details['devbranch']);
} else { $commitjson = json_decode($cjson['body'] ?: '');
$commitjson = '';
} }
if ($masterversion = $releasejson->tag_name ? str_replace('v', '', $releasejson->tag_name) : '') { if ($masterversion = $releasejson->tag_name ? str_replace('v', '', $releasejson->tag_name) : '') {
try { try {
...@@ -58,12 +42,11 @@ foreach ($softwares as $software => $details) { ...@@ -58,12 +42,11 @@ foreach ($softwares as $software => $details) {
} }
} }
} elseif ($details['gittype'] === 'gitlab') { } elseif ($details['gittype'] === 'gitlab') {
$context = stream_context_create($opts); $rjson = curl('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/tags');
$releasejson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/tags', false, $context)); $releasejson = json_decode($rjson['body'] ?: '');
if ($details['devbranch']) { if ($details['devbranch']) {
$commitjson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/commits/' . $details['devbranch'], false, $context)); $cjson = curl('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/commits/' . $details['devbranch']);
} else { $commitjson = json_decode($cjson['body'] ?: '');
$commitjson = '';
} }
if ($masterversion = $releasejson[0]->name ? str_replace('v', '', $releasejson[0]->name) : '') { if ($masterversion = $releasejson[0]->name ? str_replace('v', '', $releasejson[0]->name) : '') {
try { try {
......
...@@ -15,14 +15,28 @@ if (!is_cli()) { ...@@ -15,14 +15,28 @@ if (!is_cli()) {
exit; exit;
} }
try {
$total_runs = R::getAll("
SELECT
count(value),
to_char(date_created, 'yyyy-mm') as yymm
FROM meta
WHERE name = 'pods_updated'
GROUP BY yymm
");
} catch (\RedBeanPHP\RedException $e) {
debug('Error in SQL query: ' . sprintf($e->getMessage()));
}
try { try {
$monthly_totals = R::getAll(" $monthly_totals = R::getAll("
SELECT SELECT
to_char(date_checked, 'yyyy-mm') AS yymm, to_char(date_checked, 'yyyy-mm') AS yymm,
sum(total_users) / COUNT(DISTINCT CASE WHEN domain = 'diasp.org' THEN id ELSE NULL END) as users, sum(total_users) as users,
sum(local_posts) / COUNT(DISTINCT CASE WHEN domain = 'diasp.org' THEN id ELSE NULL END) as posts, sum(local_posts) as posts,
sum(comment_counts) / COUNT(DISTINCT CASE WHEN domain = 'diasp.org' THEN id ELSE NULL END) as comments, sum(comment_counts) as comments,
count(domain) / COUNT(DISTINCT CASE WHEN domain = 'diasp.org' THEN id ELSE NULL END) as pods, count(domain) as pods,
count(DISTINCT CASE WHEN domain = 'diasp.org' THEN id ELSE NULL END) as oldtotal,
count(nullif(online, false)) as uptime, count(nullif(online, false)) as uptime,
count(nullif(online, true)) as downtime count(nullif(online, true)) as downtime
FROM checks FROM checks
...@@ -36,13 +50,23 @@ foreach ($monthly_totals as $monthly) { ...@@ -36,13 +50,23 @@ foreach ($monthly_totals as $monthly) {
// Format date to timestamp. // Format date to timestamp.
$timestamp = $monthly['yymm'] . '-01 01:01:01-01'; $timestamp = $monthly['yymm'] . '-01 01:01:01-01';
$total = $monthly['oldtotal'];
foreach ($total_runs as $runs) {
if ($monthly['yymm'] === $runs['yymm']) {
$total = $runs['count'];
break;
}
}
if ($total === 0) {
$total = 1;
}
try { try {
$p = R::findOrCreate('monthlystats', ['date_checked' => $timestamp]); $p = R::findOrCreate('monthlystats', ['date_checked' => $timestamp]);
$p['total_users'] = round($monthly['users'] / $total);
$p['total_users'] = $monthly['users']; $p['total_posts'] = round($monthly['posts'] / $total);
$p['total_posts'] = $monthly['posts']; $p['total_comments'] = round($monthly['comments'] / $total);
$p['total_comments'] = $monthly['comments']; $p['total_pods'] = round($monthly['pods'] / $total);
$p['total_pods'] = $monthly['pods'];
if ($monthly['downtime']) { if ($monthly['downtime']) {
$p['total_uptime'] = round($monthly['downtime'] / $monthly['uptime'] * 100); $p['total_uptime'] = round($monthly['downtime'] / $monthly['uptime'] * 100);
} else { } else {
......
...@@ -33,14 +33,9 @@ $foundpods = []; ...@@ -33,14 +33,9 @@ $foundpods = [];
//pulling all nodes for now //pulling all nodes for now
$federationpods = curl('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw'); $federationpods = curl('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw');
if ($pods = json_decode($federationpods['body'] ?: '', true)) { if ($pods = json_decode($federationpods['body'] ?: '', true)) {
;
foreach ($pods['data']['nodes'] ?? [] as $poddata) { foreach ($pods['data']['nodes'] ?? [] as $poddata) {
$protocols = array_column($poddata['protocols'] ?? [], 'name'); $protocols = array_column($poddata['protocols'] ?? [], 'name');
$foundpods[] = strtolower(preg_replace('(^https?://)', '', $poddata['host']));
//limiting to diaspora compatible for now
if (in_array('diaspora', $protocols, true)) {
$foundpods[] = strtolower(preg_replace('(^https?://)', '', $poddata['host']));
}
} }
} }
......
...@@ -29,6 +29,7 @@ if (!is_connected()) { ...@@ -29,6 +29,7 @@ if (!is_connected()) {
$time_start = microtime(true); $time_start = microtime(true);
$debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true)); $debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true));
$init = isset($_GET['init']) || (isset($argv) && in_array('init', $argv, true));
$sqldebug = isset($_GET['sqldebug']) || (isset($argv) && in_array('sqldebug', $argv, true)); $sqldebug = isset($_GET['sqldebug']) || (isset($argv) && in_array('sqldebug', $argv, true));
$develop = isset($_GET['develop']) || (isset($argv) && in_array('develop', $argv, true)); $develop = isset($_GET['develop']) || (isset($argv) && in_array('develop', $argv, true));
$write = !(isset($_GET['nowrite']) || (isset($argv) && in_array('nowrite', $argv, true))); $write = !(isset($_GET['nowrite']) || (isset($argv) && in_array('nowrite', $argv, true)));
...@@ -147,7 +148,7 @@ foreach ($pods as $pod) { ...@@ -147,7 +148,7 @@ foreach ($pods as $pod) {
preg_match_all('((?:\d(.|-)?)+(\.)\d+\.*)', $version, $sversion); preg_match_all('((?:\d(.|-)?)+(\.)\d+\.*)', $version, $sversion);
$shortversion = $sversion[0][0] ?? '0.0.0.0'; $shortversion = $sversion[0][0] ?? '0.0.0.0';
$signup = ($jsonssl->openRegistrations ?? false) === true; $signup = ($jsonssl->openRegistrations ?? false) === true;
$softwarename = $jsonssl->software->name ?? 'unknown'; $softwarename = strtolower($jsonssl->software->name) ?? 'unknown';
$name = $jsonssl->metadata->nodeName ?? $softwarename; $name = $jsonssl->metadata->nodeName ?? $softwarename;
$total_users = $jsonssl->usage->users->total ?? 0; $total_users = $jsonssl->usage->users->total ?? 0;
$active_users_halfyear = $jsonssl->usage->users->activeHalfyear ?? 0; $active_users_halfyear = $jsonssl->usage->users->activeHalfyear ?? 0;
...@@ -160,6 +161,9 @@ foreach ($pods as $pod) { ...@@ -160,6 +161,9 @@ foreach ($pods as $pod) {
if (is_array($jsonssl->services->outbound)) { if (is_array($jsonssl->services->outbound)) {
$services = json_encode($jsonssl->services->outbound); $services = json_encode($jsonssl->services->outbound);
} }
if (is_array($jsonssl->protocols)) {
$protocols = json_encode($jsonssl->protocols);
}
} }