Merge pull request #1057 from pi-hole/new/whitelistonblockingpage
Allow whitelisting from blocking page
This commit is contained in:
commit
1a3bdbaabf
|
@ -101,7 +101,7 @@ li::before { content: "\00BB\00a0"; }
|
||||||
li a { position: relative; top: 1px; } /* Center bullet-point arrows */
|
li a { position: relative; top: 1px; } /* Center bullet-point arrows */
|
||||||
|
|
||||||
/* Button Style */
|
/* Button Style */
|
||||||
.buttons a, input, .transparent th a { /* Swapped rgba is shared with input[type='url'] */
|
.buttons a, button, input, .transparent th a { /* Swapped rgba is shared with input[type='url'] */
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: rgba(32,32,32,0.9);
|
color: rgba(32,32,32,0.9);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -120,12 +120,15 @@ li a { position: relative; top: 1px; } /* Center bullet-point arrows */
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons { white-space: nowrap; width: 100%; display: table; }
|
.buttons { white-space: nowrap; width: 100%; display: table; }
|
||||||
|
.buttons33 { white-space: nowrap; width: 33.333%; display: table; text-align: center; margin-left: 33.333% }
|
||||||
.mini a { width: 50%; }
|
.mini a { width: 50%; }
|
||||||
a.safe { background-color: rgba(0,220,0,0.5); }
|
a.safe { background-color: rgba(0,220,0,0.5); }
|
||||||
|
button.safe { background-color: rgba(0,220,0,0.5); }
|
||||||
a.warn { background-color: rgba(220,0,0,0.5); }
|
a.warn { background-color: rgba(220,0,0,0.5); }
|
||||||
|
|
||||||
.blocked a, .mini a { display: table-cell; }
|
.blocked a, .mini a { display: table-cell; }
|
||||||
.blocked a.safe { width: 100%; }
|
.blocked a.safe50 { width: 50%; background-color: rgba(0,220,0,0.5); }
|
||||||
|
.blocked a.safe33 { width: 33.333%; background-color: rgba(0,220,0,0.5); }
|
||||||
|
|
||||||
/* Types of text */
|
/* Types of text */
|
||||||
.msg { white-space: pre; overflow: auto; -webkit-overflow-scrolling: touch; display: block; line-height: 1.2em; font-weight: bold; font-size: 1.15em; margin: 4px 8px 8px 8px; white-space: pre-line; }
|
.msg { white-space: pre; overflow: auto; -webkit-overflow-scrolling: touch; display: block; line-height: 1.2em; font-weight: bold; font-size: 1.15em; margin: 4px 8px 8px 8px; white-space: pre-line; }
|
||||||
|
|
|
@ -51,8 +51,8 @@ if($uri == "/")
|
||||||
<head>
|
<head>
|
||||||
<meta charset='UTF-8'/>
|
<meta charset='UTF-8'/>
|
||||||
<title>Website Blocked</title>
|
<title>Website Blocked</title>
|
||||||
<link rel='stylesheet' href='http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/blockingpage.css'/>
|
<link rel='stylesheet' href='http://pi.hole/pihole/blockingpage.css'/>
|
||||||
<link rel='shortcut icon' href='http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/img/favicon.png' type='image/png'/>
|
<link rel='shortcut icon' href='http://pi.hole/admin/img/favicon.png' type='image/png'/>
|
||||||
<meta name='viewport' content='width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=no'/>
|
<meta name='viewport' content='width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=no'/>
|
||||||
<meta name='robots' content='noindex,nofollow'/>
|
<meta name='robots' content='noindex,nofollow'/>
|
||||||
</head>
|
</head>
|
||||||
|
@ -69,35 +69,94 @@ if($uri == "/")
|
||||||
<button id="btnSearch" class="buttons blocked" type="button" style="visibility: hidden;"></button>
|
<button id="btnSearch" class="buttons blocked" type="button" style="visibility: hidden;"></button>
|
||||||
This page is blocked because it is explicitly contained within the following block list(s):
|
This page is blocked because it is explicitly contained within the following block list(s):
|
||||||
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre><br/>
|
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre><br/>
|
||||||
<div class='buttons blocked'><a class='safe' href='javascript:history.back()'>Go back</a>
|
<div class='buttons blocked'>
|
||||||
|
<a class='safe33' href='javascript:history.back()'>Go back</a>
|
||||||
|
<a class='safe33' id="whitelisting">Whitelist this page</a>
|
||||||
|
<a class='safe33' href='javascript:window.close()'>Close window</a>
|
||||||
|
</div>
|
||||||
|
<div style="width: 98%; text-align: center; padding: 10px;" hidden="true" id="whitelistingform">Password required!<br/>
|
||||||
|
<form>
|
||||||
|
<input name="list" type="hidden" value="white"><br/>
|
||||||
|
Domain:<br/>
|
||||||
|
<input name="domain" value="<?php echo $serverName ?>" disabled><br/><br/>
|
||||||
|
Password:<br/>
|
||||||
|
<input type="password" id="pw" name="pw"><br/><br/>
|
||||||
|
<button class="buttons33 safe" id="btnAdd" type="button">Whitelist</button>
|
||||||
|
</form><br/>
|
||||||
|
<pre id="whitelistingoutput" style="width: 100%; height: 100%; padding: 5px;" hidden="true"></pre><br/>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>Generated <?php echo date('D g:i A, M d'); ?> by Pi-hole <?php echo $piHoleVersion; ?></footer>
|
<footer>Generated <?php echo date('D g:i A, M d'); ?> by Pi-hole <?php echo $piHoleVersion; ?></footer>
|
||||||
<script src="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/js/other/jquery.min.js"></script>
|
<script src="http://pi.hole/admin/js/other/jquery.min.js"></script>
|
||||||
<script src="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/admin/js/pihole/queryads.js"></script>
|
<script src="http://pi.hole/admin/js/pihole/queryads.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function inIframe () {
|
function inIframe () {
|
||||||
try {
|
try {
|
||||||
return window.self !== window.top;
|
return window.self !== window.top;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to detect if page is loaded within iframe
|
||||||
|
if(inIframe())
|
||||||
|
{
|
||||||
|
// Within iframe
|
||||||
|
// hide content of page
|
||||||
|
$('#body').hide();
|
||||||
|
// remove background
|
||||||
|
document.body.style.backgroundImage = "none";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Query adlists
|
||||||
|
$( "#btnSearch" ).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
$( "#whitelisting" ).on( "click", function(){ $( "#whitelistingform" ).removeAttr( "hidden" ); });
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
var domain = $("#domain");
|
||||||
|
var pw = $("#pw");
|
||||||
|
if(domain.val().length === 0){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to detect if page is loaded within iframe
|
$.ajax({
|
||||||
if(inIframe())
|
url: "admin/php/add.php",
|
||||||
{
|
method: "post",
|
||||||
// Within iframe
|
data: {"domain":domain.val(), "list":"white", "pw":pw.val()},
|
||||||
// hide content of page
|
success: function(response) {
|
||||||
$('#body').hide();
|
$( "#whitelistingoutput" ).removeAttr( "hidden" );
|
||||||
// remove background
|
if(response.indexOf("Pi-hole blocking") !== -1)
|
||||||
document.body.style.backgroundImage = "none";
|
{
|
||||||
}
|
// Reload page after 5 seconds
|
||||||
else
|
setTimeout(function(){window.location.reload(1);}, 5000);
|
||||||
{
|
$( "#whitelistingoutput" ).html("---> Success <---<br/>You may have to flush your DNS cache");
|
||||||
// Query adlists
|
}
|
||||||
$( "#btnSearch" ).click();
|
else
|
||||||
}
|
{
|
||||||
// }
|
$( "#whitelistingoutput" ).html("---> "+response+" <---");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(jqXHR, exception) {
|
||||||
|
$( "#whitelistingoutput" ).removeAttr( "hidden" );
|
||||||
|
$( "#whitelistingoutput" ).html("---> Unknown Error <---");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Handle enter button for adding domains
|
||||||
|
$(document).keypress(function(e) {
|
||||||
|
if(e.which === 13 && $("#pw").is(":focus")) {
|
||||||
|
add();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle buttons
|
||||||
|
$("#btnAdd").on("click", function() {
|
||||||
|
add();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -798,11 +798,11 @@ installPiholeWeb() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "/var/www/html/admin/blockingpage.css" ]; then
|
if [ -f "/var/www/html/pihole/blockingpage.css" ]; then
|
||||||
echo "::: Existing blockingpage.css detected, not overwriting"
|
echo "::: Existing blockingpage.css detected, not overwriting"
|
||||||
else
|
else
|
||||||
echo -n "::: index.css missing, replacing... "
|
echo -n "::: index.css missing, replacing... "
|
||||||
cp /etc/.pihole/advanced/blockingpage.css /var/www/html/admin
|
cp /etc/.pihole/advanced/blockingpage.css /var/www/html/pihole
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue