Commit 5dc21db1 authored by dmorley's avatar dmorley

show json in nice way. other clean up

parent cc2fddbb
......@@ -52,7 +52,7 @@ $expire = date("Y-m-d H:i:s", time() + 1700);
die("Error in SQL query: " . pg_last_error());
}
$to = "support@diasp.org";
$subject = "Temporary edit key for podupti.me";
$subject = "FORWARD REQUEST: Temporary edit key for podupti.me";
$message = "User trying to edit pod without email address. Email found: " . $row["email"] . " Link: https://podupti.me/db/edit.php?domain=" . $_POST["domain"] . "&token=" . $uuid . " Expires: " . $expire . "\n\n";
$headers = "From: support@diasp.org\r\nBcc: support@diasp.org\r\n";
@mail( $to, $subject, $message, $headers );
......
<?php
$debug=1;
//* Copyright (c) 2011-2016, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$domain = isset($_GET['domain'])?$_GET['domain']:null;
$sql = "SELECT pingdomurl FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($domain));
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
$apikey = pg_fetch_all($result);
$upti = curl_init();
$curlurl = "https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=".$apikey[0]['pingdomurl'];
curl_setopt($upti, CURLOPT_URL, $curlurl);
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($upti, CURLOPT_FOLLOWLOCATION, true);
$uptimerobot = curl_exec($upti); curl_close($upti);
$json_encap = "jsonUptimeRobotApi()"; $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $uptr = json_decode($up2);
var_dump($uptimerobot);
echo "<br><br>UptimeRobot Json displayed in Human<br>";
echo "Name: ".$uptr->monitors->monitor{'0'}->friendlyname."<br>";
echo "Url: ".$uptr->monitors->monitor{'0'}->url."<br>";
echo "Interval: ".$uptr->monitors->monitor{'0'}->interval."ms<br>";
echo "Uptime: ".$uptr->monitors->monitor{'0'}->alltimeuptimeratio."%<br>";
echo "Response Time: ".$uptr->monitors->monitor{'0'}->responsetime{'0'}->value."ms<br>";
if ($uptr->monitors->monitor{'0'}->status == 2) {$live = "Up";}
if ($uptr->monitors->monitor{'0'}->status == 1) {$live = "Paused";}
if ($uptr->monitors->monitor{'0'}->status == 8) {$live = "Seems Down";}
if ($uptr->monitors->monitor{'0'}->status == 9) {$live = "Down";}
echo "Status: ".$live;
pg_free_result($result);
pg_close($dbh);
?>
......@@ -109,7 +109,7 @@ EOF;
} elseif ($cleanup) {
include("cleanup.php");
} else {
echo "<a href='random.php' class='btn danger large'>Confused and just want to sign up?? Click Here</a><br>";
echo "<a href='random.php' class='btn danger large'>Confused and just want to sign up?? Click Here and we will pick one for you</a><br>";
include("show.php");
}
?>
......
......@@ -38,6 +38,7 @@ Show as: <a href="?mapview=true">Map</a> | <a href="/">Simple Table</a> | <a hre
<th>Version<a class="tipsy" title="Version of software 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>IPv6</th>
<th>Response Time</th>
<th>Signups</th>
<th>Total Users<a class="tipsy" title="Number of total users on this pod.">?</a></th>
<th>Active Last 6<a class="tipsy" title="Number of users active last 6 months on this pod.">?</a></th>
......@@ -85,6 +86,7 @@ if ($row["shortversion"] == $row["masterversion"] && $row["shortversion"] != "")
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["ipv6"] . "</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>";
......@@ -92,7 +94,7 @@ if ($row["signup"] == 1) {$signup="Open";} else {$signup="Closed";}
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"];}
if (strpos($row["pingdomurl"], "pingdom.com")) {$moreurl = $row["pingdomurl"];} else {$moreurl = "/db/showuptimerobot.php?domain=".$row["domain"];}
echo "<td><div title='Last Check ".$row["dateupdated"]."' class='tipsy'><a target='new' href='".$moreurl."'>" . $row["monthsmonitored"] . "</a></div></td>";
if ($row["userrating"] >6) {$userratingclass="green";} elseif ($row["userrating"] <7) {$userratingclass="yellow";} elseif ($row["userrating"] <3) {$userratingclass="red";}
echo "<td><a rel=\"facebox\" href=\"rate.php?domain=".$row["domain"]."\"><div class='tipsy rating ".$userratingclass."' title='User rating is ".$row["userrating"]."/10 Auto Score is: " .$row["score"]. "/20'>";
......
......@@ -36,9 +36,10 @@ $numrows = pg_num_rows($result);
if ($row["service_twitter"] == "t") {$feat.= "<div id=\'twitter\' class=\'smlogo\'></div>";}
if ($row["service_tumblr"] == "t") {$feat.= "<div id=\'tumblr\' class=\'smlogo\'></div>";}
if ($row["service_wordpress"] == "t") {$feat.= "<div id=\'wordpress\' class=\'smlogo\'></div>";}
unset($signup);if ($row["signup"] == 1) {$signup = "yes";} else {$signup= "no";}
echo <<<EOF
{ "type": "Feature", "id":"1", "properties":
{ "html":"{$row["name"]}<br><a href=\'http://{$row["domain"]}/users/sign_up\'>Signup</a> for {$row["domain"]}<br> Users: {$row["active_users_halfyear"]}<br> Uptime: {$row["uptimelast7"]}%<br> Services:{$feat}" }, "geometry": { "type": "Point", "coordinates": [{$row["long"]},{$row["lat"]} ] } },
{ "html":"{$row["name"]}<br><a href=\'http://{$row["domain"]}\'>Visit</a> {$row["domain"]}<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"]} ] } },
EOF;
}
?>
......
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