From 971e4ca0af5a6adbc8c724c9dff12cf8edf93dd9 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Jul 1999 19:18:25 +0000 Subject: initial checkin --- fs_signup/Signup.pm | 129 +++++++++++++++++++++++++++++++++++++++++++++ fs_signup/fs_signup_server | 77 +++++++++++++++++++++++++++ fs_signup/fs_signupd | 49 +++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100755 fs_signup/Signup.pm create mode 100755 fs_signup/fs_signup_server create mode 100755 fs_signup/fs_signupd (limited to 'fs_signup') diff --git a/fs_signup/Signup.pm b/fs_signup/Signup.pm new file mode 100755 index 000000000..bcf09f1fe --- /dev/null +++ b/fs_signup/Signup.pm @@ -0,0 +1,129 @@ +#!/usr/bin/perl -Tw +# +# fs_passwd +# +# portions of this script are copied from the `passwd' script in the original +# (perl 4) camel book, now archived at +# http://www.perl.com/CPAN/scripts/nutshell/ch6/passwd +# +# ivan@sisd.com 98-mar-8 +# +# password lengths 0,255 instead of 6,8 - we'll let the server process +# check the data ivan@sisd.com 98-jul-17 + +use strict; +use Getopt::Std; +use Socket; +use IO::Handle; +use vars qw($opt_f $opt_s); + +my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; +my($freeside_uid)=scalar(getpwnam('freeside')); + +$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; + +$SIG{__DIE__}= sub { system '/bin/stty', 'echo'; }; + +die "passwd program isn't running setuid to freeside\n" if $> != $freeside_uid; + +unshift @ARGV, "-f" if $0 =~ /chfn$/; +unshift @ARGV, "-s" if $0 =~ /chsh$/; + +getopts('fs'); + +my($me)=''; +if ( $_ = shift(@ARGV) ) { + /^(\w{2,8})$/; + $me = $1; +} +die "You can't change the password for $me." if $me && $<; +$me = (getpwuid($<))[0] unless $me; + +my($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell)= + getpwnam $me; + +my($old_password,$new_password,$new_gecos,$new_shell); + +if ( $opt_f || $opt_s ) { + system '/bin/stty', '-echo'; + print "Password:"; + $old_password=; + system '/bin/stty', 'echo'; + chop($old_password); + #$old_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; + $old_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; + $old_password = $1; + + $new_password = ''; + + if ( $opt_f ) { + print "\nChanging gecos for $me.\n"; + print "Gecos [", $gcos, "]: "; + $new_gecos=; + chop($new_gecos); + $new_gecos ||= $gcos; + $new_gecos =~ /^(.{0,255})$/ or die "\nIllegal gecos.\n"; + } else { + $new_gecos = ''; + } + + if ( $opt_s ) { + print "\nChanging shell for $me.\n"; + print "Shell [", $shell, "]: "; + $new_shell=; + chop($new_shell); + $new_shell ||= $shell; + $new_shell =~ /^(.{0,255})$/ or die "\nIllegal shell.\n"; + } else { + $new_shell = ''; + } + +} else { + + print "Changing password for $me.\n"; + print "Old password:"; + system '/bin/stty', '-echo'; + $old_password=; + chop $old_password; + #$old_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; + $old_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; + $old_password = $1; + print "\nEnter the new password (minimum of 6, maximum of 8 characters)\n"; + print "Please use a combination of upper and lowercase letters and numbers.\n"; + print "New password:"; + $new_password=; + chop($new_password); + #$new_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; + $new_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; + $new_password = $1; + print "\nRe-enter new password:"; + my($check_new_password); + $check_new_password=; + chop($check_new_password); + die "\nThey don't match; try again.\n" unless $check_new_password eq $new_password; + + $new_gecos=''; + $new_shell=''; +} +print "\n"; + +system '/bin/stty', 'echo'; + +socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; +connect(SOCK, sockaddr_un($fs_passwdd_socket)) or die "connect: $!"; +print SOCK join("\n",$me,$old_password,$new_password,$new_gecos,$new_shell),"\n"; +SOCK->flush; +my($error); +$error = ; +chop $error; + +if ($error) { + print "\nUpdate error: $error\n"; +} else { + print "\nUpdate sucessful.\n"; +} diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server new file mode 100755 index 000000000..cb0e693dd --- /dev/null +++ b/fs_signup/fs_signup_server @@ -0,0 +1,77 @@ +#!/usr/bin/perl -Tw +# +# fs_passwd_server +# +# portions of this script are copied from the `passwd' script in the original +# (perl 4) camel book, now archived at +# http://www.perl.com/CPAN/scripts/nutshell/ch6/passwd +# +# ivan@sisd.com 98-mar-9 +# +# crypt-aware, s/password/_password/; ivan@sisd.com 98-aug-23 + +use strict; +use IO::Handle; +use FS::SSH qw(sshopen2); +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearchs); +use FS::svc_acct; + +my $user = shift or die &usage; +adminsuidsetup $user; + +my($shellmachine)=shift or die &usage; + +$SIG{CHLD} = sub { wait() }; + +my($fs_passwdd)="/usr/local/sbin/fs_passwdd"; + +while (1) { + my($reader,$writer)=(new IO::Handle, new IO::Handle); + $writer->autoflush(1); + sshopen2($shellmachine,$reader,$writer,$fs_passwdd); + while (1) { + my($username,$old_password,$new_password,$new_gecos,$new_shell); + defined($username=<$reader>) or last; + defined($old_password=<$reader>) or last; + defined($new_password=<$reader>) or last; + defined($new_gecos=<$reader>) or last; + defined($new_shell=<$reader>) or last; + chop($username); + chop($old_password); + chop($new_password); + chop($new_gecos); + chop($new_shell); + my($svc_acct); + + #need to try both $old_password and encrypted $old_password + #maybe the crypt function in svc_acct.export needs to be a library? + my $salt = substr($old_password,0,2); + my $cold_password = crypt($old_password,$salt); + $svc_acct=qsearchs('svc_acct',{'username'=>$username, + '_password'=>$old_password, + } ) + || qsearchs('svc_acct',{'username'=>$username, + '_password'=>$cold_password, + } ); + unless ( $svc_acct ) { print $writer "Incorrect password.\n"; next; } + + my(%hash)=$svc_acct->hash; + my($new_svc_acct) = new FS::svc_acct ( \%hash ); + $new_svc_acct->setfield('_password',$new_password) + if $new_password && $new_password ne $old_password; + $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos; + $new_svc_acct->setfield('shell',$new_shell) if $new_shell; + my($error)=$new_svc_acct->replace($svc_acct); + print $writer $error,"\n"; + } + close $writer; + close $reader; + sleep 60; + warn "Connection to $shellmachine lost! Reconnecting...\n"; +} + +sub usage { + die "Usage:\n\n fs_passwd_server user shellmachine\n"; +} + diff --git a/fs_signup/fs_signupd b/fs_signup/fs_signupd new file mode 100755 index 000000000..582e13ccd --- /dev/null +++ b/fs_signup/fs_signupd @@ -0,0 +1,49 @@ +#!/usr/bin/perl -Tw +# +# fs_passwdd +# +# This is run REMOTELY over ssh by fs_passwd_server. +# +# ivan@sisd.com 98-mar-9 + +use strict; +use Socket; + +my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; + +$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; + +$|=1; + +my $uaddr = sockaddr_un($fs_passwdd_socket); +my $proto = getprotobyname('tcp'); + +socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; +unlink($fs_passwdd_socket); +bind(Server, $uaddr) or die "bind: $!"; +listen(Server,SOMAXCONN) or die "listen: $!"; + +my($paddr); +for ( ; $paddr = accept(Client,Server); close Client) { + my($me,$old_password,$new_password,$new_gecos,$new_shell); + + $me=; + $old_password=; + $new_password=; + $new_gecos=; + $new_shell=; + + print $me,$old_password,$new_password,$new_gecos,$new_shell; + my($error); + + $error=; + + print Client $error; + close Client; +} + -- cgit v1.2.1 From 53437ddeba0439876f496eae235700d46ea7645f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jul 1999 19:13:06 +0000 Subject: *** empty log message *** --- fs_signup/fs_signup_server | 54 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 13 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index cb0e693dd..5feed4cb6 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -1,36 +1,64 @@ #!/usr/bin/perl -Tw # -# fs_passwd_server +# fs_signup_server # -# portions of this script are copied from the `passwd' script in the original -# (perl 4) camel book, now archived at -# http://www.perl.com/CPAN/scripts/nutshell/ch6/passwd -# -# ivan@sisd.com 98-mar-9 -# -# crypt-aware, s/password/_password/; ivan@sisd.com 98-aug-23 use strict; use IO::Handle; use FS::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearchs); -use FS::svc_acct; +use FS::cust_main_county; +use FS::cust_main; + +use vars qw( $opt ); my $user = shift or die &usage; adminsuidsetup $user; -my($shellmachine)=shift or die &usage; +my $machine = shift or die &usage; + +my $agentnum = shift or die &usage; +my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ) or die &usage; +#my %part_pkg = %{ $agent->pkgpart_hashref }; + +my $refnum = shift or die &usage; $SIG{CHLD} = sub { wait() }; -my($fs_passwdd)="/usr/local/sbin/fs_passwdd"; +my($fs_signupd)="/usr/local/sbin/fs_signupd"; while (1) { my($reader,$writer)=(new IO::Handle, new IO::Handle); $writer->autoflush(1); - sshopen2($shellmachine,$reader,$writer,$fs_passwdd); + sshopen2($shellmachine,$reader,$writer,$fs_signupd); + + #send fs_signupd state/county/country + @cust_main_county = qsearch('cust_main_county', {} ); + print $writer join("\n", + scalar(@cust_main_county), + map { + $_->taxnum, + $_->state, + $_->county, + $_->country, + } @cust_main_county + ),"\n"; + + #send fs_signupd package definitions + + #send fs_signupd POPs + + + while (1) { + my( $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $username, $password, $popnum, + ); + + + my($username,$old_password,$new_password,$new_gecos,$new_shell); defined($username=<$reader>) or last; defined($old_password=<$reader>) or last; @@ -72,6 +100,6 @@ while (1) { } sub usage { - die "Usage:\n\n fs_passwd_server user shellmachine\n"; + die "Usage:\n\n fs_signup_server user machine agentnum refnum\n"; } -- cgit v1.2.1 From 453f8ffb1b1b54998c208ec49a8284394b2727bf Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 10 Aug 1999 12:55:11 +0000 Subject: ready for testing --- fs_signup/fs_signup_server | 152 ++++++++++++++++++++++++++++++++------------- fs_signup/fs_signupd | 116 ++++++++++++++++++++++++++++------ 2 files changed, 206 insertions(+), 62 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 5feed4cb6..cf2519ec0 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -20,7 +20,7 @@ my $machine = shift or die &usage; my $agentnum = shift or die &usage; my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ) or die &usage; -#my %part_pkg = %{ $agent->pkgpart_hashref }; +my $pkgpart = $agent->pkgpart_hashref; my $refnum = shift or die &usage; @@ -34,9 +34,9 @@ while (1) { sshopen2($shellmachine,$reader,$writer,$fs_signupd); #send fs_signupd state/county/country - @cust_main_county = qsearch('cust_main_county', {} ); + @my cust_main_county = qsearch('cust_main_county', {} ); print $writer join("\n", - scalar(@cust_main_county), + scalar(@cust_main_county) || die "no tax rates (cust_main_county records)", map { $_->taxnum, $_->state, @@ -46,57 +46,121 @@ while (1) { ),"\n"; #send fs_signupd package definitions + my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } + qsearch( 'part_pkg', {} ); + print $writer join("\n", + scalar(@part_pkg) || die "no usable package definitions, agent $agentnum", + map { + $_->pkgpart, + $_->pkg, + } @part_pkg + ), "\n"; #send fs_signupd POPs + my @svc_acct_pop = qsearch ('svc_acct_pop',{} ); + print $writer join("\n", + scalar(@svc_acct_pop) || die "No points of presence (svc_acct_pop records)", + map { + $_->popnum, + $_->city, + $_->state, + $_->ac, + $_->exch, + } @svc_acct_pop + ), "\n"; + while (1) { + chop( my( + $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, + $popnum, + ) = <$reader> ); + + my $error = ''; + + #shares some stuff with htdocs/edit/process/cust_main.cgi... take any + # common that are still here and library them. + my $cust_main = new FS::cust_main ( { + 'custnum' => '', + 'agentnum' => $agentnum, + 'refnum' => $refnum, + 'last' => $last, + 'first' => $first, + 'ss' => $ss, + 'company' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'county' => $county, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + } ); + my @invoicing_list = split( /\s*\,\s*/, $invoicing_list ); - while (1) { - my( $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $username, $password, $popnum, - ); - - - - my($username,$old_password,$new_password,$new_gecos,$new_shell); - defined($username=<$reader>) or last; - defined($old_password=<$reader>) or last; - defined($new_password=<$reader>) or last; - defined($new_gecos=<$reader>) or last; - defined($new_shell=<$reader>) or last; - chop($username); - chop($old_password); - chop($new_password); - chop($new_gecos); - chop($new_shell); - my($svc_acct); - - #need to try both $old_password and encrypted $old_password - #maybe the crypt function in svc_acct.export needs to be a library? - my $salt = substr($old_password,0,2); - my $cold_password = crypt($old_password,$salt); - $svc_acct=qsearchs('svc_acct',{'username'=>$username, - '_password'=>$old_password, - } ) - || qsearchs('svc_acct',{'username'=>$username, - '_password'=>$cold_password, + $error ||= $cust_main->check_invoicing_list( \@invoicing_list ); + + my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) + or die "unknown pkgpart $pkgpart"; + my $svcpart = $part_pkg->svcpart; + + # this should wind up in FS::cust_pkg! + die "agent $agentnum can't purchase pkgpart $pkgpart" + unless $pkgpart->{ $pkgpart }; + + my $cust_pkg = new FS::cust_pkg ( { + #later#'custnum' => $custnum, + 'pkgpart' => $pkgpart, + } ); + $error ||= $cust_pkg->check; + + $svc_acct = new FS::svc_acct ( { + 'svcpart' => $svcpart, + 'username' => $username, + '_password' => $password, + 'popnum' => $popnum, } ); - unless ( $svc_acct ) { print $writer "Incorrect password.\n"; next; } - - my(%hash)=$svc_acct->hash; - my($new_svc_acct) = new FS::svc_acct ( \%hash ); - $new_svc_acct->setfield('_password',$new_password) - if $new_password && $new_password ne $old_password; - $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos; - $new_svc_acct->setfield('shell',$new_shell) if $new_shell; - my($error)=$new_svc_acct->replace($svc_acct); - print $writer $error,"\n"; + + my $y = $svc_acct->setdefault; # arguably should be in new method + $error ||= $y unless ref($y); + #and just in case you were silly + $svc_acct->svcpart($svcpart); + $svc_acct->username($username); + $svc_acct->_password($password); + $svc_acct->popnum($popnum); + + $error ||= $svc_acct->check; + + $error ||= $cust_main->insert; + if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always + #be definied, but.... + $cust_pkg->custnum( $new->custnum ); + $error ||= $cust_pkg->insert; + warn "WARNING: $error on pre-checked cust_pkg record!" if $error; + $svc_acct->pkgnum( $cust_pkg->pkgnum ); + $error ||= $svc_acct->insert; + warn "WARNING: $error on pre-checked svc_acct record!" if $error; + } + + print $writer $error, "\n"; + + $cust_main->invoicing_list( \@invoicing_list ) unless $error; + } close $writer; close $reader; + warn "connection to $shellmachine lost! waiting 60 seconds...\n"; sleep 60; - warn "Connection to $shellmachine lost! Reconnecting...\n"; + warn "reconnecting...\n"; } sub usage { diff --git a/fs_signup/fs_signupd b/fs_signup/fs_signupd index 582e13ccd..71fd1540d 100755 --- a/fs_signup/fs_signupd +++ b/fs_signup/fs_signupd @@ -1,17 +1,16 @@ #!/usr/bin/perl -Tw # -# fs_passwdd +# fs_signupd # -# This is run REMOTELY over ssh by fs_passwd_server. +# This is run REMOTELY over ssh by fs_signup_server. # -# ivan@sisd.com 98-mar-9 use strict; use Socket; -my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; +my($fs_passwdd_socket)="/usr/local/freeside/fs_signupd_socket"; -$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = " \t\n"; $ENV{'CDPATH'} = ''; @@ -20,6 +19,46 @@ $ENV{'BASH_ENV'} = ''; $|=1; +chomp( my $n_cust_main_county = ); +my @cust_main_county = map { + chomp( my $taxnum = ); + chomp( my $state = ); + chomp( my $county = ); + chomp( my $country = ); + { + 'taxnum' => $taxnum, + 'state' => $state, + 'county' => $county, + 'country' => $country, + }; +} ( 1 .. $n_cust_main_county ); + +chomp( my $n_part_pkg = ); +my @part_pkg = map { + chomp( my $pkgpart = ); + chomp( my $pkg = ); + { + 'pkgpart' => $pkgpart, + 'pkg' => $pkg, + }; +} ( 1 .. $n_part_pkg ); + +chomp( my $n_svc_acct_pop = ); +my @svc_acct_pop = map { + chomp( my $popnum = ); + chomp( my $city = ); + chomp( my $state = ); + chomp( my $ac = ); + chomp( my $exch = ); + { + 'popnum' => $popnum, + 'city' => $city, + 'state' => $state, + 'ac' => $ac, + 'exch' => $exch, + }; +} ( 1 .. $n_svc_acct_pop ); + my $uaddr = sockaddr_un($fs_passwdd_socket); my $proto = getprotobyname('tcp'); @@ -28,22 +67,63 @@ unlink($fs_passwdd_socket); bind(Server, $uaddr) or die "bind: $!"; listen(Server,SOMAXCONN) or die "listen: $!"; -my($paddr); +my $paddr; + for ( ; $paddr = accept(Client,Server); close Client) { - my($me,$old_password,$new_password,$new_gecos,$new_shell); - $me=; - $old_password=; - $new_password=; - $new_gecos=; - $new_shell=; + chop( my $command = ); + + if ( $command eq "signup_info" ) { + + print Client join("\n", $n_cust_main_county, + map { + $_->{taxnum}, + $_->{state}, + $_->{county}, + $_->{country}, + } @cust_main_county + ), "\n"; + + print Client join("\n", $n_part_pkg, + map { + $_->{pkgpart}, + $_->{pkg}, + } @part_pkg + ), "\n"; + + print Client join("\n", $n_svc_acct_pop, + map { + $_->{popnum}, + $_->{city}, + $_->{state}, + $_->{ac}, + $_->{exch}, + } @svc_acct_pop + ), "\n"; + + } elsif ( $operation eq "new_customer" ) { + + my( + $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, + $popnum, + ) = ; + + print + $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, + $popnum, + ; + + my $error = ; + + print Client $error; - print $me,$old_password,$new_password,$new_gecos,$new_shell; - my($error); + } else { + die "unexpected command from client: $command"; + } - $error=; - - print Client $error; - close Client; } -- cgit v1.2.1 From 464d6da8fb57fe3e60e4c2c3cae6069bdafff6a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 24 Aug 1999 07:40:45 +0000 Subject: initial checkin of signup server --- fs_signup/FS-SignupClient/Changes | 5 + fs_signup/FS-SignupClient/MANIFEST | 8 + fs_signup/FS-SignupClient/MANIFEST.SKIP | 1 + fs_signup/FS-SignupClient/Makefile.PL | 10 + fs_signup/FS-SignupClient/cgi/signup.cgi | 302 +++++++++++++++++++++++++++++++ fs_signup/FS-SignupClient/fs_signupd | 139 ++++++++++++++ fs_signup/FS-SignupClient/test.pl | 20 ++ fs_signup/README | 18 ++ fs_signup/Signup.pm | 129 ------------- fs_signup/fs_signup_server | 61 ++++--- fs_signup/fs_signupd | 129 ------------- 11 files changed, 543 insertions(+), 279 deletions(-) create mode 100644 fs_signup/FS-SignupClient/Changes create mode 100644 fs_signup/FS-SignupClient/MANIFEST create mode 100644 fs_signup/FS-SignupClient/MANIFEST.SKIP create mode 100644 fs_signup/FS-SignupClient/Makefile.PL create mode 100755 fs_signup/FS-SignupClient/cgi/signup.cgi create mode 100755 fs_signup/FS-SignupClient/fs_signupd create mode 100644 fs_signup/FS-SignupClient/test.pl create mode 100644 fs_signup/README delete mode 100755 fs_signup/Signup.pm delete mode 100755 fs_signup/fs_signupd (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/Changes b/fs_signup/FS-SignupClient/Changes new file mode 100644 index 000000000..e750a82bc --- /dev/null +++ b/fs_signup/FS-SignupClient/Changes @@ -0,0 +1,5 @@ +Revision history for Perl extension FS::SignupClient. + +0.01 Mon Aug 23 01:12:46 1999 + - original version; created by h2xs 1.19 + diff --git a/fs_signup/FS-SignupClient/MANIFEST b/fs_signup/FS-SignupClient/MANIFEST new file mode 100644 index 000000000..b4a9900c8 --- /dev/null +++ b/fs_signup/FS-SignupClient/MANIFEST @@ -0,0 +1,8 @@ +Changes +MANIFEST +MANIFEST.SKIP +Makefile.PL +SignupClient.pm +test.pl +fs_signupd +cgi/signup.cgi diff --git a/fs_signup/FS-SignupClient/MANIFEST.SKIP b/fs_signup/FS-SignupClient/MANIFEST.SKIP new file mode 100644 index 000000000..ae335e78a --- /dev/null +++ b/fs_signup/FS-SignupClient/MANIFEST.SKIP @@ -0,0 +1 @@ +CVS/ diff --git a/fs_signup/FS-SignupClient/Makefile.PL b/fs_signup/FS-SignupClient/Makefile.PL new file mode 100644 index 000000000..859d757c3 --- /dev/null +++ b/fs_signup/FS-SignupClient/Makefile.PL @@ -0,0 +1,10 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'FS::SignupClient', + 'VERSION_FROM' => 'SignupClient.pm', # finds $VERSION + 'EXE_FILES' => [ 'fs_signupd' ], + 'INSTALLSCRIPT' => '/usr/local/sbin', + 'PERM_RWX' => '750', +); diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi new file mode 100755 index 000000000..7131ad2e8 --- /dev/null +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -0,0 +1,302 @@ +#!/usr/bin/perl -Tw +# +# $Id: signup.cgi,v 1.1 1999-08-24 07:40:45 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 ); +use subs qw( print_form print_okay expselect ); + +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use FS::SignupClient qw( signup_info new_customer ); + +#@payby = qw( CARD BILL COMP ); +#@payby = qw( CARD BILL ); +@payby = qw( CARD ); + +( $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"), + ); + + 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), + ); + + 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 { + 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 .= " ); +my @cust_main_county = map { + chomp( my $taxnum = ); + chomp( my $state = ); + chomp( my $county = ); + chomp( my $country = ); + { + 'taxnum' => $taxnum, + 'state' => $state, + 'county' => $county, + 'country' => $country, + }; +} ( 1 .. $n_cust_main_county ); + +warn "[fs_signupd] Reading package definitions...\n" if $Debug; +chomp( my $n_part_pkg = ); +my @part_pkg = map { + chomp( my $pkgpart = ); + chomp( my $pkg = ); + { + 'pkgpart' => $pkgpart, + 'pkg' => $pkg, + }; +} ( 1 .. $n_part_pkg ); + +warn "[fs_signupd] Reading POPs...\n" if $Debug; +chomp( my $n_svc_acct_pop = ); +my @svc_acct_pop = map { + chomp( my $popnum = ); + chomp( my $city = ); + chomp( my $state = ); + chomp( my $ac = ); + chomp( my $exch = ); + { + 'popnum' => $popnum, + 'city' => $city, + 'state' => $state, + 'ac' => $ac, + 'exch' => $exch, + }; +} ( 1 .. $n_svc_acct_pop ); + +warn "[fs_signupd] Creating $fs_signupd_socket\n" if $Debug; +my $uaddr = sockaddr_un($fs_signupd_socket); +my $proto = getprotobyname('tcp'); +socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; +unlink($fs_signupd_socket); +bind(Server, $uaddr) or die "bind: $!"; +listen(Server,SOMAXCONN) or die "listen: $!"; + +warn "[fs_signupd] Entering main loop...\n" if $Debug; +my $paddr; +for ( ; $paddr = accept(Client,Server); close Client) { + + chop( my $command = ); + + if ( $command eq "signup_info" ) { + warn "[fs_signupd] sending signup info...\n" if $Debug; + print Client join("\n", $n_cust_main_county, + map { + $_->{taxnum}, + $_->{state}, + $_->{county}, + $_->{country}, + } @cust_main_county + ), "\n"; + + print Client join("\n", $n_part_pkg, + map { + $_->{pkgpart}, + $_->{pkg}, + } @part_pkg + ), "\n"; + + print Client join("\n", $n_svc_acct_pop, + map { + $_->{popnum}, + $_->{city}, + $_->{state}, + $_->{ac}, + $_->{exch}, + } @svc_acct_pop + ), "\n"; + + } elsif ( $command eq "new_customer" ) { + warn "[fs_signupd] reading customer signup...\n" if $Debug; + my( + $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, + $popnum, + ) = map { scalar() } ( 1 .. 23 ); + + warn "[fs_signupd] sending customer data to remote server...\n" if $Debug; + print + $first, $last, $ss, $company, $address1, $address2, $city, $county, + $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, + $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, + $popnum, + ; + + warn "[fs_signupd] reading error from remote server...\n" if $Debug; + my $error = ; + + warn "[fs_signupd] sending error to local client...\n" if $Debug; + print Client $error; + + } else { + die "unexpected command from client: $command"; + } + +} + diff --git a/fs_signup/FS-SignupClient/test.pl b/fs_signup/FS-SignupClient/test.pl new file mode 100644 index 000000000..690f5840e --- /dev/null +++ b/fs_signup/FS-SignupClient/test.pl @@ -0,0 +1,20 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. + +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..1\n"; } +END {print "not ok 1\n" unless $loaded;} +use FS::SignupClient; +$loaded = 1; +print "ok 1\n"; + +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + diff --git a/fs_signup/README b/fs_signup/README new file mode 100644 index 000000000..631c22364 --- /dev/null +++ b/fs_signup/README @@ -0,0 +1,18 @@ +this should become better docs soon + +on client machine (public webserver): + +install perl, ssh, CGI.pm +cd FS-SignupClient; perl Makefile.PL; make; su; make install +copy or symlink FS-SignupClient/cgi/signup.cgi into the web server's view +use suExec or setuid to run cgi/signup.cgi as the freeside user +(chmod /usr/local/freeside/fs_signupd_socket 600, chown freeside) + +on server machine (Freeside machine): + +run fs_signup_server user machine agentnum refnum + + user is a freeside user from mapsecrets + machine is the client machine + agentnum and refnum are the fixed values for this signup server + diff --git a/fs_signup/Signup.pm b/fs_signup/Signup.pm deleted file mode 100755 index bcf09f1fe..000000000 --- a/fs_signup/Signup.pm +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -Tw -# -# fs_passwd -# -# portions of this script are copied from the `passwd' script in the original -# (perl 4) camel book, now archived at -# http://www.perl.com/CPAN/scripts/nutshell/ch6/passwd -# -# ivan@sisd.com 98-mar-8 -# -# password lengths 0,255 instead of 6,8 - we'll let the server process -# check the data ivan@sisd.com 98-jul-17 - -use strict; -use Getopt::Std; -use Socket; -use IO::Handle; -use vars qw($opt_f $opt_s); - -my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; -my($freeside_uid)=scalar(getpwnam('freeside')); - -$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; -$ENV{'SHELL'} = '/bin/sh'; -$ENV{'IFS'} = " \t\n"; -$ENV{'CDPATH'} = ''; -$ENV{'ENV'} = ''; -$ENV{'BASH_ENV'} = ''; - -$SIG{__DIE__}= sub { system '/bin/stty', 'echo'; }; - -die "passwd program isn't running setuid to freeside\n" if $> != $freeside_uid; - -unshift @ARGV, "-f" if $0 =~ /chfn$/; -unshift @ARGV, "-s" if $0 =~ /chsh$/; - -getopts('fs'); - -my($me)=''; -if ( $_ = shift(@ARGV) ) { - /^(\w{2,8})$/; - $me = $1; -} -die "You can't change the password for $me." if $me && $<; -$me = (getpwuid($<))[0] unless $me; - -my($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell)= - getpwnam $me; - -my($old_password,$new_password,$new_gecos,$new_shell); - -if ( $opt_f || $opt_s ) { - system '/bin/stty', '-echo'; - print "Password:"; - $old_password=; - system '/bin/stty', 'echo'; - chop($old_password); - #$old_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; - $old_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; - $old_password = $1; - - $new_password = ''; - - if ( $opt_f ) { - print "\nChanging gecos for $me.\n"; - print "Gecos [", $gcos, "]: "; - $new_gecos=; - chop($new_gecos); - $new_gecos ||= $gcos; - $new_gecos =~ /^(.{0,255})$/ or die "\nIllegal gecos.\n"; - } else { - $new_gecos = ''; - } - - if ( $opt_s ) { - print "\nChanging shell for $me.\n"; - print "Shell [", $shell, "]: "; - $new_shell=; - chop($new_shell); - $new_shell ||= $shell; - $new_shell =~ /^(.{0,255})$/ or die "\nIllegal shell.\n"; - } else { - $new_shell = ''; - } - -} else { - - print "Changing password for $me.\n"; - print "Old password:"; - system '/bin/stty', '-echo'; - $old_password=; - chop $old_password; - #$old_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; - $old_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; - $old_password = $1; - print "\nEnter the new password (minimum of 6, maximum of 8 characters)\n"; - print "Please use a combination of upper and lowercase letters and numbers.\n"; - print "New password:"; - $new_password=; - chop($new_password); - #$new_password =~ /^(.{6,8})$/ or die "\nIllegal password.\n"; - $new_password =~ /^(.{0,255})$/ or die "\nIllegal password.\n"; - $new_password = $1; - print "\nRe-enter new password:"; - my($check_new_password); - $check_new_password=; - chop($check_new_password); - die "\nThey don't match; try again.\n" unless $check_new_password eq $new_password; - - $new_gecos=''; - $new_shell=''; -} -print "\n"; - -system '/bin/stty', 'echo'; - -socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; -connect(SOCK, sockaddr_un($fs_passwdd_socket)) or die "connect: $!"; -print SOCK join("\n",$me,$old_password,$new_password,$new_gecos,$new_shell),"\n"; -SOCK->flush; -my($error); -$error = ; -chop $error; - -if ($error) { - print "\nUpdate error: $error\n"; -} else { - print "\nUpdate sucessful.\n"; -} diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index cf2519ec0..e1c9b3517 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -7,14 +7,18 @@ use strict; use IO::Handle; use FS::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); -use FS::Record qw(qsearchs); +use FS::Record qw( qsearch qsearchs ); use FS::cust_main_county; use FS::cust_main; -use vars qw( $opt ); +use vars qw( $opt $Debug ); + +$Debug = 0; + +my @payby = qw(CARD); my $user = shift or die &usage; -adminsuidsetup $user; +&adminsuidsetup( $user ); my $machine = shift or die &usage; @@ -31,12 +35,15 @@ my($fs_signupd)="/usr/local/sbin/fs_signupd"; while (1) { my($reader,$writer)=(new IO::Handle, new IO::Handle); $writer->autoflush(1); - sshopen2($shellmachine,$reader,$writer,$fs_signupd); + warn "[fs_signup_server] Connecting to $machine...\n" if $Debug; + sshopen2($machine,$reader,$writer,$fs_signupd); + + my $data; - #send fs_signupd state/county/country - @my cust_main_county = qsearch('cust_main_county', {} ); - print $writer join("\n", - scalar(@cust_main_county) || die "no tax rates (cust_main_county records)", + warn "[fs_signup_server] Sending locales...\n" if $Debug; + my @cust_main_county = qsearch('cust_main_county', {} ); + print $writer $data = join("\n", + ( scalar(@cust_main_county) || die "no tax rates (cust_main_county records)" ), map { $_->taxnum, $_->state, @@ -44,22 +51,24 @@ while (1) { $_->country, } @cust_main_county ),"\n"; + warn "[fs_signup_server] $data\n" if $Debug > 2; - #send fs_signupd package definitions + warn "[fs_signup_server] Sending package definitions...\n" if $Debug; my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } qsearch( 'part_pkg', {} ); - print $writer join("\n", - scalar(@part_pkg) || die "no usable package definitions, agent $agentnum", + print $writer $data = join("\n", + ( scalar(@part_pkg) || die "no usable package definitions, agent $agentnum" ), map { $_->pkgpart, $_->pkg, } @part_pkg ), "\n"; + warn "[fs_signup_server] $data\n" if $Debug > 2; - #send fs_signupd POPs + warn "[fs_signup_server] Sending POPs...\n" if $Debug; my @svc_acct_pop = qsearch ('svc_acct_pop',{} ); - print $writer join("\n", - scalar(@svc_acct_pop) || die "No points of presence (svc_acct_pop records)", + print $writer $data = join("\n", + ( scalar(@svc_acct_pop) || die "No points of presence (svc_acct_pop records)" ), map { $_->popnum, $_->city, @@ -68,14 +77,19 @@ while (1) { $_->exch, } @svc_acct_pop ), "\n"; + warn "[fs_signup_server] $data\n" if $Debug > 2; + warn "[fs_signup_server] Entering main loop...\n" if $Debug; while (1) { + warn "[fs_signup_server] Reading (waiting for) signup data...\n" if $Debug; chop( my( $first, $last, $ss, $company, $address1, $address2, $city, $county, $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, $popnum, - ) = <$reader> ); + ) = map { scalar(<$reader>) } ( 1 .. 23 ) ); + + warn "[fs_signup_server] Processing signup...\n" if $Debug; my $error = ''; @@ -105,17 +119,21 @@ while (1) { 'payname' => $payname, } ); + $error = "Illegal payment type" unless grep { $_ eq $payby } @payby; + my @invoicing_list = split( /\s*\,\s*/, $invoicing_list ); $error ||= $cust_main->check_invoicing_list( \@invoicing_list ); my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) - or die "unknown pkgpart $pkgpart"; + or $error ||= "WARNING: unknown pkgpart $pkgpart"; my $svcpart = $part_pkg->svcpart; # this should wind up in FS::cust_pkg! - die "agent $agentnum can't purchase pkgpart $pkgpart" - unless $pkgpart->{ $pkgpart }; + my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ); + my $pkgpart_href = $agent->pkgpart_hashref; + $error ||= "WARNING: agent $agentnum can't purchase pkgpart $pkgpart" + unless $pkgpart_href->{ $pkgpart }; my $cust_pkg = new FS::cust_pkg ( { #later#'custnum' => $custnum, @@ -123,7 +141,7 @@ while (1) { } ); $error ||= $cust_pkg->check; - $svc_acct = new FS::svc_acct ( { + my $svc_acct = new FS::svc_acct ( { 'svcpart' => $svcpart, 'username' => $username, '_password' => $password, @@ -143,7 +161,7 @@ while (1) { $error ||= $cust_main->insert; if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always #be definied, but.... - $cust_pkg->custnum( $new->custnum ); + $cust_pkg->custnum( $cust_main->custnum ); $error ||= $cust_pkg->insert; warn "WARNING: $error on pre-checked cust_pkg record!" if $error; $svc_acct->pkgnum( $cust_pkg->pkgnum ); @@ -151,6 +169,7 @@ while (1) { warn "WARNING: $error on pre-checked svc_acct record!" if $error; } + warn "[fs_signup_server] Sending results...\n" if $Debug; print $writer $error, "\n"; $cust_main->invoicing_list( \@invoicing_list ) unless $error; @@ -158,7 +177,7 @@ while (1) { } close $writer; close $reader; - warn "connection to $shellmachine lost! waiting 60 seconds...\n"; + warn "connection to $machine lost! waiting 60 seconds...\n"; sleep 60; warn "reconnecting...\n"; } diff --git a/fs_signup/fs_signupd b/fs_signup/fs_signupd deleted file mode 100755 index 71fd1540d..000000000 --- a/fs_signup/fs_signupd +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -Tw -# -# fs_signupd -# -# This is run REMOTELY over ssh by fs_signup_server. -# - -use strict; -use Socket; - -my($fs_passwdd_socket)="/usr/local/freeside/fs_signupd_socket"; - -$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; -$ENV{'SHELL'} = '/bin/sh'; -$ENV{'IFS'} = " \t\n"; -$ENV{'CDPATH'} = ''; -$ENV{'ENV'} = ''; -$ENV{'BASH_ENV'} = ''; - -$|=1; - -chomp( my $n_cust_main_county = ); -my @cust_main_county = map { - chomp( my $taxnum = ); - chomp( my $state = ); - chomp( my $county = ); - chomp( my $country = ); - { - 'taxnum' => $taxnum, - 'state' => $state, - 'county' => $county, - 'country' => $country, - }; -} ( 1 .. $n_cust_main_county ); - -chomp( my $n_part_pkg = ); -my @part_pkg = map { - chomp( my $pkgpart = ); - chomp( my $pkg = ); - { - 'pkgpart' => $pkgpart, - 'pkg' => $pkg, - }; -} ( 1 .. $n_part_pkg ); - -chomp( my $n_svc_acct_pop = ); -my @svc_acct_pop = map { - chomp( my $popnum = ); - chomp( my $city = ); - chomp( my $state = ); - chomp( my $ac = ); - chomp( my $exch = ); - { - 'popnum' => $popnum, - 'city' => $city, - 'state' => $state, - 'ac' => $ac, - 'exch' => $exch, - }; -} ( 1 .. $n_svc_acct_pop ); - -my $uaddr = sockaddr_un($fs_passwdd_socket); -my $proto = getprotobyname('tcp'); - -socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; -unlink($fs_passwdd_socket); -bind(Server, $uaddr) or die "bind: $!"; -listen(Server,SOMAXCONN) or die "listen: $!"; - -my $paddr; - -for ( ; $paddr = accept(Client,Server); close Client) { - - chop( my $command = ); - - if ( $command eq "signup_info" ) { - - print Client join("\n", $n_cust_main_county, - map { - $_->{taxnum}, - $_->{state}, - $_->{county}, - $_->{country}, - } @cust_main_county - ), "\n"; - - print Client join("\n", $n_part_pkg, - map { - $_->{pkgpart}, - $_->{pkg}, - } @part_pkg - ), "\n"; - - print Client join("\n", $n_svc_acct_pop, - map { - $_->{popnum}, - $_->{city}, - $_->{state}, - $_->{ac}, - $_->{exch}, - } @svc_acct_pop - ), "\n"; - - } elsif ( $operation eq "new_customer" ) { - - my( - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ) = ; - - print - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ; - - my $error = ; - - print Client $error; - - } else { - die "unexpected command from client: $command"; - } - -} - -- cgit v1.2.1 From 76b34eacaaa4237ef73b24a028a01b45020d77b3 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 24 Aug 1999 07:56:38 +0000 Subject: forgot this file! --- fs_signup/FS-SignupClient/SignupClient.pm | 215 ++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 fs_signup/FS-SignupClient/SignupClient.pm (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/SignupClient.pm b/fs_signup/FS-SignupClient/SignupClient.pm new file mode 100644 index 000000000..d3118467b --- /dev/null +++ b/fs_signup/FS-SignupClient/SignupClient.pm @@ -0,0 +1,215 @@ +package FS::SignupClient; + +use strict; +use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket); +use Exporter; +use Socket; +use IO::Handle; + +$VERSION = '0.01'; + +@ISA = qw( Exporter ); +@EXPORT_OK = qw( signup_info new_customer ); + +$fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket"; + +$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; + +my $freeside_uid = scalar(getpwnam('freeside')); +die "not running as the freeside user\n" if $> != $freeside_uid; + +=head1 NAME + +FS::SignupClient - Freeside signup client API + +=head1 SYNOPSIS + + use FS::SignupClient qw( signup_info new_customer ); + + ( $locales, $packages, $pops ) = signup_info; + + $error = new_customer ( { + 'first' => $first, + 'last' => $last, + 'ss' => $ss, + 'comapny' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'county' => $county, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + 'invoicing_list' => $invoicing_list, + 'pkgpart' => $pkgpart, + 'username' => $username, + '_password' => $password, + 'popnum' => $popnum, + } ); + +=head1 DESCRIPTION + +This module provides an API for a remote signup server. + +It needs to be run as the freeside user. Because of this, the program which +calls these subroutines should be written very carefully. + +=head1 SUBROUTINES + +=over 4 + +=item signup_info + +Returns three array references of hash references. + +The first set of hash references is of allowable locales. Each hash reference +has the following keys: + taxnum + state + county + country + +The second set of hash references is of allowable packages. Each hash +reference has the following keys: + pkgpart + pkg + +The third set of hash references is of allowable POPs (Points Of Presence). +Each hash reference has the following keys: + popnum + city + state + ac + exch + +=cut + +sub signup_info { + socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; + connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!"; + print SOCK "signup_info\n"; + SOCK->flush; + + chop ( my $n_cust_main_county = ); + my @cust_main_county = map { + chop ( my $taxnum = ); + chop ( my $state = ); + chop ( my $county = ); + chop ( my $country = ); + { + 'taxnum' => $taxnum, + 'state' => $state, + 'county' => $county, + 'country' => $country, + }; + } 1 .. $n_cust_main_county; + + chop ( my $n_part_pkg = ); + my @part_pkg = map { + chop ( my $pkgpart = ); + chop ( my $pkg = ); + { + 'pkgpart' => $pkgpart, + 'pkg' => $pkg, + }; + } 1 .. $n_part_pkg; + + chop ( my $n_svc_acct_pop = ); + my @svc_acct_pop = map { + chop ( my $popnum = ); + chop ( my $city = ); + chop ( my $state = ); + chop ( my $ac = ); + chop ( my $exch = ); + { + 'popnum' => $popnum, + 'city' => $city, + 'state' => $state, + 'ac' => $ac, + 'exch' => $exch, + }; + } 1 .. $n_svc_acct_pop; + + close SOCK; + + \@cust_main_county, \@part_pkg, \@svc_acct_pop; +} + +=item new_customer HASHREF + +Adds a customer to the remote Freeside system. Requires a hash reference as +a paramater with the following keys: + first + last + ss + comapny + address1 + address2 + city + county + state + zip + country + daytime + night + fax + payby + payinfo + paydate + payname + invoicing_list + pkgpart + username + _password + popnum + +Returns a scalar error message, or the empty string for success. + +=cut + +sub new_customer { + my $hashref = shift; + + socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; + connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!"; + print SOCK "new_customer\n"; + + print SOCK join("\n", map { $hashref->{$_} } qw( + first last ss company address1 address2 city county state zip country + daytime night fax payby payinfo paydate payname invoicing_list + pkgpart username _password popnum + ) ), "\n"; + SOCK->flush; + + chop( my $error = ); + $error; +} + +=back + +=head1 VERSION + +$Id: SignupClient.pm,v 1.1 1999-08-24 07:56:38 ivan Exp $ + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L + +=cut + +1; + -- cgit v1.2.1 From add9a2b100af10df0b5d4ed174c158d99358cee3 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Dec 1999 12:03:03 +0000 Subject: beginning of IEAK support --- fs_signup/FS-SignupClient/cgi/signup.cgi | 80 ++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 7131ad2e8..15767c151 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,22 +1,34 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.1 1999-08-24 07:40:45 ivan Exp $ +# $Id: signup.cgi,v 1.2 1999-12-17 12:03:03 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 ); + $paydate $payname $pkgpart $username $password $popnum + $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 ); +#acceptable payment methods +# #@payby = qw( CARD BILL COMP ); #@payby = qw( CARD BILL ); @payby = qw( CARD ); +#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; @@ -265,13 +277,75 @@ END } sub print_okay { - print $cgi->header( '-expires' => 'now' ), <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'); + 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 { -- cgit v1.2.1 From 359433c470f820e110e3da847700fd32aa3d44d1 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2000 22:47:31 +0000 Subject: wrote real documentation --- fs_signup/README | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 fs_signup/README (limited to 'fs_signup') diff --git a/fs_signup/README b/fs_signup/README deleted file mode 100644 index 631c22364..000000000 --- a/fs_signup/README +++ /dev/null @@ -1,18 +0,0 @@ -this should become better docs soon - -on client machine (public webserver): - -install perl, ssh, CGI.pm -cd FS-SignupClient; perl Makefile.PL; make; su; make install -copy or symlink FS-SignupClient/cgi/signup.cgi into the web server's view -use suExec or setuid to run cgi/signup.cgi as the freeside user -(chmod /usr/local/freeside/fs_signupd_socket 600, chown freeside) - -on server machine (Freeside machine): - -run fs_signup_server user machine agentnum refnum - - user is a freeside user from mapsecrets - machine is the client machine - agentnum and refnum are the fixed values for this signup server - -- cgit v1.2.1 From 7fa1271c9e0be6e154aa12d31466109407bb03b4 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2000 22:48:33 +0000 Subject: example template --- fs_signup/ieak.template | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 fs_signup/ieak.template (limited to 'fs_signup') diff --git a/fs_signup/ieak.template b/fs_signup/ieak.template new file mode 100755 index 000000000..5da2a2036 --- /dev/null +++ b/fs_signup/ieak.template @@ -0,0 +1,40 @@ +[Entry]\r +Entry_Name = The Internet\r +[Phone]\r +Dial_As_Is=no\r +Phone_Number = { $exch. $loc }\r +Area_Code = { $ac }\r +Country_Code = 1\r +Country_Id = 1\r +[Server]\r +Type = PPP\r +SW_Compress = Yes\r +PW_Encrypt = Yes\r +Negotiate_TCP/IP = Yes\r +Disable_LCP = No\r +[TCP/IP]\r +Specify_IP_Address = No\r +Specity_Server_Address = No\r +IP_Header_Compress = Yes\r +Gateway_On_Remote = Yes\r +[User]\r +Name = { $username }\r +Password = { $password }\r +Display_Password = Yes\r +[Internet_Mail]\r +Email_Name = { $email_name }\r +Email_Address = { $username }\@domain.tld\r +POP_Server = mail.domain.tld\r +POP_Server_Port_Number = 110\r +POP_Login_Name = { $username }\r +POP_Login_Password = { $password }\r +SMTP_Server = mail.domain.tld\r +SMTP_Server_Port_Number = 25\r +Install_Mail = 1\r +[Internet_News]\r +NNTP_Server = news.domain.tld\r +NNTP_Server_Port_Number = 119\r +Logon_Required = No\r +Install_News = 1\r +[Branding]\r +Window_Title = The Internet\r -- cgit v1.2.1 From 5e39e2d7963d6f8304e5afb5d8b5f50aa6eaaf14 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2000 22:49:28 +0000 Subject: full phone number --- fs_signup/FS-SignupClient/SignupClient.pm | 4 +++- fs_signup/FS-SignupClient/fs_signupd | 3 +++ fs_signup/fs_signup_server | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/SignupClient.pm b/fs_signup/FS-SignupClient/SignupClient.pm index d3118467b..7c96609f6 100644 --- a/fs_signup/FS-SignupClient/SignupClient.pm +++ b/fs_signup/FS-SignupClient/SignupClient.pm @@ -133,12 +133,14 @@ sub signup_info { chop ( my $state = ); chop ( my $ac = ); chop ( my $exch = ); + chop ( my $loc = ); { 'popnum' => $popnum, 'city' => $city, 'state' => $state, 'ac' => $ac, 'exch' => $exch, + 'loc' => $loc, }; } 1 .. $n_svc_acct_pop; @@ -201,7 +203,7 @@ sub new_customer { =head1 VERSION -$Id: SignupClient.pm,v 1.1 1999-08-24 07:56:38 ivan Exp $ +$Id: SignupClient.pm,v 1.2 2000-01-28 22:49:28 ivan Exp $ =head1 BUGS diff --git a/fs_signup/FS-SignupClient/fs_signupd b/fs_signup/FS-SignupClient/fs_signupd index 972e3c7b4..f22ab15d4 100755 --- a/fs_signup/FS-SignupClient/fs_signupd +++ b/fs_signup/FS-SignupClient/fs_signupd @@ -57,12 +57,14 @@ my @svc_acct_pop = map { chomp( my $state = ); chomp( my $ac = ); chomp( my $exch = ); + chomp( my $loc = ); { 'popnum' => $popnum, 'city' => $city, 'state' => $state, 'ac' => $ac, 'exch' => $exch, + 'loc' => $loc, }; } ( 1 .. $n_svc_acct_pop ); @@ -105,6 +107,7 @@ for ( ; $paddr = accept(Client,Server); close Client) { $_->{state}, $_->{ac}, $_->{exch}, + $_->{loc}, } @svc_acct_pop ), "\n"; diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index e1c9b3517..56d616b53 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -75,6 +75,7 @@ while (1) { $_->state, $_->ac, $_->exch, + $_->loc, } @svc_acct_pop ), "\n"; warn "[fs_signup_server] $data\n" if $Debug > 2; -- cgit v1.2.1 From b202e6a1fd3f2ef13f5bc8d77f44e2869083c494 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2000 22:49:49 +0000 Subject: proper IEAK stuff --- fs_signup/FS-SignupClient/cgi/signup.cgi | 88 +++++++++++--------------------- 1 file changed, 30 insertions(+), 58 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 15767c151..6fccf11b1 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,19 +1,22 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.2 1999-12-17 12:03:03 ivan Exp $ +# $Id: signup.cgi,v 1.3 2000-01-28 22:49:49 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_docroot $ieak_baseurl ); + $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 # @@ -21,11 +24,20 @@ use FS::SignupClient qw( signup_info new_customer ); #@payby = qw( CARD BILL ); @payby = qw( CARD ); -#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"; +$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`); @@ -277,65 +289,25 @@ END } sub print_okay { - $user_agent = new HTTP::Headers::UserAgnet $ENV{HTTP_USER_AGENT}; - if ( defined($ieak_docroot) - && defined($ieak_baseurl) - && defined($ieak_secret) + 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' + && ($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'); - my $ins_file = rand(4294967296). ".ins"; - open(INS_FILE, ">$ieak_docroot/$ins_file"); - print INS_FILE <redirect("$ieak_docroot/$ins_file"); + 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' ), < Date: Mon, 31 Jan 2000 05:22:23 +0000 Subject: prepaid "internet cards" --- fs_signup/FS-SignupClient/cgi/signup.cgi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 6fccf11b1..961ad505a 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.3 2000-01-28 22:49:49 ivan Exp $ +# $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 @@ -22,7 +22,8 @@ use Text::Template; # #@payby = qw( CARD BILL COMP ); #@payby = qw( CARD BILL ); -@payby = qw( CARD ); +#@payby = qw( CARD ); +@payby = qw( CARD PREPAY ); $ieak_file = '/usr/local/freeside/ieak.template'; @@ -220,12 +221,14 @@ END '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) { -- cgit v1.2.1 From b812b5a4a664e0bd271392ae4a609b18e85ca6b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Feb 2000 07:44:00 +0000 Subject: fix some bugs in signup server --- fs_signup/FS-SignupClient/SignupClient.pm | 3 ++- fs_signup/FS-SignupClient/cgi/signup.cgi | 4 ++-- fs_signup/fs_signup_server | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/SignupClient.pm b/fs_signup/FS-SignupClient/SignupClient.pm index 7c96609f6..5769c18fc 100644 --- a/fs_signup/FS-SignupClient/SignupClient.pm +++ b/fs_signup/FS-SignupClient/SignupClient.pm @@ -4,6 +4,7 @@ use strict; use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket); use Exporter; use Socket; +use FileHandle; use IO::Handle; $VERSION = '0.01'; @@ -203,7 +204,7 @@ sub new_customer { =head1 VERSION -$Id: SignupClient.pm,v 1.2 2000-01-28 22:49:28 ivan Exp $ +$Id: SignupClient.pm,v 1.3 2000-02-02 07:44:00 ivan Exp $ =head1 BUGS diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 961ad505a..e5cf6d050 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.4 2000-01-31 05:22:23 ivan Exp $ +# $Id: signup.cgi,v 1.5 2000-02-02 07:44:00 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $r $error @@ -292,7 +292,7 @@ END } sub print_okay { - my $user_agent = new HTTP::Headers::UserAgnet $ENV{HTTP_USER_AGENT}; + my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT}; if ( $ieak_template && $user_agent->platform eq 'ia32' && $user_agent->os =~ /^win/ diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 56d616b53..f6702386e 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -128,7 +128,7 @@ while (1) { my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) or $error ||= "WARNING: unknown pkgpart $pkgpart"; - my $svcpart = $part_pkg->svcpart; + my $svcpart = $part_pkg->svcpart unless $error; # this should wind up in FS::cust_pkg! my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ); -- cgit v1.2.1 From 3bfec7cf75a1a4eb4da1cdf8c64003bd6babcd81 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Feb 2000 20:22:18 +0000 Subject: bugfix prepayment in signup server --- fs_signup/fs_signup_server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index f6702386e..1d7ab291b 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -15,7 +15,7 @@ use vars qw( $opt $Debug ); $Debug = 0; -my @payby = qw(CARD); +my @payby = qw(CARD PREPAY); my $user = shift or die &usage; &adminsuidsetup( $user ); -- cgit v1.2.1 From ee2813f461f788e18c13bf0eabbf6bd242f51c2f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 1 Mar 2000 08:14:30 +0000 Subject: cvs cruft --- fs_signup/FS-SignupClient/cgi/signup.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index e5cf6d050..48376c219 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.5 2000-02-02 07:44:00 ivan Exp $ +# $Id: signup.cgi,v 1.6 2000-03-01 08:14:30 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $r $error -- cgit v1.2.1 From 11df841f26fa4b5f6531109cbf0db87a376cfc3c Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 May 2000 23:57:57 +0000 Subject: Netscape CCK autoconfiguration support --- fs_signup/FS-SignupClient/cgi/signup.cgi | 67 ++++++++++++++++++++++---------- fs_signup/cck.template | 14 +++++++ 2 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 fs_signup/cck.template (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 48376c219..839ad333d 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,15 +1,15 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.6 2000-03-01 08:14:30 ivan Exp $ +# $Id: signup.cgi,v 1.7 2000-05-10 23:57:57 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_file $ieak_template $cck_file $cck_template + $ac $exch $loc ); - #$ieak_docroot $ieak_baseurl use subs qw( print_form print_okay expselect ); use CGI; @@ -26,6 +26,7 @@ use Text::Template; @payby = qw( CARD PREPAY ); $ieak_file = '/usr/local/freeside/ieak.template'; +$cck_file = '/usr/local/freeside/cck.template'; if ( -e $ieak_file ) { $ieak_template = new Text::Template ( TYPE => 'FILE', SOURCE => $ieak_file ) @@ -33,14 +34,12 @@ if ( -e $ieak_file ) { } 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`); +if ( -e $cck_file ) { + $cck_template = new Text::Template ( TYPE => 'FILE', SOURCE => $cck_file ) + or die "Couldn't construct template: $Text::Template::ERROR"; +} else { + $cck_template = ''; +} ( $locales, $packages, $pops ) = signup_info(); @@ -293,24 +292,41 @@ END 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"; + my $email_name = $1; + + my $pop = pop_info($cgi->param('popnum')) + or die "fatal: invalid popnum got past FS::SignupClient::new_customer"; + my ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} ); + 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"); + } 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' ), <{'popnum'} == $popnum ) { return $pop; } + } + ''; +} + sub expselect { my $prefix = shift; my $date = shift || ''; diff --git a/fs_signup/cck.template b/fs_signup/cck.template new file mode 100644 index 000000000..f1db554b1 --- /dev/null +++ b/fs_signup/cck.template @@ -0,0 +1,14 @@ +SITE_FILE 8chrfile +SITE_NAME YourISP +LOGIN { $username } +PASSWORD { $password } +PHONE_NUM +1({ $ac }){ $exch }-{ $loc } +DNS_ADDR 10.0.0.1 +DNS_ADDR2 10.0.0.2 +NNTP_HOST news.yourisp.com +SMTP_HOST mail.yourisp.com +DOMAIN_NAME yourisp.com +POP_SERVER { $username }@mail.yourisp.com +POP_PASSWORD { $password } +HOME_URL http://www.yourisp.com +EMAIL_ADDR { $username }@yourisp.com -- cgit v1.2.1 From 31063fe61bb3b76b52832d2e501e997274cdd2b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 7 Jul 2000 04:05:25 +0000 Subject: wait()ing on SIGCHLD causing hangs for some folks --- fs_signup/fs_signup_server | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 1d7ab291b..b5fc23c28 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -28,7 +28,8 @@ my $pkgpart = $agent->pkgpart_hashref; my $refnum = shift or die &usage; -$SIG{CHLD} = sub { wait() }; +#causing trouble for some folks +#$SIG{CHLD} = sub { wait() }; my($fs_signupd)="/usr/local/sbin/fs_signupd"; -- cgit v1.2.1 From f01fe96a27912381d4b30ccad3d355d74f76f505 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 24 Aug 2000 07:26:50 +0000 Subject: untaint template source --- fs_signup/FS-SignupClient/cgi/signup.cgi | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 839ad333d..7576b8b42 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.7 2000-05-10 23:57:57 ivan Exp $ +# $Id: signup.cgi,v 1.8 2000-08-24 07:26:50 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $r $error @@ -29,14 +29,22 @@ $ieak_file = '/usr/local/freeside/ieak.template'; $cck_file = '/usr/local/freeside/cck.template'; if ( -e $ieak_file ) { - $ieak_template = new Text::Template ( TYPE => 'FILE', SOURCE => $ieak_file ) - or die "Couldn't construct template: $Text::Template::ERROR"; + my $ieak_txt = Text::Template::_load_text($ieak_file) + or die $Text::Template::ERROR; + $ieak_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $ieak_txt = $1; + $ieak_template = new Text::Template ( TYPE => 'STRING', SOURCE => $ieak_txt ) + or die $Text::Template::ERROR; } else { $ieak_template = ''; } if ( -e $cck_file ) { - $cck_template = new Text::Template ( TYPE => 'FILE', SOURCE => $cck_file ) - or die "Couldn't construct template: $Text::Template::ERROR"; + my $cck_txt = Text::Template::_load_text($cck_file) + or die $Text::Template::ERROR; + $cck_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $cck_txt = $1; + $cck_template = new Text::Template ( TYPE => 'STRING', SOURCE => $cck_txt ) + or die $Text::Template::ERROR; } else { $cck_template = ''; } -- cgit v1.2.1 From 65dea21c4088a0dbf3e8863a6dadc39aed67d4db Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 14:29:15 +0000 Subject: template bugfix from Jason Spence --- fs_signup/FS-SignupClient/cgi/signup.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 7576b8b42..a3fa9e788 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.8 2000-08-24 07:26:50 ivan Exp $ +# $Id: signup.cgi,v 1.9 2000-12-03 14:29:15 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $r $error @@ -313,7 +313,7 @@ sub print_okay { my $pop = pop_info($cgi->param('popnum')) or die "fatal: invalid popnum got past FS::SignupClient::new_customer"; - my ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} ); + ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} ); if ( $ieak_template && $user_agent->platform eq 'ia32' -- cgit v1.2.1 From d220c8a4bfa1aee8f17ed71c2dba655160dd3595 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 3 Feb 2001 14:03:50 +0000 Subject: time-based prepaid cards, session monitor. woop! --- fs_signup/fs_signup_server | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index b5fc23c28..86455a477 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -5,6 +5,7 @@ use strict; use IO::Handle; +use Tie::RefHash; use FS::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); use FS::Record qw( qsearch qsearchs ); @@ -160,16 +161,19 @@ while (1) { $error ||= $svc_acct->check; - $error ||= $cust_main->insert; - if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always - #be definied, but.... - $cust_pkg->custnum( $cust_main->custnum ); - $error ||= $cust_pkg->insert; - warn "WARNING: $error on pre-checked cust_pkg record!" if $error; - $svc_acct->pkgnum( $cust_pkg->pkgnum ); - $error ||= $svc_acct->insert; - warn "WARNING: $error on pre-checked svc_acct record!" if $error; - } + use Tie::RefHash; + tie my %hash, 'Tie::RefHash'; + %hash = { $cust_pkg => [ $svc_acct ] }; + $error ||= $cust_main->insert( \%hash ); + #if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always + # #be definied, but.... + # $cust_pkg->custnum( $cust_main->custnum ); + # $error ||= $cust_pkg->insert; + # warn "WARNING: $error on pre-checked cust_pkg record!" if $error; + # $svc_acct->pkgnum( $cust_pkg->pkgnum ); + # $error ||= $svc_acct->insert; + # warn "WARNING: $error on pre-checked svc_acct record!" if $error; + #} warn "[fs_signup_server] Sending results...\n" if $Debug; print $writer $error, "\n"; -- cgit v1.2.1 From 1c14b1faec0f3f07a6d4190cf535b3ddb45075ce Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 22 Apr 2001 01:56:15 +0000 Subject: get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) --- fs_signup/fs_signup_server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 86455a477..8fbc819ad 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -6,7 +6,7 @@ use strict; use IO::Handle; use Tie::RefHash; -use FS::SSH qw(sshopen2); +use Net::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); use FS::Record qw( qsearch qsearchs ); use FS::cust_main_county; -- cgit v1.2.1 From df962da38244a75e6a10277770b641bb73053e57 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 7 May 2001 02:07:38 +0000 Subject: http://www.sisd.com/freeside/list-archive/msg01906.html --- fs_signup/fs_signup_server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 8fbc819ad..03defd6f9 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -163,7 +163,7 @@ while (1) { use Tie::RefHash; tie my %hash, 'Tie::RefHash'; - %hash = { $cust_pkg => [ $svc_acct ] }; + %hash = ( $cust_pkg => [ $svc_acct ] ); $error ||= $cust_main->insert( \%hash ); #if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always # #be definied, but.... -- cgit v1.2.1 From 35f71d9fa1c7304e4be260d5db28c0a8480b4750 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Aug 2001 10:52:54 +0000 Subject: fix email invoice to the being-creted-account bug --- fs_signup/fs_signup_server | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 03defd6f9..c6ee665fa 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -126,8 +126,6 @@ while (1) { my @invoicing_list = split( /\s*\,\s*/, $invoicing_list ); - $error ||= $cust_main->check_invoicing_list( \@invoicing_list ); - my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) or $error ||= "WARNING: unknown pkgpart $pkgpart"; my $svcpart = $part_pkg->svcpart unless $error; @@ -164,22 +162,11 @@ while (1) { use Tie::RefHash; tie my %hash, 'Tie::RefHash'; %hash = ( $cust_pkg => [ $svc_acct ] ); - $error ||= $cust_main->insert( \%hash ); - #if ( $cust_pkg && ! $error ) { #in this case, $cust_pkg should always - # #be definied, but.... - # $cust_pkg->custnum( $cust_main->custnum ); - # $error ||= $cust_pkg->insert; - # warn "WARNING: $error on pre-checked cust_pkg record!" if $error; - # $svc_acct->pkgnum( $cust_pkg->pkgnum ); - # $error ||= $svc_acct->insert; - # warn "WARNING: $error on pre-checked svc_acct record!" if $error; - #} + $error ||= $cust_main->insert( \%hash, \@invoicing_list ); warn "[fs_signup_server] Sending results...\n" if $Debug; print $writer $error, "\n"; - $cust_main->invoicing_list( \@invoicing_list ) unless $error; - } close $writer; close $reader; -- cgit v1.2.1 From 5e99168da38e7616fc726242ce7d85e140f22c6f Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 28 Aug 2001 16:58:08 +0000 Subject: customer-to-customer referrals in singup server --- fs_signup/FS-SignupClient/SignupClient.pm | 60 ++++++++++++++++--------------- fs_signup/FS-SignupClient/cgi/signup.cgi | 58 ++++++++++++++++-------------- fs_signup/FS-SignupClient/fs_signupd | 10 +++--- fs_signup/fs_signup_server | 49 ++++++++++++------------- 4 files changed, 92 insertions(+), 85 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/SignupClient.pm b/fs_signup/FS-SignupClient/SignupClient.pm index 5769c18fc..d656d7528 100644 --- a/fs_signup/FS-SignupClient/SignupClient.pm +++ b/fs_signup/FS-SignupClient/SignupClient.pm @@ -7,7 +7,7 @@ use Socket; use FileHandle; use IO::Handle; -$VERSION = '0.01'; +$VERSION = '0.02'; @ISA = qw( Exporter ); @EXPORT_OK = qw( signup_info new_customer ); @@ -35,29 +35,30 @@ FS::SignupClient - Freeside signup client API ( $locales, $packages, $pops ) = signup_info; $error = new_customer ( { - 'first' => $first, - 'last' => $last, - 'ss' => $ss, - 'comapny' => $company, - 'address1' => $address1, - 'address2' => $address2, - 'city' => $city, - 'county' => $county, - 'state' => $state, - 'zip' => $zip, - 'country' => $country, - 'daytime' => $daytime, - 'night' => $night, - 'fax' => $fax, - 'payby' => $payby, - 'payinfo' => $payinfo, - 'paydate' => $paydate, - 'payname' => $payname, - 'invoicing_list' => $invoicing_list, - 'pkgpart' => $pkgpart, - 'username' => $username, - '_password' => $password, - 'popnum' => $popnum, + 'first' => $first, + 'last' => $last, + 'ss' => $ss, + 'comapny' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'county' => $county, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + 'invoicing_list' => $invoicing_list, + 'referral_custnum' => $referral_custnum, + 'pkgpart' => $pkgpart, + 'username' => $username, + '_password' => $password, + 'popnum' => $popnum, } ); =head1 DESCRIPTION @@ -173,6 +174,7 @@ a paramater with the following keys: paydate payname invoicing_list + referral_custnum pkgpart username _password @@ -185,6 +187,10 @@ Returns a scalar error message, or the empty string for success. sub new_customer { my $hashref = shift; + #things that aren't necessary in base class, but are for signup server + return "Empty password" unless $hashref->{'_password'}; + return "No POP selected" unless $hashref->{'popnum'}; + socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!"; print SOCK "new_customer\n"; @@ -192,7 +198,7 @@ sub new_customer { print SOCK join("\n", map { $hashref->{$_} } qw( first last ss company address1 address2 city county state zip country daytime night fax payby payinfo paydate payname invoicing_list - pkgpart username _password popnum + referral_custnum pkgpart username _password popnum ) ), "\n"; SOCK->flush; @@ -202,10 +208,6 @@ sub new_customer { =back -=head1 VERSION - -$Id: SignupClient.pm,v 1.3 2000-02-02 07:44:00 ivan Exp $ - =head1 BUGS =head1 SEE ALSO diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index a3fa9e788..5d024a812 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,12 +1,13 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.9 2000-12-03 14:29:15 ivan Exp $ +# $Id: signup.cgi,v 1.10 2001-08-28 16:58:08 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 + $paydate $payname $referral_custnum + $pkgpart $username $password $popnum $ieak_file $ieak_template $cck_file $cck_template $ac $exch $loc ); @@ -15,7 +16,7 @@ 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 FS::SignupClient 0.02 qw( signup_info new_customer ); use Text::Template; #acceptable payment methods @@ -75,29 +76,30 @@ if ( defined $cgi->param('magic') ) { } ( $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'), + '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, + 'referral_custnum' => $referral_custnum = $cgi->param('ref'), + 'pkgpart' => $pkgpart = $cgi->param('pkgpart'), + 'username' => $username = $cgi->param('username'), + '_password' => $password = $cgi->param('_password'), + 'popnum' => $popnum = $cgi->param('popnum'), } ) ) ? print_form() : print_okay(); @@ -129,13 +131,14 @@ if ( defined $cgi->param('magic') ) { $username = ''; $password = ''; $popnum = ''; - + $referral_custnum = $cgi->param('ref') || ''; print_form; } sub print_form { my $r = qq!*!; + $cgi->delete('ref'); my $self_url = $cgi->self_url; print $cgi->header( '-expires' => 'now' ), < + Contact Information diff --git a/fs_signup/FS-SignupClient/fs_signupd b/fs_signup/FS-SignupClient/fs_signupd index f22ab15d4..8b3cdde53 100755 --- a/fs_signup/FS-SignupClient/fs_signupd +++ b/fs_signup/FS-SignupClient/fs_signupd @@ -116,16 +116,16 @@ for ( ; $paddr = accept(Client,Server); close Client) { my( $first, $last, $ss, $company, $address1, $address2, $city, $county, $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ) = map { scalar() } ( 1 .. 23 ); + $paydate, $payname, $invoicing_list, $referral_custnum, + $pkgpart, $username, $password, $popnum, + ) = map { scalar() } ( 1 .. 24 ); warn "[fs_signupd] sending customer data to remote server...\n" if $Debug; print $first, $last, $ss, $company, $address1, $address2, $city, $county, $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, + $paydate, $payname, $invoicing_list, $referral_custnum, + $pkgpart, $username, $password, $popnum, ; warn "[fs_signupd] reading error from remote server...\n" if $Debug; diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index c6ee665fa..43683b01d 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -88,9 +88,9 @@ while (1) { chop( my( $first, $last, $ss, $company, $address1, $address2, $city, $county, $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ) = map { scalar(<$reader>) } ( 1 .. 23 ) ); + $paydate, $payname, $invoicing_list, $referral_custnum, + $pkgpart, $username, $password, $popnum, + ) = map { scalar(<$reader>) } ( 1 .. 24 ) ); warn "[fs_signup_server] Processing signup...\n" if $Debug; @@ -99,27 +99,28 @@ while (1) { #shares some stuff with htdocs/edit/process/cust_main.cgi... take any # common that are still here and library them. my $cust_main = new FS::cust_main ( { - 'custnum' => '', - 'agentnum' => $agentnum, - 'refnum' => $refnum, - 'last' => $last, - 'first' => $first, - 'ss' => $ss, - 'company' => $company, - 'address1' => $address1, - 'address2' => $address2, - 'city' => $city, - 'county' => $county, - 'state' => $state, - 'zip' => $zip, - 'country' => $country, - 'daytime' => $daytime, - 'night' => $night, - 'fax' => $fax, - 'payby' => $payby, - 'payinfo' => $payinfo, - 'paydate' => $paydate, - 'payname' => $payname, + 'custnum' => '', + 'agentnum' => $agentnum, + 'refnum' => $refnum, + 'last' => $last, + 'first' => $first, + 'ss' => $ss, + 'company' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'county' => $county, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paydate' => $paydate, + 'payname' => $payname, + 'referral_custnum' => $referral_custnum, } ); $error = "Illegal payment type" unless grep { $_ eq $payby } @payby; -- cgit v1.2.1 From 294b8c0914f497b7714bad51dfb000d33e843995 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 30 Aug 2001 16:23:32 +0000 Subject: update signup server: template form and success html, document --- fs_signup/FS-SignupClient/cgi/signup.cgi | 382 ++++++++++++++++------------- fs_signup/FS-SignupClient/cgi/signup.html | 149 +++++++++++ fs_signup/FS-SignupClient/cgi/success.html | 4 + 3 files changed, 365 insertions(+), 170 deletions(-) create mode 100755 fs_signup/FS-SignupClient/cgi/signup.html create mode 100644 fs_signup/FS-SignupClient/cgi/success.html (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 5d024a812..0da960579 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,18 +1,19 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.10 2001-08-28 16:58:08 ivan Exp $ +# $Id: signup.cgi,v 1.11 2001-08-30 16:23:32 ivan Exp $ use strict; -use vars qw( @payby $cgi $locales $packages $pops $r $error +use vars qw( @payby $cgi $locales $packages $pops $error $last $first $ss $company $address1 $address2 $city $state $county $country $zip $daytime $night $fax $invoicing_list $payby $payinfo $paydate $payname $referral_custnum $pkgpart $username $password $popnum $ieak_file $ieak_template $cck_file $cck_template + $signup_html $signup_template $success_html $success_template $ac $exch $loc + $self_url ); -use subs qw( print_form print_okay expselect ); - +use subs qw( print_form print_okay expselect signup_default success_default ); use CGI; use CGI::Carp qw(fatalsToBrowser); use HTTP::Headers::UserAgent 2.00; @@ -28,6 +29,8 @@ use Text::Template; $ieak_file = '/usr/local/freeside/ieak.template'; $cck_file = '/usr/local/freeside/cck.template'; +$signup_html = '/usr/local/freeside/signup.html'; +$success_html = '/usr/local/freeside/success.html'; if ( -e $ieak_file ) { my $ieak_txt = Text::Template::_load_text($ieak_file) @@ -39,6 +42,7 @@ if ( -e $ieak_file ) { } else { $ieak_template = ''; } + if ( -e $cck_file ) { my $cck_txt = Text::Template::_load_text($cck_file) or die $Text::Template::ERROR; @@ -50,6 +54,42 @@ if ( -e $cck_file ) { $cck_template = ''; } +if ( -e $signup_html ) { + my $signup_txt = Text::Template::_load_text($signup_html) + or die $Text::Template::ERROR; + $signup_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $signup_txt = $1; + $signup_template = new Text::Template ( TYPE => 'STRING', + SOURCE => $signup_txt, + DELIMITERS => [ '<%=', '%>' ] + ) + or die $Text::Template::ERROR; +} else { + $signup_template = new Text::Template ( TYPE => 'STRING', + SOURCE => &signup_default, + DELIMITERS => [ '<%=', '%>' ] + ) + or die $Text::Template::ERROR; +} + +if ( -e $success_html ) { + my $success_txt = Text::Template::_load_text($signup_html) + or die $Text::Template::ERROR; + $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $success_txt = $1; + $success_template = new Text::Template ( TYPE => 'STRING', + SOURCE => $success_txt, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} else { + $success_template = new Text::Template ( TYPE => 'STRING', + SOURCE => &success_default, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} + ( $locales, $packages, $pops ) = signup_info(); $cgi = new CGI; @@ -137,168 +177,13 @@ if ( defined $cgi->param('magic') ) { sub print_form { - my $r = qq!*!; $cgi->delete('ref'); - 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{$_}!; - } - } + $self_url = $cgi->self_url; - print <
$paybychecked{$_}
$r required fields for each billing type -

