Merge branch 'release/v5.0' into new/CNAME_inspection_details

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-02-04 07:47:45 +01:00
13 changed files with 288 additions and 351 deletions
+1
View File
@@ -72,6 +72,7 @@
</div>
</div>
<script src="scripts/pi-hole/js/groups-common.js"></script>
<script src="scripts/pi-hole/js/groups-adlists.js"></script>
<?php
+1
View File
@@ -72,6 +72,7 @@
</div>
</div>
<script src="scripts/pi-hole/js/groups-common.js"></script>
<script src="scripts/pi-hole/js/groups-clients.js"></script>
<?php
+1
View File
@@ -82,6 +82,7 @@
</div>
</div>
<script src="scripts/pi-hole/js/groups-common.js"></script>
<script src="scripts/pi-hole/js/groups-domains.js"></script>
<?php
+1
View File
@@ -71,6 +71,7 @@
</div>
</div>
<script src="scripts/pi-hole/js/groups-common.js"></script>
<script src="scripts/pi-hole/js/groups.js"></script>
<?php
+37 -80
View File
@@ -5,71 +5,11 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global moment:false */
/* global utils:false */
var table;
var groups = [];
var token = $("#token").html();
var info = null;
function showAlert(type, icon, title, message) {
var opts = {};
title = "&nbsp;<strong>" + title + "</strong><br>";
switch (type) {
case "info":
opts = {
type: "info",
icon: "glyphicon glyphicon-time",
title: title,
message: message
};
info = $.notify(opts);
break;
case "success":
opts = {
type: "success",
icon: icon,
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "warning":
opts = {
type: "warning",
icon: "glyphicon glyphicon-warning-sign",
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "error":
opts = {
type: "danger",
icon: "glyphicon glyphicon-remove",
title: "&nbsp;<strong>Error, something went wrong!</strong><br>",
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
default:
}
}
function get_groups() {
$.post(
@@ -83,10 +23,6 @@ function get_groups() {
);
}
function datetime(date) {
return moment.unix(Math.floor(date)).format("Y-MM-DD HH:mm:ss z");
}
$(document).ready(function() {
$("#btnAdd").on("click", addAdlist);
@@ -120,9 +56,9 @@ function initTable() {
rowCallback: function(row, data) {
var tooltip =
"Added: " +
datetime(data.date_added) +
utils.datetime(data.date_added) +
"\nLast modified: " +
datetime(data.date_modified) +
utils.datetime(data.date_modified) +
"\nDatabase ID: " +
data.id;
$("td:eq(0)", row).html(
@@ -234,10 +170,11 @@ function addAdlist() {
var address = $("#new_address").val();
var comment = $("#new_comment").val();
showAlert("info", "", "Adding adlist...", address);
utils.disableAll();
utils.showAlert("info", "", "Adding adlist...", address);
if (address.length === 0) {
showAlert("warning", "", "Warning", "Please specify an adlist address");
utils.showAlert("warning", "", "Warning", "Please specify an adlist address");
return;
}
@@ -252,17 +189,24 @@ function addAdlist() {
token: token
},
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-plus", "Successfully added adlist", address);
utils.showAlert(
"success",
"glyphicon glyphicon-plus",
"Successfully added adlist",
address
);
$("#new_address").val("");
$("#new_comment").val("");
table.ajax.reload();
} else {
showAlert("error", "", "Error while adding new adlist: ", response.message);
utils.showAlert("error", "", "Error while adding new adlist: ", response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while adding new adlist: ", jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while adding new adlist: ", jqXHR.responseText);
console.log(exception);
}
});
@@ -293,7 +237,8 @@ function editAdlist() {
not_done = "editing groups of";
}
showAlert("info", "", "Editing adlist...", address);
utils.disableAll();
utils.showAlert("info", "", "Editing adlist...", address);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
@@ -308,15 +253,16 @@ function editAdlist() {
token: token
},
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert(
utils.showAlert(
"success",
"glyphicon glyphicon-pencil",
"Successfully " + done + " adlist ",
address
);
} else {
showAlert(
utils.showAlert(
"error",
"",
"Error while " + not_done + " adlist with ID " + id,
@@ -325,7 +271,8 @@ function editAdlist() {
}
},
error: function(jqXHR, exception) {
showAlert(
utils.enableAll();
utils.showAlert(
"error",
"",
"Error while " + not_done + " adlist with ID " + id,
@@ -341,23 +288,33 @@ function deleteAdlist() {
var tr = $(this).closest("tr");
var address = tr.find("#address").text();
showAlert("info", "", "Deleting adlist...", address);
utils.disableAll();
utils.showAlert("info", "", "Deleting adlist...", address);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
dataType: "json",
data: { action: "delete_adlist", id: id, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-trash", "Successfully deleted adlist ", address);
utils.showAlert(
"success",
"glyphicon glyphicon-trash",
"Successfully deleted adlist ",
address
);
table
.row(tr)
.remove()
.draw(false);
} else showAlert("error", "", "Error while deleting adlist with ID " + id, response.message);
} else {
utils.showAlert("error", "", "Error while deleting adlist with ID " + id, response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while deleting adlist with ID " + id, jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while deleting adlist with ID " + id, jqXHR.responseText);
console.log(exception);
}
});
+34 -73
View File
@@ -5,69 +5,11 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global utils:false */
var table;
var groups = [];
var token = $("#token").html();
var info = null;
function showAlert(type, icon, title, message) {
var opts = {};
title = "&nbsp;<strong>" + title + "</strong><br>";
switch (type) {
case "info":
opts = {
type: "info",
icon: "glyphicon glyphicon-time",
title: title,
message: message
};
info = $.notify(opts);
break;
case "success":
opts = {
type: "success",
icon: icon,
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "warning":
opts = {
type: "warning",
icon: "glyphicon glyphicon-warning-sign",
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "error":
opts = {
type: "danger",
icon: "glyphicon glyphicon-remove",
title: "&nbsp;<strong>Error, something went wrong!</strong><br>",
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
default:
}
}
function reload_client_suggestions() {
$.post(
@@ -242,10 +184,12 @@ function addClient() {
ip = $("#ip-custom").val();
}
showAlert("info", "", "Adding client...", ip);
utils.disableAll();
utils.showAlert("info", "", "Adding client...", ip);
if (ip.length === 0) {
showAlert("warning", "", "Warning", "Please specify a client IP address");
utils.enableAll();
utils.showAlert("warning", "", "Warning", "Please specify a client IP address");
return;
}
@@ -255,16 +199,18 @@ function addClient() {
dataType: "json",
data: { action: "add_client", ip: ip, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-plus", "Successfully added client", ip);
utils.showAlert("success", "glyphicon glyphicon-plus", "Successfully added client", ip);
reload_client_suggestions();
table.ajax.reload();
} else {
showAlert("error", "", "Error while adding new client", response.message);
utils.showAlert("error", "", "Error while adding new client", response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while adding new client", jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while adding new client", jqXHR.responseText);
console.log(exception);
}
});
@@ -290,26 +236,33 @@ function editClient() {
ip_name += " (" + name + ")";
}
showAlert("info", "", "Editing client...", ip_name);
utils.disableAll();
utils.showAlert("info", "", "Editing client...", ip_name);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
dataType: "json",
data: { action: "edit_client", id: id, groups: groups, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert(
utils.showAlert(
"success",
"glyphicon glyphicon-plus",
"Successfully " + done + " client",
ip_name
);
} else {
showAlert("error", "Error while " + not_done + " client with ID " + id, response.message);
utils.showAlert(
"error",
"Error while " + not_done + " client with ID " + id,
response.message
);
}
},
error: function(jqXHR, exception) {
showAlert(
utils.enableAll();
utils.showAlert(
"error",
"",
"Error while " + not_done + " client with ID " + id,
@@ -331,26 +284,34 @@ function deleteClient() {
ip_name += " (" + name + ")";
}
showAlert("info", "", "Deleting client...", ip_name);
utils.disableAll();
utils.showAlert("info", "", "Deleting client...", ip_name);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
dataType: "json",
data: { action: "delete_client", id: id, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-trash", "Successfully deleted client ", ip_name);
utils.showAlert(
"success",
"glyphicon glyphicon-trash",
"Successfully deleted client ",
ip_name
);
table
.row(tr)
.remove()
.draw(false);
reload_client_suggestions();
} else {
showAlert("error", "", "Error while deleting client with ID " + id, response.message);
utils.showAlert("error", "", "Error while deleting client with ID " + id, response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while deleting client with ID " + id, jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while deleting client with ID " + id, jqXHR.responseText);
console.log(exception);
}
});
+95
View File
@@ -0,0 +1,95 @@
/* Pi-hole: A black hole for Internet advertisements
* (c) 2020 Pi-hole, LLC (https://pi-hole.net)
* 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. */
/* global moment:false */
var info = null;
function showAlert(type, icon, title, message) {
var opts = {};
title = "&nbsp;<strong>" + title + "</strong><br>";
switch (type) {
case "info":
opts = {
type: "info",
icon: "glyphicon glyphicon-time",
title: title,
message: message
};
info = $.notify(opts);
break;
case "success":
opts = {
type: "success",
icon: icon,
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "warning":
opts = {
type: "warning",
icon: "glyphicon glyphicon-warning-sign",
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "error":
opts = {
type: "danger",
icon: "glyphicon glyphicon-remove",
title: "&nbsp;<strong>Error, something went wrong!</strong><br>",
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
default:
}
}
function datetime(date) {
return moment.unix(Math.floor(date)).format("Y-MM-DD HH:mm:ss z");
}
function disableAll() {
$("input").attr("disabled", true);
$("select").attr("disabled", true);
$("button").attr("disabled", true);
$("textarea").attr("disabled", true);
}
function enableAll() {
$("input").attr("disabled", false);
$("select").attr("disabled", false);
$("button").attr("disabled", false);
$("textarea").attr("disabled", false);
}
window.utils = (function() {
return {
showAlert: showAlert,
datetime: datetime,
disableAll: disableAll,
enableAll: enableAll
};
})();
+33 -80
View File
@@ -5,73 +5,13 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global moment:false */
/* global utils:false */
var table;
var groups = [];
var token = $("#token").html();
var info = null;
var GETDict = {};
function showAlert(type, icon, title, message) {
var opts = {};
title = "&nbsp;<strong>" + title + "</strong><br>";
switch (type) {
case "info":
opts = {
type: "info",
icon: "glyphicon glyphicon-time",
title: title,
message: message
};
info = $.notify(opts);
break;
case "success":
opts = {
type: "success",
icon: icon,
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "warning":
opts = {
type: "warning",
icon: "glyphicon glyphicon-warning-sign",
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "error":
opts = {
type: "danger",
icon: "glyphicon glyphicon-remove",
title: "&nbsp;<strong>Error, something went wrong!</strong><br>",
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
default:
}
}
function get_groups() {
$.post(
"scripts/pi-hole/php/groups.php",
@@ -84,10 +24,6 @@ function get_groups() {
);
}
function datetime(date) {
return moment.unix(Math.floor(date)).format("Y-MM-DD HH:mm:ss z");
}
$(document).ready(function() {
window.location.search
.substr(1)
@@ -129,9 +65,9 @@ function initTable() {
rowCallback: function(row, data) {
var tooltip =
"Added: " +
datetime(data.date_added) +
utils.datetime(data.date_added) +
"\nLast modified: " +
datetime(data.date_modified) +
utils.datetime(data.date_modified) +
"\nDatabase ID: " +
data.id;
$("td:eq(0)", row).html(
@@ -279,10 +215,12 @@ function addDomain() {
var type = $("#new_type").val();
var comment = $("#new_comment").val();
showAlert("info", "", "Adding domain...", domain);
utils.disableAll();
utils.showAlert("info", "", "Adding domain...", domain);
if (domain.length === 0) {
showAlert("warning", "", "Warning", "Please specify a domain");
utils.enableAll();
utils.showAlert("warning", "", "Warning", "Please specify a domain");
return;
}
@@ -298,15 +236,17 @@ function addDomain() {
token: token
},
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-plus", "Successfully added domain", domain);
utils.showAlert("success", "glyphicon glyphicon-plus", "Successfully added domain", domain);
$("#new_domain").val("");
$("#new_comment").val("");
table.ajax.reload();
} else showAlert("error", "", "Error while adding new domain", response.message);
} else utils.showAlert("error", "", "Error while adding new domain", response.message);
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while adding new domain", jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while adding new domain", jqXHR.responseText);
console.log(exception);
}
});
@@ -344,7 +284,8 @@ function editDomain() {
not_done = "editing groups of";
}
showAlert("info", "", "Editing domain...", name);
utils.disableAll();
utils.showAlert("info", "", "Editing domain...", name);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
@@ -359,15 +300,16 @@ function editDomain() {
token: token
},
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert(
utils.showAlert(
"success",
"glyphicon glyphicon-pencil",
"Successfully " + done + " domain",
domain
);
} else
showAlert(
utils.showAlert(
"error",
"",
"Error while " + not_done + " domain with ID " + id,
@@ -375,7 +317,8 @@ function editDomain() {
);
},
error: function(jqXHR, exception) {
showAlert(
utils.enableAll();
utils.showAlert(
"error",
"",
"Error while " + not_done + " domain with ID " + id,
@@ -391,23 +334,33 @@ function deleteDomain() {
var tr = $(this).closest("tr");
var domain = tr.find("#domain").text();
showAlert("info", "", "Deleting domain...", domain);
utils.disableAll();
utils.showAlert("info", "", "Deleting domain...", domain);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
dataType: "json",
data: { action: "delete_domain", id: id, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-trash", "Successfully deleted domain", domain);
utils.showAlert(
"success",
"glyphicon glyphicon-trash",
"Successfully deleted domain",
domain
);
table
.row(tr)
.remove()
.draw(false);
} else showAlert("error", "", "Error while deleting domain with ID " + id, response.message);
} else {
utils.showAlert("error", "", "Error while deleting domain with ID " + id, response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while deleting domain with ID " + id, jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while deleting domain with ID " + id, jqXHR.responseText);
console.log(exception);
}
});
+35 -80
View File
@@ -5,74 +5,10 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global moment:false */
/* global utils:false */
var table;
var token = $("#token").html();
var info = null;
function showAlert(type, icon, title, message) {
var opts = {};
title = "&nbsp;<strong>" + title + "</strong><br>";
switch (type) {
case "info":
opts = {
type: "info",
icon: "glyphicon glyphicon-time",
title: title,
message: message
};
info = $.notify(opts);
break;
case "success":
opts = {
type: "success",
icon: icon,
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "warning":
opts = {
type: "warning",
icon: "glyphicon glyphicon-warning-sign",
title: title,
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
case "error":
opts = {
type: "danger",
icon: "glyphicon glyphicon-remove",
title: "&nbsp;<strong>Error, something went wrong!</strong><br>",
message: message
};
if (info) {
info.update(opts);
} else {
$.notify(opts);
}
break;
default:
}
}
function datetime(date) {
return moment.unix(Math.floor(date)).format("Y-MM-DD HH:mm:ss z");
}
$(document).ready(function() {
$("#btnAdd").on("click", addGroup);
@@ -97,9 +33,9 @@ $(document).ready(function() {
rowCallback: function(row, data) {
var tooltip =
"Added: " +
datetime(data.date_added) +
utils.datetime(data.date_added) +
"\nLast modified: " +
datetime(data.date_modified) +
utils.datetime(data.date_modified) +
"\nDatabase ID: " +
data.id;
$("td:eq(0)", row).html(
@@ -195,10 +131,11 @@ function addGroup() {
var name = $("#new_name").val();
var desc = $("#new_desc").val();
showAlert("info", "", "Adding group...", name);
utils.disableAll();
utils.showAlert("info", "", "Adding group...", name);
if (name.length === 0) {
showAlert("warning", "", "Warning", "Please specify a group name");
utils.showAlert("warning", "", "Warning", "Please specify a group name");
return;
}
@@ -208,17 +145,19 @@ function addGroup() {
dataType: "json",
data: { action: "add_group", name: name, desc: desc, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-plus", "Successfully added group", name);
utils.showAlert("success", "glyphicon glyphicon-plus", "Successfully added group", name);
$("#new_name").val("");
$("#new_desc").val("");
table.ajax.reload();
} else {
showAlert("error", "", "Error while adding new group", response.message);
utils.showAlert("error", "", "Error while adding new group", response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while adding new group", jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while adding new group", jqXHR.responseText);
console.log(exception);
}
});
@@ -248,7 +187,8 @@ function editGroup() {
not_done = "editing description of";
}
showAlert("info", "", "Editing group...", name);
utils.disableAll();
utils.showAlert("info", "", "Editing group...", name);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
@@ -262,10 +202,16 @@ function editGroup() {
token: token
},
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-pencil", "Successfully " + done + " group", name);
utils.showAlert(
"success",
"glyphicon glyphicon-pencil",
"Successfully " + done + " group",
name
);
} else {
showAlert(
utils.showAlert(
"error",
"",
"Error while " + not_done + " group with ID " + id,
@@ -274,7 +220,8 @@ function editGroup() {
}
},
error: function(jqXHR, exception) {
showAlert(
utils.enableAll();
utils.showAlert(
"error",
"",
"Error while " + not_done + " group with ID " + id,
@@ -290,25 +237,33 @@ function deleteGroup() {
var tr = $(this).closest("tr");
var name = tr.find("#name").val();
showAlert("info", "", "Deleting group...", name);
utils.disableAll();
utils.showAlert("info", "", "Deleting group...", name);
$.ajax({
url: "scripts/pi-hole/php/groups.php",
method: "post",
dataType: "json",
data: { action: "delete_group", id: id, token: token },
success: function(response) {
utils.enableAll();
if (response.success) {
showAlert("success", "glyphicon glyphicon-trash", "Successfully deleted group ", name);
utils.showAlert(
"success",
"glyphicon glyphicon-trash",
"Successfully deleted group ",
name
);
table
.row(tr)
.remove()
.draw(false);
} else {
showAlert("error", "", "Error while deleting group with ID " + id, response.message);
utils.showAlert("error", "", "Error while deleting group with ID " + id, response.message);
}
},
error: function(jqXHR, exception) {
showAlert("error", "", "Error while deleting group with ID " + id, jqXHR.responseText);
utils.enableAll();
utils.showAlert("error", "", "Error while deleting group with ID " + id, jqXHR.responseText);
console.log(exception);
}
});
+6
View File
@@ -14,6 +14,12 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
}
var i, item;
// Use the first IP in case there is a list of IPs
// for a given device
if (Array.isArray(a)) {
a = a[0];
}
var m = a.split("."),
n = a.split(":"),
x = "",
+13 -7
View File
@@ -101,16 +101,22 @@ $(document).ready(function() {
// Set number of queries to localized string (add thousand separators)
$("td:eq(6)", row).html(data.numQueries.toLocaleString());
var ips = data.ip;
var shortips = ips;
if (ips.length > MAXIPDISPLAY) {
shortips = ips.slice(0, MAXIPDISPLAY - 1);
shortips.push("...");
var ips = [];
var maxiter = Math.min(data.ip.length, MAXIPDISPLAY);
for (var index = 0; index < maxiter; index++) {
var ip = data.ip[index];
ips.push('<a href="queries.php?client=' + ip + '">' + ip + "</a>");
}
$("td:eq(0)", row).html(shortips.join("<br>"));
if (data.ip.length > MAXIPDISPLAY) {
// We hit the maximum above, add "..." to symbolize we would
// have more to show here
ips.push("...");
}
$("td:eq(0)", row).html(ips.join("<br>"));
$("td:eq(0)", row).hover(function() {
this.title = ips.join("\n");
this.title = data.ip.join("\n");
});
// MAC + Vendor field if available
+29 -29
View File
@@ -49,7 +49,7 @@ if ($_POST['action'] == 'get_groups') {
}
echo json_encode(array('data' => $data));
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'add_group') {
// Add new group
@@ -72,9 +72,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'edit_group') {
// Edit group identified by ID
@@ -111,9 +111,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'delete_group') {
// Delete group identified by ID
@@ -142,9 +142,9 @@ if ($_POST['action'] == 'get_groups') {
}
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'get_clients') {
// List all available groups
@@ -193,7 +193,7 @@ if ($_POST['action'] == 'get_groups') {
echo json_encode(array('data' => $data));
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'get_unconfigured_clients') {
// List all available clients WITHOUT already configured clients
@@ -227,7 +227,7 @@ if ($_POST['action'] == 'get_groups') {
echo json_encode($ips);
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'add_client') {
// Add new client
@@ -246,9 +246,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'edit_client') {
// Edit client identified by ID
@@ -288,9 +288,9 @@ if ($_POST['action'] == 'get_groups') {
$db->query('COMMIT;');
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'delete_client') {
// Delete client identified by ID
@@ -322,9 +322,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'get_domains') {
// List all available groups
@@ -352,7 +352,7 @@ if ($_POST['action'] == 'get_groups') {
echo json_encode(array('data' => $data));
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'add_domain') {
// Add new domain
@@ -392,9 +392,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'edit_domain') {
// Edit domain identified by ID
@@ -469,9 +469,9 @@ if ($_POST['action'] == 'get_groups') {
$db->query('COMMIT;');
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'delete_domain') {
// Delete domain identified by ID
@@ -503,9 +503,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'get_adlists') {
// List all available groups
@@ -533,7 +533,7 @@ if ($_POST['action'] == 'get_groups') {
echo json_encode(array('data' => $data));
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'add_adlist') {
// Add new adlist
@@ -556,9 +556,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'edit_adlist') {
// Edit adlist identified by ID
@@ -629,9 +629,9 @@ if ($_POST['action'] == 'get_groups') {
$db->query('COMMIT;');
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} elseif ($_POST['action'] == 'delete_adlist') {
// Delete adlist identified by ID
@@ -663,9 +663,9 @@ if ($_POST['action'] == 'get_groups') {
}
$reload = true;
return JSON_success();
JSON_success();
} catch (\Exception $ex) {
return JSON_error($ex->getMessage());
JSON_error($ex->getMessage());
}
} else {
log_and_die('Requested action not supported!');
+2 -2
View File
@@ -35,7 +35,7 @@ function istrue(&$argument) {
// Credit: http://stackoverflow.com/a/4694816/2087442
function validDomain($domain_name)
{
$validChars = preg_match("/^([_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([a-z\d])*)*$/i", $domain_name);
$validChars = preg_match("/^([_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([_a-z\d])*)*$/i", $domain_name);
$lengthCheck = preg_match("/^.{1,253}$/", $domain_name);
$labelLengthCheck = preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name);
return ( $validChars && $lengthCheck && $labelLengthCheck ); //length of each label
@@ -44,7 +44,7 @@ function validDomain($domain_name)
function validDomainWildcard($domain_name)
{
// There has to be either no or at most one "*" at the beginning of a line
$validChars = preg_match("/^((\*.)?[_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([a-z\d])*)*$/i", $domain_name);
$validChars = preg_match("/^((\*.)?[_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([_a-z\d])*)*$/i", $domain_name);
$lengthCheck = preg_match("/^.{1,253}$/", $domain_name);
$labelLengthCheck = preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name);
return ( $validChars && $lengthCheck && $labelLengthCheck ); //length of each label