diff --git a/.gitattributes b/.gitattributes index b982f2e8..55160680 100644 --- a/.gitattributes +++ b/.gitattributes @@ -105,6 +105,7 @@ bureau/admin/dom_dodel.php -text bureau/admin/dom_edit.inc.php -text bureau/admin/dom_edit.php -text bureau/admin/dom_editdns.php -text +bureau/admin/dom_import.php -text bureau/admin/dom_subdel.php -text bureau/admin/dom_subdodel.php -text bureau/admin/dom_subdoedit.php -text diff --git a/bureau/admin/dom_add.php b/bureau/admin/dom_add.php index 56f71f88..cc5d425a 100644 --- a/bureau/admin/dom_add.php +++ b/bureau/admin/dom_add.php @@ -54,7 +54,7 @@ if (isset($error) && $error) echo "
$error
"; ?> + + diff --git a/bureau/admin/styles/style.css b/bureau/admin/styles/style.css index 37cbb670..e56d8642 100644 --- a/bureau/admin/styles/style.css +++ b/bureau/admin/styles/style.css @@ -85,6 +85,16 @@ fieldset { border: 1px solid #555; } +pre { + overflow: auto; + background-color: #ddd; + padding: 10px; + border: solid 1px #999; + border-radius: 4px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; +} + .inp { /* Should not be use anymore !!! */ border-color: blue; @@ -568,6 +578,16 @@ input#dir, input#sub_local { width: 200px; } +.tab-ok { + background-color: lightgreen; +} +.tab-err { + background-color: red; +} +.tab-warn { + background-color: coral; +} + .warningmsg { width: 500px; } diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index e9b05a40..c065e034 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -169,6 +169,266 @@ class m_dom { } } + function import_manual_dns_zone($zone, $domain, $detect_redirect=true, $save=false) { + global $err; + if ($save) { + if (! $this->import_manual_dns_prep_zone($domain) ) { + $err->raise('dom', _("Err: failed to prepare the zone")); + return false; + } + } + + $val = array(); + foreach (explode("\n", $zone) as $z) { + $z=trim($z); + if (empty($z)) continue; + $val[] = $this->import_manual_dns_entry($z,$domain,$detect_redirect,$save); + } + return $val; + } + + function import_manual_dns_entry($zone, $domain, $detect_redirect=true, $save=false) { + global $cuid, $err; + $err->log("dom","import_manual_dns_entry"); + $zone=trim($zone); + if (empty($zone)) return false; + + $domain=trim($domain); + if ( empty($domain) ) { + $err->raise("dom", _("Missing domain name")); + return false; + } + + $val = array( + 'status' => 'err', // can be 'ok', 'err', 'warn' + 'comment' => 'no val', + 'entry_old' => $zone, + 'entry_new' => array('domain'=>$domain), + ); + + // Examples: + // ; hello comment + if ( preg_match('/^;/', $zone, $ret) ) { + $val['status'] = 'ok'; + $val['comment'] = 'Just a comment, do not import'; + } else + // Examples: + // $TTL 86400' + if ( preg_match('/^\$TTL\h+(?P