cleanup.php 5.14 KB
Newer Older
1
<?php
2

noplanman's avatar
noplanman committed
3
use RedBeanPHP\R;
4

noplanman's avatar
noplanman committed
5 6 7 8 9 10 11 12 13 14 15 16
defined('PODUPTIME') || die();

try {
  $pods = R::getAll('
    SELECT domain, masterversion, shortversion, monthsmonitored, score, signup, name, uptime_alltime, active_users_halfyear, active_users_monthly, latency, date_updated, total_users, local_posts, comment_counts, stats_apikey, sslvalid
    FROM pods
    WHERE score < 50
    ORDER BY weightedscore ASC
  ');
} catch (\RedBeanPHP\RedException $e) {
  die('Error in SQL query: ' . $e->getMessage());
}
17
?>
18

noplanman's avatar
noplanman committed
19
<meta property="og:title" content="<?php echo count($pods); ?> #Diaspora Pods listed, Come see the privacy aware social network."/><?php echo count($pods); ?> pods that are open for signup now.
20 21
<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. */ -->
22
<div class="table-responsive">
23
<table class="table table-striped table-sm tablesorter-bootstrap table-hover tfont">
24 25 26 27 28 29 30 31 32 33 34 35
  <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>
36
    <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
37
    <th>Sc<a class="tipsy" title="System Score on a 100 scale.">?</a></th>
38 39 40 41 42 43
    <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
44
  $tt = 0;
noplanman's avatar
noplanman committed
45 46

  foreach ($pods as $pod) {
47
    $tt++;
noplanman's avatar
noplanman committed
48
    $verdiff = (int) str_replace('.', '', $pod['masterversion']) - (int) str_replace('.', '', $pod['shortversion']);
49

noplanman's avatar
noplanman committed
50
    $pod_name = htmlentities($pod['name'], ENT_QUOTES);
51 52
    $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',
53
      $pod_name,
noplanman's avatar
noplanman committed
54 55 56 57 58
      $pod['monthsmonitored'],
      $pod['latency'],
      $pod['uptime_alltime'],
      $pod['date_updated'],
      $pod['score']
59
    );
60

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

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