Skip to content

Commit

Permalink
Merge pull request #343 from pi-hole/tweak/multiadd
Browse files Browse the repository at this point in the history
Add multiple domains separated by whitespace
  • Loading branch information
AzureMarker authored Jan 8, 2017
2 parents 0d82d03 + b6695f9 commit b2279ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion list.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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.
Failure! Something went wrong.<br/><span id="err"></span>
</div>

<!-- Domain List -->
Expand Down
6 changes: 4 additions & 2 deletions scripts/pi-hole/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function add() {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var alFailure = $("#alFailure");
var err = $("#err");
alInfo.show();
alSuccess.hide();
alFailure.hide();
Expand All @@ -85,10 +86,11 @@ function add() {
if (response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0) {
alFailure.show();
alFailure.delay(1000).fadeOut(2000, function() {
err.html(response);
alFailure.delay(4000).fadeOut(2000, function() {
alFailure.hide();
});
alInfo.delay(1000).fadeOut(2000, function() {
alInfo.delay(4000).fadeOut(2000, function() {
alInfo.hide();
});
} else {
Expand Down
10 changes: 7 additions & 3 deletions scripts/pi-hole/php/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ function hash_equals($known_string, $user_string) {

function check_domain() {
if(isset($_POST['domain'])){
$validDomain = is_valid_domain_name($_POST['domain']);
if(!$validDomain){
log_and_die(htmlspecialchars($_POST['domain']. ' is not a valid domain'));
$domains = explode(" ",$_POST['domain']);
foreach($domains as $domain)
{
$validDomain = is_valid_domain_name($domain);
if(!$validDomain){
log_and_die(htmlspecialchars($domain. ' is not a valid domain'));
}
}
}
}
Expand Down

0 comments on commit b2279ad

Please sign in to comment.