1
0
Fork 0
mirror of https://gitlab.com/niansa/simpsh-httpd.git synced 2025-03-06 20:53:36 +01:00

Update urlcheck.sh

This commit is contained in:
niansa 2018-07-03 16:29:38 +00:00
parent 232abbb467
commit 3fe0bc0a08

View file

@ -1,12 +1,12 @@
#! /bin/bash #! /bin/bash
# Blockiere Versuche, das restliche Dateisystem zu lesen # Block tries to read documents outside the document root
if [[ "$URL" == *..* ]]; then if [[ "$URL" == *..* ]]; then
URL='/' URL='/'
FILE="$FILES" FILE="$FILES"
fi fi
# Verhindere "/"-bug # Avoid a bug
if [ -d "$FILE" ]; then if [ -d "$FILE" ]; then
if [[ "$URL" != */ ]]; then if [[ "$URL" != */ ]]; then
STATUS='HTTP/1.0 302 Moved permanently STATUS='HTTP/1.0 302 Moved permanently
@ -17,26 +17,26 @@ Location: '"${WEBSITE}${URL}"'/'
fi fi
fi fi
# Finde index.html # Find index.html
if [ -f "${FILE}index.html" ]; then if [ -f "${FILE}index.html" ]; then
URL="${URL}index.html" URL="${URL}index.html"
FILE="${FILE}index.html" FILE="${FILE}index.html"
fi fi
# Finde index.php # Find index.php
if [ -f "${FILE}index.php" ]; then if [ -f "${FILE}index.php" ]; then
URL="${URL}index.php" URL="${URL}index.php"
FILE="${FILE}index.php" FILE="${FILE}index.php"
fi fi
# Antworte 404 Not Found wenn Datei nicht existiert # Answer 404 if the file doesn't exist
if [ ! -e "$FILE" ]; then if [ ! -e "$FILE" ]; then
STATUS='HTTP/1.0 404 Not Found' STATUS='HTTP/1.0 404 Not Found'
CONTENTTYPE='text/html' CONTENTTYPE='text/html'
FILE="$ERROR404" FILE="$ERROR404"
fi fi
# Antworte 403 Forbidden wenn Datei nicht lesbar ist # Answer 403 if the file isn't readable
if [ ! -r "$FILE" ]; then if [ ! -r "$FILE" ]; then
STATUS='HTTP/1.0 403 Forbidden' STATUS='HTTP/1.0 403 Forbidden'
CONTENTTYPE='text/html' CONTENTTYPE='text/html'