From f80f775dfbe12cf6b95bda38b73f5dc37327d7fa Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Thu, 26 Jul 2018 15:09:50 +0100 Subject: Change the "private file" prefix from "@" to "_" It has all the benefits previously mentioned in commit 2f547251, as well as mirroring the common programming convention of using a "_" prefix to identify private variables/functions Hides files beginning with _ from mod_autoindex listings As well as 404ing on files starting with "_", also 404 on files starting with ".", as these are also private. Except for /.well-known/, because that's... well known, and should be public. --- apache2.conf | 9 +++++-- html/@include.php | 66 ------------------------------------------------- html/_include.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ html/about | 2 +- html/contact | 2 +- html/index.php | 2 +- html/privacy | 2 +- html/projects/index.php | 2 +- rawdog/page.template | 2 +- 9 files changed, 79 insertions(+), 74 deletions(-) delete mode 100644 html/@include.php create mode 100644 html/_include.php diff --git a/apache2.conf b/apache2.conf index a29a16d..030bac1 100644 --- a/apache2.conf +++ b/apache2.conf @@ -157,9 +157,14 @@ RewriteCond %{LA-U:REQUEST_FILENAME} !-d RewriteRule !\. - [H=application/x-httpd-php] - # Disallow access to files/directories whose names begin with "@", returning a 404. + # Disallow access to files/directories whose names begin with "_" or "." + # (except for /.well-known/), returning a 404. # This makes those files appear to not exist. - RewriteRule "/@" "-" [R=404,L] + RewriteCond "%{REQUEST_URI}" "!^/.well-known/" + RewriteRule "/[_.]" "-" [R=404,L] + + # Do not list files beginning with an underscore in directory listings + IndexIgnore _??* AuthType Basic diff --git a/html/@include.php b/html/@include.php deleted file mode 100644 index 7ce79b0..0000000 --- a/html/@include.php +++ /dev/null @@ -1,66 +0,0 @@ - elements for the site -function site_head($title) { - return "{$title}\n" - . "\n" - . "\n" - . "\n" - . "\n"; -} - -/// Get a single top-level navigation item for the site -function site_navitem($url, $text, $hide = false) { - $selected = $url == $_SERVER['REQUEST_URI']; - - $classes = []; - if ($selected) { - $classes[] = "selected"; - } - if ($hide && !$selected) { - $classes[] = "hidden"; - } - $classes = count($classes) > 0 ? (" class=\"" . implode(" ", $classes) . "\"") : ""; - - return "{$text}"; -} - -/// Get the standard page header elements for the site -function site_header($title) { - return "

{$title}

\n" - . "\n"; -} - -/// Get the standard page footer elements for the site -function site_footer() { - return "
\n" - . "

Spragg Software Services Ltd is registered in England, No. 11248242.\n" - . " Registered office: 82 Upper Hanover Street, Sheffield, S3 7RQ.\n" - . " VAT reg No. 295343283.

\n"; -} - -?> diff --git a/html/_include.php b/html/_include.php new file mode 100644 index 0000000..7ce79b0 --- /dev/null +++ b/html/_include.php @@ -0,0 +1,66 @@ + elements for the site +function site_head($title) { + return "{$title}\n" + . "\n" + . "\n" + . "\n" + . "\n"; +} + +/// Get a single top-level navigation item for the site +function site_navitem($url, $text, $hide = false) { + $selected = $url == $_SERVER['REQUEST_URI']; + + $classes = []; + if ($selected) { + $classes[] = "selected"; + } + if ($hide && !$selected) { + $classes[] = "hidden"; + } + $classes = count($classes) > 0 ? (" class=\"" . implode(" ", $classes) . "\"") : ""; + + return "{$text}"; +} + +/// Get the standard page header elements for the site +function site_header($title) { + return "

{$title}

\n" + . "\n"; +} + +/// Get the standard page footer elements for the site +function site_footer() { + return "
\n" + . "

Spragg Software Services Ltd is registered in England, No. 11248242.\n" + . " Registered office: 82 Upper Hanover Street, Sheffield, S3 7RQ.\n" + . " VAT reg No. 295343283.

\n"; +} + +?> diff --git a/html/about b/html/about index fa4d544..4092829 100644 --- a/html/about +++ b/html/about @@ -1,4 +1,4 @@ - + diff --git a/html/contact b/html/contact index 632113a..3938f87 100644 --- a/html/contact +++ b/html/contact @@ -1,4 +1,4 @@ - + diff --git a/html/index.php b/html/index.php index 29e0cfa..488d9ba 100644 --- a/html/index.php +++ b/html/index.php @@ -1,4 +1,4 @@ - + diff --git a/html/privacy b/html/privacy index 6d338fd..a04ebd6 100644 --- a/html/privacy +++ b/html/privacy @@ -1,4 +1,4 @@ - + diff --git a/html/projects/index.php b/html/projects/index.php index b995ccf..f7e5f07 100644 --- a/html/projects/index.php +++ b/html/projects/index.php @@ -1,4 +1,4 @@ - + diff --git a/rawdog/page.template b/rawdog/page.template index 050f719..df5e817 100644 --- a/rawdog/page.template +++ b/rawdog/page.template @@ -1,4 +1,4 @@ - + -- cgit v1.2.1