diff options
| -rw-r--r-- | controllers/archive.php | 18 | ||||
| -rw-r--r-- | views/archive/topbar.php | 13 |
2 files changed, 13 insertions, 18 deletions
diff --git a/controllers/archive.php b/controllers/archive.php index c1ff4a2..9b8ac16 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -354,13 +354,6 @@ class DownloadPage { } } - function getArchiveTop() : array { - return array( - file_get_contents(__DIR__ . '/../views/archive/topbar.php'), - file_get_contents(__DIR__ . '/../views/archive/topbar.css') - ); - } - function createArchive($simular_pages) : void { // Creates the folder with the correct resources and the main html page in a index.html tag $dom = new DOMDocument(); @@ -382,12 +375,17 @@ class DownloadPage { $this->changeHyperlinkToLocal($dom, 'a', 'href'); // Add the header for the archives - list($archive_top, $archive_top_style) = $this->getArchiveTop(); - $phpTag = $dom->createElement('script', $archive_top); + $phpTag = $dom->createElement('script', ' + </script> + <?php require_once "' . __DIR__ . '/../views/archive/topbar.php" ?> + <script> + '); $body = $dom->getElementsByTagName('body')->item(0); $body->appendChild($phpTag); - $styleTag = $dom->createElement('style', $archive_top_style); + $styleTag = $dom->createElement('link', ''); + $styleTag->setAttribute('rel', 'stylesheet'); + $styleTag->setAttribute('href', '/archive/topbar.css'); $head = $dom->getElementsByTagName('head')->item(0); $head->appendChild($styleTag); diff --git a/views/archive/topbar.php b/views/archive/topbar.php index f521fcb..b00a33d 100644 --- a/views/archive/topbar.php +++ b/views/archive/topbar.php @@ -1,17 +1,14 @@ -<!-- Dirty hack to escape all PHP dom sanitization and checks --> -</script> - <?php require_once "../../models/database.php"; require_once "../../models/webpage.php"; require_once "../../models/user.php"; - $currentPageId = basename(__DIR__); + $currentPageId = explode('/', $_SERVER['REQUEST_URI'], 4)[2]; $currentPage = Database\Webpage::fromDBwid($currentPageId); - $requesterUsername = Database\User::fromDBuid($currentPage->RequesterUID); + $requester = Database\User::fromDBuid($currentPage->RequesterUID); - $previousPageId = Database\Webpage::getPreviousPageId($currentPage->URL, $currentPage->Date); - $nextPageId = Database\Webpage::getNextPageId($currentPage->URL, $currentPage->Date); + $previousPageId = $currentPage->previousPageId(); + $nextPageId = $currentPage->nextPageId(); ?> <div class="navbar"> @@ -20,7 +17,7 @@ <span>Url: <?= $currentPage->URL ?></span> <span>Date of archival: <?= $currentPage->Date ?></span> <span>Visits: <?= $currentPage->Visits ?></span> - <span>Requested by: <?= $requesterUsername->Username ?></span> + <span>Requested by: <?= $requester->Username ?></span> </div> <div class="navbar-links"> |
