Commit 1bc47169 authored by MatrixCrawler's avatar MatrixCrawler

Introduced PDO-SQL and new Config

parent 2b1f655a
...@@ -34,16 +34,17 @@ if (!$dbConnection) { ...@@ -34,16 +34,17 @@ if (!$dbConnection) {
$sql = "INSERT INTO rating_comments (domain, comment, rating, username, userurl)" $sql = "INSERT INTO rating_comments (domain, comment, rating, username, userurl)"
. " VALUES(".$dbConnection->quote($_POST['domain']).", ".$dbConnection->quote($_POST['comment']).", ".$dbConnection->quote($_POST['rating']). "," . " VALUES(".$dbConnection->quote($_POST['domain']).", ".$dbConnection->quote($_POST['comment']).", ".$dbConnection->quote($_POST['rating']). ","
. " ".$dbConnection->quote($_POST['username']).", ".$dbConnection->quote($_POST['userurl']).")"; . " ".$dbConnection->quote($_POST['username']).", ".$dbConnection->quote($_POST['userurl']).")";
$result = $dbConnection->query($sql);
if (!$result) { if (!$result) {
die("Error in SQL query: " . $dbConnection->errorInfo()[2]); die("Error in SQL query: " . $dbConnection->errorInfo()[2]);
} }
$subject = "New rating added to poduptime "; $subject = "New rating added to poduptime ";
$message = "Pod:" . $_POST["domain"] . "\n\n"; $message = "Pod:" . $_POST["domain"] . "\n\n";
$headers = "From: ".$_POST["email"]."\r\n"; $headers = "From: ".$_POST["email"]."\r\n";
@mail( ADMIN_EMAIL, $subject, $message, $headers ); @mail( ADMIN_EMAIL, $subject, $message, $headers );
echo "Comment posted!"; echo "Comment posted!";
?> ?>
<meta charset="utf-8"> <meta charset="utf-8">
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ --> <!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<table id="myTable" class="tablesorter" width="98%"> <table id="myTable" class="tablesorter" style="width: 98%">
<thead> <thead>
<tr> <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 style="width:220px">Diaspora Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
<th>Live Status<a class="tipsy" title="Up or Down according to Pingdom">?</a></th> <th>Live Status<a class="tipsy" title="Up or Down according to Pingdom">?</a></th>
<th>Last Code Pull<a class="tipsy" title="Because the alpha is updated everyday pods with old software will not work correcly with pods with new software. This is the date the p <th>Last Code Pull<a class="tipsy" title="Because the alpha is updated everyday pods with old software will not work correcly with pods with new software. This is the date the p
od last updated from the main Diaspora code.">?</a></th> od last updated from the main Diaspora code.">?</a></th>
...@@ -16,44 +16,65 @@ od last updated from the main Diaspora code.">?</a></th> ...@@ -16,44 +16,65 @@ od last updated from the main Diaspora code.">?</a></th>
</thead> </thead>
<tbody> <tbody>
<?php <?php
include('config.php'); require_once 'config.inc.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); require_once 'db.class.php';
if (!$dbh) {
die("Error in connection: " . pg_last_error()); $dbConnection = DB::connectDB();
} if (!$dbConnection) {
if ($_GET['hidden'] == "true") { die("Error in connection: " . $dbConnection->errorInfo()[2]);
$sql = "SELECT * FROM pods WHERE hidden <> 'no'"; }
} else {
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'"; if (isset($_GET['hidden']) && $_GET['hidden'] == "true") {
} $sql = "SELECT * FROM pods WHERE hidden <> 'no'";
$result = pg_query($dbh, $sql); } else {
if (!$result) { $sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
if ($row["secure"] == "true") {$method = "https://";$class="green";$tip="This pod uses SSL encryption for traffic.";} else {$method = "http://";$class="red";$tip="This pod does not offer SSL";}
echo "<tr><td><div title='$tip' class='tipsy'><a class='$class' target='new' href='". $method . $row["domain"] ."'>" . $method . $row["domain"] . "</a></div></td>";
echo "<td>" . $row["status"] . "</td>";
echo "<td><div class='tipsy' title='Git Revision ".$row["hgitref"]."'><div id='".$row["hgitdate"]."' class='utc-timestamp'>" . strtotime($row["hgitdate"]) . "</div></div></td>";
echo "<td>" . $row["uptimelast7"] . "%</td>";
echo "<td><div title='Last Check ".$row["dateupdated"]."' class='tipsy'><a target='new' href='".$row["pingdomurl"]."'>" . $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><div class='tipsy rating ".$userratingclass."' title='User rating is ".$row["adminrating"]."'>";
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"]."'>"; $result = $dbConnection->query($sql);
for ($i = 0; $i < $row["adminrating"]; $i++) { if (!$result) {
echo "✪"; die("Error in SQL query: " . $dbConnection->errorInfo()[2]);
} }
echo "</div></td>"; foreach ($result->fetchAll() as $row) {
echo "<td>" . $row["responsetimelast7"] . "</td>"; if ($row["secure"] == "true") {
echo "<td class='tipsy' title='IP Address ".$row["ip"]." '>" . $row["ipv6"] . "</td></tr>\n"; $method = "https://";$class="green";$tip="This pod uses SSL encryption for traffic.";
} else {
$method = "http://";$class="red";$tip="This pod does not offer SSL";
}
echo "<tr><td><div title='$tip' class='tipsy'><a class='$class' target='new' href='". $method . $row["domain"] ."'>" . $method . $row["domain"] . "</a></div></td>";
echo "<td>" . $row["status"] . "</td>";
echo "<td><div class='tipsy' title='Git Revision ".$row["hgitref"]."'><div id='".$row["hgitdate"]."' class='utc-timestamp'>" . strtotime($row["hgitdate"]) . "</div></div></td>";
echo "<td>" . $row["uptimelast7"] . "%</td>";
echo "<td><div title='Last Check ".$row["dateupdated"]."' class='tipsy'><a target='new' href='".$row["pingdomurl"]."'>" . $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><div class='tipsy rating ".$userratingclass."' title='User rating is ".$row["adminrating"]."'>";
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"]."'>";
for ($i = 0; $i < $row["adminrating"]; $i++) {
echo "✪";
}
echo "</div></td>";
echo "<td>" . $row["responsetimelast7"] . "</td>";
echo "<td class='tipsy' title='IP Address ".$row["ip"]." '>" . $row["ipv6"] . "</td></tr>\n";
} }
pg_free_result($result);
pg_close($dbh);
?> ?>
</tbody> </tbody>
</table> </table>
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