Apache-DnsZone
view release on metacpan or search on metacpan
lib/Apache/DnsZone.pm view on Meta::CPAN
}
my $page_title = $lang{PAGE_ADD};
$page_title =~ s/\$record/$type/;
$page_title =~ s/\$domain/$domain/;
$tpl->assign(TITLE => $page_title);
$tpl->define(record => 'a/add.tpl');
$tpl->assign(HOST_VALUE => encode_entities(apr()->param('host'))); # maybe it needs to fully qualify it if it was okay?
$tpl->assign(IP_ADDRESS_VALUE => encode_entities(apr()->param('ip')));
$tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));
# do the red-marker assignment
# and the error text getting
my $error_text = $lang{ERROR_CORRECT};
if (!($ip = check_ip($ip))) {
$tpl->assign(IP_ADDRESS => qq{<font color="red">} . $lang{IP_ADDRESS} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_IP}};
}
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_HOST}};
}
if (!check_ttl($ttl)) {
$tpl->assign(TTL => qq{<font color="red">} . $lang{TTL} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_TTL}};
}
# check_before_add_A
if ($all_set) {
# this means check_before_add_A failed!
# text for error?
$tpl->assign(IP_ADDRESS => qq{<font color="red">} . $lang{IP_ADDRESS} . qq{</font>});
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_DUPLICATE}};
}
$tpl->assign(EXPLANATION => $error_text);
$tpl->assign(DOM_ID => $dom_id);
$tpl->parse(MENU => "menu");
$tpl->parse(MAIN => ["record", "layout"]);
my $content_ref = $tpl->fetch("MAIN");
output_headers($r, 1, length(${$content_ref}));
$r->print(${$content_ref});
$dbh->close();
return OK;
}
}
elsif (/^AAAA$/) {
# actually there needs to be another check to see if they really exists the parameters maybe up in the checking of the rec_lock
my $all_set = 1;
my $ipv6 = apr()->param('ipv6');
if (ip_is_ipv6($ipv6)) {
$ipv6 = ip_expand_address($ipv6, 6); # to always have the correct full address to match against
} else {
$all_set = 0;
}
my $host = "";
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$all_set = 0;
}
my $ttl = apr()->param('ttl');
if (!check_ttl($ttl)) {
$all_set = 0;
}
if ($all_set && check_before_add_AAAA($dom_id, $host, $ipv6)) {
# update dns! and sql
# check wheter name is the same? so no need for update?
# rule checking like not the same a and cname record
# check wheter an excact copy exists in dns to avoid errors
if (dns_set_AAAA($dom_id, $host, $ipv6, $ttl)) {
Debug(5, qq{dns_set_AAAA succeded\n});
} else {
Debug(5, qq{dns_set_AAAA failed\n});
}
} else {
my $tpl = new CGI::FastTemplate($cfg->{'cfg'}->{DnsZoneTemplateDir});
$tpl->define(layout => 'layout.tpl', menu => 'menu.tpl');
$tpl->assign(%lang);
$tpl->assign(DEBUG => '');
if ($dbh->get_domain_count($uid) == 1) {
$tpl->assign(ADDITIONAL_MENU => '');
} else {
$tpl->assign(ADDITIONAL_MENU => qq{<a href="/admin?action=default">$lang{LIST_DOMAIN}</a> | });
}
my $page_title = $lang{PAGE_ADD};
$page_title =~ s/\$record/$type/;
$page_title =~ s/\$domain/$domain/;
$tpl->assign(TITLE => $page_title);
$tpl->define(record => 'aaaa/add.tpl');
$tpl->assign(HOST_VALUE => encode_entities(apr()->param('host'))); # maybe it needs to fully qualify it if it was okay?
$tpl->assign(IPV6_ADDRESS_VALUE => encode_entities(apr()->param('ipv6')));
$tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));
# do the red-marker assignment
# and the error text getting
my $error_text = $lang{ERROR_CORRECT};
if (!ip_is_ipv6($ipv6)) {
$tpl->assign(IPV6_ADDRESS => qq{<font color="red">} . $lang{IPV6_ADDRESS} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_IPV6}};
}
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_HOST}};
}
if (!check_ttl($ttl)) {
$tpl->assign(TTL => qq{<font color="red">} . $lang{TTL} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_TTL}};
lib/Apache/DnsZone.pm view on Meta::CPAN
} else {
$tpl->assign(ADDITIONAL_MENU => qq{<a href="/admin?action=default">$lang{LIST_DOMAIN}</a> | });
}
my $page_title = $lang{PAGE_EDIT};
$page_title =~ s/\$record/$type/;
$page_title =~ s/\$domain/$domain/;
$tpl->assign(TITLE => $page_title);
$tpl->define(record => 'a/edit.tpl');
$tpl->assign(HOST_VALUE => encode_entities(apr()->param('host'))); # maybe it needs to fully qualify it if it was okay?
$tpl->assign(IP_ADDRESS_VALUE => encode_entities(apr()->param('ip')));
$tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));
# do the red-marker assignment
my $error_text = $lang{ERROR_CORRECT};
if (!($ip = check_ip(apr()->param('ip')))) {
$tpl->assign(IP_ADDRESS => qq{<font color="red">} . $lang{IP_ADDRESS} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_IP}};
}
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_HOST}};
}
if (!check_ttl($ttl)) {
$tpl->assign(TTL => qq{<font color="red">} . $lang{TTL} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_TTL}};
}
if ($all_set) {
$tpl->assign(IP_ADDRESS => qq{<font color="red">} . $lang{IP_ADDRESS} . qq{</font>});
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_DUPLICATE}};
}
$tpl->assign(EXPLANATION => $error_text);
$tpl->assign(DOM_ID => $dom_id);
$tpl->assign(RECORD_ID => $record_id);
$tpl->parse(MENU => "menu");
$tpl->parse(MAIN => ["record", "layout"]);
my $content_ref = $tpl->fetch("MAIN");
output_headers($r, 1, length(${$content_ref}));
$r->print(${$content_ref});
$dbh->close();
return OK;
}
}
elsif (/^AAAA$/) {
# actually there needs to be another check to see if they really exists the parameters maybe up in the checking of the rec_lock
my $all_set = 1;
my $ipv6 = apr()->param('ipv6');
if (ip_is_ipv6($ipv6)) {
$ipv6 = ip_expand_address($ipv6, 6); # to always have the correct full address to match against
} else {
$all_set = 0;
}
my $host = "";
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$all_set = 0;
}
my $ttl = apr()->param('ttl');
if (!check_ttl($ttl)) {
$all_set = 0;
}
if ($all_set && check_before_edit_AAAA($dom_id, $record_id, $host, $ipv6)) {
# update dns! and sql
# check wheter name is the same? so no need for update?
# check wheter an excact copy exists in dns to avoid errors
if (is_updated_AAAA($dom_id, $record_id, $host, $ipv6, $ttl)) {
if (dns_update_AAAA($dom_id, $record_id, $host, $ipv6, $ttl)) {
Debug(2, qq{dns_update_AAAA succeded\n});
} else {
Debug(2, qq{dns_update_AAAA failed\n});
}
} else {
Debug(2, qq{Dns record not changed so not updated\n});
}
} else {
my $tpl = new CGI::FastTemplate($cfg->{'cfg'}->{DnsZoneTemplateDir});
$tpl->define(layout => 'layout.tpl', menu => 'menu.tpl');
$tpl->assign(%lang);
$tpl->assign(DEBUG => '');
if ($dbh->get_domain_count($uid) == 1) {
$tpl->assign(ADDITIONAL_MENU => '');
} else {
$tpl->assign(ADDITIONAL_MENU => qq{<a href="/admin?action=default">$lang{LIST_DOMAIN}</a> | });
}
my $page_title = $lang{PAGE_EDIT};
$page_title =~ s/\$record/$type/;
$page_title =~ s/\$domain/$domain/;
$tpl->assign(TITLE => $page_title);
$tpl->define(record => 'aaaa/edit.tpl');
$tpl->assign(HOST_VALUE => encode_entities(apr()->param('host'))); # maybe it needs to fully qualify it if it was okay?
$tpl->assign(IPV6_ADDRESS_VALUE => encode_entities(apr()->param('ipv6')));
$tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));
# do the red-marker assignment
my $error_text = $lang{ERROR_CORRECT};
if (!ip_is_ipv6($ipv6)) {
$tpl->assign(IPV6_ADDRESS => qq{<font color="red">} . $lang{IPV6_ADDRESS} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_IPV6}};
}
if (!($host = check_fqdn(apr()->param('host'), $domain))) {
$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
$error_text .= qq{<br>$lang{ERROR_HOST}};
}
( run in 2.748 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )