summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-21 22:48:04 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-21 22:48:04 -0400
commit3517c1aac1e844f91779e844b8030ad7b11e05d1 (patch)
treefc511745f9600dd50468f9e4320e83c8010673cf /index.php
parent6ced32a51269303343a6d3e803dc299eff39781d (diff)
add an automatic mirror selection script
Diffstat (limited to 'index.php')
-rw-r--r--index.php22
1 files changed, 4 insertions, 18 deletions
diff --git a/index.php b/index.php
index 694931a..5a09cd6 100644
--- a/index.php
+++ b/index.php
@@ -13,26 +13,13 @@ $repos_para_project = [ 'libre', 'libre-testing',
$repos_para_community = [ 'cross', 'java', 'kernels', 'nonprism', 'pcr' ];
// Automatic configuration
-$assetdir = dirname($_SERVER["SCRIPT_NAME"]);
+$asseturl = dirname($_SERVER["SCRIPT_NAME"]);
+$assetdir = dirname($_SERVER["SCRIPT_FILENAME"]);
$root = $_SERVER["DOCUMENT_ROOT"];
$dirname = explode("?", $_SERVER["REQUEST_URI"], 2)[0];
////////////////////////////////////////////////////////////////////////////////
-function show_404() {
- // This is the template used by Nginx internally;
- // if you want something else, have Nginx intercept it.
- // Separation of concerns.
- ?><html>
-<head><title>404 Not Found</title></head>
-<body bgcolor="white">
-<center><h1>404 Not Found</h1></center>
-<hr><center><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></center>
-</body>
-</html>
-<?php
-}
-
function normalizeN($filename) {
$parts = preg_split("|/+|", $filename, -1, PREG_SPLIT_NO_EMPTY);
$abs = substr($filename, 0, 1) === '/';
@@ -96,8 +83,7 @@ if (!is_dir($root.'/'.$dirname)) {
header('Content-Type: text/plain'); // gross, but if Nginx is "properly" configured, this only happens when serving itself, which is text
readfile($root.'/'.$dirname);
} else {
- header("HTTP/1.0 404 Not Found");
- show_404();
+ require $assetdir.'/404.php';
}
exit(0);
}
@@ -109,7 +95,7 @@ if (!is_dir($root.'/'.$dirname)) {
<head>
<meta charset="utf-8" />
<title>Parabola GNU/Linux-libre - Index of <?php echo htmlentities($dirname); ?></title>
- <link rel="stylesheet" type="text/css" href="<?php echo $assetdir."/style.css"; ?>" />
+ <link rel="stylesheet" type="text/css" href="<?php echo $asseturl."/style.css"; ?>" />
<link rel="icon" type="image/x-icon" href="https://www.parabola.nu/static/favicon.72ab042ac877.ico" />
<link rel="shortcut icon" type="image/x-icon" href="https://www.parabola.nu/static/favicon.72ab042ac877.ico" />
<link rel="apple-touch-icon" href="https://www.parabola.nu/static/logos/apple-touch-icon-57x57.6484c8e17e2f.png" />