Commit dfcb51f9 authored by noplanman's avatar noplanman

Small code improvements and warning fixes.

parent 27b4991b
...@@ -10,9 +10,7 @@ use RedBeanPHP\R; ...@@ -10,9 +10,7 @@ use RedBeanPHP\R;
require_once __DIR__ . '/../boot.php'; require_once __DIR__ . '/../boot.php';
if (!($_domain = $_GET['domain'] ?? null)) { ($_domain = $_GET['domain'] ?? null) || die('no pod domain given');
die('no pod domain given');
}
// Other parameters. // Other parameters.
$_email = $_GET['email'] ?? ''; $_email = $_GET['email'] ?? '';
...@@ -33,6 +31,7 @@ try { ...@@ -33,6 +31,7 @@ try {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
} }
$stop = false;
foreach ($pods as $pod) { foreach ($pods as $pod) {
if ($pod['domain'] === $_domain) { if ($pod['domain'] === $_domain) {
if ($pod['email']) { if ($pod['email']) {
...@@ -75,12 +74,11 @@ foreach ($pods as $pod) { ...@@ -75,12 +74,11 @@ foreach ($pods as $pod) {
</form> </form>
EOF; EOF;
$stop = 1; $stop = true;
} }
} }
if (!$stop) { if (!$stop) {
$link = 'https://' . $_domain . '/nodeinfo/1.0'; $link = 'https://' . $_domain . '/nodeinfo/1.0';
if ($infos = file_get_contents('https://' . $_domain . '/.well-known/nodeinfo')) { if ($infos = file_get_contents('https://' . $_domain . '/.well-known/nodeinfo')) {
$info = json_decode($infos, true); $info = json_decode($infos, true);
...@@ -103,12 +101,12 @@ if (!$stop) { ...@@ -103,12 +101,12 @@ if (!$stop) {
$publickey = md5(uniqid($_domain, true)); $publickey = md5(uniqid($_domain, true));
try { try {
$p = R::dispense('pods'); $p = R::dispense('pods');
$p['domain'] = $_domain; $p['domain'] = $_domain;
$p['email'] = $_email; $p['email'] = $_email;
$p['podmin_statement'] = $_podmin_statement; $p['podmin_statement'] = $_podmin_statement;
$p['podmin_notify'] = $_podmin_notify; $p['podmin_notify'] = $_podmin_notify;
$p['publickey'] = $publickey; $p['publickey'] = $publickey;
R::store($p); R::store($p);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
......
...@@ -143,4 +143,4 @@ Authorized to edit <b><?php echo $_domain; ?></b> for <?php echo (new Carbon($po ...@@ -143,4 +143,4 @@ Authorized to edit <b><?php echo $_domain; ?></b> for <?php echo (new Carbon($po
<input value="debug" type="button" aria-describedby="debug" data-featherlight="/db/pull.php?debug=1&nowrite=1&domain=<?php echo $_domain; ?>"/> <input value="debug" type="button" aria-describedby="debug" data-featherlight="/db/pull.php?debug=1&nowrite=1&domain=<?php echo $_domain; ?>"/>
<small id="debug" class="form-text text-muted"> <small id="debug" class="form-text text-muted">
Do a debug pull of your pod. Won't update the database just show what it would look like on a pass. Do a debug pull of your pod. Won't update the database just show what it would look like on a pass.
</small> </small>
\ No newline at end of file
...@@ -5,20 +5,22 @@ ...@@ -5,20 +5,22 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Carbon\Carbon; use Carbon\Carbon;
require_once __DIR__ . '/boot.php'; require_once __DIR__ . '/boot.php';
$lastfile = 'db/last.data'; $lastfile = 'db/last.data';
$input = isset($_GET['input']) ? substr($_GET['input'], 1) : null; $input = isset($_GET['input']) ? substr($_GET['input'], 1) : null;
$mapview = isset($_GET['mapview']) || $input == 'map'; $mapview = isset($_GET['mapview']) || $input === 'map';
$statsview = isset($_GET['statsview']) || $input == 'stats'; $statsview = isset($_GET['statsview']) || $input === 'stats';
$podmin = isset($_GET['podmin']) || $input == 'podmin'; $podmin = isset($_GET['podmin']) || $input === 'podmin';
$podminedit = isset($_GET['podminedit']) || $input == 'podminedit'; $podminedit = isset($_GET['podminedit']) || $input === 'podminedit';
$edit = isset($_GET['edit']) || $input == 'edit'; $edit = isset($_GET['edit']) || $input === 'edit';
$add = isset($_GET['add']) || $input == 'add'; $add = isset($_GET['add']) || $input === 'add';
$gettoken = isset($_GET['gettoken']) || $input == 'gettoken'; $gettoken = isset($_GET['gettoken']) || $input === 'gettoken';
$simpleview = !($mapview || $podmin || $podminedit || $statsview); $simpleview = !($mapview || $podmin || $podminedit || $statsview);
$fullview = false;
?> ?>
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
...@@ -67,16 +69,16 @@ $navs = [ ...@@ -67,16 +69,16 @@ $navs = [
<h4 class="text-white">About</h4> <h4 class="text-white">About</h4>
<p class="text-muted">Poduptime helps you find a diaspora, friendica, hubzilla or socialhome pod to use and join the federated social network.</p> <p class="text-muted">Poduptime helps you find a diaspora, friendica, hubzilla or socialhome pod to use and join the federated social network.</p>
<ul class="navbar-nav"> <ul class="navbar-nav">
<?php <?php
foreach ($navs['links'] as $nav_item) { foreach ($navs['links'] as $nav_item) {
printf( printf(
'<li class="nav-item"><a href="%1$s">%2$s%3$s</a></li>', '<li class="nav-item"><a href="%1$s">%2$s%3$s</a></li>',
$nav_item['href'], $nav_item['href'],
$nav_item['text'], $nav_item['text'],
$nav_item['active'] ? ' <span class="sr-only">(current)</span>' : '' $nav_item['active'] ? ' <span class="sr-only">(current)</span>' : ''
); );
} }
?> ?>
</ul> </ul>
</div> </div>
<div class="col-sm-4 offset-md-1 py-4"> <div class="col-sm-4 offset-md-1 py-4">
...@@ -128,7 +130,7 @@ $navs = [ ...@@ -128,7 +130,7 @@ $navs = [
include_once __DIR__ . '/db/gettoken.php'; include_once __DIR__ . '/db/gettoken.php';
} else { } else {
include_once __DIR__ . '/showfull.php'; include_once __DIR__ . '/showfull.php';
$fullview = 1; $fullview = true;
} }
?> ?>
</div> </div>
...@@ -147,9 +149,7 @@ $navs = [ ...@@ -147,9 +149,7 @@ $navs = [
<script src="node_modules/ion-rangeslider/js/ion.rangeSlider.min.js"></script> <script src="node_modules/ion-rangeslider/js/ion.rangeSlider.min.js"></script>
<?php <?php
$statsview && include_once __DIR__ . '/statsviewjs.php'; $statsview && include_once __DIR__ . '/statsviewjs.php';
if ($fullview) { $fullview && printf('<script src="js/podup.js"></script>');
echo '<script src="js/podup.js"></script>';
}
?> ?>
</body> </body>
</html> </html>
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