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;
//foreach pod check it and update db
$domain = isset($_GET['domain'])?$_GET['domain']:null;
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";
$result = pg_query_params($dbh, $sql, array($domain));
}
else {
$sql = "SELECT domain,pingdomurl,score,datecreated,adminrating FROM pods";
$sql = "SELECT domain,pingdomurl,score,datecreated,adminrating,weight FROM pods";
$sleep="1";
$result = pg_query($dbh, $sql);
}
......@@ -45,6 +45,7 @@ $debug=1;
$score = $row[$i]['score'];
$dateadded = $row[$i]['datecreated'];
$admindb = $row[$i]['adminrating'];
$weight = $row[$i]['weight'];
//get ratings
$userrate=0;$adminrate=0;$userratingavg = array();$adminratingavg = array();$userrating = array();$adminrating = array();
$sqlforr = "SELECT * FROM rating_comments WHERE domain = $1";
......@@ -303,6 +304,7 @@ $score=$score-2;
$json_encap = "jsonUptimeRobotApi()";
$up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap));
$uptr = json_decode($up2);
if ($debug) {print_r($uptr);}
$responsetime = 'n/a';
$uptimerobotstat = $uptr->stat;
$uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio;
......@@ -319,16 +321,18 @@ $score=$score-2;
}
}
$weightedscore = ($uptime + $score + ($active_users_monthly/19999) - ((10 - $weight) *.12));
//sql it
$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,
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, 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
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) {
die("Error in SQL query3: " . pg_last_error());
}
......
......@@ -3,6 +3,7 @@ CREATE TABLE pods (
domain text UNIQUE NOT NULL,
name text,
score int DEFAULT 10,
weightedscore int DEFAULT 10,
adminrating decimal DEFAULT 10,
userrating decimal DEFAULT 10,
whois text,
......
<?php
$tt=0;
include('db/config.php');
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$hidden = isset($_GET['hidden'])?$_GET['hidden']:null;
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 {
$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);
if (!$result) {
......@@ -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 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='' title=''>";
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_tumblr"] == "t") {echo "<div id='tumblr' class='smlogo'></div>";}
if ($row["service_wordpress"] == "t") {echo "<div id='wordpress' class='smlogo'></div>";}
echo "</td></tr>\n";
if ($tt == 5) {
if ($tt == 4) {
echo <<<EOF
<td colspan='12' style='padding-left:200px;'>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
......@@ -86,8 +91,6 @@ EOF;
}
pg_free_result($result);
pg_close($dbh);
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
//echo $country_code;
?>
</tbody>
</table>
......@@ -7,9 +7,9 @@ $tt=0;
}
$hidden = isset($_GET['hidden'])?$_GET['hidden']:null;
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 {
$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);
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