diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index e3f6a971..e88df5c0 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -18,6 +18,50 @@ $(function () {
$('input[name="AddIP"]').val(ip);
$('input[name="AddMAC"]').val(mac);
});
+
+ // prepare Teleporter Modal & iframe for operation
+ $("#teleporterModal").on("show.bs.modal", function () {
+ $('iframe[name="teleporter_iframe"]').removeAttr("style").contents().find("body").html("");
+ $(this).find("button").prop("disabled", true);
+ $(this).find(".overlay").show();
+ });
+
+ // set Teleporter iframe's font, enable Modal's button(s), ...
+ $('iframe[name="teleporter_iframe"]').on("load", function () {
+ var font = {
+ "font-family": $("pre").css("font-family"),
+ "font-size": $("pre").css("font-size")
+ };
+ var contents = $(this).contents();
+ contents.find("body").css(font);
+ $("#teleporterModal").find(".overlay").hide();
+ var BtnEls = $(this).parents(".modal-content").find("button").prop("disabled", false);
+
+ // force user to reload the page if necessary
+ var reloadEl = contents.find("span[data-forcereload]");
+ if (reloadEl.length > 0) {
+ var msg = "The page must now be reloaded to display the imported entries";
+ reloadEl.append(msg);
+ BtnEls.toggleClass("hidden")
+ .not(".hidden")
+ .on("click", function () {
+ // window.location.href avoids a browser warning for resending form data
+ window.location = window.location.href;
+ });
+ }
+
+ // expand iframe's height
+ var contentHeight = contents.find("html").height();
+ if (contentHeight > $(this).height()) {
+ $(this).height(contentHeight);
+ }
+ });
+
+ // display selected import file on button's adjacent textfield
+ $("#zip_file").change(function () {
+ var fileName = $(this)[0].files.length === 1 ? $(this)[0].files[0].name : "";
+ $("#zip_filename").val(fileName);
+ });
});
$(".confirm-poweroff").confirm({
text: "Are you sure you want to send a poweroff command to your Pi-hole?",
@@ -258,10 +302,6 @@ $(function () {
$(".nav-tabs a").on("shown.bs.tab", function (e) {
var tab = e.target.hash.substring(1);
window.history.pushState("", "", "?tab=" + tab);
- if (tab === "piholedhcp") {
- window.location.reload();
- }
-
window.scrollTo(0, 0);
});
diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php
index 123c3f0a..9dbc350e 100644
--- a/scripts/pi-hole/php/teleporter.php
+++ b/scripts/pi-hole/php/teleporter.php
@@ -320,6 +320,15 @@ function process_file($contents)
return $domains;
}
+function noun($num)
+{
+ if($num === 1)
+ {
+ return " entry";
+ }
+ return " entries";
+}
+
if(isset($_POST["action"]))
{
if($_FILES["zip_file"]["name"] && $_POST["action"] == "in")
@@ -352,6 +361,7 @@ if(isset($_POST["action"]))
$archive = new PharData($fullfilename);
$importedsomething = false;
+ $reloadsettingspage = false;
$flushtables = isset($_POST["flushtables"]);
@@ -360,21 +370,21 @@ if(isset($_POST["action"]))
if(isset($_POST["blacklist"]) && $file->getFilename() === "blacklist.txt")
{
$num = archive_insert_into_table($file, "blacklist", $flushtables);
- echo "Processed blacklist (exact) (".$num." entries)
\n";
+ echo "Processed blacklist (exact) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["whitelist"]) && $file->getFilename() === "whitelist.txt")
{
$num = archive_insert_into_table($file, "whitelist", $flushtables);
- echo "Processed whitelist (exact) (".$num." entries)
\n";
+ echo "Processed whitelist (exact) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["regexlist"]) && $file->getFilename() === "regex.list")
{
$num = archive_insert_into_table($file, "regex_blacklist", $flushtables);
- echo "Processed blacklist (regex) (".$num." entries)
\n";
+ echo "Processed blacklist (regex) (".$num.noun($num).")
\n";
$importedsomething = true;
}
@@ -382,63 +392,63 @@ if(isset($_POST["action"]))
if(isset($_POST["regexlist"]) && $file->getFilename() === "wildcardblocking.txt")
{
$num = archive_insert_into_table($file, "regex_blacklist", $flushtables, true);
- echo "Processed blacklist (regex, wildcard style) (".$num." entries)
\n";
+ echo "Processed blacklist (regex, wildcard style) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["auditlog"]) && $file->getFilename() === "auditlog.list")
{
$num = archive_insert_into_table($file, "domain_audit", $flushtables);
- echo "Processed audit log (".$num." entries)
\n";
+ echo "Processed audit log (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["adlist"]) && $file->getFilename() === "adlists.list")
{
$num = archive_insert_into_table($file, "adlist", $flushtables);
- echo "Processed adlists (".$num." entries)
\n";
+ echo "Processed adlists (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["blacklist"]) && $file->getFilename() === "blacklist.exact.json")
{
$num = archive_restore_table($file, "blacklist", $flushtables);
- echo "Processed blacklist (exact) (".$num." entries)
\n";
+ echo "Processed blacklist (exact) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["regexlist"]) && $file->getFilename() === "blacklist.regex.json")
{
$num = archive_restore_table($file, "regex_blacklist", $flushtables);
- echo "Processed blacklist (regex) (".$num." entries)
\n";
+ echo "Processed blacklist (regex) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["whitelist"]) && $file->getFilename() === "whitelist.exact.json")
{
$num = archive_restore_table($file, "whitelist", $flushtables);
- echo "Processed whitelist (exact) (".$num." entries)
\n";
+ echo "Processed whitelist (exact) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["regex_whitelist"]) && $file->getFilename() === "whitelist.regex.json")
{
$num = archive_restore_table($file, "regex_whitelist", $flushtables);
- echo "Processed whitelist (regex) (".$num." entries)
\n";
+ echo "Processed whitelist (regex) (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["adlist"]) && $file->getFilename() === "adlist.json")
{
$num = archive_restore_table($file, "adlist", $flushtables);
- echo "Processed adlist (".$num." entries)
\n";
+ echo "Processed adlist (".$num.noun($num).")
\n";
$importedsomething = true;
}
if(isset($_POST["auditlog"]) && $file->getFilename() === "domain_audit.json")
{
$num = archive_restore_table($file, "domain_audit", $flushtables);
- echo "Processed domain_audit (".$num." entries)
\n";
+ echo "Processed domain_audit (".$num.noun($num).")
\n";
$importedsomething = true;
}
@@ -498,9 +508,10 @@ if(isset($_POST["action"]))
}
readStaticLeasesFile();
- echo "Processed static DHCP leases (".$num." entries)
\n";
+ echo "Processed static DHCP leases (".$num.noun($num).")
\n";
if($num > 0) {
$importedsomething = true;
+ $reloadsettingspage = true;
}
}
@@ -560,6 +571,10 @@ if(isset($_POST["action"]))
unlink($fullfilename);
echo "OK";
+ if($reloadsettingspage)
+ {
+ echo "
\n";
+ }
}
else
{
diff --git a/settings.php b/settings.php
index 4402e073..17ce96c3 100644
--- a/settings.php
+++ b/settings.php
@@ -1250,7 +1250,7 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "dns", "piho