show.php 5.39 KB
Newer Older
dmorley's avatar
dmorley committed
1
<?php
2

3 4 5 6 7 8
/**
 * Show pod list.
 */

declare(strict_types=1);

9
use Carbon\Carbon;
10 11
use Poduptime\PodStatus;
use RedBeanPHP\R;
12

noplanman's avatar
noplanman committed
13
defined('PODUPTIME') || die();
14

noplanman's avatar
noplanman committed
15
try {
16 17 18
    $pods = R::getAll('
        SELECT domain, masterversion, shortversion, softwarename, daysmonitored, podmin_statement, score, signup, name, country, countryname, city, state, uptime_alltime, active_users_halfyear, active_users_monthly, service_facebook, service_twitter, service_tumblr, service_wordpress, service_xmpp
        FROM pods
dmorley's avatar
dmorley committed
19
        WHERE signup
20 21 22
            AND status = ?
        ORDER BY weightedscore DESC
    ', [PodStatus::UP]);
noplanman's avatar
noplanman committed
23
} catch (\RedBeanPHP\RedException $e) {
24
    die('Error in SQL query: ' . $e->getMessage());
noplanman's avatar
noplanman committed
25
}
26

dmorley's avatar
dmorley committed
27
?>
noplanman's avatar
noplanman committed
28

29 30
<meta property="og:title" content="<?php echo count($pods); ?> Federated Pods listed, Come see the privacy aware social networks." xmlns="http://www.w3.org/1999/html"/>
<div class="d-md-none">Scroll right or rotate device for more</div>
dmorley's avatar
dmorley committed
31
<div class="table-responsive loadingtable">
dmorley's avatar
dmorley committed
32
    <table class="table table-bordered table-sm tablesorter table-hover">
dmorley's avatar
dmorley committed
33 34
        <thead class="thead-dark">
        <tr>
dmorley's avatar
dmorley committed
35 36 37 38 39 40
            <th><div data-toggle="tooltip" title="A pod is a site for you to set up your account.">Pod</div></th>
            <th><div data-toggle="tooltip" title="Percent of the time the pod is online." data-placeholder="Try: >= 99.94">Uptime %</div></th>
            <th><div data-toggle="tooltip" title="Number of users active last 6 months on this pod.">Active Users</div></th>
            <th><div data-toggle="tooltip" title="Pod location, based on IP Geolocation." data-placeholder="Try: <?php echo $country_code ?: 'US'; ?>">Location</div></th>
            <th><div data-toggle="tooltip" title="External Social Networks this pod can post to." class="filter-false">Services Offered</div></th>
            <th><div data-toggle="tooltip" title="More information from the host of this pod.">Info</div></th>
dmorley's avatar
dmorley committed
41 42 43
        </tr>
        </thead>
        <tbody>
David Morley's avatar
David Morley committed
44

dmorley's avatar
dmorley committed
45 46 47 48
        <?php
        foreach ($pods as $pod) {
            $humanmonitored = Carbon::now()->subDays($pod['daysmonitored'])->diffForHumans(null, true);
            $tip            = "This {$pod['softwarename']} pod's uptime is {$pod['uptime_alltime']}% over {$humanmonitored}.";
dmorley's avatar
dmorley committed
49
            echo '<tr>';
dmorley's avatar
dmorley committed
50
            if (($_COOKIE['domain'] ?? null) === $pod['domain']) {
dmorley's avatar
dmorley committed
51
                echo '<td data-toggle="tooltip" title="This is the last pod you visited from this site. ' . $tip . '" class="bg-secondary"><a class="text-warning url" target="_self" href="/go.php?domain=' . $pod['domain'] . '">' . $pod['domain'] . '</a></td>';
dmorley's avatar
dmorley committed
52
            } else {
dmorley's avatar
dmorley committed
53
                echo '<td data-toggle="tooltip" title="' . $tip . '"><a class="text-success url" target="_self" href="/go.php?domain=' . $pod['domain'] . '">' . $pod['domain'] . '</a></td>';
dmorley's avatar
dmorley committed
54
            }
dmorley's avatar
dmorley committed
55
            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>';
dmorley's avatar
dmorley committed
56
            if ($pod['active_users_halfyear'] > 0) {
dmorley's avatar
dmorley committed
57
                echo '<td data-toggle="tooltip" title="Active users six months: ' . $pod['active_users_halfyear'] . ' Active users one month: ' . $pod['active_users_monthly'] . '">' . $pod['active_users_halfyear'] . '</td>';
dmorley's avatar
dmorley committed
58
            } else {
dmorley's avatar
dmorley committed
59
                echo '<td data-toggle="tooltip" title="Pod does not share user data."></td>';
dmorley's avatar
dmorley committed
60 61
            }
            if ($country_code === $pod['country']) {
dmorley's avatar
dmorley committed
62
                echo '<td class="text-success" data-toggle="tooltip" title="Country: ' . ($pod['countryname'] ?? 'n/a') . '&#0010;City: ' . ($pod['city'] ?? 'n/a') . '&#0010;State: ' . ($pod['state'] ?? 'n/a') . '"><b>' . $pod['country'] . '</b></td>';
dmorley's avatar
dmorley committed
63
            } else {
dmorley's avatar
dmorley committed
64
                echo '<td data-toggle="tooltip" title="Country: ' . ($pod['countryname'] ?? 'n/a') . '&#0010;City: ' . ($pod['city'] ?? 'n/a') . '&#0010;State: ' . ($pod['state'] ?? 'n/a') . '">' . $pod['country'] . '</td>';
dmorley's avatar
dmorley committed
65 66
            }
            echo '<td>';
dmorley's avatar
dmorley committed
67 68 69 70 71
            $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>';
            $pod['service_tumblr'] && print '<div class="smlogo smlogo-tumblr" data-toggle="tooltip" title="Publish to Tumblr"></div>';
            $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>';
dmorley's avatar
dmorley committed
72
            echo '</td>';
73

dmorley's avatar
dmorley committed
74
            $podmin_statement = htmlentities($pod['podmin_statement'] ?? '', ENT_QUOTES);
dmorley's avatar
dmorley committed
75 76
            echo '<td>' . ($podmin_statement ? '<a href="#" data-featherlight="<p>' . $podmin_statement . '</p>">&#128172;</a>' : '&nbsp;') . '</td>';
            echo '</tr>';
dmorley's avatar
dmorley committed
77 78 79 80
        }
        ?>
        </tbody>
    </table>
dmorley's avatar
dmorley committed
81 82 83 84 85 86 87
</div>
<div class="pager">
    <span class="first pagination" title="First page">&laquo;</span>
    <span class="prev pagination" title="Previous page">&lt;</span>
    <span class="pagedisplay"></span>
    <span class="next pagination" title="Next page">&gt;</span>
    <span class="last pagination" title="Last page">&raquo;</span>
88
</div>