#!/usr/bin/perl -Tw # # $Id: signup.cgi,v 1.4 2000-01-31 05:22:23 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $r $error $last $first $ss $company $address1 $address2 $city $state $county $country $zip $daytime $night $fax $invoicing_list $payby $payinfo $paydate $payname $pkgpart $username $password $popnum $ieak_file $ieak_template $ac $exch $loc ); #$ieak_docroot $ieak_baseurl use subs qw( print_form print_okay expselect ); use CGI; use CGI::Carp qw(fatalsToBrowser); use HTTP::Headers::UserAgent 2.00; use FS::SignupClient qw( signup_info new_customer ); use Text::Template; #acceptable payment methods # #@payby = qw( CARD BILL COMP ); #@payby = qw( CARD BILL ); #@payby = qw( CARD ); @payby = qw( CARD PREPAY ); $ieak_file = '/usr/local/freeside/ieak.template'; if ( -e $ieak_file ) { $ieak_template = new Text::Template ( TYPE => 'FILE', SOURCE => $ieak_file ) or die "Couldn't construct template: $Text::Template::ERROR"; } else { $ieak_template = ''; } # #to enable ieak signups, you need to specify a directory in the web server's # #document space and the equivalent base URL # # # $ieak_docroot = "/var/www/sisd.420.am/freeside/ieak"; # $ieak_baseurl = "http://sisd.420.am/freeside/ieak"; #srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`); ( $locales, $packages, $pops ) = signup_info(); $cgi = new CGI; if ( defined $cgi->param('magic') ) { if ( $cgi->param('magic') eq 'process' ) { $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ or die "Oops, illegal \"state\" param: ". $cgi->param('state'); $state = $1; $county = $3 || ''; $country = $4; $payby = $cgi->param('payby'); $payinfo = $cgi->param( $payby. '_payinfo' ); $paydate = $cgi->param( $payby. '_month' ). '-'. $cgi->param( $payby. '_year' ); $payname = $cgi->param( $payby. '_payname' ); if ( $invoicing_list = $cgi->param('invoicing_list') ) { $invoicing_list .= ', POST' if $cgi->param('invoicing_list_POST'); } else { $invoicing_list = 'POST'; } ( $error = new_customer ( { 'last' => $last = $cgi->param('last'), 'first' => $first = $cgi->param('first'), 'ss' => $ss = $cgi->param('ss'), 'company' => $company = $cgi->param('company'), 'address1' => $address1 = $cgi->param('address1'), 'address2' => $address2 = $cgi->param('address2'), 'city' => $city = $cgi->param('city'), 'county' => $county, 'state' => $state, 'zip' => $zip = $cgi->param('zip'), 'country' => $country, 'daytime' => $daytime = $cgi->param('daytime'), 'night' => $night = $cgi->param('night'), 'fax' => $fax = $cgi->param('fax'), 'payby' => $payby, 'payinfo' => $payinfo, 'paydate' => $paydate, 'payname' => $payname, 'invoicing_list' => $invoicing_list, 'pkgpart' => $pkgpart = $cgi->param('pkgpart'), 'username' => $username = $cgi->param('username'), '_password' => $password = $cgi->param('_password'), 'popnum' => $popnum = $cgi->param('popnum'), } ) ) ? print_form() : print_okay(); } else { die "unrecognized magic: ". $cgi->param('magic'); } } else { $error = ''; $last = ''; $first = ''; $ss = ''; $company = ''; $address1 = ''; $address2 = ''; $city = ''; $state = ''; $county = ''; $country = ''; $zip = ''; $daytime = ''; $night = ''; $fax = ''; $invoicing_list = ''; $payby = ''; $payinfo = ''; $paydate = ''; $payname = ''; $pkgpart = ''; $username = ''; $password = ''; $popnum = ''; print_form; } sub print_form { my $r = qq!*!; my $self_url = $cgi->self_url; print $cgi->header( '-expires' => 'now' ), <ISP Signup form ISP Signup form

END print qq!Error: $error! if $error; print < Contact Information
${r}Contact name
(last, first)
, SS#
Company
${r}Address
 
${r}City ${r}State/Country ${r}Zip
Day Phone
Night Phone
Fax
$r required fields

Billing information!; print <
END print qq!Postal mail invoice
Email invoice ', qq!
Billing type
END my %payby = ( 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD"). qq!
${r}Name on card
!, 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", "12-2037"). qq!
${r}Attention
!, 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP"), 'PREPAY' => qq!Prepaid card
${r}!, ); my %paybychecked = ( 'CARD' => qq!Credit card
${r}
${r}Exp !. expselect("CARD", $paydate). qq!
${r}Name on card
!, 'BILL' => qq!Billing
P.O.
${r}Exp !. expselect("BILL", $paydate). qq!
${r}Attention
!, 'COMP' => qq!Complimentary
${r}Approved by
${r}Exp !. expselect("COMP", $paydate), 'PREPAY' => qq!Prepaid card
${r}!, ); for (@payby) { print qq!!; } else { print qq!> $payby{$_}!; } } print <
$paybychecked{$_}
$r required fields for each billing type

First package
Username
Password (blank to generate)
POP


END } sub print_okay { my $user_agent = new HTTP::Headers::UserAgnet $ENV{HTTP_USER_AGENT}; if ( $ieak_template && $user_agent->platform eq 'ia32' && $user_agent->os =~ /^win/ && ($user_agent->browser)[0] eq 'IE' ) { #send an IEAK config my $username = $cgi->param('username'); my $password = $cgi->param('_password'); my $email_name = $cgi->param('first'). ' '. $cgi->param('last'); print $cgi->header('application/x-Internet-signup'), $ieak_template->fill_in(); # my $ins_file = rand(4294967296). ".ins"; # open(INS_FILE, ">$ieak_docroot/$ins_file"); # print INS_FILE <redirect("$ieak_docroot/$ins_file"); } else { #send a simple confirmation print $cgi->header( '-expires' => 'now' ), <Signup successful Signup successful

blah blah blah END } } sub expselect { my $prefix = shift; my $date = shift || ''; my( $m, $y ) = ( 0, 0 ); if ( $date =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #PostgreSQL date format ( $m, $y ) = ( $2, $1 ); } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) { ( $m, $y ) = ( $1, $3 ); } my $return = qq!!; for ( 1999 .. 2037 ) { $return .= "