convert ssi html files to php code
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 10 Jul 2017 02:09:49 +0000 (04:09 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 12 Jul 2017 02:46:06 +0000 (04:46 +0200)
Replace includes by equivalent php: single head.inc.php sets up same static
head.inc.html but with mandatory edit container, and existing foot.inc.php
(similar ssi variant no longer needed).

Requires httpd to change .html handler from server-parsed (ssi) to
application/x-httpd-php.

404.php
edit.php
foot.inc.html [deleted file]
head.inc.php [new file with mode: 0644]

diff --git a/404.php b/404.php
index ba3e8206717cb8458054406bf378cac9be6597d6..0410799ff2874bf7b5f9ad2ee4d667258537bc77 100755 (executable)
--- a/404.php
+++ b/404.php
@@ -1,4 +1,4 @@
-<?php include 'head.inc.html'; ?>
+<?php include 'head.inc.php'; ?>
 
 <h2>Niet gevonden</h2>
 
@@ -6,4 +6,3 @@
 De gevraagde pagina <em><?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?></em> bestaat niet.
 </p>
 
-<?php include 'foot.inc.php'; ?>
index 357d3a429bde2c04f82bb0a452e32cad4f7f2320..afa6c6d4868c1948ade99c31579726d52ea9a358 100755 (executable)
--- a/edit.php
+++ b/edit.php
@@ -29,8 +29,8 @@ if (!strlen($upload)) {
        exit;
 }
 
-$prepend = '<!--#include virtual="/head.inc.html" -->'."\n\n";
-$append  = "\n".'<!--#include virtual="/foot.inc.html" -->'."\n";
+$prepend = "<?php include 'head.inc.php'; ?>\n\n";
+$append  = "\n";
 
 if (!file_put_contents($filename, $prepend . $upload . $append))
        abort('500 save error', "fout bij schrijven van $filename");
diff --git a/foot.inc.html b/foot.inc.html
deleted file mode 100644 (file)
index 41feac0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-</div>
-<hr class="footer" />
-<!--#if expr="-A /edit.php" -->
-<p class="footer">Beheer toegestaan voor <!--#echo var="REMOTE_ADDR" -->:
-<!--#if expr="$QUERY_STRING = edit || $REQUEST_URI = /[?]edit$/" -->
-<!--#if expr="$DOCUMENT_NAME = 404.php" -->
-<script>
-var pagebody = document.getElementsByClassName('article')[0];
-pagebody.innerHTML = '<h2>Nieuwe pagina</h2><p>&nbsp;</p>';
-</script>
-<!--#endif -->
-<script src="/ckeditor/ckeditor.js"></script>
-<script src="/edit.js"></script>
-<a href="?">lezen</a>
-<!--#elif expr="$DOCUMENT_NAME = 404.php" -->
-<a href="?edit">aanmaken</a>
-<!--#else -->
-<a href="?edit">aanpassen</a>
-<!--#endif -->
-</p>
-<!--#endif -->
-</body></html>
diff --git a/head.inc.php b/head.inc.php
new file mode 100644 (file)
index 0000000..847d515
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+include 'head.inc.html';
+
+print '<div class="article">'."\n\n";
+
+register_shutdown_function(function () {
+       include 'foot.inc.php';
+});