Commit bd57ef3f authored by David Morley's avatar David Morley

Merge branch 'noplanman-simple_dies'

parents 3f63e29d 55be40e2
<?php
//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') {
die;
}
$_GET['key'] === '4r45tg' || die;
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
if ($_GET['format'] == 'georss') {
echo <<<EOF
......@@ -23,9 +20,8 @@ xmlns:georss="http://www.georss.org/georss">
EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
$pod_name = htmlentities($row['name'], ENT_QUOTES);
......@@ -61,9 +57,8 @@ EOF;
} 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';
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this
header('Content-type: application/json');
......@@ -79,9 +74,8 @@ EOF;
$i = 0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up') {
......
......@@ -3,14 +3,12 @@ $tt = 0;
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE hidden <> 'no' AND score < 50 ORDER BY weightedscore";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
?>
......
......@@ -29,14 +29,12 @@ if (strlen($_POST['url']) < 14) {
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain,pingdomurl FROM pods';
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($row['domain'] == $_POST['domain']) {
$log->lwrite('domain already exists ' . $_POST['domain']);
......@@ -82,9 +80,8 @@ if (stristr($output, 'nodeName')) {
if ($valid == '1') {
$sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)";
$result = pg_query_params($dbh, $sql, [$_POST['domain'], $_POST['url'], $_POST['email']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$to = $adminemail;
$cc = $_POST['email'];
$subject = 'New pod added to podupti.me ';
......
......@@ -4,14 +4,12 @@
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || 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";
$result = pg_query_params($dbh, $sql, [$_GET['url']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') {
echo json_encode($row);
......
<?php
if (!$_GET['domain']) {
die('no pod domain given');
}
if (!$_GET['token']) {
die('no token given');
}
if (strlen($_GET['token']) < 6) {
die('bad token');
}
$_GET['domain'] || die('no pod domain given');
$_GET['token'] || die('no token given');
strlen($_GET['token']) < 6 || die('bad token');
$domain = $_GET['domain'];
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT domain,email,token,tokenexpire,pingdomurl,weight FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($row['token'] <> $_GET['token']) {
die('token not a match');
......
......@@ -8,14 +8,12 @@ $domain = $_POST['domain'];
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$rows = pg_num_rows($result);
if ($rows <= 0) {
die('domain not found');
......
......@@ -13,14 +13,12 @@ $domain = $_POST['domain'];
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('one Error in SQL query: ' . pg_last_error());
}
$result || die('one Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
if ($adminkey <> $_POST['adminkey']) {
die('admin key fail');
......
......@@ -38,9 +38,8 @@ if ($debug) {
}
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh2 = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
//foreach pod check it and update db
$domain = isset($_GET['domain']) ? $_GET['domain'] : null;
......@@ -53,10 +52,8 @@ if ($domain) {
$sleep = '1';
$result = pg_query($dbh, $sql);
}
if (!$result) {
die('Error in SQL query1: ' . pg_last_error());
}
$result || die('Error in SQL query1: ' . pg_last_error());
while ($row = pg_fetch_all($result)) {
$numrows = pg_num_rows($result);
for ($i = 0; $i < $numrows; $i ++) {
......@@ -74,9 +71,8 @@ while ($row = pg_fetch_all($result)) {
$adminrating = [];
$sqlforr = "SELECT * FROM rating_comments WHERE domain = $1";
$ratings = pg_query_params($dbh, $sqlforr, [$domain]);
if (!$ratings) {
die('Error in SQL query2: ' . pg_last_error());
}
$ratings || die('Error in SQL query2: ' . pg_last_error());
$numratings = pg_num_rows($ratings);
while ($myrow = pg_fetch_assoc($ratings)) {
if ($myrow['admin'] == 0) {
......@@ -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
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]);
if (!$result) {
die('Error in SQL query3: ' . pg_last_error());
}
$result || die('Error in SQL query3: ' . pg_last_error());
if ($debug) {
echo '<br>Score out of 100: ' . $score . '<br>';
}
......
<?php
if (!$_POST['username']) {
die('no username given');
}
if (!$_POST['userurl']) {
die('no userurl given');
}
if (!$_POST['domain']) {
die('no pod domain given');
}
if (!$_POST['comment']) {
die('no comment');
}
if (!$_POST['rating']) {
die('no rating given');
}
$_POST['username'] || die('no username given');
$_POST['userurl'] || die('no userurl given');
$_POST['domain'] || die('no pod domain given');
$_POST['comment'] || die('no comment');
$_POST['rating'] || die('no rating given');
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$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']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$to = $adminemail;
$subject = 'New rating added to poduptime ';
$message = 'Pod:' . $_POST['domain'] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n";
......
......@@ -4,15 +4,13 @@ $debug = 1;
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$domain = isset($_GET['domain']) ? $_GET['domain'] : null;
$sql = "SELECT pingdomurl FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$domain]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$apikey = pg_fetch_all($result);
$upti = curl_init();
$key = $apikey[0]['pingdomurl'];
......@@ -52,5 +50,3 @@ if ($uptr->monitors[0]->status == 9) {
echo 'Status: ' . $live;
pg_free_result($result);
pg_close($dbh);
?>
......@@ -2,14 +2,12 @@
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || 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";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query1: ' . pg_last_error());
}
$result || die('Error in SQL query1: ' . pg_last_error());
$row = pg_fetch_all($result);
if ($row[0]['secure'] == 'true') {
$ssl = 's';
......
<?php
$_GET['domain'] || die('domain not specified');
?>
<html>
<head>
<style type="text/css">
......@@ -51,17 +55,12 @@
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
if (is_null($_GET['domain'])) {
die('domain not specified');
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM rating_comments WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$_GET['domain']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$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>';
if (!$numrows) {
......
......@@ -6,9 +6,8 @@ require_once __DIR__ . '/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());
}
$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 uptimelast7 DESC";
......@@ -16,9 +15,8 @@ if ($hidden == 'true') {
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND signup = 1 ORDER BY uptimelast7 DESC";
}
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
?>
......
......@@ -3,9 +3,8 @@ $tt = 0;
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$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 uptimelast7 DESC";
......@@ -13,9 +12,8 @@ if ($hidden == 'true') {
$sql = 'SELECT * FROM pods ORDER BY uptimelast7 DESC';
}
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
?>
......
......@@ -24,14 +24,12 @@ foreach ($csv as $cords) {
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$result || die('Error in SQL query: ' . pg_last_error());
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
$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