Apache-DnsZone

 view release on metacpan or  search on metacpan

lib/Apache/DnsZone.pm  view on Meta::CPAN

    $res->res->domain($domain);
    $res->res->searchlist($domain);
    $res->res->tcp_timeout(5);
#    $res->res->print;
}

###################################
# check_for_conflicts($host)      # 
# check for conflicting hostnames #
###################################

sub check_for_conflicts {

}

#############################################
# output_headers($r, $cache, $length)       # 
# output headers, w w/o cache, w w/o length #
#############################################

sub output_headers {
    my $r = shift || Apache->request();
    my $cache = shift || 0;
    my $length = shift || 0;
    Debug(5, qq{output_headers(\$r, $cache, $length) called\n});    
    $r->content_type('text/html');

    if ($cache != 0) {
	$r->header_out("Pragma", "no-cache");
	$r->header_out("Cache-control", "no-cache");
	$r->no_cache(1);
    }
    if ($length != 0) {
	$r->header_out("Content-Length", $length);
    }

    $r->send_http_header();
}

##########################################
# output_redirect($r, $cache, $location) # 
# output redirect, w w/o cache, location #
##########################################

sub output_redirect {
    my $r = shift || Apache->request();
    my $cache = shift || 0;
    my $location = shift || 0;
    Debug(5, qq{output_redirect(\$r, $cache, $location) called\n});
    $r->content_type('text/html');

    if ($cache != 0) {
	$r->header_out("Pragma", "no-cache");
	$r->header_out("Cache-control", "no-cache");
	$r->no_cache(1);
    }

    $r->header_out(Location => $location);
}

sub is_updated_SOA {
    my $dom_id = shift;
    my $new_email = shift;
    my $new_refresh = shift;
    my $new_retry = shift;
    my $new_expire = shift;
    my $new_ttl = shift;
    my ($old_auth_ns, $old_email, $old_serial, $old_refresh, $old_retry, $old_expire, $old_ttl, $rec_lock) = $dbh->soa_lookup($dom_id);
    return 0 if $old_email eq $new_email && $old_refresh == $new_refresh && $old_retry == $new_retry && $old_expire == $new_expire && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_A {
    my $dom_id = shift;
    my $host = shift;
    my $address = shift;
    Debug(5, qq{check_before_add_A($dom_id, $host, $address) called});
    if ($dbh->is_duplicate_A($dom_id, $host, $address)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    # no A record exists that has the same address, no CNAME record exists with the same name
    return 1;
}

sub check_before_edit_A {
    my $dom_id = shift;
    my $a_id = shift;
    my $new_host = shift;
    my $new_address = shift;
    Debug(5, qq{check_before_edit_A($dom_id, $a_id, $new_host, $new_address) called});
    my ($old_name, $old_address, $old_ttl) = $dbh->a_lookup($dom_id, $a_id);
    return 1 if $old_name eq $new_host && $old_address eq $new_address;
    if ($dbh->is_duplicate_A($dom_id, $new_host, $new_address)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_A {
    my $dom_id = shift;
    my $a_id = shift;
    my $new_host = shift;
    my $new_address = shift;
    my $new_ttl = shift;
    my ($old_name, $old_address, $old_ttl) = $dbh->a_lookup($dom_id, $a_id);
    return 0 if $old_name eq $new_host && $old_address eq $new_address && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_AAAA {
    my $dom_id = shift;
    my $host = shift;
    my $address = shift;
    Debug(5, qq{check_before_add_AAA($dom_id, $host, $address) called});
    if ($dbh->is_duplicate_AAAA($dom_id, $host, $address)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    # no A record exists that has the same address, no CNAME record exists with the same name
    return 1;
}

sub check_before_edit_AAAA {
    my $dom_id = shift;
    my $a_id = shift;
    my $new_host = shift;
    my $new_address = shift;
    Debug(5, qq{check_before_edit_AAAA($dom_id, $a_id, $new_host, $new_address) called});
    my ($old_name, $old_address, $old_ttl) = $dbh->aaaa_lookup($dom_id, $a_id);
    return 1 if $old_name eq $new_host && $old_address eq $new_address;
    if ($dbh->is_duplicate_AAAA($dom_id, $new_host, $new_address)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_AAAA {
    my $dom_id = shift;
    my $a_id = shift;
    my $new_host = shift;
    my $new_address = shift;
    my $new_ttl = shift;
    my ($old_name, $old_address, $old_ttl) = $dbh->aaaa_lookup($dom_id, $a_id);
    return 0 if $old_name eq $new_host && $old_address eq $new_address && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_CNAME {
    my $dom_id = shift;
    my $host = shift;
    Debug(5, qq{check_before_add_CNAME($dom_id, $host) called});
    if ($dbh->does_A_exist($dom_id, $host)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    if ($dbh->does_MX_exist($dom_id, $host)) {
	return 0;
    }
    if ($dbh->does_NS_exist($dom_id, $host)) {
	return 0;
    }
    if ($dbh->does_TXT_exist($dom_id, $host)) {
	return 0;
    }
    return 1;
}

sub check_before_edit_CNAME {
    my $dom_id = shift;
    my $cname_id = shift;
    my $new_host = shift;
    my $new_cname = shift;
    Debug(5, qq{check_before_edit_CNAME($dom_id, $cname_id, $new_host, $new_cname) called});
    my ($old_host, $old_cname, $old_ttl) = $dbh->cname_lookup($dom_id, $cname_id);
    return 1 if $old_host eq $new_host && $old_cname eq $new_cname;
    return 1 if $old_host eq $new_host;
    if ($dbh->does_A_exist($dom_id, $new_host)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    if ($dbh->does_MX_exist($dom_id, $new_host)) {
	return 0;
    }
    if ($dbh->does_NS_exist($dom_id, $new_host)) {
	return 0;
    }
    if ($dbh->does_TXT_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_CNAME {
    my $dom_id = shift;
    my $cname_id = shift;
    my $new_host = shift;
    my $new_cname = shift;
    my $new_ttl = shift;
    my ($old_host, $old_cname, $old_ttl) = $dbh->cname_lookup($dom_id, $cname_id);
    return 0 if $old_host eq $new_host && $old_cname eq $new_cname && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_MX {
    my $dom_id = shift;
    my $host = shift;
    my $exchanger = shift;
    my $preference = shift;
    Debug(5, qq{check_before_add_MX($dom_id, $host, $exchanger, $preference) called});
    if ($dbh->is_duplicate_MX($dom_id, $host, $preference)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    return 1;
}

sub check_before_edit_MX {
    my $dom_id = shift;
    my $mx_id = shift;
    my $new_host = shift;
    my $new_exchanger = shift;
    my $new_preference = shift;
    Debug(5, qq{check_before_edit_MX($dom_id, $mx_id, $new_host, $new_exchanger, $new_preference) called});
    my ($old_name, $old_exchanger, $old_preference, $old_ttl) = $dbh->mx_lookup($dom_id, $mx_id);
    return 1 if $old_name eq $new_host && $old_preference eq $new_preference;
    if ($dbh->is_duplicate_MX($dom_id, $new_host, $new_preference)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_MX {
    my $dom_id = shift;
    my $mx_id = shift;
    my $new_host = shift;
    my $new_exchanger = shift;
    my $new_preference = shift;
    my $new_ttl = shift;
    my ($old_name, $old_exchanger, $old_preference, $old_ttl) = $dbh->mx_lookup($dom_id, $mx_id);
    return 0 if $old_name eq $new_host && $old_preference == $new_preference && $old_exchanger eq $new_exchanger && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_NS {
    my $dom_id = shift;
    my $host = shift;
    my $nsdname = shift;
    Debug(5, qq{check_before_add_NS($dom_id, $host, $nsdname) called});
    if ($dbh->is_duplicate_NS($dom_id, $host, $nsdname)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    return 1;
}

sub check_before_edit_NS {
    my $dom_id = shift;
    my $ns_id = shift;
    my $new_host = shift;
    my $new_ns = shift;
    Debug(5, qq{check_before_edit_NS($dom_id, $ns_id, $new_host, $new_ns) called});
    my ($old_name, $old_nameserver, $old_ttl) = $dbh->ns_lookup($dom_id, $ns_id);
    return 1 if $old_name eq $new_host && $old_nameserver eq $new_ns;
    if ($dbh->is_duplicate_NS($dom_id, $new_host, $new_ns)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_NS {
    my $dom_id = shift;
    my $ns_id = shift;
    my $new_host = shift;
    my $new_ns = shift;
    my $new_ttl = shift;
    my ($old_name, $old_nameserver, $old_ttl) = $dbh->ns_lookup($dom_id, $ns_id);
    return 0 if $old_name eq $new_host && $old_nameserver eq $new_ns && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_PTR {
    my $dom_id = shift;
    my $host = shift;
    my $reverse = shift;
    Debug(5, qq{check_before_add_PTR($dom_id, $host, $reverse) called});
    if ($dbh->is_duplicate_PTR($dom_id, $host, $reverse)) {
	return 0;
    }
    # no PTR record exists that has the same address
    return 1;
}

sub check_before_edit_PTR {
    my $dom_id = shift;
    my $ptr_id = shift;
    my $new_host = shift;
    my $new_reverse = shift;
    Debug(5, qq{check_before_edit_PTR($dom_id, $ptr_id, $new_host, $new_reverse) called});
    my ($old_name, $old_reverse, $old_ttl) = $dbh->ptr_lookup($dom_id, $ptr_id);
    return 1 if $old_name eq $new_host && $old_reverse eq $new_reverse;
    if ($dbh->is_duplicate_PTR($dom_id, $new_host, $new_reverse)) {
	return 0;
    }
    return 1;
}

sub is_updated_PTR {
    my $dom_id = shift;
    my $ptr_id = shift;
    my $new_host = shift;
    my $new_reverse = shift;
    my $new_ttl = shift;
    my ($old_name, $old_reverse, $old_ttl) = $dbh->ptr_lookup($dom_id, $ptr_id);
    return 0 if $old_name eq $new_host && $old_reverse eq $new_reverse && $old_ttl == $new_ttl;
    return 1;
}

sub check_before_add_TXT {
    my $dom_id = shift;
    my $host = shift;
    my $txt = shift;
    Debug(5, qq{check_before_add_TXT($dom_id, $host, $txt) called});
    if ($dbh->is_duplicate_TXT($dom_id, $host, $txt)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $host)) {
	return 0;
    }
    return 1;
}

sub check_before_edit_TXT {
    my $dom_id = shift;
    my $txt_id = shift;
    my $new_host = shift;
    my $new_txt = shift;
    Debug(5, qq{check_before_edit_TXT($dom_id, $txt_id, $new_host, $new_txt) called});
    my ($old_name, $old_txt, $old_ttl) = $dbh->txt_lookup($dom_id, $txt_id);
    return 1 if $old_name eq $new_host && $old_txt eq $new_txt;
    if ($dbh->is_duplicate_TXT($dom_id, $new_host, $new_txt)) {
	return 0;
    }
    if ($dbh->does_CNAME_exist($dom_id, $new_host)) {
	return 0;
    }
    return 1;
}

sub is_updated_TXT {
    my $dom_id = shift;
    my $txt_id = shift;
    my $new_host = shift;
    my $new_txt = shift;
    my $new_ttl = shift;
    my ($old_name, $old_txt, $old_ttl) = $dbh->txt_lookup($dom_id, $txt_id);
    return 0 if $old_name eq $new_host && $old_txt eq $new_txt && $old_ttl == $new_ttl;
    return 1;
}

sub handler {
    my $r = shift || Apache->request();
    Debug(2, qq{Apache::DnsZone::handler called});
    if ($r->header_only) {
	$r->send_http_header;
	return OK;
    }
    init($r);
    # lang is setup for the whole process of the script here
    my $user = $r->connection->user;
    my ($lang) = $dbh->get_user_lang($user);
    %lang = lang($lang);

    my $uri = $r->uri;
    if ($uri !~ m|^/admin|) {
	return DECLINED;
    } 

    # Internal dispatch based on parameters to the url

    if (apr()->param('action')) {
	my $action = lc(apr()->param('action'));
	my $button = "";
	if (apr->param('button')) {
	    $button = lc(apr()->param('button'));
	    if ($button eq lc($lang{'CANCEL'})) {
	        Debug(3, qq{pushing cancel() to PerlHandler (called from a pushed button)});
		$r->push_handlers(PerlHandler => \&cancel);
		return OK;
#	    } elsif ($button eq lc($lang{'HELP'})) {
#	        DnsZone::Debug(3, qq{pushing help() to PerlHandler (called from a pushed button)});
#		$r->push_handlers(PerlHandler => \&help);
#		return OK;
	    } 
	}
	if ($action eq 'view') {
	    Debug(3, qq{pushing view_domain() to PerlHandler});
	    $r->push_handlers(PerlHandler => \&view_domain);
	} elsif ($action eq 'edit') {
	    Debug(3, qq{pushing edit_record() to PerlHandler});
	    $r->push_handlers(PerlHandler => \&edit_record);
	} elsif ($action eq 'add') {
	    Debug(3, qq{pushing add_record() to PerlHandler});
	    $r->push_handlers(PerlHandler => \&add_record);
        } elsif ($action eq 'delete') {
  	    Debug(3, qq{pushing delete_record() to PerlHandler});
	    $r->push_handlers(PerlHandler => \&delete_record);
        } elsif ($action eq 'settings') {
  	    Debug(3, qq{pushing settings() to PerlHandler});
	    $r->push_handlers(PerlHandler => \&settings);

lib/Apache/DnsZone.pm  view on Meta::CPAN

	$dbh->close();
	return REDIRECT;
    }

    # now only if it's a SOA it's okay not to have a record_id - record_id is equal to dom_id
    my $record_id = apr()->param('record_id') if apr()->param('record_id');
    $record_id = $dom_id if $type eq 'SOA';
    ($record_id) = ($record_id =~ /(\d+)/)[0];
    if ($record_id !~ /^\d+$/) {
	$r->log_reason("User didn't supply a record id for this request or tried to fake it");
	output_redirect($r, 1, '/admin');
	$dbh->close();
	return REDIRECT;
    }

    # check for rec_lock
    # and at the same time if UID = owner of record
    my $rec_lock = 0;
    for ($type) {
	if (/^SOA$/) { ($rec_lock) = $dbh->get_lock_SOA($dom_id); }
	elsif (/^A$/) { ($rec_lock) = $dbh->get_lock_A($dom_id, $record_id); }
	elsif (/^AAAA$/) { ($rec_lock) = $dbh->get_lock_AAAA($dom_id, $record_id); }
	elsif (/^CNAME$/) { ($rec_lock) = $dbh->get_lock_CNAME($dom_id, $record_id); }
	elsif (/^MX$/) { ($rec_lock) = $dbh->get_lock_MX($dom_id, $record_id); }
	elsif (/^NS$/) { ($rec_lock) = $dbh->get_lock_NS($dom_id, $record_id); }
	elsif (/^PTR$/) { ($rec_lock) = $dbh->get_lock_PTR($dom_id, $record_id); }
	elsif (/^TXT$/) { ($rec_lock) = $dbh->get_lock_TXT($dom_id, $record_id); }
	else { $rec_lock = 1; }
    }
    if ($rec_lock) {
	$r->log_reason("User tried to change a locked record");
	output_redirect($r, 1, '/admin');
	$dbh->close();
	return REDIRECT;
    }

    if (apr()->param('button') && lc(apr()->param('button')) eq lc($lang{'SUBMIT'})) {
        Debug(5, qq{This is a submit of edit_record request});
	for ($type) {
	    if (/^SOA$/) { 
		my $soa_email = apr()->param('soa_email');
		my $refresh = apr()->param('refresh');
		my $retry = apr()->param('retry');
		my $expire = apr()->param('expire');
		my $default_ttl = apr()->param('default_ttl');
		my $all_set = 1;
		if (!(check_ttl($refresh) && check_ttl($retry) && check_ttl($expire) && check_ttl($default_ttl))) {
		    $all_set = 0;
		}
		if (!($soa_email = check_email($soa_email))) {
		    $all_set = 0;
		}
		if ($soa_email =~ /\..*?\@/) { 
		    # is there a dot before the @ => invalid for a soa email
		    $all_set = 0;
                } 
		if ($all_set) {
		    my $serial = get_serial_from_zone($dom_id);
		    $serial++;
		    $soa_email =~ s/\@/\./;
		    if (is_updated_SOA($dom_id, $soa_email, $refresh, $retry, $expire, $default_ttl)) {
			if (dns_update_SOA($dom_id, $serial, $soa_email, $refresh, $retry, $expire, $default_ttl)) {
			    Debug(2, qq{dns_update_SOA succeded\n});
			} else {
			    Debug(2, qq{dns_update_SOA 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 => 'soa/edit.tpl');
		    $tpl->assign(ADMIN_EMAIL_VALUE => encode_entities(apr()->param('soa_email')));
		    $tpl->assign(REFRESH_VALUE => encode_entities(apr()->param('refresh')));
		    $tpl->assign(RETRY_VALUE => encode_entities(apr()->param('retry')));
		    $tpl->assign(EXPIRE_VALUE => encode_entities(apr()->param('expire')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('default_ttl')));
		    
		    my ($auth_ns, $serial) = $dbh->get_authns_serial($dom_id);

		    $tpl->assign(AUTH_NS_VALUE => $auth_ns);
		    $tpl->assign(SERIAL_VALUE => $serial);

		    my $error_text = $lang{ERROR_CORRECT};

		    if (!check_ttl($refresh)) {
			$tpl->assign(REFRESH => qq{<font color="red">} . $lang{REFRESH} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_REFRESH}};
		    }
		    if (!check_ttl($retry)) {
			$tpl->assign(RETRY => qq{<font color="red">} . $lang{RETRY} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_RETRY}};
		    }
		    if (!check_ttl($expire)) {
			$tpl->assign(EXPIRE => qq{<font color="red">} . $lang{EXPIRE} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_EXPIRE}};
		    }
		    if (!check_ttl($default_ttl)) {
			$tpl->assign(TTL => qq{<font color="red">} . $lang{TTL} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_TTL}};
		    }
		    
		    if (!($soa_email = check_email($soa_email))) {
			$tpl->assign(ADMIN_EMAIL => qq{<font color="red">} . $lang{ADMIN_EMAIL} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_ADMIN_EMAIL}};
		    }
		    if ($soa_email =~ /\..*?\@/) { 
			# is there a dot before the @ => invalid for a soa email
			$tpl->assign(ADMIN_EMAIL => qq{<font color="red">} . $lang{ADMIN_EMAIL} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_ADMIN_EMAIL}};
		    } 
		    
		    $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 (/^A$/) { 
		# 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 $ip = apr()->param('ip');
		if (!($ip = check_ip($ip))) {
		    $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_A($dom_id, $record_id, $host, $ip)) {
		    # 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_A($dom_id, $record_id, $host, $ip, $ttl)) {
			if (dns_update_A($dom_id, $record_id, $host, $ip, $ttl)) {
			    Debug(2, qq{dns_update_A succeded\n});
			} else {
			    Debug(2, qq{dns_update_A 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 => '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}};
		    }
		    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(IPV6_ADDRESS => qq{<font color="red">} . $lang{IPV6_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 (/^CNAME$/) { 
		my $all_set = 1;
                my $host = "";
		if (!($host = check_fqdn(apr()->param('host'), $domain))) {
		    $all_set = 0;
		}
		my $cname = apr()->param('cname');
		if (!check_cname_host($cname)) {
		    $all_set = 0;
		}
		my $ttl = apr()->param('ttl');
		if (!check_ttl($ttl)) {
		    $all_set = 0;
		}
		# do the update dance!
		if ($all_set && check_before_edit_CNAME($dom_id, $record_id, $host, $cname)) {
		    # 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_CNAME($dom_id, $record_id, $host, $cname, $ttl)) {
			if (dns_update_CNAME($dom_id, $record_id, $host, $cname, $ttl)) {
			    Debug(2, qq{dns_update_CNAME succeded\n});
			} else {
			    Debug(2, qq{dns_update_CNAME 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 => 'cname/edit.tpl');
		    $tpl->assign(HOST_VALUE => encode_entities(apr()->param('host')));
		    $tpl->assign(CNAME_VALUE => encode_entities(apr()->param('cname')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));

		    my $error_text = $lang{ERROR_CORRECT};

		    if (!check_cname_host($cname)) {
			$tpl->assign(CNAME => qq{<font color="red">} . $lang{CNAME} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_CNAME}};
		    }
		    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(CNAME => qq{<font color="red">} . $lang{CNAME} . 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 (/^MX$/) { 
		my $all_set = 1;
		my $host = "";
		if (!($host = check_fqdn(apr()->param('host'), $domain))) {
		    $all_set = 0;
		}
		my $exchanger = apr()->param('exchanger');
		if (!check_exchanger($exchanger)) {
		    $all_set = 0;
		}
		my $preference = apr()->param('preference');
		if (!check_preference($preference)) { 
		    $all_set = 0;
		}
		my $ttl = apr()->param('ttl');
		if (!check_ttl($ttl)) {
		    $all_set = 0;
		}
		if ($all_set && check_before_edit_MX($dom_id, $record_id, $host, $exchanger, $preference)) {
		    if (is_updated_MX($dom_id, $record_id, $host, $exchanger, $preference, $ttl)) {
                        if (dns_update_MX($dom_id, $record_id, $host, $exchanger, $preference, $ttl)) {
			    Debug(2, qq{dns_update_MX succeded\n});
			} else {
			    Debug(2, qq{dns_update_MX 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 => 'mx/edit.tpl');
		    $tpl->assign(HOST_VALUE => encode_entities(apr()->param('host')));
		    $tpl->assign(MX_VALUE => encode_entities(apr()->param('exchanger')));
		    $tpl->assign(PREFERENCE_VALUE => encode_entities(apr()->param('preference')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));

                    my $error_text = $lang{ERROR_CORRECT};

		    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_exchanger($exchanger)) {
			$tpl->assign(MX => qq{<font color="red">} . $lang{MX} . qq{</font>});
                        $error_text .= qq{<br>$lang{ERROR_MX}};
		    }
		    if (!check_preference($preference)) {
			$tpl->assign(PREFERENCE => qq{<font color="red">} . $lang{PREFERENCE} . qq{</font>});
                        $error_text .= qq{<br>$lang{ERROR_PREFERENCE}};
		    }
		    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(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
			$tpl->assign(PREFERENCE => qq{<font color="red">} . $lang{PREFERENCE} . 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(${$tpl->fetch("MAIN")});	

                    $dbh->close();
		    return OK;
		}
	    }
	    elsif (/^NS$/) { 
		my $all_set = 1;
		my $zone = "";
		if (!($zone = check_fqdn_ns(apr()->param('zone'), $domain))) {
		    $all_set = 0;
		}
		my $nameserver = apr()->param('nsdname');
		if (!check_nameserver($nameserver)) {
		    $all_set = 0;
		}
		my $ttl = apr()->param('ttl');
		if (!check_ttl($ttl)) {
		    $all_set = 0;
		}
		if ($all_set && check_before_edit_NS($dom_id, $record_id, $zone, $nameserver)) {
		    if (is_updated_NS($dom_id, $record_id, $zone, $nameserver, $ttl)) {
			if (dns_update_NS($dom_id, $record_id, $zone, $nameserver, $ttl)) {
			    Debug(2, qq{dns_update_NS succeded\n});
                        } else {
			    Debug(2, qq{dns_update_NS failed\n});
                        }
                    } else {
			Debug(2, qq{Dns record not changed so not updating\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 => 'ns/edit.tpl');
		    $tpl->assign(HOST_VALUE => encode_entities(apr()->param('zone')));
		    $tpl->assign(NS_VALUE => encode_entities(apr()->param('nsdname')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));

		    my $error_text = $lang{ERROR_CORRECT};

		    if (!($zone = check_fqdn_ns(apr()->param('zone'), $domain))) {
			$tpl->assign(ZONE => qq{<font color="red">} . $lang{ZONE} . qq{</font>});
                        $error_text .= qq{<br>$lang{ERROR_ZONE}};
		    }
		    if (!check_nameserver($nameserver)) {
			$tpl->assign(NS => qq{<font color="red">} . $lang{NS} . qq{</font>});
                        $error_text .= qq{<br>$lang{ERROR_NS}};
		    }
		    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(ZONE => qq{<font color="red">} . $lang{ZONE} . qq{</font>});
			$tpl->assign(NS => qq{<font color="red">} . $lang{NS} . 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 (/^PTR$/) { 
		# 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 $reverse = apr()->param('host');
		if (!(check_host($reverse))) {
		    $all_set = 0;
		}
		my $host = "";
		if (!($host = check_reverse(apr()->param('reverse'), $domain))) {
		    $all_set = 0;
		}
		my $ttl = apr()->param('ttl');
		if (!check_ttl($ttl)) {
		    $all_set = 0;
		}
		if ($all_set && check_before_edit_PTR($dom_id, $record_id, $host, $reverse)) {
		    # 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_PTR($dom_id, $record_id, $host, $reverse, $ttl)) {
			if (dns_update_PTR($dom_id, $record_id, $host, $reverse, $ttl)) {
			    Debug(2, qq{dns_update_PTR succeded\n});
			} else {
			    Debug(2, qq{dns_update_PTR 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 => 'ptr/edit.tpl');
		    $tpl->assign(HOST_VALUE => encode_entities(apr()->param('host'))); # maybe it needs to fully qualify it if it was okay?
		    $tpl->assign(REVERSE_HOST_VALUE => encode_entities(apr()->param('reverse')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));

		    # do the red-marker assignment

		    my $error_text = $lang{ERROR_CORRECT};

		    if (!(check_host(apr()->param('host')))) {
			$tpl->assign(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_IP}};
		    }
		    if (!($host = check_reverse(apr()->param('reverse'), $domain))) {
			$tpl->assign(REVERSE_HOST => qq{<font color="red">} . $lang{REVERSE_HOST} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_REVERSE}};
		    }
		    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(REVERSE_HOST => qq{<font color="red">} . $lang{REVERSE_HOST} . 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 (/^TXT$/) { 
		my $all_set = 1;
		my $host = "";
		if (!($host = check_fqdn(apr()->param('host'), $domain))) {
		    $all_set = 0;
		}
		my $txtdata = apr()->param('txtdata');
		if (!check_txt($txtdata)) {
		    $all_set = 0;
		}
		my $ttl = apr()->param('ttl');
		if (!check_ttl($ttl)) {
		    $all_set = 0;
		}
		if ($all_set && check_before_edit_TXT($dom_id, $record_id, $host, $txtdata)) {
		    if (is_updated_TXT($dom_id, $record_id, $host, $txtdata, $ttl)) {
			if (dns_update_TXT($dom_id, $record_id, $host, $txtdata, $ttl)) {
			    Debug(2, qq{dns_update_TXT succeded\n});
			} else {
			    Debug(2, qq{dns_update_TXT failed\n});
			}
		    } else {
			Debug(2, qq{Dns record not changed so not updating\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 => 'txt/edit.tpl');
		    $tpl->assign(HOST_VALUE => encode_entities(apr()->param('host')));
		    $tpl->assign(TXT_VALUE => encode_entities(apr()->param('txtdata')));
		    $tpl->assign(TTL_VALUE => encode_entities(apr()->param('ttl')));

		    my $error_text = $lang{ERROR_CORRECT};

		    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_txt($txtdata)) {
			$tpl->assign(TXT => qq{<font color="red">} . $lang{TXT} . qq{</font>});
			$error_text .= qq{<br>$lang{ERROR_TXT}};
		    }
		    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(HOST => qq{<font color="red">} . $lang{HOST} . qq{</font>});
			$tpl->assign(TXT => qq{<font color="red">} . $lang{TXT} . 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");



( run in 1.805 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )