Format code structure and align code nicely.

parent d9b0a90d
<?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;}
if ($_GET['key'] != '4r45tg') {
die;
}
require_once __DIR__ . '/config.php';
......@@ -8,6 +10,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
if ($_GET['format'] == 'georss') {
echo <<<EOF
<?xml version="1.0" encoding="utf-8"?>
......@@ -18,15 +21,15 @@ xmlns:georss="http://www.georss.org/georss">
<link href="http://podupti.me/"/>
EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$result = pg_query($dbh, $sql);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
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);
$tip = sprintf(
$tip = sprintf(
'This pod %1$s has been watched for %2$s months and its average ping time is %3$s with uptime of %4$s%% this month and was last checked on %5$s. On a score of 100 this pod is a %6$s right now',
$pod_name,
$row['monthsmonitored'],
......@@ -35,8 +38,12 @@ EOF;
$row['dateupdated'],
$row['score']
);
if ($row['secure'] == 'true') {$method = 'https://';} else {$method = 'http://';}
echo <<<EOF
if ($row['secure'] == 'true') {
$method = 'https://';
} else {
$method = 'http://';
}
echo <<<EOF
<entry>
<title>{$method}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/>
......@@ -51,9 +58,8 @@ EOF;
EOF;
}
echo '</feed>';
}
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';
} 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());
......@@ -61,34 +67,42 @@ elseif ($_GET['format'] == 'json') {
$numrows = pg_num_rows($result);
//json output, thx Vipul A M for fixing this
header('Content-type: application/json');
$rows=array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
$obj->pods = $rows;
$rows = array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
$obj->pods = $rows;
if ($_GET['method'] == 'jsonp') {
print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else {
print json_encode($obj);
}
}
else {
$i=0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
} else {
$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());
}
$numrows = pg_num_rows($result);
while ($row = pg_fetch_array($result)) {
if ($row['status'] == 'up'){$status = 'Online';} else {$status = 'Offline';}
if ($row['secure'] == 'true') {$method = 'https://';$class = 'green';} else {$method = 'http://';$class = 'red';}
if ($row['status'] == 'up') {
$status = 'Online';
} else {
$status = 'Offline';
}
if ($row['secure'] == 'true') {
$method = 'https://';
$class = 'green';
} else {
$method = 'http://';
$class = 'red';
}
echo $row['domain'] . ' Up ' . $row['uptimelast7'] . '% This Month - Located in: ' . $row['country'];
if ($i < ($numrows -1)) {
if ($i < ($numrows - 1)) {
echo ',';
}
$i++;
}
$i ++;
}
pg_free_result($result);
pg_close($dbh);
pg_free_result($result);
pg_close($dbh);
}
This diff is collapsed.
......@@ -17,4 +17,4 @@ $adminemail = '';
//admin key for deleting pods, set this as a cookie on your own
$adminkey = '';
//apikey for public api calls
$apikey= '';
$apikey = '';
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<?php
$valid=0;
$valid = 0;
require_once __DIR__ . '/../logging.php';
$log = new Logging();
$log->lfile($log_dir . '/add.php.log');
if (!$_POST['url']){
$log->lwrite('no url given '.$_POST['domain']);
if (!$_POST['url']) {
$log->lwrite('no url given ' . $_POST['domain']);
die('no url given');
}
if (!$_POST['email']){
$log->lwrite('no email given '.$_POST['domain']);
if (!$_POST['email']) {
$log->lwrite('no email given ' . $_POST['domain']);
die('no email given');
}
if (!$_POST['domain']){
$log->lwrite('no domain given '.$_POST['domain']);
if (!$_POST['domain']) {
$log->lwrite('no domain given ' . $_POST['domain']);
die('no pod domain given');
}
if (!$_POST['url']){
$log->lwrite('no api given '.$_POST['domain']);
if (!$_POST['url']) {
$log->lwrite('no api given ' . $_POST['domain']);
die('no API key for your stats');
}
if (strlen($_POST['url']) < 14){
$log->lwrite('api key too short '.$_POST['domain']);
if (strlen($_POST['url']) < 14) {
$log->lwrite('api key too short ' . $_POST['domain']);
die('API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee');
}
......@@ -32,18 +32,18 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die('Error in connection: ' . pg_last_error());
}
$sql = 'SELECT domain,pingdomurl FROM pods';
$sql = 'SELECT domain,pingdomurl FROM pods';
$result = pg_query($dbh, $sql);
if (!$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']);
$log->lwrite('domain already exists ' . $_POST['domain']);
die('domain already exists');
}
if ($row['pingdomurl'] == $_POST['url']) {
$log->lwrite('API key already exists '.$_POST['domain']);
$log->lwrite('API key already exists ' . $_POST['domain']);
die('API key already exists');
}
}
......@@ -70,38 +70,38 @@ $output = curl_exec($ch);
curl_close($ch);
if (stristr($outputssl, 'nodeName')) {
$log->lwrite('Your pod has ssl and is valid '.$_POST['domain']);
$log->lwrite('Your pod has ssl and is valid ' . $_POST['domain']);
echo 'Your pod has ssl and is valid<br>';
$valid=1;
$valid = 1;
}
if (stristr($output, 'nodeName')) {
$log->lwrite('Your pod does not have ssl but is a valid pod '.$_POST['domain']);
$log->lwrite('Your pod does not have ssl but is a valid pod ' . $_POST['domain']);
echo 'Your pod does not have ssl but is a valid pod<br>';
$valid=1;
$valid = 1;
}
if ($valid == '1') {
$sql = "INSERT INTO pods (domain, pingdomurl, email) VALUES($1, $2, $3)";
$result = pg_query_params($dbh, $sql, array($_POST['domain'], $_POST['url'], $_POST['email']));
$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());
}
$to = $adminemail;
$cc = $_POST['email'];
$to = $adminemail;
$cc = $_POST['email'];
$subject = 'New pod added to podupti.me ';
$message.= sprintf(
$message .= sprintf(
"%1$s\n\n Stats Url: %2$s\n\n Pod: %3$s\n\n",
'https://podupti.me',
'https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=' . $_POST['url'],
'https://podupti.me/db/pull.php?debug=1&domain=' . $_POST['domain']
);
$message.= 'Your pod will not show right away, needs to pass a few checks, Give it a few hours!';
$message .= 'Your pod will not show right away, needs to pass a few checks, Give it a few hours!';
$headers = 'From: ' . $_POST['email'] . "\r\nReply-To: " . $_POST['email'] . "\r\nCc: " . $_POST['email'] . "\r\n";
@mail( $to, $subject, $message, $headers );
@mail($to, $subject, $message, $headers);
echo 'Data successfully inserted! Your pod will be reviewed and live on the list in a few hours!';
pg_free_result($result);
pg_close($dbh);
} else {
$log->lwrite('Could not validate your pod on http or https, check your setup! ' . $_POST['domain']);
......
......@@ -6,26 +6,26 @@ require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$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, array($_GET['url']));
}
$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());
}
}
while ($row = pg_fetch_array($result)) {
if ($_GET['format'] == 'json') {
echo json_encode($row);
} else {
echo 'Status: ' . $row['status'] . '<br>';
echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $row['uptimelast7'] . '<br>';
echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>';
echo 'Response Time: ' . $row['responsetimelast7'] . '<br>';
echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Location: ' . $row['country'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>';
echo 'Longitude: ' . $row['long'] . '<br>';
echo 'Status: ' . $row['status'] . '<br>';
echo 'Last Git Pull: ' . $row['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $row['uptimelast7'] . '<br>';
echo 'Months Monitored: ' . $row['monthsmonitored'] . '<br>';
echo 'Response Time: ' . $row['responsetimelast7'] . '<br>';
echo 'User Rating: ' . $row['userrating'] . '<br>';
echo 'Server Location: ' . $row['country'] . '<br>';
echo 'Latitude: ' . $row['lat'] . '<br>';
echo 'Longitude: ' . $row['long'] . '<br>';
}
}
pg_free_result($result);
pg_free_result($result);
pg_close($dbh);
<?php
require_once __DIR__ . '/../config.php';
$keep = (60 * 60 * 6) * 1;
$keep = (60 * 60 * 6) * 1;
$dump_date = date('Ymd_Hs');
$file_name = $backup_dir . '/dump_' . $dump_date . '.sql';
system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --username=$pguser $pgdb >> $file_name");
echo "pg backup of $pgdb made";
$dirh = dir($backup_dir);
while($entry = $dirh->read()) {
while ($entry = $dirh->read()) {
$old_file_time = (date('U') - $keep);
$file_created = filectime("$backup_dir/$entry");
$file_created = filectime("$backup_dir/$entry");
if ($file_created < $old_file_time && !is_dir($entry)) {
if(unlink("$backup_dir/$entry")) {
if (unlink("$backup_dir/$entry")) {
echo 'Cleaned up old backups';
}
}
......
<?php
if (!$_GET['domain']){
if (!$_GET['domain']) {
die('no pod domain given');
}
if (!$_GET['token']){
if (!$_GET['token']) {
die('no token given');
}
if (strlen($_GET['token']) < 6){
if (strlen($_GET['token']) < 6) {
die('bad token');
}
$domain = $_GET['domain'];
......@@ -16,7 +16,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
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);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
......@@ -25,13 +25,13 @@ while ($row = pg_fetch_array($result)) {
if ($row['token'] <> $_GET['token']) {
die('token not a match');
}
if ($row['tokenexpire'] < date('Y-m-d H:i:s', time())) {
if ($row['tokenexpire'] < date('Y-m-d H:i:s', time())) {
die('token expired');
}
//delete pod
if ($_GET['delete'] == $row['token']){
$sql = "DELETE FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['domain']));
if ($_GET['delete'] == $row['token']) {
$sql = "DELETE FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$_GET['domain']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
} else {
......@@ -39,20 +39,20 @@ while ($row = pg_fetch_array($result)) {
}
}
//save and exit
if ($_GET['save'] == $row['token']){
if ($_GET['save'] == $row['token']) {
if ($_GET['weight'] > 10) {
die('10 is max weight');
}
$sql = "UPDATE pods SET email=$1, pingdomurl=$2, weight=$3 WHERE domain = $4";
$result = pg_query_params($dbh, $sql, array($_GET['email'],$_GET['pingdomurl'],$_GET['weight'],$_GET['domain']));
$sql = "UPDATE pods SET email=$1, pingdomurl=$2, weight=$3 WHERE domain = $4";
$result = pg_query_params($dbh, $sql, [$_GET['email'], $_GET['pingdomurl'], $_GET['weight'], $_GET['domain']]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$to = $_GET['email'];
$to = $_GET['email'];
$subject = 'Edit notice from poduptime ';
$message = 'Data for ' . $_GET['domain'] . " Updated. If it was not you reply and let me know! \n\n";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org,". $_GET['oldemail'] ."\r\n";
@mail( $to, $subject, $message, $headers );
$headers = "From: support@diasp.org\r\nCc:support@diasp.org," . $_GET['oldemail'] . "\r\n";
@mail($to, $subject, $message, $headers);
pg_free_result($result);
pg_close($dbh);
die('Data saved. Will go into effect on next hourly change');
......
<?php
$systemTimeZone = system('date +%Z');
if (!$_POST['domain']){
if (!$_POST['domain']) {
die('no pod domain given');
}
$domain = $_POST['domain'];
......@@ -11,7 +11,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
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);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
......@@ -21,36 +21,36 @@ if ($rows <= 0) {
die('domain not found');
}
while ($row = pg_fetch_array($result)) {
if ($_POST['email']){
if ($_POST['email']) {
if ($row['email'] <> $_POST['email']) {
die('email not a match');
}
$uuid = md5(uniqid($domain, true));
$uuid = md5(uniqid($domain, true));
$expire = date('Y-m-d H:i:s', time() + 2700);
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
$result = pg_query_params($dbh, $sql, array($uuid,$expire));
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
$result = pg_query_params($dbh, $sql, [$uuid, $expire]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$to = $_POST['email'];
$to = $_POST['email'];
$subject = 'Temporary edit key for podupti.me';
$message = 'Link: https://podupti.me/db/edit.php?domain=' . $_POST['domain'] . '&token=' . $uuid . ' Expires: ' . $expire . ' ' . $systemTimeZone . "\n\n";
$headers = "From: support@diasp.org\r\nBcc: support@diasp.org\r\n";
@mail( $to, $subject, $message, $headers );
@mail($to, $subject, $message, $headers);
echo 'Link sent to your email';
} elseif (!$_POST['email']){
$uuid = md5(uniqid($domain, true));
} elseif (!$_POST['email']) {
$uuid = md5(uniqid($domain, true));
$expire = date('Y-m-d H:i:s', time() + 9700);
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
$result = pg_query_params($dbh, $sql, array($uuid,$expire));
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
$result = pg_query_params($dbh, $sql, [$uuid, $expire]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
$to = 'support@diasp.org';
$to = 'support@diasp.org';
$subject = 'FORWARD REQUEST: Temporary edit key for podupti.me';
$message = 'User trying to edit pod without email address. Email found: ' . $row['email'] . ' Link: https://podupti.me/db/edit.php?domain=' . $_POST['domain'] . '&token=' . $uuid . ' Expires: ' . $expire . ' ' . $systemTimeZone . "\n\n";
$headers = "From: support@diasp.org\r\nBcc: support@diasp.org\r\n";
@mail( $to, $subject, $message, $headers );
@mail($to, $subject, $message, $headers);
echo 'Link sent to administrator to review and verify, if approved they will forward the edit key to you.';
}
pg_free_result($result);
......
<?php
if (!$_POST['domain']){
if (!$_POST['domain']) {
die('no pod domain given');
}
if (!$_POST['adminkey']){
if (!$_POST['adminkey']) {
die('no token given');
}
if (!$_POST['action']){
if (!$_POST['action']) {
die('no action selected');
}
$domain = $_POST['domain'];
......@@ -16,7 +16,7 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
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);
if (!$result) {
die('one Error in SQL query: ' . pg_last_error());
......@@ -26,29 +26,29 @@ while ($row = pg_fetch_array($result)) {
die('admin key fail');
}
//save and exit
if ($_POST['action'] == 'delete') {
$sql = "DELETE from pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($domain));
if (!$result) {
die('two Error in SQL query: ' . pg_last_error());
}
if ($row['email']) {
$to = $row['email'];
$subject = 'Pod deleted from poduptime ';
$message = 'Pod ' . $_POST['domain'] . ' was deleted from podupti.me as it was dead on the list. ' . $_POST['comments'] . " Feel free to add back at any time. \n\n";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org,". $row['email'] . "\r\n";
@mail( $to, $subject, $message, $headers );
}
pg_free_result($result);
pg_close($dbh);
} elseif ($_POST['action'] == 'warn') {
if ($row['email']) {
$to = $row['email'];
$subject = 'Pod removal warning from poduptime ';
$message = 'Pod ' . $_POST['domain'] . ' is on the list to be deleted now because: ' . $_POST['comments'] . ". \n\n Please let me know if you need help fixing before it is removed. \n\n";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org,". $row['email'] . "\r\n";
@mail( $to, $subject, $message, $headers );
}
if ($_POST['action'] == 'delete') {
$sql = "DELETE from pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, [$domain]);
if (!$result) {
die('two Error in SQL query: ' . pg_last_error());
}
if ($row['email']) {
$to = $row['email'];
$subject = 'Pod deleted from poduptime ';
$message = 'Pod ' . $_POST['domain'] . ' was deleted from podupti.me as it was dead on the list. ' . $_POST['comments'] . " Feel free to add back at any time. \n\n";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org," . $row['email'] . "\r\n";
@mail($to, $subject, $message, $headers);
}
pg_free_result($result);
pg_close($dbh);
} elseif ($_POST['action'] == 'warn') {
if ($row['email']) {
$to = $row['email'];
$subject = 'Pod removal warning from poduptime ';
$message = 'Pod ' . $_POST['domain'] . ' is on the list to be deleted now because: ' . $_POST['comments'] . ". \n\n Please let me know if you need help fixing before it is removed. \n\n";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org," . $row['email'] . "\r\n";
@mail($to, $subject, $message, $headers);
}
}
echo $result;
}
This diff is collapsed.
<?php
if (!$_POST['username']){
if (!$_POST['username']) {
die('no username given');
}
if (!$_POST['userurl']){
if (!$_POST['userurl']) {
die('no userurl given');
}
if (!$_POST['domain']){
if (!$_POST['domain']) {
die('no pod domain given');
}
if (!$_POST['comment']){
if (!$_POST['comment']) {
die('no comment');
}
if (!$_POST['rating']){
if (!$_POST['rating']) {
die('no rating given');
}
......@@ -21,16 +21,16 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$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, array($_POST['domain'], $_POST['comment'], $_POST['rating'], $_POST['username'], $_POST['userurl']));
$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());
}
$to = $adminemail;
$to = $adminemail;
$subject = 'New rating added to poduptime ';
$message = 'Pod:' . $_POST['domain'] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n";
$headers = 'From: ' . $_POST['email'] . "\r\n";
@mail( $to, $subject, $message, $headers );
@mail($to, $subject, $message, $headers);
echo 'Comment posted!';
pg_free_result($result);
pg_close($dbh);
<?php
$debug=1;
$debug = 1;
//* Copyright (c) 2011-2016, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$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, array($domain));
if (!$result) {die('Error in SQL query: ' . pg_last_error());}
if (!$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());
}
$apikey = pg_fetch_all($result);
$upti = curl_init();
$key = $apikey[0]['pingdomurl'];
$data = array('all_time_uptime_ratio' => 1, 'format' => 'json', 'custom_uptime_ratios' => '7-30-60-90', 'response_times' => 1, 'response_times_average' => 86400, 'api_key' => $key, 'callback' => 'jsonpUptimeRobot');
$upti = curl_init();
$key = $apikey[0]['pingdomurl'];
$data = ['all_time_uptime_ratio' => 1, 'format' => 'json', 'custom_uptime_ratios' => '7-30-60-90', 'response_times' => 1, 'response_times_average' => 86400, 'api_key' => $key, 'callback' => 'jsonpUptimeRobot'];
curl_setopt($upti, CURLOPT_URL, 'https://api.uptimerobot.com/v2/getMonitors');
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_POST, 1);
curl_setopt($upti, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
$uptimerobot = curl_exec($upti); curl_close($upti);
$json_encap = 'jsonpUptimeRobot()'; $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $uptr = json_decode($up2);
$uptimerobot = curl_exec($upti);
curl_close($upti);
$json_encap = 'jsonpUptimeRobot()';
$up2 = substr($uptimerobot, strlen($json_encap) - 1, strlen($uptimerobot) - strlen($json_encap));
$uptr = json_decode($up2);
echo '<b>UptimeRobot Json displayed in Human</b><br><br>';
echo 'Name: ' . $uptr->monitors[0]->friendly_name . '<br>';
echo 'Url: ' . $uptr->monitors[0]->url . '<br>';
echo 'Interval: ' . $uptr->monitors[0]->interval . 'ms<br>';
echo 'Uptime: ' . $uptr->monitors[0]->all_time_uptime_ratio . '%<br>';
echo 'Response Time: ' . round($uptr->monitors[0]->average_response_time) . 'ms<br>';
if ($uptr->monitors[0]->status == 2) {$live = 'Up';}
if ($uptr->monitors[0]->status == 0) {$live = 'Paused';}
if ($uptr->monitors[0]->status == 1) {$live = 'Not Checked Yet';}
if ($uptr->monitors[0]->status == 8) {$live = 'Seems Down';}
if ($uptr->monitors[0]->status == 9) {$live = 'Down';}
if ($uptr->monitors[0]->status == 2) {
$live = 'Up';
}
if ($uptr->monitors[0]->status == 0) {
$live = 'Paused';
}
if ($uptr->monitors[0]->status == 1) {
$live = 'Not Checked Yet';
}
if ($uptr->monitors[0]->status == 8) {
$live = 'Seems Down';
}
if ($uptr->monitors[0]->status == 9) {
$live = 'Down';
}
echo 'Status: ' . $live;
pg_free_result($result);
pg_close($dbh);
......
......@@ -3,7 +3,6 @@ $dur = (time() - filemtime('last.data'));
echo $dur;
if ($dur > 4500) {
http_response_code(500);
}
else {
} else {
http_response_code(200);
}
This diff is collapsed.
<br>
Want your pod listed?<br>
Its easy start monitoring on your pod with a free <a href="https://uptimerobot.com" target="new">Uptime Robot</a> account.<br>
Create a monitor for your pod, then in "My Settings" create a monitor-specific API key and paste below.<br>
<br><form action="https://podupti.me/db/add.php" method="post">
Monitor API Key:<input type="text" name="url" class="xlarge span8" placeholder="m58978-80abdb799f6ccf15e3e4ttwe"> (don't copy the period on the end)<br>
Pod domainname:<input type="text" name="domain" class="xlarge span4" placeholder="domain.com"><br>
Your Email:<input type="text" name="email" class="xlarge span4" placeholder="user@domain.com"><br>
<input type="submit" value="submit">
</form>
<br>
Want your pod listed?<br>
Its easy start monitoring on your pod with a free <a href="https://uptimerobot.com" target="new">Uptime Robot</a> account.<br>
Create a monitor for your pod, then in "My Settings" create a monitor-specific API key and paste below.<br>
<br>
<form action="https://podupti.me/db/add.php" method="post">
Monitor API Key:<input type="text" name="url" class="xlarge span8" placeholder="m58978-80abdb799f6ccf15e3e4ttwe"> (don't copy the period on the end)<br>
Pod domainname:<input type="text" name="domain" class="xlarge span4" placeholder="domain.com"><br>
Your Email:<input type="text" name="email" class="xlarge span4" placeholder="user@domain.com"><br>
<input type="submit" value="submit">
</form>
<form action="https://podupti.me/db/gettoken.php" method="post">Pod Domainname:<input type="text" name="domain">Registered Email:<input type="text" name="email" placeholder="Ok to leave blank if you forgot"><input type=submit value="send"></form>
<form action="https://podupti.me/db/gettoken.php" method="post">
Pod Domainname: <input type="text" name="domain">
Registered Email: <input type="text" name="email" placeholder="Ok to leave blank if you forgot">
<input type="submit" value="send">
</form>
......@@ -5,11 +5,15 @@ $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$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";
$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());
}
$row = pg_fetch_all($result);
if ($row[0]['secure'] == 'true') {$ssl = 's';} else {$ssl = '';}
if ($row[0]['secure'] == 'true') {
$ssl = 's';
} else {
$ssl = '';
}
header('Location: http' . $ssl . '://' . $row[0]['domain'] . '/users/sign_up');
<html><head>
<style type="text/css">
#slider { margin: 10px;width:250px;display:inline-block; }
#rating { height: 35px;width:35px; }
</style>
<script>
$(document).ready(function() {
$('#addrating').click(function() {
$('#commentform').show('slow'); $('#ratings').hide('slow');