</div>
<hr class="footer" />
<?php
-if (($notfound = $_SERVER['SCRIPT_NAME'] == '/404.php')) {
- echo <<<'EOT'
-<script>
-var pagebody = document.getElementsByClassName('article')[0];
-pagebody.innerHTML = '<h2>Nieuwe pagina</h2><p> </p>';
-</script>
-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)) {
}
if ($editable) {
+ $edit = preg_match('/[?]edit$/', $_SERVER['REQUEST_URI']);
+
+ if ($edit) {
+ echo '<script src="/ckeditor/ckeditor.js"></script>'.N;
+ echo '<script src="/edit.js"></script>'.N;
+ if (($notfound = $_SERVER['SCRIPT_NAME'] == '/404.php')) {
+ echo <<<'EOT'
+<script>
+var pagebody = document.getElementsByClassName('article')[0];
+pagebody.innerHTML = '<h2>Nieuwe pagina</h2><p> </p>';
+</script>
+EOT;
+ }
+ }
+
echo '<p class="footer">'.N;
- echo $editable.N;
- echo '<script src="/ckeditor/ckeditor.js"></script>'.N;
- echo '<script src="/edit.js"></script>'.N;
- $edit = array_key_exists($_GET['edit']);
+ echo "Beheer toegestaan voor $editable:".N;
printf('<a href="?%s">%s</a>'.N,
$edit ? '' : 'edit',
$edit ? 'lezen' : ($notfound ? 'aanmaken' : 'aanpassen')