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 <?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") {exit;} if ($_GET['key'] != "4r45tg") {exit;}
include('db/config.php'); include('db/config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$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
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" <feed xmlns="http://www.w3.org/2005/Atom"
xmlns:georss="http://www.georss.org/georss"> xmlns:georss="http://www.georss.org/georss">
<title>Diaspora Pods</title> <title>Diaspora Pods</title>
<subtitle>IP Locations of Diaspora pods on podupti.me</subtitle> <subtitle>IP Locations of Diaspora pods on podupti.me</subtitle>
<link href="http://podupti.me/"/> <link href="http://podupti.me/"/>
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) { if (!$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);
$tip=""; $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.="\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"; $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://";} if ($row["secure"] == "true") {$method = "https://";} else {$method = "http://";}
echo <<<EOF echo <<<EOF
<entry> <entry>
<title>{$method}{$row['domain']}</title> <title>{$method}{$row['domain']}</title>
<link href="{$method}{$row['domain']}"/> <link href="{$method}{$row['domain']}"/>
<id>urn:{$row['domain']}</id> <id>urn:{$row['domain']}</id>
...@@ -36,49 +36,47 @@ echo <<<EOF ...@@ -36,49 +36,47 @@ echo <<<EOF
&#xA;{$tip}</summary> &#xA;{$tip}</summary>
<georss:point>{$row['lat']} {$row['long']}</georss:point> <georss:point>{$row['lat']} {$row['long']}</georss:point>
<georss:featureName>{$row['domain']}</georss:featureName> <georss:featureName>{$row['domain']}</georss:featureName>
</entry> </entry>
EOF;
}
echo "</feed>";
EOF;
}
echo "</feed>";
} }
elseif ($_GET['format'] == "json") { 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"; $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";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
if (!$result) { if (!$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');
$rows=array_values(pg_fetch_all($result)); $rows=array_values(pg_fetch_all($result));
$obj->podcount = $numrows; $obj->podcount = $numrows;
$obj->pods = $rows; $obj->pods = $rows;
if ($_GET['method'] == "jsonp") { if ($_GET['method'] == "jsonp") {
print $_GET['callback'] . '(' . json_encode($obj) . ')'; print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else { } else {
print json_encode($obj); print json_encode($obj);
} }
} else { } else {
$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) { if (!$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"){$status="Online";}else{$status="Offline";} if ($row["status"] == "up"){$status="Online";}else{$status="Offline";}
if ($row["secure"] == "true") {$method = "https://";$class="green";} else {$method = "http://";$class="red";} 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"]; echo $row["domain"] ." Up ".$row["uptimelast7"]."% This Month - Located in: ".$row["country"];
if ($i < ($numrows -1)) { if ($i < ($numrows -1)) {
echo ","; echo ",";
}
$i++;
} }
$i++;
}
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?> ?>
...@@ -107,7 +107,7 @@ echo "✪"; ...@@ -107,7 +107,7 @@ echo "✪";
echo "<td>" . $row["country"] . "</td>\n"; echo "<td>" . $row["country"] . "</td>\n";
?> ?>
<td> <td>
<form method="post" action="db/kill.php"> <form method="post" action="db/kill.php" target="_blank">
<input name="comments" size=10> <input name="comments" size=10>
<input name="domain" value="<?php echo $row["domain"] ?>" type="hidden"> <input name="domain" value="<?php echo $row["domain"] ?>" type="hidden">
<input name="adminkey" value="<?php echo $_COOKIE["adminkey"] ?>" 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. */ --> <!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<?php <?php
$valid=0; $valid=0;
include('config.php'); include('config.php');
include('../logging.php'); include('../logging.php');
$log = new Logging(); $log = new Logging();
$log->lfile($log_dir."/add.php.log"); $log->lfile($log_dir."/add.php.log");
if (!$_POST['url']){ if (!$_POST['url']){
echo "no url given";$log->lwrite('no url given '.$_POST['domain']); echo "no url given";$log->lwrite('no url given '.$_POST['domain']);
die; die;
} }
if (!$_POST['email']){ if (!$_POST['email']){
echo "no email given";$log->lwrite('no email given '.$_POST['domain']); echo "no email given";$log->lwrite('no email given '.$_POST['domain']);
die; die;
} }
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given";$log->lwrite('no domain given '.$_POST['domain']); echo "no pod domain given";$log->lwrite('no domain given '.$_POST['domain']);
die; die;
} }
if (!$_POST['url']){ if (!$_POST['url']){
echo "no API key for your stats";$log->lwrite('no api given '.$_POST['domain']); echo "no API key for your stats";$log->lwrite('no api given '.$_POST['domain']);
die; die;
} }
if (strlen($_POST['url']) < 14){ if (strlen($_POST['url']) < 14){
echo "API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee";$log->lwrite('api key too short '.$_POST['domain']); echo "API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee";$log->lwrite('api key too short '.$_POST['domain']);
die; die;
} }
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die("Error in connection: " . pg_last_error()); 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']) { $sql = "SELECT domain,pingdomurl FROM pods";
echo "API key already exists";$log->lwrite('API key already exists '.$_POST['domain']);die; $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 the header of pod with and without https
curl_setopt($chss, CURLOPT_URL, "https://".$_POST['domain']."/nodeinfo/1.0"); $chss = curl_init();
curl_setopt($chss, CURLOPT_POST, 0); curl_setopt($chss, CURLOPT_URL, "https://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($chss, CURLOPT_HEADER, 0); curl_setopt($chss, CURLOPT_POST, 0);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($chss, CURLOPT_HEADER, 0);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1); curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($chss, CURLOPT_NOBODY, 0); curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
$outputssl = curl_exec($chss); curl_setopt($chss, CURLOPT_NOBODY, 0);
curl_close($chss); $outputssl = curl_exec($chss);
curl_close($chss);
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$_POST['domain']."/nodeinfo/1.0"); curl_setopt($ch, CURLOPT_URL, "http://".$_POST['domain']."/nodeinfo/1.0");
curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_NOBODY, 0);
$output = curl_exec($ch); $output = curl_exec($ch);
curl_close($ch); curl_close($ch);
if (stristr($outputssl, 'nodeName')) { if (stristr($outputssl, 'nodeName')) {
echo "Your pod has ssl and is valid<br>";$log->lwrite('Your pod has ssl and is valid '.$_POST['domain']); echo "Your pod has ssl and is valid<br>";$log->lwrite('Your pod has ssl and is valid '.$_POST['domain']);
...@@ -73,28 +72,27 @@ if (stristr($output, 'nodeName')) { ...@@ -73,28 +72,27 @@ 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']); 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; $valid=1;
} }
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, array($_POST['domain'], $_POST['url'], $_POST['email'])); $result = pg_query_params($dbh, $sql, array($_POST['domain'], $_POST['url'], $_POST['email']));
if (!$result) { if (!$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 ";
$message.= "https://podupti.me\n\n Stats Url: https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=" . $_POST["url"] . "\n\n Pod: https://podupti.me/db/pull.php?debug=1&domain=" . $_POST["domain"] . "\n\n"; $message.= "https://podupti.me\n\n Stats Url: https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&apiKey=" . $_POST["url"] . "\n\n Pod: https://podupti.me/db/pull.php?debug=1&domain=" . $_POST["domain"] . "\n\n";
$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"; $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!"; echo "Data successfully inserted! Your pod will be reviewed and live on the list in a few hours!";
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
} else { } 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(); $log->lclose();
?> ?>
<?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.
//this is just a single api for a pod for the android app to get data //this is just a single api for a pod for the android app to get data
include('config.php'); include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$dbh) {
die("Error in connection: " . pg_last_error()); die("Error in connection: " . pg_last_error());
} }
$sql = "SELECT * FROM pods WHERE domain = $1"; $sql = "SELECT * FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url'])); $result = pg_query_params($dbh, $sql, array($_GET['url']));
if (!$result) { if (!$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)) {
echo "Status: " . $row["status"] . "<br>"; echo "Status: " . $row["status"] . "<br>";
echo "Last Git Pull: " . $row["hgitdate"] . "<br>"; echo "Last Git Pull: " . $row["hgitdate"] . "<br>";
echo "Uptime This Month " . $row["uptimelast7"] . "<br>"; echo "Uptime This Month " . $row["uptimelast7"] . "<br>";
echo "Months Monitored: " . $row["monthsmonitored"] . "<br>"; echo "Months Monitored: " . $row["monthsmonitored"] . "<br>";
echo "Response Time: " . $row["responsetimelast7"] . "<br>"; echo "Response Time: " . $row["responsetimelast7"] . "<br>";
echo "User Rating: ". $row["userrating"] . "<br>"; echo "User Rating: ". $row["userrating"] . "<br>";
echo "Server Location: ". $row["country"] . "<br>"; echo "Server Location: ". $row["country"] . "<br>";
echo "Latitude: ". $row["lat"] . "<br>"; echo "Latitude: ". $row["lat"] . "<br>";
echo "Longitude: ". $row["long"] . "<br>"; echo "Longitude: ". $row["long"] . "<br>";
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?> ?>
...@@ -7,12 +7,12 @@ system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --username=$pguser $pg ...@@ -7,12 +7,12 @@ system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --username=$pguser $pg
echo "pg backup of $pgdb made"; echo "pg backup of $pgdb made";
$dirh = dir($backup_dir); $dirh = dir($backup_dir);
while($entry = $dirh->read()) { while($entry = $dirh->read()) {
$old_file_time = (date("U") - $keep); $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 ($file_created < $old_file_time && !is_dir($entry)) {
if(unlink("$backup_dir/$entry")) { if(unlink("$backup_dir/$entry")) {
echo "Cleaned up old backups"; echo "Cleaned up old backups";
} }
} }
} }
?> ?>
<?php <?php
include('config.php'); include('config.php');
if (!$_GET['domain']){ if (!$_GET['domain']){
echo "no pod domain given"; echo "no pod domain given";
die; die;
} }
if (!$_GET['token']){ if (!$_GET['token']){
echo "no token given"; echo "no token given";
die; die;
} }
if (strlen($_GET['token']) < 6){ if (strlen($_GET['token']) < 6){
echo "bad token"; echo "bad token";
die; die;
} }
$domain = $_GET['domain']; $domain = $_GET['domain'];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$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) { if (!$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']) {
echo "token not a match";die; echo "token not a match";die;
} }
if ($row["tokenexpire"] < date("Y-m-d H:i:s", time())) { if ($row["tokenexpire"] < date("Y-m-d H:i:s", time())) {
echo "token expired";die; echo "token expired";die;
} }
//save and exit //save and exit
if ($_GET['save'] == $row["token"]){ if ($_GET['save'] == $row["token"]){
if ($_GET['weight'] > 10) { if ($_GET['weight'] > 10) {
echo "10 is max weight"; echo "10 is max weight";
die; die;
} }
$sql = "UPDATE pods SET email=$1, pingdomurl=$2, weight=$3 WHERE domain = $4";
$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']));
$result = pg_query_params($dbh, $sql, array($_GET['email'],$_GET['pingdomurl'],$_GET['weight'],$_GET['domain'])); if (!$result) {
if (!$result) { die("Error in SQL query: " . pg_last_error());
die("Error in SQL query: " . pg_last_error()); }
} $to = $_GET["email"];
$to = $_GET["email"]; $subject = "Edit notice from poduptime ";
$subject = "Edit notice from poduptime "; $message = "Data for " . $_GET["domain"] . " Updated. If it was not you reply and let me know! \n\n";
$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";
$headers = "From: support@diasp.org\r\nCc:support@diasp.org,". $_GET['oldemail'] ."\r\n"; @mail( $to, $subject, $message, $headers );
@mail( $to, $subject, $message, $headers ); pg_free_result($result);
pg_close($dbh);
pg_free_result($result); echo "Data saved. Will go into effect on next hourly change";
pg_close($dbh); die;
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 <?php
include('config.php'); include('config.php');
$systemTimeZone = system('date +%Z'); $systemTimeZone = system('date +%Z');
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given"; echo "no pod domain given";
die; die;
} }
$domain = $_POST['domain']; $domain = $_POST['domain'];
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) { if (!$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) { if (!$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) {
echo "domain not found";die; echo "domain not found";die;
} }
while ($row = pg_fetch_array($result)) {
while ($row = pg_fetch_array($result)) { if ($_POST['email']){
if ($row["email"] <> $_POST['email']) {
if ($_POST['email']){ echo "email not a match";die;
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);
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
$result = pg_query_params($dbh, $sql, array($uuid,$expire));
$uuid = md5(uniqid($domain, true)); if (!$result) {
$expire = date("Y-m-d H:i:s", time() + 2700); die("Error in SQL query: " . pg_last_error());
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'"; }
$result = pg_query_params($dbh, $sql, array($uuid,$expire)); $to = $_POST["email"];
if (!$result) { $subject = "Temporary edit key for podupti.me";
die("Error in SQL query: " . pg_last_error()); $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";
$to = $_POST["email"]; @mail( $to, $subject, $message, $headers );
$subject = "Temporary edit key for podupti.me"; echo "Link sent to your email";
$message = "Link: https://podupti.me/db/edit.php?domain=" . $_POST["domain"] . "&token=" . $uuid . " Expires: " . $expire . " " . $systemTimeZone ."\n\n"; } elseif (!$_POST['email']){
$headers = "From: support@diasp.org\r\nBcc: support@diasp.org\r\n"; $uuid = md5(uniqid($domain, true));
@mail( $to, $subject, $message, $headers ); $expire = date("Y-m-d H:i:s", time() + 9700);
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'";
echo "Link sent to your email"; $result = pg_query_params($dbh, $sql, array($uuid,$expire));
if (!$result) {
} elseif (!$_POST['email']){ die("Error in SQL query: " . pg_last_error());
}
$uuid = md5(uniqid($domain, true)); $to = "support@diasp.org";
$expire = date("Y-m-d H:i:s", time() + 9700); $subject = "FORWARD REQUEST: Temporary edit key for podupti.me";
$sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'"; $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";
$result = pg_query_params($dbh, $sql, array($uuid,$expire)); $headers = "From: support@diasp.org\r\nBcc: support@diasp.org\r\n";
if (!$result) { @mail( $to, $subject, $message, $headers );
die("Error in SQL query: " . pg_last_error()); echo "Link sent to administrator to review and verify, if approved they will forward the edit key to you.";
} }
$to = "support@diasp.org"; pg_free_result($result);
$subject = "FORWARD REQUEST: Temporary edit key for podupti.me"; pg_close($dbh);
$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 <?php
include('config.php'); include('config.php');
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given"; echo "no pod domain given";
die; die;
} }
if (!$_POST['adminkey']){ if (!$_POST['adminkey']){
echo "no token given"; echo "no token given";
die; die;
} }
if (!$_POST['action']){