2016-12-04 21:17:08 +00:00
< ? php
/* Detailed Pi-Hole Block Page: Show "Website Blocked" if user browses to site, but not to image/file requests based on the work of WaLLy3K for DietPi & Pi-Hole */
$uri = escapeshellcmd ( $_SERVER [ 'REQUEST_URI' ]);
$serverName = escapeshellcmd ( $_SERVER [ 'SERVER_NAME' ]);
// Retrieve server URI extension (EG: jpg, exe, php)
$uriExt = pathinfo ( $uri , PATHINFO_EXTENSION );
// Define which URL extensions get rendered as "Website Blocked"
$webExt = array ( 'asp' , 'htm' , 'html' , 'php' , 'rss' , 'xml' );
if ( in_array ( $uriExt , $webExt ) || empty ( $uriExt ))
{
// Requested resource has an extension listed in $webExt
// or no extension (index access to some folder incl. the root dir)
$showPage = true ;
}
else
{
// Something else
$showPage = false ;
}
// Handle incoming URI types
if ( ! $showPage )
{
?>
2015-06-07 04:28:41 +00:00
< html >
2016-08-20 00:45:17 +00:00
< head >
2016-12-04 21:17:08 +00:00
< script > window . close (); </ script ></ head >
< body >
2016-12-05 11:34:30 +00:00
< img src = " data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 " >
2016-12-04 21:17:08 +00:00
</ body >
</ html >
< ? php
die ();
}
// Get Pi-Hole version
$piHoleVersion = exec ( 'cd /etc/.pihole/ && git describe --tags --abbrev=0' );
2016-12-05 11:12:01 +00:00
// Don't show the URI if it is the root directory
if ( $uri == " / " )
{
$uri = " " ;
}
2016-12-04 21:17:08 +00:00
?>
<! DOCTYPE html >
< head >
< meta charset = 'UTF-8' />
< title > Website Blocked </ title >
2016-12-05 09:51:41 +00:00
< link rel = 'stylesheet' href = 'http://<?php echo $_SERVER[' SERVER_ADDR ']; ?>/admin/blockingpage.css' />
2016-12-04 21:20:51 +00:00
< link rel = 'shortcut icon' href = 'http://<?php echo $_SERVER[' SERVER_ADDR ']; ?>/admin/img/favicon.png' type = 'image/png' />
2016-12-04 21:17:08 +00:00
< meta name = 'viewport' content = 'width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=no' />
< meta name = 'robots' content = 'noindex,nofollow' />
2016-08-20 00:45:17 +00:00
</ head >
2016-12-06 13:05:02 +00:00
< body id = " body " >
2016-12-04 21:17:08 +00:00
< header >
< h1 >< a href = '/' > Website Blocked </ a ></ h1 >
</ header >
< main >
< div > Access to the following site has been blocked :< br />
< span class = 'pre msg' >< ? php echo $serverName . $uri ; ?> </span></div>
2016-12-15 09:38:24 +00:00
< div > If you have an ongoing use for this website , please ask the owner of the Pi - hole in your network to have it whitelisted .</ div >
2016-12-05 11:12:01 +00:00
< input id = " domain " type = " hidden " value = " <?php echo $serverName ; ?> " >
< input id = " quiet " type = " hidden " value = " yes " >
< 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 ) :
2016-12-05 13:39:07 +00:00
< 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 >
2016-12-04 21:17:08 +00:00
</ main >
< footer > Generated < ? php echo date ( 'D g:i A, M d' ); ?> by Pi-hole <?php echo $piHoleVersion; ?></footer>
2016-12-05 11:12:01 +00:00
< script src = " http://<?php echo $_SERVER['SERVER_ADDR'] ; ?>/admin/js/other/jquery.min.js " ></ script >
< script src = " http://<?php echo $_SERVER['SERVER_ADDR'] ; ?>/admin/js/pihole/queryads.js " ></ script >
< script >
2016-12-06 13:05:02 +00:00
function inIframe () {
try {
return window . self !== window . top ;
} catch ( e ) {
return true ;
}
}
// Try to detect if page is loaded within iframe
if ( inIframe ())
{
2016-12-06 13:08:45 +00:00
// Within iframe
// hide content of page
2016-12-06 13:05:02 +00:00
$ ( '#body' ) . hide ();
2016-12-06 13:08:45 +00:00
// remove background
2016-12-06 13:05:02 +00:00
document . body . style . backgroundImage = " none " ;
}
2016-12-06 13:05:48 +00:00
else
{
2016-12-06 13:08:45 +00:00
// Query adlists
2016-12-06 13:05:48 +00:00
$ ( " #btnSearch " ) . click ();
}
2016-12-06 13:05:02 +00:00
// }
2016-12-05 11:12:01 +00:00
</ script >
2015-06-07 04:28:41 +00:00
</ body >
2016-08-20 00:45:17 +00:00
</ html >