+ $error = "Error: $error" if $error;
+
+ print $cgi->header( '-expires' => 'now' ),
+ $signup_template->fill_in();
+
+}
+
+sub print_decline {
+ print $cgi->header( '-expires' => 'now' ),
+ $decline_template->fill_in();
+}
+
+sub print_okay {
+ my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
+
+ $cgi->param('username') =~ /^(.+)$/
+ or die "fatal: invalid username got past FS::SignupClient::new_customer";
+ my $username = $1;
+ $cgi->param('_password') =~ /^(.+)$/
+ or die "fatal: invalid password got past FS::SignupClient::new_customer";
+ my $password = $1;
+ ( $cgi->param('first'). ' '. $cgi->param('last') ) =~ /^(.*)$/
+ or die "fatal: invalid email_name got past FS::SignupClient::new_customer";
+ $email_name = $1; #global for template
+
+ my $pop = pop_info($cgi->param('popnum'));
+ #or die "fatal: invalid popnum got past FS::SignupClient::new_customer";
+ if ( $pop ) {
+ ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} );
+ } else {
+ ( $ac, $exch, $loc ) = ( '', '', ''); #presumably you're not using them.
+ }
+
+ #global for template
+ $pkg = ( grep { $_->{'pkgpart'} eq $pkgpart } @$packages )[0]->{'pkg'};
+
+ if ( $ieak_template
+ && $user_agent->platform eq 'ia32'
+ && $user_agent->os =~ /^win/
+ && ($user_agent->browser)[0] eq 'IE'
+ )
+ { #send an IEAK config
+ print $cgi->header('application/x-Internet-signup'),
+ $ieak_template->fill_in();
+ } elsif ( $cck_template
+ && $user_agent->platform eq 'ia32'
+ && $user_agent->os =~ /^win/
+ && ($user_agent->browser)[0] eq 'Netscape'
+ )
+ { #send a Netscape config
+ my $cck_data = $cck_template->fill_in();
+ print $cgi->header('application/x-netscape-autoconfigure-dialer-v2'),
+ map {
+ m/(.*)\s+(.*)$/;
+ pack("N", length($1)). $1. pack("N", length($2)). $2;
+ } split(/\n/, $cck_data);
+
+ } else { #send a simple confirmation
+ print $cgi->header( '-expires' => 'now' ),
+ $success_template->fill_in();
+ }
+}
+
+sub pop_info {
+ my $popnum = shift;
+ my $pop;
+ foreach $pop ( @{$pops} ) {
+ if ( $pop->{'popnum'} == $popnum ) { return $pop; }
+ }
+ '';
+}
+
+#horrible false laziness with FS/FS/svc_acct_pop.pm::popselector
+sub popselector {
+ my( $popnum, $state ) = @_;
+
+ return '<INPUT TYPE="hidden" NAME="popnum" VALUE="">' unless @$pops;
+ return $pops->[0]{city}. ', '. $pops->[0]{state}.
+ ' ('. $pops->[0]{ac}. ')/'. $pops->[0]{exch}.
+ '<INPUT TYPE="hidden" NAME="popnum" VALUE="'. $pops->[0]{popnum}. '">'
+ if scalar(@$pops) == 1;
+
+ my %pop = ();
+ push @{ $pop{$_->{state}} }, $_ foreach @$pops;
+
+ my $text = <<END;
+ <SCRIPT>
+ function opt(what,href,text) {
+ var optionName = new Option(text, href, false, false)
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function popstate_changed(what) {
+ state = what.options[what.selectedIndex].text;
+ for (var i = what.form.popnum.length;i > 0;i--)
+ what.form.popnum.options[i] = null;
+ what.form.popnum.options[0] = new Option("", "", false, true);