Commit 05b33577 authored by dmorley's avatar dmorley

podmins can weight down the list if desired to slow traffic

parent 0ab121d3
...@@ -25,12 +25,12 @@ $debug=1; ...@@ -25,12 +25,12 @@ $debug=1;
//foreach pod check it and update db //foreach pod check it and update db
$domain = isset($_GET['domain'])?$_GET['domain']:null; $domain = isset($_GET['domain'])?$_GET['domain']:null;
if ($domain) { if ($domain) {
$sql = "SELECT domain,pingdomurl,score,datecreated FROM pods WHERE domain = $1"; $sql = "SELECT domain,pingdomurl,score,datecreated,weight FROM pods WHERE domain = $1";
$sleep="0"; $sleep="0";
$result = pg_query_params($dbh, $sql, array($domain)); $result = pg_query_params($dbh, $sql, array($domain));
} }
else { else {
$sql = "SELECT domain,pingdomurl,score,datecreated,adminrating FROM pods"; $sql = "SELECT domain,pingdomurl,score,datecreated,adminrating,weight FROM pods";
$sleep="1"; $sleep="1";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
} }
...@@ -45,6 +45,7 @@ $debug=1; ...@@ -45,6 +45,7 @@ $debug=1;
$score = $row[$i]['score']; $score = $row[$i]['score'];
$dateadded = $row[$i]['datecreated']; $dateadded = $row[$i]['datecreated'];
$admindb = $row[$i]['adminrating']; $admindb = $row[$i]['adminrating'];
$weight = $row[$i]['weight'];
//get ratings //get ratings
$userrate=0;$adminrate=0;$userratingavg = array();$adminratingavg = array();$userrating = array();$adminrating = array(); $userrate=0;$adminrate=0;$userratingavg = array();$adminratingavg = array();$userrating = array();$adminrating = array();
$sqlforr = "SELECT * FROM rating_comments WHERE domain = $1"; $sqlforr = "SELECT * FROM rating_comments WHERE domain = $1";
...@@ -303,6 +304,7 @@ $score=$score-2; ...@@ -303,6 +304,7 @@ $score=$score-2;
$json_encap = "jsonUptimeRobotApi()"; $json_encap = "jsonUptimeRobotApi()";
$up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap));
$uptr = json_decode($up2); $uptr = json_decode($up2);
if ($debug) {print_r($uptr);}
$responsetime = 'n/a'; $responsetime = 'n/a';
$uptimerobotstat = $uptr->stat; $uptimerobotstat = $uptr->stat;
$uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio; $uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio;
...@@ -319,16 +321,18 @@ $score=$score-2; ...@@ -319,16 +321,18 @@ $score=$score-2;
} }
} }
$weightedscore = ($uptime + $score + ($active_users_monthly/19999) - ((10 - $weight) *.12));
//sql it //sql it
$timenow = date('Y-m-d H:i:s'); $timenow = 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, $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, 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, state=$19, lat=$20, long=$21, postalcode='', connection=$22, whois=$23, userrating=$24, longversion=$25, shortversion=$26,
masterversion=$27, signup=$28, total_users=$29, active_users_halfyear=$30, active_users_monthly=$31, local_posts=$32, name=$33, masterversion=$27, signup=$28, total_users=$29, active_users_halfyear=$30, active_users_monthly=$31, local_posts=$32, name=$33,
comment_counts=$35, service_facebook=$36, service_tumblr=$37, service_twitter=$38, service_wordpress=$39 comment_counts=$35, service_facebook=$36, service_tumblr=$37, service_twitter=$38, service_wordpress=$39, weightedscore=$40
WHERE WHERE
domain=$34"; 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, $dver, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $domain, $comment_counts, $service_facebook, $service_tumblr, $service_twitter, $service_wordpress)); $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, $dver, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $domain, $comment_counts, $service_facebook, $service_tumblr, $service_twitter, $service_wordpress, $weightedscore));
if (!$result) { if (!$result) {
die("Error in SQL query3: " . pg_last_error()); die("Error in SQL query3: " . pg_last_error());
} }
......
...@@ -3,6 +3,7 @@ CREATE TABLE pods ( ...@@ -3,6 +3,7 @@ CREATE TABLE pods (
domain text UNIQUE NOT NULL, domain text UNIQUE NOT NULL,
name text, name text,
score int DEFAULT 10, score int DEFAULT 10,
weightedscore int DEFAULT 10,
adminrating decimal DEFAULT 10, adminrating decimal DEFAULT 10,
userrating decimal DEFAULT 10, userrating decimal DEFAULT 10,
whois text, whois text,
......
<?php <?php
$tt=0; $tt=0;
include('db/config.php'); include('db/config.php');
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die("Error in connection: " . pg_last_error()); 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 active_users_halfyear DESC NULLS LAST, uptimelast7 DESC NULLS LAST"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY weightedscore DESC";
} else { } else {
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY active_users_halfyear DESC NULLS LAST, uptimelast7 DESC NULLS LAST"; $sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY weightedscore DESC";
} }
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
...@@ -61,14 +62,18 @@ $tip.="On a score of -20 to +20 this pod is a {$row["score"]} right now"; ...@@ -61,14 +62,18 @@ $tip.="On a score of -20 to +20 this pod is a {$row["score"]} right now";
echo "<td>" . $row["uptimelast7"] . "%</td>"; echo "<td>" . $row["uptimelast7"] . "%</td>";
echo "<td class='tipsy' title='active six months: " . $row["active_users_halfyear"] . ", active one month: " . $row["active_users_monthly"] . "'>" . $row["active_users_halfyear"] . "</td>"; echo "<td class='tipsy' 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"]) {
echo "<td class='tipsy green' title='".$row["whois"]." '><b>" . $row["country"] . "</b></td>\n";
} else {
echo "<td class='tipsy' title='".$row["whois"]." '>" . $row["country"] . "</td>\n"; echo "<td class='tipsy' title='".$row["whois"]." '>" . $row["country"] . "</td>\n";
}
echo "<td class='' title=''>"; echo "<td class='' title=''>";
if ($row["service_facebook"] == "t") {echo "<div id='facebook' class='smlogo'></div>";} if ($row["service_facebook"] == "t") {echo "<div id='facebook' class='smlogo'></div>";}
if ($row["service_twitter"] == "t") {echo "<div id='twitter' class='smlogo'></div>";} if ($row["service_twitter"] == "t") {echo "<div id='twitter' class='smlogo'></div>";}
if ($row["service_tumblr"] == "t") {echo "<div id='tumblr' class='smlogo'></div>";} if ($row["service_tumblr"] == "t") {echo "<div id='tumblr' class='smlogo'></div>";}
if ($row["service_wordpress"] == "t") {echo "<div id='wordpress' class='smlogo'></div>";} if ($row["service_wordpress"] == "t") {echo "<div id='wordpress' class='smlogo'></div>";}
echo "</td></tr>\n"; echo "</td></tr>\n";
if ($tt == 5) { if ($tt == 4) {
echo <<<EOF echo <<<EOF
<td colspan='12' style='padding-left:200px;'> <td colspan='12' style='padding-left:200px;'>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
...@@ -86,8 +91,6 @@ EOF; ...@@ -86,8 +91,6 @@ EOF;
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
//echo $country_code;
?> ?>
</tbody> </tbody>
</table> </table>
...@@ -7,9 +7,9 @@ $tt=0; ...@@ -7,9 +7,9 @@ $tt=0;
} }
$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 active_users_halfyear DESC NULLS LAST, uptimelast7 DESC NULLS LAST"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY weightedscore DESC";
} else { } else {
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' ORDER BY active_users_halfyear DESC NULLS LAST, uptimelast7 DESC NULLS LAST"; $sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' ORDER BY weightedscore DESC";
} }
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$result) {
......
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