Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Schaper <dan@glacialmagma.com>2020-04-11 06:50:26 +0300
committerGitHub <noreply@github.com>2020-04-11 06:50:26 +0300
commit413fa94e9824af924da4366f5719bdccb85fde41 (patch)
tree529c8e6309f14218d80e95b08b2154afde2464a0 /advanced
parent2de5362adc2c1c780eac1ab39e466875143091d5 (diff)
parent308eb5eda5c32fd262c09a81c5df7ac2433886d9 (diff)
Merge pull request #3263 from mschoettle/fix/broken-blocking-landing-page-v5.0
Fixes broken blocking page and landing page when changing server port or host name (v5.0)
Diffstat (limited to 'advanced')
-rw-r--r--advanced/index.php37
1 files changed, 25 insertions, 12 deletions
diff --git a/advanced/index.php b/advanced/index.php
index b0c4a7c3..4f2a17f7 100644
--- a/advanced/index.php
+++ b/advanced/index.php
@@ -6,8 +6,8 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-// Sanitise HTTP_HOST output
-$serverName = htmlspecialchars($_SERVER["HTTP_HOST"]);
+// Sanitize SERVER_NAME output
+$serverName = htmlspecialchars($_SERVER["SERVER_NAME"]);
// Remove external ipv6 brackets if any
$serverName = preg_replace('/^\[(.*)\]$/', '${1}', $serverName);
@@ -50,16 +50,24 @@ function setHeader($type = "x") {
}
// Determine block page type
-if ($serverName === "pi.hole") {
+if ($serverName === "pi.hole"
+ || (!empty($_SERVER["VIRTUAL_HOST"]) && $serverName === $_SERVER["VIRTUAL_HOST"])) {
// Redirect to Web Interface
exit(header("Location: /admin"));
} elseif (filter_var($serverName, FILTER_VALIDATE_IP) || in_array($serverName, $authorizedHosts)) {
// Set Splash Page output
$splashPage = "
- <html><head>
+ <html>
+ <head>
$viewPort
- <link rel='stylesheet' href='/pihole/blockingpage.css' type='text/css'/>
- </head><body id='splashpage'><img src='/admin/img/logo.svg'/><br/>Pi-<b>hole</b>: Your black hole for Internet advertisements<br><a href='/admin'>Did you mean to go to the admin panel?</a></body></html>
+ <link rel='stylesheet' href='pihole/blockingpage.css' type='text/css'/>
+ </head>
+ <body id='splashpage'>
+ <img src='admin/img/logo.svg'/><br/>
+ Pi-<b>hole</b>: Your black hole for Internet advertisements<br/>
+ <a href='/admin'>Did you mean to go to the admin panel?</a>
+ </body>
+ </html>
";
// Set splash/landing page based off presence of $landPage
@@ -68,7 +76,7 @@ if ($serverName === "pi.hole") {
// Unset variables so as to not be included in $landPage
unset($serverName, $svPasswd, $svEmail, $authorizedHosts, $validExtTypes, $currentUrlExt, $viewPort);
- // Render splash/landing page when directly browsing via IP or authorised hostname
+ // Render splash/landing page when directly browsing via IP or authorized hostname
exit($renderPage);
} elseif ($currentUrlExt === "js") {
// Serve Pi-hole Javascript for blocked domains requesting JS
@@ -131,7 +139,12 @@ ini_set("default_socket_timeout", 3);
function queryAds($serverName) {
// Determine the time it takes while querying adlists
$preQueryTime = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"];
- $queryAds = file("http://127.0.0.1/admin/scripts/pi-hole/php/queryads.php?domain=$serverName&bp", FILE_IGNORE_NEW_LINES);
+ $queryAdsURL = sprintf(
+ "http://127.0.0.1:%s/admin/scripts/pi-hole/php/queryads.php?domain=%s&bp",
+ $_SERVER["SERVER_PORT"],
+ $serverName
+ );
+ $queryAds = file($queryAdsURL, FILE_IGNORE_NEW_LINES);
$queryAds = array_values(array_filter(preg_replace("/data:\s+/", "", $queryAds)));
$queryTime = sprintf("%.0f", (microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"]) - $preQueryTime);
@@ -209,7 +222,7 @@ $phVersion = exec("cd /etc/.pihole/ && git describe --long --tags");
if (explode("-", $phVersion)[1] != "0")
$execTime = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"];
-// Please Note: Text is added via CSS to allow an admin to provide a localised
+// Please Note: Text is added via CSS to allow an admin to provide a localized
// language without the need to edit this file
setHeader();
@@ -226,10 +239,10 @@ setHeader();
<?=$viewPort ?>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="x-dns-prefetch-control" content="off">
- <link rel="shortcut icon" href="//pi.hole/admin/img/favicon.png" type="image/x-icon"/>
- <link rel="stylesheet" href="//pi.hole/pihole/blockingpage.css" type="text/css"/>
+ <link rel="shortcut icon" href="admin/img/favicon.png" type="image/x-icon"/>
+ <link rel="stylesheet" href="pihole/blockingpage.css" type="text/css"/>
<title>● <?=$serverName ?></title>
- <script src="//pi.hole/admin/scripts/vendor/jquery.min.js"></script>
+ <script src="admin/scripts/vendor/jquery.min.js"></script>
<script>
window.onload = function () {
<?php