showfull.php 6.56 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'] ?? '';
David Morley's avatar
David Morley committed
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());

dmorley's avatar
dmorley committed
11
$sql = 'SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,name,country,city,state,lat,long,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp,responsetime,date_updated,ipv6,total_users,local_posts,comment_counts,stats_apikey,userrating FROM pods pods ORDER BY uptime_alltime 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."/>
dmorley's avatar
dmorley committed
20
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
David Morley's avatar
David Morley committed
21
<table id="myTable" class="table table-striped table-sm tablesorter table-hover tfont">
22 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>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Version of software this pod runs">Version</a></th>
26
    <th><a data-toggle="tooltip" data-placement="bottom" title="Percent of the time the pod is online.">Uptime</a></th>
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    <th>IPv6</th>
    <th>Response Time</th>
    <th>Signups</th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of total users on this pod.">Users</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 6 months on this pod.">Active Users 6</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 1 month on this pod.">Active Users 1</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of total posts on this pod.">Posts</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Number of total comments on this pod.">Comments</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="How many months has this pod been online? Click number for more history.">Months</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="User rating for this pod.">Rating</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="System Score on a 100 point scale">Score</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="Pod location, based on IP Geolocation">Country</a></th>
    <th><a data-toggle="tooltip" data-placement="bottom" title="External Social Networks this pod can post to">Services</a></th>
  </tr>
  </thead>
  <tbody>
  <?php
  while ($row = pg_fetch_array($result)) {
    $pod_name = htmlentities($row['name'], ENT_QUOTES);
dmorley's avatar
dmorley committed
46
    $tip = "\n This {$row['softwarename']} pod {$pod_name} has been watched for {$row['monthsmonitored']} months with an overall uptime of {$row['uptime_alltime']}% and a response time average today of {$row['responsetime']}ms was last checked on {$row['dateupdated']}. ";
47
    $tip .= "On a scale of 100 this pod is a {$row['score']} right now";
dmorley's avatar
dmorley committed
48

dmorley's avatar
fixes  
dmorley committed
49
    echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" class="text-success" target="_self" href="/go.php?url=https://' . $row['domain'] . '">' . $row['domain'] . '</a></td>';
dmorley's avatar
dmorley committed
50

David Morley's avatar
David Morley committed
51 52
    if ($row['shortversion'] > $row['masterversion']) {
      $version = $row['shortversion'];
53 54 55 56 57 58 59 60
      $pre     = 'This pod runs pre release development code';
    } elseif (!$row['shortversion']) {
      $version = '0';
      $pre     = 'This pod runs unknown code';
    } else {
      $version = $row['shortversion'];
      $pre     = 'This pod runs production code';
    }
David Morley's avatar
David Morley committed
61 62 63 64
    if (version_compare($row['shortversion'], $row['masterversion'], '=')) {
      $classver = 'text-success';
    } elseif (version_compare($row['shortversion'], $row['masterversion'], '<')) {
      $classver = 'text-warning';
65 66 67
    } else {
      $classver = 'black';
    }
David Morley's avatar
David Morley committed
68
    echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>';
dmorley's avatar
dmorley committed
69
    echo '<td>' . $row['uptime_alltime'] . '%</td>';
dmorley's avatar
dmorley committed
70
    echo '<td>' . ($row['ipv6'] === 't' ? 'Yes' : 'No') . '</td>';
71
    echo '<td>' . $row['responsetime'] . '</td>';
72
    echo '<td>' . ($row['signup'] === 't' ? 'Open' : 'Closed') . '</td>';
73 74 75 76 77
    echo '<td>' . $row['total_users'] . '</td>';
    echo '<td>' . $row['active_users_halfyear'] . '</td>';
    echo '<td>' . $row['active_users_monthly'] . '</td>';
    echo '<td>' . $row['local_posts'] . '</td>';
    echo '<td>' . $row['comment_counts'] . '</td>';
dmorley's avatar
cleanup  
dmorley committed
78
    $moreurl = '/showstats.php?domain=' . $row['domain'];
David Morley's avatar
David Morley committed
79
    echo '<td><div title="Last Check ' . $row['date_updated'] . '" data-toggle="tooltip" data-placement="bottom"><a rel="facebox" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>';
80 81 82
    echo '<td><a rel="facebox" href="rate.php?domain=' . $row['domain'] . '">' . $row['userrating'] . '/10';
    echo '</a></td>';
    echo '<td>' . $row['score'] . '/100</td>';
David Morley's avatar
David Morley committed
83
    if ($country_code === $row['country']) {
dmorley's avatar
dmorley committed
84
      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>';
David Morley's avatar
David Morley committed
85
    } else {
dmorley's avatar
dmorley committed
86
      echo '<td data-toggle="tooltip" data-placement="bottom" title="City: '. ($row['city'] ?? 'n/a') . ' State: ' . ($row['state'] ?? 'n/a') . '">' . $row['country'] . '</td>';
David Morley's avatar
David Morley committed
87
    }
noplanman's avatar
noplanman committed
88
    echo '<td>';
dmorley's avatar
cleanup  
dmorley committed
89 90 91 92
    $row['service_facebook'] === 't' && print '<div class="smlogo smlogo-facebook" title="Publish to Facebook" alt="Publish to Facebook"></div>';
    $row['service_twitter'] === 't' && print '<div class="smlogo smlogo-twitter" title="Publish to Twitter" alt="Publish to Twitter"></div>';
    $row['service_tumblr'] === 't' && print '<div class="smlogo smlogo-tumblr" title="Publish to Tumblr" alt="Publish to Tumblr"></div>';
    $row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"  title="Publish to Wordpress" alt="Publish to Wordpress"></div>';
dmorley's avatar
dmorley committed
93
    $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>';
noplanman's avatar
noplanman committed
94
    echo '</td></tr>';
95 96 97 98 99
  }
  pg_free_result($result);
  pg_close($dbh);
  ?>
  </tbody>
dmorley's avatar
dmorley committed
100
</table>