-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocbase.php
More file actions
executable file
·26 lines (22 loc) · 931 Bytes
/
docbase.php
File metadata and controls
executable file
·26 lines (22 loc) · 931 Bytes
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
<?php
$explodedPath = explode("/", $_SERVER['SCRIPT_NAME']);
$projectPart = $explodedPath[count($explodedPath) - 2];
$githubLink = "https://raw.githubusercontent.com/MispiOS/documentation/refs/heads/main/" . $projectPart . "/";
$askedDocPage = substr($_SERVER["REQUEST_URI"], strlen($projectPart) + 2);
if(str_ends_with($askedDocPage, "/")) {
$askedDocPage = substr($askedDocPage,0, strlen($askedDocPage) - 1);
}
$askedDocPage = (strlen($askedDocPage) == 0 ? "home.md" : $askedDocPage . (str_ends_with($askedDocPage, ".md") ? "" : ".md"));
$askedDocPage = str_replace("\/.\/", "\/", $askedDocPage);
$link = $githubLink . $askedDocPage;
$content = file_get_contents($link);
if($content == false) {
echo "pas trouvé";
//header("pageNotFound.php");
} else {
include("../Parsedown.php");
$parser = new Parsedown();
$parser->setUrlsLinked(false);
$content = $parser->text($content);
echo $content;
}