Added defunct archived.php code.
This commit is contained in:
parent
dee22d6f4d
commit
f2126d3481
42
archived.php
Normal file
42
archived.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
// Directory containing HTML files
|
||||
$htmlDir = __DIR__ . DIRECTORY_SEPARATOR . 'public';
|
||||
|
||||
// Header and Footer content
|
||||
$headHeaderContent =
|
||||
'<style>'.' '.
|
||||
'.__archived__content__, .__archived__content__ p, .__archived__content__ h2 { background-color: #007bff; color: #fff; font-family: "Saira Extra Condensed", Verdana, Arial, sans-serif; text-align: center; }'.' '.
|
||||
'.__archived__content__ { padding: 0.5rem; }'.' '.
|
||||
'.__archived__content__:first-of-type { margin-top: 0rem; margin-bottom: 1rem; }'.' '.
|
||||
'.__archived__content__:last-of-type { margin-top: 1rem; margin-bottom: 0; }'.' '.
|
||||
'.__archived__content__, .__archived__content__ p { font-size: 1.2rem; }'.' '.
|
||||
'.__archived__content__, .__archived__content__ h2 { font-size: 2rem; }'.' '.
|
||||
'.__archived__content__ a:link, .__archived__content__ a:visited { color: #fff; }'.' '.
|
||||
'.__archived__content__ a:hover, .__archived__content__ a:active { text-decoration: none; }'.
|
||||
'</style>';
|
||||
$headFooterContent = '<link href="https://fonts.googleapis.com/css?family=Saira+Extra+Condensed:100,200,300,400,500,600,700,800,900" rel="stylesheet">';
|
||||
$bodyHeaderContent = '<div class="__archived__content__"><h2>Archived Web Site</h2><p>This is an archived version of the original website. Some features may not be functional. Do not submit any personal information to this archived website.</p><p><a href="./">Current Working Directory List</a> | <a href="/">Back to Archive Index</a></p></div>';
|
||||
$bodyFooterContent = '<div class="__archived__content__"><p>This is an archived version of the original website. Some features may not be functional. Do not submit any personal information to this archived website.</p><p><a href="./">Current Working Directory Listing</a> | <a href="/">Back to Archive Index</a></p></div>';
|
||||
|
||||
// Get the requested HTML file
|
||||
$requestedFile = $_SERVER['REQUEST_URI'];
|
||||
|
||||
// Validate and sanitize the requested file path to ensure it's within the intended directory.
|
||||
$filePath = realpath($htmlDir . DIRECTORY_SEPARATOR . $requestedFile);
|
||||
|
||||
if (strpos($filePath, $htmlDir) === 0 && is_file($filePath)) {
|
||||
|
||||
// Read the HTML file
|
||||
$htmlContent = file_get_contents($filePath);
|
||||
|
||||
// Add archive branding
|
||||
$maxReplacements = 1; // do not replace more than one
|
||||
$htmlContent = preg_replace('/<head\s*[^>]*>/i', '$0' . $headHeaderContent, $htmlContent, $maxReplacements);
|
||||
$htmlContent = str_replace('</head>', $headFooterContent . '</head>', $htmlContent);
|
||||
$htmlContent = preg_replace('/<body\s*[^>]*>/i', '$0' . $bodyHeaderContent, $htmlContent, $maxReplacements);
|
||||
$htmlContent = str_replace('</body>', $bodyFooterContent . '</body>', $htmlContent);
|
||||
|
||||
// Output the modified HTML content
|
||||
echo $htmlContent;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user