-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·58 lines (48 loc) · 1.56 KB
/
Copy pathindex.php
File metadata and controls
executable file
·58 lines (48 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// PHPMark Framework - Simple SSR Blog Framework
// Simple but fast router
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// Remove trailing slash
$uri = rtrim($uri, '/');
if (empty($uri)) $uri = '/';
// Load configuration
require_once __DIR__ . '/includes/config.php';
// Route handling
switch ($uri) {
case '/':
require __DIR__ . '/pages/home.php';
break;
case '/blog':
require __DIR__ . '/pages/blog.php';
break;
case '/portfolio':
require __DIR__ . '/pages/portfolio.php';
break;
case '/notes':
require __DIR__ . '/pages/notes.php';
break;
case '/about':
require __DIR__ . '/pages/about.php';
break;
default:
// Check for blog posts
if (preg_match('#^/blog/([a-z0-9-]+)$#', $uri, $matches)) {
$_GET['slug'] = $matches[1];
require __DIR__ . '/pages/blog-post.php';
break;
}
// Check for notes
if (preg_match('#^/notes/([a-z0-9-]+)$#', $uri, $matches)) {
$_GET['slug'] = $matches[1];
require __DIR__ . '/pages/note.php';
break;
}
// 404
header('HTTP/1.0 404 Not Found');
$currentPage = '';
$pageTitle = '404 - Page Not Found';
$content = '<div class="card"><h2>Page not found</h2><p>The requested page could not be found.</p><a href="/" class="link">← Back to home</a></div>';
require __DIR__ . '/templates/layout.php';
break;
}
?>