show.php 3.72 KB
Newer Older
dmorley's avatar
dmorley committed
1
<?php
2
$tt = 0;
3 4
require_once __DIR__ . '/config.php';

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

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

11 12
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY uptimelast7 DESC";

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

dmorley's avatar
dmorley committed
16
$numrows = pg_num_rows($result);
dmorley's avatar
dmorley committed
17
?>
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 23 24 25 26 27 28 29 30 31
<table class="table table-striped table-sm tablesorter table-hover" id="myTable">
  <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>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Percent of the time the pod is online for <?php echo date('F') ?>.">Uptime %</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 6 months on this pod.">Active Users</a></th>
    <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>
  </tr>
  </thead>
  <tbody>
David Morley's avatar
David Morley committed
32 33


34 35
  <?php
  while ($row = pg_fetch_array($result)) {
36 37 38
    $tt++;
    if ($row['secure'] === 'true') {
      $scheme = 'https://';
39
      $class  = 'text-success';
David Morley's avatar
David Morley committed
40
//$tip="This pod uses SSL encryption for traffic.";
41
    } else {
42
      $scheme = 'http://';
43
      $class  = 'red';
David Morley's avatar
David Morley committed
44
//$tip="This pod does not offer SSL";
45 46 47 48 49 50 51 52 53 54 55
    }
    $verdiff  = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
    $pod_name = htmlentities($row['name'], ENT_QUOTES);
    $tip      = sprintf(
      'This %1$s pod %2$s has been watched for %3$s months and with an uptime of %4$s%% this month. On a scale of 100 this pod is a %5$s right now',
      $row['softwarename'],
      $pod_name,
      $row['monthsmonitored'],
      $row['uptimelast7'],
      $row['score']
    );
56
    echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="' . $class . ' url" target="_self" href="/go.php?url=' . $scheme . $row['domain'] . '">' . $row['domain'] . '</a></div></td>';
57

58 59
    echo '<td>' . $row['uptimelast7'] . '%</td>';
    echo '<td data-toggle="tooltip" data-placement="bottom" title="active six months: ' . $row['active_users_halfyear'] . ', active one month: ' . $row['active_users_monthly'] . '">' . $row['active_users_halfyear'] . '</td>';
60
    if ($country_code === $row['country']) {
61 62 63 64 65
      echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '"><b>' . $row['country'] . '</b></td>';
    } else {
      echo '<td data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '">' . $row['country'] . '</td>';
    }
    echo '<td>';
66 67 68 69 70
    $row['service_facebook'] === 't' && print '<div class="smlogo smlogo-facebook"></div>';
    $row['service_twitter'] === 't' && print '<div class="smlogo smlogo-twitter"></div>';
    $row['service_tumblr'] === 't' && print '<div class="smlogo smlogo-tumblr"></div>';
    $row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></div>';
    $row['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>';
71 72 73 74 75 76
    echo '</td></tr>';
  }
  pg_free_result($result);
  pg_close($dbh);
  ?>
  </tbody>
77
</table>