From b4d172efa2225ef5070c1a6f168eb98fce8c5c62 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 29 May 2002 04:40:31 +0000 Subject: add fs_selfservice --- fs_selfservice/FS-SelfService/Changes | 6 + fs_selfservice/FS-SelfService/MANIFEST | 6 + fs_selfservice/FS-SelfService/Makefile.PL | 15 ++ fs_selfservice/FS-SelfService/SelfService.pm | 66 +++++++++ fs_selfservice/FS-SelfService/test.pl | 17 +++ fs_selfservice/freeside-selfservice-server | 198 +++++++++++++++++++++++++++ 6 files changed, 308 insertions(+) create mode 100644 fs_selfservice/FS-SelfService/Changes create mode 100644 fs_selfservice/FS-SelfService/MANIFEST create mode 100644 fs_selfservice/FS-SelfService/Makefile.PL create mode 100644 fs_selfservice/FS-SelfService/SelfService.pm create mode 100644 fs_selfservice/FS-SelfService/test.pl create mode 100644 fs_selfservice/freeside-selfservice-server (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/Changes b/fs_selfservice/FS-SelfService/Changes new file mode 100644 index 000000000..b9e26b7dc --- /dev/null +++ b/fs_selfservice/FS-SelfService/Changes @@ -0,0 +1,6 @@ +Revision history for Perl extension FS::SelfService. + +0.01 Tue May 28 16:49:41 2002 + - original version; created by h2xs 1.21 with options + -A -X -n FS::SelfService + diff --git a/fs_selfservice/FS-SelfService/MANIFEST b/fs_selfservice/FS-SelfService/MANIFEST new file mode 100644 index 000000000..3c490e7dd --- /dev/null +++ b/fs_selfservice/FS-SelfService/MANIFEST @@ -0,0 +1,6 @@ +Changes +Makefile.PL +MANIFEST +README +SelfService.pm +test.pl diff --git a/fs_selfservice/FS-SelfService/Makefile.PL b/fs_selfservice/FS-SelfService/Makefile.PL new file mode 100644 index 000000000..da0a0aa24 --- /dev/null +++ b/fs_selfservice/FS-SelfService/Makefile.PL @@ -0,0 +1,15 @@ +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::SelfService', + 'VERSION_FROM' => 'SelfService.pm', # finds $VERSION + 'EXE_FILES' => [ 'freeside-selfservice-clientd' ], + 'INSTALLSCRIPT' => '/usr/local/sbin', + 'INSTALLSITEBIN' => '/usr/local/sbin', + 'PERM_RWX' => '750', + 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 + ($] >= 5.005 ? ## Add these new keywords supported since 5.005 + (ABSTRACT_FROM => 'SelfService.pm', # retrieve abstract from module + AUTHOR => 'Ivan Kohler ') : ()), +); diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm new file mode 100644 index 000000000..75e550a2d --- /dev/null +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -0,0 +1,66 @@ +package FS::SelfService; + +use 5.006; +use strict; +use warnings; + +require Exporter; + +our @ISA = qw(Exporter); + +# Items to export into callers namespace by default. Note: do not export +# names by default without a very good reason. Use EXPORT_OK instead. +# Do not simply export all your public functions/methods/constants. + +# This allows declaration use FS::SelfService ':all'; +# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK +# will save memory. +our %EXPORT_TAGS = ( 'all' => [ qw( + +) ] ); + +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); + +our @EXPORT = qw( + +); +our $VERSION = '0.01'; + + +# Preloaded methods go here. + +1; +__END__ +# Below is stub documentation for your module. You better edit it! + +=head1 NAME + +FS::SelfService - Perl extension for blah blah blah + +=head1 SYNOPSIS + + use FS::SelfService; + blah blah blah + +=head1 DESCRIPTION + +Stub documentation for FS::SelfService, created by h2xs. It looks like the +author of the extension was negligent enough to leave the stub +unedited. + +Blah blah blah. + +=head2 EXPORT + +None by default. + + +=head1 AUTHOR + +A. U. Thor, Ea.u.thor@a.galaxy.far.far.awayE + +=head1 SEE ALSO + +L. + +=cut diff --git a/fs_selfservice/FS-SelfService/test.pl b/fs_selfservice/FS-SelfService/test.pl new file mode 100644 index 000000000..7468ea471 --- /dev/null +++ b/fs_selfservice/FS-SelfService/test.pl @@ -0,0 +1,17 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### + +# change 'tests => 1' to 'tests => last_test_to_print'; + +use Test; +BEGIN { plan tests => 1 }; +use FS::SelfService; +ok(1); # If we made it this far, we're ok. + +######################### + +# Insert your test code below, the Test module is use()ed here so read +# its man page ( perldoc Test ) for help writing this test script. + diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server new file mode 100644 index 000000000..6146d3752 --- /dev/null +++ b/fs_selfservice/freeside-selfservice-server @@ -0,0 +1,198 @@ +#!/usr/bin/perl -w +# +# freeside-selfservice-server + +# alas, much false laziness with freeside-queued and fs_signup_server. at +# least it is slated to replace fs_{signup,passwd,mailadmin}_server +# should probably generalize the version in here, or better yet use +# Proc::Daemon or somesuch + +use strict; +use vars qw( $kids $max_kids $shutdown $log_file ); +use vars qw($ssh_pid); +use Fcntl qw(:flock); +use POSIX qw(setsid); +use IO::Handle; +use Storable qw(nstore_fd fd_retrieve); +use Net::SSH qw(sshopen2); +use FS::UID qw(adminsuidsetup); + +#use Tie::RefHash; +#use FS::Conf; +#use FS::Record qw( qsearch qsearchs ); +#use FS::cust_main_county; +#use FS::cust_main; +#use FS::Msgcat qw(gettext); + +$shutdown = 0; +$max_kids = '10'; #? +$kids = 0; + +my $user = shift or die &usage; +my $machine = shift or die &usage; +my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; +#my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; $FS::UID::datasrc not posible, but should include machine name at least, hmm + +&init($user); + +my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name? + +my %dispatch = ( + 'signup' => \&signup, + #'signup_init' => 'signup_init', + 'passwd' => \&passwd, + +); + +my $warnkids=0; +while (1) { + my($reader, $writer) = (new IO::Handle, new IO::Handle); + warn "connecting to $machine"; + $ssh_pid = sshopen2($machine,$reader,$writer,$clientd); + + warn "entering main loop"; + while (1) { + + warn "waiting for packet from client"; + my $packet = eval { + local $SIG{__DIE__}; + local $SIG{ALRM} = sub { die "alarm\n" }; #NB: \n required + alarm 5; + my $p = fd_retrieve($reader); + alarm 0; + $p; + }; + if ($@) { + die $@ unless $@ eq "alarm\n"; + #timeout + next unless $shutdown; + &shutdown; + } + warn "packet received"; + + #prevent runaway forking + my $warnkids = 0; + while ( $kids >= $max_kids ) { + warn "WARNING: maximum $kids children reached" unless $warnkids++; + sleep 1; + } + + warn "forking child"; + defined( my $pid = fork ) or die "can't fork: $!"; + if ( $pid ) { + warn "child $pid spawned"; + $kids++; + } else { #kid time + + #get new db handle + $FS::UID::dbh->{InactiveDestroy} = 1; + forksuidsetup($user); + + my $sub = $dispatch{$packet->{_packet}}; + my $rv; + if ( $sub ) { + warn "calling $sub handler"; + $rv = &{$sub}($packet); + } else { + warn my $error = "WARNING: unknown packet type ". $packet->{_packet}; + $rv = { _error => $error }; + } + $rv->{_token} = $packet->{_token}; #identifier + + warn "sending response"; + flock($writer, LOCK_EX); #acquire write lock + nstore_fd($rv, $writer) or die "can't send response: $!"; + $writer->flush; + flock($writer, LOCK_UN); #release write lock + + warn "child exiting"; + exit; #end-of-kid + } + + } + +} + +### +# utility subroutines +### + +sub init { + my $user = shift; + + chdir "/" or die "Can't chdir to /: $!"; + open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + defined(my $pid = fork) or die "Can't fork: $!"; + if ( $pid ) { + print "freeside-selfservice-server to $machine started with pid $pid\n"; #logging to $log_file + exit unless $pid_file; + my $pidfh = new IO::File ">$pid_file" or exit; + print $pidfh "$pid\n"; + exit; + } + + sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; } + $SIG{CHLD} = \&REAPER; + + $shutdown = 0; + $SIG{HUP} = sub { warn "SIGHUP received; shutting down\n"; $shutdown++; }; + $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $shutdown++; }; + $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $shutdown++; }; + $SIG{QUIT} = sub { warn "SIGQUIT received; shutting down\n"; $shutdown++; }; + $SIG{PIPE} = sub { warn "SIGPIPE received; shutting down\n"; $shutdown++; }; + + $> = $FS::UID::freeside_uid unless $>; + $< = $>; + $ENV{HOME} = (getpwuid($>))[7]; #for ssh + adminsuidsetup $user; + + #$log_file = "/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc; #MACHINE NAME + $log_file = "/usr/local/etc/freeside/selfservice.$machine.log"; + + open STDOUT, '>/dev/null' + or die "Can't write to /dev/null: $!"; + setsid or die "Can't start a new session: $!"; + open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; + + $SIG{__DIE__} = \&_die; + $SIG{__WARN__} = \&_logmsg; + + warn "freeside-selfservice-server starting\n"; + +} + +sub shutdown { + my $wait = 12; #wait up to 1 minute + while ( $kids && $wait-- ) { + warn "waiting for $kids children to terminate"; + sleep 5; + } + warn "abandoning $kids children" if $kids; + kill 'TERM', $ssh_pid if $ssh_pid; + die "exiting"; +} + +sub _die { + my $msg = shift; + unlink $pid_file if -e $pid_file; + _logmsg($msg); +} + +sub _logmsg { + chomp( my $msg = shift ); + my $log = new IO::File ">>$log_file"; + flock($log, LOCK_EX); + seek($log, 0, 2); + print $log "[server] [". time2str("%a %b %e %T %Y",time). "] [$$] $msg\n"; + flock($log, LOCK_UN); + close $log; +} + +sub usage { + die "Usage:\n\n fs_signup_server user machine\n"; +} + +### +# handlers... should go in their own files eventually... +### + -- cgit v1.2.1 From b58821fcd50e52ae726834ef3863b85ed293379f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Jul 2002 13:52:39 +0000 Subject: finally working async framework --- fs_selfservice/DEPLOY | 8 + fs_selfservice/FS-SelfService/MANIFEST | 2 +- fs_selfservice/FS-SelfService/SelfService.pm | 103 ++++++---- .../FS-SelfService/freeside-selfservice-clientd | 222 +++++++++++++++++++++ fs_selfservice/freeside-selfservice-server | 115 +++++++++-- fs_selfservice/fs_passwd_test | 14 ++ 6 files changed, 409 insertions(+), 55 deletions(-) create mode 100755 fs_selfservice/DEPLOY create mode 100644 fs_selfservice/FS-SelfService/freeside-selfservice-clientd create mode 100755 fs_selfservice/fs_passwd_test (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY new file mode 100755 index 000000000..9b03bf259 --- /dev/null +++ b/fs_selfservice/DEPLOY @@ -0,0 +1,8 @@ +#!/bin/sh + +cd FS-SelfService +perl Makefile.PL && make && make install + +cd .. +kill `cat /var/run/freeside-selfservice-server.ivan.pid`; sleep 3 +./freeside-selfservice-server ivan localhost diff --git a/fs_selfservice/FS-SelfService/MANIFEST b/fs_selfservice/FS-SelfService/MANIFEST index 3c490e7dd..ebd0d3b1a 100644 --- a/fs_selfservice/FS-SelfService/MANIFEST +++ b/fs_selfservice/FS-SelfService/MANIFEST @@ -1,6 +1,6 @@ Changes Makefile.PL MANIFEST -README SelfService.pm test.pl +freeside-selfservice-clientd diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 75e550a2d..3cd4fd94e 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1,66 +1,95 @@ package FS::SelfService; -use 5.006; use strict; -use warnings; +use vars qw($VERSION @ISA @EXPORT_OK $socket); +use Exporter; +use Socket; +use FileHandle; +#use IO::Handle; +use IO::Select; +use Storable qw(nstore_fd fd_retrieve); -require Exporter; +$VERSION = '0.03'; -our @ISA = qw(Exporter); +@ISA = qw( Exporter ); +@EXPORT_OK = qw( passwd ); -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. +$socket = "/usr/local/freeside/selfservice_socket"; -# This allows declaration use FS::SelfService ':all'; -# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK -# will save memory. -our %EXPORT_TAGS = ( 'all' => [ qw( - -) ] ); +$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'SHELL'} = '/bin/sh'; +$ENV{'IFS'} = " \t\n"; +$ENV{'CDPATH'} = ''; +$ENV{'ENV'} = ''; +$ENV{'BASH_ENV'} = ''; -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +my $freeside_uid = scalar(getpwnam('freeside')); +die "not running as the freeside user\n" if $> != $freeside_uid; -our @EXPORT = qw( - -); -our $VERSION = '0.01'; +=head1 NAME +FS::SelfService - Freeside self-service API -# Preloaded methods go here. +=head1 SYNOPSIS -1; -__END__ -# Below is stub documentation for your module. You better edit it! +=head1 DESCRIPTION -=head1 NAME +Use this API to implement your own client "self-service" module. -FS::SelfService - Perl extension for blah blah blah +If you just want to customize the look of the existing "self-service" module, +see XXXX instead. -=head1 SYNOPSIS +=head1 FUNCTIONS - use FS::SelfService; - blah blah blah +=over 4 -=head1 DESCRIPTION +=item passwd -Stub documentation for FS::SelfService, created by h2xs. It looks like the -author of the extension was negligent enough to leave the stub -unedited. +Returns the empty value on success, or an error message on errors. -Blah blah blah. +=cut -=head2 EXPORT +sub passwd { + my $param; + if ( ref($_[0]) ) { + $param = shift; + } else { + $param = { @_ }; + } -None by default. + $param->{_packet} = 'passwd'; + simple_packet($param); +} -=head1 AUTHOR +sub simple_packet { + my $packet = shift; + socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; + connect(SOCK, sockaddr_un($socket)) or die "connect: $!"; + nstore_fd($packet, \*SOCK) or die "can't send packet: $!"; + SOCK->flush; -A. U. Thor, Ea.u.thor@a.galaxy.far.far.awayE + #shoudl trap: Magic number checking on storable file failed at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/fd_retrieve.al) line 337, at /usr/local/share/perl/5.6.1/FS/SelfService.pm line 71 + + #block until there is a message on socket +# my $w = new IO::Select; +# $w->add(\*SOCK); +# my @wait = $w->can_read; + my $return = fd_retrieve(\*SOCK) or die "error reading result: $!"; + die $return->{'_error'} if defined $return->{_error} && $return->{_error}; + + $return->{'error'}; +} + +=back + +=head1 BUGS =head1 SEE ALSO -L. +L, L =cut + +1; + diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd new file mode 100644 index 000000000..149f894e0 --- /dev/null +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -0,0 +1,222 @@ +#!/usr/bin/perl -w +# +# freeside-selfservice-clientd +# +# This is run REMOTELY over ssh by freeside-selfservice-server + +use strict; +use subs qw(spawn logmsg); +use Fcntl qw(:flock); +use Socket; +use Storable qw(nstore_fd fd_retrieve); +use IO::Handle; +use IO::Select; +use IPC::Open2; + +use LockFile::Simple qw(lock unlock); + +use vars qw( $Debug ); +$Debug = 2; + +my $socket = "/usr/local/freeside/selfservice_socket"; +my $pid_file = "$socket.pid"; +my $lock_file = "$socket.lock"; +unlink $lock_file; + +my $me = '[client]'; + +$|=1; + +#read data to be cached or something +#warn "$me Reading init data\n" if $Debug; +#my $signup_init = + +warn "[client] Creating $socket\n" if $Debug; +my $uaddr = sockaddr_un($socket); +my $proto = getprotobyname('tcp'); +socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; +unlink($socket); +bind(Server, $uaddr) or die "bind: $!"; +listen(Server,SOMAXCONN) or die "listen: $!"; + +if ( -e $pid_file ) { + open(PIDFILE,"<$pid_file"); + #chomp( my $old_pid = ); + my $old_pid = ; + close PIDFILE; + $old_pid =~ /^(\d+)$/; + kill 'TERM', $1; +} +open(PIDFILE,">$pid_file"); +print PIDFILE "$$\n"; +close PIDFILE; + +#my $waitedpid; +#sub REAPER { $waitedpid = wait; $SIG{CHLD} = \&REAPER; } +#$SIG{CHLD} = \&REAPER; + +warn "[client] entering main loop\n" if $Debug; + +#sub spawn; +#sub logmsg; + +my %kids; + + # my $gar = ; + +#my $s = new IO::Select; +#$s->add(\*STDIN); +#$s->add(\*Server); + +#for ( $waitedpid = 0; +# accept(Client,Server) || $waitedpid; +# $waitedpid = 0, close Client) +#{ +# next if $waitedpid; + +#$SIG{PIPE} = sub { warn "SIGPIPE received" }; +#$SIG{CHLD} = sub { warn "SIGCHLD received" }; + +sub REAPER { warn "SIGCHLD received"; my $pid = wait; $SIG{CHLD} = \&REAPER; } +#sub REAPER { my $pid = wait; delete $kids{$pid}; $SIG{CHLD} = \&REAPER; } +$SIG{CHLD} = \&REAPER; + +warn "[client] creating IO::Select\n" if $Debug; +my $s = new IO::Select; +$s->add(\*STDIN); +$s->add(\*Server); + +while (1) { + +warn "[client] waiting for connection or token\n" if $Debug; +while ( my @handles = $s->can_read ) { + + foreach my $handle ( @handles ) { + + if ( $handle == \*STDIN ) { + +# my $gar = ; +# die $gar; + + my $packet = fd_retrieve(\*STDIN); + my $token = $packet->{'_token'}; + warn "[client] received packet with token $token\n". + join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) + if $Debug; + if ( exists($kids{$token}) ) { + warn "[client] sending return packet to $token via $kids{$token}\n" + if $Debug; + nstore_fd($packet, $kids{$token}); + warn "[client] flushing $kids{$token}\n" if $Debug; + $kids{$token}->flush; + #eval { $kids{$token}->flush; }; + #die "error flushing?!?!? $@\n" if $@ ne ''; + #warn "[client] closing $kids{$token}\n"; + #close $kids{$token}; + #warn "[client] deleting $kids{$token}\n"; + #delete $kids{$token}; + warn "[client] done with $token\n" if $Debug; + } else { + warn "[client] WARNING: unknown token $token, discarding message"; + #die "[client] FATAL: unknown token $token, discarding message"; + } + + } elsif ( $handle == \*Server ) { + + warn "[client] received local connection; forking\n" if $Debug; + + accept(Client, Server); + + spawn sub { #child + warn "[client-$$] reading packet from local client" if $Debug > 1; + my $packet = fd_retrieve(\*Client); + warn "[client-$$] packet received:\n". + join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) + if $Debug > 1; + my $command = $packet->{'command'}; + #handle some commands weirdly? + $packet->{_token}=$$; #?? + + warn "[client-$$] sending packet to remote server" if $Debug > 1; + flock(STDOUT, LOCK_EX); #acquire write lock + #lock($lock_file); + nstore_fd($packet, \*STDOUT); + STDOUT->flush; + #unlock($lock_file); + flock(STDOUT, LOCK_UN); #release write lock + + warn "[client-$$] waiting for response from parent" if $Debug > 1; + + #block until parent has a message + my $w = new IO::Select; + $w->add(\*STDIN); + my @wait = $w->can_read; + my $rv = fd_retrieve(\*STDIN); + + #close STDIN; + + warn "[client-$$] sending response to local client" if $Debug > 1; + + #send message to local client + nstore_fd($rv, \*Client); + Client->flush; + + close Client; + + warn "[client-$$] child exiting" if $Debug > 1; + + #while (1) { sleep 5 }; + #sleep 5; + exit; + + }; #eo child + + #close Client; #in parent, right? + + } else { + die "wtf? $handle"; + } + + } + + warn "[client] done handling messages; returning to wait-state" if $Debug;; + +} + +#die "[client] died unexpectedly: $!\n"; +warn "[client] fell-through unexpectedly: $!\n" if $Debug; + +} #WTF? + +sub spawn { + my $coderef = shift; + + unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') { + use Carp; + confess "usage: spawn CODEREF"; + } + + my $pid; + #if (!defined($pid = fork)) { + my $kid = new IO::Handle; + if (!defined($pid = open($kid, '|-'))) { + logmsg "WARNING: cannot fork: $!"; + return; + } elsif ($pid) { + logmsg "begat $pid" if $Debug; + $kids{$pid} = $kid; + #$kids{$pid}->autoflush; + return; # I'm the parent + } + # else I'm the child -- go spawn + +# open(STDIN, "<&Client") || die "can't dup client to stdin"; +# open(STDOUT, ">&Client") || die "can't dup client to stdout"; + ## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr"; + exit &$coderef(); +} + +#sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" } +#DON'T PRINT!!!!! +sub logmsg { warn "[client] $0 $$: @_ at ", scalar localtime, "\n" } + diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server index 6146d3752..7b4a88166 100644 --- a/fs_selfservice/freeside-selfservice-server +++ b/fs_selfservice/freeside-selfservice-server @@ -12,10 +12,13 @@ use vars qw( $kids $max_kids $shutdown $log_file ); use vars qw($ssh_pid); use Fcntl qw(:flock); use POSIX qw(setsid); +use Date::Format; use IO::Handle; use Storable qw(nstore_fd fd_retrieve); use Net::SSH qw(sshopen2); -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup forksuidsetup); + +use LockFile::Simple qw(lock unlock); #use Tie::RefHash; #use FS::Conf; @@ -32,6 +35,8 @@ my $user = shift or die &usage; my $machine = shift or die &usage; my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; #my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; $FS::UID::datasrc not posible, but should include machine name at least, hmm +my $lock_file = "/usr/local/etc/freeside/freeside-selfservice-server.$user.lock"; +unlink $lock_file; &init($user); @@ -47,51 +52,64 @@ my %dispatch = ( my $warnkids=0; while (1) { my($reader, $writer) = (new IO::Handle, new IO::Handle); - warn "connecting to $machine"; + warn "connecting to $machine\n"; $ssh_pid = sshopen2($machine,$reader,$writer,$clientd); - warn "entering main loop"; +# nstore_fd(\*writer, {'hi'=>'there'}); + + warn "entering main loop\n"; + my $undisp = 0; while (1) { - warn "waiting for packet from client"; + warn "waiting for packet from client\n" unless $undisp; + $undisp = 1; my $packet = eval { local $SIG{__DIE__}; - local $SIG{ALRM} = sub { die "alarm\n" }; #NB: \n required + local $SIG{ALRM} = sub { local $SIG{__DIE__};die "MyAlarm\n" }; #NB: \n required alarm 5; + #my $string = <$reader>; + #die $string; my $p = fd_retrieve($reader); alarm 0; $p; }; if ($@) { - die $@ unless $@ eq "alarm\n"; + &shutdown if $shutdown && $@; + die "Fatal error receiving packet from client: $@" if $@ !~ /^MyAlarm/; + #die $@ unless $@ eq "alarm\n" || $@ eq 'Alarm'; #????? #timeout next unless $shutdown; &shutdown; } - warn "packet received"; + warn "packet received\n". + join('', map { " $_=>$packet->{$_}\n" } keys %$packet ); + + $undisp = 0; #prevent runaway forking my $warnkids = 0; while ( $kids >= $max_kids ) { - warn "WARNING: maximum $kids children reached" unless $warnkids++; + warn "WARNING: maximum $kids children reached\n" unless $warnkids++; sleep 1; } - warn "forking child"; + warn "forking child\n"; defined( my $pid = fork ) or die "can't fork: $!"; if ( $pid ) { - warn "child $pid spawned"; + warn "child $pid spawned\n"; $kids++; } else { #kid time + #local($SIG{PIPE}); + #get new db handle - $FS::UID::dbh->{InactiveDestroy} = 1; + #$FS::UID::dbh->{InactiveDestroy} = 1; forksuidsetup($user); my $sub = $dispatch{$packet->{_packet}}; my $rv; if ( $sub ) { - warn "calling $sub handler"; + warn "calling $sub handler\n"; $rv = &{$sub}($packet); } else { warn my $error = "WARNING: unknown packet type ". $packet->{_packet}; @@ -99,13 +117,15 @@ while (1) { } $rv->{_token} = $packet->{_token}; #identifier - warn "sending response"; + warn "sending response\n"; flock($writer, LOCK_EX); #acquire write lock + #lock($lock_file); nstore_fd($rv, $writer) or die "can't send response: $!"; $writer->flush; + #unlock($lock_file); flock($writer, LOCK_UN); #release write lock - - warn "child exiting"; +# + warn "child exiting\n"; exit; #end-of-kid } @@ -113,6 +133,50 @@ while (1) { } +### +# dispatch subroutines (should live elsewhere eventually) +### + +sub passwd { + #sleep 3; + use FS::Record qw(qsearchs); + use FS::svc_acct; + #use FS::svc_domain; + + my $packet = shift; + + #my $domain = qsearchs('svc_domain', { 'domain' => $packet->{'domain'} } ) + # or return { error => "Domain $domain not found" }; + + my $old_password = $packet->{'old_password'}; + my $new_password = $packet->{'new_password'}; + my $new_gecos = $packet->{'new_gecos'}; + my $new_shell = $packet->{'new_shell'}; + + my $svc_acct = + ( length($old_password) < 13 + && qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, + #'domsvc' => $svc_domain->domsvc, + '_password' => $old_password } ) + ) + || qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, + #'domsvc' => $svc_domain->domsvc, + '_password' => $old_password } ); + + unless ( $svc_acct ) { return { error => 'Incorrect password.' } } + + 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); + + return { error => $error }; + +} + ### # utility subroutines ### @@ -143,6 +207,23 @@ sub init { $> = $FS::UID::freeside_uid unless $>; $< = $>; + + #false laziness w/freeside-queued + my $freeside_gid = scalar(getgrnam('freeside')) + or die "can't setgid to freeside group\n"; + $) = $freeside_gid; + $( = $freeside_gid; + #if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd + ($(,$)) = ($),$(); + $) = $freeside_gid; + + $> = $FS::UID::freeside_uid; + $< = $FS::UID::freeside_uid; + #freebsd is sofa king broken, won't setuid() + ($<,$>) = ($>,$<); + $> = $FS::UID::freeside_uid; + #eslaf + $ENV{HOME} = (getpwuid($>))[7]; #for ssh adminsuidsetup $user; @@ -152,7 +233,7 @@ sub init { open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; setsid or die "Can't start a new session: $!"; - open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; +# open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; $SIG{__DIE__} = \&_die; $SIG{__WARN__} = \&_logmsg; @@ -163,7 +244,7 @@ sub init { sub shutdown { my $wait = 12; #wait up to 1 minute - while ( $kids && $wait-- ) { + while ( $kids > 0 && $wait-- ) { warn "waiting for $kids children to terminate"; sleep 5; } diff --git a/fs_selfservice/fs_passwd_test b/fs_selfservice/fs_passwd_test new file mode 100755 index 000000000..77782e651 --- /dev/null +++ b/fs_selfservice/fs_passwd_test @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use strict; +use FS::SelfService qw(passwd); + +my $error = passwd( + 'username' => 'ivan', + 'old_password' => 'heyhoo', + 'new_password' => 'haloo', +); + +die $error if $error; + +print "password changed sucessfully\n"; -- cgit v1.2.1 From 0393935877eebdd5bc0932d5ba0ef030bc46d167 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Jul 2002 08:28:18 +0000 Subject: working framework, no hung clients, whew --- .../FS-SelfService/freeside-selfservice-clientd | 174 +++++++++++---------- fs_selfservice/freeside-selfservice-server | 121 +++++++------- fs_selfservice/fs_passwd_test | 8 +- 3 files changed, 158 insertions(+), 145 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 149f894e0..319d4254f 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -7,31 +7,35 @@ use strict; use subs qw(spawn logmsg); use Fcntl qw(:flock); +use POSIX qw(:sys_wait_h); use Socket; use Storable qw(nstore_fd fd_retrieve); -use IO::Handle; +use IO::Handle qw(_IONBF); use IO::Select; -use IPC::Open2; +use IO::File; -use LockFile::Simple qw(lock unlock); +STDOUT->setbuf(''); use vars qw( $Debug ); -$Debug = 2; +$Debug = 2; #2 will turn on child logging, 3 will log packet contents, + #including potentially compromising information my $socket = "/usr/local/freeside/selfservice_socket"; my $pid_file = "$socket.pid"; -my $lock_file = "$socket.lock"; -unlink $lock_file; -my $me = '[client]'; +my $log_file = "/usr/local/freeside/selfservice.log"; + +#my $me = '[client]'; $|=1; +$SIG{__WARN__} = \&_logmsg; + #read data to be cached or something #warn "$me Reading init data\n" if $Debug; #my $signup_init = -warn "[client] Creating $socket\n" if $Debug; +warn "Creating $socket\n" if $Debug; my $uaddr = sockaddr_un($socket); my $proto = getprotobyname('tcp'); socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; @@ -41,7 +45,6 @@ listen(Server,SOMAXCONN) or die "listen: $!"; if ( -e $pid_file ) { open(PIDFILE,"<$pid_file"); - #chomp( my $old_pid = ); my $old_pid = ; close PIDFILE; $old_pid =~ /^(\d+)$/; @@ -55,18 +58,13 @@ close PIDFILE; #sub REAPER { $waitedpid = wait; $SIG{CHLD} = \&REAPER; } #$SIG{CHLD} = \&REAPER; -warn "[client] entering main loop\n" if $Debug; - -#sub spawn; -#sub logmsg; +warn "entering main loop\n" if $Debug; my %kids; - # my $gar = ; - -#my $s = new IO::Select; -#$s->add(\*STDIN); -#$s->add(\*Server); +my $s = new IO::Select; +$s->add(\*STDIN); +$s->add(\*Server); #for ( $waitedpid = 0; # accept(Client,Server) || $waitedpid; @@ -77,116 +75,117 @@ my %kids; #$SIG{PIPE} = sub { warn "SIGPIPE received" }; #$SIG{CHLD} = sub { warn "SIGCHLD received" }; -sub REAPER { warn "SIGCHLD received"; my $pid = wait; $SIG{CHLD} = \&REAPER; } +#sub REAPER { warn "SIGCHLD received"; my $pid = wait; $SIG{CHLD} = \&REAPER; } +#sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; } #sub REAPER { my $pid = wait; delete $kids{$pid}; $SIG{CHLD} = \&REAPER; } -$SIG{CHLD} = \&REAPER; - -warn "[client] creating IO::Select\n" if $Debug; -my $s = new IO::Select; -$s->add(\*STDIN); -$s->add(\*Server); +#$SIG{CHLD} = \&REAPER; +my $undisp = 0; while (1) { -warn "[client] waiting for connection or token\n" if $Debug; -while ( my @handles = $s->can_read ) { + &reap_kids; + + warn "waiting for connection\n" if $Debug && !$undisp; + #my @handles = $s->can_read(); + my @handles = $s->can_read(5); + $undisp = !scalar(@handles); foreach my $handle ( @handles ) { if ( $handle == \*STDIN ) { -# my $gar = ; -# die $gar; + warn "receiving packet from server\n" if $Debug; my $packet = fd_retrieve(\*STDIN); my $token = $packet->{'_token'}; - warn "[client] received packet with token $token\n". - join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) + warn "received packet from server with token $token\n". + ( $Debug > 2 + ? join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) + : '' ) if $Debug; + if ( exists($kids{$token}) ) { - warn "[client] sending return packet to $token via $kids{$token}\n" + warn "sending return packet to $token via $kids{$token}\n" if $Debug; nstore_fd($packet, $kids{$token}); - warn "[client] flushing $kids{$token}\n" if $Debug; - $kids{$token}->flush; - #eval { $kids{$token}->flush; }; - #die "error flushing?!?!? $@\n" if $@ ne ''; - #warn "[client] closing $kids{$token}\n"; - #close $kids{$token}; - #warn "[client] deleting $kids{$token}\n"; - #delete $kids{$token}; - warn "[client] done with $token\n" if $Debug; + warn "flushing to $token\n" if $Debug; + until ( $kids{$token}->flush ) { + warn "WARNING: error flushing: $!"; + sleep 1; + } + #no close or delete here - will block waiting for child + warn "done with $token\n" if $Debug; } else { - warn "[client] WARNING: unknown token $token, discarding message"; - #die "[client] FATAL: unknown token $token, discarding message"; + warn "WARNING: unknown token $token, discarding message"; } } elsif ( $handle == \*Server ) { - warn "[client] received local connection; forking\n" if $Debug; + until ( accept(Client, Server) ) { + warn "WARNING: accept failed: $!"; + next; + } - accept(Client, Server); + warn "received local connection; forking\n" if $Debug; spawn sub { #child - warn "[client-$$] reading packet from local client" if $Debug > 1; + warn "[child-$$] reading packet from local client" if $Debug > 1; my $packet = fd_retrieve(\*Client); - warn "[client-$$] packet received:\n". + warn "[child-$$] packet received:\n". join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) - if $Debug > 1; + if $Debug > 2; my $command = $packet->{'command'}; #handle some commands weirdly? - $packet->{_token}=$$; #?? - - warn "[client-$$] sending packet to remote server" if $Debug > 1; - flock(STDOUT, LOCK_EX); #acquire write lock - #lock($lock_file); - nstore_fd($packet, \*STDOUT); - STDOUT->flush; - #unlock($lock_file); - flock(STDOUT, LOCK_UN); #release write lock + $packet->{_token}=$$; - warn "[client-$$] waiting for response from parent" if $Debug > 1; + warn "[child-$$] sending packet to remote server" if $Debug > 1; + flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!"; + nstore_fd($packet, \*STDOUT) or die "FATAL: can't send response: $!"; + STDOUT->flush or die "FATAL: can't flush: $!"; + flock(STDOUT, LOCK_UN) or die "FATAL: can't release write lock: $!"; + close STDOUT or die "FATAL: can't close write stream: $!"; #??! - #block until parent has a message + warn "[child-$$] waiting for response from parent" if $Debug > 1; my $w = new IO::Select; $w->add(\*STDIN); - my @wait = $w->can_read; + until ( $w->can_read ) { + warn "[child-$$] WARNING: interrupted select: $!\n"; + } my $rv = fd_retrieve(\*STDIN); #close STDIN; - warn "[client-$$] sending response to local client" if $Debug > 1; - - #send message to local client + warn "[child-$$] sending response to local client" if $Debug > 1; nstore_fd($rv, \*Client); - Client->flush; - - close Client; + Client->flush or die "FATAL: can't flush to local client: $!"; + close Client or die "FATAL: can't close connection to local client: $!"; - warn "[client-$$] child exiting" if $Debug > 1; - - #while (1) { sleep 5 }; - #sleep 5; + warn "[child-$$] child exiting" if $Debug > 1; exit; }; #eo child - #close Client; #in parent, right? + #close Client; } else { die "wtf? $handle"; } } - - warn "[client] done handling messages; returning to wait-state" if $Debug;; - + } -#die "[client] died unexpectedly: $!\n"; -warn "[client] fell-through unexpectedly: $!\n" if $Debug; - -} #WTF? +sub reap_kids { + #warn "reaping kids\n"; + foreach my $pid ( keys %kids ) { + my $kid = waitpid($pid, WNOHANG); + if ( $kid > 0 ) { + close $kids{$kid}; + delete $kids{$kid}; + } + } + #warn "done reaping\n"; +} sub spawn { my $coderef = shift; @@ -200,10 +199,10 @@ sub spawn { #if (!defined($pid = fork)) { my $kid = new IO::Handle; if (!defined($pid = open($kid, '|-'))) { - logmsg "WARNING: cannot fork: $!"; + warn "WARNING: cannot fork: $!"; return; } elsif ($pid) { - logmsg "begat $pid" if $Debug; + warn "begat $pid" if $Debug; $kids{$pid} = $kid; #$kids{$pid}->autoflush; return; # I'm the parent @@ -212,11 +211,16 @@ sub spawn { # open(STDIN, "<&Client") || die "can't dup client to stdin"; # open(STDOUT, ">&Client") || die "can't dup client to stdout"; - ## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr"; +# open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr"; exit &$coderef(); } -#sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" } -#DON'T PRINT!!!!! -sub logmsg { warn "[client] $0 $$: @_ at ", scalar localtime, "\n" } - +sub _logmsg { + chomp( my $msg = shift ); + my $log = new IO::File ">>$log_file"; + flock($log, LOCK_EX); + seek($log, 0, 2); + print $log "[client] [". scalar(localtime). "] [$$] $msg\n"; + flock($log, LOCK_UN); + close $log; +} diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server index 7b4a88166..0e1c75e43 100644 --- a/fs_selfservice/freeside-selfservice-server +++ b/fs_selfservice/freeside-selfservice-server @@ -8,17 +8,16 @@ # Proc::Daemon or somesuch use strict; -use vars qw( $kids $max_kids $shutdown $log_file ); -use vars qw($ssh_pid); +use vars qw( $Debug %kids $kids $max_kids $shutdown $log_file $ssh_pid ); use Fcntl qw(:flock); -use POSIX qw(setsid); -use Date::Format; +use POSIX qw(:sys_wait_h setsid); use IO::Handle; +use IO::Select; +use IO::File; use Storable qw(nstore_fd fd_retrieve); use Net::SSH qw(sshopen2); -use FS::UID qw(adminsuidsetup forksuidsetup); -use LockFile::Simple qw(lock unlock); +use FS::UID qw(adminsuidsetup forksuidsetup); #use Tie::RefHash; #use FS::Conf; @@ -27,6 +26,9 @@ use LockFile::Simple qw(lock unlock); #use FS::cust_main; #use FS::Msgcat qw(gettext); +$Debug = 1; # >= 2 will log packet contents, including potentially compromising + # information + $shutdown = 0; $max_kids = '10'; #? $kids = 0; @@ -35,8 +37,6 @@ my $user = shift or die &usage; my $machine = shift or die &usage; my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; #my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; $FS::UID::datasrc not posible, but should include machine name at least, hmm -my $lock_file = "/usr/local/etc/freeside/freeside-selfservice-server.$user.lock"; -unlink $lock_file; &init($user); @@ -51,65 +51,61 @@ my %dispatch = ( my $warnkids=0; while (1) { - my($reader, $writer) = (new IO::Handle, new IO::Handle); - warn "connecting to $machine\n"; + my($writer,$reader,$error) = (new IO::Handle, new IO::Handle, new IO::Handle); + warn "connecting to $machine\n" if $Debug; + $ssh_pid = sshopen2($machine,$reader,$writer,$clientd); # nstore_fd(\*writer, {'hi'=>'there'}); - warn "entering main loop\n"; + warn "entering main loop\n" if $Debug; my $undisp = 0; + my $s = IO::Select->new( $reader ); while (1) { - warn "waiting for packet from client\n" unless $undisp; + &reap_kids; + + warn "waiting for packet from client\n" if $Debug && !$undisp; $undisp = 1; - my $packet = eval { - local $SIG{__DIE__}; - local $SIG{ALRM} = sub { local $SIG{__DIE__};die "MyAlarm\n" }; #NB: \n required - alarm 5; - #my $string = <$reader>; - #die $string; - my $p = fd_retrieve($reader); - alarm 0; - $p; - }; - if ($@) { - &shutdown if $shutdown && $@; - die "Fatal error receiving packet from client: $@" if $@ !~ /^MyAlarm/; - #die $@ unless $@ eq "alarm\n" || $@ eq 'Alarm'; #????? - #timeout - next unless $shutdown; - &shutdown; + my @handles = $s->can_read(5); + unless ( @handles ) { + &shutdown if $shutdown; + next; } - warn "packet received\n". - join('', map { " $_=>$packet->{$_}\n" } keys %$packet ); $undisp = 0; + warn "receiving packet from client\n" if $Debug; + + my $packet = fd_retrieve($reader); + warn "packet received\n". + join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) + if $Debug > 1; + #prevent runaway forking my $warnkids = 0; while ( $kids >= $max_kids ) { warn "WARNING: maximum $kids children reached\n" unless $warnkids++; + &reap_kids; sleep 1; } - warn "forking child\n"; + warn "forking child\n" if $Debug; defined( my $pid = fork ) or die "can't fork: $!"; if ( $pid ) { - warn "child $pid spawned\n"; $kids++; + $kids{$pid} = 1; + warn "child $pid spawned\n" if $Debug; } else { #kid time - #local($SIG{PIPE}); - #get new db handle - #$FS::UID::dbh->{InactiveDestroy} = 1; + $FS::UID::dbh->{InactiveDestroy} = 1; forksuidsetup($user); my $sub = $dispatch{$packet->{_packet}}; my $rv; if ( $sub ) { - warn "calling $sub handler\n"; + warn "calling $sub handler\n" if $Debug; $rv = &{$sub}($packet); } else { warn my $error = "WARNING: unknown packet type ". $packet->{_packet}; @@ -117,15 +113,13 @@ while (1) { } $rv->{_token} = $packet->{_token}; #identifier - warn "sending response\n"; - flock($writer, LOCK_EX); #acquire write lock - #lock($lock_file); - nstore_fd($rv, $writer) or die "can't send response: $!"; - $writer->flush; - #unlock($lock_file); - flock($writer, LOCK_UN); #release write lock -# - warn "child exiting\n"; + warn "sending response\n" if $Debug; + flock($writer, LOCK_EX) or die "FATAL: can't lock write stream: $!"; + nstore_fd($rv, $writer) or die "FATAL: can't send response: $!"; + $writer->flush or die "FATAL: can't flush: $!"; + flock($writer, LOCK_UN) or die "WARNING: can't release write lock: $!"; + + warn "child exiting\n" if $Debug; exit; #end-of-kid } @@ -181,11 +175,23 @@ sub passwd { # utility subroutines ### +sub reap_kids { + #warn "reaping kids\n"; + foreach my $pid ( keys %kids ) { + my $kid = waitpid($pid, WNOHANG); + if ( $kid > 0 ) { + $kids--; + delete $kids{$kid}; + } + } + #warn "done reaping\n"; +} + sub init { my $user = shift; chdir "/" or die "Can't chdir to /: $!"; - open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; defined(my $pid = fork) or die "Can't fork: $!"; if ( $pid ) { print "freeside-selfservice-server to $machine started with pid $pid\n"; #logging to $log_file @@ -195,8 +201,9 @@ sub init { exit; } - sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; } - $SIG{CHLD} = \&REAPER; +# sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; } +# #sub REAPER { my $pid = wait; $kids--; $SIG{CHLD} = \&REAPER; } +# $SIG{CHLD} = \&REAPER; $shutdown = 0; $SIG{HUP} = sub { warn "SIGHUP received; shutting down\n"; $shutdown++; }; @@ -205,9 +212,6 @@ sub init { $SIG{QUIT} = sub { warn "SIGQUIT received; shutting down\n"; $shutdown++; }; $SIG{PIPE} = sub { warn "SIGPIPE received; shutting down\n"; $shutdown++; }; - $> = $FS::UID::freeside_uid unless $>; - $< = $>; - #false laziness w/freeside-queued my $freeside_gid = scalar(getgrnam('freeside')) or die "can't setgid to freeside group\n"; @@ -233,7 +237,7 @@ sub init { open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; setsid or die "Can't start a new session: $!"; -# open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; + open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; $SIG{__DIE__} = \&_die; $SIG{__WARN__} = \&_logmsg; @@ -260,11 +264,16 @@ sub _die { } sub _logmsg { + chomp( my $msg = shift ); + _do_logmsg( "[server] [". scalar(localtime). "] [$$] $msg\n" ); +} + +sub _do_logmsg { chomp( my $msg = shift ); my $log = new IO::File ">>$log_file"; flock($log, LOCK_EX); seek($log, 0, 2); - print $log "[server] [". time2str("%a %b %e %T %Y",time). "] [$$] $msg\n"; + print $log "$msg\n"; flock($log, LOCK_UN); close $log; } @@ -273,7 +282,3 @@ sub usage { die "Usage:\n\n fs_signup_server user machine\n"; } -### -# handlers... should go in their own files eventually... -### - diff --git a/fs_selfservice/fs_passwd_test b/fs_selfservice/fs_passwd_test index 77782e651..c6a297968 100755 --- a/fs_selfservice/fs_passwd_test +++ b/fs_selfservice/fs_passwd_test @@ -9,6 +9,10 @@ my $error = passwd( 'new_password' => 'haloo', ); -die $error if $error; +if ( $error eq 'Incorrect password.' ) { + exit; +} else { + die $error if $error; + die "no error"; +} -print "password changed sucessfully\n"; -- cgit v1.2.1 From 6ff02eb18af2dd61ce2dca064414ca183fa02e6e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Jul 2002 12:28:02 +0000 Subject: invoice viewing... --- fs_selfservice/DEPLOY | 7 ++ fs_selfservice/FS-SelfService/SelfService.pm | 41 +++++--- fs_selfservice/FS-SelfService/cgi/login.html | 23 +++++ fs_selfservice/FS-SelfService/cgi/myaccount.html | 47 +++++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 109 +++++++++++++++++++++ .../FS-SelfService/cgi/view_invoice.html | 21 ++++ .../FS-SelfService/freeside-selfservice-clientd | 2 +- fs_selfservice/freeside-selfservice-server | 74 ++------------ fs_selfservice/fs_passwd_test | 3 +- 9 files changed, 246 insertions(+), 81 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/login.html create mode 100644 fs_selfservice/FS-SelfService/cgi/myaccount.html create mode 100644 fs_selfservice/FS-SelfService/cgi/selfservice.cgi create mode 100644 fs_selfservice/FS-SelfService/cgi/view_invoice.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY index 9b03bf259..7c68e78ec 100755 --- a/fs_selfservice/DEPLOY +++ b/fs_selfservice/DEPLOY @@ -1,8 +1,15 @@ #!/bin/sh +( cd ..; make deploy; cd fs_selfservice ) + cd FS-SelfService perl Makefile.PL && make && make install cd .. kill `cat /var/run/freeside-selfservice-server.ivan.pid`; sleep 3 ./freeside-selfservice-server ivan localhost + +cp /home/ivan/freeside_current/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount +chown freeside /var/www/MyAccount/selfservice.cgi +chmod 4755 /var/www/MyAccount/selfservice.cgi +ln -s /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/index.cgi diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 3cd4fd94e..9019ea4f8 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1,7 +1,7 @@ package FS::SelfService; use strict; -use vars qw($VERSION @ISA @EXPORT_OK $socket); +use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload ); use Exporter; use Socket; use FileHandle; @@ -12,10 +12,19 @@ use Storable qw(nstore_fd fd_retrieve); $VERSION = '0.03'; @ISA = qw( Exporter ); -@EXPORT_OK = qw( passwd ); $socket = "/usr/local/freeside/selfservice_socket"; +%autoload = ( + 'passwd' => 'passwd/passwd', + 'chfn' => 'passwd/passwd', + 'chsh' => 'passwd/passwd', + 'login' => 'MyAccount/login', + 'customer_info' => 'MyAccount/customer_info', + 'invoice' => 'MyAccount/invoice', +); +@EXPORT_OK = keys %autoload; + $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = " \t\n"; @@ -49,17 +58,25 @@ Returns the empty value on success, or an error message on errors. =cut -sub passwd { - my $param; - if ( ref($_[0]) ) { - $param = shift; - } else { - $param = { @_ }; - } +foreach my $autoload ( keys %autoload ) { + + my $eval = + "sub $autoload { ". ' + my $param; + if ( ref($_[0]) ) { + $param = shift; + } else { + $param = { @_ }; + } + + $param->{_packet} = \''. $autoload{$autoload}. '\'; + + simple_packet($param); + }'; - $param->{_packet} = 'passwd'; + eval $eval; + die $@ if $@; - simple_packet($param); } sub simple_packet { @@ -78,7 +95,7 @@ sub simple_packet { my $return = fd_retrieve(\*SOCK) or die "error reading result: $!"; die $return->{'_error'} if defined $return->{_error} && $return->{_error}; - $return->{'error'}; + $return; } =back diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html new file mode 100644 index 000000000..dfbd0137a --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -0,0 +1,23 @@ +Login +Login

+<%= $error %> +
+ + + + + + + + + + + + + + + +
Username
Domain
Password
+

+
+ diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html new file mode 100644 index 000000000..f8a916eea --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -0,0 +1,47 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+MyAccount
+SomethingElse
+
+ +Hello <%= $name %>!

+Your customer number is <%= $custnum %>

+Your contact information
<%= $small_custview %> +Your outstanding balance is $<%= $balance %>

+ +<%= + if ( @open_invoices ) { + $OUT .= ''. + '$td${a}Invoice #". $invoice->{'invnum'}. "$td". + "$td$a". $invoice->{'date'}. "$td". + qq!'. + ''; + $col = $col eq $col1 ? $col2 : $col1; + } + $OUT .= '
Open Invoices'; + my $link = qq!!; + my $a=qq!'; + $OUT .= + "
$a\$!. $invoice->{'owed'}. + '
'; + } else { + $OUT .= 'You have no outstanding invoices.

'; + } +%> + +
+
+small text + + + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi new file mode 100644 index 000000000..eae373931 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -0,0 +1,109 @@ +#!/usr/bin/perl -Tw + +use strict; +use vars qw($cgi $session_id $form_max $template_dir); +use subs qw(do_template); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use Text::Template; +use FS::SelfService qw(login customer_info invoice); + +$template_dir = '.'; + +$form_max = 255; + +$cgi = new CGI; + +unless ( defined $cgi->param('session') ) { + do_template('login',{}); + exit; +} + +if ( $cgi->param('session') eq 'login' ) { + + $cgi->param('username') =~ /^\s*([a-z0-9_\-\.\&]{0,$form_max})\s*$/i + or die "illegal username"; + my $username = $1; + + $cgi->param('domain') =~ /^\s*([\w\-\.]{0,$form_max})\s*$/ + or die "illegal domain"; + my $domain = $1; + + $cgi->param('password') =~ /^(.{0,$form_max})$/ + or die "illegal password"; + my $password = $1; + + my $rv = login( + 'username' => $username, + 'domain' => $domain, + 'password' => $password, + ); + if ( $rv->{error} ) { + do_template('login', { + 'error' => $rv->{error}, + 'username' => $username, + 'domain' => $domain, + } ); + exit; + } else { + $cgi->param('session' => $rv->{session_id} ); + $cgi->param('action' => 'myaccount' ); + } +} + +$session_id = $cgi->param('session'); + +$cgi->param('action') =~ /^(myaccount|view_invoice)$/ + or die "unknown action ". $cgi->param('action'); +my $action = $1; + +my $result = eval "&$action();"; +die $@ if $@; + +if ( $result->{error} eq "Can't resume session" ) { #ick + do_template('login',{}); + exit; +} + +#warn $result->{'open_invoices'}; +#warn scalar(@{$result->{'open_invoices'}}); + +do_template($action, { + 'session_id' => $session_id, + %{$result} +}); + +#-- + +sub myaccount { customer_info( 'session_id' => $session_id ); } + +sub view_invoice { + + $cgi->param('invnum') =~ /^(\d+)$/ or die "illegal invnum"; + my $invnum = $1; + + invoice( 'session_id' => $session_id, + 'invnum' => $invnum, + ); + +} + +#-- + +sub do_template { + my $name = shift; + my $fill_in = shift; + + $cgi->delete_all(); + $fill_in->{'self_url'} = $cgi->self_url; + + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => "$template_dir/$name.html", + DELIMITERS => [ '<%=', '%>' ], + UNTAINT => 1, ) + or die $Text::Template::ERROR; + + print $cgi->header( '-expires' => 'now' ), + $template->fill_in( HASH => $fill_in ); +} + diff --git a/fs_selfservice/FS-SelfService/cgi/view_invoice.html b/fs_selfservice/FS-SelfService/cgi/view_invoice.html new file mode 100644 index 000000000..33388de99 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/view_invoice.html @@ -0,0 +1,21 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+MyAccount
+SomethingElse
+
+ +<-- back to MyAccount

+ +
+<%= $invoice_text %>
+
+ +
+
+small text + + + + diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 319d4254f..0c25c3407 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -17,7 +17,7 @@ use IO::File; STDOUT->setbuf(''); use vars qw( $Debug ); -$Debug = 2; #2 will turn on child logging, 3 will log packet contents, +$Debug = 3; #2 will turn on child logging, 3 will log packet contents, #including potentially compromising information my $socket = "/usr/local/freeside/selfservice_socket"; diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server index 0e1c75e43..e55ca4984 100644 --- a/fs_selfservice/freeside-selfservice-server +++ b/fs_selfservice/freeside-selfservice-server @@ -16,17 +16,10 @@ use IO::Select; use IO::File; use Storable qw(nstore_fd fd_retrieve); use Net::SSH qw(sshopen2); - use FS::UID qw(adminsuidsetup forksuidsetup); +use FS::ClientAPI; -#use Tie::RefHash; -#use FS::Conf; -#use FS::Record qw( qsearch qsearchs ); -#use FS::cust_main_county; -#use FS::cust_main; -#use FS::Msgcat qw(gettext); - -$Debug = 1; # >= 2 will log packet contents, including potentially compromising +$Debug = 2; # >= 2 will log packet contents, including potentially compromising # information $shutdown = 0; @@ -42,13 +35,6 @@ my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name? -my %dispatch = ( - 'signup' => \&signup, - #'signup_init' => 'signup_init', - 'passwd' => \&passwd, - -); - my $warnkids=0; while (1) { my($writer,$reader,$error) = (new IO::Handle, new IO::Handle, new IO::Handle); @@ -102,13 +88,11 @@ while (1) { $FS::UID::dbh->{InactiveDestroy} = 1; forksuidsetup($user); - my $sub = $dispatch{$packet->{_packet}}; - my $rv; - if ( $sub ) { - warn "calling $sub handler\n" if $Debug; - $rv = &{$sub}($packet); - } else { - warn my $error = "WARNING: unknown packet type ". $packet->{_packet}; + my $type = $packet->{_packet}; + warn "calling $type handler\n" if $Debug; + my $rv = eval { FS::ClientAPI->dispatch($type, $packet); }; + if ( $@ ) { + warn my $error = "WARNING: error dispatching $type: $@"; $rv = { _error => $error }; } $rv->{_token} = $packet->{_token}; #identifier @@ -127,50 +111,6 @@ while (1) { } -### -# dispatch subroutines (should live elsewhere eventually) -### - -sub passwd { - #sleep 3; - use FS::Record qw(qsearchs); - use FS::svc_acct; - #use FS::svc_domain; - - my $packet = shift; - - #my $domain = qsearchs('svc_domain', { 'domain' => $packet->{'domain'} } ) - # or return { error => "Domain $domain not found" }; - - my $old_password = $packet->{'old_password'}; - my $new_password = $packet->{'new_password'}; - my $new_gecos = $packet->{'new_gecos'}; - my $new_shell = $packet->{'new_shell'}; - - my $svc_acct = - ( length($old_password) < 13 - && qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - #'domsvc' => $svc_domain->domsvc, - '_password' => $old_password } ) - ) - || qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - #'domsvc' => $svc_domain->domsvc, - '_password' => $old_password } ); - - unless ( $svc_acct ) { return { error => 'Incorrect password.' } } - - 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); - - return { error => $error }; - -} - ### # utility subroutines ### diff --git a/fs_selfservice/fs_passwd_test b/fs_selfservice/fs_passwd_test index c6a297968..4f8b8a888 100755 --- a/fs_selfservice/fs_passwd_test +++ b/fs_selfservice/fs_passwd_test @@ -3,11 +3,12 @@ use strict; use FS::SelfService qw(passwd); -my $error = passwd( +my $rv = passwd( 'username' => 'ivan', 'old_password' => 'heyhoo', 'new_password' => 'haloo', ); +my $error = $rv->{error}; if ( $error eq 'Incorrect password.' ) { exit; -- cgit v1.2.1 From 920c0d8dea4535893157a547c87dda63dca64599 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Jul 2002 10:51:22 +0000 Subject: adding --- fs_selfservice/FS-SelfService/cgi/passwd.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 fs_selfservice/FS-SelfService/cgi/passwd.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/passwd.html b/fs_selfservice/FS-SelfService/cgi/passwd.html new file mode 100644 index 000000000..fadc4df8b --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/passwd.html @@ -0,0 +1,25 @@ + + + Change password + + +

Change password

+
+ + + + + + + + + + + + + +
Username
Current password
New password
Re-enter new password
+
+ + + -- cgit v1.2.1 From a09332084464d9319cd98aaabae901ad1be0ebb7 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 23 Dec 2002 14:38:51 +0000 Subject: added stuff for selfservice_server-quiet, signup_server-quiet, and emailcancel messages. --- fs_selfservice/freeside-selfservice-server | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server index e55ca4984..264cbc56d 100644 --- a/fs_selfservice/freeside-selfservice-server +++ b/fs_selfservice/freeside-selfservice-server @@ -19,6 +19,10 @@ use Net::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup forksuidsetup); use FS::ClientAPI; +use FS::Conf; +use FS::cust_bill; +use FS::cust_pkg; + $Debug = 2; # >= 2 will log packet contents, including potentially compromising # information @@ -33,6 +37,13 @@ my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; &init($user); +my $conf = new FS::Conf; + +if ($conf->exists('selfservice_server-quiet')) { + $FS::cust_bill::quiet = 1; + $FS::cust_pkg::quiet = 1; +} + my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name? my $warnkids=0; -- cgit v1.2.1 From 1bfcd9ce4738e5c9f3c8a309775235e823b2f82c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 14 Jan 2003 09:26:49 +0000 Subject: move freeside-selfservice-server to proper MakeMaker install location --- fs_selfservice/freeside-selfservice-server | 235 ----------------------------- 1 file changed, 235 deletions(-) delete mode 100644 fs_selfservice/freeside-selfservice-server (limited to 'fs_selfservice') diff --git a/fs_selfservice/freeside-selfservice-server b/fs_selfservice/freeside-selfservice-server deleted file mode 100644 index 264cbc56d..000000000 --- a/fs_selfservice/freeside-selfservice-server +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/perl -w -# -# freeside-selfservice-server - -# alas, much false laziness with freeside-queued and fs_signup_server. at -# least it is slated to replace fs_{signup,passwd,mailadmin}_server -# should probably generalize the version in here, or better yet use -# Proc::Daemon or somesuch - -use strict; -use vars qw( $Debug %kids $kids $max_kids $shutdown $log_file $ssh_pid ); -use Fcntl qw(:flock); -use POSIX qw(:sys_wait_h setsid); -use IO::Handle; -use IO::Select; -use IO::File; -use Storable qw(nstore_fd fd_retrieve); -use Net::SSH qw(sshopen2); -use FS::UID qw(adminsuidsetup forksuidsetup); -use FS::ClientAPI; - -use FS::Conf; -use FS::cust_bill; -use FS::cust_pkg; - -$Debug = 2; # >= 2 will log packet contents, including potentially compromising - # information - -$shutdown = 0; -$max_kids = '10'; #? -$kids = 0; - -my $user = shift or die &usage; -my $machine = shift or die &usage; -my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; -#my $pid_file = "/var/run/freeside-selfservice-server.$user.pid"; $FS::UID::datasrc not posible, but should include machine name at least, hmm - -&init($user); - -my $conf = new FS::Conf; - -if ($conf->exists('selfservice_server-quiet')) { - $FS::cust_bill::quiet = 1; - $FS::cust_pkg::quiet = 1; -} - -my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name? - -my $warnkids=0; -while (1) { - my($writer,$reader,$error) = (new IO::Handle, new IO::Handle, new IO::Handle); - warn "connecting to $machine\n" if $Debug; - - $ssh_pid = sshopen2($machine,$reader,$writer,$clientd); - -# nstore_fd(\*writer, {'hi'=>'there'}); - - warn "entering main loop\n" if $Debug; - my $undisp = 0; - my $s = IO::Select->new( $reader ); - while (1) { - - &reap_kids; - - warn "waiting for packet from client\n" if $Debug && !$undisp; - $undisp = 1; - my @handles = $s->can_read(5); - unless ( @handles ) { - &shutdown if $shutdown; - next; - } - - $undisp = 0; - - warn "receiving packet from client\n" if $Debug; - - my $packet = fd_retrieve($reader); - warn "packet received\n". - join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) - if $Debug > 1; - - #prevent runaway forking - my $warnkids = 0; - while ( $kids >= $max_kids ) { - warn "WARNING: maximum $kids children reached\n" unless $warnkids++; - &reap_kids; - sleep 1; - } - - warn "forking child\n" if $Debug; - defined( my $pid = fork ) or die "can't fork: $!"; - if ( $pid ) { - $kids++; - $kids{$pid} = 1; - warn "child $pid spawned\n" if $Debug; - } else { #kid time - - #get new db handle - $FS::UID::dbh->{InactiveDestroy} = 1; - forksuidsetup($user); - - my $type = $packet->{_packet}; - warn "calling $type handler\n" if $Debug; - my $rv = eval { FS::ClientAPI->dispatch($type, $packet); }; - if ( $@ ) { - warn my $error = "WARNING: error dispatching $type: $@"; - $rv = { _error => $error }; - } - $rv->{_token} = $packet->{_token}; #identifier - - warn "sending response\n" if $Debug; - flock($writer, LOCK_EX) or die "FATAL: can't lock write stream: $!"; - nstore_fd($rv, $writer) or die "FATAL: can't send response: $!"; - $writer->flush or die "FATAL: can't flush: $!"; - flock($writer, LOCK_UN) or die "WARNING: can't release write lock: $!"; - - warn "child exiting\n" if $Debug; - exit; #end-of-kid - } - - } - -} - -### -# utility subroutines -### - -sub reap_kids { - #warn "reaping kids\n"; - foreach my $pid ( keys %kids ) { - my $kid = waitpid($pid, WNOHANG); - if ( $kid > 0 ) { - $kids--; - delete $kids{$kid}; - } - } - #warn "done reaping\n"; -} - -sub init { - my $user = shift; - - chdir "/" or die "Can't chdir to /: $!"; - open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; - defined(my $pid = fork) or die "Can't fork: $!"; - if ( $pid ) { - print "freeside-selfservice-server to $machine started with pid $pid\n"; #logging to $log_file - exit unless $pid_file; - my $pidfh = new IO::File ">$pid_file" or exit; - print $pidfh "$pid\n"; - exit; - } - -# sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; } -# #sub REAPER { my $pid = wait; $kids--; $SIG{CHLD} = \&REAPER; } -# $SIG{CHLD} = \&REAPER; - - $shutdown = 0; - $SIG{HUP} = sub { warn "SIGHUP received; shutting down\n"; $shutdown++; }; - $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $shutdown++; }; - $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $shutdown++; }; - $SIG{QUIT} = sub { warn "SIGQUIT received; shutting down\n"; $shutdown++; }; - $SIG{PIPE} = sub { warn "SIGPIPE received; shutting down\n"; $shutdown++; }; - - #false laziness w/freeside-queued - my $freeside_gid = scalar(getgrnam('freeside')) - or die "can't setgid to freeside group\n"; - $) = $freeside_gid; - $( = $freeside_gid; - #if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd - ($(,$)) = ($),$(); - $) = $freeside_gid; - - $> = $FS::UID::freeside_uid; - $< = $FS::UID::freeside_uid; - #freebsd is sofa king broken, won't setuid() - ($<,$>) = ($>,$<); - $> = $FS::UID::freeside_uid; - #eslaf - - $ENV{HOME} = (getpwuid($>))[7]; #for ssh - adminsuidsetup $user; - - #$log_file = "/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc; #MACHINE NAME - $log_file = "/usr/local/etc/freeside/selfservice.$machine.log"; - - open STDOUT, '>/dev/null' - or die "Can't write to /dev/null: $!"; - setsid or die "Can't start a new session: $!"; - open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; - - $SIG{__DIE__} = \&_die; - $SIG{__WARN__} = \&_logmsg; - - warn "freeside-selfservice-server starting\n"; - -} - -sub shutdown { - my $wait = 12; #wait up to 1 minute - while ( $kids > 0 && $wait-- ) { - warn "waiting for $kids children to terminate"; - sleep 5; - } - warn "abandoning $kids children" if $kids; - kill 'TERM', $ssh_pid if $ssh_pid; - die "exiting"; -} - -sub _die { - my $msg = shift; - unlink $pid_file if -e $pid_file; - _logmsg($msg); -} - -sub _logmsg { - chomp( my $msg = shift ); - _do_logmsg( "[server] [". scalar(localtime). "] [$$] $msg\n" ); -} - -sub _do_logmsg { - chomp( my $msg = shift ); - my $log = new IO::File ">>$log_file"; - flock($log, LOCK_EX); - seek($log, 0, 2); - print $log "$msg\n"; - flock($log, LOCK_UN); - close $log; -} - -sub usage { - die "Usage:\n\n fs_signup_server user machine\n"; -} - -- cgit v1.2.1 From e5e992881cee6c8bb5c64c101d1985d47fd62cd6 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jan 2003 06:21:38 +0000 Subject: selfservice cancel functionality --- fs_selfservice/FS-SelfService/SelfService.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 9019ea4f8..4d68d614a 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -22,6 +22,7 @@ $socket = "/usr/local/freeside/selfservice_socket"; 'login' => 'MyAccount/login', 'customer_info' => 'MyAccount/customer_info', 'invoice' => 'MyAccount/invoice', + 'cancel' => 'MyAccount/cancel', ); @EXPORT_OK = keys %autoload; -- cgit v1.2.1 From 1a6e8ccb610247daf9f475358471cfeed44f4e65 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 May 2003 06:03:53 +0000 Subject: updated freebsd install --- fs_selfservice/DEPLOY | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY index 7c68e78ec..7ab3b2a7a 100755 --- a/fs_selfservice/DEPLOY +++ b/fs_selfservice/DEPLOY @@ -9,7 +9,7 @@ cd .. kill `cat /var/run/freeside-selfservice-server.ivan.pid`; sleep 3 ./freeside-selfservice-server ivan localhost -cp /home/ivan/freeside_current/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount +cp /home/ivan/freeside/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount chown freeside /var/www/MyAccount/selfservice.cgi -chmod 4755 /var/www/MyAccount/selfservice.cgi -ln -s /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/index.cgi +chmod 755 /var/www/MyAccount/selfservice.cgi +ln -s /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/index.cgi || true -- cgit v1.2.1 From 6a961cb36a8f9606a168331fd5c3625c3bbec9c2 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 12 May 2003 07:34:15 +0000 Subject: setbuf call doesn't appear to be working... --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 0c25c3407..f13dd42d7 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -14,7 +14,7 @@ use IO::Handle qw(_IONBF); use IO::Select; use IO::File; -STDOUT->setbuf(''); +#STDOUT->setbuf(''); use vars qw( $Debug ); $Debug = 3; #2 will turn on child logging, 3 will log packet contents, -- cgit v1.2.1 From 9033414f18177eb733d1a227d2be1c15d244f766 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 13 May 2003 03:22:35 +0000 Subject: - self-service updates: cleanup and beginnings of "make a payment" - fix pod masking FS::svc_acct::cust_svc --- fs_selfservice/FS-SelfService/cgi/login.html | 15 ++++++++++++--- fs_selfservice/FS-SelfService/cgi/myaccount.html | 13 ++++++++----- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 8 ++++++-- fs_selfservice/FS-SelfService/cgi/view_invoice.html | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html index dfbd0137a..112cc34ea 100644 --- a/fs_selfservice/FS-SelfService/cgi/login.html +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -6,16 +6,25 @@ - + - + - +
Username + + +
Domain + + +
Password + + +


diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index f8a916eea..d8bfe0cb1 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -3,20 +3,23 @@ <%= $url = "$selfurl?session=$session_id;action="; ''; %> @@ -23,7 +23,7 @@
MyAccount
-SomethingElse
+
Hello <%= $name %>!

-Your customer number is <%= $custnum %>

Your contact information
<%= $small_custview %> -Your outstanding balance is $<%= $balance %>

+
+<%= if ( $balance ) { + $OUT .= qq! Make a $balance payment!; +} %> +

<%= if ( @open_invoices ) { $OUT .= ''. '
Open Invoices'; - my $link = qq!myaccount!; my $col1 = "ffffff"; my $col2 = "dddddd"; my $col = $col1; @@ -40,7 +43,7 @@ Your outstanding balance is $<%= $balance %>


-small text +powered by freeside diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index eae373931..9b8bdc100 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -53,7 +53,7 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); -$cgi->param('action') =~ /^(myaccount|view_invoice)$/ +$cgi->param('action') =~ /^(myaccount|view_invoice|make_payment)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -88,6 +88,10 @@ sub view_invoice { } +sub make_payment { + +} + #-- sub do_template { @@ -95,7 +99,7 @@ sub do_template { my $fill_in = shift; $cgi->delete_all(); - $fill_in->{'self_url'} = $cgi->self_url; + $fill_in->{'selfurl'} = $cgi->self_url; my $template = new Text::Template( TYPE => 'FILE', SOURCE => "$template_dir/$name.html", diff --git a/fs_selfservice/FS-SelfService/cgi/view_invoice.html b/fs_selfservice/FS-SelfService/cgi/view_invoice.html index 33388de99..d2b012b5d 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_invoice.html +++ b/fs_selfservice/FS-SelfService/cgi/view_invoice.html @@ -3,7 +3,7 @@ <%= $url = "$selfurl?session=$session_id;action="; ''; %>
MyAccount
-SomethingElse
+
<-- back to MyAccount

