#!/usr/bin/perl # .Copyright (C) 1999-2002 TUCOWS.com Inc. # .Created: 11/19/1999 # .Contactid: # .Url: http://www.opensrs.org # .Originally Developed by: # VPOP Technologies, Inc. for Tucows/OpenSRS # .Authors: Joe McDonald, Tom McDonald, Matt Reimer, Brad Hilton, # Daniel Manley, Evgeniy Pirogov # # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use vars qw( %in $cgi $path_templates %actions $action %cc_types $XML_Client %contact_keys %data %cc_mons @cc_types ); ( %in, $cgi, $path_templates, %actions, $action, %cc_mons, %cc_types, $XML_Client, %contact_keys, %data ) = (); # pull in conf file with defined values # XXX NOTE XXX Update this configuration file BEGIN { do "/home/koreainternic/OpenSRS.conf"; } use strict; use lib $PATH_LIB; use CGI ':cgi-lib'; use RACE; RACE::Initialise(%RACESETTINGS); RACE::UseRace($USE_RACE); use OpenSRS::XML_Client qw(:default); use OpenSRS::Util::Common qw(send_email build_select_menu build_select_menu3 build_country_list); use OpenSRS::Util::America qw(build_app_purpose_list); # global defines $cgi = $ENV{SCRIPT_NAME}; $path_templates = "$PATH_TEMPLATES/reg_system"; %in = (); # list of valid actions to execute %actions = ( lookup => undef, check_transfer => undef, setup_profile => undef, do_setup_profile => undef, verify_order => undef, register => undef, bulk_order => undef, bulk_order_ca => undef, bulk_order_us => undef, bulk_transfer => undef, do_bulk_transfer => undef, purchase_webcert => undef, verify_purchase_webcert => undef, do_purchase_webcert => undef, ); %cc_types = ( visa => "Visa", mastercard => "Mastercard", amex => "American Express", discover => "Discover", ); @cc_types = qw (visa mastercard amex discover); %cc_mons = (1=>"01", 2=>"02", 3=>"03", 4=>"04", 5=>"05", 6=>"06", 7=>"07", 8=>"08",9=>"09",10=>"10",11=>"11",12=>"12",); %contact_keys = ( first_name => undef, last_name => undef, address1 => undef, address2 => undef, address3 => undef, city => undef, state => undef, postal_code => undef, country => undef, email => undef, url => undef, fax => undef, phone => undef, org_name => undef, ); ############################################### ############################################### print "Content-type: text/html\n\n"; # set debugging level start_up(); # create a client object which we will use to connect to the OpenSRS server $XML_Client = new OpenSRS::XML_Client(%OPENSRS); $XML_Client->login; # read in the form data ReadParse(\%in); $action = $in{action}; # no action was supplied, so use the default if (not $action) { main_menu(); # they passed a valid action } elsif (exists $actions{$action}) { no strict "refs"; &$action(); use strict; # they passed an invalid action } else { main_menu("Invalid action: $action"); } # close connection to the server $XML_Client->logout; exit; #################################################################### ### Begin subroutines ################################################################### ###################################################### ## First, subroutines you may wish to adjust... ##################################################### sub start_up { if ($REG_SYSTEM{debug}) { # print error to the page select (STDOUT); $| = 1; open (STDERR, ">&STDOUT") or die "Can't dump stdout: $!\n"; select (STDERR); $| = 1; select (STDOUT); } OpenSRS::Util::Common::initialize(path_templates => $PATH_TEMPLATES); } sub main_menu { my (%HTML, $mldns); # no action was specified, so print main page $HTML{CGI} = $cgi; $HTML{affiliate_id} = $in{affiliate_id}; # # MLDNS requires extra stuff... # #createMLDNSHTMLLink (\%HTML); print_form("$path_templates/main_menu.html",\%HTML); } sub verify_order { # check fields for proper data my ($key,$cleaned_value,$error_msg,$domain_string,$domain,@domains); my (%good_domains,%bad_domains,%domains,$type,$field,$num,$fqdn,$nameservers); my ($raceObj, $originalDomain, $formCountry); my %converted_good_domains; my ($lookup_data); my $cc_num = $in{p_cc_num}; my $cc_type = $in{p_cc_type}; my $cc_exp_mon = $in{p_cc_exp_mon}; my $cc_exp_yr = $in{p_cc_exp_yr}; ################################################################## # here we check the validity of the cc_number, both its length # and its validity # only run this test if you set F_VERIFY_CC in conf file if ($REG_SYSTEM{F_VERIFY_CC}) { # check the cc number if (not cc_verify($cc_num)) { error_out("Invalid credit card number.\n"); exit; } # check the expiration date if (not cc_exp_verify($cc_exp_mon,$cc_exp_yr)) { error_out("Invalid credit card expiration: $cc_exp_mon/$cc_exp_yr.\n"); exit; } } # check for reg_username and reg_password if (not $in{reg_username}) { error_out("No username supplied"); exit; } elsif (not $in{reg_password}) { error_out("No password supplied"); exit; } elsif (defined $in{reg_password_confirm} and $in{reg_password} ne $in{reg_password_confirm}) { error_out("Password mismatch"); exit; } ################################################################## ################################################################## ################################### # check syntax on domains given if this is a bulk order my ($gtld,$ca,$uk,$us); my $mldn = 0; my $ascii = 0; if ($in{bulk_order}) { # this is a bulk order my $domains = $in{domains}; my $syntaxError = undef; $domains =~ s/\r//g; $domains =~ s/\n/ /g; $domains =~ s/,/ /g; @domains = split /\s+/, $domains; $error_msg = ""; foreach $domain (@domains) { # # check for duplicates # if (exists $domains{$domain}) { $bad_domains{$domain} = "Duplicate domain."; next; } $raceObj = RACE::DoRACE (Domain => $domain, EncodingType => $UNIVERSAL_ENCODING_TYPE); $raceObj->{ConvertedDomain} = lc $raceObj->{ConvertedDomain}; if ($raceObj->{DomainConverted} == 1) { $mldn = 1; } else { $ascii = 1; } $gtld = $gtld || $raceObj->{ConvertedDomain} =~ /(com|net|org)$/i; $ca = $ca || $raceObj->{ConvertedDomain} =~ /ca$/i; $us = $us || $raceObj->{ConvertedDomain} =~ /us$/i; $uk = $uk || $raceObj->{ConvertedDomain} =~ /uk$/i; # # Check syntax. # if ($syntaxError = check_domain_syntax($raceObj->{ConvertedDomain})) { $bad_domains{$originalDomain} = $syntaxError; next; } if ( $raceObj->{ConvertedDomain} =~ /\.tv$/i ) { $bad_domains{$originalDomain} = '.tv domains are not supported for bulk orders.'; next; } $lookup_data = { action => "lookup", object => "domain", attributes => { domain => $domain, affiliate_id => $in{affiliate_id}, } }; # add the domain to the hash to check for duplicates $domains{$domain} = 1; if ($in{reg_type} eq 'new') { my $lookup_results = $XML_Client->send_cmd( $lookup_data ); if ($lookup_results->{attributes}->{status} eq 'taken') { $bad_domains{$domain} = "Domain taken."; next; } if ($lookup_results->{attributes}->{status} eq 'invalid') { unless ($F_QUEUE_SUPPLIER_UNAVAILABLE) { $bad_domains{$domain} = "Error checking domain [".$lookup_results->{response_text}."]."; next; } } } else { $lookup_data->{action} = "check_transfer"; $lookup_data->{object} = "domain"; my $lookup_results = $XML_Client->send_cmd( $lookup_data ); if ($lookup_results && $lookup_results->{is_success} == 1) { if ( $lookup_results->{attributes}->{transferrable} != 1 and !( $lookup_results->{attributes}->{noservice} and $F_QUEUE_SUPPLIER_UNAVAILABLE ) ) { $bad_domains{$domain} = "Domain not transferable: $lookup_results->{attributes}->{reason}."; next; } } else { $bad_domains{$domain} = "Domain not transferable: Error in check transfer [$lookup_results->{response_text}]."; next; } } $good_domains{$domain} = 1; } if ( $ascii and $mldn and $in{ reg_type } eq 'transfer' ) { $error_msg = "Bulk transfer requests cannot contain both ASCII and multi-lingual domains"; } if ($ca and ($gtld or $uk or $us)){ $error_msg = "You can't mix .ca with gTLD or .uk domains in bulk_registration"; } if ($us and ($gtld or $uk or $ca)){ $error_msg = "You can't mix .us with gTLD, .ca or .uk domains in bulk_registration"; } if ($ca and $in{reg_domain} !~ /ca$/i and $in{reg_type} eq 'new'){ $error_msg = "Bulk registration for .ca must be based on a previously registered .ca domain"; } # if they didn't provide any good domains, error out now if (not keys %good_domains and keys %bad_domains) { $error_msg = join("", map { "$_: $bad_domains{$_}
\n" } keys %bad_domains); } if ($error_msg) { error_out($error_msg); exit; } } else { # this isn't a bulk order, but we still need to allow for a person # registering multiple domains with different tlds %good_domains = map { $_, 1 } split /\0/, $in{domain}; map { $gtld = $gtld || $_ =~ /(com|net|org|info|biz)$/i; $ca = $ca || $_ =~ /ca$/i; $uk = $uk || $_ =~ /uk$/i; $us = $us || $_ =~ /us$/i; } keys %good_domains; if ($ca and ($gtld or $uk or $us)){ error_out("You can't mix .ca with gTLD, .us, or .uk domains in bulk_registration"); exit; } elsif ($us and ($gtld or $uk or $ca)){ error_out("You can't mix .us with gTLD, .ca, or .uk domains in bulk_registration"); exit; } elsif ( $ca and $in{reg_type} eq 'new' ) { # for .ca domains, ensure a valid legal type was given if ( $in{ legal_type } eq '' ) { error_out( 'No legal type selected' ); exit; } if ( not exists $CA_LEGAL_TYPES{ $in{ legal_type } } ) { error_out( 'Invalid legal type selected.' ); exit; } } # .us validation for nexus is done in XML_Client::validate() } foreach $domain (keys %good_domains) { $domain_string .= "\n"; } if ($in{email_bundle}) { $domain_string .= "\n"; } my %HTML = %in; if ( ( not $in{reg_type} eq 'transfer' ) or ( not $ca ) ) { # do not check transfer for .ca # copy over the normal contact info to 'admin', 'billing' and/or 'tech' info # if they had that flag set if (defined $in{flag_admin_use_contact_info} and $in{flag_admin_use_contact_info}) { foreach $key (keys %in) { if ($key =~ /^admin_(.+)$/) { $in{"admin_$1"} = $in{"owner_$1"}; $HTML{$key} = $in{"owner_$1"}; } } } if (defined $in{flag_billing_use_contact_info} and $in{flag_billing_use_contact_info}) { foreach $key (keys %in) { if ($key =~ /^billing_(.+)$/) { $in{"billing_$1"} = $in{"owner_$1"}; $HTML{$key} = $in{"owner_$1"}; } } } elsif (defined $in{flag_billing_use_admin_info} and $in{flag_billing_use_admin_info}){ foreach $key (keys %in) { if ($key =~ /^billing_(.+)$/) { $in{"billing_$1"} = $in{"admin_$1"}; $HTML{$key} = $in{"admin_$1"}; } } } if ($REG_SYSTEM{custom_tech_contact}){ if (defined $in{flag_tech_use_contact_info} and $in{flag_tech_use_contact_info}) { foreach $key (keys %in) { if ($key =~ /^tech_(.+)$/) { $HTML{$key} = $in{"owner_$1"}; } } } elsif (defined $in{flag_tech_use_admin_info} and $in{flag_tech_use_admin_info}) { foreach $key (keys %in) { if ($key =~ /^tech_(.+)$/) { $HTML{$key} = $in{"admin_$1"}; } } } elsif (defined $in{flag_tech_use_billing_info} and $in{flag_tech_use_billing_info}) { foreach $key (keys %in) { if ($key =~ /^tech_(.+)$/) { $HTML{$key} = $in{"billing_$1"}; } } } } # use library to verify the supplied data my ($custom_nameservers); if ($in{reg_type} eq 'new' and $REG_SYSTEM{custom_nameservers}) { $custom_nameservers = 1; } else { $custom_nameservers = 0; } # insert the domains into $HTML{domain} for the validation code below foreach my $dom (keys %good_domains) { my $hashRef = RACE::DoRACE (Domain => $dom, EncodingType => $UNIVERSAL_ENCODING_TYPE); if (! defined $hashRef->{ConvertedDomain}) { error_out ("Domain $dom contains illegal characters."); exit; } $converted_good_domains{$hashRef->{ConvertedDomain}} = 1; } $HTML{domain} = join "\0", keys %converted_good_domains; my $custom_verify='default'; if ($ca) { $custom_verify='ca'; } my %verify_results = $XML_Client->validate(\%HTML, custom_tech_contact => $REG_SYSTEM{custom_tech_contact}, custom_nameservers => $custom_nameservers,custom_verify => $custom_verify ); if (not $verify_results{is_success}) { # there were problems with submitted data... $error_msg = $verify_results{error_msg}; error_out($error_msg); exit; } # everything looks in order... so far... # pass along the tech contact info if the conf file tells us to # use %HTML so that "flag_tech_use_contact_info" is applied if ($REG_SYSTEM{custom_tech_contact}) { $HTML{TECH_CONTACT} = build_tech_verify(\%HTML); } # add 'tech' as a contact type if the conf file has that defined my @contact_types = ('owner','admin','billing'); if ($REG_SYSTEM{custom_tech_contact}) { push @contact_types, 'tech'; } # encode the contact info and pass it to the next form foreach $type (@contact_types) { foreach $field (qw(first_name last_name org_name address1 address2 address3 city state postal_code country email phone fax)) { $HTML{CONTACT_INFO} .= "\n"; } } # make the display of this data look a little better if ($HTML{owner_address2}) { $HTML{owner_address2} .= "
\n" } if ($HTML{owner_address3}) { $HTML{owner_address3} .= "
\n" } if ($HTML{billing_address2}) { $HTML{billing_address2} .= "
\n" } if ($HTML{billing_address3}) { $HTML{billing_address3} .= "
\n" } # encode the nameserver info and pass it to the next form if ($custom_nameservers) { foreach $num (1..6) { $fqdn = $in{"fqdn$num"}; if ($fqdn) { $nameservers .= "$fqdn
\n"; $HTML{NAMESERVER_INFO} .= " $fqdn, EncodingType => $UNIVERSAL_ENCODING_TYPE)->{ConvertedDomain}) . "\">\n"; } } $HTML{NAMESERVERS} = <Nameserver Information $nameservers EOF } if ($REG_SYSTEM{allow_auto_renew}) { $HTML{BILLING_INFO} .= "\n"; } } # encode the billing info and pass it to the next form $HTML{BILLING_INFO} .= "\n"; $HTML{BILLING_INFO} .= "\n"; $HTML{BILLING_INFO} .= "\n"; $HTML{BILLING_INFO} .= "\n"; # display the cc_type using our %cc_types hash at the top of the # script $HTML{p_cc_type} = $cc_types{$in{p_cc_type}}; $HTML{domains} = join("
\n", keys %good_domains); $HTML{forwarding_email} = $in{forwarding_email}; if (keys %bad_domains) { $HTML{bad_domains} = "Invalid Domains:
\n" . join("", map { "$_: $bad_domains{$_}
\n" } keys %bad_domains) . "
\n";; } $HTML{domain_string} = $domain_string; $HTML{CGI} = $cgi; $HTML{affiliate_id} = $in{affiliate_id}; $HTML{period_text} = $REG_PERIODS{$in{period}}; $HTML{reg_username} = encode($in{reg_username}); $HTML{reg_password} = encode($in{reg_password}); $HTML{reg_domain} = encode($in{reg_domain}); $HTML{reg_type} = $in{reg_type}; if ($REG_SYSTEM{allow_auto_renew}) { my $renew_value = $in{auto_renew} ? 'Yes':'No'; $HTML{auto_renew_section} = < Auto-renew: $renew_value EOF } if ($in{reg_type} eq 'new') { if ( $MANAGE{ allow_domain_locking }) { my $lock_value = $in{ f_lock_domain } ? 'Yes' : 'No'; $HTML{ domain_locking_section } = < Lock domain: $lock_value EOF } $HTML{reg_type_text} = 'New Domain'; $HTML{action} = 'register'; } else { if ($in{bulk_order}) { $HTML{reg_type_text} = 'Batch Transfer'; $HTML{ mldn } = $mldn || 0; $HTML{action} = 'do_bulk_transfer'; } else { $HTML{reg_type_text} = 'Transfer'; $HTML{action} = 'register'; } } if ( $ca and $in{reg_type} eq 'transfer') { print_form("$path_templates/verify_ca_transfer.html",\%HTML); return; } if ( $ca ) { $formCountry = "_ca"; $HTML{isa_trademark} = $in{isa_trademark} ? "Yes" : "No"; $HTML{want_cira_member} = $in{cira_member} eq 'Y' ? "Yes" : "No"; $HTML{domain_description} = $in{domain_description} ? $in{domain_description} : "-none-"; $HTML{domain_description} =~ s/\n/
/g; $HTML{legal_type} = $CA_LEGAL_TYPES{$in{legal_type}}; $HTML{lang_pref} = ( $in{lang_pref} eq "EN" ) ? "English" : "Français"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; } elsif ( $us ) { my $ccodes; $formCountry = "_us"; $HTML{app_purpose} = $OpenSRS::Util::America::america_application_purposes{$in{app_purpose}}; $HTML{nexus_category} = $OpenSRS::Util::America::america_nexus_categories{$in{nexus_category}}; if ( $in{nexus_validator} ) { $HTML{nexus_validator} = $in{nexus_validator}; $HTML{nexus_validator} .= " - ".OpenSRS::Util::Common::CODE_2_Country($in{nexus_validator}); } else { $HTML{nexus_validator} = "Not Applicable"; } $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; $HTML{SPECIAL_DOMAIN_INFO} .= '\n"; } elsif ( $in{domain} =~ /name$/ && $in{email_bundle} == 1) { $formCountry = "_name"; } else { $formCountry = ""; } print_form("$path_templates/verify$formCountry.html",\%HTML); } ######################################################## # dynamically build all .ca legal types. sub build_ca_domain_legal_types { my $type = shift; my ($selected, $key); $selected = $type ? "" : "selected"; my $string = qq(