-$prepend = '<!--#include virtual="common.html" -->'."\n\n";
-$append = "\n\n".'<!--#include virtual="footer.html" -->'."\n";
+$filename = preg_replace('/(?:\.html)?$/', '.html', ltrim($_SERVER['PATH_INFO'], '/'), 1);
+if (file_exists($filename) and !is_writable($filename))
+ abort('403 input error', "ongeldige bestandsnaam: $filename");
+
+$prepend = '<!--#include virtual="/common.html" -->'."\n\n";
+$append = "\n".'<!--#include virtual="/footer.html" -->'."\n";