singleview.php 2.6 KB
Newer Older
dmorley's avatar
dmorley committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php

/**
 * This is just a single pod data pull for /domain.tld page
 */

declare(strict_types=1);

use RedBeanPHP\R;

// Required parameters.
($_domain = $input ?? null) || die('no domain given');

require_once __DIR__ . '/boot.php';

$iso = new Matriphe\ISO639\ISO639;

try {
    $pod = R::getRow('
        SELECT domain, podmin_statement, shortversion, softwarename, monthsmonitored, score, name, countryname, city, state, detectedlanguage, uptime_alltime, active_users_halfyear, services, service_xmpp, latency, total_users, local_posts, comment_counts, userrating, status, lat, long
        FROM pods
        WHERE domain = ?
    ', [$_domain]);
} catch (\RedBeanPHP\RedException $e) {
    die('Error in SQL query: ' . $e->getMessage());
}

echo '<h1>Poduptime report for ' . $pod['domain'] . ' </h1><br>';

echo '<h2>This pod or node runs ' . $pod['softwarename'] . ' software version ' . $pod['shortversion'] . ' </h2><br>';
echo 'Performance score for this pod is  ' . $pod['score'] . ' out of 100<br>';
echo 'Detected language of this pod is ' . ($pod['detectedlanguage'] ? $iso->languageByCode1($pod['detectedlanguage']) : '') . '<br>';
echo '<br>';
echo 'Uptime since we started monitoring this pod ' . $pod['monthsmonitored'] . ' months ago is <a href="#" class="green" data-featherlight="/podstat-uptime.php?domain=' . $pod['domain'] . '">' . $pod['uptime_alltime'] . '</a> percent<br>';
echo 'Response Time from our monitoring server in Los Angeles is  ' . $pod['latency'] . ' milliseconds<br>';
echo 'This pod has <a href="#" class="green" data-featherlight="podstat-counts.php?domain=' . $pod['domain'] . '">' . $pod['total_users'] . '</a> total users with ' . $pod['active_users_halfyear'] . ' active the last 6 months, users have posted ' . $pod['local_posts'] . ' times and commented ' . $pod['comment_counts'] . ' times<br>';
echo 'Users rate this pod <a href="#" class="green" data-featherlight-variant="table-responsive" data-featherlight="rate.php?domain=' . $pod['domain'] . '">' . $pod['userrating'] . '</a> out of 10<br>';
echo 'Services this pod offers are: ';
$services = json_decode($pod['services'] ?? '[]') ?: [];
($pod['service_xmpp'] ?? false) && $services[] = 'xmpp';
echo implode(', ', $services);
echo '<br><br>';
echo 'Server Country: ' . $pod['countryname'] . '<br>';
echo 'Server State: ' . $pod['state'] . '<br>';
echo 'Server City: ' . $pod['city'] . '<br>';
echo 'Server Latitude: ' . $pod['lat'] . '<br>';
echo 'Server Longitude: ' . $pod['long'] . '<br>';
echo '<br>';
if ($pod['podmin_statement']) {
    echo 'The host of the pod would like you to know<br><b><i> ' . $pod['podmin_statement'] . ' </i></b><br>';
}