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