--- /dev/null
+RewriteEngine on
+RewriteBase /
+
+# common php handler
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule '' page.php%{REQUEST_FILENAME} [L]
init: function(editor) {
editor.addCommand( 'inlinesave', {
exec: function (editor) {
- var pagename = window.location.pathname.replace(/\.php$/, '').replace(/\/$/, '/index');
+ var pagename = window.location.pathname.replace(/\/$/, '/index');
var data = 'body='+encodeURIComponent(editor.getData());
ajaxpost = new XMLHttpRequest();
- ajaxpost.open('POST', '/edit.php'+pagename, true);
+ ajaxpost.open('POST', '/edit'+pagename, true);
ajaxpost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxpost.onreadystatechange = function () {
if (ajaxpost.readyState != 4)
config.format_tags = 'h2;h3;h4;p';
config.allowedContent = true;
config.entities = false; // keep unicode
- config.filebrowserImageUploadUrl = '/edit.php?type=img';
+ config.filebrowserImageUploadUrl = '/edit?type=img';
config.forcePasteAsPlainText = true;
config.contentsCss = '/excelsior.css';
config.toolbar = [
if (!isset($_SERVER['PATH_INFO']) or strlen($_SERVER['PATH_INFO']) <= 1)
abort('409 input error', "geen bestand aangeleverd");
-$filename = preg_replace('/(?:\.php)?$/', '.php', ltrim($_SERVER['PATH_INFO'], '/'), 1);
+$filename = ltrim($Args, '/').'.html';
if (file_exists($filename) and !is_writable($filename))
abort('403 input error', "ongeldige bestandsnaam: $filename");
if (is_executable($filename))
exit;
}
-$rootpath = str_repeat('../', substr_count($filename, '/'));
-$prepend = "<?php include '${rootpath}head.inc.php'; ?>\n\n";
-$append = "\n";
-
-if (!file_put_contents($filename, $prepend . $upload . $append))
+if (!file_put_contents($filename, $upload))
abort('500 save error', "fout bij schrijven van $filename");
print "Bestand opgeslagen";
<?php
define('N', "\n");
-global $User, $Admin;
-
-$curfile = ltrim($_SERVER['SCRIPT_NAME'], '/');
-if (is_executable(__DIR__ . '/' . $curfile)) {
- // dynamic code is +x
- $Admin = FALSE;
-}
+global $Page, $User, $Admin;
if ($Admin) {
$edit = preg_match('/[?]edit$/', $_SERVER['REQUEST_URI']);
+ $notfound = $Page == '404';
if ($edit) {
echo '<script src="/ckeditor/ckeditor.js"></script>'.N;
echo '<script src="/edit.js"></script>'.N;
- if (($notfound = $_SERVER['SCRIPT_NAME'] == '/404.php')) {
+ if ($notfound) {
echo <<<'EOT'
<script>
var pagebody = document.getElementsByClassName('article')[0];
include 'foot.inc.php';
print "</body></html>\n";
});
+
+include "$Page.html";
+if (file_exists("$Page.php")) include_once("$Page.php");
+
--- /dev/null
+<?php
+error_reporting(E_ALL);
+ini_set('display_errors', TRUE);
+
+$Args = '';
+$Page = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
+$Page = urldecode(trim($Page, '/')) ?: 'index';
+while (TRUE) {
+ if (file_exists("$Page/index.html")) {
+ $Page .= '/index';
+ break;
+ }
+ if (file_exists("$Page.html")) {
+ break;
+ }
+ if (file_exists("$Page.php")) {
+ # unformatted script override
+ require "$Page.php";
+ break;
+ }
+
+ $up = strrpos($Page, '/');
+ if ($up === FALSE) {
+ http_response_code(404);
+ $Page = '404';
+ break;
+ }
+ $Args = substr($Page, $up) . $Args;
+ $Page = substr($Page, 0, $up);
+}
+
+include 'head.inc.php';