summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]app.php19
-rwxr-xr-x[-rw-r--r--]css/desktop/body.css (renamed from css/body.css)0
-rw-r--r--css/desktop/container.css (renamed from css/container.css)0
-rwxr-xr-x[-rw-r--r--]css/desktop/content.css (renamed from css/content.css)0
-rwxr-xr-x[-rw-r--r--]css/desktop/footer.css (renamed from css/footer.css)0
-rwxr-xr-x[-rw-r--r--]css/desktop/header.css (renamed from css/header.css)0
-rwxr-xr-x[-rw-r--r--]html/app.html15
-rwxr-xr-x[-rw-r--r--]html/footer.html0
-rwxr-xr-x[-rw-r--r--]html/header.html0
-rw-r--r--php/execute.php (renamed from php/templates.php)20
-rwxr-xr-x[-rw-r--r--]php/footer.php0
-rw-r--r--php/load-css.php9
-rw-r--r--php/path-clean.php (renamed from css/all.css)12
-rwxr-xr-x[-rw-r--r--]php/replace.php0
14 files changed, 45 insertions, 30 deletions
diff --git a/app.php b/app.php
index 62fdda7..6a4b41e 100644..100755
--- a/app.php
+++ b/app.php
@@ -24,17 +24,22 @@ define('ROOT_DIR', __DIR__ . '/');
define('HTML_DIR', __DIR__ . '/html/');
define('PHP_DIR', __DIR__ . '/php/');
-require_once PHP_DIR . 'templates.php';
+require_once PHP_DIR . 'replace.php';
+require_once PHP_DIR . 'execute.php';
+require_once PHP_DIR . 'path-clean.php';
-$file = $_GET['file'] ?? 'index.html';
+$file = path_clean($_GET['file'] ?? 'index.html');
-$components = [
- '{{HEADER}}' => HTML_DIR . 'header.html',
- '{{CONTENT}}' => ROOT_DIR . $file,
- '{{FOOTER}}' => PHP_DIR . 'footer.php'
+$device = 'desktop';
+
+$targets = [
+ '{{header}}' => file_get_contents(HTML_DIR . 'header.html'),
+ '{{content}}' => file_get_contents(ROOT_DIR . $file),
+ '{{footer}}' => execute(PHP_DIR . 'footer.php'),
+ '{{device}}' => $device
];
-$app_html = template_process(HTML_DIR . 'app.html', $components);
+$app_html = replace(HTML_DIR . 'app.html', $targets);
echo $app_html;
?>
diff --git a/css/body.css b/css/desktop/body.css
index e252f1c..e252f1c 100644..100755
--- a/css/body.css
+++ b/css/desktop/body.css
diff --git a/css/container.css b/css/desktop/container.css
index ff5e766..ff5e766 100644
--- a/css/container.css
+++ b/css/desktop/container.css
diff --git a/css/content.css b/css/desktop/content.css
index 0a86b16..0a86b16 100644..100755
--- a/css/content.css
+++ b/css/desktop/content.css
diff --git a/css/footer.css b/css/desktop/footer.css
index 7e3b215..7e3b215 100644..100755
--- a/css/footer.css
+++ b/css/desktop/footer.css
diff --git a/css/header.css b/css/desktop/header.css
index ad7afb8..ad7afb8 100644..100755
--- a/css/header.css
+++ b/css/desktop/header.css
diff --git a/html/app.html b/html/app.html
index b5e4d0d..a01ca45 100644..100755
--- a/html/app.html
+++ b/html/app.html
@@ -20,19 +20,26 @@
<html lang="en">
<head>
<meta charset="UTF-8">
+
<title>GNUfault.org</title>
- <link rel="stylesheet" type="text/css" href="/css/all.css">
+
<link rel="icon" type="image/x-icon" href="/images/logos/taya.gif">
+
+ <link rel="stylesheet" href="/css/{{device}}/body.css" media="(min-width: 768px)">
+ <link rel="stylesheet" href="/css/{{device}}/content.css" media="(min-width: 768px)">
+ <link rel="stylesheet" href="/css/{{device}}/header.css" media="(min-width: 768px)">
+ <link rel="stylesheet" href="/css/{{device}}/footer.css" media="(min-width: 768px)">
+ <link rel="stylesheet" href="/css/{{device}}/container.css" media="(min-width: 768px)">
</head>
<body ontouchstart>
<div class="container">
- {{HEADER}}
+ {{header}}
<div class="content">
- {{CONTENT}}
+ {{content}}
</div>
- {{FOOTER}}
+ {{footer}}
</div>
</body>
</html>
diff --git a/html/footer.html b/html/footer.html
index 3a15050..3a15050 100644..100755
--- a/html/footer.html
+++ b/html/footer.html
diff --git a/html/header.html b/html/header.html
index 5035bfa..5035bfa 100644..100755
--- a/html/header.html
+++ b/html/header.html
diff --git a/php/templates.php b/php/execute.php
index dfd4063..bd8fe18 100644
--- a/php/templates.php
+++ b/php/execute.php
@@ -17,21 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-function render_component(string $componentPath): string {
- ob_start();
- include($componentPath);
- return ob_get_clean();
-}
-
-function template_process(string $template, array $components = []): string {
- $html = file_get_contents($template);
-
- foreach ($components as $placeholder => $componentPath) {
- $injectedContent = render_component($componentPath);
- $html = str_replace($placeholder, $injectedContent, $html);
+function execute($path) {
+ if (file_exists($path)) {
+ ob_start();
+ include $path;
+ return ob_get_clean();
}
-
- return $html;
+ return '';
}
?>
diff --git a/php/footer.php b/php/footer.php
index 0d9c8b6..0d9c8b6 100644..100755
--- a/php/footer.php
+++ b/php/footer.php
diff --git a/php/load-css.php b/php/load-css.php
new file mode 100644
index 0000000..7cabc91
--- /dev/null
+++ b/php/load-css.php
@@ -0,0 +1,9 @@
+<?php
+$isMobile = isset($_SERVER['HTTP_SEC_CH_UA_MOBILE']) && $_SERVER['HTTP_SEC_CH_UA_MOBILE'] === '?1';
+$folder = $isMobile ? 'mobile' : 'desktop';
+?>
+<link rel="stylesheet" href="<?php echo $folder; ?>/body.css">
+<link rel="stylesheet" href="<?php echo $folder; ?>/content.css">
+<link rel="stylesheet" href="<?php echo $folder; ?>/header.css">
+<link rel="stylesheet" href="<?php echo $folder; ?>/footer.css">
+<link rel="stylesheet" href="<?php echo $folder; ?>/container.css">
diff --git a/css/all.css b/php/path-clean.php
index 1900236..d7b5fbf 100644
--- a/css/all.css
+++ b/php/path-clean.php
@@ -1,3 +1,4 @@
+<?php
/*
* GNUfault.org - GNUfault's website
* Copyright (C) 2026 Connor Thomson
@@ -16,8 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-@import url("body.css");
-@import url("content.css");
-@import url("header.css");
-@import url("footer.css");
-@import url("container.css");
+function path_clean($path) {
+ $pattern = '/(\.\.\/)+/';
+ return preg_replace($pattern, '', $path);
+}
+
+?>
diff --git a/php/replace.php b/php/replace.php
index 9cdc5bf..9cdc5bf 100644..100755
--- a/php/replace.php
+++ b/php/replace.php