Apache-DnsZone

 view release on metacpan or  search on metacpan

TODO  view on Meta::CPAN

[Fixed] || Apache->request on all handlers
[Fixed] redo global vars shit! instead of $DnsZone::whatever, just have a global my $whatever
[Fixed] Ability to set a default language for login page? (DnsZoneLoginLang); Default login language!!
[Fixed] cookie stuff error codes in language files uc(cookiereturn)
[Fixed] Implement own Apache::AuthCookie derivate with templates! (use Apache::(AuthTicket|AuthCookieDBI) as examples)
[Fixed] TimeOut of cookie + 15 minute renewal of each cookie! If not done anything for the last 15 minutes and request another page => re-login; subclass of Apache::AuthCookie; Needs to take defaults from Apache::DnsZone::Config
[Fixed] Login template needs to be unfucked!
[Fixed] Maybe a layer above the menu system so that menus and stuff wont be on login page?
[Fixed] Template system outputter (so menu will only be shown on non-login page && list_domains (maybe even show all the domains you have in the url?))
[Fixed] logout?
[Fixed] is_updated_SOA? (Is SOA updated in edit submit request)
[Fixed] GET/POST where? POST => when submitting forms to avoid 4K limit
[Fixed] is_updated_* ttl eq and not == ?
[Fixed] which pages need caching and which don't? All pages should have caching turned off so no pages will be in cache if user is not authenticated
[Fixed] Settings, Logout, Menu, List domain texts! Menu with list_domains and settings and logout (if appropriate)
[Fixed] SSL - why would there be any issues with using ssl?
[Fixed] Login page language should use Accept-Language header if existing in the db otherwise the Login page language from the configuration. (Netscape can change this in preferences for navigator)
[Fixed] DnsZone::Debug needs to be worked on && export Debug from DnsZone.pm && get rid of DnsZone::Debug
[Fixed] Update SQL to include authentication tables
[Fixed] Install documentation
[Fixed] $VERSION in all files: ($VERSION) = qq$Revision: 1.23 $ =~ /([\d\.]+)/;
[Fixed] Remove old data in sql/mysql.sql
[Fixed] Check_before needs Debug?

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


    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;
}

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

    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;
}

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

    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;
}

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

    }
    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;
}

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

    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;
}

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

    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;
}

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

    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;
}

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

    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;
}

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

		    $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 {

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

		}
		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 {

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

		}
		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 {

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

		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 {

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

		}
		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 {

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

		}
		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});

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

		}
		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 {

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

		}
		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});



( run in 0.944 second using v1.01-cache-2.11-cpan-05444aca049 )