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

dmorley's avatar
dmorley committed
5 6
 $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
 if (!$dbh) {
7
     die('Error in connection: ' . pg_last_error());
dmorley's avatar
dmorley committed
8
 }  
9
 $sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore";
dmorley's avatar
dmorley committed
10 11
 $result = pg_query($dbh, $sql);
 if (!$result) {
12
     die('Error in SQL query: ' . pg_last_error());
dmorley's avatar
dmorley committed
13
 }   
noplanman's avatar
noplanman committed
14
$numrows = pg_num_rows($result);
dmorley's avatar
dmorley committed
15
?>
noplanman's avatar
noplanman committed
16 17

<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
18 19
<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
20
<table id="myTable" class="table table-striped table-sm tablesorter table-hover tfont">
dmorley's avatar
dmorley committed
21 22
<thead>
<tr>
David Morley's avatar
David Morley committed
23
<th>Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
dmorley's avatar
dmorley committed
24
<th>Version<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th>
25
<th>Uptime<a class="tipsy" title="Percent of the time the pod is online for <?php echo date('F') ?>.">?</a></th>
David Morley's avatar
David Morley committed
26
<th>ms</th>
dmorley's avatar
dmorley committed
27
<th>Signups</th>
David Morley's avatar
David Morley committed
28 29 30
<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>
dmorley's avatar
dmorley committed
31
<th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th>
David Morley's avatar
David Morley committed
32 33 34 35
<th>Comm<a class="tipsy" title="Number of total comments on this pod.">?</a></th>
<th>Month<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a></th>
<th>Sc<a class="tipsy" title="System Score on a 100 scale">?</a></th>
<th>conn<a class="tipsy" title="">?</a></th>
dmorley's avatar
dmorley committed
36 37 38 39 40 41 42
<th>Delete?<a class="tipsy" title="Delete this pod from DB?">?</a></th>
</tr>
</thead>
<tbody>
<?php
 while ($row = pg_fetch_array($result)) {
$tt=$tt+1;
43 44 45 46
if ($row['secure'] == 'true') {
$method = 'https://';
$class= 'green';
$tip= 'This pod uses SSL encryption for traffic.';}
dmorley's avatar
dmorley committed
47 48

else {
49 50 51
$method = 'http://';
$class= 'red';
$tip= 'This pod does not offer SSL';
dmorley's avatar
dmorley committed
52
} 
53
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
dmorley's avatar
dmorley committed
54 55


56
$pod_name = htmlentities($row['name'], ENT_QUOTES);
noplanman's avatar
noplanman committed
57 58 59 60 61 62 63 64 65
$tip .= sprintf(
  "\n" . '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',
  $pod_name,
  $row['monthsmonitored'],
  $row['responsetimelast7'],
  $row['uptimelast7'],
  $row['dateupdated'],
  $row['score']
);
dmorley's avatar
dmorley committed
66

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

69 70 71 72 73
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';}
dmorley's avatar
dmorley committed
74
else 
75 76
{$version =$row['shortversion'];$pre = 'This pod runs production code';}
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') {$classver = 'green';} elseif ($verdiff > 6) {$classver = 'red';} else {$classver = 'black';}
noplanman's avatar
noplanman committed
77
     echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['longversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
78 79 80 81 82 83 84 85 86 87 88
     echo '<td>' . $row['uptimelast7'] . '</td>';
     echo '<td>' . $row['responsetimelast7'] . '</td>';
if ($row['signup'] == 1) {$signup = 'Open';} else {$signup = 'Closed';}
     echo '<td>' . $signup . '</td>';
     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>';
if (strpos($row['pingdomurl'],
  'pingdom.com')) {$moreurl = $row['pingdomurl'];} else {$moreurl = 'http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl'];}
noplanman's avatar
noplanman committed
89 90 91
     echo '<td><div title="Last Check ' . $row['dateupdated'] . '" class="tipsy"><a target="_self" href="' . $moreurl . '">' . $row['monthsmonitored'] . '</a></div></td>';
     echo '<td>' . $row['score'] . '</td>';
     echo '<td><div class="tipsy" title="' . $row['sslvalid'] . '">con info </td>';
dmorley's avatar
dmorley committed
92 93
?>
<td>
dmorley's avatar
cleanup  
dmorley committed
94
<form method="post" action="db/kill.php"  target="_blank">
noplanman's avatar
noplanman committed
95 96 97
<input name="comments" value="<?php echo $row['sslvalid']; ?>" size=10>
<input name="domain" value="<?php echo $row['domain']; ?>" type="hidden">
<input name="adminkey" value="<?php echo $_COOKIE['adminkey']; ?>" type="hidden">
dmorley's avatar
dmorley committed
98 99 100
<input name="action" type="radio" value="warn">warn
<input name="action" type="radio" value="delete">delete
<input type="submit" value="Process">
dmorley's avatar
dmorley committed
101 102 103
</form>
</td>
<?php
noplanman's avatar
noplanman committed
104
     echo '</td></tr>';
dmorley's avatar
dmorley committed
105 106 107 108 109 110
 }
 pg_free_result($result);       
 pg_close($dbh);
?>
</tbody>
</table>