Skip to content

Commit

Permalink
Merge pull request pi-hole#872 from pi-hole/release/v4.1
Browse files Browse the repository at this point in the history
Update development with final v4.1 changes
  • Loading branch information
AzureMarker authored Dec 10, 2018
2 parents c4b9018 + 185a5c7 commit 9fa4cc6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 20 deletions.
6 changes: 5 additions & 1 deletion list.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ function getFullName() {
</div>
<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden="true">
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Failure! Something went wrong.<br/><span id="err"></span>
Failure! Something went wrong, see output below:<br/><br/><pre><span id="err"></span></pre>
</div>
<div id="alWarning" class="alert alert-warning alert-dismissible fade in" role="alert" hidden="true">
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
At least one domain was already present, see output below:<br/><br/><pre><span id="warn"></span></pre>
</div>


Expand Down
18 changes: 15 additions & 3 deletions scripts/pi-hole/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,35 @@ function add(arg) {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var alFailure = $("#alFailure");
var alWarning = $("#alWarning");
var err = $("#err");
var warn = $("#warn");
alInfo.show();
alSuccess.hide();
alFailure.hide();
alWarning.hide();
$.ajax({
url: "scripts/pi-hole/php/add.php",
method: "post",
data: {"domain":domain.val().trim(), "list":locallistType, "token":token},
success: function(response) {
if (!wild && response.indexOf("] Pi-hole blocking is ") === -1 ||
if (!wild && response.indexOf(" already exists in ") !== -1) {
alWarning.show();
warn.html(response);
alWarning.delay(8000).fadeOut(2000, function() {
alWarning.hide();
});
alInfo.delay(8000).fadeOut(2000, function() {
alInfo.hide();
});
} else if (!wild && response.indexOf("] Pi-hole blocking is ") === -1 ||
wild && response.length > 1) {
alFailure.show();
err.html(response);
alFailure.delay(4000).fadeOut(2000, function() {
alFailure.delay(8000).fadeOut(2000, function() {
alFailure.hide();
});
alInfo.delay(4000).fadeOut(2000, function() {
alInfo.delay(8000).fadeOut(2000, function() {
alInfo.hide();
});
} else {
Expand Down
16 changes: 7 additions & 9 deletions scripts/pi-hole/php/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* Network-wide ad blocking via your own hardware.
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */ ?>

<?php
* Please see LICENSE file for your rights under this license. */
require_once('auth.php');

$type = $_POST['list'];
Expand All @@ -20,20 +18,20 @@
switch($type) {
case "white":
if(!isset($_POST["auditlog"]))
echo exec("sudo pihole -w -q ${_POST['domain']}");
echo shell_exec("sudo pihole -w ${_POST['domain']}");
else
{
echo exec("sudo pihole -w -q -n ${_POST['domain']}");
echo exec("sudo pihole -a audit ${_POST['domain']}");
echo shell_exec("sudo pihole -w -n ${_POST['domain']}");
echo shell_exec("sudo pihole -a audit ${_POST['domain']}");
}
break;
case "black":
if(!isset($_POST["auditlog"]))
echo exec("sudo pihole -b -q ${_POST['domain']}");
echo shell_exec("sudo pihole -b ${_POST['domain']}");
else
{
echo exec("sudo pihole -b -q -n ${_POST['domain']}");
echo exec("sudo pihole -a audit ${_POST['domain']}");
echo shell_exec("sudo pihole -b -n ${_POST['domain']}");
echo shell_exec("sudo pihole -a audit ${_POST['domain']}");
}
break;
case "wild":
Expand Down
3 changes: 2 additions & 1 deletion scripts/pi-hole/php/queryads.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function echoEvent($datatext) {
ini_set("pcre.recursion_limit", 1500);
function is_valid_domain_name($domain_name)
{
return (preg_match("/^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/i", $domain_name) // Valid chars check
return ($domain_name[0] !== '-' // Don't allow domains to appear as command line options
&& preg_match("/^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/i", $domain_name) // Valid chars check
&& preg_match("/^.{1,253}$/", $domain_name) // Overall length check
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name) ); // Length of each label
}
Expand Down
27 changes: 24 additions & 3 deletions scripts/pi-hole/php/savesettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,13 @@ function readAdlists()
{
$adminemail = 'noadminemail';
}
elseif(!filter_var($adminemail, FILTER_VALIDATE_EMAIL))
elseif(!filter_var($adminemail, FILTER_VALIDATE_EMAIL) || strpos($adminemail, "'") !== false)
{
$error .= "Administrator email address (".htmlspecialchars($adminemail).") is invalid!<br>";
}
else
{
exec('sudo pihole -a -e '.$adminemail);
exec('sudo pihole -a -e \''.$adminemail.'\'');
}
if(isset($_POST["boxedlayout"]))
{
Expand Down Expand Up @@ -696,8 +696,29 @@ function readAdlists()
$level = intval($_POST["privacylevel"]);
if($level >= 0 && $level <= 4)
{
// Check if privacylevel is already set
if (isset($piholeFTLConf["PRIVACYLEVEL"])) {
$privacylevel = intval($piholeFTLConf["PRIVACYLEVEL"]);
} else {
$privacylevel = 0;
}

// Store privacy level
exec("sudo pihole -a privacylevel ".$level);
$success .= "The privacy level has been updated";

if($privacylevel > $level)
{
exec("sudo pihole -a restartdns");
$success .= "The privacy level has been decreased and the DNS resolver has been restarted";
}
elseif($privacylevel < $level)
{
$success .= "The privacy level has been increased";
}
else
{
$success .= "The privacy level has been not been changed";
}
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ function convertseconds($argument)
<div class="radio">
<label><input type="radio" name="privacylevel" value="4"
<?php if ($privacylevel === 4){ ?>checked<?php }
?>>No Statistics mode: This disables all statistics processing. Even the query counters will not be available.<br>Additionally, you can disable logging to the file <code>/var/log/pihole.log</code> using <code>sudo pihole logging off</code>.</label>
?>>No Statistics mode: This disables all statistics processing. Even the query counters will not be available.<br><strong>Note that regex blocking is not available when query analyzing is disabled.</strong><br>Additionally, you can disable logging to the file <code>/var/log/pihole.log</code> using <code>sudo pihole logging off</code>.</label>
</div>
</div>
<p>The privacy level may be changed at any time without having to restart the DNS resolver. However, note that queries with (partially) hidden details cannot be disclosed with a subsequent reduction of the privacy level.</p>
<p>The privacy level may be increased at any time without having to restart the DNS resolver. However, note that the DNS resolver needs to be restarted when lowering the privacy level. This restarting is automatically done when saving.</p>
<?php if($privacylevel > 0 && $piHoleLogging){ ?>
<p class="lookatme">Warning: Pi-hole's query logging is activated. Although the dashboard will hide the requested details, all queries are still fully logged to the pihole.log file.</p>
<?php } ?>
Expand Down Expand Up @@ -1329,7 +1329,7 @@ function get_FTL_data($arg)
</div>
<p class="hidden-md hidden-lg"></p>
<div class="col-md-4">
<button type="button" class="btn btn-warning confirm-restartdns form-control">Restart dnsmasq</button>
<button type="button" class="btn btn-warning confirm-restartdns form-control">Restart DNS resolver</button>
</div>
</div>
<br/>
Expand Down

0 comments on commit 9fa4cc6

Please sign in to comment.