First package - - - - - - - - - - - - - - - - -
Username
Password - (blank to generate)
POP
-

- -END + print $cgi->header( '-expires' => 'now' ), + $signup_template->fill_in(); } @@ -341,13 +226,8 @@ sub print_okay { } split(/\n/, $cck_data); } else { #send a simple confirmation - print $cgi->header( '-expires' => 'now' ), <Signup successful -Signup successful

-blah blah blah - - -END + print $cgi->header( '-expires' => 'now' ), + $success_template->fill_in(); } } @@ -386,3 +266,165 @@ sub expselect { $return; } +sub success_default { #html to use if you don't specify a success file + <<'END'; +Signup successful +Signup successful

+Thanks for signing up! + +END +} + +sub signup_default { #html to use if you don't specify a template file + <<'END'; +ISP Signup form +ISP Signup form

+<%= $error %> +
+ + + +Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country*Zip
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + my %payby = ( + 'CARD' => qq!Credit card
*
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", "12-2037"). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + my %paybychecked = ( + 'CARD' => qq!Credit card
*
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + for (@payby) { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + } + %> + +
$paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +
Username
Password + (blank to generate)
POP
+

+
+END +} diff --git a/fs_signup/FS-SignupClient/cgi/signup.html b/fs_signup/FS-SignupClient/cgi/signup.html new file mode 100755 index 000000000..bc02db230 --- /dev/null +++ b/fs_signup/FS-SignupClient/cgi/signup.html @@ -0,0 +1,149 @@ +ISP Signup form +ISP Signup form

+<%= $error %> +
+ + + +Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country*Zip
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + my %payby = ( + 'CARD' => qq!Credit card
*
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", "12-2037"). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + my %paybychecked = ( + 'CARD' => qq!Credit card
*
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + for (@payby) { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + } + %> + +
$paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +
Username
Password + (blank to generate)
POP
+

+
diff --git a/fs_signup/FS-SignupClient/cgi/success.html b/fs_signup/FS-SignupClient/cgi/success.html new file mode 100644 index 000000000..6bc2d1fd7 --- /dev/null +++ b/fs_signup/FS-SignupClient/cgi/success.html @@ -0,0 +1,4 @@ +Signup successful +Signup successful

+Thanks for signing up! + -- cgit v1.2.1 From fa0a72bfd08ec131523df6c40da96296ddadbb30 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Sep 2001 11:03:06 +0000 Subject: missing quote in new template --- fs_signup/FS-SignupClient/cgi/signup.cgi | 4 ++-- fs_signup/FS-SignupClient/cgi/signup.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'fs_signup') diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 0da960579..4ed5bf7d9 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.11 2001-08-30 16:23:32 ivan Exp $ +# $Id: signup.cgi,v 1.12 2001-09-11 11:03:06 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $error @@ -414,7 +414,7 @@ Contact Information <%= foreach my $pop ( @{$pops} ) { - $OUT .= '