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