-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.php
More file actions
51 lines (45 loc) · 1.52 KB
/
Copy patharticle.php
File metadata and controls
51 lines (45 loc) · 1.52 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
<!DOCTYPE html>
<html lang="en">
<?php
$articlesDir = __DIR__ . '/articles/';
$defaultArticle = 'new-website.php';
$article = $_GET['article'] ?? null;
/**
* Allow only safe filenames (letters, numbers, dash, underscore)
*/
if ($article && preg_match('/^[a-zA-Z0-9_-]+$/', $article)) {
$articleFile = $article . '.php';
} else {
header("Location: https://fmdx.org");
die;
}
/**
* Resolve real path and validate directory
*/
$fullPath = realpath($articlesDir . $articleFile);
if ($fullPath === false || strpos($fullPath, realpath($articlesDir)) !== 0) {
header("Location: https://fmdx.org"); // Invalid or traversal attempt
}
include $fullPath;
$pageTitle = $article->title;
include 'includes/header.php';
?>
<body>
<?php include 'includes/navigation.php';?>
<div id="wrapper">
<div class="flex-container flex-center">
<div class="tx-icon"></div>
<h1 class="m-0"><span class="color-main text-bold">FMDX.org</span> </h1>
</div>
<div class="flex-container">
<main>
<?php
$article->render();
?>
</main>
<?php include 'includes/sidepanels.php';?>
</div>
</div>
<?php include 'includes/footer.php';?>
</body>
</html>