Skip to content

Commit 911d45c

Browse files
committed
Added a new tool to force DNS Resyncs.
1 parent 85d6697 commit 911d45c

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

interface/web/tools/dns_resync.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/*
3+
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
require_once('../../lib/config.inc.php');
31+
require_once('../../lib/app.inc.php');
32+
33+
//* Check permissions for module
34+
$app->auth->check_module_permissions('admin');
35+
36+
//* This is only allowed for administrators
37+
if(!$app->auth->is_admin()) die('only allowed for administrators.');
38+
39+
$app->uses('tpl,validate_dns');
40+
41+
$app->tpl->newTemplate('form.tpl.htm');
42+
$app->tpl->setInclude('content_tpl', 'templates/dns_resync.htm');
43+
$msg = '';
44+
$error = '';
45+
46+
// Resyncing dns zones
47+
if(isset($_POST['resync']) && $_POST['resync'] == 1) {
48+
$zones = $app->db->queryAllRecords("SELECT id,origin,serial FROM dns_soa WHERE active = 'Y'");
49+
if(is_array($zones)) {
50+
foreach($zones as $zone) {
51+
$records = $app->db->queryAllRecords("SELECT id,serial FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
52+
if(is_array($records)) {
53+
foreach($records as $rec) {
54+
$new_serial = $app->validate_dns->increase_serial($rec["serial"]);
55+
$app->db->datalogUpdate('dns_rr', "serial = '".$new_serial."'", 'id', $rec['id']);
56+
57+
}
58+
}
59+
$new_serial = $app->validate_dns->increase_serial($zone["serial"]);
60+
$app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone['id']);
61+
$msg .= "Resynced: ".$zone['origin'].'<br />';
62+
}
63+
}
64+
65+
}
66+
67+
$app->tpl->setVar('msg',$msg);
68+
$app->tpl->setVar('error',$error);
69+
70+
71+
//* load language file
72+
/*
73+
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_mailbox_import.lng';
74+
include($lng_file);
75+
$app->tpl->setVar($wb);
76+
*/
77+
78+
$app->tpl_defaults();
79+
$app->tpl->pparse();
80+
81+
82+
?>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
4+
// Menu
5+
6+
if($app->auth->is_admin()) {
7+
8+
$items = array();
9+
10+
$items[] = array( 'title' => 'Resync',
11+
'target' => 'content',
12+
'link' => 'tools/dns_resync.php');
13+
14+
15+
$module['nav'][] = array( 'title' => 'DNS Tools',
16+
'open' => 1,
17+
'items' => $items);
18+
19+
unset($items);
20+
}
21+
22+
?>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2><tmpl_var name="list_head_txt"></h2>
2+
<p><tmpl_var name="list_desc_txt"></p>
3+
4+
<div class="panel panel_language_import">
5+
6+
<div class="pnl_formsarea">
7+
<fieldset class="inlineLabels"><legend>DNS Resync</legend>
8+
<div class="ctrlHolder">
9+
<p class="label">Resync DNS Records</p>
10+
<div class="multiField">
11+
<input id="resync" type="checkbox" value="1" name="resync" checked/>
12+
</div>
13+
</div>
14+
</fieldset>
15+
16+
<tmpl_if name="msg">
17+
<div id="OKMsg"><p><tmpl_var name="msg"></p></div>
18+
</tmpl_if>
19+
<tmpl_if name="error">
20+
<div id="errorMsg"><h3>ERROR</h3><ol><tmpl_var name="error"></ol></div>
21+
</tmpl_if>
22+
23+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
24+
25+
<div class="buttonHolder buttons">
26+
<button class="positive iconstxt icoPositive" type="button" value="Import" onClick="submitUploadForm('pageForm','tools/dns_resync.php');"><span>Start</span></button>
27+
<button class="negative iconstxt icoNegative" type="button" value="Cancel" onClick="loadContent('tools/index.php');"><span>Cancel</span></button>
28+
</div>
29+
</div>
30+
31+
</div>

0 commit comments

Comments
 (0)