Commit a94ae102 authored by David Morley's avatar David Morley

Merge branch 'develop' of https://git.feneas.org/diasporg/Poduptime into develop

parents c81adfbb c0f90add
......@@ -3,6 +3,10 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
## [Unreleased]
### Added
- Added bootstrapping to simplify initialisation of config and database
- Config syntax has changed to array style (#155)
- Added `pghost` config to set database port
- Added `CONTRIBUTING.md`
### Changed
- Introduce proper changelog format (#189)
- Moved DB migration scripts into `db` folder
......
# How To Contribute
## Workflow
* Fork Git Repo https://git.feneas.org/diasporg/Poduptime
* Pull Git
* Create a topic branch to work from
* Commit and push your branch up
* Create a Merge Request to the develop branch
## Guidelines
* Note your changes in [`CHANGELOG.md`] following https://keepachangelog.com
* Create any necessary DB migration script in [`db/migrations`] and note them in the changelog.
* Update [`README.md`] with needed changes
* Update the [Wiki] with API changes
* Write your tests and validate them before you do your MR
## Coding Style
* PHP follows [PSR-2]
* CSS follows [CSSLint]
* JS follows [ESLint]
[`README.md`]: https://git.feneas.org/diasporg/Poduptime/blob/master/README.md
[`CHANGELOG.md`]: https://git.feneas.org/diasporg/Poduptime/blob/master/CHANGELOG.md
[`db/migrations`]: https://git.feneas.org/diasporg/Poduptime/tree/master/db/migrations
[Wiki]: https://git.feneas.org/diasporg/Poduptime/wikis/home
[PSR-2]: https://www.php-fig.org/psr/psr-2/
[CSSLint]: https://github.com/CSSLint/csslint
[ESLint]: https://eslint.org/docs/rules/
<?php
/**
* Boot the application, loading config and database connection.
*/
declare(strict_types=1);
use RedBeanPHP\R;
/**
......
......@@ -2,16 +2,16 @@
## New install
When setting up a new install, import [`db/tables.sql`][tables.sql] and do not perform any migrations!
When setting up a new install, import [`db/tables.sql`] and do not perform any migrations!
## Migrating
If you are upgrading your existing installation, execute the necessary migrations scripts found in [`db/migrations`][migrations].
If you are upgrading your existing installation, execute the necessary migrations scripts found in [`db/migrations`].
## API v1
To support the original API v1 you should import [`db/pods_apiv1.sql`][pods_apiv1.sql] into your DB as often as you want your API updated.
To support the original API v1 you should import [`db/pods_apiv1.sql`] into your DB as often as you want your API updated.
[tables.sql] https://git.feneas.org/diasporg/Poduptime/blob/master/db/tables.sql
[migrations] https://git.feneas.org/diasporg/Poduptime/tree/master/db/migrations
[pods_apiv1.sql] https://git.feneas.org/diasporg/Poduptime/blob/master/db/pods_apiv1.sql
[`db/tables.sql`]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/tables.sql
[`db/migrations`]: https://git.feneas.org/diasporg/Poduptime/tree/master/db/migrations
[`db/pods_apiv1.sql`]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/pods_apiv1.sql
......@@ -94,28 +94,24 @@ foreach ($pods as $pod) {
// Default link to fetch node info.
$link = "https://{$domain}/nodeinfo/1.0";
if (($infos = @file_get_contents("https://{$domain}/.well-known/nodeinfo")) !== false) {
$info = json_decode($infos, true);
extract(_curl("https://{$domain}/.well-known/nodeinfo"));
$outputwellknown = $curl_body;
if ($outputwellknown !== false) {
$info = json_decode($outputwellknown, true);
$link = max($info['links'])['href'];
}
_debug('Nodeinfo link', $link);
extract(_curl($link));
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, $link);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($chss, CURLOPT_TIMEOUT, 30);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_CERTINFO, 1);
curl_setopt($chss, CURLOPT_CAINFO, c('cafullpath'));
$outputssl = curl_exec($chss);
$outputsslerror = curl_error($chss);
$info = curl_getinfo($chss, CURLINFO_CERTINFO);
$conntime = curl_getinfo($chss, CURLINFO_CONNECT_TIME);
$nstime = curl_getinfo($chss, CURLINFO_NAMELOOKUP_TIME);
$outputssl = $curl_body;
$outputsslerror = $curl_error;
$info = $curl_info;
$conntime = $curl_conntime;
$nstime = $curl_nstime;
$latency = $conntime - $nstime;
$sslexpire = $info[0]['Expire date'] ?? null;
curl_close($chss);
_debug('Nodeinfo output', $outputssl, true);
_debug('Nodeinfo output error', $outputsslerror, true);
......@@ -252,12 +248,14 @@ foreach ($pods as $pod) {
$d = new DOMDocument;
libxml_use_internal_errors(true);
$d->loadHTMLFile('https://' . $domain);
extract(_curl("https://{$domain}/"));
$outputbody = $curl_body;
($outputbody ? $d->loadHTML($outputbody) : $d->loadHTML('<html></html>'));
$body = $d->getElementsByTagName('html')->item(0);
if ($body) {
$ld = new Language;
$detectedlanguage = strtoupper(key($ld->detect($body->nodeValue)->bestResults()->close()));
$detectedlanguage = key($ld->detect($body->nodeValue)->bestResults()->close());
} else {
$score -= 1;
$detectedlanguage = null;
......@@ -448,3 +446,24 @@ function _debug($label, $var = null, $dump = false)
printf('%s: %s%s', $label, $output, $newline);
}
function _curl($url)
{
global $cafullpath;
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, $url);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($chss, CURLOPT_TIMEOUT, 20);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_CERTINFO, 1);
curl_setopt($chss, CURLOPT_CAINFO, $cafullpath);
return [
'curl_body' => curl_exec($chss),
'curl_error' => curl_error($chss),
'curl_info' => curl_getinfo($chss, CURLINFO_CERTINFO),
'curl_conntime' => curl_getinfo($chss, CURLINFO_CONNECT_TIME),
'curl_nstime' => curl_getinfo($chss, CURLINFO_NAMELOOKUP_TIME)
];
curl_close($chss);
}
......@@ -38,7 +38,7 @@ $(document).ready(function () {
$('table').trigger('filterReset');
});
$('.columnsadvanced').on('click', function () {
$('table').trigger('refreshColumnSelector', ['columns', [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 28]]);
$('table').trigger('refreshColumnSelector', ['columns', [2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 28]]);
$('#colSelect1').prop('checked', false);
$('.columnSelectorWrapper').show().css('display', 'inline-block');
$('.columnssimple').show().css('display', 'inline-block');
......@@ -57,7 +57,7 @@ $(document).ready(function () {
if (input) {
columns[0] = input;
}
columns[7] = 'Y';
columns[7] = 'Yes';
$('table').trigger('search', [columns]);
$('.pagerhidden').delay(900).show(200);
$('[data-toggle="tooltip"]').tooltip();
......
......@@ -56,11 +56,11 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
<th data-priority="1" class="columnSelector-disable"><div data-toggle="tooltip" title="A pod is a site for you to set up your account.">Pod</div></th>
<th class="columnSelector-false"><div>Name</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Version of software this pod runs">Version</div></th>
<th class="columnSelector-false" data-priority="3"><div data-toggle="tooltip" title="Type of software this pod runs">Software</div></th>
<th class="columnSelector-false filter-select" data-priority="3"><div data-toggle="tooltip" title="Type of software this pod runs">Software</div></th>
<th data-priority="1"><div data-toggle="tooltip" title="Percent of the time the pod is online.">Uptime</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Does this pod offer ipv6 connection.">IPv6</div></th>
<th class="columnSelector-false filter-select"<div data-toggle="tooltip" title="Does this pod offer ipv6 connection.">IPv6</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Average connection latency time in ms from Los Angeles.">Latency</div></th>
<th data-priority="2"><div data-toggle="tooltip" title="Does this pod allow new users.">Signups</div></th>
<th class="filter-select" data-priority="2"><div data-toggle="tooltip" title="Does this pod allow new users.">Signups</div></th>
<th data-priority="2" data-selector-name="Total Users"><div data-toggle="tooltip" title="Number of total users on this pod.">Users</div></th>
<th class="columnSelector-false" data-selector-name="Users last 6 months"><div data-toggle="tooltip" title="Number of users active last 6 months on this pod.">6m</div></th>
<th class="columnSelector-false" data-selector-name="Users last 1 month"><div data-toggle="tooltip" title="Number of users active last 1 month on this pod.">1m</div></th>
......@@ -69,18 +69,18 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
<th class="columnSelector-false"><div data-toggle="tooltip" title="How many months have we been watching this pod." data-placeholder="Try: ! 0">Months</div></th>
<th data-priority="6"><div data-toggle="tooltip" title="User rating for this pod.">Rating</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="System Score on a 100 point scale.">Score</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="System Status.">Status</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Does this domain use DNSSEC.">DNSSEC</div></th>
<th data-priority="1"><div data-toggle="tooltip" title="Pod location, based on IP Geolocation." data-placeholder="Try: <?php echo $country_code ?: 'US'; ?>">Country</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="System Status.">Status</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="Does this domain use DNSSEC.">DNSSEC</div></th>
<th class="filter-select" data-priority="1"><div data-toggle="tooltip" title="Pod location, based on IP Geolocation." data-placeholder="Try: <?php echo $country_code ?: 'US'; ?>">Country</div></th>
<th class="columnSelector-false" data-priority="5"><div data-toggle="tooltip" title="Pod City, based on IP Geolocation.">City</div></th>
<th class="columnSelector-false" data-priority="5"><div data-toggle="tooltip" title="Pod State, based on IP Geolocation.">State</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Pod language detected from their main page text.">Language</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="Pod language detected from their main page text.">Language</div></th>
<th data-priority="3" data-selector-name="All Services"><div data-toggle="tooltip" title="External Social Networks this pod can post to." class="filter-false">Services</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="External post to Facebook.">Facebook</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="External post to Twitter.">Twitter</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="External post to Tumblr.">Tumblr</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="External post to Wordpress.">Wordpress</div></th>
<th class="columnSelector-false"><div data-toggle="tooltip" title="Supports Jabber/XMPP for chat.">XMPP</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="External post to Facebook.">Facebook</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="External post to Twitter.">Twitter</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="External post to Tumblr.">Tumblr</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="External post to Wordpress.">Wordpress</div></th>
<th class="columnSelector-false filter-select"><div data-toggle="tooltip" title="Supports Jabber/XMPP for chat.">XMPP</div></th>
<th data-priority="6" data-selector-name="Podmin Info"><div data-toggle="tooltip" title="Click for more information about this pod from the pod host (podmin).">Info</div></th>
</tr>
</thead>
......
......@@ -57,9 +57,9 @@ foreach ($pods as $pod) {
echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $pod['shortversion'] . ' master version is: ' . ($pod['masterversion'] ?: 'unknown') . '" data-toggle="tooltip">' . $version . '</div></td>';
echo '<td>' . $pod['softwarename'] . '</td>';
echo '<td><a href="#" data-featherlight-variant="table-responsive" data-featherlight="podstat-uptime.php?domain=' . $pod['domain'] . '">' . ($pod['uptime_alltime'] > 0 ? $pod['uptime_alltime'] . '%' : '') . '</a></td>';
echo '<td>' . ($pod['ipv6'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['ipv6'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['latency'] > 0 ? $pod['latency'] : '') . '</td>';
echo '<td>' . ($pod['signup'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['signup'] ? 'Yes' : 'No') . '</td>';
echo '<td><a href="#" data-featherlight-variant="table-responsive" data-featherlight="podstat-counts.php?domain=' . $pod['domain'] . '">' . ($pod['total_users'] > 0 ? $pod['total_users'] : '') . '</a></td>';
echo '<td>' . ($pod['active_users_halfyear'] > 0 ? $pod['active_users_halfyear'] : '') . '</td>';
echo '<td>' . ($pod['active_users_monthly'] > 0 ? $pod['active_users_monthly'] : '') . '</td>';
......@@ -69,7 +69,7 @@ foreach ($pods as $pod) {
echo '<td><a href="#" data-featherlight-variant="table-responsive" data-featherlight="rate.php?domain=' . $pod['domain'] . '">' . $pod['userrating'] . '</a></td>';
echo '<td><div>' . $pod['score'] . '</div></td>';
echo '<td><div>' . PodStatus::getKey((int) $pod['status']) . '</div></td>';
echo '<td>' . ($pod['dnssec'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['dnssec'] ? 'Yes' : 'No') . '</td>';
if ($country_code === $pod['country']) {
echo '<td class="text-success" data-toggle="tooltip" title="Country: ' . ($pod['countryname'] ?? 'n/a') . ' City: ' . ($pod['city'] ?? 'n/a') . ' State: ' . ($pod['state'] ?? 'n/a') . '"><b>' . $pod['country'] . '</b></td>';
} else {
......@@ -77,7 +77,7 @@ foreach ($pods as $pod) {
}
echo '<td>' . $pod['city'] . '</td>';
echo '<td>' . $pod['state'] . '</td>';
echo '<td>' . ($pod['detectedlanguage'] ?: '') . '</td>';
echo '<td>' . ($pod['detectedlanguage'] ? strtoupper($pod['detectedlanguage']) : '') . '</td>';
echo '<td class="text-truncate">';
$pod['service_facebook'] && print '<div class="smlogo smlogo-facebook" data-toggle="tooltip" title="Publish to Facebook"></div>';
$pod['service_twitter'] && print '<div class="smlogo smlogo-twitter" data-toggle="tooltip" title="Publish to Twitter"></div>';
......@@ -85,11 +85,11 @@ foreach ($pods as $pod) {
$pod['service_wordpress'] && print '<div class="smlogo smlogo-wordpress" data-toggle="tooltip" title="Publish to WordPress"></div>';
$pod['service_xmpp'] && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" data-toggle="tooltip" title="XMPP chat server" alt="XMPP chat server"></div>';
echo '</td>';
echo '<td>' . ($pod['service_facebook'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['service_twitter'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['service_tumblr'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['service_wordpress'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['service_xmpp'] ? 'Y' : 'N') . '</td>';
echo '<td>' . ($pod['service_facebook'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['service_twitter'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['service_tumblr'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['service_wordpress'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . ($pod['service_xmpp'] ? 'Yes' : 'No') . '</td>';
$podmin_statement = htmlentities($pod['podmin_statement'] ?? '', ENT_QUOTES);
echo '<td>' . ($podmin_statement ? '<a href="#" data-featherlight="<p>' . $podmin_statement . '</p>">&#128172;</a>' : '&nbsp;') . '</td></tr>';
......
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