3 # $Id: signup.cgi,v 1.2 1999-12-17 12:03:03 ivan Exp $
6 use vars qw( @payby $cgi $locales $packages $pops $r $error
7 $last $first $ss $company $address1 $address2 $city $state $county
8 $country $zip $daytime $night $fax $invoicing_list $payby $payinfo
9 $paydate $payname $pkgpart $username $password $popnum
10 $ieak_docroot $ieak_baseurl );
11 use subs qw( print_form print_okay expselect );
14 use CGI::Carp qw(fatalsToBrowser);
15 use HTTP::Headers::UserAgent 2.00;
16 use FS::SignupClient qw( signup_info new_customer );
18 #acceptable payment methods
20 #@payby = qw( CARD BILL COMP );
21 #@payby = qw( CARD BILL );
24 #to enable ieak signups, you need to specify a directory in the web server's
25 #document space and the equivalent base URL
27 $ieak_docroot = "/var/www/sisd.420.am/freeside/ieak";
28 $ieak_baseurl = "http://sisd.420.am/freeside/ieak";
30 #srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
32 ( $locales, $packages, $pops ) = signup_info();
36 if ( defined $cgi->param('magic') ) {
37 if ( $cgi->param('magic') eq 'process' ) {
39 $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/
40 or die "Oops, illegal \"state\" param: ". $cgi->param('state');
45 $payby = $cgi->param('payby');
46 $payinfo = $cgi->param( $payby. '_payinfo' );
48 $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' );
49 $payname = $cgi->param( $payby. '_payname' );
51 if ( $invoicing_list = $cgi->param('invoicing_list') ) {
52 $invoicing_list .= ', POST' if $cgi->param('invoicing_list_POST');
54 $invoicing_list = 'POST';
57 ( $error = new_customer ( {
58 'last' => $last = $cgi->param('last'),
59 'first' => $first = $cgi->param('first'),
60 'ss' => $ss = $cgi->param('ss'),
61 'company' => $company = $cgi->param('company'),
62 'address1' => $address1 = $cgi->param('address1'),
63 'address2' => $address2 = $cgi->param('address2'),
64 'city' => $city = $cgi->param('city'),
67 'zip' => $zip = $cgi->param('zip'),
68 'country' => $country,
69 'daytime' => $daytime = $cgi->param('daytime'),
70 'night' => $night = $cgi->param('night'),
71 'fax' => $fax = $cgi->param('fax'),
73 'payinfo' => $payinfo,
74 'paydate' => $paydate,
75 'payname' => $payname,
76 'invoicing_list' => $invoicing_list,
77 'pkgpart' => $pkgpart = $cgi->param('pkgpart'),
78 'username' => $username = $cgi->param('username'),
79 '_password' => $password = $cgi->param('_password'),
80 'popnum' => $popnum = $cgi->param('popnum'),
85 die "unrecognized magic: ". $cgi->param('magic');
103 $invoicing_list = '';
118 my $r = qq!<font color="#ff0000">*</font>!;
119 my $self_url = $cgi->self_url;
121 print $cgi->header( '-expires' => 'now' ), <<END;
122 <HTML><HEAD><TITLE>ISP Signup form</TITLE></HEAD>
123 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>ISP Signup form</FONT><BR><BR>
126 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT>! if $error;
129 <FORM ACTION="$self_url" METHOD=POST>
130 <INPUT TYPE="hidden" NAME="magic" VALUE="process">
132 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
134 <TH ALIGN="right">${r}Contact name<BR>(last, first)</TH>
135 <TD COLSPAN=3><INPUT TYPE="text" NAME="last" VALUE="$last">,
136 <INPUT TYPE="text" NAME="first" VALUE="$first"></TD>
137 <TD ALIGN="right">SS#</TD>
138 <TD><INPUT TYPE="text" NAME="ss" SIZE=11 VALUE="$ss"></TD>
141 <TD ALIGN="right">Company</TD>
142 <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="$company"></TD>
145 <TH ALIGN="right">${r}Address</TH>
146 <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="$address1"></TD>
149 <TD ALIGN="right"> </TD>
150 <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="$address2"></TD>
153 <TH ALIGN="right">${r}City</TH>
154 <TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD>
155 <TH ALIGN="right">${r}State/Country</TH>
156 <TD><SELECT NAME="state" SIZE="1">
159 foreach ( @{$locales} ) {
161 print " SELECTED" if ( $state eq $_->{'state'}
162 && $county eq $_->{'county'}
163 && $country eq $_->{'country'}
165 print ">", $_->{'state'};
166 print " (",$_->{'county'},")" if $_->{'county'};
167 print " / ", $_->{'country'};
173 <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="$zip"></TD>
176 <TD ALIGN="right">Day Phone</TD>
177 <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18></TD>
180 <TD ALIGN="right">Night Phone</TD>
181 <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18></TD>
184 <TD ALIGN="right">Fax</TD>
185 <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD>
187 </TABLE>$r required fields<BR>
188 <BR>Billing information<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
192 print qq!<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"!;
193 my @invoicing_list = split(', ', $invoicing_list );
195 if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
196 print '>Postal mail invoice</TD></TR><TR><TD>Email invoice ',
197 qq!<INPUT TYPE="text" NAME="invoicing_list" VALUE="!,
198 join(', ', grep { $_ ne 'POST' } @invoicing_list ),
202 <TR><TD>Billing type</TD></TR></TABLE>
203 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
208 'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD"). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
209 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR>${r}Exp !. expselect("BILL", "12-2037"). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
210 'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR>${r}Exp !. expselect("COMP"),
214 'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD", $paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
215 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("BILL", $paydate). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
216 'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("COMP", $paydate),
220 print qq!<TD VALIGN=TOP><INPUT TYPE="radio" NAME="payby" VALUE="$_"!;
222 print qq! CHECKED> $paybychecked{$_}</TD>!;
224 print qq!> $payby{$_}</TD>!;
229 </TR></TABLE>$r required fields for each billing type
230 <BR><BR>First package
231 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=0 WIDTH="100%">
233 <TD COLSPAN=2><SELECT NAME="pkgpart"><OPTION VALUE="">(none)
236 foreach my $package ( @{$packages} ) {
237 print qq!<OPTION VALUE="!, $package->{'pkgpart'}, '"';
238 print " SELECTED" if $pkgpart && ( $package->{'pkgpart'} == $pkgpart );
239 print ">", $package->{'pkg'};
246 <TD ALIGN="right">Username</TD>
247 <TD><INPUT TYPE="text" NAME="username" VALUE="$username"></TD>
250 <TD ALIGN="right">Password</TD>
251 <TD><INPUT TYPE="text" NAME="_password" VALUE="$password">
252 (blank to generate)</TD>
255 <TD ALIGN="right">POP</TD>
256 <TD><SELECT NAME="popnum" SIZE=1><OPTION>
259 foreach my $pop ( @{$pops} ) {
260 print qq!<OPTION VALUE="!, $pop->{'popnum'}, '"',
261 ( $popnum && $pop->{'popnum'} == $popnum ) ? ' SELECTED' : '', ">",
262 $pop->{'popnum'}, ": ",
263 $pop->{'city'}, ", ",
265 " (", $pop->{'ac'}, ")/",
273 <BR><BR><INPUT TYPE="submit" VALUE="Signup">
274 </FORM></BODY></HTML>
280 $user_agent = new HTTP::Headers::UserAgnet $ENV{HTTP_USER_AGENT};
281 if ( defined($ieak_docroot)
282 && defined($ieak_baseurl)
283 && defined($ieak_secret)
284 && $user_agent->platform eq 'ia32'
285 && $user_agent->os =~ /^win/
286 && ($user-agent->browser)[0] eq 'IE'
288 { #send an IEAK config
289 my $username = $cgi->param('username');
290 my $password = $cgi->param('_password');
291 my $email_name = $cgi->param('first'). ' '. $cgi->param('last');
292 my $ins_file = rand(4294967296). ".ins";
293 open(INS_FILE, ">$ieak_docroot/$ins_file");
294 print INS_FILE <<END;
296 Entry_Name = Netloud\r
299 Phone_Number = 5551212\r
307 Negotiate_TCP/IP = Yes\r
310 Specify_IP_Address = No\r
311 Specity_Server_Address = No\r
312 IP_Header_Compress = Yes\r
313 Gateway_On_Remote = Yes\r
316 Password = $password\r
317 Display_Password = Yes\r
319 Email_Name = $email_name\r
320 Email_Address = $username\@netloud.com\r
321 POP_Server = mail.netloud.com\r
322 POP_Server_Port_Number = 110\r
323 POP_Login_Name = $username\r
324 POP_Login_Password = $password\r
325 SMTP_Server = mail.netloud.com\r
326 SMTP_Server_Port_Number = 25\r
329 NNTP_Server = news.netloud.com\r
330 NNTP_Server_Port_Number = 119\r
331 Logon_Required = No\r
334 Window_Title = Internet Explorer From Netloud.com\r
338 print $cgi->redirect("$ieak_docroot/$ins_file");
340 } else { #send a simple confirmation
341 print $cgi->header( '-expires' => 'now' ), <<END;
342 <HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
343 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
353 my $date = shift || '';
354 my( $m, $y ) = ( 0, 0 );
355 if ( $date =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format
356 ( $m, $y ) = ( $2, $1 );
357 } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
358 ( $m, $y ) = ( $1, $3 );
360 my $return = qq!<SELECT NAME="$prefix!. qq!_month" SIZE="1">!;
362 $return .= "<OPTION";
363 $return .= " SELECTED" if $_ == $m;
366 $return .= qq!</SELECT>/<SELECT NAME="$prefix!. qq!_year" SIZE="1">!;
367 for ( 1999 .. 2037 ) {
368 $return .= "<OPTION";
369 $return .= " SELECTED" if $_ == $y;
372 $return .= "</SELECT>";