Commit 1b07a757 authored by noplanman's avatar noplanman

Clean up most of the PHP code.

parent 563b338b
......@@ -7,12 +7,10 @@ require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
if ($_GET['format'] == 'georss') {
if ($_GET['format'] === 'georss') {
echo <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:georss="http://www.georss.org/georss">
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
<title>Diaspora Pods</title>
<subtitle>IP Locations of Diaspora pods on podupti.me</subtitle>
<link href="http://podupti.me/"/>
......@@ -25,7 +23,7 @@ EOF;
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
$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',
$pod_name,
$row['monthsmonitored'],
......@@ -34,19 +32,15 @@ EOF;
$row['dateupdated'],
$row['score']
);
if ($row['secure'] == 'true') {
$method = 'https://';
} else {
$method = 'http://';
}
$scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
echo <<<EOF
<entry>
<title>{$method}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/>
<title>{$scheme}{$row['domain']}</title>
<link href="{$scheme}{$row['domain']}"/>
<id>urn:{$row['domain']}</id>
<summary>Pod Location is: {$row['country']}
&#xA;
{$tip}</summary>
{$summary}</summary>
<georss:point>{$row['lat']} {$row['long']}</georss:point>
<georss:featureName>{$row['domain']}</georss:featureName>
</entry>
......@@ -54,18 +48,21 @@ EOF;
EOF;
}
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';
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this
header('Content-type: application/json');
$rows = array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
$obj->pods = $rows;
if ($_GET['method'] == 'jsonp') {
$numrows = pg_num_rows($result);
$rows = array_values(pg_fetch_all($result));
$obj = [
'podcount' => $numrows,
'pods' => $rows,
];
if ($_GET['method'] === 'jsonp') {
print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else {
print json_encode($obj);
......@@ -78,23 +75,17 @@ EOF;
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up') {
$status = 'Online';
} else {
$status = 'Offline';
}
if ($row['secure'] == 'true') {
$method = 'https://';
$class = 'green';
} else {
$method = 'http://';
$class = 'red';
}
echo $row['domain'] . ' Up ' . $row['uptimelast7'] . '% This Month - Located in: ' . $row['country'];
if ($i < ($numrows - 1)) {
echo ',';
}
$i ++;
// $status = $row['status'] === 'up' ? 'Online' : 'Offline';
// $scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
// $class = $row['secure'] === 'true' ? 'green' : 'red';
$i++ > 0 && print ',';
printf(
'%1$s Up %2$s%% This Month - Located in: %3$s',
$row['domain'],
$row['uptimelast7'],
$row['country']
);
}
pg_free_result($result);
......
<?php
$tt = 0;
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
......@@ -37,20 +36,20 @@ $numrows = pg_num_rows($result);
</thead>
<tbody>
<?php
$tt = 0;
while ($row = pg_fetch_array($result)) {
$tt = $tt + 1;
if ($row['secure'] == 'true') {
$method = 'https://';
$tt++;
if ($row['secure'] === 'true') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
} else {
$method = 'http://';
$scheme = 'http://';
$class = 'red';
$tip = 'This pod does not offer SSL';
}
$verdiff = str_replace('.', '', $row['masterversion']) - str_replace('.', '', $row['shortversion']);
$pod_name = htmlentities($row['name'], ENT_QUOTES);
$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',
......@@ -62,7 +61,7 @@ $numrows = pg_num_rows($result);
$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')) {
$version = '.dev';
......@@ -74,7 +73,7 @@ $numrows = pg_num_rows($result);
$version = $row['shortversion'];
$pre = 'This pod runs production code';
}
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') {
if ($row['shortversion'] === $row['masterversion'] && $row['shortversion'] !== '') {
$classver = 'green';
} elseif ($verdiff > 6) {
$classver = 'red';
......@@ -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>' . $row['uptimelast7'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>';
if ($row['signup'] == 1) {
$signup = 'Open';
} else {
$signup = 'Closed';
}
echo '<td>' . $signup . '</td>';
echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</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')) {
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'];
......
......@@ -11,7 +11,7 @@ $result = pg_query_params($dbh, $sql, [$_GET['url']]);
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') {
if ($_GET['format'] === 'json') {
echo json_encode($row);
} else {
echo 'Status: ' . $row['status'] . '<br>';
......
......@@ -33,9 +33,9 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<a class="navbar-brand" href="#">Poduptime</a>
<div id="navbar" class="text-muted collapse">
<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 $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 $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 $mapview && print ' active'; ?>" href="/?mapview">Map View</a>
</nav>
</div>
</nav>
......@@ -43,13 +43,13 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<div class="row">
<div class="col-sm-3 col-md-2 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 $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 $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 $mapview && print ' class="active"'; ?>><a href="/?mapview">Map View<?php $mapview && print ' <span class="sr-only bg-dark">(current)</span>'; ?></a></li>
</ul>
<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 $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 $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><a href="https://diasporafoundation.org/">Host a pod</a></li>
</ul>
<ul class="nav nav-sidebar">
......@@ -64,7 +64,7 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<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 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>
......@@ -73,17 +73,17 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi
<div class="table-responsive">
<?php
if ($advancedview) {
include('showfull.php');
include_once __DIR__ . '/showfull.php';
} elseif ($mapview) {
include('showmap.php');
include_once __DIR__ . '/showmap.php';
} elseif ($podmin) {
include('podmin.php');
include_once __DIR__ . '/podmin.php';
} elseif ($podminedit) {
include('podminedit.php');
include_once __DIR__ . '/podminedit.php';
} elseif ($cleanup) {
include('cleanup.php');
include_once __DIR__ . '/cleanup.php';
} else {
include('show.php');
include_once __DIR__ . '/show.php';
}
?>
</div>
......
......@@ -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";
$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);
if ($row[0]['secure'] == 'true') {
$ssl = 's';
} else {
$ssl = '';
}
header('Location: http' . $ssl . '://' . $row[0]['domain'] . '/users/sign_up');
$scheme = $row[0]['secure'] === 'true' ? 'https://' : 'http://';
header('Location: http' . $scheme . $row[0]['domain'] . '/users/sign_up');
<?php
$_GET['domain'] || die('domain not specified');
$domain = $_GET['domain'];
?>
<html>
<head>
<style type="text/css">
......@@ -23,7 +23,7 @@ $_GET['domain'] || die('domain not specified');
$('#ratings').hide('slow');
});
$('#submitrating').click(function () {
var domain = '<?php echo $_GET['domain']; ?>';
var domain = '<?php echo $domain; ?>';
$.ajax({
type: 'POST',
url: 'db/saverating.php',
......@@ -58,37 +58,38 @@ $_GET['domain'] || die('domain not specified');
$dbh || die('Error in connection: ' . pg_last_error());
$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());
$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) {
echo '<b>This pod has no rating yet!</b>';
}
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 '<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 '<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 id="commentform" style="display:none">
Would you like to add a comment?<br>
Your Name (or Diaspora handle)?<br><input id="username" name="username"><br>
Your Profile URL?<br><input id="userurl" name="userurl"><br>
Comment<br><textarea id="comment" name="comment"></textarea><br>
Rating (1-10 scale, 10 high)<br><div id="slider"></div><input class="disabled" disabled="" id="rating" name="rating" value="10">
<br><input class="btn primary" id="submitrating" type="submit" value="Submit your Rating">
<div class="alert-message warning" id="error" style="display:none"><span id="errortext">Some Error</span></div>
</div>
EOF;
pg_free_result($result);
pg_close($dbh);
?>
Would you like to add a comment?<br>
<label>Your Name (or Diaspora handle)?<br><input id="username" name="username"></label><br>
<label>Your Profile URL?<br><input id="userurl" name="userurl"></label><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"><br>
<input class="btn primary" id="submitrating" type="submit" value="Submit your Rating">
<div class="alert-message warning" id="error" style="display:none">
<span id="errortext">Some Error</span>
</div>
</div>
<?php
pg_free_result($result);
pg_close($dbh);
......@@ -37,13 +37,13 @@ $numrows = pg_num_rows($result);
<?php
while ($row = pg_fetch_array($result)) {
$tt = $tt + 1;
if ($row['secure'] == 'true') {
$method = 'https://';
$tt++;
if ($row['secure'] === 'true') {
$scheme = 'https://';
$class = 'text-success';
//$tip="This pod uses SSL encryption for traffic.";
} else {
$method = 'http://';
$scheme = 'http://';
$class = 'red';
//$tip="This pod does not offer SSL";
}
......@@ -57,31 +57,21 @@ $numrows = pg_num_rows($result);
$row['uptimelast7'],
$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 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>';
} else {
echo '<td data-toggle="tooltip" data-placement="bottom" title="' . $row['whois'] . '">' . $row['country'] . '</td>';
}
echo '<td>';
if ($row['service_facebook'] === 't') {
echo '<div class="smlogo smlogo-facebook"></div>';
}
if ($row['service_twitter'] === 't') {
echo '<div class="smlogo smlogo-twitter"></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>';
}
$row['service_facebook'] === 't' && print '<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>';
$row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></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>';
echo '</td></tr>';
}
pg_free_result($result);
......
......@@ -6,7 +6,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$hidden = isset($_GET['hidden']) ? $_GET['hidden'] : null;
if ($hidden == 'true') {
if ($hidden === 'true') {
$sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY uptimelast7 DESC";
} else {
$sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC';
......@@ -24,7 +24,7 @@ $numrows = pg_num_rows($result);
<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>
<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>Response Time</th>
<th>Signups</th>
......@@ -43,13 +43,13 @@ $numrows = pg_num_rows($result);
<tbody>
<?php
while ($row = pg_fetch_array($result)) {
$tt = $tt + 1;
if ($row['secure'] == 'true') {
$method = 'https://';
$tt++;
if ($row['secure'] === 'true') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
} else {
$method = 'http://';
$scheme = 'http://';
$class = 'red';
$tip = 'This pod does not offer SSL';
}
......@@ -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 .= "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')) {
$version = '.dev';
......@@ -70,7 +70,7 @@ $numrows = pg_num_rows($result);
$version = $row['shortversion'];
$pre = 'This pod runs production code';
}
if ($row['shortversion'] == $row['masterversion'] && $row['shortversion'] != '') {
if ($row['shortversion'] === $row['masterversion'] && $row['shortversion'] !== '') {
$classver = 'green';
} elseif ($verdiff > 6) {
$classver = 'red';
......@@ -81,19 +81,13 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['uptimelast7'] . '%</td>';
echo '<td>' . $row['ipv6'] . '</td>';
echo '<td>' . $row['responsetimelast7'] . '</td>';
if ($row['signup'] == 1) {
$signup = 'Open';
} else {
$signup = 'Closed';
}
echo '<td>' . $signup . '</td>';
echo '<td>' . ($row['signup'] === '1' ? 'Open' : 'Closed') . '</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')) {
if (strpos($row['pingdomurl'], 'pingdom.com')) {
$moreurl = $row['pingdomurl'];
} else {
$moreurl = '/db/showuptimerobot.php?domain=' . $row['domain'];
......@@ -107,21 +101,11 @@ $numrows = pg_num_rows($result);
echo '<td>' . $row['country'] . '</td>';
echo '<td>';
if ($row['service_facebook'] === 't') {
echo '<div class="smlogo smlogo-facebook"></div>';
}
if ($row['service_twitter'] === 't') {
echo '<div class="smlogo smlogo-twitter"></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>';
}
$row['service_facebook'] === 't' && print '<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>';
$row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress"></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>';
echo '</td></tr>';
}
pg_free_result($result);
......
......@@ -5,7 +5,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'];
$csv = array_map('str_getcsv', file('db/country_latlon.csv'));
foreach ($csv as $cords) {
if ($cords[0] == $country_code) {
if ($cords[0] === $country_code) {
$lat = $cords[1];
$long = $cords[2];
}
......@@ -29,58 +29,38 @@ foreach ($csv as $cords) {
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
$i = 0;
while ($row = pg_fetch_array($result)) {
// If this isn't the first entry, put a comma to separate the entries.
$i++ > 0 && print ',';
$feat = '';
if ($row['service_facebook'] === 't') {
$feat .= '<div class="smlogo smlogo-facebook"></div>';
}
if ($row['service_twitter'] === 't') {
$feat .= '<div class="smlogo smlogo-twitter"></div>';
}
if ($row['service_tumblr'] === 't') {
$feat .= '<div class="smlogo smlogo-tumblr"></div>';
}
if ($row['service_wordpress'] === 't') {
$feat .= '<div class="smlogo smlogo-wordpress"></div>';
}
if ($row['xmpp'] === 't') {
$feat .= '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
}
unset($signup);
if ($row['signup'] == 1) {
$signup = 'yes';
} else {
$signup = 'no';
}
$row['service_facebook'] === 't' && $feat .= '<div class="smlogo smlogo-facebook"></div>';
$row['service_twitter'] === 't' && $feat .= '<div class="smlogo smlogo-twitter"></div>';
$row['service_tumblr'] === 't' && $feat .= '<div class="smlogo smlogo-tumblr"></div>';
$row['service_wordpress'] === 't' && $feat .= '<div class="smlogo smlogo-wordpress"></div>';
$row['xmpp'] === 't' && $feat .= '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
$pod_name = htmlentities($row['name'], ENT_QUOTES);
if ($row['secure'] == 'true') {
$ur = 'https';
} else {
$ur = 'http';
}
$scheme = $row['secure'] === 'true' ? 'https://' : 'http://';
$signup = $row['signup'] === '1' ? 'yes' : 'no';
echo <<<EOF
{
'type': 'Feature',
'id': '1',
'properties' : {
'html': '{$pod_name}<br><a href="{$ur}://{$row['domain']}">Visit</a><br> Open Signup: {$signup}<br> Users: {$row['active_users_halfyear']}<br> Uptime: {$row['uptimelast7']}%<br> Services:{$feat}'
'html': '{$pod_name}<br><a href="{$scheme}{$row['domain']}">Visit</a><br> Open Signup: {$signup}<br> Users: {$row['active_users_halfyear']}<br> Uptime: {$row['uptimelast7']}%<br> Services:{$feat}'
},
'geometry': {
'type': 'Point',
'coordinates': [{$row['long']},{$row['lat']} ]
'coordinates': [{$row['long']},{$row['lat']}]
}
},
}
EOF;
}
?>
{
'type': 'Feature',
'id': '1',
'properties': {'html': ''},
'geometry': {'type': 'Point', 'coordinates': [0, 0]}
}
]
};
var tiles = L.tileLayer('https://{s}.tiles.mapbox.com/v4/diasporg.l615e519/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlhc3BvcmciLCJhIjoibTVBaldtayJ9.HdGPBIFeZyNKKQqCmU11nA', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment