From 7e01ee5991abc18d92a8c57e8e0ebe8887a18593 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 10 Jul 2017 03:36:40 +0200 Subject: [PATCH] edit: emulate ip authentication in php footer Equivalent to .htaccess rules for SSI foot.inc.html. --- foot.inc.php | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/foot.inc.php b/foot.inc.php index d2ba826..799fb13 100755 --- a/foot.inc.php +++ b/foot.inc.php @@ -1,18 +1,13 @@ -var pagebody = document.getElementsByClassName('article')[0]; -pagebody.innerHTML = '

Nieuwe pagina

 

'; - -EOT; -} - define('N', "\n"); -$editable = FALSE; // "Beheer toegestaan voor {$_SERVER['REMOTE_ADDR']}:"; +$ALLOWED = [ + '127.0.0.1', +]; +$editable = in_array($_SERVER['REMOTE_ADDR'], $ALLOWED) ? + $_SERVER['REMOTE_ADDR'] : FALSE; $curfile = ltrim($_SERVER['SCRIPT_NAME'], '/'); if (is_executable(__DIR__ . '/' . $curfile)) { @@ -21,11 +16,23 @@ if (is_executable(__DIR__ . '/' . $curfile)) { } if ($editable) { + $edit = preg_match('/[?]edit$/', $_SERVER['REQUEST_URI']); + + if ($edit) { + echo ''.N; + echo ''.N; + if (($notfound = $_SERVER['SCRIPT_NAME'] == '/404.php')) { + echo <<<'EOT' + +EOT; + } + } + echo '