Commit a5d68080 authored by dmorley's avatar dmorley

cleanup

parent eb8ddf7d
db/api-more.php
\ No newline at end of file
<?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
//this is just a single api for a pod for the android app to get data
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url']));
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
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_close($dbh);
?>
<?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") {exit;}
include('db/config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
include('db/config.php');
$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"?>
<feed xmlns="http://www.w3.org/2005/Atom"
echo <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:georss="http://www.georss.org/georss">
<title>Diaspora Pods</title>
<subtitle>IP Locations of Diaspora pods on podupti.me</subtitle>
<link href="http://podupti.me/"/>
EOF;
EOF;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes'";
$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)) {
$pod_name = htmlentities($row["name"], ENT_QUOTES);
$tip="";
$tip.="\n This pod {$pod_name} has been watched for {$row["monthsmonitored"]} months and its average ping time is {$row["responsetimelast7"]} with uptime of {$row["uptimelast7"]}% this month and was last checked on {$row["dateupdated"]}. ";
$tip.="On a score of -20 to +20 this pod is a {$row["score"]} right now";
if ($row["secure"] == "true") {$method = "https://";} else {$method = "http://";}
echo <<<EOF
while ($row = pg_fetch_array($result)) {
$pod_name = htmlentities($row["name"], ENT_QUOTES);
$tip="";
$tip.="\n This pod {$pod_name} has been watched for {$row["monthsmonitored"]} months and its average ping time is {$row["responsetimelast7"]} with uptime of {$row["uptimelast7"]}% this month and was last checked on {$row["dateupdated"]}. ";
$tip.="On a score of -20 to +20 this pod is a {$row["score"]} right now";
if ($row["secure"] == "true") {$method = "https://";} else {$method = "http://";}
echo <<<EOF
<entry>
<title>{$method}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/>
......@@ -38,10 +38,9 @@ echo <<<EOF
<georss:featureName>{$row['domain']}</georss:featureName>
</entry>
EOF;
}
echo "</feed>";
EOF;
}
echo "</feed>";
}
elseif ($_GET['format'] == "json") {
$sql = "SELECT id,domain,status,secure,score,userrating,adminrating,city,state,country,lat,long,ip,ipv6,hgitdate,hgitref,pingdomurl,pingdomlast,monthsmonitored,uptimelast7,responsetimelast7,hruntime,hencoding,dateCreated,dateUpdated,dateLaststats,hidden FROM pods";
......@@ -50,7 +49,7 @@ elseif ($_GET['format'] == "json") {
die("Error in SQL query: " . pg_last_error());
}
$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');
$rows=array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
......@@ -60,7 +59,6 @@ elseif ($_GET['format'] == "json") {
} else {
print json_encode($obj);
}
} else {
$i=0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
......@@ -76,9 +74,9 @@ elseif ($_GET['format'] == "json") {
if ($i < ($numrows -1)) {
echo ",";
}
$i++;
$i++;
}
}
pg_free_result($result);
pg_close($dbh);
pg_free_result($result);
pg_close($dbh);
?>
......@@ -107,7 +107,7 @@ echo "✪";
echo "<td>" . $row["country"] . "</td>\n";
?>
<td>
<form method="post" action="db/kill.php">
<form method="post" action="db/kill.php" target="_blank">
<input name="comments" size=10>
<input name="domain" value="<?php echo $row["domain"] ?>" type="hidden">
<input name="adminkey" value="<?php echo $_COOKIE["adminkey"] ?>" type="hidden">
......
<!-- /* 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;
include('config.php');
include('../logging.php');
include('config.php');
include('../logging.php');
$log = new Logging();
$log->lfile($log_dir."/add.php.log");
if (!$_POST['url']){
......@@ -25,45 +25,44 @@ if (strlen($_POST['url']) < 14){
echo "API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee";$log->lwrite('api key too short '.$_POST['domain']);
die;
}
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$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());
}
while ($row = pg_fetch_array($result)) {
if ($row["domain"] == $_POST['domain']) {
echo "domain already exists";$log->lwrite('domain already exists '.$_POST['domain']);die;
}
if ($row["pingdomurl"] == $_POST['url']) {
echo "API key already exists";$log->lwrite('API key already exists '.$_POST['domain']);die;
$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']) {
echo "domain already exists";$log->lwrite('domain already exists '.$_POST['domain']);die;
}
if ($row["pingdomurl"] == $_POST['url']) {
echo "API key already exists";$log->lwrite('API key already exists '.$_POST['domain']);die;
}
}
//curl the header of pod with and without https
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, "https://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($chss, CURLOPT_POST, 0);
curl_setopt($chss, CURLOPT_HEADER, 0);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_NOBODY, 0);
$outputssl = curl_exec($chss);
curl_close($chss);
//curl the header of pod with and without https
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, "https://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($chss, CURLOPT_POST, 0);
curl_setopt($chss, CURLOPT_HEADER, 0);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_NOBODY, 0);
$outputssl = curl_exec($chss);
curl_close($chss);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch);
curl_close($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch);
curl_close($ch);
if (stristr($outputssl, 'nodeName')) {
echo "Your pod has ssl and is valid<br>";$log->lwrite('Your pod has ssl and is valid '.$_POST['domain']);
......@@ -73,7 +72,6 @@ if (stristr($output, 'nodeName')) {
echo "Your pod does not have ssl but is a valid pod<br>";$log->lwrite('Your pod does not have ssl but is a valid pod '.$_POST['domain']);
$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']));
......@@ -94,7 +92,7 @@ if ($valid=="1") {
pg_close($dbh);
} else {
echo "Could not validate your pod on http or https, check your setup!<br>Take a look at <a href='https://".$_POST['domain']."/nodeinfo/1.0'>your /nodeinfo</a>";$log->lwrite('Could not validate your pod on http or https, check your setup! '.$_POST['domain']);
echo "Could not validate your pod on http or https, check your setup!<br>Take a look at <a href='https://".$_POST['domain']."/nodeinfo/1.0'>your /nodeinfo</a>";$log->lwrite('Could not validate your pod on http or https, check your setup! '.$_POST['domain']);
}
$log->lclose();
?>
<?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
//this is just a single api for a pod for the android app to get data
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url']));
if (!$result) {
}
$sql = "SELECT * FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url']));
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
}
while ($row = pg_fetch_array($result)) {
echo "Status: " . $row["status"] . "<br>";
echo "Last Git Pull: " . $row["hgitdate"] . "<br>";
echo "Uptime This Month " . $row["uptimelast7"] . "<br>";
......@@ -21,7 +21,7 @@
echo "Server Location: ". $row["country"] . "<br>";
echo "Latitude: ". $row["lat"] . "<br>";
echo "Longitude: ". $row["long"] . "<br>";
}
pg_free_result($result);
pg_close($dbh);
}
pg_free_result($result);
pg_close($dbh);
?>
......@@ -7,12 +7,12 @@ system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --username=$pguser $pg
echo "pg backup of $pgdb made";
$dirh = dir($backup_dir);
while($entry = $dirh->read()) {
$old_file_time = (date("U") - $keep);
$file_created = filectime("$backup_dir/$entry");
if ($file_created < $old_file_time && !is_dir($entry)) {
if(unlink("$backup_dir/$entry")) {
echo "Cleaned up old backups";
}
}
$old_file_time = (date("U") - $keep);
$file_created = filectime("$backup_dir/$entry");
if ($file_created < $old_file_time && !is_dir($entry)) {
if(unlink("$backup_dir/$entry")) {
echo "Cleaned up old backups";
}
}
}
?>
<?php
include('config.php');
include('config.php');
if (!$_GET['domain']){
echo "no pod domain given";
die;
......@@ -13,29 +13,28 @@ if (strlen($_GET['token']) < 6){
die;
}
$domain = $_GET['domain'];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
$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'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
if ($row["token"] <> $_GET['token']) {
echo "token not a match";die;
}
if ($row["tokenexpire"] < date("Y-m-d H:i:s", time())) {
echo "token expired";die;
$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());
}
//save and exit
if ($_GET['save'] == $row["token"]){
if ($_GET['weight'] > 10) {
while ($row = pg_fetch_array($result)) {
if ($row["token"] <> $_GET['token']) {
echo "token not a match";die;
}
if ($row["tokenexpire"] < date("Y-m-d H:i:s", time())) {
echo "token expired";die;
}
//save and exit
if ($_GET['save'] == $row["token"]){
if ($_GET['weight'] > 10) {
echo "10 is max weight";
die;
}
}
$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']));
if (!$result) {
......@@ -46,22 +45,19 @@ if ($_GET['weight'] > 10) {
$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 );
pg_free_result($result);
pg_close($dbh);
echo "Data saved. Will go into effect on next hourly change";
die;
}
//form
echo "Authorized to edit <b>" . $domain . "</b> until " .$row["tokenexpire"] . "<br>";
echo "<form action='' method='get'><input type=hidden name=oldemail value=" . $row["email"] . "><input type=hidden name=save value=" . $_GET['token'] . "><input type=hidden name=token value=" . $_GET['token'] . "><input type=hidden name=domain value=" . $_GET['domain'] . ">";
echo "Stats Key <input type=text size=50 name=pingdomurl value=" .$row["pingdomurl"] . ">Uptimerobot API key for this monitor<br>";
echo "Email <input type=text size=20 name=email value=" .$row["email"] . "><br>";
echo "Weight <input type=text size=2 name=weight value=" .$row["weight"] . "> This lets you weight your pod lower on the list if you have too much trafic coming in, 10 is the norm use lower to move down the list.<br>";
echo "<input type=submit name=submit><br><br><br>";
}
echo "delete button soon, remove your stats data and save to goto hidden list for now.<br>";
//form
echo "Authorized to edit <b>" . $domain . "</b> until " .$row["tokenexpire"] . "<br>";
echo "<form action='' method='get'><input type=hidden name=oldemail value=" . $row["email"] . "><input type=hidden name=save value=" . $_GET['token'] . "><input type=hidden name=token value=" . $_GET['token'] . "><input type=hidden name=domain value=" . $_GET['domain'] . ">";
echo "Stats Key <input type=text size=50 name=pingdomurl value=" .$row["pingdomurl"] . ">Uptimerobot API key for this monitor<br>";
echo "Email <input type=text size=20 name=email value=" .$row["email"] . "><br>";
echo "Weight <input type=text size=2 name=weight value=" .$row["weight"] . "> This lets you weight your pod lower on the list if you have too much trafic coming in, 10 is the norm use lower to move down the list.<br>";
echo "<input type=submit name=submit><br><br><br>";
echo "delete button soon, remove your stats data and save to goto hidden list for now.<br>";
}
?>
<?php
include('config.php');
include('config.php');
$systemTimeZone = system('date +%Z');
if (!$_POST['domain']){
echo "no pod domain given";
die;
}
$domain = $_POST['domain'];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
$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'";
$result = pg_query($dbh, $sql);
if (!$result) {
}
$sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
}
$rows = pg_num_rows($result);
if ($rows <= 0) {
echo "domain not found";die;
}
while ($row = pg_fetch_array($result)) {
if ($_POST['email']){
while ($row = pg_fetch_array($result)) {
if ($_POST['email']){
if ($row["email"] <> $_POST['email']) {
echo "email not a match";die;
}
$uuid = md5(uniqid($domain, true));
$expire = date("Y-m-d H:i:s", time() + 2700);
$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));
if (!$result) {
......@@ -40,13 +36,10 @@ $expire = date("Y-m-d H:i:s", time() + 2700);
$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 );
echo "Link sent to your email";
} elseif (!$_POST['email']){
$uuid = md5(uniqid($domain, true));
$expire = date("Y-m-d H:i:s", time() + 9700);
} 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));
if (!$result) {
......@@ -57,10 +50,8 @@ $expire = date("Y-m-d H:i:s", time() + 9700);
$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 );
echo "Link sent to administrator to review and verify, if approved they will forward the edit key to you.";
}
}
pg_free_result($result);
pg_close($dbh);
}
......
<?php
include('config.php');
include('config.php');
if (!$_POST['domain']){
echo "no pod domain given";
die;
......@@ -14,21 +14,21 @@ if (!$_POST['action']){
}
$domain = $_POST['domain'];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
$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'";
$result = pg_query($dbh, $sql);
if (!$result) {
}
$sql = "SELECT email FROM pods WHERE domain = '$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("one Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
if ($adminkey <> $_POST['adminkey']) {
echo "admin key fail";die;
}
//save and exit
if ($_POST['action'] == "delete") {
while ($row = pg_fetch_array($result)) {
if ($adminkey <> $_POST['adminkey']) {
echo "admin key fail";die;
}
//save and exit
if ($_POST['action'] == "delete") {
$sql = "DELETE from pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($domain));
if (!$result) {
......@@ -43,7 +43,7 @@ if ($_POST['action'] == "delete") {
}
pg_free_result($result);
pg_close($dbh);
} elseif ($_POST['action'] == "warn") {
} elseif ($_POST['action'] == "warn") {
if ($row["email"]) {
$to = $row["email"];
$subject = "Pod removal warning from poduptime ";
......@@ -51,10 +51,7 @@ if ($_POST['action'] == "delete") {
$headers = "From: support@diasp.org\r\nCc:support@diasp.org,". $row["email"] ."\r\n";
@mail( $to, $subject, $message, $headers );
}
}
header( 'Location: https://podupti.me/?cleanup=true' ) ;
}
echo $result;
}
?>
This diff is collapsed.
......@@ -17,8 +17,8 @@ exit;
else
echo "Pulling in new pod data";
cd /var/www/poduptime/db
php5 pull.php debug=1
php pull.php debug=1
touch last.data
php5 backup.php
php backup.php
rm /tmp/index.google
fi
<?php
include('config.php');
include('config.php');
if (!$_POST['username']){
echo "no username given";
die;
......@@ -20,24 +20,21 @@ if (!$_POST['rating']){
echo "no rating given";
die;
}
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
$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']));
if (!$result) {
}
$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']));
if (!$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";
$headers = "From: ".$_POST["email"]."\r\n";
@mail( $to, $subject, $message, $headers );
echo "Comment posted!";
pg_free_result($result);
pg_close($dbh);
}
$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 );
echo "Comment posted!";
pg_free_result($result);
pg_close($dbh);
?>
......@@ -2,41 +2,35 @@
$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. */
include('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());
}
$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());}
$apikey = pg_fetch_all($result);
$upti = curl_init();
$curlurl = "https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=".$apikey[0]['pingdomurl'];
curl_setopt($upti, CURLOPT_URL, $curlurl);
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($upti, CURLOPT_FOLLOWLOCATION, true);
$uptimerobot = curl_exec($upti); curl_close($upti);
$json_encap = "jsonUptimeRobotApi()"; $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $uptr = json_decode($up2);
var_dump($uptimerobot);
echo "<br><br>UptimeRobot Json displayed in Human<br>";
$upti = curl_init();
$curlurl = "https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=".$apikey[0]['pingdomurl'];
curl_setopt($upti, CURLOPT_URL, $curlurl);
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($upti, CURLOPT_FOLLOWLOCATION, true);
$uptimerobot = curl_exec($upti); curl_close($upti);
$json_encap = "jsonUptimeRobotApi()"; $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->monitor{'0'}->friendlyname."<br>";
echo "Url: ".$uptr->monitors->monitor{'0'}->url."<br>";
echo "Interval: ".$uptr->monitors->monitor{'0'}->interval."ms<br>";
echo "Uptime: ".$uptr->monitors->monitor{'0'}->alltimeuptimeratio."%<br>";
echo "Response Time: ".$uptr->monitors->monitor{'0'}->responsetime{'0'}->value."ms<br>";
if ($uptr->monitors->monitor{'0'}->status == 2) {$live = "Up";}
if ($uptr->monitors->monitor{'0'}->status == 1) {$live = "Paused";}
if ($uptr->monitors->monitor{'0'}->status == 0) {$live = "Paused";}
if ($uptr->monitors->monitor{'0'}->status == 1) {$live = "Not Checked Yet";}
if ($uptr->monitors->monitor{'0'}->status == 8) {$live = "Seems Down";}
if ($uptr->monitors->monitor{'0'}->status == 9) {$live = "Down";}
echo "Status: ".$live;
pg_free_result($result);
pg_close($dbh);
pg_free_result($result);
pg_close($dbh);
?>
......@@ -2,9 +2,9 @@
$dur = (time() - filemtime("last.data"));
echo $dur;
if ($dur > 4500) {
http_response_code(500);
http_response_code(500);
}
else {
http_response_code(200);
http_response_code(200);
}
?>
<?php
include('db/config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
include('db/config.php');
$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";
$result = pg_query($dbh, $sql);
if (!$result) {
}
$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="";}
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: 30px;width:30px; }
</style>
<script>
$(document).ready(function() {
<style type="text/css">
#slider { margin: 10px;width:250px;display:inline-block; }
#rating { height: 30px;width:30px; }
</style>
<script>
$(document).ready(function() {
$('#addrating').click(function() {
$('#commentform').show('slow'); $('#ratings').hide('slow');
});
$('#submitrating').click(function() {
<?php
echo "var domain = \"{$_GET['domain']}\";";
?>
......@@ -22,50 +21,50 @@ $.ajax({
if (msg == 1) {
$("#commentform").replaceWith("<h3>Your comment was saved, Thank You!</h3>");
} else {$('#errortext').html(msg);$('#error').slideDown(633).delay(2500).slideUp(633);}
}
});