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

3 4
require_once __DIR__ . '/config.php';

5 6
// Cloudflare country code pull.
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
7

dmorley's avatar
cleanup  
dmorley committed
8
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
9 10
$dbh || die('Error in connection: ' . pg_last_error());

11
$sql = "SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,podmin_statement,score,signup,name,country,city,state,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp FROM pods WHERE NOT hidden AND signup ORDER BY weightedscore DESC";
David Morley's avatar
David Morley committed
12

dmorley's avatar
cleanup  
dmorley committed
13
$result = pg_query($dbh, $sql);
14 15
$result || die('Error in SQL query: ' . pg_last_error());

dmorley's avatar
cleanup  
dmorley committed
16
$numrows = pg_num_rows($result);
dmorley's avatar
dmorley committed
17
?>
noplanman's avatar
noplanman committed
18

19
<meta property="og:title" content="<?php echo $numrows; ?> Federated Pods listed, Come see the privacy aware social networks."/>
David Morley's avatar
David Morley committed
20
<div class="hidden-sm-up">Scroll right or rotate device for more</div>
21 22
<div class="table-responsive">
<table class="table table-striped table-sm tablesorter table-hover">
23 24 25
  <thead class="thead-inverse">
  <tr>
    <th><a data-toggle="tooltip" data-placement="bottom" title="A pod is a site for you to set up your account.">Pod</a></th>
26
    <th><a data-toggle="tooltip" data-placement="bottom" title="Percent of the time the pod is online.">Uptime %</a></th>
27
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 6 months on this pod.">Active Users</a></th>
dmorley's avatar
dmorley committed
28 29
    <th><a data-toggle="tooltip" data-placement="bottom" title="Pod location, based on IP Geolocation.">Location</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="External Social Networks this pod can post to.">Services Offered</a></th>
30
    <th><a data-toggle="tooltip" data-placement="bottom" title="More information from the host of this pod.">Info</a></th>
31 32 33
  </tr>
  </thead>
  <tbody>
David Morley's avatar
David Morley committed
34

35 36 37 38 39
  <?php
  while ($row = pg_fetch_array($result)) {
    $verdiff  = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
    $pod_name = htmlentities($row['name'], ENT_QUOTES);
    $tip      = sprintf(
David Morley's avatar
David Morley committed
40
      'Uptime %2$s%% over %1$s months, score is %3$s out of 100.',
41
      $row['monthsmonitored'],
dmorley's avatar
dmorley committed
42
      $row['uptime_alltime'],
43 44
      $row['score']
    );
noplanman's avatar
noplanman committed
45
    echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="text-success url" target="_self" href="/go.php?domain=' . $row['domain'] . '">' . $row['domain'] . '</a></div></td>';
46

dmorley's avatar
dmorley committed
47
    echo '<td>' . $row['uptime_alltime'] . '%</td>';
dmorley's avatar
dmorley committed
48
    if ($row['active_users_halfyear'] > 0) {
dmorley's avatar
cleanup  
dmorley committed
49
    echo '<td data-toggle="tooltip" data-placement="bottom" title="Active users six months: ' . $row['active_users_halfyear'] . ', Active users one month: ' . $row['active_users_monthly'] . '">' . $row['active_users_halfyear'] . '</td>';
dmorley's avatar
dmorley committed
50 51 52
    } else {
    echo '<td data-toggle="tooltip" data-placement="bottom" title="Pod does not share user data."></td>';
    }
noplanman's avatar
noplanman committed
53
    if ($country_code === $row['country']) {
David Morley's avatar
David Morley committed
54
      echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="City: ' . ($row['city'] ?? 'n/a') . ', State: ' . ($row['state'] ?? 'n/a') . '"><b>' . $row['country'] . '</b></td>';
55
    } else {
David Morley's avatar
David Morley committed
56
      echo '<td data-toggle="tooltip" data-placement="bottom" title="City: ' . ($row['city'] ?? 'n/a') . ', State: ' . ($row['state'] ?? 'n/a') . '">' . $row['country'] . '</td>';
57 58
    }
    echo '<td>';
noplanman's avatar
noplanman committed
59 60 61 62
    $row['service_facebook'] === 't' && print '<div class="smlogo smlogo-facebook" title="Publish to Facebook"></div>';
    $row['service_twitter'] === 't' && print '<div class="smlogo smlogo-twitter" title="Publish to Twitter"></div>';
    $row['service_tumblr'] === 't' && print '<div class="smlogo smlogo-tumblr" title="Publish to Tumblr"></div>';
    $row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"  title="Publish to WordPress"></div>';
63
    $row['service_xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div></td>';
David Morley's avatar
David Morley committed
64
    echo '<td>' . ($row['podmin_statement'] ? '<a tabindex="0" data-toggle="popover" data-trigger="focus" data-placement="left" title="Podmin Statement" data-html="true" data-content="' . htmlentities($row['podmin_statement'], ENT_QUOTES) . '">&#128172;</a>' : '&nbsp;') . '</td></tr>';
65 66 67
  }
  ?>
  </tbody>
68
</table>
69
</div>