diff --git a/var/www/pages/index.php b/var/www/pages/index.php
index 43454d4..fbca7a2 100644
--- a/var/www/pages/index.php
+++ b/var/www/pages/index.php
@@ -8,7 +8,7 @@ function send_response($code, $message) {
$request_url = filter_var($_SERVER["PHP_SELF"], FILTER_SANITIZE_URL);
-if ($request_url === "/") {
+if ($request_url === "/" and $_SERVER["HTTP_HOST"] === "codeberg.eu") {
send_response(200, "
@@ -20,7 +20,7 @@ if ($request_url === "/") {
Codeberg Pages. Static Pages for your Projects.
Create a repo named 'pages' in your user account or org, push static content, HTML, style, fonts, images.
- Share your rendered content via:
https://" . $_SERVER["HTTP_HOST"] . "/<username>/
+ Share your rendered content via:
https://<username>." . $_SERVER["HTTP_HOST"] . "
Welcome to Codeberg.org!
@@ -30,14 +30,21 @@ if ($request_url === "/") {
}
# Restrict allowed characters in request URI:
-if (preg_match("/^\/[a-zA-Z0-9_ +\-\/\.]+\$/", $request_url) != 1) {
+if (preg_match("/^\/[a-zA-Z0-9_ +\-\/\.]*\$/", $request_url) != 1) {
send_response(404, "invalid request URL");
}
$git_prefix = "/data/git/gitea-repositories";
$parts = explode("/", $request_url);
$parts = array_diff($parts, array("")); # Remove empty parts in URL
-$owner = strtolower(array_shift($parts));
+
+$parts_dot = explode(".",$_SERVER["HTTP_HOST"]);
+if (count($parts_dot) != 3)
+{
+ send_response(404, "invalid subdomain");
+}
+$owner = $parts_dot[0];
+
$git_root = realpath("$git_prefix/$owner/pages.git");
$file_url = implode("/", $parts);