cleanup.php 5.33 KB
Newer Older
dmorley's avatar
dmorley committed
1
<?php
2 3
require_once __DIR__ . '/config.php';

4
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
5 6
$dbh || die('Error in connection: ' . pg_last_error());

dmorley's avatar
latent  
dmorley committed
7
$sql    = "SELECT domain,masterversion,shortversion,softwarename,monthsmonitored,score,signup,secure,name,country,city,state,lat,long,uptime_alltime,active_users_halfyear,active_users_monthly,service_facebook,service_twitter,service_tumblr,service_wordpress,service_xmpp,latency,date_updated,ipv6,total_users,local_posts,comment_counts,stats_apikey,userrating,sslvalid FROM pods WHERE score < 50 ORDER BY weightedscore";
8
$result = pg_query($dbh, $sql);
9
$result || die('Error in SQL query: ' . pg_last_error());
noplanman's avatar
noplanman committed
10
$numrows = pg_num_rows($result);
dmorley's avatar
dmorley committed
11
?>
noplanman's avatar
noplanman committed
12

13
<meta property="og:title" content="<?php echo $numrows; ?> #Diaspora Pods listed, Come see the privacy aware social network."/><?php echo $numrows; ?> pods that are open for signup now.
dmorley's avatar
dmorley committed
14 15
<meta charset="utf-8">
<!-- /* 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
16
<table id="myTable" class="table table-striped table-sm tablesorter table-hover tfont">
17 18 19 20 21 22 23 24 25 26 27 28
  <thead>
  <tr>
    <th>Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
    <th>Version<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th>
    <th>Uptime<a class="tipsy" title="Percent of the time the pod is online for <?php echo date('F') ?>.">?</a></th>
    <th>ms</th>
    <th>Signups</th>
    <th>Total<a class="tipsy" title="Number of total users on this pod.">?</a></th>
    <th>Active 6<a class="tipsy" title="Number of users active last 6 months on this pod.">?</a></th>
    <th>Active 1<a class="tipsy" title="Number of users active last 1 month on this pod.">?</a></th>
    <th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th>
    <th>Comm<a class="tipsy" title="Number of total comments on this pod.">?</a></th>
29
    <th>Month<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a></th>
dmorley's avatar
dmorley committed
30
    <th>Sc<a class="tipsy" title="System Score on a 100 scale.">?</a></th>
31 32 33 34 35 36
    <th>conn<a class="tipsy" title="">?</a></th>
    <th>Delete?<a class="tipsy" title="Delete this pod from DB?">?</a></th>
  </tr>
  </thead>
  <tbody>
  <?php
noplanman's avatar
noplanman committed
37
  $tt = 0;
38
  while ($row = pg_fetch_array($result)) {
noplanman's avatar
noplanman committed
39
    $tt++;
40
    $verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
dmorley's avatar
dmorley committed
41

42
    $pod_name = htmlentities($row['name'], ENT_QUOTES);
43 44
    $tip      = sprintf(
      'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of -20 to +20 this pod is a %6$s right now',
45 46
      $pod_name,
      $row['monthsmonitored'],
dmorley's avatar
latent  
dmorley committed
47
      $row['latency'],
dmorley's avatar
dmorley committed
48
      $row['uptime_alltime'],
49
      $row['date_updated'],
50 51
      $row['score']
    );
dmorley's avatar
dmorley committed
52

noplanman's avatar
noplanman committed
53
    echo '<tr><td><a class="text-success" target="_self" href="https://' . $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>';
dmorley's avatar
dmorley committed
54

55 56 57 58 59 60 61 62 63 64
    if (stristr($row['shortversion'], 'head')) {
      $version = '.dev';
      $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';
    }
noplanman's avatar
noplanman committed
65
    if ($row['shortversion'] === $row['masterversion'] && $row['shortversion'] !== '') {
dmorley's avatar
fixes  
dmorley committed
66
      $classver = 'text-success';
67
    } elseif ($verdiff > 6) {
dmorley's avatar
fixes  
dmorley committed
68
      $classver = 'text-warning';
69 70 71
    } else {
      $classver = 'black';
    }
72
    echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
dmorley's avatar
dmorley committed
73
    echo '<td>' . $row['uptime_alltime'] . '</td>';
dmorley's avatar
latent  
dmorley committed
74
    echo '<td>' . $row['latency'] . '</td>';
75
    echo '<td>' . ($row['signup'] === 't' ? 'Open' : 'Closed') . '</td>';
76 77 78 79 80
    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>';
noplanman's avatar
noplanman committed
81
    $moreurl = 'https://api.uptimerobot.com/getMonitors?format=json&noJsonCallback=1&customUptimeRatio=7-30-60-90&apiKey=' . $row['stats_apikey'];
82
    echo '<td><div title="Last Check ' . $row['date_updated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>';
83
    echo '<td>' . $row['score'] . '</td>';
84
    echo '<td><div class="tipsy" title="' . $row['sslvalid'] . '">con info</td>';
85 86 87
    ?>
    <td>
      <form method="post" action="db/kill.php" target="_blank">
88 89 90 91 92
        <input type="hidden" name="domain" value="<?php echo $row['domain']; ?>">
        <input type="hidden" name="adminkey" value="<?php echo $_COOKIE['adminkey']; ?>">
        <label>Comments<input name="comments" value="<?php echo $row['sslvalid']; ?>" size="10"></label>
        <label><input type="radio" name="action" value="warn">warn</label>
        <label><input type="radio" name="action" value="delete">delete</label>
93 94 95 96
        <input type="submit" value="Process">
      </form>
    </td>
    <?php
97
    echo '</tr>';
98 99 100
  }
  ?>
  </tbody>
dmorley's avatar
dmorley committed
101
</table>