Commit 48db15c5 authored by Armando Luescher's avatar Armando Luescher

Combine echo and die statements.

Remove superfluous PHP ending ?>
parent ba6693f3
...@@ -85,4 +85,3 @@ elseif ($_GET['format'] == "json") { ...@@ -85,4 +85,3 @@ elseif ($_GET['format'] == "json") {
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
} }
?>
...@@ -6,24 +6,24 @@ require_once __DIR__ . '/../logging.php'; ...@@ -6,24 +6,24 @@ require_once __DIR__ . '/../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']); $log->lwrite('no url given '.$_POST['domain']);
die; die("no url given");
} }
if (!$_POST['email']){ if (!$_POST['email']){
echo "no email given";$log->lwrite('no email given '.$_POST['domain']); $log->lwrite('no email given '.$_POST['domain']);
die; die("no email given");
} }
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given";$log->lwrite('no domain given '.$_POST['domain']); $log->lwrite('no domain given '.$_POST['domain']);
die; die("no pod domain given");
} }
if (!$_POST['url']){ if (!$_POST['url']){
echo "no API key for your stats";$log->lwrite('no api given '.$_POST['domain']); $log->lwrite('no api given '.$_POST['domain']);
die; die("no API key for your stats");
} }
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']); $log->lwrite('api key too short '.$_POST['domain']);
die; die("API key bad needs to be like m58978-80abdb799f6ccf15e3e3787ee");
} }
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
...@@ -39,10 +39,12 @@ if (!$result) { ...@@ -39,10 +39,12 @@ if (!$result) {
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($row["domain"] == $_POST['domain']) { if ($row["domain"] == $_POST['domain']) {
echo "domain already exists";$log->lwrite('domain already exists '.$_POST['domain']);die; $log->lwrite('domain already exists '.$_POST['domain']);
die("domain already exists");
} }
if ($row["pingdomurl"] == $_POST['url']) { if ($row["pingdomurl"] == $_POST['url']) {
echo "API key already exists";$log->lwrite('API key already exists '.$_POST['domain']);die; $log->lwrite('API key already exists '.$_POST['domain']);
die("API key already exists");
} }
} }
...@@ -68,11 +70,13 @@ $output = curl_exec($ch); ...@@ -68,11 +70,13 @@ $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']); $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')) { 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']); $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") { if ($valid=="1") {
...@@ -98,4 +102,3 @@ if ($valid=="1") { ...@@ -98,4 +102,3 @@ if ($valid=="1") {
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();
?>
...@@ -29,4 +29,3 @@ while ($row = pg_fetch_array($result)) { ...@@ -29,4 +29,3 @@ while ($row = pg_fetch_array($result)) {
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?>
...@@ -16,4 +16,3 @@ while($entry = $dirh->read()) { ...@@ -16,4 +16,3 @@ while($entry = $dirh->read()) {
} }
} }
} }
?>
<?php <?php
if (!$_GET['domain']){ if (!$_GET['domain']){
echo "no pod domain given"; die("no pod domain given");
die;
} }
if (!$_GET['token']){ if (!$_GET['token']){
echo "no token given"; die("no token given");
die;
} }
if (strlen($_GET['token']) < 6){ if (strlen($_GET['token']) < 6){
echo "bad token"; die("bad token");
die;
} }
$domain = $_GET['domain']; $domain = $_GET['domain'];
...@@ -26,10 +23,10 @@ if (!$result) { ...@@ -26,10 +23,10 @@ if (!$result) {
} }
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; 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())) {
echo "token expired";die; die("token expired");
} }
//delete pod //delete pod
if ($_GET['delete'] == $row["token"]){ if ($_GET['delete'] == $row["token"]){
...@@ -38,14 +35,13 @@ while ($row = pg_fetch_array($result)) { ...@@ -38,14 +35,13 @@ while ($row = pg_fetch_array($result)) {
if (!$result) { if (!$result) {
die("Error in SQL query: " . pg_last_error()); die("Error in SQL query: " . pg_last_error());
} else { } else {
echo "pod removed from DB"; echo "pod removed from DB";
} }
} }
//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"; die("10 is max weight");
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']));
...@@ -59,8 +55,7 @@ while ($row = pg_fetch_array($result)) { ...@@ -59,8 +55,7 @@ while ($row = pg_fetch_array($result)) {
@mail( $to, $subject, $message, $headers ); @mail( $to, $subject, $message, $headers );
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
echo "Data saved. Will go into effect on next hourly change"; die("Data saved. Will go into effect on next hourly change");
die;
} }
//form //form
...@@ -73,6 +68,4 @@ while ($row = pg_fetch_array($result)) { ...@@ -73,6 +68,4 @@ while ($row = pg_fetch_array($result)) {
echo "<form action='' method='get'><input type=hidden name=delete value=" . $_GET['token'] . "><input type=hidden name=token value=" . $_GET['token'] . "><input type=hidden name=domain value=" . $_GET['domain'] . ">"; echo "<form action='' method='get'><input type=hidden name=delete value=" . $_GET['token'] . "><input type=hidden name=token value=" . $_GET['token'] . "><input type=hidden name=domain value=" . $_GET['domain'] . ">";
echo "WARNING: This can not be undone, you will need to add your pod again if you want back on list: <input type=submit name=submit value=delete><br><br><br>"; echo "WARNING: This can not be undone, you will need to add your pod again if you want back on list: <input type=submit name=submit value=delete><br><br><br>";
} }
?>
<?php <?php
$systemTimeZone = system('date +%Z'); $systemTimeZone = system('date +%Z');
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given"; die("no pod domain given");
die;
} }
$domain = $_POST['domain']; $domain = $_POST['domain'];
...@@ -19,12 +18,12 @@ if (!$result) { ...@@ -19,12 +18,12 @@ if (!$result) {
} }
$rows = pg_num_rows($result); $rows = pg_num_rows($result);
if ($rows <= 0) { if ($rows <= 0) {
echo "domain not found";die; die("domain not found");
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($_POST['email']){ if ($_POST['email']){
if ($row["email"] <> $_POST['email']) { if ($row["email"] <> $_POST['email']) {
echo "email not a match";die; 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); $expire = date("Y-m-d H:i:s", time() + 2700);
...@@ -57,5 +56,3 @@ while ($row = pg_fetch_array($result)) { ...@@ -57,5 +56,3 @@ while ($row = pg_fetch_array($result)) {
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
} }
?>
<?php <?php
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given"; die("no pod domain given");
die;
} }
if (!$_POST['adminkey']){ if (!$_POST['adminkey']){
echo "no token given"; die("no token given");
die;
} }
if (!$_POST['action']){ if (!$_POST['action']){
echo "no action selected"; die("no action selected");
die;
} }
$domain = $_POST['domain']; $domain = $_POST['domain'];
...@@ -26,7 +23,7 @@ if (!$result) { ...@@ -26,7 +23,7 @@ if (!$result) {
} }
while ($row = pg_fetch_array($result)) { while ($row = pg_fetch_array($result)) {
if ($adminkey <> $_POST['adminkey']) { if ($adminkey <> $_POST['adminkey']) {
echo "admin key fail";die; die("admin key fail");
} }
//save and exit //save and exit
if ($_POST['action'] == "delete") { if ($_POST['action'] == "delete") {
...@@ -55,4 +52,3 @@ while ($row = pg_fetch_array($result)) { ...@@ -55,4 +52,3 @@ while ($row = pg_fetch_array($result)) {
} }
echo $result; echo $result;
} }
?>
...@@ -304,5 +304,3 @@ while ($row = pg_fetch_all($result)) { ...@@ -304,5 +304,3 @@ while ($row = pg_fetch_all($result)) {
} }
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?>
<?php <?php
if (!$_POST['username']){ if (!$_POST['username']){
echo "no username given"; die("no username given");
die;
} }
if (!$_POST['userurl']){ if (!$_POST['userurl']){
echo "no userurl given"; die("no userurl given");
die;
} }
if (!$_POST['domain']){ if (!$_POST['domain']){
echo "no pod domain given"; die("no pod domain given");
die;
} }
if (!$_POST['comment']){ if (!$_POST['comment']){
echo "no comment"; die("no comment");
die;
} }
if (!$_POST['rating']){ if (!$_POST['rating']){
echo "no rating given"; die("no rating given");
die;
} }
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
...@@ -39,4 +34,3 @@ $headers = "From: ".$_POST["email"]."\r\n"; ...@@ -39,4 +34,3 @@ $headers = "From: ".$_POST["email"]."\r\n";
echo "Comment posted!"; echo "Comment posted!";
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?>
...@@ -7,4 +7,3 @@ if ($dur > 4500) { ...@@ -7,4 +7,3 @@ if ($dur > 4500) {
else { else {
http_response_code(200); http_response_code(200);
} }
?>
...@@ -13,4 +13,3 @@ if (!$result) { ...@@ -13,4 +13,3 @@ if (!$result) {
$row = pg_fetch_all($result); $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"); header("Location: http" . $ssl . "://" . $row[0]['domain'] . "/users/sign_up");
?>
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