-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
33 lines (23 loc) · 872 Bytes
/
index.php
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
<?php
$req = (isset($_GET['req']) ? $_GET['req'] : FALSE);
if ($req && file_exists('./pages/' . $req . '.php')) {
$html = new DOMDocument();
libxml_use_internal_errors(true);
$html->loadHTMLFile('./pages/master.php');
$page = new DOMDocument();
$page->loadHTMLFile('./pages/' . $req . '.php');
$head = $html->getElementsByTagName('head');
$pageHead = $page->getElementsByTagName('head');
foreach ($pageHead->item(0)->childNodes as $node) {
$head->item(0)->appendChild($html->importNode($node, TRUE));
}
$main = $html->getElementsByTagName('main');
$mainPage = $page->getElementsByTagName('main');
foreach ($mainPage->item(0)->childNodes as $node) {
$main->item(0)->appendChild($html->importNode($node, TRUE));
}
echo $html->saveHTML();
} else {
require_once "./404/index.php";
}
?>