Commit 342bba09 authored by root's avatar root

switch to new json, store and expose some of the new stats

parent 024af999
......@@ -26,8 +26,8 @@ body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:
.container:after{clear:both;}
.container-fluid{position:relative;min-width:940px;padding-left:20px;padding-right:20px;zoom:1;}.container-fluid:before,.container-fluid:after{display:table;content:"";zoom:1;*display:inline;}
.container-fluid:after{clear:both;}
.container-fluid>.sidebar{float:right;width:340px;}
.container-fluid>.content{margin-left:2px;width:80%;}
.container-fluid>.sidebar{float:right;width:120px;}
.container-fluid>.content{margin-left:2px;width:85%;}
a{color:#0069d6;text-decoration:none;line-height:inherit;font-weight:inherit;}a:hover{color:#00438a;text-decoration:underline;}
.pull-right{float:right;}
.pull-left{float:left;}
......
<?php
$debug = isset($_GET['debug'])?1:0;
$debug = 1;//isset($_GET['debug'])?1:0;
//if ($_GET['debug'] == 1) {$debug =1;}
//$debug = isset($argv[1])?1:0;
//* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
......@@ -82,29 +82,34 @@ $userrate=0;$adminrate=0;
unset($userratingavg);
unset($adminratingavg);
//curl the header of pod with and without https
unset($name);
unset($total_users);
unset($active_users_halfyear);
unset($active_users_monthly);
unset($local_posts);
unset($registrations_open);
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, "https://".$domain."/users/sign_in");
curl_setopt($chss, CURLOPT_POST, 1);
curl_setopt($chss, CURLOPT_URL, "https://".$domain."/statistics.json");
curl_setopt($chss, CURLOPT_POST, 0);
curl_setopt($chss, CURLOPT_HEADER, 1);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_NOBODY, 1);
curl_setopt($chss, CURLOPT_NOBODY, 0);
$outputssl = curl_exec($chss);
curl_close($chss);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$domain."/users/sign_in");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, "http://".$domain."/statistics.json");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch);
curl_close($ch);
if ($debug) {print $output;}
if ($debug) {print $outputssl;}
if (stristr($outputssl, '_diaspora_session')) {
if (stristr($outputssl, 'registrations_open')) {
//parse header data
$secure="true";
if ($debug) {echo "Secure: ".$secure."<br>";}
......@@ -127,7 +132,15 @@ preg_match('/Server: (.*?)\n/',$outputssl,$xserver);
$server = isset($xserver[1])?trim($xserver[1]):null;
preg_match('/Content-Encoding: (.*?)\n/',$outputssl,$xencoding);
if ($xencoding) {$encoding = trim($xencoding[1]);} else {$encoding = null;}
//get new json
preg_match_all("/{(.*?)}/", $outputssl, $jsonssl_array);
$jsonssl = json_decode($jsonssl_array[0][0]);
if ($jsonssl->registrations_open === true) {$registrations_open=1;}
$name = isset($jsonssl->name)?$jsonssl->name:"null";
$total_users = isset($jsonssl->total_users)?$jsonssl->total_users:0;
$active_users_halfyear = isset($jsonssl->active_users_halfyear)?$jsonssl->active_users_halfyear:0;
$active_users_monthly = isset($jsonssl->active_users_monthly)?$jsonssl->active_users_monthly:0;
$local_posts = isset($jsonssl->local_posts)?$jsonssl->local_posts:0;
} elseif (stristr($output, 'Set-Cookie: _diaspora_session=')) {
"not";$secure="false";
//$hidden="no";
......@@ -148,6 +161,14 @@ preg_match('/Server: (.*?)\n/',$output,$xserver);
$server = isset($xserver[1])?trim($xserver[1]):null;
preg_match('/Content-Encoding: (.*?)\n/',$output,$xencoding);
$encoding = isset($xencoding[1])?trim($xencoding[1]):null;
preg_match_all("/{(.*?)}/", $output, $jsonssl_array);
$jsonssl = json_decode($jsonssl_array[0][0]);
if ($jsonssl->registrations_open === true) {$registrations_open=1;}
$name = isset($jsonssl->name)?$jsonssl->name:"null";
$total_users = isset($jsonssl->total_users)?$jsonssl->total_users:0;
$active_users_halfyear = isset($jsonssl->active_users_halfyear)?$jsonssl->active_users_halfyear:0;
$active_users_monthly = isset($jsonssl->active_users_monthly)?$jsonssl->active_users_monthly:0;
$local_posts = isset($jsonssl->local_posts)?$jsonssl->local_posts:0;
} else {
$secure="false";
$score = $score - 1;
......@@ -155,31 +176,8 @@ $score = $score - 1;
//no diaspora cookie on either, lets set this one as hidden and notify someone its not really a pod
//could also be a ssl pod with a bad cert, I think its ok to call that a dead pod now
}
if ($secure == "true") {$sorno = "s";} else {$sorno- "";}
$chksup = curl_init();
curl_setopt($chksup, CURLOPT_URL, "http".$sorno."://".$domain."/users/sign_up");
curl_setopt($chksup, CURLOPT_POST, 1);
curl_setopt($chksup, CURLOPT_HEADER, 1);
curl_setopt($chksup, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chksup, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chksup, CURLOPT_NOBODY, 1);
$outputchksup = curl_exec($chksup);
curl_close($chksup);
if ($debug) {print $outputchksup;}
preg_match('/Status:(.*?)\n/',$outputchksup,$xsignupon);
$signupon = isset($xsignupon[1])?trim($xsignupon[1]):null;
$signupon = substr($signupon, 0, 3);
if ($signupon == "200") {$signup = 1;} else {$signup = 0;}
$signup = $registrations_open;
if ($debug) {echo "<br>Signup Open: ".$signup."<br>";}
if ($debug) {echo "<br>SSL: ".$secure."<br>";}
//if (!$gitdate) {
//if a pod is not displaying the git header data its really really really old lets lower your score
//$hidden="yes";
//if ($debug) {echo "Valid Headers: ".$gitdate."<br>";}
//$score = $score - 2;
//}
if ($score > 5) {
$hidden = "no";
} else {
......@@ -296,10 +294,10 @@ $pingdomdate = date('Y-m-d H:i:s');
$sql = "UPDATE pods SET Hgitdate=$1, Hencoding=$2, secure=$3, hidden=$4, Hruntime=$5, Hgitref=$6, ip=$7, ipv6=$8, monthsmonitored=$9,
uptimelast7=$10, status=$11, dateLaststats=$12, dateUpdated=$13, responsetimelast7=$14, score=$15, adminrating=$16, country=$17, city=$18,
state=$19, lat=$20, long=$21, postalcode='', connection=$22, whois=$23, userrating=$24, longversion=$25, shortversion=$26,
masterversion=$27, signup=$28
masterversion=$27, signup=$28, total_users=$29, active_users_halfyear=$30, active_users_monthly=$31, local_posts=$32, name=$33
WHERE
domain=$29";
$result = pg_query_params($dbh, $sql, array($gitdate, $encoding, $secure, $hidden, $runtime, $gitrev, $ipnum, $ipv6, $months, $uptime, $live, $pingdomdate, $timenow, $responsetime, $score, $adminrating, $country, $city, $state, $lat, $long, $dver, $whois, $userrating, $xdver[1], $dver, $masterversion, $signup, $domain));
domain=$34";
$result = pg_query_params($dbh, $sql, array($gitdate, $encoding, $secure, $hidden, $runtime, $gitrev, $ipnum, $ipv6, $months, $uptime, $live, $pingdomdate, $timenow, $responsetime, $score, $adminrating, $country, $city, $state, $lat, $long, $dver, $whois, $userrating, $xdver[1], $dver, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $domain));
if (!$result) {
die("Error in SQL query3: " . pg_last_error());
}
......
CREATE TABLE pods (
id serial8 UNIQUE PRIMARY KEY,
domain text UNIQUE NOT NULL,
name text,
score int DEFAULT 10,
adminrating decimal DEFAULT 10,
userrating decimal DEFAULT 10,
......@@ -27,6 +28,10 @@ CREATE TABLE pods (
pingdomlast text,
monthsmonitored int,
signup int,
total_users int,
active_users_halfyear int,
active_users_monthly int,
local_posts int,
uptimelast7 numeric(5,2),
status text,
responsetimelast7 text,
......
......@@ -69,11 +69,11 @@ s1.parentNode.insertBefore(s, s1);
<div class="sidebar">
<div class="adsense2">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- poduptimebigger -->
<!-- podsky -->
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
style="display:inline-block;width:120px;height:600px"
data-ad-client="ca-pub-3662181805557062"
data-ad-slot="8271090637"></ins>
data-ad-slot="2647650630"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
......
......@@ -4,12 +4,14 @@
<thead>
<tr>
<th width="220px">Diaspora Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
<th>Version Code<a class="tipsy" title="Version of Diaspora this pod runs">?</a></th>
<th>Uptime Percent<a class="tipsy" title="Percent of the time the pod is online for <?php echo date("F") ?>.">?</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>Signups<a class="tipsy" title="Open to public or Closed/Invite only.">?</a></th>
<th>Users<a class="tipsy" title="Number of total users on this pod.">?</a></th>
<th>Posts<a class="tipsy" title="Number of total posts on this pod.">?</a></th>
<th>Months Online<a class="tipsy" title="How many months has this pod been online? Click number for more history.">?</a></th>
<th>User Rating<a class="tipsy" title="User and Admin rating for this pod.">?</a></th>
<th>Server Location<a class="tipsy" title="Pod location, based on IP Geolocation">?</a></th>
<th>Location<a class="tipsy" title="Pod location, based on IP Geolocation">?</a></th>
</tr>
</thead>
<tbody>
......@@ -46,7 +48,7 @@ $tip="This pod does not offer SSL";
$verdiff = str_replace(".", "", $row["masterversion"]) - str_replace('.', '', $row["shortversion"]);
$tip.="\n This pod {$row["domain"]} has been watched for {$row["monthsmonitored"]} months and its average ping time is {$row["responsetimelast7"]} with uptime of {$row["uptimelast7"]}% this month and was last checked on {$row["dateupdated"]}. ";
$tip.="\n This pod {$row["name"]} has been watched for {$row["monthsmonitored"]} months and its average ping time is {$row["responsetimelast7"]} with uptime of {$row["uptimelast7"]}% this month and was last checked on {$row["dateupdated"]}. ";
$tip.="Code base is {$row["shortversion"]} and the current github base is {$row["masterversion"]}. ";
$tip.="This pod is {$verdiff} versions behind the current code. This pods IP {$row["ip"]} ". ($row["ipv6"] == "yes" ? "has" : "does not have") ." IPv6 and is located in {$row["country"]}. On a score of -20 to +20 this pod is a {$row["score"]} right now, all data is checked every hour. Pod " . ($row["signup"] == "1" ? "does" : "does not") . " allow new users.";
......@@ -54,7 +56,7 @@ $tip.="This pod is {$verdiff} versions behind the current code. This pods IP {$r
"</div></td>";
if (stristr($row["shortversion"],'head'))
{$version=".development code";$pre = "This pod runs pre release
{$version=".dev code";$pre = "This pod runs pre release
development code";} elseif (!$row["shortversion"])
{$version="0";$pre = "This pod runs
unknown code";}
......@@ -65,6 +67,8 @@ if ($row["shortversion"] == $row["masterversion"] && $row["shortversion"] != "")
echo "<td>" . $row["uptimelast7"] . "%</td>";
if ($row["signup"] == 1) {$signup="Open";} else {$signup="Closed";}
echo "<td>" . $signup . "</td>";
echo "<td>" . $row["total_users"] . "</td>";
echo "<td>" . $row["local_posts"] . "</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"];}
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";}
......
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