Fix some CSS and security issues

This commit is contained in:
Lazarus 2024-01-07 15:26:27 +01:00
parent 442232a990
commit b7b3a1781a
2 changed files with 16 additions and 9 deletions

View File

@ -2,6 +2,7 @@
/* style from Omar Polo: https://gmid.omarpolo.com/style.css */ /* style from Omar Polo: https://gmid.omarpolo.com/style.css */
body { body {
background-color: white;
font-family: monospace; font-family: monospace;
font-size: 14px; font-size: 14px;
max-width: 780px; max-width: 780px;
@ -15,7 +16,7 @@ h1::before {
} }
h2 { h2 {
margin-top: 40px; margin-top: 20px;
} }
h2::before { h2::before {
@ -48,6 +49,10 @@ p.link::before {
content: "→ "; content: "→ ";
} }
p {
margin: 0;
}
strong::before { content: "*" } strong::before { content: "*" }
strong::after { content: "*" } strong::after { content: "*" }
@ -120,4 +125,4 @@ color: #ff4cff;
@media (max-width: 500px) { @media (max-width: 500px) {
pre.banner { font-size: 10px; } pre.banner { font-size: 10px; }
} }

View File

@ -12,6 +12,12 @@ $domain = $_SERVER['HTTP_HOST'];
$php_self = $_SERVER['PHP_SELF']; // by default: /htmgem/index.php $php_self = $_SERVER['PHP_SELF']; // by default: /htmgem/index.php
$php_self_dir = dirname($php_self); $php_self_dir = dirname($php_self);
$url = @$_REQUEST["url"]; $url = @$_REQUEST["url"];
if(isset($_REQUEST['style']))
$style = htmlspecialchars($_REQUEST['style']);
else
$style = "";
$urlRewriting = @$_REQUEST["rw"]=="1"; $urlRewriting = @$_REQUEST["rw"]=="1";
/** /**
@ -66,7 +72,7 @@ if ($go404) {
http_response_code(404); http_response_code(404);
$page404 = \htmgem\html\get404GmiPage($url); $page404 = \htmgem\html\get404GmiPage($url);
$gt_html = new \htmgem\GemTextTranslate_html($page404); $gt_html = new \htmgem\GemTextTranslate_html($page404);
if (empty($gt_html->getCss())) $gt_html->addCss($php_self_dir."/css/htmgem.css"); if (empty($gt_html->getCss())) $gt_html->addCss($php_self_dir.DEFAULT_CSS);
if ($urlRewriting) if ($urlRewriting)
echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url); echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url);
else else
@ -82,8 +88,6 @@ $fileContents = @file_get_contents($filePath);
/* CSS and special style management /* CSS and special style management
*/ */
$style = @$_REQUEST['style'];
if ("source" == $style) { if ("source" == $style) {
$basename = basename($filePath); $basename = basename($filePath);
header("Cache-Control: public"); header("Cache-Control: public");
@ -123,12 +127,10 @@ if (empty($style)) {
} else { } else {
$style = preg_replace("/,/", "/", $style); $style = preg_replace("/,/", "/", $style);
if ("/" == $php_self_dir) $php_self_dir = ""; # dirname() never use a final slash except for the root if ("/" == $php_self_dir) $php_self_dir = ""; # dirname() never use a final slash except for the root
$gt_html->addCss("$php_self_dir/css/$style"); $gt_html->addCss($php_self_dir."/css/$style");
} }
if ($urlRewriting) if ($urlRewriting)
echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url); echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url);
else else
echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url, "$php_self?url="); echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $url, "$php_self?url=");
?>