page: skip head formatting for script overrides (edit)
[minimedit.git] / page.php
1 <?php
2 error_reporting(E_ALL);
3 ini_set('display_errors', TRUE);
4
5 $Args = '';
6 $Page = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
7 $Page = urldecode(trim($Page, '/')) ?: 'index';
8 while (TRUE) {
9         if (file_exists("$Page/index.html")) {
10                 $Page .= '/index';
11                 break;
12         }
13         if (file_exists("$Page.html")) {
14                 break;
15         }
16         if (file_exists("$Page.php")) {
17                 # unformatted script override
18                 require "$Page.php";
19                 exit;
20         }
21
22         $up = strrpos($Page, '/');
23         if ($up === FALSE) {
24                 http_response_code(404);
25                 $Page = '404';
26                 break;
27         }
28         $Args = substr($Page, $up) . $Args;
29         $Page = substr($Page, 0, $up);
30 }
31
32 $Edit = isset($_GET['edit']);
33
34 include 'head.inc.php';