Skip to content

Commit

Permalink
Merge pull request #440 from pi-hole/AdminLTE-backports
Browse files Browse the repository at this point in the history
Pi-Hole Admin Page v2.5.2
  • Loading branch information
DL6ER authored Mar 14, 2017
2 parents 078cbb1 + 8a4861c commit ca8f440
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
3 changes: 2 additions & 1 deletion list.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function getFullName() {
</span>
</div>
<?php if($list === "white") { ?>
<p>Note that whitelisting domains which are blocked using the wildcard method won't work.</p><?php } ?>
<p>Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.</p>
<?php } ?>

<!-- Alerts -->
<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
Expand Down
3 changes: 0 additions & 3 deletions scripts/pi-hole/php/queryads.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

require "password.php";
if(!$auth) die("Not authorized");

ob_end_flush();
ini_set("output_buffering", "0");
ob_implicit_flush(true);
Expand Down
34 changes: 27 additions & 7 deletions scripts/pi-hole/php/teleporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* Please see LICENSE file for your rights under this license. */

require "password.php";
if(!$auth) die("Not authorized");
if (php_sapi_name() !== "cli") {
if(!$auth) die("Not authorized");
}

require('func.php');
function process_zip($name)
Expand Down Expand Up @@ -36,6 +38,22 @@ function add_to_zip($path,$name)
$zip->addFile($path.$name,$name);
}

function add_dir_to_zip($path)
{
global $zip;
if($dir = opendir($path))
{
while(false !== ($entry = readdir($dir)))
{
if($entry !== "." && $entry !== "..")
{
$zip->addFile($path.$entry,$entry);
}
}
closedir($dir);
}
}

function check_domains($domains)
{
foreach($domains as $domain)
Expand Down Expand Up @@ -67,9 +85,9 @@ function getWildcardListContent() {
return "";
}

if($_POST["action"] == "in")
if(isset($_POST["action"]))
{
if($_FILES["zip_file"]["name"])
if($_FILES["zip_file"]["name"] && $_POST["action"] == "in")
{
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
Expand Down Expand Up @@ -122,12 +140,13 @@ function getWildcardListContent() {
}
else
{
die("No file transmitted.");
die("No file transmitted or parameter error.");
}
}
else
{
$archive_file_name = "/var/www/html/pi-hole-teleporter_".microtime(true).".zip";
$filename = "pi-hole-teleporter_".date("Y-m-d_h-i-s").".zip";
$archive_file_name = "/var/www/html/".$filename;
$zip = new ZipArchive();
touch($archive_file_name);
$res = $zip->open($archive_file_name, ZipArchive::CREATE | ZipArchive::OVERWRITE);
Expand All @@ -140,17 +159,18 @@ function getWildcardListContent() {
add_to_zip("/etc/pihole/","blacklist.txt");
add_to_zip("/etc/pihole/","adlists.list");
add_to_zip("/etc/pihole/","setupVars.conf");
add_dir_to_zip("/etc/dnsmasq.d/");

$zip->addFromString("wildcardblocking.txt", getWildcardListContent());
$zip->close();

header("Content-type: application/zip");
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=pi-hole-teleporter.zip");
header("Content-Disposition: attachment; filename=".$filename);
header("Content-length: " . filesize($archive_file_name));
header("Pragma: no-cache");
header("Expires: 0");
ob_end_clean();
if(ob_get_length() > 0) ob_end_clean();
readfile($archive_file_name);
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ function convertseconds($argument) {
$DNSinterface = "local";
}
} else {
$DNSinterface = "local";
$DNSinterface = "single";
}
?>
<div class="box box-warning">
Expand Down

0 comments on commit ca8f440

Please sign in to comment.