Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phpipam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
phpipam
Commits
94415361
Commit
94415361
authored
Jun 1, 2023
by
Jelloul Ayeb
Browse files
Options
Downloads
Patches
Plain Diff
update soa serials of affected domains when deleting records
parent
958602f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions/classes/class.PowerDNS.php
+43
-11
43 additions, 11 deletions
functions/classes/class.PowerDNS.php
with
43 additions
and
11 deletions
functions/classes/class.PowerDNS.php
+
43
−
11
View file @
94415361
...
@@ -686,6 +686,27 @@ class PowerDNS extends Common_functions {
...
@@ -686,6 +686,27 @@ class PowerDNS extends Common_functions {
return
!
is_null
(
$record
)
?
$record
:
false
;
return
!
is_null
(
$record
)
?
$record
:
false
;
}
}
/**
* Searches domains referencing a hostname or ip
*
* @access public
* @param mixed $hostname
* @param mixed $ip
* @return array|boolean
*/
public
function
search_domains_by_hostname_or_ip
(
$hostname
,
$ip
)
{
// query
$query
=
"select DISTINCT(`domain_id`) from `records` where `name` = ? or `content` = ? and `type` != 'NS' and `type` != 'SOA';"
;
// fetch
try
{
$records
=
$this
->
Database_pdns
->
getObjectsQuery
(
$query
,
array
(
$hostname
,
$ip
));
}
catch
(
Exception
$e
)
{
$this
->
Result
->
show
(
"danger"
,
_
(
"Error: "
)
.
$e
->
getMessage
());
return
false
;
}
# result
return
sizeof
(
$records
)
>
0
?
$records
:
false
;
}
/**
/**
* Searches records for specific domainid for type and name values
* Searches records for specific domainid for type and name values
*
*
...
@@ -933,6 +954,9 @@ class PowerDNS extends Common_functions {
...
@@ -933,6 +954,9 @@ class PowerDNS extends Common_functions {
* @return void
* @return void
*/
*/
public
function
pdns_remove_ip_and_hostname_records
(
$hostname
,
$ip
)
{
public
function
pdns_remove_ip_and_hostname_records
(
$hostname
,
$ip
)
{
// find out which domains are going to need an soa serial update
$domains_records
=
$this
->
search_domains_by_hostname_or_ip
(
$hostname
,
$ip
);
// set query
// set query
$query
=
"delete from `records` where (`name` = ? or `content` = ?) and `type` != 'NS' and `type` != 'SOA';"
;
$query
=
"delete from `records` where (`name` = ? or `content` = ?) and `type` != 'NS' and `type` != 'SOA';"
;
...
@@ -942,6 +966,14 @@ class PowerDNS extends Common_functions {
...
@@ -942,6 +966,14 @@ class PowerDNS extends Common_functions {
$this
->
Result
->
show
(
"danger"
,
_
(
"Error: "
)
.
$e
->
getMessage
());
$this
->
Result
->
show
(
"danger"
,
_
(
"Error: "
)
.
$e
->
getMessage
());
return
false
;
return
false
;
}
}
// update soa serial for impacted domains
if
(
$domains_records
!==
false
)
{
foreach
(
$domains_records
as
$d
)
{
$this
->
update_soa_serial
(
$d
->
domain_id
);
}
}
#result
#result
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment