mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Merge branch 'devel' into new/OTHER_types
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -405,4 +405,14 @@ function returnError($message = "", $json = true)
|
||||
}
|
||||
}
|
||||
|
||||
function getQueryTypeStr($querytype)
|
||||
{
|
||||
$qtypes = ["A (IPv4)", "AAAA (IPv6)", "ANY", "SRV", "SOA", "PTR", "TXT", "NAPTR", "MX", "DS", "RRSIG", "DNSKEY", "NS", "OTHER", "SVCB", "HTTPS"];
|
||||
$qtype = intval($querytype);
|
||||
if($qtype > 0 && $qtype <= count($qtypes))
|
||||
return $qtypes[$qtype-1];
|
||||
else
|
||||
return "TYPE".($qtype - 100);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -382,7 +382,10 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing DELETE statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
foreach ($_POST['groups'] as $gid) {
|
||||
$groups = array();
|
||||
if(isset($_POST['groups']))
|
||||
$groups = $_POST['groups'];
|
||||
foreach ($groups as $gid) {
|
||||
$stmt = $db->prepare('INSERT INTO client_by_group (client_id,group_id) VALUES(:id,:gid);');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
@@ -400,7 +403,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
}
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -437,7 +442,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
if (!$stmt->execute()) {
|
||||
throw new Exception('While executing client statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -677,7 +684,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
$added++;
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$after = intval($db->querySingle("SELECT COUNT(*) FROM domainlist;"));
|
||||
$difference = $after - $before;
|
||||
@@ -739,39 +748,43 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (isset($_POST['groups'])) {
|
||||
$stmt = $db->prepare('DELETE FROM domainlist_by_group WHERE domainlist_id = :id');
|
||||
$stmt = $db->prepare('DELETE FROM domainlist_by_group WHERE domainlist_id = :id');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing DELETE statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':id', intval($_POST['id']), SQLITE3_INTEGER)) {
|
||||
throw new Exception('While binding id: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
throw new Exception('While executing DELETE statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$groups = array();
|
||||
if(isset($_POST['groups']))
|
||||
$groups = $_POST['groups'];
|
||||
foreach ($groups as $gid) {
|
||||
$stmt = $db->prepare('INSERT INTO domainlist_by_group (domainlist_id,group_id) VALUES(:id,:gid);');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing DELETE statement: ' . $db->lastErrorMsg());
|
||||
throw new Exception('While preparing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':id', intval($_POST['id']), SQLITE3_INTEGER)) {
|
||||
throw new Exception('While binding id: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':gid', intval($gid), SQLITE3_INTEGER)) {
|
||||
throw new Exception('While binding gid: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
throw new Exception('While executing DELETE statement: ' . $db->lastErrorMsg());
|
||||
throw new Exception('While executing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_POST['groups'] as $gid) {
|
||||
$stmt = $db->prepare('INSERT INTO domainlist_by_group (domainlist_id,group_id) VALUES(:id,:gid);');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':id', intval($_POST['id']), SQLITE3_INTEGER)) {
|
||||
throw new Exception('While binding id: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':gid', intval($gid), SQLITE3_INTEGER)) {
|
||||
throw new Exception('While binding gid: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
throw new Exception('While executing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
}
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
@@ -810,7 +823,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing domainlist statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -856,7 +871,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing domainlist statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -920,7 +937,11 @@ if ($_POST['action'] == 'get_groups') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(preg_match("/[^a-zA-Z0-9:\/?&%=~._()-;]/", $address) !== 0) {
|
||||
// this will remove first @ that is after schema and before domain
|
||||
// $1 is optional schema, $2 is userinfo
|
||||
$check_address = preg_replace("|([^:/]*://)?([^/]+)@|", "$1$2", $address, 1);
|
||||
|
||||
if(preg_match("/[^a-zA-Z0-9:\/?&%=~._()-;]/", $check_address) !== 0) {
|
||||
throw new Exception('<strong>Invalid adlist URL ' . htmlentities($address) . '</strong><br>'.
|
||||
'Added ' . $added . " out of ". $total . " adlists");
|
||||
}
|
||||
@@ -937,7 +958,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
$added++;
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -993,7 +1016,10 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing DELETE statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
foreach ($_POST['groups'] as $gid) {
|
||||
$groups = array();
|
||||
if(isset($_POST['groups']))
|
||||
$groups = $_POST['groups'];
|
||||
foreach ($groups as $gid) {
|
||||
$stmt = $db->prepare('INSERT INTO adlist_by_group (adlist_id,group_id) VALUES(:id,:gid);');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing INSERT INTO statement: ' . $db->lastErrorMsg());
|
||||
@@ -1012,7 +1038,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -1050,7 +1078,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While executing adlist statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$reload = true;
|
||||
JSON_success();
|
||||
@@ -1090,7 +1120,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
$added++;
|
||||
}
|
||||
|
||||
$db->query('COMMIT;');
|
||||
if(!$db->query('COMMIT;')) {
|
||||
throw new Exception('While commiting changes to the database: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
$after = intval($db->querySingle("SELECT COUNT(*) FROM domain_audit;"));
|
||||
$difference = $after - $before;
|
||||
|
||||
Reference in New Issue
Block a user