a7118ed2bee676301f7315774c65d966271d89fc
[freeside.git] / fs_signup / FS-SignupClient / cgi / signup.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: signup.cgi,v 1.23 2002-04-17 12:14:37 ivan Exp $
4
5 use strict;
6 use vars qw( @payby $cgi $locales $packages $pops $init_data $error
7              $last $first $ss $company $address1 $address2 $city $state $county
8              $country $zip $daytime $night $fax $invoicing_list $payby $payinfo
9              $paydate $payname $referral_custnum
10              $pkgpart $username $password $password2 $sec_phrase $popnum
11              $agentnum
12              $ieak_file $ieak_template $cck_file $cck_template
13              $signup_html $signup_template $success_html $success_template
14              $ac $exch $loc
15              $self_url
16            );
17 use subs qw( print_form print_okay expselect signup_default success_default );
18 use CGI;
19 #use CGI::Carp qw(fatalsToBrowser);
20 use Text::Template;
21 use Business::CreditCard;
22 use HTTP::Headers::UserAgent 2.00;
23 use FS::SignupClient 0.03 qw( signup_info new_customer );
24
25 #acceptable payment methods
26 #
27 #@payby = qw( CARD BILL COMP );
28 #@payby = qw( CARD BILL );
29 #@payby = qw( CARD );
30 @payby = qw( CARD PREPAY );
31
32 $ieak_file = '/usr/local/freeside/ieak.template';
33 $cck_file = '/usr/local/freeside/cck.template';
34 $signup_html = -e 'signup.html'
35                  ? 'signup.html'
36                  : '/usr/local/freeside/signup.html';
37 $success_html = -e 'success.html'
38                   ? 'success.html'
39                   : '/usr/local/freeside/success.html';
40
41 if ( -e $ieak_file ) {
42   my $ieak_txt = Text::Template::_load_text($ieak_file)
43     or die $Text::Template::ERROR;
44   $ieak_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
45   $ieak_txt = $1;
46   $ieak_template = new Text::Template ( TYPE => 'STRING', SOURCE => $ieak_txt )
47     or die $Text::Template::ERROR;
48 } else {
49   $ieak_template = '';
50 }
51
52 if ( -e $cck_file ) {
53   my $cck_txt = Text::Template::_load_text($cck_file)
54     or die $Text::Template::ERROR;
55   $cck_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
56   $cck_txt = $1;
57   $cck_template = new Text::Template ( TYPE => 'STRING', SOURCE => $cck_txt )
58     or die $Text::Template::ERROR;
59 } else {
60   $cck_template = '';
61 }
62
63 if ( -e $signup_html ) {
64   my $signup_txt = Text::Template::_load_text($signup_html)
65     or die $Text::Template::ERROR;
66   $signup_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
67   $signup_txt = $1;
68   $signup_template = new Text::Template ( TYPE => 'STRING',
69                                           SOURCE => $signup_txt,
70                                           DELIMITERS => [ '<%=', '%>' ]
71                                         )
72     or die $Text::Template::ERROR;
73 } else {
74   $signup_template = new Text::Template ( TYPE => 'STRING',
75                                           SOURCE => &signup_default,
76                                           DELIMITERS => [ '<%=', '%>' ]
77                                         )
78     or die $Text::Template::ERROR;
79 }
80
81 if ( -e $success_html ) {
82   my $success_txt = Text::Template::_load_text($success_html)
83     or die $Text::Template::ERROR;
84   $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
85   $success_txt = $1;
86   $success_template = new Text::Template ( TYPE => 'STRING',
87                                            SOURCE => $success_txt,
88                                            DELIMITERS => [ '<%=', '%>' ],
89                                          )
90     or die $Text::Template::ERROR;
91 } else {
92   $success_template = new Text::Template ( TYPE => 'STRING',
93                                            SOURCE => &success_default,
94                                            DELIMITERS => [ '<%=', '%>' ],
95                                          )
96     or die $Text::Template::ERROR;
97 }
98
99 ( $locales, $packages, $pops, $init_data ) = signup_info();
100 @payby = @{$init_data->{'payby'}} if @{$init_data->{'payby'}};
101
102 $cgi = new CGI;
103
104 if ( defined $cgi->param('magic') ) {
105   if ( $cgi->param('magic') eq 'process' ) {
106
107     $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/
108       or die "Oops, illegal \"state\" param: ". $cgi->param('state');
109     $state = $1;
110     $county = $3 || '';
111     $country = $4;
112
113     $payby = $cgi->param('payby');
114     $payinfo = $cgi->param( $payby. '_payinfo' );
115     $paydate =
116       $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' );
117     $payname = $cgi->param( $payby. '_payname' );
118
119     if ( $invoicing_list = $cgi->param('invoicing_list') ) {
120       $invoicing_list .= ', POST' if $cgi->param('invoicing_list_POST');
121     } else {
122       $invoicing_list = 'POST';
123     }
124
125     $error = '';
126
127     if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
128       $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat
129       $password  = '';
130       $password2 = '';
131     } else {
132       $password2 = $cgi->param('_password2');
133
134       if ( $payby eq 'CARD' && $cgi->param('CARD_type') ) {
135         $payinfo =~ s/\D//g;
136
137         $payinfo =~ /^(\d{13,16})$/
138           or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo;
139         $payinfo = $1;
140         validate($payinfo)
141           or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo;
142         cardtype($payinfo) eq $cgi->param('CARD_type')
143           or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type');
144       }
145
146       $error ||= new_customer ( {
147         'last'             => $last             = $cgi->param('last'),
148         'first'            => $first            = $cgi->param('first'),
149         'ss'               => $ss               = $cgi->param('ss'),
150         'company'          => $company          = $cgi->param('company'),
151         'address1'         => $address1         = $cgi->param('address1'),
152         'address2'         => $address2         = $cgi->param('address2'),
153         'city'             => $city             = $cgi->param('city'),
154         'county'           => $county,
155         'state'            => $state,
156         'zip'              => $zip              = $cgi->param('zip'),
157         'country'          => $country,
158         'daytime'          => $daytime          = $cgi->param('daytime'),
159         'night'            => $night            = $cgi->param('night'),
160         'fax'              => $fax              = $cgi->param('fax'),
161         'payby'            => $payby,
162         'payinfo'          => $payinfo,
163         'paydate'          => $paydate,
164         'payname'          => $payname,
165         'invoicing_list'   => $invoicing_list,
166         'referral_custnum' => $referral_custnum = $cgi->param('ref'),
167         'pkgpart'          => $pkgpart          = $cgi->param('pkgpart'),
168         'username'         => $username         = $cgi->param('username'),
169         'sec_phrase'       => $sec_phrase       = $cgi->param('sec_phrase'),
170         '_password'        => $password         = $cgi->param('_password'),
171         'popnum'           => $popnum           = $cgi->param('popnum'),
172         'agentnum'         => $agentnum         = $cgi->param('agentnum'),
173       } );
174
175     }
176     
177     if ( $error ) {
178       print_form();
179     } else {
180       print_okay();
181     }
182
183   } else {
184     die "unrecognized magic: ". $cgi->param('magic');
185   }
186 } else {
187   $error = '';
188   $last = '';
189   $first = '';
190   $ss = '';
191   $company = '';
192   $address1 = '';
193   $address2 = '';
194   $city = '';
195   $state = '';
196   $county = '';
197   $country = '';
198   $zip = '';
199   $daytime = '';
200   $night = '';
201   $fax = '';
202   $invoicing_list = '';
203   $payby = '';
204   $payinfo = '';
205   $paydate = '';
206   $payname = '';
207   $pkgpart = '';
208   $username = '';
209   $password = '';
210   $password2 = '';
211   $sec_phrase = '';
212   $popnum = '';
213   $referral_custnum = $cgi->param('ref') || '';
214   print_form;
215 }
216
217 sub print_form {
218
219   $cgi->delete('ref');
220   $self_url = $cgi->self_url;
221
222   $error = "Error: $error" if $error;
223
224   print $cgi->header( '-expires' => 'now' ),
225         $signup_template->fill_in();
226
227 }
228
229 sub print_okay {
230   my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
231
232   $cgi->param('username') =~ /^(.+)$/
233     or die "fatal: invalid username got past FS::SignupClient::new_customer";
234   my $username = $1;
235   $cgi->param('_password') =~ /^(.+)$/
236     or die "fatal: invalid password got past FS::SignupClient::new_customer";
237   my $password = $1;
238   ( $cgi->param('first'). ' '. $cgi->param('last') ) =~ /^(.*)$/
239     or die "fatal: invalid email_name got past FS::SignupClient::new_customer";
240   my $email_name = $1;
241
242   my $pop = pop_info($cgi->param('popnum'));
243     #or die "fatal: invalid popnum got past FS::SignupClient::new_customer";
244   if ( $pop ) {
245     ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} );
246   } else {
247     ( $ac, $exch, $loc ) = ( '', '', ''); #presumably you're not using them.
248   }
249
250   my $pkg = ( grep { $_->{'pkgpart'} eq $pkgpart } @$packages )[0]->{'pkg'};
251
252   if ( $ieak_template
253        && $user_agent->platform eq 'ia32'
254        && $user_agent->os =~ /^win/
255        && ($user_agent->browser)[0] eq 'IE'
256      )
257   { #send an IEAK config
258     print $cgi->header('application/x-Internet-signup'),
259           $ieak_template->fill_in();
260   } elsif ( $cck_template
261             && $user_agent->platform eq 'ia32'
262             && $user_agent->os =~ /^win/
263             && ($user_agent->browser)[0] eq 'Netscape'
264           )
265   { #send a Netscape config
266     my $cck_data = $cck_template->fill_in();
267     print $cgi->header('application/x-netscape-autoconfigure-dialer-v2'),
268           map {
269             m/(.*)\s+(.*)$/;
270             pack("N", length($1)). $1. pack("N", length($2)). $2;
271           } split(/\n/, $cck_data);
272
273   } else { #send a simple confirmation
274     print $cgi->header( '-expires' => 'now' ),
275           $success_template->fill_in();
276   }
277 }
278
279 sub pop_info {
280   my $popnum = shift;
281   my $pop;
282   foreach $pop ( @{$pops} ) {
283     if ( $pop->{'popnum'} == $popnum ) { return $pop; }
284   }
285   '';
286 }
287
288 #horrible false laziness with FS/FS/svc_acct_pop.pm::popselector
289 sub popselector {
290   my( $popnum, $state ) = @_;
291
292   return '<INPUT TYPE="hidden" NAME="popnum" VALUE="">' unless @$pops;
293   return $pops->[0]{city}. ', '. $pops->[0]{state}.
294          ' ('. $pops->[0]{ac}. ')/'. $pops->[0]{exch}.
295          '<INPUT TYPE="hidden" NAME="popnum" VALUE="'. $pops->[0]{popnum}. '">'
296     if scalar(@$pops) == 1;
297
298   my %pop = ();
299   push @{ $pop{$_->{state}} }, $_ foreach @$pops;
300
301   my $text = <<END;
302     <SCRIPT>
303     function opt(what,href,text) {
304       var optionName = new Option(text, href, false, false)
305       var length = what.length;
306       what.options[length] = optionName;
307     }
308     
309     function popstate_changed(what) {
310       state = what.options[what.selectedIndex].text;
311       for (var i = what.form.popnum.length;i > 0;i--)
312                 what.form.popnum.options[i] = null;
313       what.form.popnum.options[0] = new Option("", "", false, true);
314 END
315
316   foreach my $popstate ( sort { $a cmp $b } keys %pop ) {
317     $text .= "\nif ( state == \"$popstate\" ) {\n";
318
319     foreach my $pop ( @{$pop{$popstate}}) {
320       my $o_popnum = $pop->{popnum};
321       my $poptext =  $pop->{city}. ', '. $pop->{state}.
322                      ' ('. $pop->{ac}. ')/'. $pop->{exch};
323
324       $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
325     }
326     $text .= "}\n";
327   }
328
329   $text .= "}\n</SCRIPT>\n";
330
331   $text .=
332     qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
333     qq!<OPTION> !;
334   $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %pop;
335   $text .= '</SELECT>'; #callback? return 3 html pieces?  #'</TD><TD>';
336
337   $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
338   foreach my $pop ( @$pops ) {
339     $text .= qq!<OPTION VALUE="!. $pop->{popnum}. '"'.
340              ( ( $popnum && $pop->{popnum} == $popnum ) ? ' SELECTED' : '' ). ">".
341              $pop->{city}. ', '. $pop->{state}.
342                ' ('. $pop->{ac}. ')/'. $pop->{exch};
343   }
344   $text .= '</SELECT>';
345
346   $text;
347 }
348
349 sub expselect {
350   my $prefix = shift;
351   my $date = shift || '';
352   my( $m, $y ) = ( 0, 0 );
353   if ( $date  =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format
354     ( $m, $y ) = ( $2, $1 );
355   } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
356     ( $m, $y ) = ( $1, $3 );
357   }
358   my $return = qq!<SELECT NAME="$prefix!. qq!_month" SIZE="1">!;
359   for ( 1 .. 12 ) {
360     $return .= "<OPTION";
361     $return .= " SELECTED" if $_ == $m;
362     $return .= ">$_";
363   }
364   $return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!;
365   for ( 2001 .. 2037 ) {
366     $return .= "<OPTION";
367     $return .= " SELECTED" if $_ == $y;
368     $return .= ">$_";
369   }
370   $return .= "</SELECT>";
371
372   $return;
373 }
374
375 sub success_default { #html to use if you don't specify a success file
376   <<'END';
377 <HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
378 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
379 Thanks for signing up!
380 <BR><BR>
381 Signup information for <%= $email_name %>:
382 <BR><BR>
383 Username: <%= $username %><BR>
384 Password: <%= $password %><BR>
385 Access number: (<%= $ac %>) / $exch - $local<BR>
386 Package: <%= $pkg %><BR>
387 </BODY></HTML>
388 END
389 }
390
391 sub signup_default { #html to use if you don't specify a template file
392   <<'END';
393 <HTML><HEAD><TITLE>ISP Signup form</TITLE></HEAD>
394 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>ISP Signup form</FONT><BR><BR>
395 <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT>
396 <FORM ACTION="<%= $self_url %>" METHOD=POST>
397 <INPUT TYPE="hidden" NAME="magic" VALUE="process">
398 <INPUT TYPE="hidden" NAME="ref" VALUE="<%= $referral_custnum %>">
399 <INPUT TYPE="hidden" NAME="ss" VALUE="">
400 Contact Information
401 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
402 <TR>
403   <TH ALIGN="right"><font color="#ff0000">*</font>Contact name<BR>(last, first)</TH>
404   <TD COLSPAN=5><INPUT TYPE="text" NAME="last" VALUE="<%= $last %>">,
405                 <INPUT TYPE="text" NAME="first" VALUE="<%= $first %>"></TD>
406 </TR>
407 <TR>
408   <TD ALIGN="right">Company</TD>
409   <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="<%= $company %>"></TD>
410 </TR>
411 <TR>
412   <TH ALIGN="right"><font color="#ff0000">*</font>Address</TH>
413   <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="<%= $address1 %>"></TD>
414 </TR>
415 <TR>
416   <TD ALIGN="right">&nbsp;</TD>
417   <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="<%= $address2 %>"></TD>
418 </TR>
419 <TR>
420   <TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
421   <TD><INPUT TYPE="text" NAME="city" VALUE="<%= $city %>"></TD>
422   <TH ALIGN="right"><font color="#ff0000">*</font>State/Country</TH>
423   <TD><SELECT NAME="state" SIZE="1">
424
425   <%=
426     foreach ( @{$locales} ) {
427       $OUT .= '<OPTION';
428       $OUT .= ' SELECTED' if ( $state eq $_->{'state'}
429                                && $county eq $_->{'county'}
430                                && $country eq $_->{'country'}
431                              );
432       $OUT .= '>'. $_->{'state'};
433       $OUT .= ' ('. $_->{'county'}. ')' if $_->{'county'};
434       $OUT .= ' / '. $_->{'country'};
435     }
436   %>
437
438   </SELECT></TD>
439   <TH><font color="#ff0000">*</font>Zip</TH>
440   <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="<%= $zip %>"></TD>
441 </TR>
442 <TR>
443   <TD ALIGN="right">Day Phone</TD>
444   <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="<%= $daytime %>" SIZE=18></TD>
445 </TR>
446 <TR>
447   <TD ALIGN="right">Night Phone</TD>
448   <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="<%= $night %>" SIZE=18></TD>
449 </TR>
450 <TR>
451   <TD ALIGN="right">Fax</TD>
452   <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="<%= $fax %>" SIZE=12></TD>
453 </TR>
454 </TABLE><font color="#ff0000">*</font> required fields<BR>
455 <BR>Billing information<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
456 <TR><TD>
457
458   <%=
459     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
460     my @invoicing_list = split(', ', $invoicing_list );
461     $OUT .= ' CHECKED'
462       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
463     $OUT .= '>';
464   %>
465
466   Postal mail invoice
467 </TD></TR>
468 <TR><TD>Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ ne 'POST' } split(', ', $invoicing_list ) ) %>">
469 </TD></TR>
470 <%= scalar(@payby) > 1 ? '<TR><TD>Billing type</TD></TR>' : '' %>
471 </TABLE>
472 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
473 <TR>
474
475   <%=
476
477     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
478     my %types = (
479                   'VISA' => 'VISA card',
480                   'MasterCard' => 'MasterCard',
481                   'Discover' => 'Discover card',
482                   'American Express' => 'American Express card',
483                 );
484     foreach ( keys %types ) {
485       $selected = $cgi->param('CARD_type') eq $types{$_} ? 'SELECTED' : '';
486       $cardselect .= qq!<OPTION $selected VALUE="$types{$_}">$_</OPTION>!;
487     }
488     $cardselect .= '</SELECT>';
489   
490     my %payby = (
491       'CARD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("CARD"). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
492       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR><font color="#ff0000">*</font>Exp !. expselect("BILL", "12-2037"). qq!<BR><font color="#ff0000">*</font>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
493       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR><font color="#ff0000">*</font>Exp !. expselect("COMP"),
494       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
495     );
496
497     my %paybychecked = (
498       'CARD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("CARD", $paydate). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
499       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><font color="#ff0000">*</font>Exp !. expselect("BILL", $paydate). qq!<BR><font color="#ff0000">*</font>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
500       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR><font color="#ff0000">*</font>Exp !. expselect("COMP", $paydate),
501       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
502     );
503
504     for (@payby) {
505       if ( scalar(@payby) == 1) {
506         $OUT .= '<TD VALIGN=TOP>'.
507                 qq!<INPUT TYPE="hidden" NAME="payby" VALUE="$_">!.
508                 "$paybychecked{$_}</TD>";
509       } else {
510         $OUT .= qq!<TD VALIGN=TOP><INPUT TYPE="radio" NAME="payby" VALUE="$_"!;
511         if ($payby eq $_) {
512           $OUT .= qq! CHECKED> $paybychecked{$_}</TD>!;
513         } else {
514           $OUT .= qq!> $payby{$_}</TD>!;
515         }
516
517       }
518     }
519   %>
520
521 </TR></TABLE><font color="#ff0000">*</font> required fields for each billing type
522 <BR><BR>First package
523 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
524 <TR>
525   <TD COLSPAN=2><SELECT NAME="pkgpart"><OPTION VALUE="">(none)
526
527   <%=
528     foreach my $package ( @{$packages} ) {
529       $OUT .= '<OPTION VALUE="'. $package->{'pkgpart'}. '"';
530       $OUT .= ' SELECTED' if $pkgpart && $package->{'pkgpart'} == $pkgpart;
531       $OUT .= '>'. $package->{'pkg'};
532     }
533   %>
534
535   </SELECT></TD>
536 </TR>
537 <TR>
538   <TD ALIGN="right">Username</TD>
539   <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"></TD>
540 </TR>
541 <TR>
542   <TD ALIGN="right">Password</TD>
543   <TD><INPUT TYPE="password" NAME="_password" VALUE="<%= $password %>"></TD>
544 </TR>
545 <TR>
546   <TD ALIGN="right">Re-enter Password</TD>
547   <TD><INPUT TYPE="password" NAME="_password2" VALUE="<%= $password2 %>"></TD>
548 </TR>
549 <%=
550   if ( $init_data->{'security_phrase'} ) {
551     $OUT .= <<ENDOUT;
552 <TR>
553   <TD ALIGN="right">Security Phrase</TD>
554   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
555   </TD>
556 </TR>
557 ENDOUT
558   } else {
559     $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
560   }
561 %>
562 <%=
563   if ( scalar(@$pops) ) {
564     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
565             popselector($popnum). '</TD></TR>';
566   } else {
567     $OUT .= popselector($popnum);
568   }
569 %>
570 </TABLE>
571 <BR><BR><INPUT TYPE="submit" VALUE="Signup">
572 </FORM></BODY></HTML>
573 END
574 }