Verified Commit 55be40e2 authored by noplanman's avatar noplanman

Replace "if" error statements with simpler "or die" statements.

Also use this for required $_GET parameters.
parent 3f63e29d
<?php <?php
//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.
if ($_GET['key'] != '4r45tg') { $_GET['key'] === '4r45tg' || die;
die;
}
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
if ($_GET['format'] == 'georss') { if ($_GET['format'] == 'georss') {
echo <<<EOF echo <<<EOF
...@@ -23,9 +20,8 @@ xmlns:georss="http://www.georss.org/georss"> ...@@ -23,9 +20,8 @@ xmlns:georss="http://www.georss.org/georss">
EOF; EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'"; $sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$pod_name = htmlentities($row['name'], ENT_QUOTES); $pod_name = htmlentities($row['name'], ENT_QUOTES);
...@@ -61,9 +57,8 @@ EOF; ...@@ -61,9 +57,8 @@ EOF;
} elseif ($_GET['format'] == 'json') { } elseif ($_GET['format'] == 'json') {
$sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods'; $sql = 'SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this //json output, thx Vipul A M for fixing this
header('Content-type: application/json'); header('Content-type: application/json');
...@@ -79,9 +74,8 @@ EOF; ...@@ -79,9 +74,8 @@ EOF;
$i = 0; $i = 0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC"; $sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up') { if ($row['status'] == 'up') {
......
...@@ -3,14 +3,12 @@ $tt = 0; ...@@ -3,14 +3,12 @@ $tt = 0;
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
?> ?>
......
...@@ -29,14 +29,12 @@ if (strlen($_POST['url']) < 14) { ...@@ -29,14 +29,12 @@ if (strlen($_POST['url']) < 14) {
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = 'SELECT domain,pingdomurl FROM pods'; $sql = 'SELECT domain,pingdomurl FROM pods';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['domain'] == $_POST['domain']) { if ($row['domain'] == $_POST['domain']) {
$log->lwrite('domain already exists ' . $_POST['domain']); $log->lwrite('domain already exists ' . $_POST['domain']);
...@@ -82,9 +80,8 @@ if (stristr($output, 'nodeName')) { ...@@ -82,9 +80,8 @@ if (stristr($output, 'nodeName')) {
if ($valid == '1') { if ($valid == '1') {
$sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)"; $sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)";
$result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['url'], $_POST['email']]); $result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['url'], $_POST['email']]);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$to = $adminemail; $to = $adminemail;
$cc = $_POST['email']; $cc = $_POST['email'];
$subject = 'New pod added to podupti.me '; $subject = 'New pod added to podupti.me ';
......
...@@ -4,14 +4,12 @@ ...@@ -4,14 +4,12 @@
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods WHERE domain = $1"; $sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,pingdomurl,monthsmonitored,uptimelast7,responsetimelast7,local_posts,comment_counts,dateCreated,dateUpdated,dateLaststats,hidden FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$_GET['url']]); $result = pg_query_params($dbh, $sql, [$_GET['url']]);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') { if ($_GET['format'] == 'json') {
echo json_encode($row); echo json_encode($row);
......
<?php <?php
if (!$_GET['domain']) { $_GET['domain'] || die('no pod domain given');
die('no pod domain given'); $_GET['token'] || die('no token given');
} strlen($_GET['token']) < 6 || die('bad token');
if (!$_GET['token']) {
die('no token given');
}
if (strlen($_GET['token']) < 6) {
die('bad token');
}
$domain = $_GET['domain']; $domain = $_GET['domain'];
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT domain,email,token,tokenexpire,pingdomurl,weight FROM pods WHERE domain = '$domain'"; $sql = "SELECT domain,email,token,tokenexpire,pingdomurl,weight FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row['token'] <> $_GET['token']) { if ($row['token'] <> $_GET['token']) {
die('token not a match'); die('token not a match');
......
...@@ -8,14 +8,12 @@ $domain = $_POST['domain']; ...@@ -8,14 +8,12 @@ $domain = $_POST['domain'];
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT email FROM pods WHERE domain = '$domain'"; $sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$rows = pg_num_rows($result); $rows = pg_num_rows($result);
if ($rows <= 0) { if ($rows <= 0) {
die('domain not found'); die('domain not found');
......
...@@ -13,14 +13,12 @@ $domain = $_POST['domain']; ...@@ -13,14 +13,12 @@ $domain = $_POST['domain'];
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT email FROM pods WHERE domain = '$domain'"; $sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('one Error in SQL query: ' . pg_last_error());
die('one Error in SQL query: ' . pg_last_error());
}
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($adminkey <> $_POST['adminkey']) { if ($adminkey <> $_POST['adminkey']) {
die('admin key fail'); die('admin key fail');
......
...@@ -38,9 +38,8 @@ if ($debug) { ...@@ -38,9 +38,8 @@ if ($debug) {
} }
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh2 = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh2 = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
//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;
...@@ -53,10 +52,8 @@ if ($domain) { ...@@ -53,10 +52,8 @@ if ($domain) {
$sleep = '1'; $sleep = '1';
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
} }
if (!$result) { $result || die('Error in SQL query1: ' . pg_last_error());
die('Error in SQL query1: ' . pg_last_error());
}
while ($row = pg_fetch_all($result)) { while ($row = pg_fetch_all($result)) {
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
for ($i = 0; $i < $numrows; $i ++) { for ($i = 0; $i < $numrows; $i ++) {
...@@ -74,9 +71,8 @@ while ($row = pg_fetch_all($result)) { ...@@ -74,9 +71,8 @@ while ($row = pg_fetch_all($result)) {
$adminrating = []; $adminrating = [];
$sqlforr = "SELECT * FROM rating_comments WHERE domain = $1"; $sqlforr = "SELECT * FROM rating_comments WHERE domain = $1";
$ratings = pg_query_params($dbh, $sqlforr, [$domain]); $ratings = pg_query_params($dbh, $sqlforr, [$domain]);
if (!$ratings) { $ratings || die('Error in SQL query2: ' . pg_last_error());
die('Error in SQL query2: ' . pg_last_error());
}
$numratings = pg_num_rows($ratings); $numratings = pg_num_rows($ratings);
while ($myrow = pg_fetch_assoc($ratings)) { while ($myrow = pg_fetch_assoc($ratings)) {
if ($myrow['admin'] == 0) { if ($myrow['admin'] == 0) {
...@@ -406,9 +402,8 @@ while ($row = pg_fetch_all($result)) { ...@@ -406,9 +402,8 @@ while ($row = pg_fetch_all($result)) {
comment_counts=$35, service_facebook=$36, service_tumblr=$37, service_twitter=$38, service_wordpress=$39, weightedscore=$40, xmpp=$41, softwarename=$42, sslvalid=$43 comment_counts=$35, service_facebook=$36, service_tumblr=$37, service_twitter=$38, service_wordpress=$39, weightedscore=$40, xmpp=$41, softwarename=$42, sslvalid=$43
WHERE domain=$34"; WHERE domain=$34";
$result = pg_query_params($dbh, $sql, [$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, $xmpp, $softwarename, $outputsslerror]); $result = pg_query_params($dbh, $sql, [$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, $xmpp, $softwarename, $outputsslerror]);
if (!$result) { $result || die('Error in SQL query3: ' . pg_last_error());
die('Error in SQL query3: ' . pg_last_error());
}
if ($debug) { if ($debug) {
echo '<br>Score out of 100: ' . $score . '<br>'; echo '<br>Score out of 100: ' . $score . '<br>';
} }
......
<?php <?php
if (!$_POST['username']) { $_POST['username'] || die('no username given');
die('no username given'); $_POST['userurl'] || die('no userurl given');
} $_POST['domain'] || die('no pod domain given');
if (!$_POST['userurl']) { $_POST['comment'] || die('no comment');
die('no userurl given'); $_POST['rating'] || die('no rating given');
}
if (!$_POST['domain']) {
die('no pod domain given');
}
if (!$_POST['comment']) {
die('no comment');
}
if (!$_POST['rating']) {
die('no rating given');
}
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "INSERT INTO rating_comments (domain, comment, rating, username, userurl) VALUES($1, $2, $3, $4, $5)"; $sql = "INSERT INTO rating_comments (domain, comment, rating, username, userurl) VALUES($1, $2, $3, $4, $5)";
$result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['comment'], $_POST['rating'], $_POST['username'], $_POST['userurl']]); $result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['comment'], $_POST['rating'], $_POST['username'], $_POST['userurl']]);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$to = $adminemail; $to = $adminemail;
$subject = 'New rating added to poduptime '; $subject = 'New rating added to poduptime ';
$message = 'Pod:' . $_POST['domain'] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n"; $message = 'Pod:' . $_POST['domain'] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n";
......
...@@ -4,15 +4,13 @@ $debug = 1; ...@@ -4,15 +4,13 @@ $debug = 1;
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$domain = isset($_GET['domain']) ? $_GET['domain'] : null; $domain = isset($_GET['domain']) ? $_GET['domain'] : null;
$sql = "SELECT pingdomurl FROM pods WHERE domain = $1"; $sql = "SELECT pingdomurl FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$domain]); $result = pg_query_params($dbh, $sql, [$domain]);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$apikey = pg_fetch_all($result); $apikey = pg_fetch_all($result);
$upti = curl_init(); $upti = curl_init();
$key = $apikey[0]['pingdomurl']; $key = $apikey[0]['pingdomurl'];
...@@ -52,5 +50,3 @@ if ($uptr->monitors[0]->status == 9) { ...@@ -52,5 +50,3 @@ if ($uptr->monitors[0]->status == 9) {
echo 'Status: ' . $live; echo 'Status: ' . $live;
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?>
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND uptimelast7 > 95 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1"; $sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND uptimelast7 > 95 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query1: ' . pg_last_error());
die('Error in SQL query1: ' . pg_last_error());
}
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
if ($row[0]['secure'] == 'true') { if ($row[0]['secure'] == 'true') {
$ssl = 's'; $ssl = 's';
......
<?php
$_GET['domain'] || die('domain not specified');
?>
<html> <html>
<head> <head>
<style type="text/css"> <style type="text/css">
...@@ -51,17 +55,12 @@ ...@@ -51,17 +55,12 @@
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
if (is_null($_GET['domain'])) {
die('domain not specified');
}
$sql = "SELECT * FROM rating_comments WHERE domain = $1"; $sql = "SELECT * FROM rating_comments WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$_GET['domain']]); $result = pg_query_params($dbh, $sql, [$_GET['domain']]);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
echo '<input id="addrating" class="btn primary" style="float:right;margin-right:15px;" type="submit" value="Add a Rating"><h3>Podupti.me ratings for ' . $_GET['domain'] . ' pod</h3><div id="ratings"><hr>'; echo '<input id="addrating" class="btn primary" style="float:right;margin-right:15px;" type="submit" value="Add a Rating"><h3>Podupti.me ratings for ' . $_GET['domain'] . ' pod</h3><div id="ratings"><hr>';
if (!$numrows) { if (!$numrows) {
......
...@@ -6,9 +6,8 @@ require_once __DIR__ . '/config.php'; ...@@ -6,9 +6,8 @@ require_once __DIR__ . '/config.php';
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY']; $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) { $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 uptimelast7 DESC"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY uptimelast7 DESC";
...@@ -16,9 +15,8 @@ if ($hidden == 'true') { ...@@ -16,9 +15,8 @@ if ($hidden == 'true') {
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY uptimelast7 DESC"; $sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY uptimelast7 DESC";
} }
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
?> ?>
......
...@@ -3,9 +3,8 @@ $tt = 0; ...@@ -3,9 +3,8 @@ $tt = 0;
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $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 uptimelast7 DESC"; $sql = "SELECT * FROM pods WHERE hidden <> 'no' ORDER BY uptimelast7 DESC";
...@@ -13,9 +12,8 @@ if ($hidden == 'true') { ...@@ -13,9 +12,8 @@ if ($hidden == 'true') {
$sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC'; $sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC';
} }
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
?> ?>
......
...@@ -24,14 +24,12 @@ foreach ($csv as $cords) { ...@@ -24,14 +24,12 @@ foreach ($csv as $cords) {
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { $dbh || die('Error in connection: ' . pg_last_error());
die('Error in connection: ' . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'"; $sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { $result || die('Error in SQL query: ' . pg_last_error());
die('Error in SQL query: ' . pg_last_error());
}
$numrows = pg_num_rows($result); $numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
$feat = ''; $feat = '';
......
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