@@ -14,7 +14,7 @@

-small text +powered by freeside -- cgit v1.2.1 From d1d57ae4fa0f2a30b36a70c656aa2672744f75a3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 18 May 2003 06:20:21 +0000 Subject: self-service: make payment UI done --- fs_selfservice/FS-SelfService/SelfService.pm | 1 + fs_selfservice/FS-SelfService/cgi/login.html | 4 ++-- fs_selfservice/FS-SelfService/cgi/myaccount.html | 7 ++----- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 5 +++-- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 4d68d614a..c561dabdb 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -23,6 +23,7 @@ $socket = "/usr/local/freeside/selfservice_socket"; 'customer_info' => 'MyAccount/customer_info', 'invoice' => 'MyAccount/invoice', 'cancel' => 'MyAccount/cancel', + 'payment_info' => 'MyAccount/payment_info', ); @EXPORT_OK = keys %autoload; diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html index 112cc34ea..ca6251eb1 100644 --- a/fs_selfservice/FS-SelfService/cgi/login.html +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -8,7 +8,7 @@
Username - +
Password - +
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index d8bfe0cb1..f1a63870a 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -9,12 +9,9 @@ Hello <%= $name %>!

Your contact information
<%= $small_custview %>
-<%= if ( $balance ) { - $OUT .= qq! Make a $balance payment!; +<%= if ( $balance > 0 ) { + $OUT .= qq! Make a payment

!; } %> -

- <%= if ( @open_invoices ) { $OUT .= ''. diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 9b8bdc100..7b392bcf4 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -6,7 +6,7 @@ use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Template; -use FS::SelfService qw(login customer_info invoice); +use FS::SelfService qw(login customer_info invoice payment_info); $template_dir = '.'; @@ -68,6 +68,7 @@ if ( $result->{error} eq "Can't resume session" ) { #ick #warn $result->{'open_invoices'}; #warn scalar(@{$result->{'open_invoices'}}); +warn "processing template $action\n"; do_template($action, { 'session_id' => $session_id, %{$result} @@ -89,7 +90,7 @@ sub view_invoice { } sub make_payment { - + payment_info( 'session_id' => $session_id ); } #-- -- cgit v1.2.1 From 416dc3b6df09133c4130445008919408f04586c3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 18 May 2003 08:08:12 +0000 Subject: more self-service make payment UI work --- fs_selfservice/DEPLOY | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY index 7ab3b2a7a..4aef4cfa4 100755 --- a/fs_selfservice/DEPLOY +++ b/fs_selfservice/DEPLOY @@ -1,14 +1,12 @@ #!/bin/sh +kill `cat /var/run/freeside-selfservice-server.fs_selfservice.pid` + ( cd ..; make deploy; cd fs_selfservice ) cd FS-SelfService perl Makefile.PL && make && make install -cd .. -kill `cat /var/run/freeside-selfservice-server.ivan.pid`; sleep 3 -./freeside-selfservice-server ivan localhost - cp /home/ivan/freeside/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount chown freeside /var/www/MyAccount/selfservice.cgi chmod 755 /var/www/MyAccount/selfservice.cgi -- cgit v1.2.1 From 2c88b03550a72438bbd75ec7461d2c26fc797efc Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 18 May 2003 08:09:41 +0000 Subject: forgot this file --- .../FS-SelfService/cgi/make_payment.html | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 fs_selfservice/FS-SelfService/cgi/make_payment.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html new file mode 100644 index 000000000..d469bddb6 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -0,0 +1,118 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+MyAccount
+ +
+Make a payment

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Amount Due +
+ $<%=sprintf("%.2f",$balance)%> +
+
Payment amount +
+ $"> +
+
Card type + +
Card number + + + + + + + + +
+ Exp. + + / + +
+
Exact name on card
Card billing address + +
Address line 2 + +
City + + + + + + + + +
+ + State + + Zip + +
+
+ + Remember this information +
+ NAME="CARD"> + Charge future payments to this card automatically +
+ + +
+
+powered by freeside + + -- cgit v1.2.1 From 667a729f660ad4f871acd5eb3173303396543eeb Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 18 May 2003 11:44:37 +0000 Subject: interface for making payments all done --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 14 ++++++++------ fs_selfservice/FS-SelfService/cgi/myaccount.html | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index d469bddb6..ce1db6865 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -6,7 +6,7 @@ Make a payment

-
+ @@ -29,8 +29,8 @@ - +
Card type @@ -63,7 +63,7 @@
Exact name on card
Card billing address @@ -85,7 +85,7 @@ State @@ -109,7 +109,9 @@
- +
+ +

diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index f1a63870a..f48fdedea 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -7,7 +7,7 @@ Hello <%= $name %>!

-Your contact information
<%= $small_custview %> +<%= $small_custview %>
<%= if ( $balance > 0 ) { $OUT .= qq! Make a payment

!; -- cgit v1.2.1 From f0afbc011e7b909a2e6ac54039c975710e76f341 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 19 May 2003 00:15:20 +0000 Subject: processing payments... --- .../FS-SelfService/cgi/make_payment.html | 4 +- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 73 +++++++++++++++++++++- 2 files changed, 74 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index ce1db6865..6adc0bde0 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -99,12 +99,12 @@ - + Remember this information - NAME="CARD"> + NAME="auto" VALUE="1"> Charge future payments to this card automatically diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 7b392bcf4..2ce2c8b6c 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -53,7 +53,8 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); -$cgi->param('action') =~ /^(myaccount|view_invoice|make_payment)$/ +$cgi->param('action') =~ + /^(myaccount|view_invoice|make_payment|process_payment)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -93,6 +94,76 @@ sub make_payment { payment_info( 'session_id' => $session_id ); } +sub process_payment { + + $cgi->param('amount') =~ /^\s*(\d+(\.\d{2})?)\s*$/ + or die "illegal amount"; #!!! + my $amount = $1; + + my $payinfo = $cgi->param('payinfo'); + $payinfo =~ s/\D//g; + $payinfo =~ /^(\d{13,16})$/ + #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + or die "illegal card"; #!!! + $payinfo = $1; + validate($payinfo) + #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + or die "invalid card"; #!!! + cardtype($payinfo) eq $cgi->param('card_type') + #or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); + or die "not a ". $cgi->param('card_type'); + + $cgi->param('month') =~ /^(\d{2})$/ or die "illegal month"; + my $month = $1; + $cgi->param('year') =~ /^(\d{4})$/ or die "illegal year"; + my $year = $1; + + $cgi->param('payname') =~ /^(.{0,80})$/ or die "illegal payname"; + my $payname = $1; + + $cgi->param('address1') =~ /^(.{0,80})$/ or die "illegal address1"; + my $address1 = $1; + + $cgi->param('address2') =~ /^(.{0,80})$/ or die "illegal address2"; + my $address2 = $1; + + $cgi->param('city') =~ /^(.{0,80})$/ or die "illegal city"; + my $city = $1; + + $cgi->param('state') =~ /^(.{2})$/ or die "illegal state"; + my $state = $1; + + $cgi->param('zip') =~ /^(.{0,10})$/ or die "illegal zip"; + my $zip = $1; + + my $save = 0; + $save = 1 if $cgi->param('save'); + + my $auto = 0; + $auto = 1 if $cgi->param('auto'); + + $cgi->param('paybatch') =~ /^([\w\-\.]+)$/ or die "illegal paybatch"; + my $patbatch = $1; + + process_payment( + 'session_id' => $session_id, + 'amount' => $amount, + 'payinfo' => $payinfo, + 'month' => $month, + 'year' => $year, + 'payname' => $payname, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'state' => $state, + 'zip' => $zip, + 'save' => $save, + 'auto' => $auto, + 'paybatch' => $paybatch, + ); + +} + #-- sub do_template { -- cgit v1.2.1 From a1295d0682aa81a408abe06fcaa7c14440f6a2e2 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 19 May 2003 13:38:41 +0000 Subject: first crack at payment processing with self-service (step two of the process) --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 4 ++-- fs_selfservice/FS-SelfService/cgi/process_payment.html | 18 ++++++++++++++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 4 +++- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/process_payment.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index 6adc0bde0..fdb411b11 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -31,7 +31,7 @@ @@ -104,7 +104,7 @@ - NAME="auto" VALUE="1"> + NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> Charge future payments to this card automatically diff --git a/fs_selfservice/FS-SelfService/cgi/process_payment.html b/fs_selfservice/FS-SelfService/cgi/process_payment.html new file mode 100644 index 000000000..e4946dc8f --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_payment.html @@ -0,0 +1,18 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+MyAccount
+ +
+Payment results

+<%= if ( $error ) { + $OUT .= qq!Error processing your payment: $error +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 2ce2c8b6c..d43df4041 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -96,6 +96,8 @@ sub make_payment { sub process_payment { + use Business::CreditCard; + $cgi->param('amount') =~ /^\s*(\d+(\.\d{2})?)\s*$/ or die "illegal amount"; #!!! my $amount = $1; @@ -143,7 +145,7 @@ sub process_payment { $auto = 1 if $cgi->param('auto'); $cgi->param('paybatch') =~ /^([\w\-\.]+)$/ or die "illegal paybatch"; - my $patbatch = $1; + my $paybatch = $1; process_payment( 'session_id' => $session_id, -- cgit v1.2.1 From e2a51e422dbd070a4571f229f8e5c6929950d137 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 19 May 2003 13:54:55 +0000 Subject: fix up some bugs in processing payments via self-service... appears to be working so far --- fs_selfservice/FS-SelfService/SelfService.pm | 17 +++++++++-------- fs_selfservice/FS-SelfService/cgi/make_payment.html | 4 ++-- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 7 ++++--- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index c561dabdb..5849b28d1 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -16,14 +16,15 @@ $VERSION = '0.03'; $socket = "/usr/local/freeside/selfservice_socket"; %autoload = ( - 'passwd' => 'passwd/passwd', - 'chfn' => 'passwd/passwd', - 'chsh' => 'passwd/passwd', - 'login' => 'MyAccount/login', - 'customer_info' => 'MyAccount/customer_info', - 'invoice' => 'MyAccount/invoice', - 'cancel' => 'MyAccount/cancel', - 'payment_info' => 'MyAccount/payment_info', + 'passwd' => 'passwd/passwd', + 'chfn' => 'passwd/passwd', + 'chsh' => 'passwd/passwd', + 'login' => 'MyAccount/login', + 'customer_info' => 'MyAccount/customer_info', + 'invoice' => 'MyAccount/invoice', + 'cancel' => 'MyAccount/cancel', + 'payment_info' => 'MyAccount/payment_info', + 'process_payment' => 'MyAccount/process_payment', ); @EXPORT_OK = keys %autoload; diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index fdb411b11..1d860f08a 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -8,7 +8,7 @@ Make a payment

- + @@ -110,7 +110,7 @@
Amount Due

- +
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index d43df4041..456d2dde2 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -6,7 +6,8 @@ use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Template; -use FS::SelfService qw(login customer_info invoice payment_info); +use FS::SelfService qw( login customer_info invoice payment_info + process_payment ); $template_dir = '.'; @@ -54,7 +55,7 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|process_payment)$/ + /^(myaccount|view_invoice|make_payment|do_payment)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -94,7 +95,7 @@ sub make_payment { payment_info( 'session_id' => $session_id ); } -sub process_payment { +sub do_payment { use Business::CreditCard; -- cgit v1.2.1 From e354694764fb1442b6bc74a63189f094c51f1a89 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 May 2003 05:43:47 +0000 Subject: working self-service self-payments! --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 2 +- fs_selfservice/FS-SelfService/cgi/payment_results.html | 18 ++++++++++++++++++ fs_selfservice/FS-SelfService/cgi/process_payment.html | 18 ------------------ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/payment_results.html delete mode 100644 fs_selfservice/FS-SelfService/cgi/process_payment.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index 1d860f08a..a1cda6d49 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -8,7 +8,7 @@ Make a payment

- + diff --git a/fs_selfservice/FS-SelfService/cgi/payment_results.html b/fs_selfservice/FS-SelfService/cgi/payment_results.html new file mode 100644 index 000000000..92c8cf51b --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/payment_results.html @@ -0,0 +1,18 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
Amount Due
+MyAccount
+ +
+Payment results

+<%= if ( $error ) { + $OUT .= qq!Error processing your payment: $error!; +} else { + $OUT .= 'Your payment was processed sucessfully. Thank you.'; +} %> +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/process_payment.html b/fs_selfservice/FS-SelfService/cgi/process_payment.html deleted file mode 100644 index e4946dc8f..000000000 --- a/fs_selfservice/FS-SelfService/cgi/process_payment.html +++ /dev/null @@ -1,18 +0,0 @@ -MyAccount -MyAccount

-<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
-Payment results

-<%= if ( $error ) { - $OUT .= qq!Error processing your payment: $error -
-
-powered by freeside - - diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 456d2dde2..6d6716ddc 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -55,7 +55,7 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|do_payment)$/ + /^(myaccount|view_invoice|make_payment|payment_results)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -95,7 +95,7 @@ sub make_payment { payment_info( 'session_id' => $session_id ); } -sub do_payment { +sub payment_results { use Business::CreditCard; -- cgit v1.2.1 From 7c5ac7082001b4aee97e0cdde41e492869b9fbaa Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 19 Sep 2003 11:35:57 +0000 Subject: finish moving signup server functions to self-service interace --- fs_selfservice/FS-SelfService/SelfService.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 5849b28d1..5d3f50b10 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -15,6 +15,7 @@ $VERSION = '0.03'; $socket = "/usr/local/freeside/selfservice_socket"; +#maybe should ask ClientAPI for this list %autoload = ( 'passwd' => 'passwd/passwd', 'chfn' => 'passwd/passwd', @@ -25,6 +26,8 @@ $socket = "/usr/local/freeside/selfservice_socket"; 'cancel' => 'MyAccount/cancel', 'payment_info' => 'MyAccount/payment_info', 'process_payment' => 'MyAccount/process_payment', + 'signup_info' => 'Signup/signup_info', + 'new_customer' => 'Signup/new_customer', ); @EXPORT_OK = keys %autoload; -- cgit v1.2.1 From 9679b64218a5bb0b148d07582589dd8ef0de7567 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 25 Sep 2003 10:28:13 +0000 Subject: freebsd portability fix --- .../FS-SelfService/freeside-selfservice-clientd | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index f13dd42d7..438d472c9 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -5,7 +5,7 @@ # This is run REMOTELY over ssh by freeside-selfservice-server use strict; -use subs qw(spawn logmsg); +use subs qw(spawn logmsg lock_write unlock_write); use Fcntl qw(:flock); use POSIX qw(:sys_wait_h); use Socket; @@ -25,6 +25,8 @@ my $pid_file = "$socket.pid"; my $log_file = "/usr/local/freeside/selfservice.log"; +my $lock_file = "/usr/local/freeside/selfservice.writelock"; + #my $me = '[client]'; $|=1; @@ -35,6 +37,9 @@ $SIG{__WARN__} = \&_logmsg; #warn "$me Reading init data\n" if $Debug; #my $signup_init = +warn "Creating $lock_file\n" if $Debug; +open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!"; + warn "Creating $socket\n" if $Debug; my $uaddr = sockaddr_un($socket); my $proto = getprotobyname('tcp'); @@ -138,11 +143,19 @@ while (1) { #handle some commands weirdly? $packet->{_token}=$$; + warn "[child-$$] locking write stream" if $Debug > 1; + lock_write; + warn "[child-$$] sending packet to remote server" if $Debug > 1; - flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!"; nstore_fd($packet, \*STDOUT) or die "FATAL: can't send response: $!"; + + warn "[child-$$] flushing write stream" if $Debug > 1; STDOUT->flush or die "FATAL: can't flush: $!"; - flock(STDOUT, LOCK_UN) or die "FATAL: can't release write lock: $!"; + + warn "[child-$$] releasing write lock" if $Debug > 1; + unlock_write; + + warn "[child-$$] closing write stream" if $Debug > 1; close STDOUT or die "FATAL: can't close write stream: $!"; #??! warn "[child-$$] waiting for response from parent" if $Debug > 1; @@ -224,3 +237,17 @@ sub _logmsg { flock($log, LOCK_UN); close $log; } + +sub lock_write { + #broken on freebsd? + #flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!"; + + flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!"; +} + +sub unlock_write { + #broken on freebsd? + #flock(STDOUT, LOCK_UN) or die "FATAL: can't release write lock: $!"; + + flock(LOCKFILE, LOCK_UN) or die "FATAL: can't unlock $lock_file: $!"; +} -- cgit v1.2.1 From d8ea8ef98411f56069ff4036bd5a2403b456655b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Oct 2003 11:23:04 +0000 Subject: removing testing info --- fs_selfservice/FS-SelfService/cgi/login.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html index ca6251eb1..5607de783 100644 --- a/fs_selfservice/FS-SelfService/cgi/login.html +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -7,23 +7,20 @@ Username - - + Domain - - + Password - - + -- cgit v1.2.1 From 98527623b1fea1107b2c0422a0838b4602c21fa9 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Oct 2003 12:42:23 +0000 Subject: update Makefile.PL dependancies (PREREQ_PM) for self-service module and signup wrapper --- fs_selfservice/FS-SelfService/Makefile.PL | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/Makefile.PL b/fs_selfservice/FS-SelfService/Makefile.PL index da0a0aa24..e5cbd1aef 100644 --- a/fs_selfservice/FS-SelfService/Makefile.PL +++ b/fs_selfservice/FS-SelfService/Makefile.PL @@ -8,7 +8,9 @@ WriteMakefile( 'INSTALLSCRIPT' => '/usr/local/sbin', 'INSTALLSITEBIN' => '/usr/local/sbin', 'PERM_RWX' => '750', - 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 + 'PREREQ_PM' => { + 'Storable' => 0, + }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'SelfService.pm', # retrieve abstract from module AUTHOR => 'Ivan Kohler ') : ()), -- cgit v1.2.1 From 2563e2d621c76a1fe9987e99e68fbe33e3f7aa7e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Oct 2003 13:08:58 +0000 Subject: turn off super-verbose logging --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 438d472c9..45d9da9c7 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -17,7 +17,7 @@ use IO::File; #STDOUT->setbuf(''); use vars qw( $Debug ); -$Debug = 3; #2 will turn on child logging, 3 will log packet contents, +$Debug = 2; #2 will turn on child logging, 3 will log packet contents, #including potentially compromising information my $socket = "/usr/local/freeside/selfservice_socket"; -- cgit v1.2.1 From bacea004a735c7a9c30a35e9184a63897a200e6e Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 15 Oct 2003 15:03:56 +0000 Subject: add tagging ability so we can run multiple self-service clients on one machine --- fs_selfservice/FS-SelfService/SelfService.pm | 3 ++- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 5d3f50b10..b2532be71 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1,7 +1,7 @@ package FS::SelfService; use strict; -use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload ); +use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload $tag); use Exporter; use Socket; use FileHandle; @@ -14,6 +14,7 @@ $VERSION = '0.03'; @ISA = qw( Exporter ); $socket = "/usr/local/freeside/selfservice_socket"; +$socket .= '.'.$tag if defined $tag && length($tag); #maybe should ask ClientAPI for this list %autoload = ( diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 45d9da9c7..a8b1e713b 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -16,16 +16,18 @@ use IO::File; #STDOUT->setbuf(''); +my $tag = scalar(@ARGV) ? '.'.shift : ''; + use vars qw( $Debug ); $Debug = 2; #2 will turn on child logging, 3 will log packet contents, #including potentially compromising information -my $socket = "/usr/local/freeside/selfservice_socket"; +my $socket = "/usr/local/freeside/selfservice_socket$tag"; my $pid_file = "$socket.pid"; -my $log_file = "/usr/local/freeside/selfservice.log"; +my $log_file = "/usr/local/freeside/selfservice$tag.log"; -my $lock_file = "/usr/local/freeside/selfservice.writelock"; +my $lock_file = "/usr/local/freeside/selfservice$tag.writelock"; #my $me = '[client]'; -- cgit v1.2.1 From 8bf0686b09cde9eb2aa453420e3a7bcc4ada9f88 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 8 Nov 2003 16:31:49 +0000 Subject: documentation for self-service functions! --- fs_selfservice/FS-SelfService/SelfService.pm | 559 +++++++++++++++++++++++++-- 1 file changed, 536 insertions(+), 23 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index b2532be71..be6dd3a8a 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -27,6 +27,9 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'cancel' => 'MyAccount/cancel', 'payment_info' => 'MyAccount/payment_info', 'process_payment' => 'MyAccount/process_payment', + 'list_pkgs' => 'MyAccount/list_pkgs', + 'order_pkg' => 'MyAccount/order_pkg', + 'cancel_pkg' => 'MyAccount/cancel_pkg', 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', ); @@ -42,29 +45,6 @@ $ENV{'BASH_ENV'} = ''; my $freeside_uid = scalar(getpwnam('freeside')); die "not running as the freeside user\n" if $> != $freeside_uid; -=head1 NAME - -FS::SelfService - Freeside self-service API - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -Use this API to implement your own client "self-service" module. - -If you just want to customize the look of the existing "self-service" module, -see XXXX instead. - -=head1 FUNCTIONS - -=over 4 - -=item passwd - -Returns the empty value on success, or an error message on errors. - -=cut - foreach my $autoload ( keys %autoload ) { my $eval = @@ -105,6 +85,539 @@ sub simple_packet { $return; } +=head1 NAME + +FS::SelfService - Freeside self-service API + +=head1 SYNOPSIS + + # password and shell account changes + use FS::SelfService qw(passwd chfn chsh); + + # "my account" functionality + use FS::SelfService qw( login customer_info invoice cancel payment_info process_payment ); + + my $rv = login( { 'username' => $username, + 'domain' => $domain, + 'password' => $password, + } + ); + + if ( $rv->{'error'} ) { + #handle login error... + } else { + #successful login + my $session_id = $rv->{'session_id'}; + } + + my $customer_info = customer_info( { 'session_id' => $session_id } ); + + #payment_info and process_payment are available in 1.5+ only + my $payment_info = payment_info) { 'session_id' => $session_id } ); + + #!!! process_payment example + + #!!! list_pkgs example + + #!!! order_pkg example + + #!!! cancel_pkg example + + # signup functionality + use FS::SelfService qw( signup_info new_customer ); + + my $signup_info = signup_info; + + $rv = new_customer( { + 'first' => $first, + 'last' => $last, + 'company' => $company, + 'address1' => $address1, + 'address2' => $address2, + 'city' => $city, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + 'daytime' => $daytime, + 'night' => $night, + 'fax' => $fax, + 'payby' => $payby, + 'payinfo' => $payinfo, + 'paycvv' => $paycvv, + 'paydate' => $paydate, + 'payname' => $payname, + 'invoicing_list' => $invoicing_list, + 'referral_custnum' => $referral_custnum, + 'pkgpart' => $pkgpart, + 'username' => $username, + '_password' => $password, + 'popnum' => $popnum, + 'agentnum' => $agentnum, + } + ); + + my $error = $rv->{'error'}; + if ( $error eq '_decline' ) { + print_decline(); + } elsif ( $error ) { + reprint_signup(); + } else { + print_success(); + } + +=head1 DESCRIPTION + +Use this API to implement your own client "self-service" module. + +If you just want to customize the look of the existing "self-service" module, +see XXXX instead. + +=head1 PASSWORD, GECOS, SHELL CHANGING FUNCTIONS + +=over 4 + +=item passwd + +=item chfn + +=item chsh + +=back + +=head1 "MY ACCOUNT" FUNCTIONS + +=over 4 + +=item login HASHREF + +Creates a user session. Takes a hash reference as parameter with the +following keys: + +=over 4 + +=item username + +=item domain + +=item password + +=back + +Returns a hash reference with the following keys: + +=over 4 + +=item error + +Empty on success, or an error message on errors. + +=item session_id + +Session identifier for successful logins + +=back + +=item customer_info HASHREF + +Returns general customer information. + +Takes a hash reference as parameter with a single key: B + +Returns a hash reference with the following keys: + +=over 4 + +=item name + +Customer name + +=item balance + +Balance owed + +=item open + +Array reference of hash references of open inoices. Each hash reference has +the following keys: invnum, date, owed + +=item small_custview + +An HTML fragment containing shipping and billing addresses. + +=back + +=item invoice HASHREF + +Returns an invoice. Takes a hash reference as parameter with two keys: +session_id and invnum + +Returns a hash reference with the following keys: + +=over 4 + +=item error + +Empty on success, or an error message on errors + +=item invnum + +Invoice number + +=item invoice_text + +Invoice text + +=back + +=item cancel HASHREF + +Cancels this customer. + +Takes a hash reference as parameter with a single key: B + +Returns a hash reference with a single key, B, which is empty on +success or an error message on errors. + +=item payment_info HASHREF + +Returns information that may be useful in displaying a payment page. + +Takes a hash reference as parameter with a single key: B. + +Returns a hash reference with the following keys: + +=over 4 + +=item error + +Empty on success, or an error message on errors + +=item balance + +Balance owed + +=item payname + +Exact name on credit card (CARD/DCRD) + +=item address1 + +=item address2 + +=item city + +=item state + +=item zip + +=item payby + +Customer's current default payment type. + +=item card_type + +For CARD/DCRD payment types, the card type (Visa card, MasterCard, Discover card, American Express card, etc.) + +=item payinfo + +For CARD/DCRD payment types, the card number + +=item month + +For CARD/DCRD payment types, expiration month + +=item year + +For CARD/DCRD payment types, expiration year + +=item cust_main_county + +County/state/country data - array reference of hash references, each of which has the fields of a cust_main_county record (see L). Note these are not FS::cust_main_county objects, but hash references of columns and values. + +=item states + +Array reference of all states in the current default country. + +=item card_types + +Hash reference of card types; keys are card types, values are the exact strings +passed to the process_payment function + +=item paybatch + +Unique transaction identifier (prevents multiple charges), passed to the +process_payment function + +=back + +=item process_payment HASHREF + +Processes a payment and possible change of address or payment type. Takes a +hash reference as parameter with the following keys: + +=over 4 + +=item session_id + +=item save + +If true, address and card information entered will be saved for subsequent +transactions. + +=item auto + +If true, future credit card payments will be done automatically (sets payby to +CARD). If false, future credit card payments will be done on-demand (sets +payby to DCRD). This option only has meaning if B is set true. + +=item payname + +=item address1 + +=item address2 + +=item city + +=item state + +=item zip + +=item payinfo + +Card number + +=item month + +Card expiration month + +=item year + +Card expiration year + +=item paybatch + +Unique transaction identifier, returned from the payment_info function. +Prevents multiple charges. + +=back + +Returns a hash reference with a single key, B, empty on success, or an +error message on errors + +=item list_pkgs + +Returns package information for this customer. + +Takes a hash reference as parameter with a single key: B + +Returns a hash reference containing customer package information. The hash reference contains the following keys: + +=over 4 + +=item cust_pkg HASHREF + +Array reference of hash references, each of which has the fields of a cust_pkg record (see L). Note these are not FS::cust_pkg objects, but hash references of columns and values. + +=back + +=item order_pkg + +Orders a package for this customer. + +Takes a hash reference as parameter with the following keys: + +=over 4 + +=item session_id + +=item pkgpart + +=item svcpart + +optional svcpart, required only if the package definition does not contain +one svc_acct service definition with quantity 1 (it may contain others with +quantity >1) + +=item username + +=item _password + +=item sec_phrase + +=item popnum + +=back + +Returns a hash reference with a single key, B, empty on success, or an +error message on errors. The special error '_decline' is returned for +declined transactions. + +=item cancel_pkg + +Cancels a package for this customer. + +Takes a hash reference as parameter with the following keys: + +=over 4 + +=item session_id + +=item pkgpart + +=back + +Returns a hash reference with a single key, B, empty on success, or an +error message on errors. + +=back + +=head1 SIGNUP FUNCTIONS + +=over 4 + +=item signup_info + +Returns a hash reference containing information that may be useful in +displaying a signup page. The hash reference contains the following keys: + +=over 4 + +=item cust_main_county + +County/state/country data - array reference of hash references, each of which has the fields of a cust_main_county record (see L). Note these are not FS::cust_main_county objects, but hash references of columns and values. + +=item part_pkg + +Available packages - array reference of hash references, each of which has the fields of a part_pkg record (see L). Each hash reference also has an additional 'payby' field containing an array reference of acceptable payment types specific to this package (see below and L). Note these are not FS::part_pkg objects, but hash references of columns and values. Requires the 'signup_server-default_agentnum' configuration value to be set. + +=item agent + +Array reference of hash references, each of which has the fields of an agent record (see L). Note these are not FS::agent objects, but hash references of columns and values. + +=item agentnum2part_pkg + +Hash reference; keys are agentnums, values are array references of available packages for that agent, in the same format as the part_pkg arrayref above. + +=item svc_acct_pop + +Access numbers - array reference of hash references, each of which has the fields of an svc_acct_pop record (see L). Note these are not FS::svc_acct_pop objects, but hash references of columns and values. + +=item security_phrase + +True if the "security_phrase" feature is enabled + +=item payby + +Array reference of acceptable payment types for signup + +=over 4 + +=item CARD (credit card - automatic) + +=item DCRD (credit card - on-demand - version 1.5+ only) + +=item CHEK (electronic check - automatic) + +=item DCHK (electronic check - on-demand - version 1.5+ only) + +=item LECB (Phone bill billing) + +=item BILL (billing, not recommended for signups) + +=item COMP (free, definately not recommended for signups) + +=item PREPAY (special billing type: applies a credit (see FS::prepay_credit) and sets billing type to BILL) + +=back + +=item cvv_enabled + +True if CVV features are available (1.5+ or 1.4.2 with CVV schema patch) + +=item msgcat + +Hash reference of message catalog values, to support error message customization. Currently available keys are: passwords_dont_match, invalid_card, unknown_card_type, and not_a (as in "Not a Discover card"). Values are configured in the web interface under "View/Edit message catalog". + +=item statedefault + +Default state + +=item countrydefault + +Default country + +=back + +=item new_customer HASHREF + +Creates a new customer. Takes a hash reference as parameter with the +following keys: + +=over 4 + +=item first - first name (required) + +=item last - last name (required) + +=item ss (not typically collected; mostly used for ACH transactions) + +=item company + +=item address1 (required) + +=item address2 + +=item city (required) + +=item county + +=item state (required) + +=item zip (required) + +=item daytime - phone + +=item night - phone + +=item fax - phone + +=item payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, COMP or PREPAY (see L (required) + +=item payinfo - Card number for CARD/DCRD, account_number@aba_number for CHEK/DCHK, prepaid "pin" for PREPAY, purchase order number for BILL + +=item paycvv - Credit card CVV2 number (1.5+ or 1.4.2 with CVV schema patch) + +=item paydate - Expiration date for CARD/DCRD + +=item payname - Exact name on credit card for CARD/DCRD, bank name for CHEK/DCHK + +=item invoicing_list - comma-separated list of email addresses for email invoices. The special value 'POST' is used to designate postal invoicing (it may be specified alone or in addition to email addresses), + +=item referral_custnum - referring customer number + +=item pkgpart - pkgpart of initial package + +=item username + +=item _password + +=item sec_phrase - security phrase + +=item popnum - access number (index, not the literal number) + +=item agentnum - agent number + +=back + +Returns a hash reference with the following keys: + +=over 4 + +=item error Empty on success, or an error message on errors. The special error '_decline' is returned for declined transactions; other error messages should be suitable for display to the user (and are customizable in under Sysadmin | View/Edit message catalog) + +=back + + =back =head1 BUGS -- cgit v1.2.1 From 3631b278f61e0dd08026f7a21ac2d24964f1ea99 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 15 Nov 2003 07:18:39 +0000 Subject: add trailing newline to supress useless error messages in log --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index a8b1e713b..925bce6d2 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -145,22 +145,22 @@ while (1) { #handle some commands weirdly? $packet->{_token}=$$; - warn "[child-$$] locking write stream" if $Debug > 1; + warn "[child-$$] locking write stream\n" if $Debug > 1; lock_write; - warn "[child-$$] sending packet to remote server" if $Debug > 1; + warn "[child-$$] sending packet to remote server\n" if $Debug > 1; nstore_fd($packet, \*STDOUT) or die "FATAL: can't send response: $!"; - warn "[child-$$] flushing write stream" if $Debug > 1; + warn "[child-$$] flushing write stream\n" if $Debug > 1; STDOUT->flush or die "FATAL: can't flush: $!"; - warn "[child-$$] releasing write lock" if $Debug > 1; + warn "[child-$$] releasing write lock\n" if $Debug > 1; unlock_write; - warn "[child-$$] closing write stream" if $Debug > 1; + warn "[child-$$] closing write stream\n" if $Debug > 1; close STDOUT or die "FATAL: can't close write stream: $!"; #??! - warn "[child-$$] waiting for response from parent" if $Debug > 1; + warn "[child-$$] waiting for response from parent\n" if $Debug > 1; my $w = new IO::Select; $w->add(\*STDIN); until ( $w->can_read ) { -- cgit v1.2.1 From 38d7ed9d33840a59bbbf6895e3c7a6d191094c03 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 00:51:37 +0000 Subject: add edit_info to selfservice API --- fs_selfservice/FS-SelfService/SelfService.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index be6dd3a8a..715f935f3 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -23,6 +23,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'chsh' => 'passwd/passwd', 'login' => 'MyAccount/login', 'customer_info' => 'MyAccount/customer_info', + 'edit_info' => 'MyAccount/edit_info', 'invoice' => 'MyAccount/invoice', 'cancel' => 'MyAccount/cancel', 'payment_info' => 'MyAccount/payment_info', @@ -113,7 +114,7 @@ FS::SelfService - Freeside self-service API my $customer_info = customer_info( { 'session_id' => $session_id } ); #payment_info and process_payment are available in 1.5+ only - my $payment_info = payment_info) { 'session_id' => $session_id } ); + my $payment_info = payment_info( { 'session_id' => $session_id } ); #!!! process_payment example @@ -244,8 +245,23 @@ the following keys: invnum, date, owed An HTML fragment containing shipping and billing addresses. +=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax + =back +=item edit_info HASHREF + +Takes a hash reference as parameter with any of the following keys: + +first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax + +If a field exists, the customer record is updated with the new value of that +field. If a field does not exist, that field is not changed on the customer +record. + +Returns a hash reference with a single key, B, empty on success, or an +error message on errors + =item invoice HASHREF Returns an invoice. Takes a hash reference as parameter with two keys: -- cgit v1.2.1 From cccf2f33d38b693c2742b5806e32d892d31b4374 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 01:46:40 +0000 Subject: require Storable minimum 2.09 --- fs_selfservice/FS-SelfService/SelfService.pm | 3 ++- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 715f935f3..7cbf5ecad 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -7,7 +7,7 @@ use Socket; use FileHandle; #use IO::Handle; use IO::Select; -use Storable qw(nstore_fd fd_retrieve); +use Storable 2.09 qw(nstore_fd fd_retrieve); $VERSION = '0.03'; @@ -31,6 +31,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'list_pkgs' => 'MyAccount/list_pkgs', 'order_pkg' => 'MyAccount/order_pkg', 'cancel_pkg' => 'MyAccount/cancel_pkg', + 'charge' => 'MyAccount/charge', 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', ); diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 925bce6d2..ce9e14d35 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -9,7 +9,7 @@ use subs qw(spawn logmsg lock_write unlock_write); use Fcntl qw(:flock); use POSIX qw(:sys_wait_h); use Socket; -use Storable qw(nstore_fd fd_retrieve); +use Storable 2.09 qw(nstore_fd fd_retrieve); use IO::Handle qw(_IONBF); use IO::Select; use IO::File; @@ -233,6 +233,7 @@ sub spawn { sub _logmsg { chomp( my $msg = shift ); my $log = new IO::File ">>$log_file"; + die "can't open $log_file: $!" unless defined($log); flock($log, LOCK_EX); seek($log, 0, 2); print $log "[client] [". scalar(localtime). "] [$$] $msg\n"; -- cgit v1.2.1 From 0147f0917ebbff5f72f43db0f81f13a87d7cf626 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Mar 2004 12:50:07 +0000 Subject: credit card expiration selection now -> 15 years instead of hardcoded --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index a1cda6d49..40cd83c6f 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -53,7 +53,7 @@ / -- cgit v1.2.1 From 6004e9f3ed07a72f6a4c0f24e326b89acc859a45 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 26 Mar 2004 04:54:47 +0000 Subject: depend on Storable 2.09 --- fs_selfservice/FS-SelfService/Makefile.PL | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/Makefile.PL b/fs_selfservice/FS-SelfService/Makefile.PL index e5cbd1aef..a14580eb2 100644 --- a/fs_selfservice/FS-SelfService/Makefile.PL +++ b/fs_selfservice/FS-SelfService/Makefile.PL @@ -4,12 +4,14 @@ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'FS::SelfService', 'VERSION_FROM' => 'SelfService.pm', # finds $VERSION - 'EXE_FILES' => [ 'freeside-selfservice-clientd' ], + 'EXE_FILES' => [ 'freeside-selfservice-clientd', + 'freeside-selfservice-xmlrpc-server', + ], 'INSTALLSCRIPT' => '/usr/local/sbin', 'INSTALLSITEBIN' => '/usr/local/sbin', 'PERM_RWX' => '750', 'PREREQ_PM' => { - 'Storable' => 0, + 'Storable' => 2.09, }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'SelfService.pm', # retrieve abstract from module -- cgit v1.2.1 From 60083c565ce36609c46bbe935ecc31ca97a59210 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 Apr 2004 05:53:06 +0000 Subject: comment out xmlrpc server until it is ready --- fs_selfservice/FS-SelfService/Makefile.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/Makefile.PL b/fs_selfservice/FS-SelfService/Makefile.PL index a14580eb2..0b7fc4606 100644 --- a/fs_selfservice/FS-SelfService/Makefile.PL +++ b/fs_selfservice/FS-SelfService/Makefile.PL @@ -5,7 +5,7 @@ WriteMakefile( 'NAME' => 'FS::SelfService', 'VERSION_FROM' => 'SelfService.pm', # finds $VERSION 'EXE_FILES' => [ 'freeside-selfservice-clientd', - 'freeside-selfservice-xmlrpc-server', + #'freeside-selfservice-xmlrpc-server', ], 'INSTALLSCRIPT' => '/usr/local/sbin', 'INSTALLSITEBIN' => '/usr/local/sbin', -- cgit v1.2.1 From d01dbb663c0d58ed4294c9284106a0e46f274301 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Apr 2004 00:58:04 +0000 Subject: add methods for masking credit cards, add payment info modification to self-service --- fs_selfservice/FS-SelfService/SelfService.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 7cbf5ecad..920415e30 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -246,7 +246,7 @@ the following keys: invnum, date, owed An HTML fragment containing shipping and billing addresses. -=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax +=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax payby payinfo payname month year invoicing_list postal_invoicing =back @@ -254,7 +254,7 @@ An HTML fragment containing shipping and billing addresses. Takes a hash reference as parameter with any of the following keys: -first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax +first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax payby payinfo paycvv payname month year invoicing_list postal_invoicing If a field exists, the customer record is updated with the new value of that field. If a field does not exist, that field is not changed on the customer -- cgit v1.2.1 From 7bcf2e6107458e1e784cda9500c007af32bb5505 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Jun 2004 21:27:04 +0000 Subject: simple kludge for testing --- fs_selfservice/DEPLOY | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY index 4aef4cfa4..7420df778 100755 --- a/fs_selfservice/DEPLOY +++ b/fs_selfservice/DEPLOY @@ -8,6 +8,13 @@ cd FS-SelfService perl Makefile.PL && make && make install cp /home/ivan/freeside/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount -chown freeside /var/www/MyAccount/selfservice.cgi -chmod 755 /var/www/MyAccount/selfservice.cgi +chown freeside /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/agent.cgi +chmod 755 /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/agent.cgi ln -s /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/index.cgi || true + +cp /home/ivan/freeside/fs_signup/FS-SignupClient/cgi/* /var/www/signup/ +#mv /var/www/signup/signup-snarf.html /var/www/signup/signup.html #!!!!! +chown freeside /var/www/signup/signup.cgi +chmod 755 /var/www/signup/signup.cgi +ln -s /var/www/signup/signup.cgi /var/www/signup/index.cgi || true + -- cgit v1.2.1 From 3913f6d159b5b8110061690b7c97642c27abf7eb Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 10 Jun 2004 12:31:32 +0000 Subject: agent interface --- fs_selfservice/FS-SelfService/SelfService.pm | 446 ++++++++++++++++++++- fs_selfservice/FS-SelfService/cgi/agent.cgi | 256 ++++++++++++ fs_selfservice/FS-SelfService/cgi/agent_login.html | 22 + fs_selfservice/FS-SelfService/cgi/agent_main.html | 40 ++ fs_selfservice/FS-SelfService/cgi/cvv2.html | 25 ++ fs_selfservice/FS-SelfService/cgi/cvv2.png | Bin 0 -> 3854 bytes fs_selfservice/FS-SelfService/cgi/cvv2_amex.png | Bin 0 -> 4573 bytes .../FS-SelfService/cgi/list_customers.html | 41 ++ fs_selfservice/FS-SelfService/cgi/signup.html | 233 +++++++++++ .../FS-SelfService/cgi/view_customer.html | 84 ++++ 10 files changed, 1128 insertions(+), 19 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/agent.cgi create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_login.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_main.html create mode 100644 fs_selfservice/FS-SelfService/cgi/cvv2.html create mode 100644 fs_selfservice/FS-SelfService/cgi/cvv2.png create mode 100644 fs_selfservice/FS-SelfService/cgi/cvv2_amex.png create mode 100644 fs_selfservice/FS-SelfService/cgi/list_customers.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup.html create mode 100644 fs_selfservice/FS-SelfService/cgi/view_customer.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 920415e30..2cda9fe2d 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -18,24 +18,28 @@ $socket .= '.'.$tag if defined $tag && length($tag); #maybe should ask ClientAPI for this list %autoload = ( - 'passwd' => 'passwd/passwd', - 'chfn' => 'passwd/passwd', - 'chsh' => 'passwd/passwd', - 'login' => 'MyAccount/login', - 'customer_info' => 'MyAccount/customer_info', - 'edit_info' => 'MyAccount/edit_info', - 'invoice' => 'MyAccount/invoice', - 'cancel' => 'MyAccount/cancel', - 'payment_info' => 'MyAccount/payment_info', - 'process_payment' => 'MyAccount/process_payment', - 'list_pkgs' => 'MyAccount/list_pkgs', - 'order_pkg' => 'MyAccount/order_pkg', - 'cancel_pkg' => 'MyAccount/cancel_pkg', - 'charge' => 'MyAccount/charge', - 'signup_info' => 'Signup/signup_info', - 'new_customer' => 'Signup/new_customer', + 'passwd' => 'passwd/passwd', + 'chfn' => 'passwd/passwd', + 'chsh' => 'passwd/passwd', + 'login' => 'MyAccount/login', + 'customer_info' => 'MyAccount/customer_info', + 'edit_info' => 'MyAccount/edit_info', + 'invoice' => 'MyAccount/invoice', + 'list_invoices' => 'MyAccount/list_invoices', + 'cancel' => 'MyAccount/cancel', + 'payment_info' => 'MyAccount/payment_info', + 'process_payment' => 'MyAccount/process_payment', + 'list_pkgs' => 'MyAccount/list_pkgs', + 'order_pkg' => 'MyAccount/order_pkg', + 'cancel_pkg' => 'MyAccount/cancel_pkg', + 'charge' => 'MyAccount/charge', + 'signup_info' => 'Signup/signup_info', + 'new_customer' => 'Signup/new_customer', + 'agent_login' => 'Agent/agent_login', + 'agent_info' => 'Agent/agent_info', + 'agent_list_customers' => 'Agent/agent_list_customers', ); -@EXPORT_OK = keys %autoload; +@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector ) ); $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; @@ -286,6 +290,37 @@ Invoice text =back +=item list_invoices HASHREF + +Returns a list of all customer invoices. Takes a hash references with a single +key, session_id. + +Returns a hash reference with the following keys: + +=over 4 + +=item error + +Empty on success, or an error message on errors + +=item invoices + +Reference to array of hash references with the following keys: + +=over 4 + +=item invnum + +Invoice ID + +=item _date + +Invoice date, in UNIX epoch time + +=back + +=back + =item cancel HASHREF Cancels this customer. @@ -492,7 +527,15 @@ error message on errors. =over 4 -=item signup_info +=item signup_info HASHREF + +Takes a hash reference as parameter with the following keys: + +=over 4 + +=item session_id - Optional agent/reseller interface session + +=back Returns a hash reference containing information that may be useful in displaying a signup page. The hash reference contains the following keys: @@ -505,7 +548,9 @@ County/state/country data - array reference of hash references, each of which ha =item part_pkg -Available packages - array reference of hash references, each of which has the fields of a part_pkg record (see L). Each hash reference also has an additional 'payby' field containing an array reference of acceptable payment types specific to this package (see below and L). Note these are not FS::part_pkg objects, but hash references of columns and values. Requires the 'signup_server-default_agentnum' configuration value to be set. +Available packages - array reference of hash references, each of which has the fields of a part_pkg record (see L). Each hash reference also has an additional 'payby' field containing an array reference of acceptable payment types specific to this package (see below and L). Note these are not FS::part_pkg objects, but hash references of columns and values. Requires the 'signup_server-default_agentnum' configuration value to be set, or +an agentnum specified explicitly via reseller interface session_id in the +options. =item agent @@ -634,6 +679,369 @@ Returns a hash reference with the following keys: =back +=item regionselector HASHREF | LIST + +Takes as input a hashref or list of key/value pairs with the following keys: + +=over 4 + +=item selected_county + +=item selected_state + +=item selected_country + +=item prefix - Specify a unique prefix string if you intend to use the HTML output multiple time son one page. + +=item onchange - Specify a javascript subroutine to call on changes + +=item default_state + +=item default_country + +=item locales - An arrayref of hash references specifying regions. Normally you can just pass the value of the I field returned by B. + +=back + +Returns a list consisting of three HTML fragments for county selection, +state selection and country selection, respectively. + +=cut + +#false laziness w/FS::cust_main_county (this is currently the "newest" version) +sub regionselector { + my $param; + if ( ref($_[0]) ) { + $param = shift; + } else { + $param = { @_ }; + } + $param->{'selected_country'} ||= $param->{'default_country'}; + $param->{'selected_state'} ||= $param->{'default_state'}; + + my $prefix = exists($param->{'prefix'}) ? $param->{'prefix'} : ''; + + my $countyflag = 0; + + my %cust_main_county; + +# unless ( @cust_main_county ) { #cache + #@cust_main_county = qsearch('cust_main_county', {} ); + #foreach my $c ( @cust_main_county ) { + foreach my $c ( @{ $param->{'locales'} } ) { + #$countyflag=1 if $c->county; + $countyflag=1 if $c->{county}; + #push @{$cust_main_county{$c->country}{$c->state}}, $c->county; + #$cust_main_county{$c->country}{$c->state}{$c->county} = 1; + $cust_main_county{$c->{country}}{$c->{state}}{$c->{county}} = 1; + } +# } + $countyflag=1 if $param->{selected_county}; + + my $script_html = < + function opt(what,value,text) { + var optionName = new Option(text, value, false, false); + var length = what.length; + what.options[length] = optionName; + } + function ${prefix}country_changed(what) { + country = what.options[what.selectedIndex].text; + for ( var i = what.form.${prefix}state.length; i >= 0; i-- ) + what.form.${prefix}state.options[i] = null; +END + #what.form.${prefix}state.options[0] = new Option('', '', false, true); + + foreach my $country ( sort keys %cust_main_county ) { + $script_html .= "\nif ( country == \"$country\" ) {\n"; + foreach my $state ( sort keys %{$cust_main_county{$country}} ) { + my $text = $state || '(n/a)'; + $script_html .= qq!opt(what.form.${prefix}state, "$state", "$text");\n!; + } + $script_html .= "}\n"; + } + + $script_html .= <= 0; i-- ) + what.form.${prefix}county.options[i] = null; +END + + foreach my $country ( sort keys %cust_main_county ) { + $script_html .= "\nif ( country == \"$country\" ) {\n"; + foreach my $state ( sort keys %{$cust_main_county{$country}} ) { + $script_html .= "\nif ( state == \"$state\" ) {\n"; + #foreach my $county ( sort @{$cust_main_county{$country}{$state}} ) { + foreach my $county ( sort keys %{$cust_main_county{$country}{$state}} ) { + my $text = $county || '(n/a)'; + $script_html .= + qq!opt(what.form.${prefix}county, "$county", "$text");\n!; + } + $script_html .= "}\n"; + } + $script_html .= "}\n"; + } + } + + $script_html .= < +END + + my $county_html = $script_html; + if ( $countyflag ) { + $county_html .= qq!'; + } else { + $county_html .= + qq!!; + } + + my $state_html = qq!'; + + $state_html .= ''; + + my $country_html = qq!'; + + ($county_html, $state_html, $country_html); + +} + +#=item expselect HASHREF | LIST +# +#Takes as input a hashref or list of key/value pairs with the following keys: +# +#=over 4 +# +#=item prefix - Specify a unique prefix string if you intend to use the HTML output multiple time son one page. +# +#=item date - current date, in yyyy-mm-dd or m-d-yyyy format +# +#=back + +=item expselect PREFIX [ DATE ] + +Takes as input a unique prefix string and the current expiration date, in +yyyy-mm-dd or m-d-yyyy format + +Returns an HTML fragments for expiration date selection. + +=cut + +sub expselect { + #my $param; + #if ( ref($_[0]) ) { + # $param = shift; + #} else { + # $param = { @_ }; + #my $prefix = $param->{'prefix'}; + #my $prefix = exists($param->{'prefix'}) ? $param->{'prefix'} : ''; + #my $date = exists($param->{'date'}) ? $param->{'date'} : ''; + my $prefix = shift; + my $date = scalar(@_) ? 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!!; + my @t = localtime; + my $thisYear = $t[5] + 1900; + for ( ($thisYear > $y && $y > 0 ? $y : $thisYear) .. 2037 ) { + $return .= " field returned by B. + +=back + +Returns an HTML fragment for access number selection. + +=cut + +#horrible false laziness with FS/FS/svc_acct_pop.pm::popselector +sub popselector { + my $param; + if ( ref($_[0]) ) { + $param = shift; + } else { + $param = { @_ }; + } + my $popnum = $param->{'popnum'}; + my $pops = $param->{'pops'}; + + return '' unless @$pops; + return $pops->[0]{city}. ', '. $pops->[0]{state}. + ' ('. $pops->[0]{ac}. ')/'. $pops->[0]{exch}. '-'. $pops->[0]{loc}. + '' + if scalar(@$pops) == 1; + + my %pop = (); + my %popnum2pop = (); + foreach (@$pops) { + push @{ $pop{ $_->{state} }->{ $_->{ac} } }, $_; + $popnum2pop{$_->{popnum}} = $_; + } + + my $text = < + function opt(what,href,text) { + var optionName = new Option(text, href, false, false) + var length = what.length; + what.options[length] = optionName; + } +END + + my $init_popstate = $param->{'init_popstate'}; + if ( $init_popstate ) { + $text .= ''; + } else { + $text .= <{'popac'}) { + $text .= "what.form.popac.options[what.form.popac.length-1].selected = true;\n"; + } + } + $text .= "}\n" unless $init_popstate; + } + $text .= "popac_changed(what.form.popac)}\n"; + + $text .= <{$popac}}) { + my $o_popnum = $pop->{popnum}; + my $poptext = $pop->{city}. ', '. $pop->{state}. + ' ('. $pop->{ac}. ')/'. $pop->{exch}. '-'. $pop->{loc}; + + $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"; + if ($popnum == $o_popnum) { + $text .= "what.form.popnum.options[what.form.popnum.length-1].selected = true;\n"; + } + } + $text .= "}\n"; + } + } + + + $text .= "}\n\n"; + + $text .= + qq!'; + + $text .= + qq!!; + + $text .= qq!
'; #callback? return 3 html pieces? #'
!; + + $text; + +} + +=back + +=head1 RESELLER FUNCTIONS + +Note: Resellers can also use the B and B functions +with their active session. + +=over 4 + +=item agent_login + +=item agent_info + +=item agent_list_customers =back diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi new file mode 100644 index 000000000..3508e82e3 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -0,0 +1,256 @@ +#!/usr/bin/perl -Tw + +#some false laziness w/selfservice.cgi + +use strict; +use vars qw($cgi $session_id $form_max $template_dir); +use subs qw(do_template); +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use Business::CreditCard; +use Text::Template; +use FS::SelfService qw( agent_login agent_info + agent_list_customers + signup_info new_customer + customer_info order_pkg + ); + +$template_dir = '.'; + +$form_max = 255; + +$cgi = new CGI; + +unless ( defined $cgi->param('session') ) { + do_template('agent_login',{}); + exit; +} + +if ( $cgi->param('session') eq 'login' ) { + + $cgi->param('username') =~ /^\s*([a-z0-9_\-\.\&]{0,$form_max})\s*$/i + or die "illegal username"; + my $username = $1; + + $cgi->param('password') =~ /^(.{0,$form_max})$/ + or die "illegal password"; + my $password = $1; + + my $rv = agent_login( + 'username' => $username, + 'password' => $password, + ); + if ( $rv->{error} ) { + do_template('agent_login', { + 'error' => $rv->{error}, + 'username' => $username, + } ); + exit; + } else { + $cgi->param('session' => $rv->{session_id} ); + $cgi->param('action' => 'agent_main' ); + } +} + +$session_id = $cgi->param('session'); + +$cgi->param('action') =~ + /^(agent_main|signup|process_signup|list_customers|view_customer|process_order_pkg)$/ + or die "unknown action ". $cgi->param('action'); +my $action = $1; + +warn "running $action\n"; +my $result = eval "&$action();"; +die $@ if $@; + +if ( $result->{error} eq "Can't resume session" ) { #ick + do_template('agent_login',{}); + exit; +} + +warn "processing template $action\n"; +do_template($action, { + 'session_id' => $session_id, + %{$result} +}); + +#-- + +sub agent_main { agent_info( 'session_id' => $session_id ); } + +sub signup { signup_info( 'session_id' => $session_id ); } + +sub process_signup { + + my $init_data = signup_info( 'session_id' => $session_id ); + if ( $init_data->{'error'} ) { + if ( $init_data->{'error'} eq "Can't resume session" ) { #ick + do_template('agent_login',{}); + exit; + } else { #? + die $init_data->{'error'}; + } + } + + my $error = ''; + + #some false laziness w/signup.cgi + my $payby = $cgi->param('payby'); + if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { + #$payinfo = join('@', map { $cgi->param( $payby. "_payinfo$_" ) } (1,2) ); + $cgi->param('payinfo' => $cgi->param($payby. '_payinfo1'). '@'. + $cgi->param($payby. '_payinfo2') + ); + } else { + $cgi->param('payinfo' => $cgi->param( $payby. '_payinfo' ) ); + } + $cgi->param('paydate' => $cgi->param( $payby. '_month' ). '-'. + $cgi->param( $payby. '_year' ) + ); + $cgi->param('payname' => $cgi->param( $payby. '_payname' ) ); + $cgi->param('paycvv' => defined $cgi->param( $payby. '_paycvv' ) + ? $cgi->param( $payby. '_paycvv' ) + : '' + ); + + if ( $cgi->param('invoicing_list') ) { + $cgi->param('invoicing_list' => $cgi->param('invoicing_list'). ', POST') + if $cgi->param('invoicing_list_POST'); + } else { + $cgi->param('invoicing_list' => 'POST' ); + } + + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat + $cgi->param('_password', ''); + $cgi->param('_password2', ''); + } + + if ( $payby =~ /^(CARD|DCRD)$/ && $cgi->param('CARD_type') ) { + my $payinfo = $cgi->param('payinfo'); + $payinfo =~ s/\D//g; + + $payinfo =~ /^(\d{13,16})$/ + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + $payinfo = $1; + validate($payinfo) + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + cardtype($payinfo) eq $cgi->param('CARD_type') + or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); + } + + unless ( $error ) { + my $rv = new_customer ( { + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } + qw( last first ss company + address1 address2 city county state zip country + daytime night fax + payby payinfo paycvv paydate payname invoicing_list + pkgpart username sec_phrase _password popnum refnum + ), + grep { /^snarf_/ } $cgi->param + } ); + $error = $rv->{'error'}; + } + + if ( $error ) { + $action = 'signup'; + my $r = { + $cgi->Vars, + %{$init_data}, + 'error' => $error, + }; + #warn join('\n', map "$_ => $r->{$_}", keys %$r )."\n"; + $r; + } else { + $action = 'agent_main'; + my $agent_info = agent_info( 'session_id' => $session_id ); + $agent_info->{'message'} = 'Signup sucessful'; + $agent_info; + } + +} + +sub list_customers { + agent_list_customers( 'session_id' => $session_id, + map { $_ => $cgi->param($_) } + grep defined($cgi->param($_)), + qw(prospect active susp cancel) + ); +} + +sub view_customer { + + my $init_data = signup_info( 'session_id' => $session_id ); + if ( $init_data->{'error'} ) { + if ( $init_data->{'error'} eq "Can't resume session" ) { #ick + do_template('agent_login',{}); + exit; + } else { #? + die $init_data->{'error'}; + } + } + + my $customer_info = customer_info ( + 'agent_session_id' => $session_id, + 'custnum' => $cgi->param('custnum') + ); + + + return { + ( map { $_ => $init_data->{$_} } + qw( part_pkg security_phrase svc_acct_pop ), + ), + %$customer_info, + }; +} + +sub process_order_pkg { + + my $results = order_pkg ( + 'agent_session_id' => $session_id, + map { $_ => $cgi->param($_) } + qw( custnum pkgpart username _password _password2 sec_phrase popnum ) + ); + + $action = 'view_customer'; + $cgi->delete( grep { $_ ne 'custnum' } $cgi->param ) + unless $results->{'error'}; + + return { + $cgi->Vars, + %{view_customer()}, + 'message' => $results->{'error'} + ? ''. $results->{'error'}. '' + : 'Package order sucessful.' + }; + +} + +#-- + +sub do_template { + my $name = shift; + my $fill_in = shift; + #warn join(' / ', map { "$_=>".$fill_in->{$_} } keys %$fill_in). "\n"; + + $cgi->delete_all(); + $fill_in->{'selfurl'} = $cgi->self_url; + $fill_in->{'cgi'} = \$cgi; + + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => "$template_dir/$name.html", + DELIMITERS => [ '<%=', '%>' ], + UNTAINT => 1, ) + or die $Text::Template::ERROR; + + print $cgi->header( '-expires' => 'now' ), + $template->fill_in( PACKAGE => 'FS::SelfService::_agentcgi', + HASH => $fill_in + ); +} + +package FS::SelfService::_agentcgi; +use FS::SelfService qw(regionselector expselect popselector); + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_login.html b/fs_selfservice/FS-SelfService/cgi/agent_login.html new file mode 100644 index 000000000..4b0778ec5 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_login.html @@ -0,0 +1,22 @@ +Reseller Login +Reseller Login

+<%= $error %> + + + + + + + + + + + +
Username + +
Password + +
+

+ + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_main.html b/fs_selfservice/FS-SelfService/cgi/agent_main.html new file mode 100644 index 000000000..89a1b330d --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_main.html @@ -0,0 +1,40 @@ +Reseller Main +Reseller Main

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+Reseller Main
+ +
+ +<%= $message + ? "$message" + : "Hello $agent!" +%>

+ + + +
Customer summary
+ + <%= $num_prospect %> + prospects + +
<%= $num_active %> + active + +
<%= $num_susp %> + suspended + +
<%= $num_cancel %> + cancelled + +
+ +
New customer + +
+
+powered by freeside + + + + diff --git a/fs_selfservice/FS-SelfService/cgi/cvv2.html b/fs_selfservice/FS-SelfService/cgi/cvv2.html new file mode 100644 index 000000000..b178c8513 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/cvv2.html @@ -0,0 +1,25 @@ + + + + CVV2 information + + + + The CVV2 number (also called CVC2 or CID) is a three- or four-digit + security code used to reduce credit card fraud.

+ + + + + + + + +
Visa / MasterCard / DiscoverAmerican Express
+ Visa/MasterCard/Discover + + American Express +
+
(close window)
+ + diff --git a/fs_selfservice/FS-SelfService/cgi/cvv2.png b/fs_selfservice/FS-SelfService/cgi/cvv2.png new file mode 100644 index 000000000..4610dcbe6 Binary files /dev/null and b/fs_selfservice/FS-SelfService/cgi/cvv2.png differ diff --git a/fs_selfservice/FS-SelfService/cgi/cvv2_amex.png b/fs_selfservice/FS-SelfService/cgi/cvv2_amex.png new file mode 100644 index 000000000..21c36a0ab Binary files /dev/null and b/fs_selfservice/FS-SelfService/cgi/cvv2_amex.png differ diff --git a/fs_selfservice/FS-SelfService/cgi/list_customers.html b/fs_selfservice/FS-SelfService/cgi/list_customers.html new file mode 100644 index 000000000..6d4ba564e --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/list_customers.html @@ -0,0 +1,41 @@ +Reseller Main +Reseller Main

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+Reseller Main
+ +
+ +<%= + if ( @customers ) { + $OUT .= ''. + ''. + "$td{'statuscolor'}. '">'. + ucfirst($customer->{'status'}). "". "$td". + "$td$a". $customer->{'name'}. "". + ''; + #"$td". + $col = $col eq $col1 ? $col2 : $col1; + } + $OUT .= '
Customers'; + my $col1 = "ffffff"; + my $col2 = "dddddd"; + my $col = $col1; + + foreach my $customer ( @customers ) { + my $td = qq!!; + my $a = qq!'; + $OUT .= + '
'; + } else { + $OUT .= 'No customers.

'; + } +%> + +
+
+powered by freeside + + + diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html new file mode 100755 index 000000000..973035179 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup.html @@ -0,0 +1,233 @@ +<%= $agent || 'ISP' %> Signup form + + +<%= $agent || 'ISP' %> Signup form

+<%= $error %> +
+ + + + +Where did you hear about our service?

+Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($county_html, $state_html, $country_html) = + regionselector( { + selected_county => $county, + selected_state => $state, + selected_country => $country, + default_state => $statedefault, + default_country => $countrydefault, + locales => \@cust_main_county, + } ); + + "$county_html $state_html"; + %> + *Zip
*Country<%= $country_html %>
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +<%= scalar(@payby) > 1 ? '' : '' %> +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + + my $cardselect = ''; + + my %payby = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD"). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", "12-2037"). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $cvv_enabled ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $payby{$payby} .= qq!
CVV2 (help!; + } + } + + my( $account, $aba ) = split('@', $payinfo); + my %paybychecked = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD", $paydate). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $cvv_enabled ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $paybychecked{$payby} .= qq!
CVV2 (help!; + } + } + + for (@payby) { + if ( scalar(@payby) == 1) { + $OUT .= '"; + } else { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + + } + } + %> + +
'. + qq!!. + "$paybychecked{$_} $paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+

+
diff --git a/fs_selfservice/FS-SelfService/cgi/view_customer.html b/fs_selfservice/FS-SelfService/cgi/view_customer.html new file mode 100644 index 000000000..e4e9be250 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/view_customer.html @@ -0,0 +1,84 @@ +View Customer +View Customer

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+Reseller Main
+ +
+ +<%= $message + ? "$message

" + : '' +%> + +<%= $small_custview %> + +
Purchase additional package +
+ + + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ +
+ +
+
+powered by freeside + + + + -- cgit v1.2.1 From e5e2460c838fbef71b57d9380eb2d2bb6f1576db Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Jun 2004 13:29:44 +0000 Subject: moving passwd cgi to self-service --- fs_selfservice/FS-SelfService/cgi/passwd.cgi | 60 +++++++++++++++++++++++++++ fs_selfservice/FS-SelfService/cgi/passwd.html | 3 ++ 2 files changed, 63 insertions(+) create mode 100755 fs_selfservice/FS-SelfService/cgi/passwd.cgi (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/passwd.cgi b/fs_selfservice/FS-SelfService/cgi/passwd.cgi new file mode 100755 index 000000000..38b70d0cf --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/passwd.cgi @@ -0,0 +1,60 @@ +#!/usr/bin/perl -Tw + +use strict; +use Getopt::Std; +use FS::SelfService qw(passwd); +use CGI; +use CGI::Carp qw(fatalsToBrowser); + +my $freeside_uid = scalar(getpwnam('freeside')); + +$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'} = ''; + +die "fs_passwd.cgi isn't running as freeside user\n" if $> != $freeside_uid; + +my $cgi = new CGI; + +$cgi->param('username') =~ /^([^\n]{0,255}$)/ or die "Illegal username"; +my $me = $1; + +$cgi->param('domain') =~ /^([^\n]{0,255}$)/ or die "Illegal domain"; +my $domain = $1; + +$cgi->param('old_password') =~ /^([^\n]{0,255}$)/ or die "Illegal old_password"; +my $old_password = $1; + +$cgi->param('new_password') =~ /^([^\n]{0,255}$)/ or die "Illegal new_password"; +my $new_password = $1; + +die "New passwords don't match" + unless $new_password eq $cgi->param('new_password2'); + +my $rv = passwd( + 'username' => $me, + 'domain' => $domain, + 'old_password' => $old_password, + 'new_password' => $new_password, +); + +my $error = $rv->{error}; + +if ($error) { + die $error; +} else { + print $cgi->header(), < + + Password changed + + +

Password changed

+
Your password has been changed. + + +END +} diff --git a/fs_selfservice/FS-SelfService/cgi/passwd.html b/fs_selfservice/FS-SelfService/cgi/passwd.html index fadc4df8b..7e06ecff1 100644 --- a/fs_selfservice/FS-SelfService/cgi/passwd.html +++ b/fs_selfservice/FS-SelfService/cgi/passwd.html @@ -9,6 +9,9 @@ Username + Domain + + Current password -- cgit v1.2.1 From 2449cfd0609ec82d85f4539dc454f94f14a31a41 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Jun 2004 10:58:50 +0000 Subject: check password match on agent add'l package order --- fs_selfservice/FS-SelfService/cgi/agent.cgi | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 3508e82e3..a219fe771 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -208,6 +208,13 @@ sub view_customer { sub process_order_pkg { + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + my $init_data = signup_info( 'session_id' => $session_id ); + $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat + $cgi->param('_password', ''); + $cgi->param('_password2', ''); + } + my $results = order_pkg ( 'agent_session_id' => $session_id, map { $_ => $cgi->param($_) } -- cgit v1.2.1 From 2772fa107c03791feee54c544e379f7431bef950 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Jun 2004 14:24:21 +0000 Subject: fix dup password checking on add'l package order --- fs_selfservice/FS-SelfService/cgi/agent.cgi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index a219fe771..9b07ee16b 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -208,14 +208,16 @@ sub view_customer { sub process_order_pkg { + my $results = ''; + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { my $init_data = signup_info( 'session_id' => $session_id ); - $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat + $results = { error => $init_data->{msgcat}{passwords_dont_match} }; $cgi->param('_password', ''); $cgi->param('_password2', ''); } - my $results = order_pkg ( + $results ||= order_pkg ( 'agent_session_id' => $session_id, map { $_ => $cgi->param($_) } qw( custnum pkgpart username _password _password2 sec_phrase popnum ) -- cgit v1.2.1 From 83ce2076d59c3c27beb78dd5892b2da99fd60ec1 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Jun 2004 17:57:02 +0000 Subject: fix one-time card charging not pulling in exp date? --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index 40cd83c6f..a0fb5c3f3 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -46,7 +46,7 @@ @@ -54,7 +54,7 @@ -- cgit v1.2.1 From 0b227319d33d012890891570891f9d9401ff89ff Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 30 Jun 2004 14:33:35 +0000 Subject: forgot october! closes: Bug#880 --- fs_selfservice/FS-SelfService/cgi/make_payment.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index a0fb5c3f3..cf6d62e22 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -45,7 +45,7 @@ Exp. -- cgit v1.2.1 From 034bc0f9d6b114a40bcc75ada15017ce206d0ced Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jul 2004 09:29:39 +0000 Subject: new style ; param separator --- fs_selfservice/FS-SelfService/cgi/agent_main.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/agent_main.html b/fs_selfservice/FS-SelfService/cgi/agent_main.html index 89a1b330d..629734555 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent_main.html +++ b/fs_selfservice/FS-SelfService/cgi/agent_main.html @@ -16,16 +16,16 @@ <%= $num_prospect %> - prospects + prospects
<%= $num_active %> - active + active
<%= $num_susp %> - suspended + suspended
<%= $num_cancel %> - cancelled + cancelled -- cgit v1.2.1 From d2f3aff3c7fc373c9501d5b86d6c8fa8fd2e97ff Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 9 Jul 2004 11:45:59 +0000 Subject: add debugging to agent.cgi, make sure warnings are turned off when parsing templates to avoid too much output to STDERR triggering obscure apache hang bug. thanks dean you rule. --- fs_selfservice/FS-SelfService/cgi/agent.cgi | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 9b07ee16b..2d948e790 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -3,7 +3,7 @@ #some false laziness w/selfservice.cgi use strict; -use vars qw($cgi $session_id $form_max $template_dir); +use vars qw($DEBUG $me $cgi $session_id $form_max $template_dir); use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); @@ -15,19 +15,28 @@ use FS::SelfService qw( agent_login agent_info customer_info order_pkg ); +$DEBUG = 0; +$me = 'agent.cgi:'; + $template_dir = '.'; $form_max = 255; +warn "$me starting\n" if $DEBUG; + +warn "$me initializing CGI\n" if $DEBUG; $cgi = new CGI; unless ( defined $cgi->param('session') ) { + warn "$me no session defined, sending login page\n" if $DEBUG; do_template('agent_login',{}); exit; } if ( $cgi->param('session') eq 'login' ) { + warn "$me processing login\n" if $DEBUG; + $cgi->param('username') =~ /^\s*([a-z0-9_\-\.\&]{0,$form_max})\s*$/i or die "illegal username"; my $username = $1; @@ -54,12 +63,13 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); +warn "$me checking action\n" if $DEBUG; $cgi->param('action') =~ /^(agent_main|signup|process_signup|list_customers|view_customer|process_order_pkg)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; -warn "running $action\n"; +warn "$me running $action\n" if $DEBUG; my $result = eval "&$action();"; die $@ if $@; @@ -68,11 +78,12 @@ if ( $result->{error} eq "Can't resume session" ) { #ick exit; } -warn "processing template $action\n"; +warn "$me processing template $action\n" if $DEBUG; do_template($action, { 'session_id' => $session_id, %{$result} }); +warn "$me done processing template $action\n" if $DEBUG; #-- @@ -254,6 +265,7 @@ sub do_template { UNTAINT => 1, ) or die $Text::Template::ERROR; + local $^W = 0; print $cgi->header( '-expires' => 'now' ), $template->fill_in( PACKAGE => 'FS::SelfService::_agentcgi', HASH => $fill_in -- cgit v1.2.1 From 6ced9264b8ec79e4b460be90ede25ec72a7dfc16 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Jul 2004 22:40:01 +0000 Subject: big update for customer self-service: add provisioning/unprovisioning of purchased services, like fs_selfadmin --- fs_selfservice/FS-SelfService/SelfService.pm | 42 +++++++--- fs_selfservice/FS-SelfService/cgi/agent.cgi | 4 + fs_selfservice/FS-SelfService/cgi/delete_svc.html | 18 +++++ fs_selfservice/FS-SelfService/cgi/logout.html | 5 ++ .../FS-SelfService/cgi/make_payment.html | 7 +- fs_selfservice/FS-SelfService/cgi/myaccount.html | 9 +-- .../FS-SelfService/cgi/myaccount_menu.html | 13 +++ .../FS-SelfService/cgi/payment_results.html | 7 +- .../FS-SelfService/cgi/process_svc_acct.html | 14 ++++ fs_selfservice/FS-SelfService/cgi/provision.html | 77 ++++++++++++++++++ .../FS-SelfService/cgi/provision_svc_acct.html | 66 ++++++++++++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 92 +++++++++++++++++++++- .../FS-SelfService/cgi/view_invoice.html | 9 +-- 13 files changed, 331 insertions(+), 32 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/delete_svc.html create mode 100644 fs_selfservice/FS-SelfService/cgi/logout.html create mode 100644 fs_selfservice/FS-SelfService/cgi/myaccount_menu.html create mode 100644 fs_selfservice/FS-SelfService/cgi/process_svc_acct.html create mode 100644 fs_selfservice/FS-SelfService/cgi/provision.html create mode 100644 fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 2cda9fe2d..ae6d37671 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -22,17 +22,21 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'chfn' => 'passwd/passwd', 'chsh' => 'passwd/passwd', 'login' => 'MyAccount/login', + 'logout' => 'MyAccount/logout', 'customer_info' => 'MyAccount/customer_info', - 'edit_info' => 'MyAccount/edit_info', + 'edit_info' => 'MyAccount/edit_info', #add to ss cgi! 'invoice' => 'MyAccount/invoice', - 'list_invoices' => 'MyAccount/list_invoices', - 'cancel' => 'MyAccount/cancel', + 'list_invoices' => 'MyAccount/list_invoices', #? + 'cancel' => 'MyAccount/cancel', #add to ss cgi! 'payment_info' => 'MyAccount/payment_info', 'process_payment' => 'MyAccount/process_payment', - 'list_pkgs' => 'MyAccount/list_pkgs', - 'order_pkg' => 'MyAccount/order_pkg', - 'cancel_pkg' => 'MyAccount/cancel_pkg', - 'charge' => 'MyAccount/charge', + 'list_pkgs' => 'MyAccount/list_pkgs', #add to ss cgi! + 'order_pkg' => 'MyAccount/order_pkg', #add to ss cgi! + 'cancel_pkg' => 'MyAccount/cancel_pkg', #add to ss cgi! + 'charge' => 'MyAccount/charge', #? + 'part_svc_info' => 'MyAccount/part_svc_info', + 'provision_acct' => 'MyAccount/provision_acct', + 'unprovision_svc' => 'MyAccount/unprovision_svc', 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', 'agent_login' => 'Agent/agent_login', @@ -466,9 +470,28 @@ Returns a hash reference containing customer package information. The hash refe =over 4 + =item cust_pkg HASHREF -Array reference of hash references, each of which has the fields of a cust_pkg record (see L). Note these are not FS::cust_pkg objects, but hash references of columns and values. +Array reference of hash references, each of which has the fields of a cust_pkg +record (see L) as well as the fields below. Note these are not +the internal FS:: objects, but hash references of columns and values. + +=item all fields of part_pkg (XXXpare this down to a secure subset) + +=item part_svc - An array of hash references, each of which has the following keys: + +=over 4 + +=item all fields of part_svc (XXXpare this down to a secure subset) + +=item avail + +=back + +=item error + +Empty on success, or an error message on errors. =back @@ -1033,7 +1056,8 @@ END =head1 RESELLER FUNCTIONS Note: Resellers can also use the B and B functions -with their active session. +with their active session, and the B and B functions +with their active session and an additonal I parameter. =over 4 diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 2d948e790..6d2fd5840 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -221,6 +221,10 @@ sub process_order_pkg { my $results = ''; + unless ( length($cgi->param('_password')) ) { + my $init_data = signup_info( 'session_id' => $session_id ); + $results = { 'error' => $init_data->{msgcat}{empty_password} } + } if ( $cgi->param('_password') ne $cgi->param('_password2') ) { my $init_data = signup_info( 'session_id' => $session_id ); $results = { error => $init_data->{msgcat}{passwords_dont_match} }; diff --git a/fs_selfservice/FS-SelfService/cgi/delete_svc.html b/fs_selfservice/FS-SelfService/cgi/delete_svc.html new file mode 100644 index 000000000..16054a77c --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/delete_svc.html @@ -0,0 +1,18 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+ +<%= if ( $error ) { + $OUT .= qq!Error: $error!; +} else { + $OUT .= "$svc removed."; +} %> + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/logout.html b/fs_selfservice/FS-SelfService/cgi/logout.html new file mode 100644 index 000000000..0e774e9eb --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/logout.html @@ -0,0 +1,5 @@ +MyAccount +MyAccount

+You have been logged out. + + diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index cf6d62e22..3522c0867 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Make a payment

diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index f48fdedea..9997d7059 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Hello <%= $name %>!

<%= $small_custview %> @@ -15,7 +14,7 @@ Hello <%= $name %>!

<%= if ( @open_invoices ) { $OUT .= ''. - ''; my $link = qq! + diff --git a/fs_selfservice/FS-SelfService/cgi/payment_results.html b/fs_selfservice/FS-SelfService/cgi/payment_results.html index 92c8cf51b..44289deba 100644 --- a/fs_selfservice/FS-SelfService/cgi/payment_results.html +++ b/fs_selfservice/FS-SelfService/cgi/payment_results.html @@ -1,10 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
Open Invoices'; + '
Open Invoices
+ +Overview

+Change payment info *

+Change service address *

+Setup my services

+Purchase additional package *

+ +Change password(s)

+Logout

+* coming soon +
-MyAccount
- -
+ +<%= include('myaccount_menu') %> +
Payment results

<%= if ( $error ) { $OUT .= qq!Error processing your payment: $error!; diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html new file mode 100644 index 000000000..7052059c4 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html @@ -0,0 +1,14 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+ +<%= $svc %> setup sucessfully. + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/provision.html b/fs_selfservice/FS-SelfService/cgi/provision.html new file mode 100644 index 000000000..326f90229 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/provision.html @@ -0,0 +1,77 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+Setup services

+ + + +<%= foreach my $pkg ( + grep { scalar(@{$_->{part_svc}}) + || scalar(@{$_->{cust_svc}}) + } @cust_pkg + ) { + + $OUT .= ''. + ''; + + my $col1 = "ffffff"; + my $col2 = "dddddd"; + my $col = $col1; + + foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) { + my $td = qq!'. + "$td>". $cust_svc->{label}[1]. ''. + "$td>"; + + #if ( $cust_svc->{label}[2] eq 'svc_acct' ) { + # $OUT .= qq!(!. + # 'change pw) '; + #} + + unless ( $cust_svc->{'svcnum'} == $svcnum ) { + $OUT .= qq!(!. + 'delete)'; + + } + $OUT .= ''; + $col = $col eq $col1 ? $col2 : $col1; + } + + $OUT .= '' + if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}}); + + my $col = $col1; + + foreach my $part_svc ( @{ $pkg->{part_svc} } ) { + + my $td = qq!'; + $col = $col eq $col1 ? $col2 : $col1; + } + + $OUT .= '
'. + $pkg->{'pkg'}. + '
". $cust_svc->{label}[0]. ':
!. + 'Setup '. $part_svc->{'svc'}. ' '. + '('. $part_svc->{'num_avail'}. ' available)'. + '

'; + +} %> + +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html new file mode 100644 index 000000000..d18375c82 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html @@ -0,0 +1,66 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+Setup <%= $svc %>

+ +<%= if ( $error ) { + $OUT .= qq!Error setting up $svc: $error!. + '

'; +} ''; %> + + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ + + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 6d6716ddc..d8e044a96 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -6,8 +6,11 @@ use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Template; -use FS::SelfService qw( login customer_info invoice payment_info - process_payment ); +use FS::SelfService qw( login customer_info invoice + payment_info process_payment + list_pkgs + part_svc_info provision_acct unprovision_svc + ); $template_dir = '.'; @@ -54,8 +57,9 @@ if ( $cgi->param('session') eq 'login' ) { $session_id = $cgi->param('session'); +#order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results)$/ + /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|delete_svc)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -167,6 +171,63 @@ sub payment_results { } +sub logout { + FS::SelfService::logout( 'session_id' => $session_id ); +} + +sub provision { + list_pkgs( 'session_id' => $session_id ); +} + +sub provision_svc { + + my $result = part_svc_info( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart ), + ); + die $result->{'error'} if exists $result->{'error'} && $result->{'error'}; + + $result->{'svcdb'} =~ /^svc_(.*)$/ + #or return { 'error' => 'Unknown svcdb '. $result->{'svcdb'} }; + or die 'Unknown svcdb '. $result->{'svcdb'}; + $action .= "_$1"; + + $result; +} + +sub process_svc_acct { + + my $result = provision_acct ( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( + pkgnum svcpart username _password _password2 sec_phrase popnum ) + ); + + if ( exists $result->{'error'} && $result->{'error'} ) { + warn "$result $result->{'error'}"; + $action = 'provision_svc_acct'; + return { + $cgi->Vars, + %{ part_svc_info( 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart ) + ) + }, + 'error' => $result->{'error'}, + }; + } else { + warn "$result $result->{'error'}"; + return $result; + } + +} + +sub delete_svc { + unprovision_svc( + 'session_id' => $session_id, + 'svcnum' => $cgi->param('svcnum'), + ); +} + #-- sub do_template { @@ -175,6 +236,7 @@ sub do_template { $cgi->delete_all(); $fill_in->{'selfurl'} = $cgi->self_url; + $fill_in->{'cgi'} = \$cgi; my $template = new Text::Template( TYPE => 'FILE', SOURCE => "$template_dir/$name.html", @@ -183,6 +245,28 @@ sub do_template { or die $Text::Template::ERROR; print $cgi->header( '-expires' => 'now' ), - $template->fill_in( HASH => $fill_in ); + $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi', + HASH => $fill_in + ); +} + +#*FS::SelfService::_selfservicecgi::include = \&Text::Template::fill_in_file; + +package FS::SelfService::_selfservicecgi; + +#use FS::SelfService qw(regionselector expselect popselector); +use FS::SelfService qw(popselector); + +sub include { + my $name = shift; + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => "$main::template_dir/$name.html", + DELIMITERS => [ '<%=', '%>' ], + UNTAINT => 1, + ) + or die $Text::Template::ERROR; + + $template->fill_in(); + } diff --git a/fs_selfservice/FS-SelfService/cgi/view_invoice.html b/fs_selfservice/FS-SelfService/cgi/view_invoice.html index d2b012b5d..46f731890 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_invoice.html +++ b/fs_selfservice/FS-SelfService/cgi/view_invoice.html @@ -1,12 +1,9 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-MyAccount
- -
- -<-- back to MyAccount

+ +<%= include('myaccount_menu') %> + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html b/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html new file mode 100644 index 000000000..0a665c99e --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html @@ -0,0 +1,19 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> +
 <%= $invoice_text %>
-- 
cgit v1.2.1


From 3913733875c647485de5c53b296a2343fec3fa66 Mon Sep 17 00:00:00 2001
From: ivan 
Date: Tue, 17 Aug 2004 07:43:50 +0000
Subject: fix path to passwd.cgi!

---
 fs_selfservice/FS-SelfService/cgi/passwd.cgi  | 2 +-
 fs_selfservice/FS-SelfService/cgi/passwd.html | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'fs_selfservice')

diff --git a/fs_selfservice/FS-SelfService/cgi/passwd.cgi b/fs_selfservice/FS-SelfService/cgi/passwd.cgi
index 38b70d0cf..d77876e37 100755
--- a/fs_selfservice/FS-SelfService/cgi/passwd.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/passwd.cgi
@@ -15,7 +15,7 @@ $ENV{'CDPATH'} = '';
 $ENV{'ENV'} = '';
 $ENV{'BASH_ENV'} = '';
 
-die "fs_passwd.cgi isn't running as freeside user\n" if $> != $freeside_uid;
+die "passwd.cgi isn't running as freeside user\n" if $> != $freeside_uid;
 
 my $cgi = new CGI;
 
diff --git a/fs_selfservice/FS-SelfService/cgi/passwd.html b/fs_selfservice/FS-SelfService/cgi/passwd.html
index 7e06ecff1..459c96aa8 100644
--- a/fs_selfservice/FS-SelfService/cgi/passwd.html
+++ b/fs_selfservice/FS-SelfService/cgi/passwd.html
@@ -4,7 +4,7 @@
   
   
     

Change password

-
+ -- cgit v1.2.1 From 0cbeb01df08457b056a7ae775b4924c266b4228b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 24 Aug 2004 11:16:57 +0000 Subject: big update for reseller interface --- fs_selfservice/FS-SelfService/SelfService.pm | 1 + fs_selfservice/FS-SelfService/cgi/agent.cgi | 192 ++++++++++++++++++--- .../FS-SelfService/cgi/agent_customer_menu.html | 7 + .../FS-SelfService/cgi/agent_delete_svc.html | 20 +++ .../FS-SelfService/cgi/agent_logout.html | 5 + fs_selfservice/FS-SelfService/cgi/agent_main.html | 21 +-- fs_selfservice/FS-SelfService/cgi/agent_menu.html | 15 ++ .../FS-SelfService/cgi/agent_order_pkg.html | 19 ++ .../FS-SelfService/cgi/agent_provision.html | 25 +++ .../cgi/agent_provision_svc_acct.html | 19 ++ .../FS-SelfService/cgi/list_customers.html | 12 +- fs_selfservice/FS-SelfService/cgi/order_pkg.html | 75 ++++++++ fs_selfservice/FS-SelfService/cgi/provision.html | 68 +------- .../FS-SelfService/cgi/provision_list.html | 74 ++++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 15 +- fs_selfservice/FS-SelfService/cgi/svc_acct.html | 55 ++++++ .../FS-SelfService/cgi/view_customer.html | 75 ++------ 17 files changed, 520 insertions(+), 178 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_logout.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_menu.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_order_pkg.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_provision.html create mode 100644 fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html create mode 100644 fs_selfservice/FS-SelfService/cgi/order_pkg.html create mode 100644 fs_selfservice/FS-SelfService/cgi/provision_list.html create mode 100644 fs_selfservice/FS-SelfService/cgi/svc_acct.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index ae6d37671..de33b75b1 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -40,6 +40,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', 'agent_login' => 'Agent/agent_login', + 'agent_logout' => 'Agent/agent_logout', 'agent_info' => 'Agent/agent_info', 'agent_list_customers' => 'Agent/agent_list_customers', ); diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 6d2fd5840..b88709862 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -9,10 +9,12 @@ use CGI; use CGI::Carp qw(fatalsToBrowser); use Business::CreditCard; use Text::Template; -use FS::SelfService qw( agent_login agent_info +#use HTML::Entities; +use FS::SelfService qw( agent_login agent_logout agent_info agent_list_customers signup_info new_customer - customer_info order_pkg + customer_info list_pkgs order_pkg + part_svc_info provision_acct unprovision_svc ); $DEBUG = 0; @@ -65,7 +67,7 @@ $session_id = $cgi->param('session'); warn "$me checking action\n" if $DEBUG; $cgi->param('action') =~ - /^(agent_main|signup|process_signup|list_customers|view_customer|process_order_pkg)$/ + /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|delete_svc|agent_order_pkg|process_order_pkg|logout)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -87,6 +89,11 @@ warn "$me done processing template $action\n" if $DEBUG; #-- +sub logout { + $action = 'agent_logout'; + agent_logout( 'session_id' => $session_id ); +} + sub agent_main { agent_info( 'session_id' => $session_id ); } sub signup { signup_info( 'session_id' => $session_id ); } @@ -184,15 +191,55 @@ sub process_signup { } sub list_customers { - agent_list_customers( 'session_id' => $session_id, - map { $_ => $cgi->param($_) } - grep defined($cgi->param($_)), - qw(prospect active susp cancel) - ); + + my $results = + agent_list_customers( 'session_id' => $session_id, + map { $_ => $cgi->param($_) } + grep defined($cgi->param($_)), + qw(prospect active susp cancel), + 'search', + ); + + if ( scalar( @{$results->{'customers'}} ) == 1 ) { + $action = 'view_customer'; + customer_info ( + 'agent_session_id' => $session_id, + 'custnum' => $results->{'customers'}[0]{'custnum'}, + ); + } else { + $results; + } + } sub view_customer { + #my $init_data = signup_info( 'session_id' => $session_id ); + #if ( $init_data->{'error'} ) { + # if ( $init_data->{'error'} eq "Can't resume session" ) { #ick + # do_template('agent_login',{}); + # exit; + # } else { #? + # die $init_data->{'error'}; + # } + #} + # + #my $customer_info = + customer_info ( + 'agent_session_id' => $session_id, + 'custnum' => $cgi->param('custnum'), + ); + # + #return { + # ( map { $_ => $init_data->{$_} } + # qw( part_pkg security_phrase svc_acct_pop ), + # ), + # %$customer_info, + #}; +} + +sub agent_order_pkg { + my $init_data = signup_info( 'session_id' => $session_id ); if ( $init_data->{'error'} ) { if ( $init_data->{'error'} eq "Can't resume session" ) { #ick @@ -205,16 +252,91 @@ sub view_customer { my $customer_info = customer_info ( 'agent_session_id' => $session_id, - 'custnum' => $cgi->param('custnum') + 'custnum' => $cgi->param('custnum'), ); - return { ( map { $_ => $init_data->{$_} } qw( part_pkg security_phrase svc_acct_pop ), ), %$customer_info, }; + +} + +sub agent_provision { + my $result = list_pkgs( + 'agent_session_id' => $session_id, + 'custnum' => $cgi->param('custnum'), + ); + die $result->{'error'} if exists $result->{'error'} && $result->{'error'}; + $result; +} + +sub provision_svc { + + my $result = part_svc_info( + 'agent_session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart custnum ), + ); + die $result->{'error'} if exists $result->{'error'} && $result->{'error'}; + + $result->{'svcdb'} =~ /^svc_(.*)$/ + #or return { 'error' => 'Unknown svcdb '. $result->{'svcdb'} }; + or die 'Unknown svcdb '. $result->{'svcdb'}; + $action .= "_$1"; + $action = "agent_$action"; + + $result; +} + +sub process_svc_acct { + + my $result = provision_acct ( + 'agent_session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( + custnum pkgnum svcpart username _password _password2 sec_phrase popnum ) + ); + + if ( exists $result->{'error'} && $result->{'error'} ) { + #warn "$result $result->{'error'}"; + $action = 'provision_svc_acct'; + $action = "agent_$action"; + return { + $cgi->Vars, + %{ part_svc_info( 'agent_session_id' => $session_id, + map { $_ => $cgi->param($_) } qw(pkgnum svcpart custnum) + ) + }, + 'error' => $result->{'error'}, + }; + } else { + #warn "$result $result->{'error'}"; + $action = 'agent_provision'; + return { + %{agent_provision()}, + 'message' => $result->{'svc'}. ' setup sucessfully.', + }; + } + +} + +sub delete_svc { + my $result = unprovision_svc( + 'agent_session_id' => $session_id, + 'custnum' => $cgi->param('custnum'), + 'svcnum' => $cgi->param('svcnum'), + ); + + $action = 'agent_provision'; + + return { + %{agent_provision()}, + 'message' => $result->{'error'} + ? ''. $result->{'error'}. '' + : $result->{'svc'}. ' removed.' + }; + } sub process_order_pkg { @@ -223,11 +345,12 @@ sub process_order_pkg { unless ( length($cgi->param('_password')) ) { my $init_data = signup_info( 'session_id' => $session_id ); - $results = { 'error' => $init_data->{msgcat}{empty_password} } + #die $init_data->{'error'} if $init_data->{'error'}; + $results = { 'error' => $init_data->{msgcat}{empty_password} }; } if ( $cgi->param('_password') ne $cgi->param('_password2') ) { my $init_data = signup_info( 'session_id' => $session_id ); - $results = { error => $init_data->{msgcat}{passwords_dont_match} }; + $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} }; $cgi->param('_password', ''); $cgi->param('_password2', ''); } @@ -238,17 +361,22 @@ sub process_order_pkg { qw( custnum pkgpart username _password _password2 sec_phrase popnum ) ); - $action = 'view_customer'; - $cgi->delete( grep { $_ ne 'custnum' } $cgi->param ) - unless $results->{'error'}; - - return { - $cgi->Vars, - %{view_customer()}, - 'message' => $results->{'error'} - ? ''. $results->{'error'}. '' - : 'Package order sucessful.' - }; + if ( $results->{'error'} ) { + $action = 'agent_order_pkg'; + return { + $cgi->Vars, + %{agent_order_pkg()}, + #'message' => ''. $results->{'error'}. '', + 'error' => ''. $results->{'error'}. '', + }; + } else { + $action = 'view_customer'; + #$cgi->delete( grep { $_ ne 'custnum' } $cgi->param ); + return { + %{view_customer()}, + 'message' => 'Package order sucessful.', + }; + } } @@ -277,5 +405,23 @@ sub do_template { } package FS::SelfService::_agentcgi; + +use HTML::Entities; use FS::SelfService qw(regionselector expselect popselector); +#false laziness w/selfservice.cgi +sub include { + my $name = shift; + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => "$main::template_dir/$name.html", + DELIMITERS => [ '<%=', '%>' ], + UNTAINT => 1, + ) + or die $Text::Template::ERROR; + + $template->fill_in( PACKAGE => 'FS::SelfService::_agentcgi', + #HASH => $fill_in + ); + +} + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html b/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html new file mode 100644 index 000000000..603fc0bd2 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_customer_menu.html @@ -0,0 +1,7 @@ +<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html new file mode 100644 index 000000000..e8be07ed1 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html @@ -0,0 +1,20 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
Username +Setup services

+Purchase additional package

+ +
+<%= include('myaccount_menu') %> +
+<%= $small_custview %> +
+<%= if ( $error ) { + + $OUT .= qq!Error: $error!; +} else { + $OUT .= "$svc removed."; +} %> + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_logout.html b/fs_selfservice/FS-SelfService/cgi/agent_logout.html new file mode 100644 index 000000000..98094679a --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_logout.html @@ -0,0 +1,5 @@ +Reseller +Reseller

+You have been logged out. + + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_main.html b/fs_selfservice/FS-SelfService/cgi/agent_main.html index 629734555..9dd338382 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent_main.html +++ b/fs_selfservice/FS-SelfService/cgi/agent_main.html @@ -1,10 +1,9 @@ -Reseller Main -Reseller Main

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Reseller Main
- -
+ +<%= include('agent_menu') %> +
<%= $message ? "$message" @@ -16,21 +15,19 @@
<%= $num_prospect %> - prospects + <%= $num_prospect ? qq!! : '' %>prospects
<%= $num_active %> - active + <%= $num_active ? qq!! : '' %>active
<%= $num_susp %> - suspended + <%= $num_susp ? qq!! : '' %>suspended
<%= $num_cancel %> - cancelled + <%= $num_cancel ? qq!! : '' %>cancelled
-
New customer -

powered by freeside diff --git a/fs_selfservice/FS-SelfService/cgi/agent_menu.html b/fs_selfservice/FS-SelfService/cgi/agent_menu.html new file mode 100644 index 000000000..84a295304 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_menu.html @@ -0,0 +1,15 @@ +<%= $url = "$selfurl?session=$session_id;action="; ''; %> +
+ +Overview

+New customer

+ + + +
+cust #, last name, or company
+
+ +Logout

+ +
+<%= include('agent_menu') %> +
+<%= $small_custview %> +
+ + +<%= include('agent_customer_menu') %> +
+<%= include('order_pkg') %> +
+ +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_provision.html b/fs_selfservice/FS-SelfService/cgi/agent_provision.html new file mode 100644 index 000000000..8770e2f9e --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_provision.html @@ -0,0 +1,25 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + +<%= include('agent_menu') %> +
+ +<%= $message + ? "$message

" + : '' +%> + +<%= $small_custview %> +
+ + +<%= include('agent_customer_menu') %> +
+<%= include('provision_list') %> +
+ +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html new file mode 100644 index 000000000..8d299cdc5 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/agent_provision_svc_acct.html @@ -0,0 +1,19 @@ +Reseller +Reseller

+<%= $url = "$selfurl?session=$session_id;custnum=$custnum;action="; ''; %> + +<%= include('agent_menu') %> +
+<%= $small_custview %> +
+ +<%= include('agent_customer_menu') %> +
+<%= include('svc_acct') %> +
+ +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/list_customers.html b/fs_selfservice/FS-SelfService/cgi/list_customers.html index 6d4ba564e..858e5e9ba 100644 --- a/fs_selfservice/FS-SelfService/cgi/list_customers.html +++ b/fs_selfservice/FS-SelfService/cgi/list_customers.html @@ -1,10 +1,9 @@ -Reseller Main -Reseller Main

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -$td COLSPAN=3 ALIGN=center>". - qq!!. - 'Setup '. $part_svc->{'svc'}. ' '. + qq!!. 'Setup '. $part_svc->{'svc'}. ' '. '('. $part_svc->{'num_avail'}. ' available)'. ''; $col = $col eq $col1 ? $col2 : $col1; diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 44dd8bb3a..0816758fb 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -10,7 +10,8 @@ use HTML::Entities; use FS::SelfService qw( login customer_info invoice payment_info process_payment list_pkgs - part_svc_info provision_acct unprovision_svc + part_svc_info provision_acct provision_external + unprovision_svc ); $template_dir = '.'; @@ -60,7 +61,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|delete_svc)$/ + /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -224,6 +225,13 @@ sub process_svc_acct { } +sub process_svc_external { + provision_external ( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( pkgnum svcpart ) + ); +} + sub delete_svc { unprovision_svc( 'session_id' => $session_id, -- cgit v1.2.1 From b5fbaadb1cb2893660e460a1d4a3cabe02774de7 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 12 Mar 2005 14:31:50 +0000 Subject: - bring prepaid support into this century (close: Bug#1124) - finally get rid of fs_signup (everything is in fs_selfservice now) (Bug#413) - organize main menu sysadmin section so it is slightly less confusing --- fs_selfservice/DEPLOY | 25 +- fs_selfservice/FS-SelfService/cgi/agent.cgi | 15 +- fs_selfservice/FS-SelfService/cgi/decline.html | 5 + fs_selfservice/FS-SelfService/cgi/map.gif | Bin 0 -> 8181 bytes fs_selfservice/FS-SelfService/cgi/promocode.html | 14 + fs_selfservice/FS-SelfService/cgi/regcode.html | 14 + .../FS-SelfService/cgi/signup-agentselect.html | 195 ++++++++++ .../FS-SelfService/cgi/signup-alternate.html | 218 +++++++++++ .../FS-SelfService/cgi/signup-billaddress.html | 307 +++++++++++++++ .../FS-SelfService/cgi/signup-freeoption.html | 262 +++++++++++++ .../FS-SelfService/cgi/signup-snarf.html | 228 +++++++++++ fs_selfservice/FS-SelfService/cgi/signup.cgi | 429 +++++++++++++++++++++ fs_selfservice/FS-SelfService/ieak.template | 40 ++ 13 files changed, 1740 insertions(+), 12 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/decline.html create mode 100644 fs_selfservice/FS-SelfService/cgi/map.gif create mode 100644 fs_selfservice/FS-SelfService/cgi/promocode.html create mode 100644 fs_selfservice/FS-SelfService/cgi/regcode.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup-agentselect.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup-alternate.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup-billaddress.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup-freeoption.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup-snarf.html create mode 100755 fs_selfservice/FS-SelfService/cgi/signup.cgi create mode 100755 fs_selfservice/FS-SelfService/ieak.template (limited to 'fs_selfservice') diff --git a/fs_selfservice/DEPLOY b/fs_selfservice/DEPLOY index 7420df778..63412784f 100755 --- a/fs_selfservice/DEPLOY +++ b/fs_selfservice/DEPLOY @@ -1,20 +1,27 @@ #!/bin/sh -kill `cat /var/run/freeside-selfservice-server.fs_selfservice.pid` +#this is a quick hack for my dev machine. do not use it. +# see the "make install-selfservice" and "make update-selfservice" makefile +# targets to properly install this stuff. -( cd ..; make deploy; cd fs_selfservice ) +#kill `cat /var/run/freeside-selfservice-server.fs_selfservice.pid` cd FS-SelfService perl Makefile.PL && make && make install +cd .. + +( cd ..; make deploy; cd fs_selfservice ) cp /home/ivan/freeside/fs_selfservice/FS-SelfService/cgi/* /var/www/MyAccount -chown freeside /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/agent.cgi -chmod 755 /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/agent.cgi +chown freeside /var/www/MyAccount/*.cgi +chmod 755 /var/www/MyAccount/*.cgi ln -s /var/www/MyAccount/selfservice.cgi /var/www/MyAccount/index.cgi || true -cp /home/ivan/freeside/fs_signup/FS-SignupClient/cgi/* /var/www/signup/ -#mv /var/www/signup/signup-snarf.html /var/www/signup/signup.html #!!!!! -chown freeside /var/www/signup/signup.cgi -chmod 755 /var/www/signup/signup.cgi -ln -s /var/www/signup/signup.cgi /var/www/signup/index.cgi || true + #cp /home/ivan/freeside/fs_signup/FS-SignupClient/cgi/* /var/www/signup/ + ##mv /var/www/signup/signup-snarf.html /var/www/signup/signup.html #!!!!! + ##mv /var/www/signup/signup-billaddress.html /var/www/signup/signup.html #!!!!! + ##mv /var/www/signup/signup-freeoption.html /var/www/signup/signup.html #!!!!! + #chown freeside /var/www/signup/signup.cgi + #chmod 755 /var/www/signup/signup.cgi + #ln -s /var/www/signup/signup.cgi /var/www/signup/index.cgi || true diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index 92c76f38e..695d20e4c 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -113,7 +113,7 @@ sub process_signup { my $error = ''; - #some false laziness w/signup.cgi + #false laziness w/signup.cgi, identical except for agentnum vs session_id my $payby = $cgi->param('payby'); if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { #$payinfo = join('@', map { $cgi->param( $payby. "_payinfo$_" ) } (1,2) ); @@ -161,17 +161,25 @@ sub process_signup { unless ( $error ) { my $rv = new_customer ( { 'session_id' => $session_id, - map { $_ => $cgi->param($_) } + map { $_ => scalar($cgi->param($_)) } qw( last first ss company address1 address2 city county state zip country daytime night fax + + ship_last ship_first ship_company + ship_address1 ship_address2 ship_city ship_county ship_state + ship_zip ship_country + ship_daytime ship_night ship_fax + payby payinfo paycvv paydate payname invoicing_list + referral_custnum promo_code reg_code pkgpart username sec_phrase _password popnum refnum ), grep { /^snarf_/ } $cgi->param } ); $error = $rv->{'error'}; } + #eslaf if ( $error ) { $action = 'signup'; @@ -409,7 +417,8 @@ sub do_template { #warn join(' / ', map { "$_=>".$fill_in->{$_} } keys %$fill_in). "\n"; $cgi->delete_all(); - $fill_in->{'selfurl'} = $cgi->self_url; + $fill_in->{'selfurl'} = $cgi->self_url; #OLD + $fill_in->{'self_url'} = $cgi->self_url; $fill_in->{'cgi'} = \$cgi; my $template = new Text::Template( TYPE => 'FILE', diff --git a/fs_selfservice/FS-SelfService/cgi/decline.html b/fs_selfservice/FS-SelfService/cgi/decline.html new file mode 100644 index 000000000..a37ba3ab6 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/decline.html @@ -0,0 +1,5 @@ +Processing error +Processing error

+There has been an error processing your account. Please contact customer +support. + diff --git a/fs_selfservice/FS-SelfService/cgi/map.gif b/fs_selfservice/FS-SelfService/cgi/map.gif new file mode 100644 index 000000000..ef884d8f9 Binary files /dev/null and b/fs_selfservice/FS-SelfService/cgi/map.gif differ diff --git a/fs_selfservice/FS-SelfService/cgi/promocode.html b/fs_selfservice/FS-SelfService/cgi/promocode.html new file mode 100644 index 000000000..f8ee7f6eb --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/promocode.html @@ -0,0 +1,14 @@ +ISP Signup +ISP Signup - promotional code

+ +
+Enter promotional code + + + + + diff --git a/fs_selfservice/FS-SelfService/cgi/regcode.html b/fs_selfservice/FS-SelfService/cgi/regcode.html new file mode 100644 index 000000000..e639b9b53 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/regcode.html @@ -0,0 +1,14 @@ +ISP Signup +ISP Signup - registration code

+ +
+Enter registration code + + + + + diff --git a/fs_selfservice/FS-SelfService/cgi/signup-agentselect.html b/fs_selfservice/FS-SelfService/cgi/signup-agentselect.html new file mode 100755 index 000000000..7851c5601 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup-agentselect.html @@ -0,0 +1,195 @@ +ISP Signup form +ISP Signup form

+<%= $error %> +
+ + + +Agent

+Contact Information +
-Reseller Main
- -
+ +<%= include('agent_menu') %> +'; + +} %> + +
<%= if ( @customers ) { @@ -38,4 +37,3 @@ powered by freeside - diff --git a/fs_selfservice/FS-SelfService/cgi/order_pkg.html b/fs_selfservice/FS-SelfService/cgi/order_pkg.html new file mode 100644 index 000000000..9cdd4cd6c --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/order_pkg.html @@ -0,0 +1,75 @@ + +Purchase additional package

+<%= if ( $error ) { + $OUT .= qq!$error

!; +} ''; %> +
+ + + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ +
+ diff --git a/fs_selfservice/FS-SelfService/cgi/provision.html b/fs_selfservice/FS-SelfService/cgi/provision.html index 326f90229..6d80e89db 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision.html +++ b/fs_selfservice/FS-SelfService/cgi/provision.html @@ -4,73 +4,7 @@ <%= include('myaccount_menu') %>
-Setup services

- - - -<%= foreach my $pkg ( - grep { scalar(@{$_->{part_svc}}) - || scalar(@{$_->{cust_svc}}) - } @cust_pkg - ) { - - $OUT .= ''. - ''; - - my $col1 = "ffffff"; - my $col2 = "dddddd"; - my $col = $col1; - - foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) { - my $td = qq!'. - "$td>". $cust_svc->{label}[1]. ''. - "$td>"; - - #if ( $cust_svc->{label}[2] eq 'svc_acct' ) { - # $OUT .= qq!(!. - # 'change pw) '; - #} - - unless ( $cust_svc->{'svcnum'} == $svcnum ) { - $OUT .= qq!(!. - 'delete)'; - - } - $OUT .= ''; - $col = $col eq $col1 ? $col2 : $col1; - } - - $OUT .= '' - if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}}); - - my $col = $col1; - - foreach my $part_svc ( @{ $pkg->{part_svc} } ) { - - my $td = qq!'; - $col = $col eq $col1 ? $col2 : $col1; - } - - $OUT .= '
'. - $pkg->{'pkg'}. - '
". $cust_svc->{label}[0]. ':
!. - 'Setup '. $part_svc->{'svc'}. ' '. - '('. $part_svc->{'num_avail'}. ' available)'. - '

'; - -} %> - +<%= include('provision_list') %>

powered by freeside diff --git a/fs_selfservice/FS-SelfService/cgi/provision_list.html b/fs_selfservice/FS-SelfService/cgi/provision_list.html new file mode 100644 index 000000000..7e7059388 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/provision_list.html @@ -0,0 +1,74 @@ +Setup services

+ + + + + +<%= foreach my $pkg ( + grep { scalar(@{$_->{part_svc}}) + || scalar(@{$_->{cust_svc}}) + } @cust_pkg + ) { + + $OUT .= #'
'. + ''; + + my $col1 = "ffffff"; + my $col2 = "dddddd"; + my $col = $col1; + + foreach my $cust_svc ( @{ $pkg->{cust_svc} } ) { + my $td = qq!'. + "$td>". $cust_svc->{label}[1]. ''; + $OUT .= '
password: '. encode_entities($cust_svc->{_password}). '' + if exists($cust_svc->{_password}); + $OUT .= ''. + "$td>"; + + #if ( $cust_svc->{label}[2] eq 'svc_acct' ) { + # $OUT .= qq!(!. + # 'change pw) '; + #} + + unless ( $cust_svc->{'svcnum'} == $svcnum ) { + $OUT .= qq!(!. + 'delete)'; + + } + $OUT .= ''; + $col = $col eq $col1 ? $col2 : $col1; + } + + $OUT .= '' + if scalar(@{$pkg->{part_svc}}) && scalar(@{$pkg->{cust_svc}}); + + $col = $col1; + + foreach my $part_svc ( @{ $pkg->{part_svc} } ) { + + my $td = qq!'; + $col = $col eq $col1 ? $col2 : $col1; + } + + #$OUT .= '
'. + $pkg->{'pkg'}. + '
". $cust_svc->{label}[0]. ':
!. + 'Setup '. $part_svc->{'svc'}. ' '. + '('. $part_svc->{'num_avail'}. ' available)'. + '

'; + $OUT .= '
 
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index d8e044a96..44dd8bb3a 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -6,6 +6,7 @@ use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Template; +use HTML::Entities; use FS::SelfService qw( login customer_info invoice payment_info process_payment list_pkgs @@ -176,7 +177,9 @@ sub logout { } sub provision { - list_pkgs( 'session_id' => $session_id ); + my $result = list_pkgs( 'session_id' => $session_id ); + die $result->{'error'} if exists $result->{'error'} && $result->{'error'}; + $result; } sub provision_svc { @@ -204,7 +207,7 @@ sub process_svc_acct { ); if ( exists $result->{'error'} && $result->{'error'} ) { - warn "$result $result->{'error'}"; + #warn "$result $result->{'error'}"; $action = 'provision_svc_acct'; return { $cgi->Vars, @@ -215,7 +218,7 @@ sub process_svc_acct { 'error' => $result->{'error'}, }; } else { - warn "$result $result->{'error'}"; + #warn "$result $result->{'error'}"; return $result; } @@ -255,8 +258,10 @@ sub do_template { package FS::SelfService::_selfservicecgi; #use FS::SelfService qw(regionselector expselect popselector); +use HTML::Entities; use FS::SelfService qw(popselector); +#false laziness w/agent.cgi sub include { my $name = shift; my $template = new Text::Template( TYPE => 'FILE', @@ -266,7 +271,9 @@ sub include { ) or die $Text::Template::ERROR; - $template->fill_in(); + $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi', + #HASH => $fill_in + ); } diff --git a/fs_selfservice/FS-SelfService/cgi/svc_acct.html b/fs_selfservice/FS-SelfService/cgi/svc_acct.html new file mode 100644 index 000000000..abed8786e --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/svc_acct.html @@ -0,0 +1,55 @@ +Setup <%= $svc %>

+ +<%= if ( $error ) { + $OUT .= qq!Error setting up $svc: $error!. + '

'; +} ''; %> +
+ + + + + + + + + + + + + + + + + + +<%= + if ( $security_phrase ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( @svc_acct_pop ) { + $OUT .= ''; + } else { + $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector( 'popnum' => $popnum, + 'pops' => \@svc_acct_pop, + 'init_popstate' => $init_popstate, + 'popac' => $popac, + 'acstate' => $acstate, + ). + '
+ +
diff --git a/fs_selfservice/FS-SelfService/cgi/view_customer.html b/fs_selfservice/FS-SelfService/cgi/view_customer.html index e4e9be250..11e4432d0 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_customer.html +++ b/fs_selfservice/FS-SelfService/cgi/view_customer.html @@ -1,10 +1,9 @@ -View Customer -View Customer

+Reseller +Reseller

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Reseller Main
- -
+ +<%= include('agent_menu') %> +
<%= $message ? "$message

" @@ -13,67 +12,13 @@ <%= $small_custview %> -
Purchase additional package -
- - - - - -
+<%= include('agent_customer_menu') %> + - - - - - - - - - - - - - -<%= - if ( $security_phrase ) { - $OUT .= < - - - -ENDOUT - } else { - $OUT .= ''; - } -%> -<%= - if ( @svc_acct_pop ) { - $OUT .= ''; - } else { - $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); - } -%> -
-
Username
Password
Re-enter Password
Security Phrase -
Access number'. - popselector( 'popnum' => $popnum, - 'pops' => \@svc_acct_pop, - 'init_popstate' => $init_popstate, - 'popac' => $popac, - 'acstate' => $acstate, - ). - '
- - +

-- cgit v1.2.1 From 7598902376bff0ddeba07ef9eb973f64efe87ad5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 5 Sep 2004 22:42:13 +0000 Subject: fixed duplicate checking will catch it, but add client-side protection against double-submission also. --- fs_selfservice/FS-SelfService/cgi/signup.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html index 973035179..3532527a2 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.html +++ b/fs_selfservice/FS-SelfService/cgi/signup.html @@ -14,7 +14,7 @@ //--> <%= $agent || 'ISP' %> Signup form

<%= $error %> -
+ @@ -229,5 +229,5 @@ ENDOUT } %>
-

+

-- cgit v1.2.1 From efccaa2d081bfcaaddcf9d89da3c2a065b4caafb Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Sep 2004 12:44:17 +0000 Subject: self-service keepalives --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index ce9e14d35..95e9b9b4f 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -20,7 +20,8 @@ my $tag = scalar(@ARGV) ? '.'.shift : ''; use vars qw( $Debug ); $Debug = 2; #2 will turn on child logging, 3 will log packet contents, - #including potentially compromising information + #including potentially compromising information, 4 will log + #receipts of all packets from server including keepalives (big!) my $socket = "/usr/local/freeside/selfservice_socket$tag"; my $pid_file = "$socket.pid"; @@ -65,6 +66,9 @@ close PIDFILE; #sub REAPER { $waitedpid = wait; $SIG{CHLD} = \&REAPER; } #$SIG{CHLD} = \&REAPER; +warn "enabling keep alives\n" if $Debug; +nstore_fd( { _packet => '_enable_keepalive' } , \*STDOUT ); + warn "entering main loop\n" if $Debug; my %kids; @@ -101,10 +105,16 @@ while (1) { if ( $handle == \*STDIN ) { - warn "receiving packet from server\n" if $Debug; + warn "receiving packet from server\n" if $Debug > 3; my $packet = fd_retrieve(\*STDIN); my $token = $packet->{'_token'}; + + if ( $token eq '_keepalive' ) { + $undisp = 1; + next; + } + warn "received packet from server with token $token\n". ( $Debug > 2 ? join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) -- cgit v1.2.1 From 07fd88f7c0cd757eb2f8e635b71acebe6a944602 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 14 Sep 2004 06:47:46 +0000 Subject: selfservice: - server: don't reconnect again if we've already been signalled to shutdown - server: add kid reaping to shutdown sequence - server: add another optional logging level to response sending - server: acquire write mutex for keepalives --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 95e9b9b4f..5a058381d 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -19,9 +19,10 @@ use IO::File; my $tag = scalar(@ARGV) ? '.'.shift : ''; use vars qw( $Debug ); -$Debug = 2; #2 will turn on child logging, 3 will log packet contents, - #including potentially compromising information, 4 will log - #receipts of all packets from server including keepalives (big!) +$Debug = 2; #2 will turn on child logging + #3 will log packet contents,#including passwords + #4 will log receipts of all packets from server including + # keepalives (big!) my $socket = "/usr/local/freeside/selfservice_socket$tag"; my $pid_file = "$socket.pid"; -- cgit v1.2.1 From b6b73450dada235f94f7773a53079417dd219a4c Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 15 Sep 2004 08:45:06 +0000 Subject: obtain a new descriptor for the lock in kids, this should fix locking problems --- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 5a058381d..ededfa6e9 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -43,6 +43,7 @@ $SIG{__WARN__} = \&_logmsg; warn "Creating $lock_file\n" if $Debug; open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!"; +close LOCKFILE; warn "Creating $socket\n" if $Debug; my $uaddr = sockaddr_un($socket); @@ -256,6 +257,9 @@ sub lock_write { #broken on freebsd? #flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!"; + #open a new one for each kid to get a unique lock + open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!"; + flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!"; } -- cgit v1.2.1 From b50276a1fc993e07ef839f87a0611680bbda2ce7 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 17 Oct 2004 09:54:58 +0000 Subject: use templated svc_acct provisioner, from agent interface --- .../FS-SelfService/cgi/provision_svc_acct.html | 56 +--------------------- 1 file changed, 1 insertion(+), 55 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html index d18375c82..cf3585721 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html +++ b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html @@ -4,61 +4,7 @@ <%= include('myaccount_menu') %>
-Setup <%= $svc %>

- -<%= if ( $error ) { - $OUT .= qq!Error setting up $svc: $error!. - '

'; -} ''; %> -
- - - - - - - - - - - - - - - - - -<%= - if ( $security_phrase ) { - $OUT .= < - - - -ENDOUT - } else { - $OUT .= ''; - } -%> -<%= - if ( @svc_acct_pop ) { - $OUT .= ''; - } else { - $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop); - } -%> -
Username
Password
Re-enter Password
Security Phrase -
Access number'. - popselector( 'popnum' => $popnum, - 'pops' => \@svc_acct_pop, - 'init_popstate' => $init_popstate, - 'popac' => $popac, - 'acstate' => $acstate, - ). - '
- -
- +<%= include('svc_acct') %>

powered by freeside -- cgit v1.2.1 From dda265d579b6f754feea0deacd12ae358d552f11 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 17 Oct 2004 14:01:47 +0000 Subject: add artera turbo handling to self-service and reseller interfaces --- fs_selfservice/FS-SelfService/SelfService.pm | 1 + fs_selfservice/FS-SelfService/cgi/agent.cgi | 25 ++++++++++++++++++++-- .../FS-SelfService/cgi/process_svc_external.html | 16 ++++++++++++++ .../FS-SelfService/cgi/provision_list.html | 17 +++++++++++++-- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 12 +++++++++-- 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/process_svc_external.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index de33b75b1..6e3ca3b5a 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -36,6 +36,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'charge' => 'MyAccount/charge', #? 'part_svc_info' => 'MyAccount/part_svc_info', 'provision_acct' => 'MyAccount/provision_acct', + 'provision_external' => 'MyAccount/provision_external', 'unprovision_svc' => 'MyAccount/unprovision_svc', 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', diff --git a/fs_selfservice/FS-SelfService/cgi/agent.cgi b/fs_selfservice/FS-SelfService/cgi/agent.cgi index b88709862..92c76f38e 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent.cgi +++ b/fs_selfservice/FS-SelfService/cgi/agent.cgi @@ -14,7 +14,8 @@ use FS::SelfService qw( agent_login agent_logout agent_info agent_list_customers signup_info new_customer customer_info list_pkgs order_pkg - part_svc_info provision_acct unprovision_svc + part_svc_info provision_acct provision_external + unprovision_svc ); $DEBUG = 0; @@ -67,7 +68,7 @@ $session_id = $cgi->param('session'); warn "$me checking action\n" if $DEBUG; $cgi->param('action') =~ - /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|delete_svc|agent_order_pkg|process_order_pkg|logout)$/ + /^(agent_main|signup|process_signup|list_customers|view_customer|agent_provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|agent_order_pkg|process_order_pkg|logout)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -321,6 +322,26 @@ sub process_svc_acct { } +sub process_svc_external { + + my $result = provision_external ( + 'agent_session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( custnum pkgnum svcpart ) + ); + + #warn "$result $result->{'error'}"; + $action = 'agent_provision'; + return { + %{agent_provision()}, + 'message' => $result->{'error'} + ? ''. $result->{'error'}. '' + : $result->{'svc'}. ' setup sucessfully'. + ': serial number '. + sprintf('%010d', $result->{'id'}). '-'. $result->{'title'} + }; + +} + sub delete_svc { my $result = unprovision_svc( 'agent_session_id' => $session_id, diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_external.html b/fs_selfservice/FS-SelfService/cgi/process_svc_external.html new file mode 100644 index 000000000..772cf0838 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_svc_external.html @@ -0,0 +1,16 @@ +<%= $error ? 'MyAccount' : sprintf("Your serial number is %010d-$title", $id) %> +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> + +<%= include('myaccount_menu') %> +
+ +<%= $svc %> setup sucessfully. + +

Your serial number is <%= sprintf("%010d-$title", $id) %> + +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/provision_list.html b/fs_selfservice/FS-SelfService/cgi/provision_list.html index 7e7059388..0c8e05078 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision_list.html +++ b/fs_selfservice/FS-SelfService/cgi/provision_list.html @@ -58,9 +58,22 @@ function areyousure(href, message) { my $td = qq!
{'svcdb'} eq 'svc_external' + #&& $conf->exists('svc_external-skip_manual') + ) { + $link = "${url}process_svc_external;". + "pkgnum=$pkg->{'pkgnum'};". + "svcpart=$part_svc->{'svcpart'}"; + } else { + $link = "${url}provision_svc;". + "pkgnum=$pkg->{'pkgnum'};". + "svcpart=$part_svc->{'svcpart'}"; + } + $OUT .= "
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($county_html, $state_html, $country_html) = + regionselector( $county, $state, $country ); + + "$county_html $state_html"; + %> + *Zip
*Country<%= $country_html %>
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +<%= scalar(@payby) > 1 ? '' : '' %> +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + + my $cardselect = ''; + + my %payby = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD"). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + '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( $account, $aba ) = split('@', $payinfo); + my %paybychecked = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD", $paydate). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + '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) { + if ( scalar(@payby) == 1) { + $OUT .= '"; + } else { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + + } + } + %> + +
'. + qq!!. + "$paybychecked{$_} $paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +<%= + if ( $init_data->{'security_phrase'} ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( scalar(@$pops) ) { + $OUT .= ''; + } else { + $OUT .= popselector($popnum); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector($popnum). '
+

+ diff --git a/fs_selfservice/FS-SelfService/cgi/signup-alternate.html b/fs_selfservice/FS-SelfService/cgi/signup-alternate.html new file mode 100755 index 000000000..490cefa5e --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup-alternate.html @@ -0,0 +1,218 @@ +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
+ +

+ + + + + + + + + + + + + + +<%= if ( $init_data->{'security_phrase'} ) { + < + + + +ENDOUT + } else { + ''; + } +%> + +<%= if ( scalar(@$pops) ) { + ''; + } else { + popselector($popnum); + } +%> + +
*Username
*Password
*Re-enter Password
Security Phrase +
Access number'. + popselector($popnum). '
* required fields + +

First package + + <%= use Tie::IxHash; + my %pkgpart2payby = map { $_->{pkgpart} => $_->{payby}[0] } @{$packages}; + tie my %options, 'Tie::IxHash', + '' => '(none)', + map { $_->{pkgpart} => $_->{pkg} } + sort { $a->{recur} <=> $b->{recur} } + @{$packages} + ; + + use HTML::Widgets::SelectLayers 0.02; + my @form_text = qw( magic ref ss agentnum + last first company address1 address2 + city zip daytime night fax + username _password _password2 sec_phrase ); + my @form_select = qw( state ); #county country + if ( scalar(@$pops) == 0 or scalar(@$pops) == 1 ) { + push @form_text, 'popnum', + } else { + push @form_select, 'popnum', + } + my $widget = new HTML::Widgets::SelectLayers( + options => \%options, + selected_layer => $pkgpart, + form_name => 'dummy', + form_action => $self_url, + form_text => \@form_text, + form_select => \@form_select, + layer_callback => sub { + my $layer = shift; + my $html = qq( ); + + if ( $pkgpart2payby{$layer} eq 'BILL' ) { + $html .= < + + + + + +

+ENDOUT + } elsif ( $pkgpart2payby{$layer} eq 'CARD' ) { + my $postal_checked = ''; + my @invoicing_list = split(', ', $invoicing_list ); + $postal_checked = 'CHECKED' + if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list; + + $invoicing_list= join(', ', grep { $_ ne 'POST' } @invoicing_list ); + + my $expselect = expselect("CARD", $paydate); + + my $cardselect = ''; + + $html .= < +

Billing information + + + + + + + + + + + + + + + + + + + + + + +
Email statement to
*Credit card type$cardselect
*Card number
**Exp$expselect
*Name on card
+* required fields +

+ENDOUT + } else { + $html = <Please select a package.
+ENDOUT + + } + + $html; + + }, + ); + + $widget->html; + + + %> + diff --git a/fs_selfservice/FS-SelfService/cgi/signup-billaddress.html b/fs_selfservice/FS-SelfService/cgi/signup-billaddress.html new file mode 100755 index 000000000..3cf9d2505 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup-billaddress.html @@ -0,0 +1,307 @@ +ISP Signup form + + +ISP Signup form

+<%= $error %> + + + + +Where did you hear about our service?

+Billing Address (where credit card statement is sent) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Exact name on card
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($county_html, $state_html, $country_html) = + regionselector( $county, $state, $country, '', 'changed(this)' ); + + "$county_html $state_html"; + %> + *Zip
*Country<%= $country_html %>
Day Phone
Night Phone
Fax
+ + + +

+Service Address +(>same as billing address)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($ship_county_html, $ship_state_html, $ship_country_html) = + regionselector( $ship_county, + $ship_state, + $ship_country, + 'ship_', + 'changed(this)', + ); + + "$ship_county_html $ship_state_html"; + %> + *Zip
*Country<%= $ship_country_html %>
Day Phone
Night Phone
Fax
+ +* required fields
+ +
Billing information + + +<%= scalar(@payby) > 1 ? '' : '' %> +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + + my $cardselect = ''; + + my %payby = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD"), #. qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD"), #. qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", "12-2037"). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $payby{$payby} .= qq!
CVV2 (help!; + } + } + + my( $account, $aba ) = split('@', $payinfo); + my %paybychecked = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD", $paydate), #. qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD", $paydate), #. qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $paybychecked{$payby} .= qq!
CVV2 (help!; + } + } + + for (@payby) { + if ( scalar(@payby) == 1) { + $OUT .= '"; + } else { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + + } + } + %> + +
'. + qq!!. + "$paybychecked{$_} $paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + + +<%= + if ( $init_data->{'security_phrase'} ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( scalar(@$pops) ) { + $OUT .= ''; + } else { + $OUT .= popselector($popnum); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector($popnum). '
+

+ diff --git a/fs_selfservice/FS-SelfService/cgi/signup-freeoption.html b/fs_selfservice/FS-SelfService/cgi/signup-freeoption.html new file mode 100755 index 000000000..40ad03c0b --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup-freeoption.html @@ -0,0 +1,262 @@ +ISP Signup form + + +ISP Signup form

+<%= $error %> +
+ + + +Where did you hear about our service?

+Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($county_html, $state_html, $country_html) = + regionselector( $county, $state, $country ); + + "$county_html $state_html"; + %> + *Zip
*Country<%= $country_html %>
Day Phone
Night Phone
Fax
* required fields
+
+<%= + my $first_payby = $packages->[0]{'payby'}[0]; + unless ( grep { scalar( @{$_->{'payby'}} ) > 1 + || $_->{'payby'}->[0] ne $first_payby + } @$packages + ) { + @payby = ( $first_payby ); + } + + unless ( scalar(@payby) == 1 && $payby[0] eq 'BILL' ) { + + $OUT .= ' Billing information + + '; + + $OUT .= '' + if scalar(@payby) > 1; + + $OUT .= '
+
Billing type
'; + + } else { + $OUT .= ' + '; + } + +%> + + + + + <%= + + my $cardselect = ''; + + my %payby = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD"). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => <<'END', + + + + +END + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $payby{$payby} .= qq!
CVV2 (help!; + } + } + + my( $account, $aba ) = split('@', $payinfo); + my %paybychecked = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD", $paydate). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => <<'END', + + + + +END + + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $paybychecked{$payby} .= qq!
CVV2 (help!; + } + } + + for (@payby) { + if ( scalar(@payby) == 1) { + $OUT .= '"; + } else { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + + } + } + %> + +
'. + qq!!. + "$paybychecked{$_} $paybychecked{$_}
+<%= unless ( scalar(@payby) == 1 && $payby[0] eq 'BILL' ) { + $OUT .= '* required fields for each billing type'; + } + ''; +%> +

First package + + + + + + + + + + + + + + + + +<%= + if ( $init_data->{'security_phrase'} ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( scalar(@$pops) ) { + $OUT .= ''; + } else { + $OUT .= popselector($popnum); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector($popnum). '
+

+
diff --git a/fs_selfservice/FS-SelfService/cgi/signup-snarf.html b/fs_selfservice/FS-SelfService/cgi/signup-snarf.html new file mode 100755 index 000000000..d167efbf9 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup-snarf.html @@ -0,0 +1,228 @@ +ISP Signup form + + +ISP Signup form

+<%= $error %> +
+ + + +Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*Contact name
(last, first)
, +
Company
*Address
 
*City*State/Country + <%= + ($county_html, $state_html, $country_html) = + regionselector( $county, $state, $country ); + + "$county_html $state_html"; + %> + *Zip
*Country<%= $country_html %>
Day Phone
Night Phone
Fax
* required fields
+
Billing information + + +<%= scalar(@payby) > 1 ? '' : '' %> +
+ + <%= + $OUT .= ' + + Postal mail invoice +
Email invoice +
Billing type
+ + + + <%= + + my $cardselect = ''; + + my %payby = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD"). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD"). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", "12-2037"). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP"), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $payby{$payby} .= qq!
CVV2 (help!; + } + } + + my( $account, $aba ) = split('@', $payinfo); + my %paybychecked = ( + 'CARD' => qq!Credit card
*$cardselect
*Exp !. expselect("CARD", $paydate). qq!
*Name on card
!, + 'DCRD' => qq!Credit card
*$cardselect
*Exp !. expselect("DCRD", $paydate). qq!
*Name on card
!, + 'CHEK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'DCHK' => qq!Electronic check
${r}Account number
${r}ABA/Routing code
${r}Bank name !, + 'LECB' => qq!Phone bill billing
${r}Phone number !, + 'BILL' => qq!Billing
P.O.
*Exp !. expselect("BILL", $paydate). qq!
*Attention
!, + 'COMP' => qq!Complimentary
*Approved by
*Exp !. expselect("COMP", $paydate), + 'PREPAY' => qq!Prepaid card
*!, + ); + + if ( $init_data->{'cvv_enabled'} ) { + foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5 + $paybychecked{$payby} .= qq!
CVV2 (help!; + } + } + + for (@payby) { + if ( scalar(@payby) == 1) { + $OUT .= '"; + } else { + $OUT .= qq!!; + } else { + $OUT .= qq!> $payby{$_}!; + } + + } + } + %> + +
'. + qq!!. + "$paybychecked{$_} $paybychecked{$_}
* required fields for each billing type +

First package + + + + + + + + + + + + + + + + +<%= + if ( $init_data->{'security_phrase'} ) { + $OUT .= < + + + +ENDOUT + } else { + $OUT .= ''; + } +%> +<%= + if ( scalar(@$pops) ) { + $OUT .= ''; + } else { + $OUT .= popselector($popnum); + } +%> +
Username
Password
Re-enter Password
Security Phrase +
Access number'. + popselector($popnum). '
+

Enter up to ten external accounts from which to retrieve email + + + + + + +<%= + for my $num ( 1..10 ) { + no strict 'vars'; + $OUT .= qq!!. + qq!!. + qq!!. + qq!!. + qq!!; + } +%> +
Mail serverUsernamePassword
+ +

+
diff --git a/fs_selfservice/FS-SelfService/cgi/signup.cgi b/fs_selfservice/FS-SelfService/cgi/signup.cgi new file mode 100755 index 000000000..afae1f167 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/signup.cgi @@ -0,0 +1,429 @@ +#!/usr/bin/perl -T +#!/usr/bin/perl -Tw +# +# $Id: signup.cgi,v 1.1 2005-03-12 14:31:50 ivan Exp $ + +use strict; +use vars qw( @payby $cgi $init_data + $self_url $error $agentnum + + $ieak_file $ieak_template + $signup_html $signup_template + $success_html $success_template + $decline_html $decline_template + ); + #$locales $packages + #$pops %pop %popnum2pop + + #$last $first $ss $company $address1 + #$address2 $city $state $county + #$country $zip $daytime $night $fax + + #$ship_last $ship_first $ship_ss $ship_company $ship_address1 + #$ship_address2 $ship_city $ship_state $ship_county + #$ship_country $ship_zip $ship_daytime $ship_night $ship_fax + + #$invoicing_list $payby $payinfo + #$paycvv $paydate $payname $referral_custnum $init_popstate + #$pkgpart $username $_password $_password2 $sec_phrase $popnum + #$refnum + + #$ac $exch $loc + #$email_name $pkg +use subs qw( print_form print_okay print_decline + success_default decline_default + ); +use CGI; +#use CGI::Carp qw(fatalsToBrowser); +use Text::Template; +use Business::CreditCard; +use HTTP::BrowserDetect; +use FS::SelfService qw( signup_info new_customer ); + +#acceptable payment methods +# +#@payby = qw( CARD BILL COMP ); +#@payby = qw( CARD BILL ); +#@payby = qw( CARD ); +@payby = qw( CARD PREPAY ); + +$ieak_file = '/usr/local/freeside/ieak.template'; +$signup_html = -e 'signup.html' + ? 'signup.html' + : '/usr/local/freeside/signup.html'; +$success_html = -e 'success.html' + ? 'success.html' + : '/usr/local/freeside/success.html'; +$decline_html = -e 'decline.html' + ? 'decline.html' + : '/usr/local/freeside/decline.html'; + + +if ( -e $ieak_file ) { + 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_txt =~ s/\r//g; # don't double \r on old templates + $ieak_txt =~ s/\n/\r\n/g; + $ieak_template = new Text::Template ( TYPE => 'STRING', SOURCE => $ieak_txt ) + or die $Text::Template::ERROR; +} else { + $ieak_template = ''; +} + +$agentnum = ''; +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; + if ( $signup_txt =~ + /<\s*INPUT TYPE="?hidden"?\s+NAME="?agentnum"?\s+VALUE="?(\d+)"?\s*>/si + ) { + $agentnum = $1; + } +} else { + #too much maintenance hassle to keep in this file + die "can't find ./signup.html or /usr/local/freeside/signup.html"; + #$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($success_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; +} + +if ( -e $decline_html ) { + my $decline_txt = Text::Template::_load_text($decline_html) + or die $Text::Template::ERROR; + $decline_txt =~ /^(.*)$/s; #untaint the template source - it's trusted + $decline_txt = $1; + $decline_template = new Text::Template ( TYPE => 'STRING', + SOURCE => $decline_txt, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} else { + $decline_template = new Text::Template ( TYPE => 'STRING', + SOURCE => &decline_default, + DELIMITERS => [ '<%=', '%>' ], + ) + or die $Text::Template::ERROR; +} + +$cgi = new CGI; + +$init_data = signup_info( 'agentnum' => $agentnum, + 'promo_code' => scalar($cgi->param('promo_code')), + 'reg_code' => uc(scalar($cgi->param('reg_code'))), + ); +#$error = $init_data->{'error'}; +#$locales = $init_data->{'cust_main_county'}; +#$packages = $init_data->{'part_pkg'}; +#$pops = $init_data->{'svc_acct_pop'}; +#@payby = @{$init_data->{'payby'}} if @{$init_data->{'payby'}}; +#$packages = $init_data->{agentnum2part_pkg}{$agentnum} if $agentnum; + +if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' ) + || ( defined($cgi->param('action')) && $cgi->param('action') eq 'process_signup' ) + ) { + +# if ( $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ ) { +# $state = $1; +# $county = $3 || ''; +# $country = $4; +# } elsif ( $cgi->param('state') =~ /^(\w*)$/ ) { +# $state = $1; +# $cgi->param('county') =~ /^([\w ]*)$/ +# or die "illegal county: ". $cgi->param('county'); +# $county = $1; +# $cgi->param('country') =~ /^(\w+)$/ +# or die "illegal country: ". $cgi->param('country'); +# $country = $1; +# } else { +# die "illegal state: ". $cgi->param('state'); +# } +# if ( $cgi->param('ship_state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ ) { +# $ship_state = $1; +# $ship_county = $3 || ''; +# $ship_country = $4; +# } elsif ( $cgi->param('ship_state') =~ /^(\w*)$/ ) { +# $ship_state = $1; +# $cgi->param('ship_county') =~ /^([\w ]*)$/ +# or die "illegal county: ". $cgi->param('ship_county'); +# $ship_county = $1; +# #$cgi->param('ship_country') =~ /^(\w+)$/ +# $cgi->param('ship_country') =~ /^(\w*)$/ +# or die "illegal ship_country: ". $cgi->param('ship_country'); +# $ship_country = $1; +# #} else { +# # die "illegal ship_state: ". $cgi->param('ship_state'); +# } + + $error = ''; + + $cgi->param('agentnum', $agentnum) if $agentnum; + $cgi->param('reg_code', uc(scalar($cgi->param('reg_code'))) ); + + #false laziness w/agent.cgi, identical except for agentnum + my $payby = $cgi->param('payby'); + if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { + #$payinfo = join('@', map { $cgi->param( $payby. "_payinfo$_" ) } (1,2) ); + $cgi->param('payinfo' => $cgi->param($payby. '_payinfo1'). '@'. + $cgi->param($payby. '_payinfo2') + ); + } else { + $cgi->param('payinfo' => $cgi->param( $payby. '_payinfo' ) ); + } + $cgi->param('paydate' => $cgi->param( $payby. '_month' ). '-'. + $cgi->param( $payby. '_year' ) + ); + $cgi->param('payname' => $cgi->param( $payby. '_payname' ) ); + $cgi->param('paycvv' => defined $cgi->param( $payby. '_paycvv' ) + ? $cgi->param( $payby. '_paycvv' ) + : '' + ); + + if ( $cgi->param('invoicing_list') ) { + $cgi->param('invoicing_list' => $cgi->param('invoicing_list'). ', POST') + if $cgi->param('invoicing_list_POST'); + } else { + $cgi->param('invoicing_list' => 'POST' ); + } + + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat + $cgi->param('_password', ''); + $cgi->param('_password2', ''); + } + + if ( $payby =~ /^(CARD|DCRD)$/ && $cgi->param('CARD_type') ) { + my $payinfo = $cgi->param('payinfo'); + $payinfo =~ s/\D//g; + + $payinfo =~ /^(\d{13,16})$/ + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + $payinfo = $1; + validate($payinfo) + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + cardtype($payinfo) eq $cgi->param('CARD_type') + or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); + } + + unless ( $error ) { + my $rv = new_customer( { + map { $_ => scalar($cgi->param($_)) } + qw( last first ss company + address1 address2 city county state zip country + daytime night fax + + ship_last ship_first ship_company + ship_address1 ship_address2 ship_city ship_county ship_state + ship_zip ship_country + ship_daytime ship_night ship_fax + + payby payinfo paycvv paydate payname invoicing_list + referral_custnum promo_code reg_code + pkgpart username sec_phrase _password popnum refnum + agentnum + ), + grep { /^snarf_/ } $cgi->param + } ); + $error = $rv->{'error'}; + } + #eslaf + + if ( $error eq '_decline' ) { + print_decline(); + } elsif ( $error ) { + #fudge the snarf info + no strict 'refs'; + ${$_} = $cgi->param($_) foreach grep { /^snarf_/ } $cgi->param; + print_form(); + } else { + print_okay( + 'pkgpart' => scalar($cgi->param('pkgpart')), + ); + } + +} else { + $error = ''; +# $last = ''; +# $first = ''; +# $ss = ''; +# $company = ''; +# $address1 = ''; +# $address2 = ''; +# $city = ''; +# $state = $init_data->{statedefault}; +# $county = ''; +# $country = $init_data->{countrydefault}; +# $zip = ''; +# $daytime = ''; +# $night = ''; +# $fax = ''; +# $ship_last = ''; +# $ship_first = ''; +# $ship_company = ''; +# $ship_address1 = ''; +# $ship_address2 = ''; +# $ship_city = ''; +# $ship_state = $init_data->{statedefault}; +# $ship_county = ''; +# $ship_country = $init_data->{countrydefault}; +# $ship_zip = ''; +# $ship_daytime = ''; +# $ship_night = ''; +# $ship_fax = ''; +# $invoicing_list = ''; +# $payby = ''; +# $payinfo = ''; +# $paydate = ''; +# $payname = ''; +# $pkgpart = ''; +# $username = ''; +# $_password = ''; +# $_password2 = ''; +# $sec_phrase = ''; +# $popnum = ''; +# $referral_custnum = $cgi->param('ref') || ''; +# $init_popstate = $cgi->param('init_popstate') || ''; +# $refnum = $init_data->{'refnum'}; + print_form; +} + +sub print_form { + + $error = "Error: $error" if $error; + + my $r = { + $cgi->Vars, + %{$init_data}, + 'error' => $error, + }; + + $r->{referral_custnum} = $r->{'ref'}; + #$cgi->delete('ref'); + #$cgi->delete('init_popstate'); + $r->{self_url} = $cgi->self_url; + + print $cgi->header( '-expires' => 'now' ), + $signup_template->fill_in( PACKAGE => 'FS::SelfService::_signupcgi', + HASH => $r + ); +} + +sub print_decline { + print $cgi->header( '-expires' => 'now' ), + $decline_template->fill_in(); +} + +sub print_okay { + my %param = @_; + my $user_agent = new HTTP::BrowserDetect $ENV{HTTP_USER_AGENT}; + + $cgi->param('username') =~ /^(.+)$/ + or die "fatal: invalid username got past FS::SelfService::new_customer"; + my $username = $1; + $cgi->param('_password') =~ /^(.+)$/ + or die "fatal: invalid password got past FS::SelfService::new_customer"; + my $password = $1; + ( $cgi->param('first'). ' '. $cgi->param('last') ) =~ /^(.*)$/ + or die "fatal: invalid email_name got past FS::SelfService::new_customer"; + my $email_name = $1; #global for template + + #my %pop = (); + my %popnum2pop = (); + foreach ( @{ $init_data->{'svc_acct_pop'} } ) { + #push @{ $pop{ $_->{state} }->{ $_->{ac} } }, $_; + $popnum2pop{$_->{popnum}} = $_; + } + + my( $ac, $exch, $loc); + my $pop = $popnum2pop{$cgi->param('popnum')}; + #or die "fatal: invalid popnum got past FS::SelfService::new_customer"; + if ( $pop ) { + ( $ac, $exch, $loc ) = ( $pop->{'ac'}, $pop->{'exch'}, $pop->{'loc'} ); + } else { + ( $ac, $exch, $loc ) = ( '', '', ''); #presumably you're not using them. + } + + #global for template + my $pkg = ( grep { $_->{'pkgpart'} eq $param{'pkgpart'} } + @{ $init_data->{'part_pkg'} } + )[0]->{'pkg'}; + + if ( $ieak_template && $user_agent->windows && $user_agent->ie ) { + #send an IEAK config + print $cgi->header('application/x-Internet-signup'), + $ieak_template->fill_in(); + } else { #send a simple confirmation + print $cgi->header( '-expires' => 'now' ), + $success_template->fill_in( HASH => { + username => $username, + password => $password, + _password => $password, + email_name => $email_name, + ac => $ac, + exch => $exch, + loc => $loc, + pkg => $pkg, + }); + } +} + +sub success_default { #html to use if you don't specify a success file + <<'END'; +Signup successful +Signup successful

+Thanks for signing up! +

+Signup information for <%= $email_name %>: +

+Username: <%= $username %>
+Password: <%= $password %>
+Access number: (<%= $ac %>) / <%= $exch %> - <%= $local %>
+Package: <%= $pkg %>
+ +END +} + +sub decline_default { #html to use if there is a decline + <<'END'; +Processing error +Processing error

+There has been an error processing your account. Please contact customer +support. + +END +} + +# subs for the templates... + +package FS::SelfService::_signupcgi; +use HTML::Entities; +use FS::SelfService qw(regionselector expselect popselector); + diff --git a/fs_selfservice/FS-SelfService/ieak.template b/fs_selfservice/FS-SelfService/ieak.template new file mode 100755 index 000000000..52edaa951 --- /dev/null +++ b/fs_selfservice/FS-SelfService/ieak.template @@ -0,0 +1,40 @@ +[Entry] +Entry_Name = The Internet +[Phone] +Dial_As_Is=no +Phone_Number = { $exch. $loc } +Area_Code = { $ac } +Country_Code = 1 +Country_Id = 1 +[Server] +Type = PPP +SW_Compress = Yes +PW_Encrypt = Yes +Negotiate_TCP/IP = Yes +Disable_LCP = No +[TCP/IP] +Specify_IP_Address = No +Specity_Server_Address = No +IP_Header_Compress = Yes +Gateway_On_Remote = Yes +[User] +Name = { $username } +Password = { $password } +Display_Password = Yes +[Internet_Mail] +Email_Name = { $email_name } +Email_Address = { $username }\@domain.tld +POP_Server = mail.domain.tld +POP_Server_Port_Number = 110 +POP_Login_Name = { $username } +POP_Login_Password = { $password } +SMTP_Server = mail.domain.tld +SMTP_Server_Port_Number = 25 +Install_Mail = 1 +[Internet_News] +NNTP_Server = news.domain.tld +NNTP_Server_Port_Number = 119 +Logon_Required = No +Install_News = 1 +[Branding] +Window_Title = The Internet -- cgit v1.2.1 From a6cbda0b7e6779b89abc1d466af9c3a880d8e030 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 12 Mar 2005 14:35:12 +0000 Subject: - bring prepaid support into this century (close: Bug#1124) - finally get rid of fs_signup (everything is in fs_selfservice now) (Bug#413) - organize main menu sysadmin section so it is slightly less confusing --- fs_selfservice/FS-SelfService/cgi/signup.cgi | 98 +-------------- fs_selfservice/FS-SelfService/cgi/signup.html | 9 +- fs_selfservice/FS-SelfService/cgi/stateselect.html | 134 +++++++++++++++++++++ fs_selfservice/FS-SelfService/cgi/success.html | 11 ++ 4 files changed, 152 insertions(+), 100 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/stateselect.html create mode 100644 fs_selfservice/FS-SelfService/cgi/success.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/signup.cgi b/fs_selfservice/FS-SelfService/cgi/signup.cgi index afae1f167..d2ad0d64b 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.cgi +++ b/fs_selfservice/FS-SelfService/cgi/signup.cgi @@ -1,7 +1,7 @@ #!/usr/bin/perl -T #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.1 2005-03-12 14:31:50 ivan Exp $ +# $Id: signup.cgi,v 1.2 2005-03-12 14:35:12 ivan Exp $ use strict; use vars qw( @payby $cgi $init_data @@ -12,24 +12,7 @@ use vars qw( @payby $cgi $init_data $success_html $success_template $decline_html $decline_template ); - #$locales $packages - #$pops %pop %popnum2pop - #$last $first $ss $company $address1 - #$address2 $city $state $county - #$country $zip $daytime $night $fax - - #$ship_last $ship_first $ship_ss $ship_company $ship_address1 - #$ship_address2 $ship_city $ship_state $ship_county - #$ship_country $ship_zip $ship_daytime $ship_night $ship_fax - - #$invoicing_list $payby $payinfo - #$paycvv $paydate $payname $referral_custnum $init_popstate - #$pkgpart $username $_password $_password2 $sec_phrase $popnum - #$refnum - - #$ac $exch $loc - #$email_name $pkg use subs qw( print_form print_okay print_decline success_default decline_default ); @@ -140,49 +123,11 @@ $init_data = signup_info( 'agentnum' => $agentnum, 'promo_code' => scalar($cgi->param('promo_code')), 'reg_code' => uc(scalar($cgi->param('reg_code'))), ); -#$error = $init_data->{'error'}; -#$locales = $init_data->{'cust_main_county'}; -#$packages = $init_data->{'part_pkg'}; -#$pops = $init_data->{'svc_acct_pop'}; -#@payby = @{$init_data->{'payby'}} if @{$init_data->{'payby'}}; -#$packages = $init_data->{agentnum2part_pkg}{$agentnum} if $agentnum; if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' ) || ( defined($cgi->param('action')) && $cgi->param('action') eq 'process_signup' ) ) { -# if ( $cgi->param('state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ ) { -# $state = $1; -# $county = $3 || ''; -# $country = $4; -# } elsif ( $cgi->param('state') =~ /^(\w*)$/ ) { -# $state = $1; -# $cgi->param('county') =~ /^([\w ]*)$/ -# or die "illegal county: ". $cgi->param('county'); -# $county = $1; -# $cgi->param('country') =~ /^(\w+)$/ -# or die "illegal country: ". $cgi->param('country'); -# $country = $1; -# } else { -# die "illegal state: ". $cgi->param('state'); -# } -# if ( $cgi->param('ship_state') =~ /^(\w*)( \(([\w ]+)\))? ?\/ ?(\w+)$/ ) { -# $ship_state = $1; -# $ship_county = $3 || ''; -# $ship_country = $4; -# } elsif ( $cgi->param('ship_state') =~ /^(\w*)$/ ) { -# $ship_state = $1; -# $cgi->param('ship_county') =~ /^([\w ]*)$/ -# or die "illegal county: ". $cgi->param('ship_county'); -# $ship_county = $1; -# #$cgi->param('ship_country') =~ /^(\w+)$/ -# $cgi->param('ship_country') =~ /^(\w*)$/ -# or die "illegal ship_country: ". $cgi->param('ship_country'); -# $ship_country = $1; -# #} else { -# # die "illegal ship_state: ". $cgi->param('ship_state'); -# } - $error = ''; $cgi->param('agentnum', $agentnum) if $agentnum; @@ -271,47 +216,6 @@ if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' ) } else { $error = ''; -# $last = ''; -# $first = ''; -# $ss = ''; -# $company = ''; -# $address1 = ''; -# $address2 = ''; -# $city = ''; -# $state = $init_data->{statedefault}; -# $county = ''; -# $country = $init_data->{countrydefault}; -# $zip = ''; -# $daytime = ''; -# $night = ''; -# $fax = ''; -# $ship_last = ''; -# $ship_first = ''; -# $ship_company = ''; -# $ship_address1 = ''; -# $ship_address2 = ''; -# $ship_city = ''; -# $ship_state = $init_data->{statedefault}; -# $ship_county = ''; -# $ship_country = $init_data->{countrydefault}; -# $ship_zip = ''; -# $ship_daytime = ''; -# $ship_night = ''; -# $ship_fax = ''; -# $invoicing_list = ''; -# $payby = ''; -# $payinfo = ''; -# $paydate = ''; -# $payname = ''; -# $pkgpart = ''; -# $username = ''; -# $_password = ''; -# $_password2 = ''; -# $sec_phrase = ''; -# $popnum = ''; -# $referral_custnum = $cgi->param('ref') || ''; -# $init_popstate = $cgi->param('init_popstate') || ''; -# $refnum = $init_data->{'refnum'}; print_form; } diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html index 3532527a2..2ab07b37e 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.html +++ b/fs_selfservice/FS-SelfService/cgi/signup.html @@ -14,10 +14,10 @@ //--> <%= $agent || 'ISP' %> Signup form

<%= $error %> -
+ - + Where did you hear about our service?
* required fields for each billing type

First package + + -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fs_selfservice/FS-SelfService/cgi/success.html b/fs_selfservice/FS-SelfService/cgi/success.html new file mode 100644 index 000000000..397cc6c30 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/success.html @@ -0,0 +1,11 @@ +Signup successful +Signup successful

+Thanks for signing up! +

+Signup information for <%= $email_name %>: +

+Username: <%= $username %>
+Password: <%= $password %>
+Access number: (<%= $ac %>) / <%= $exch %> - <%= $local %>
+Package: <%= $pkg %>
+ -- cgit v1.2.1 From 36939d45fbe729c953a81354030bedcb17fad91f Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Mar 2005 22:41:10 +0000 Subject: better self-service debugging, don't point to install.html for suEXEC/setuid in self-service setup docs --- fs_selfservice/FS-SelfService/SelfService.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 6e3ca3b5a..0f581758b 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1,7 +1,7 @@ package FS::SelfService; use strict; -use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload $tag); +use vars qw($VERSION @ISA @EXPORT_OK $dir $socket %autoload $tag); use Exporter; use Socket; use FileHandle; @@ -13,7 +13,8 @@ $VERSION = '0.03'; @ISA = qw( Exporter ); -$socket = "/usr/local/freeside/selfservice_socket"; +$dir = "/usr/local/freeside"; +$socket = "$dir/selfservice_socket"; $socket .= '.'.$tag if defined $tag && length($tag); #maybe should ask ClientAPI for this list @@ -57,6 +58,11 @@ $ENV{'BASH_ENV'} = ''; my $freeside_uid = scalar(getpwnam('freeside')); die "not running as the freeside user\n" if $> != $freeside_uid; +-e $dir or die "FATAL: $dir doesn't exist!"; +-d $dir or die "FATAL: $dir isn't a directory!"; +-r $dir or die "FATAL: Can't read $dir as freeside user!"; +-x $dir or die "FATAL: $dir not searchable (executable) as freeside user!"; + foreach my $autoload ( keys %autoload ) { my $eval = @@ -81,7 +87,7 @@ foreach my $autoload ( keys %autoload ) { sub simple_packet { my $packet = shift; socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; - connect(SOCK, sockaddr_un($socket)) or die "connect: $!"; + connect(SOCK, sockaddr_un($socket)) or die "connect to $socket: $!"; nstore_fd($packet, \*SOCK) or die "can't send packet: $!"; SOCK->flush; -- cgit v1.2.1 From 04cc48bd2a049909af54b9e58afebffe51cdd1b2 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 8 Jun 2005 09:03:06 +0000 Subject: prepaid card recharge --- fs_selfservice/FS-SelfService/SelfService.pm | 1 + .../FS-SelfService/cgi/agent_delete_svc.html | 1 - fs_selfservice/FS-SelfService/cgi/delete_svc.html | 1 - .../FS-SelfService/cgi/make_payment.html | 1 - fs_selfservice/FS-SelfService/cgi/myaccount.html | 1 - .../FS-SelfService/cgi/myaccount_menu.html | 92 ++++++++++++++++++++-- .../FS-SelfService/cgi/payment_results.html | 1 - .../FS-SelfService/cgi/process_svc_acct.html | 1 - .../FS-SelfService/cgi/process_svc_external.html | 1 - fs_selfservice/FS-SelfService/cgi/provision.html | 1 - .../FS-SelfService/cgi/provision_svc_acct.html | 1 - .../FS-SelfService/cgi/recharge_prepay.html | 36 +++++++++ .../FS-SelfService/cgi/recharge_results.html | 24 ++++++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 20 ++++- .../FS-SelfService/cgi/view_invoice.html | 1 - 15 files changed, 164 insertions(+), 19 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/recharge_prepay.html create mode 100644 fs_selfservice/FS-SelfService/cgi/recharge_results.html (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 0f581758b..1e6c4ec0c 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -31,6 +31,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'cancel' => 'MyAccount/cancel', #add to ss cgi! 'payment_info' => 'MyAccount/payment_info', 'process_payment' => 'MyAccount/process_payment', + 'process_prepay' => 'MyAccount/process_prepay', 'list_pkgs' => 'MyAccount/list_pkgs', #add to ss cgi! 'order_pkg' => 'MyAccount/order_pkg', #add to ss cgi! 'cancel_pkg' => 'MyAccount/cancel_pkg', #add to ss cgi! diff --git a/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html index e8be07ed1..7a2b75071 100644 --- a/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html +++ b/fs_selfservice/FS-SelfService/cgi/agent_delete_svc.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
<%= $small_custview %> diff --git a/fs_selfservice/FS-SelfService/cgi/delete_svc.html b/fs_selfservice/FS-SelfService/cgi/delete_svc.html index 16054a77c..8468deb4b 100644 --- a/fs_selfservice/FS-SelfService/cgi/delete_svc.html +++ b/fs_selfservice/FS-SelfService/cgi/delete_svc.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index 3522c0867..1bbbe90b2 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
Make a payment

diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index 9997d7059..546ca1112 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index ba3b3f2ff..f2e5e998e 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -1,13 +1,89 @@ <%= $url = "$selfurl?session=$session_id;action="; ''; %> + diff --git a/fs_selfservice/FS-SelfService/cgi/payment_results.html b/fs_selfservice/FS-SelfService/cgi/payment_results.html index 44289deba..de6c54dae 100644 --- a/fs_selfservice/FS-SelfService/cgi/payment_results.html +++ b/fs_selfservice/FS-SelfService/cgi/payment_results.html @@ -1,7 +1,6 @@ MyAccountMyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> -
-Overview

-Change payment info *

-Change service address *

-Setup my services

-Purchase additional package *

- -Change password(s)

-Logout

+ + +<%= + +my @menu = ( +{ title=>' ' }, +{ title=>'Overview', url=>'myaccount', size=>'+1', }, +{ title=>' ' }, + +{ title=>'Purchase', size=>'+1', }, + { title=>'Purchase additional package*', url=>'order', 'indent'=>2 }, +); + +if ( 1 ) { #XXXFIXME "enable selfservice prepay features" flag or something, eventually per-pkg or something really fancy + + push @menu, ( + { title=>'Recharge my account with a credit card', + url=>'make_payment', indent=>2 }, + { title=>'Recharge my account with a prepaid card', + url=>'recharge_prepay', indent=>2 }, + ); + +} + +push @menu, ( + +{ title=>' ' }, + +{ title=>'Setup my services', url=>'provision', size=>'+1', }, + +{ title=>' ' }, + +{ title=>'Change my information', size=>'+1', }, + { title=>'Change payment information*', url=>'change_bill', indent=>2 }, + { title=>'Change service address*', url=>'change_ship', indent=>2 }, + { title=>'Change password(s)*', url=>'hmmmFIXME', indent=>2 }, + +{ title=>' ' }, + +{ title=>'Logout', url=>'logout', size=>'+1', }, + +); + +foreach my $item ( @menu ) { + + $OUT .= '{'url'} && $action eq $item->{'url'} ) { + $OUT .= ' BGCOLOR="#eeeeee" '. + ' STYLE="border-top: 1px solid black;'. + ' border-left: 1px solid black;'. + ' border-bottom: 1px solid black"'; + } else { + $OUT .= ' STYLE="border-right: 1px solid black"'; + } + $OUT.='>'; + + $OUT .= '' + if exists $item->{'size'}; + + $OUT .= ' ' x $item->{'indent'} + if exists $item->{'indent'}; + + $OUT .= '' + if exists $item->{'url'} && $action ne $item->{'url'}; + + $item->{'title'} =~ s/ / /g; + $OUT .= $item->{'title'}; + + $OUT .= '' + if exists $item->{'size'}; + + $OUT .= '' + if exists $item->{'url'} && $action ne $item->{'url'}; + + $OUT .= ''; + +} + +%> + +
+ +(tempFIXME) Change password(s)

* coming soon
<%= include('myaccount_menu') %>
Payment results

diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html index 7052059c4..200a80dc9 100644 --- a/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html +++ b/fs_selfservice/FS-SelfService/cgi/process_svc_acct.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
diff --git a/fs_selfservice/FS-SelfService/cgi/process_svc_external.html b/fs_selfservice/FS-SelfService/cgi/process_svc_external.html index 772cf0838..2328fa10f 100644 --- a/fs_selfservice/FS-SelfService/cgi/process_svc_external.html +++ b/fs_selfservice/FS-SelfService/cgi/process_svc_external.html @@ -1,7 +1,6 @@ <%= $error ? 'MyAccount' : sprintf("Your serial number is %010d-$title", $id) %> MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
diff --git a/fs_selfservice/FS-SelfService/cgi/provision.html b/fs_selfservice/FS-SelfService/cgi/provision.html index 6d80e89db..d31e6070b 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision.html +++ b/fs_selfservice/FS-SelfService/cgi/provision.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
<%= include('provision_list') %> diff --git a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html index cf3585721..50540742a 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html +++ b/fs_selfservice/FS-SelfService/cgi/provision_svc_acct.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
<%= include('svc_acct') %> diff --git a/fs_selfservice/FS-SelfService/cgi/recharge_prepay.html b/fs_selfservice/FS-SelfService/cgi/recharge_prepay.html new file mode 100644 index 000000000..f8584597a --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/recharge_prepay.html @@ -0,0 +1,36 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> +
+Recharge with prepaid card

+
+ + + + + + + + +
Prepaid card number + +
+
+ + +
+
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/recharge_results.html b/fs_selfservice/FS-SelfService/cgi/recharge_results.html new file mode 100644 index 000000000..ec3ea2c7a --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/recharge_results.html @@ -0,0 +1,24 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> +
+Recharge results

+<%= if ( $error ) { + $OUT .= qq!Error processing your prepaid card: $error!; +} else { + $OUT .= 'Prepaid card recharge sucessful!

'; + + $OUT .= '$'. sprintf('%.2f', $amount). ' added to your account.

' + if $amount; + + $OUT .= $duration. ' added to your account.

' + if $seconds; + + $OUT .= 'Thank you.'; +} %> +
+
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 0816758fb..034a684c6 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -9,6 +9,7 @@ use Text::Template; use HTML::Entities; use FS::SelfService qw( login customer_info invoice payment_info process_payment + process_prepay list_pkgs part_svc_info provision_acct provision_external unprovision_svc @@ -61,7 +62,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc)$/ + /^(myaccount|view_invoice|make_payment|payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -79,6 +80,7 @@ if ( $result->{error} eq "Can't resume session" ) { #ick warn "processing template $action\n"; do_template($action, { 'session_id' => $session_id, + 'action' => $action, #so the menu knows what tab we're on... %{$result} }); @@ -173,6 +175,22 @@ sub payment_results { } +sub recharge_prepay { + customer_info( 'session_id' => $session_id ); +} + +sub recharge_results { + + my $prepaid_cardnum = $cgi->param('prepaid_cardnum'); + $prepaid_cardnum =~ s/\W//g; + $prepaid_cardnum =~ /^(\w*)$/ or die "illegal prepaid card number"; + $prepaid_cardnum = $1; + + process_prepay ( 'session_id' => $session_id, + 'prepaid_cardnum' => $prepaid_cardnum, + ); +} + sub logout { FS::SelfService::logout( 'session_id' => $session_id ); } diff --git a/fs_selfservice/FS-SelfService/cgi/view_invoice.html b/fs_selfservice/FS-SelfService/cgi/view_invoice.html index 46f731890..72d061980 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_invoice.html +++ b/fs_selfservice/FS-SelfService/cgi/view_invoice.html @@ -1,7 +1,6 @@ MyAccount MyAccount

<%= $url = "$selfurl?session=$session_id;action="; ''; %> - <%= include('myaccount_menu') %>
-- cgit v1.2.1 From 2b49cbe76b94c6c1561aa2bf37beba7d47591190 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 24 Aug 2005 13:22:27 +0000 Subject: customer edit: abstract out billing info to billing.html, re-do payment type selection with HTML::Widgets::SelectLayers, add Switch/Solo/Maestro support for start date & issue #. customer view: re-order fields for consistency. selfservice API: support paystart_month, paystart_year, payissue and payip in MyAccount::process_payment and ::edit_info and Signup::new_customer, FS::cust_main::realtime_bop: support paystart_month paystart_year payissue payip fields --- fs_selfservice/FS-SelfService/SelfService.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 1e6c4ec0c..ad909332c 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -163,6 +163,10 @@ FS::SelfService - Freeside self-service API 'payby' => $payby, 'payinfo' => $payinfo, 'paycvv' => $paycvv, + 'paystart_month' => $paystart_month + 'paystart_year' => $paystart_year, + 'payissue' => $payissue, + 'payip' => $payip 'paydate' => $paydate, 'payname' => $payname, 'invoicing_list' => $invoicing_list, -- cgit v1.2.1 From a223750d9f7a4548319007807c3564ff3a8ebe40 Mon Sep 17 00:00:00 2001 From: rsiddall Date: Fri, 30 Dec 2005 02:41:22 +0000 Subject: Fixing a few typos. --- fs_selfservice/FS-SelfService/SelfService.pm | 2 +- fs_selfservice/FS-SelfService/cgi/provision_list.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index ad909332c..bfce1287b 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -1070,7 +1070,7 @@ END Note: Resellers can also use the B and B functions with their active session, and the B and B functions -with their active session and an additonal I parameter. +with their active session and an additional I parameter. =over 4 diff --git a/fs_selfservice/FS-SelfService/cgi/provision_list.html b/fs_selfservice/FS-SelfService/cgi/provision_list.html index 0c8e05078..0f68dfe3c 100644 --- a/fs_selfservice/FS-SelfService/cgi/provision_list.html +++ b/fs_selfservice/FS-SelfService/cgi/provision_list.html @@ -41,7 +41,7 @@ function areyousure(href, message) { #} unless ( $cust_svc->{'svcnum'} == $svcnum ) { - $OUT .= qq!(!. + $OUT .= qq!(!. 'delete)'; } -- cgit v1.2.1