Commit bba9de24 authored by David Morley's avatar David Morley Committed by GitHub

Merge pull request #51 from noplanman/cleaner_php

Clean up most of the PHP code.
parents 563b338b 1b07a757
...@@ -7,12 +7,10 @@ require_once __DIR__ . '/config.php'; ...@@ -7,12 +7,10 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
if ($_GET['format'] === 'georss') {
if ($_GET['format'] == 'georss') {
echo <<<EOF echo <<<EOF
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" <feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
xmlns:georss="http://www.georss.org/georss">
<title>Diaspora Pods</title> <title>Diaspora Pods</title>
<subtitle>IP Locations of Diaspora pods on podupti.me</subtitle> <subtitle>IP Locations of Diaspora pods on podupti.me</subtitle>
<link href="http://podupti.me/"/> <link href="http://podupti.me/"/>
...@@ -25,7 +23,7 @@ EOF; ...@@ -25,7 +23,7 @@ EOF;
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip = sprintf( $summary = 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 100 this pod is a %6$s right now', '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 100 this pod is a %6$s right now',
$pod_name, $pod_name,
$row['monthsmonitored'], $row['monthsmonitored'],
...@@ -34,19 +32,15 @@ EOF; ...@@ -34,19 +32,15 @@ EOF;
$row['dateupdated'], $row['dateupdated'],
$row['score'] $row['score']
); );
if ($row['secure'] == 'true') { $scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
$method = 'https://';
} else {
$method = 'http://';
}
echo <<<EOF echo <<<EOF
<entry> <entry>
<title>{$method}{$row['domain']}</title> <title>{$scheme}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/> <link href="{$scheme}{$row['domain']}"/>
<id>urn:{$row['domain']}</id> <id>urn:{$row['domain']}</id>
<summary>Pod Location is: {$row['country']} <summary>Pod Location is: {$row['country']}
&#xA; &#xA;
{$tip}</summary> {$summary}</summary>
<georss:point>{$row['lat']} {$row['long']}</georss:point> <georss:point>{$row['lat']} {$row['long']}</georss:point>
<georss:featureName>{$row['domain']}</georss:featureName> <georss:featureName>{$row['domain']}</georss:featureName>
</entry> </entry>
...@@ -54,18 +48,21 @@ EOF; ...@@ -54,18 +48,21 @@ EOF;
EOF; EOF;
} }
echo '</feed>'; echo '</feed>';
} elseif ($_GET['format'] == 'json') { } elseif ($_GET['format'] === 'json') {
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods'; $sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this //json output, thx Vipul A M for fixing this
header('Content-type: application/json'); header('Content-type: application/json');
$rows = array_values(pg_fetch_all($result));
$obj->podcount = $numrows; $numrows = pg_num_rows($result);
$obj->pods = $rows; $rows = array_values(pg_fetch_all($result));
if ($_GET['method'] == 'jsonp') { $obj = [
'podcount' => $numrows,
'pods' => $rows,
];
if ($_GET['method'] === 'jsonp') {
print $_GET['callback'] . '(' . json_encode($obj) . ')'; print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else { } else {
print json_encode($obj); print json_encode($obj);
...@@ -78,23 +75,17 @@ EOF; ...@@ -78,23 +75,17 @@ EOF;
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up') { // $status = $row['status'] === 'up' ? 'Online' : 'Offline';
$status = 'Online'; // $scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
} else { // $class = $row['secure'] === 'true' ? 'green' : 'red';
$status = 'Offline';
} $i++ > 0 && print ',';
if ($row['secure'] == 'true') { printf(
$method = 'https://'; '%1$s Up %2$s%% This Month - Located in: %3$s',
$class = 'green'; $row['domain'],
} else { $row['uptimelast7'],
$method = 'http://'; $row['country']
$class = 'red'; );
}
echo $row['domain'] . ' Up ' . $row['uptimelast7'] . '% This Month - Located in: ' . $row['country'];
if ($i < ($numrows - 1)) {
echo ',';
}
$i ++;
} }
pg_free_result($result); pg_free_result($result);
......
<?php <?php
$tt = 0;
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
...@@ -37,20 +36,20 @@ $numrows = pg_num_rows($result); ...@@ -37,20 +36,20 @@ $numrows = pg_num_rows($result);
</thead> </thead>
<tbody> <tbody>
<?php <?php
$tt = 0;
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$tt = $tt + 1; $tt++;
if ($row['secure'] == 'true') { if ($row['secure'] === 'true') {
$method = 'https://'; $scheme = 'https://';
$class = 'green'; $class = 'green';
$tip = 'This pod uses SSL encryption for traffic.'; $tip = 'This pod uses SSL encryption for traffic.';
} else { } else {
$method = 'http://'; $scheme = 'http://';
$class = 'red'; $class = 'red';
$tip = 'This pod does not offer SSL'; $tip = 'This pod does not offer SSL';
} }
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']); $verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
$tip .= sprintf( $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', "\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',
...@@ -62,7 +61,7 @@ $numrows = pg_num_rows($result); ...@@ -62,7 +61,7 @@ $numrows = pg_num_rows($result);
$row['score'] $row['score']
); );
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>'; echo '<tr><td><a class="' . $class . '" target="_self" href="' . $scheme . $row['domain'] . '">' . $row['domain'] . '<div title="' . $tip . '" class="tipsy" style="display: inline-block">?</div></a></td>';
if (stristr($row['shortversion'], 'head')) { if (stristr($row['shortversion'], 'head')) {
$version = '.dev'; $version = '.dev';
...@@ -74,7 +73,7 @@ $numrows = pg_num_rows($result); ...@@ -74,7 +73,7 @@ $numrows = pg_num_rows($result);
$version = $row['shortversion']; $version = $row['shortversion'];
$pre = 'This pod runs production code'; $pre = 'This pod runs production code';
} }
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') { if ($row['shortversion'] === $row['masterversion'] && $row['shortversion'] !== '') {
$classver = 'green'; $classver = 'green';
} elseif ($verdiff > 6) { } elseif ($verdiff > 6) {
$classver = 'red'; $classver = 'red';
...@@ -84,19 +83,13 @@ $numrows = pg_num_rows($result); ...@@ -84,19 +83,13 @@ $numrows = pg_num_rows($result);
echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['longversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>'; echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['longversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
echo '<td>' . $row['uptimelast7'] . '</td>'; echo '<td>' . $row['uptimelast7'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>'; echo '<td>' . $row['responsetimelast7'] . '</td>';
if ($row['signup'] == 1) { echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</td>';
$signup = 'Open';
} else {
$signup = 'Closed';
}
echo '<td>' . $signup . '</td>';
echo '<td>' . $row['total_users'] . '</td>'; echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>'; echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>'; echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>'; echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['pingdomurl'], if (strpos($row['pingdomurl'], 'pingdom.com')) {
'pingdom.com')) {
$moreurl = $row['pingdomurl']; $moreurl = $row['pingdomurl'];
} else { } else {
$moreurl = 'http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl']; $moreurl = 'http://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $row['pingdomurl'];
......
...@@ -11,7 +11,7 @@ $result = pg_query_params($dbh, $sql, [$_GET['url']]); ...@@ -11,7 +11,7 @@ $result = pg_query_params($dbh, $sql, [$_GET['url']]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') { if ($_GET['format'] === 'json') {
echo json_encode($row); echo json_encode($row);
} else { } else {
echo 'Status: ' . $row['status'] . '<br>'; echo 'Status: ' . $row['status'] . '<br>';
......
...@@ -33,9 +33,9 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi ...@@ -33,9 +33,9 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<a class="navbar-brand" href="#">Poduptime</a> <a class="navbar-brand" href="#">Poduptime</a>
<div id="navbar" class="text-muted collapse"> <div id="navbar" class="text-muted collapse">
<nav class="nav navbar-nav float-xs-left"> <nav class="nav navbar-nav float-xs-left">
<a class="nav-item nav-link<?php $simpleview && print(' active'); ?>" href="/">Simple View</a> <a class="nav-item nav-link<?php $simpleview && print ' active'; ?>" href="/">Simple View</a>
<a class="nav-item nav-link<?php $advancedview && print(' active'); ?>" href="/?advancedview">Advanced View</a> <a class="nav-item nav-link<?php $advancedview && print ' active'; ?>" href="/?advancedview">Advanced View</a>
<a class="nav-item nav-link<?php $mapview && print(' active'); ?>" href="/?mapview">Map View</a> <a class="nav-item nav-link<?php $mapview && print ' active'; ?>" href="/?mapview">Map View</a>
</nav> </nav>
</div> </div>
</nav> </nav>
...@@ -43,13 +43,13 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi ...@@ -43,13 +43,13 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<div class="row"> <div class="row">
<div class="col-sm-3 col-md-2 sidebar"> <div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar"> <ul class="nav nav-sidebar">
<li<?php $simpleview && print(' class="active"'); ?>><a href="/">Simple View<?php $simpleview && print(' <span class="sr-only bg-dark">(current)</span>'); ?></a></li> <li<?php $simpleview && print ' class="active"'; ?>><a href="/">Simple View<?php $simpleview && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
<li<?php $advancedview && print(' class="active"'); ?>><a href="/?advancedview">Advanced View<?php $advancedview && print(' <span class="sr-only bg-dark">(current)</span>'); ?></a></li> <li<?php $advancedview && print ' class="active"'; ?>><a href="/?advancedview">Advanced View<?php $advancedview && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
<li<?php $mapview && print(' class="active"'); ?>><a href="/?mapview">Map View<?php $mapview && print(' <span class="sr-only bg-dark">(current)</span>'); ?></a></li> <li<?php $mapview && print ' class="active"'; ?>><a href="/?mapview">Map View<?php $mapview && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
</ul> </ul>
<ul class="nav nav-sidebar"> <ul class="nav nav-sidebar">
<li<?php $podmin && print(' class="active"'); ?>><a href="/?podmin">Add a pod<?php $podmin && print(' <span class="sr-only bg-dark">(current)</span>'); ?></a></li> <li<?php $podmin && print ' class="active"'; ?>><a href="/?podmin">Add a pod<?php $podmin && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
<li<?php $podminedit && print(' class="active"'); ?>><a href="/?podminedit">Edit a pod<?php $podminedit && print(' <span class="sr-only bg-dark">(current)</span>'); ?></a></li> <li<?php $podminedit && print ' class="active"'; ?>><a href="/?podminedit">Edit a pod<?php $podminedit && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
<li><a href="https://diasporafoundation.org/">Host a pod</a></li> <li><a href="https://diasporafoundation.org/">Host a pod</a></li>
</ul> </ul>
<ul class="nav nav-sidebar"> <ul class="nav nav-sidebar">
...@@ -64,7 +64,7 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi ...@@ -64,7 +64,7 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
(adsbygoogle = window.adsbygoogle || []).push({}); (adsbygoogle = window.adsbygoogle || []).push({});
</script> </script>
<br> <br>
Data last refreshed: <br><?php echo date('F d Y H:i:s.', filemtime($lastfile)) ?> EST Data last refreshed: <br><?php echo date('F d Y H:i:s.', filemtime($lastfile)); ?> EST
</div> </div>
<div class="main col-md-10 offset-md-2"> <div class="main col-md-10 offset-md-2">
<a href="random.php" class="btn btn-sm btn-success">Confused? Auto pick a pod for you.</a> <a href="random.php" class="btn btn-sm btn-success">Confused? Auto pick a pod for you.</a>
...@@ -73,17 +73,17 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi ...@@ -73,17 +73,17 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<div class="table-responsive"> <div class="table-responsive">
<?php <?php
if ($advancedview) { if ($advancedview) {
include('showfull.php'); include_once __DIR__ . '/showfull.php';
} elseif ($mapview) { } elseif ($mapview) {
include('showmap.php'); include_once __DIR__ . '/showmap.php';
} elseif ($podmin) { } elseif ($podmin) {
include('podmin.php'); include_once __DIR__ . '/podmin.php';
} elseif ($podminedit) { } elseif ($podminedit) {
include('podminedit.php'); include_once __DIR__ . '/podminedit.php';
} elseif ($cleanup) { } elseif ($cleanup) {
include('cleanup.php'); include_once __DIR__ . '/cleanup.php';
} else { } else {
include('show.php'); include_once __DIR__ . '/show.php';
} }
?> ?>
</div> </div>
......
...@@ -6,12 +6,8 @@ $dbh || die('Error in connection: ' . pg_last_error()); ...@@ -6,12 +6,8 @@ $dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND uptimelast7 > 95 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1"; $sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND uptimelast7 > 95 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query1: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
if ($row[0]['secure'] == 'true') { $scheme = $row[0]['secure'] === 'true' ? 'https://' : 'http://';
$ssl = 's'; header('Location: http' . $scheme . $row[0]['domain'] . '/users/sign_up');
} else {
$ssl = '';
}
header('Location: http' . $ssl . '://' . $row[0]['domain'] . '/users/sign_up');
<?php <?php
$_GET['domain'] || die('domain not specified'); $_GET['domain'] || die('domain not specified');
$domain = $_GET['domain'];
?> ?>
<html> <html>
<head> <head>
<style type="text/css"> <style type="text/css">
...@@ -23,7 +23,7 @@ $_GET['domain'] || die('domain not specified'); ...@@ -23,7 +23,7 @@ $_GET['domain'] || die('domain not specified');
$('#ratings').hide('slow'); $('#ratings').hide('slow');
}); });
$('#submitrating').click(function () { $('#submitrating').click(function () {
var domain = '<?php echo $_GET['domain']; ?>'; var domain = '<?php echo $domain; ?>';
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'db/saverating.php', url: 'db/saverating.php',
...@@ -58,37 +58,38 @@ $_GET['domain'] || die('domain not specified'); ...@@ -58,37 +58,38 @@ $_GET['domain'] || die('domain not specified');
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM rating_comments WHERE domain = $1"; $sql = "SELECT * FROM rating_comments WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$_GET['domain']]); $result = pg_query_params($dbh, $sql, [$domain]);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
echo '<input id="addrating" class="btn primary" style="float:right;margin-right:15px;" type="submit" value="Add a Rating"><h3>Podupti.me ratings for ' . $_GET['domain'] . ' pod</h3><div id="ratings"><hr>'; echo '<input id="addrating" class="btn primary" style="float:right;margin-right:15px;" type="submit" value="Add a Rating"><h3>Podupti.me ratings for ' . $domain . ' pod</h3><div id="ratings"><hr>';
if (!$numrows) { if (!$numrows) {
echo '<b>This pod has no rating yet!</b>'; echo '<b>This pod has no rating yet!</b>';
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['admin'] == 1) { if ($row['admin'] === '1') {
echo 'Poduptime Approved Comment - User: <b>' . $row['username'] . '</b> Url: <a href="' . $row['userurl'] . '">' . $row['userurl'] . '</a> Rating: <b>' . $row['rating'] . '</b> <br>'; echo 'Poduptime Approved Comment - User: <b>' . $row['username'] . '</b> Url: <a href="' . $row['userurl'] . '">' . $row['userurl'] . '</a> Rating: <b>' . $row['rating'] . '</b> <br>';
echo '<i>' . $row['comment'] . '</i><span class="label" title="id: ' . $row['id'] . '" style="float:right;margin-right:115px;">' . $row['date'] . '</span><hr>'; echo '<i>' . $row['comment'] . '</i><span class="label" title="id: ' . $row['id'] . '" style="float:right;margin-right:115px;">' . $row['date'] . '</span><hr>';
} elseif ($row['admin'] == 0) { } elseif ($row['admin'] === '0') {
echo 'User Comment - User: <b>' . $row['username'] . '</b> Url: <a href="' . $row['userurl'] . '">' . $row['userurl'] . '</a> Rating: <b>' . $row['rating'] . '</b> <br>'; echo 'User Comment - User: <b>' . $row['username'] . '</b> Url: <a href="' . $row['userurl'] . '">' . $row['userurl'] . '</a> Rating: <b>' . $row['rating'] . '</b> <br>';
echo '<i>' . $row['comment'] . '</i><span class="label" title="id: ' . $row['id'] . '" style="float:right;margin-right:115px;">' . $row['date'] . '</span><hr style="margin-top:0;margin-bottom:15px;">'; echo '<i>' . $row['comment'] . '</i><span class="label" title="id: ' . $row['id'] . '" style="float:right;margin-right:115px;">' . $row['date'] . '</span><hr style="margin-top:0;margin-bottom:15px;">';
} }
} }
echo <<<EOF ?>
</div> </div>
<div id="commentform" style="display:none"> <div id="commentform" style="display:none">
Would you like to add a comment?<br> Would you like to add a comment?<br>
Your Name (or Diaspora handle)?<br><input id="username" name="username"><br> <label>Your Name (or Diaspora handle)?<br><input id="username" name="username"></label><br>
Your Profile URL?<br><input id="userurl" name="userurl"><br> <label>Your Profile URL?<br><input id="userurl" name="userurl"></label><br>
Comment<br><textarea id="comment" name="comment"></textarea><br> <label>Comment<br><textarea id="comment" name="comment"></textarea></label><br>
Rating (1-10 scale, 10 high)<br><div id="slider"></div><input class="disabled" disabled="" id="rating" name="rating" value="10"> Rating (1-10 scale, 10 high)<br>
<br><input class="btn primary" id="submitrating" type="submit" value="Submit your Rating"> <div id="slider"></div>
<div class="alert-message warning" id="error" style="display:none"><span id="errortext">Some Error</span></div> <input class="disabled" disabled="" id="rating" name="rating" value="10"><br>
</div> <input class="btn primary" id="submitrating" type="submit" value="Submit your Rating">
EOF; <div class="alert-message warning" id="error" style="display:none">
<span id="errortext">Some Error</span>
pg_free_result($result); </div>
pg_close($dbh);
?>
</div> </div>
<?php
pg_free_result($result);
pg_close($dbh);
...@@ -37,13 +37,13 @@ $numrows = pg_num_rows($result); ...@@ -37,13 +37,13 @@ $numrows = pg_num_rows($result);
<?php <?php
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$tt = $tt + 1; $tt++;
if ($row['secure'] == 'true') { if ($row['secure'] === 'true') {
$method = 'https://'; $scheme = 'https://';
$class = 'text-success'; $class = 'text-success';
//$tip="This pod uses SSL encryption for traffic."; //$tip="This pod uses SSL encryption for traffic.";
} else { } else {
$method = 'http://'; $scheme = 'http://';
$class = 'red'; $class = 'red';
//$tip="This pod does not offer SSL"; //$tip="This pod does not offer SSL";
} }
...@@ -57,31 +57,21 @@ $numrows = pg_num_rows($result); ...@@ -57,31 +57,21 @@ $numrows = pg_num_rows($result);
$row['uptimelast7'], $row['uptimelast7'],
$row['score'] $row['score']
); );
echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="' . $class . ' url" target="_self" href="' . $method . $row['domain'] . '">' . $row['domain'] . '</a></div></td>'; echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="' . $class . ' url" target="_self" href="' . $scheme . $row['domain'] . '">' . $row['domain'] . '</a></div></td>';
echo '<td>' . $row['uptimelast7'] . '%</td>'; 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>'; 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>';
if ($country_code == $row['country']) { if ($country_code === $row['country']) {
echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '"><b>' . $row['country'] . '</b></td>'; echo '<td class="text-success" data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '"><b>' . $row['country'] . '</b></td>';
} else { } else {
echo '<td data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '">' . $row['country'] . '</td>'; echo '<td data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '">' . $row['country'] . '</td>';
} }
echo '<td>'; echo '<td>';
if ($row['service_facebook'] === 't') { $row['service_facebook'] === 't' && print '<div class="smlogo smlogo-facebook"></div>';
echo '<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>';
if ($row['service_twitter'] === 't') { $row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></div>';
echo '<div class="smlogo smlogo-twitter"></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>';
}
if ($row['service_tumblr'] === 't') {
echo '<div class="smlogo smlogo-tumblr"></div>';
}
if ($row['service_wordpress'] === 't') {
echo '<div class="smlogo smlogo-wordpress"></div>';
}
if ($row['xmpp'] === 't') {
echo '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
}
echo '</td></tr>'; echo '</td></tr>';
} }
pg_free_result($result); pg_free_result($result);
......
...@@ -6,7 +6,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); ...@@ -6,7 +6,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$hidden = isset($_GET['hidden']) ? $_GET['hidden'] : null; $hidden = isset($_GET['hidden']) ? $_GET['hidden'] : null;
if ($hidden == 'true') { if ($hidden === 'true') {
$sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY uptimelast7 DESC"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY uptimelast7 DESC";
} else { } else {
$sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC'; $sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC';
...@@ -24,7 +24,7 @@ $numrows = pg_num_rows($result); ...@@ -24,7 +24,7 @@ $numrows = pg_num_rows($result);
<tr> <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="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> <th><a data-toggle="tooltip" data-placement="bottom" title="Version of software this pod runs">Version</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="Percent of the time the pod is online for <?php echo date('F'); ?>.">Uptime</a></th>
<th>IPv6</th> <th>IPv6</th>
<th>Response Time</th> <th>Response Time</th>
<th>Signups</th> <th>Signups</th>
...@@ -43,13 +43,13 @@ $numrows = pg_num_rows($result); ...@@ -43,13 +43,13 @@ $numrows = pg_num_rows($result);
<tbody> <tbody>
<?php <?php
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$tt = $tt + 1; $tt++;
if ($row['secure'] == 'true') { if ($row['secure'] === 'true') {
$method = 'https://'; $scheme = 'https://';
$class = 'green'; $class = 'green';
$tip = 'This pod uses SSL encryption for traffic.'; $tip = 'This pod uses SSL encryption for traffic.';
} else { } else {
$method = 'http://'; $scheme = 'http://';
$class = 'red'; $class = 'red';
$tip = 'This pod does not offer SSL'; $tip = 'This pod does not offer SSL';
} }
...@@ -58,7 +58,7 @@ $numrows = pg_num_rows($result); ...@@ -58,7 +58,7 @@ $numrows = pg_num_rows($result);
$tip .= "\n This {$row['softwarename']} pod {$pod_name} has been watched for {$row['monthsmonitored']} months with an uptime of {$row['uptimelast7']}% this month and a response time average today of {$row['responsetimelast7']}ms was last checked on {$row['dateupdated']}. "; $tip .= "\n This {$row['softwarename']} pod {$pod_name} has been watched for {$row['monthsmonitored']} months with an uptime of {$row['uptimelast7']}% this month and a response time average today of {$row['responsetimelast7']}ms was last checked on {$row['dateupdated']}. ";
$tip .= "On a scale of 100 this pod is a {$row['score']} right now"; $tip .= "On a scale of 100 this pod is a {$row['score']} right now";
echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" class="' . $class . '" target="_self" href="' . $method . $row['domain'] . '">' . $row['domain'] . '</a></td>'; echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" class="' . $class . '" target="_self" href="' . $scheme . $row['domain'] . '">' . $row['domain'] . '</a></td>';
if (stristr($row['shortversion'], 'head')) { if (stristr($row['shortversion'], 'head')) {
$version = '.dev'; $version = '.dev';
...@@ -70,7 +70,7 @@ $numrows = pg_num_rows($result); ...@@ -70,7 +70,7 @@ $numrows = pg_num_rows($result);
$version = $row['shortversion']; $version = $row['shortversion'];
$pre = 'This pod runs production code'; $pre = 'This pod runs production code';
} }
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') { if ($row['shortversion'] === $row['masterversion'] && $row['shortversion'] !== '') {
$classver = 'green'; $classver = 'green';
} elseif ($verdiff > 6) { } elseif ($verdiff > 6) {
$classver = 'red'; $classver = 'red';
...@@ -81,19 +81,13 @@ $numrows = pg_num_rows($result); ...@@ -81,19 +81,13 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['uptimelast7'] . '%</td>'; echo '<td>' . $row['uptimelast7'] . '%</td>';
echo '<td>' . $row['ipv6'] . '</td>'; echo '<td>' . $row['ipv6'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>'; echo '<td>' . $row['responsetimelast7'] . '</td>';
if ($row['signup'] == 1) { echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</td>';
$signup = 'Open';
} else {
$signup = 'Closed';
}
echo '<td>' . $signup . '</td>';
echo '<td>' . $row['total_users'] . '</td>'; echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>'; echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
echo '<td>' . $row['local_posts'] . '</td>'; echo '<td>' . $row['local_posts'] . '</td>';
echo '<td>' . $row['comment_counts'] . '</td>'; echo '<td>' . $row['comment_counts'] . '</td>';
if (strpos($row['pingdomurl'], if (strpos($row['pingdomurl'], 'pingdom.com')) {
'pingdom.com')) {
$moreurl = $row['pingdomurl']; $moreurl = $row['pingdomurl'];
} else { } else {
$moreurl = '/db/showuptimerobot.php?domain=' . $row['domain']; $moreurl = '/db/showuptimerobot.php?domain=' . $row['domain'];
...@@ -107,21 +101,11 @@ $numrows = pg_num_rows($result); ...@@ -107,21 +101,11 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['country'] . '</td>'; echo '<td>' . $row['country'] . '</td>';
echo '<td>'; echo '<td>';
if ($row['service_facebook'] === 't') { $row['service_facebook'] === 't' && print '<div class="smlogo smlogo-facebook"></div>';
echo '<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>';
if ($row['service_twitter'] === 't') { $row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></div>';
echo '<div class="smlogo smlogo-twitter"></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>';
}
if ($row['service_tumblr'] === 't') {
echo '<div class="smlogo smlogo-tumblr"></div>';
}
if ($row['service_wordpress'] === 't') {
echo '<div class="smlogo smlogo-wordpress"></div>';
}
if ($row['xmpp'] === 't') {
echo '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
}
echo '</td></tr>'; echo '</td></tr>';