Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Dirk Dankhoff
ISPConfig 3
Commits
3728fe98
Commit
3728fe98
authored
May 07, 2012
by
tbrehm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tool to import dns records from PowerDNS tupa controlpanel.
parent
14b85c78
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
219 additions
and
1 deletion
+219
-1
interface/web/tools/dns_import_tupa.php
interface/web/tools/dns_import_tupa.php
+156
-0
interface/web/tools/lib/lang/en.lng
interface/web/tools/lib/lang/en.lng
+2
-0
interface/web/tools/lib/menu.d/import.menu.php
interface/web/tools/lib/menu.d/import.menu.php
+5
-1
interface/web/tools/templates/dns_import_tupa.htm
interface/web/tools/templates/dns_import_tupa.htm
+56
-0
No files found.
interface/web/tools/dns_import_tupa.php
0 → 100644
View file @
3728fe98
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once
(
'../../lib/config.inc.php'
);
require_once
(
'../../lib/app.inc.php'
);
//* Check permissions for module
$app
->
auth
->
check_module_permissions
(
'admin'
);
//* This is only allowed for administrators
if
(
!
$app
->
auth
->
is_admin
())
die
(
'only allowed for administrators.'
);
$app
->
uses
(
'tpl,validate_dns'
);
$app
->
tpl
->
newTemplate
(
'form.tpl.htm'
);
$app
->
tpl
->
setInclude
(
'content_tpl'
,
'templates/dns_import_tupa.htm'
);
$msg
=
''
;
$error
=
''
;
// Resyncing dns zones
if
(
isset
(
$_POST
[
'start'
])
&&
$_POST
[
'start'
]
==
1
)
{
//* Set variable sin template
$app
->
tpl
->
setVar
(
'dbhost'
,
$_POST
[
'dbhost'
]);
$app
->
tpl
->
setVar
(
'dbname'
,
$_POST
[
'dbname'
]);
$app
->
tpl
->
setVar
(
'dbuser'
,
$_POST
[
'dbuser'
]);
$app
->
tpl
->
setVar
(
'dbpassword'
,
$_POST
[
'dbpassword'
]);
//* Establish connection to external database
$msg
.
=
'Connecting to external database...<br />'
;
//* Backup DB login details
$conf_bak
[
'db_host'
]
=
$conf
[
'db_host'
];
$conf_bak
[
'db_database'
]
=
$conf
[
'db_database'
];
$conf_bak
[
'db_user'
]
=
$conf
[
'db_user'
];
$conf_bak
[
'db_password'
]
=
$conf
[
'db_password'
];
//* Set external Login details
$conf
[
'db_host'
]
=
$_POST
[
'dbhost'
];
$conf
[
'db_database'
]
=
$_POST
[
'dbname'
];
$conf
[
'db_user'
]
=
$_POST
[
'dbuser'
];
$conf
[
'db_password'
]
=
$_POST
[
'dbpassword'
];
//* create new db object
$exdb
=
new
db
();
$server_id
=
1
;
$sys_userid
=
1
;
$sys_groupid
=
1
;
function
addot
(
$text
)
{
return
trim
(
$text
)
.
'.'
;
}
//* Connect to DB
if
(
$exdb
->
connect
())
{
$domains
=
$exdb
->
queryAllRecords
(
"SELECT * FROM domains WHERE type = 'MASTER'"
);
if
(
is_array
(
$domains
))
{
foreach
(
$domains
as
$domain
)
{
$soa
=
$exdb
->
queryOneRecord
(
"SELECT * FROM records WHERE type = 'SOA' AND domain_id = "
.
$domain
[
'id'
]);
if
(
is_array
(
$soa
))
{
$parts
=
explode
(
' '
,
$soa
[
'content'
]);
$origin
=
addot
(
$soa
[
'name'
]);
$ns
=
addot
(
$parts
[
0
]);
$mbox
=
addot
(
$parts
[
1
]);
$serial
=
$parts
[
2
];
$refresh
=
7200
;
$retry
=
540
;
$expire
=
604800
;
$minimum
=
86400
;
$ttl
=
$soa
[
'ttl'
];
$insert_data
=
"(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`) VALUES
('
$sys_userid
', '
$sys_groupid
', 'riud', 'riud', '', '
$server_id
', '
$origin
', '
$ns
', '
$mbox
', '
$serial
', '
$refresh
', '
$retry
', '
$expire
', '
$minimum
', '
$ttl
', 'Y', '')"
;
$dns_soa_id
=
$app
->
db
->
datalogInsert
(
'dns_soa'
,
$insert_data
,
'id'
);
unset
(
$parts
);
$msg
.
=
'Import Zone: '
.
$soa
[
'name'
]
.
'<br />'
;
//* Process the other records
$records
=
$exdb
->
queryAllRecords
(
"SELECT * FROM records WHERE type != 'SOA' AND domain_id = "
.
$domain
[
'id'
]);
if
(
is_array
(
$records
))
{
foreach
(
$records
as
$rec
)
{
$rr
=
array
();
$rr
[
'name'
]
=
addot
(
$rec
[
'name'
]);
$rr
[
'type'
]
=
$rec
[
'type'
];
$rr
[
'aux'
]
=
$rec
[
'prio'
];
$rr
[
'ttl'
]
=
$rec
[
'ttl'
];
if
(
$rec
[
'type'
]
==
'NS'
||
$rec
[
'type'
]
==
'MX'
||
$rec
[
'type'
]
==
'CNAME'
)
{
$rr
[
'data'
]
=
addot
(
$rec
[
'content'
]);
}
else
{
$rr
[
'data'
]
=
$rec
[
'content'
];
}
$insert_data
=
"(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES
('
$sys_userid
', '
$sys_groupid
', 'riud', 'riud', '', '
$server_id
', '
$dns_soa_id
', '
$rr[name]
', '
$rr[type]
', '
$rr[data]
', '
$rr[aux]
', '
$rr[ttl]
', 'Y')"
;
$dns_rr_id
=
$app
->
db
->
datalogInsert
(
'dns_rr'
,
$insert_data
,
'id'
);
//$msg .= $insert_data.'<br />';
}
}
}
}
}
}
else
{
$error
.
=
$exdb
->
errorMessage
;
}
//* restore db login details
$conf
[
'db_host'
]
=
$conf_bak
[
'db_host'
];
$conf
[
'db_database'
]
=
$conf_bak
[
'db_database'
];
$conf
[
'db_user'
]
=
$conf_bak
[
'db_user'
];
$conf
[
'db_password'
]
=
$conf_bak
[
'db_password'
];
}
$app
->
tpl
->
setVar
(
'msg'
,
$msg
);
$app
->
tpl
->
setVar
(
'error'
,
$error
);
$app
->
tpl_defaults
();
$app
->
tpl
->
pparse
();
?>
\ No newline at end of file
interface/web/tools/lib/lang/en.lng
View file @
3728fe98
...
...
@@ -7,4 +7,6 @@ $wb['ispconfig_tools_note'] = 'This module allows you to change the password and
$wb
[
'Sync Tools'
]
=
'Sync Tools'
;
$wb
[
'Resync'
]
=
'Resync'
;
$wb
[
'Import'
]
=
'Import'
;
$wb
[
'ISPConfig 3 mail'
]
=
'ISPConfig 3 mail'
;
$wb
[
'PDNS Tupa'
]
=
'PowerDNS Tupa'
;
?>
\ No newline at end of file
interface/web/tools/lib/menu.d/import.menu.php
View file @
3728fe98
...
...
@@ -7,10 +7,14 @@ if($app->auth->is_admin()) {
$items
=
array
();
$items
[]
=
array
(
'title'
=>
'ISPConfig 3'
,
$items
[]
=
array
(
'title'
=>
'ISPConfig 3
mail
'
,
'target'
=>
'content'
,
'link'
=>
'tools/import_ispconfig.php'
);
$items
[]
=
array
(
'title'
=>
'PDNS Tupa'
,
'target'
=>
'content'
,
'link'
=>
'tools/dns_import_tupa.php'
);
$module
[
'nav'
][]
=
array
(
'title'
=>
'Import'
,
'open'
=>
1
,
...
...
interface/web/tools/templates/dns_import_tupa.htm
0 → 100644
View file @
3728fe98
<h2>
Import DNS recods from Tupa PowerDNS controlpanel
</h2>
<p><tmpl_var
name=
"list_desc_txt"
></p>
<div
class=
"panel panel_language_import"
>
<div
class=
"pnl_formsarea"
>
<fieldset
class=
"inlineLabels"
><legend>
PowerDNS Tupa import
</legend>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Tupa database hostname
</p>
<div
class=
"multiField"
>
<input
id=
"dbhost"
type=
"text"
value=
"{tmpl_var name='dbhost'}"
name=
"dbhost"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Tupa database name
</p>
<div
class=
"multiField"
>
<input
id=
"dbname"
type=
"text"
value=
"{tmpl_var name='dbname'}"
name=
"dbname"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Tupa database user
</p>
<div
class=
"multiField"
>
<input
id=
"dbuser"
type=
"text"
value=
"{tmpl_var name='dbuser'}"
name=
"dbuser"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Tupa database password
</p>
<div
class=
"multiField"
>
<input
id=
"dbpassword"
type=
"text"
value=
"{tmpl_var name='dbpassword'}"
name=
"dbpassword"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Import DNS Records
</p>
<div
class=
"multiField"
>
<input
id=
"start"
type=
"checkbox"
value=
"1"
name=
"start"
checked
/>
</div>
</div>
</fieldset>
<tmpl_if
name=
"msg"
>
<div
id=
"OKMsg"
><p><tmpl_var
name=
"msg"
></p></div>
</tmpl_if>
<tmpl_if
name=
"error"
>
<div
id=
"errorMsg"
><h3>
ERROR
</h3><ol><tmpl_var
name=
"error"
></ol></div>
</tmpl_if>
<input
type=
"hidden"
name=
"id"
value=
"{tmpl_var name='id'}"
>
<div
class=
"buttonHolder buttons"
>
<button
class=
"positive iconstxt icoPositive"
type=
"button"
value=
"Import"
onClick=
"submitForm('pageForm','tools/dns_import_tupa.php');"
><span>
Start
</span></button>
<button
class=
"negative iconstxt icoNegative"
type=
"button"
value=
"Cancel"
onClick=
"loadContent('tools/index.php');"
><span>
Cancel
</span></button>
</div>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment