Commit 44ca0a43 authored by David Morley's avatar David Morley

it all works! let let the public give it a try

parent 16c7c6cc
......@@ -3,7 +3,8 @@
//* Copyright (c) 2011, 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) {
$dbh2 = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
//foreach pod check it and update db
......@@ -19,16 +20,29 @@
for ($i = 0; $i < $numrows; $i++) {
$domain = $row[$i]['domain'];
$score = $row[$i]['score'];
//get ratings
$sqlforr = "SELECT rating FROM rating_comments WHERE domain = '$domain'";
$ratings = pg_query($dbh, $sqlforr);
$userrate=0;$adminrate=0;
$sqlforr = "SELECT * FROM rating_comments WHERE domain = '$domain'";
$ratings = pg_query($dbh, $sqlforr);
if (!$ratings) {
die("Error in SQL query: " . pg_last_error());
}
var_dump($ratings);
//while ($rrow = pg_fetch_all($ratings)) {
//echo $rrow['rating'];
//}
$numratings = pg_num_rows($ratings);
while($myrow = pg_fetch_assoc($ratings)) {
if ($myrow['admin'] =0) {
$userratingavg[] = $myrow['rating'];$userrate++;
} elseif ($myrow['admin'] =1) {
$adminratingavg[] = $myrow['rating'];$adminrate++;
}
}
$userrating = array_sum($userratingavg) / $userrate;
$adminrating = array_sum($adminratingavg) / $adminrate;
if (!$userrating) {$userrating=8;}
if (!$adminrating) {$adminrating=8;}
pg_free_result($ratings);
//curl the header of pod with and without https
......@@ -179,7 +193,7 @@ else {$live="error";}
//sql it
$timenow = date('Y-m-d H:i:s');
$sql = "UPDATE pods SET Hgitdate='$gitdate', Hencoding='$encoding', secure='$secure', hidden='$hidden', Hruntime='$runtime', Hgitref='$gitrev', ip='$ipnum', ipv6='$ipv6', monthsmonitored='$months', uptimelast7='$uptime', status='$live', dateLaststats='$pingdomdate', dateUpdated='$timenow', responsetimelast7='$responsetime', score='$score' WHERE domain='$domain'";
$sql = "UPDATE pods SET Hgitdate='$gitdate', Hencoding='$encoding', secure='$secure', hidden='$hidden', Hruntime='$runtime', Hgitref='$gitrev', ip='$ipnum', ipv6='$ipv6', monthsmonitored='$months', uptimelast7='$uptime', status='$live', dateLaststats='$pingdomdate', dateUpdated='$timenow', responsetimelast7='$responsetime', score='$score', adminrating='$adminrating', userrating='$userrating' WHERE domain='$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
......
......@@ -53,7 +53,7 @@ echo "<h3>".$_GET["domain"]." ratings</h3><div id='ratings'><input id='addrating
if (!$numrows) {echo "<b>This pod has no rating yet!</b>";}
while ($row = pg_fetch_array($result)) {
if ($row["admin"] == 1) {
echo "Poduptime Comment - User: <b>".$row["username"]."</b> Url: <a href='".$row["userurl"]."'>".$row["userurl"]."</a> Rating: <b>".$row["rating"]."</b> <br>";
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><hr><br>";
} 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>";
......
......@@ -43,7 +43,7 @@ for ($i = 0; $i < $row["userrating"]; $i++) {
echo "✪";
}
if ($row["adminrating"] >6) {$adminratingclass="green";} elseif ($row["adminrating"] <7) {$adminratingclass="yellow";} elseif ($row["adminrating"] <3) {$adminratingclass="red";}
echo "</div><br><div class='tipsy rating ".$adminratingclass."' backendscore='".$row["score"]."' title='Poduptime rating is ".$row["adminrating"]."'>";
echo "</div><br><div class='tipsy rating ".$adminratingclass."' backendscore='".$row["score"]."' title='Poduptime Approved rating is ".$row["adminrating"]."'>";
for ($i = 0; $i < $row["adminrating"]; $i++) {
echo "✪";
}
......
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