Netscape CCK patch

Kristian Hoffmann khoff at pc-intouch.com
Sun Apr 9 00:35:46 PDT 2000


Here's the patch, written by Mark ad myself, for fs_signup plus a few pm's
so that it will configure netscape if you use it's internet account setup
wizard.  It also includes changes so that you can enter an "Agent ID" so
you can track something like a reseller program with unique identifiers on
your cds.  I can send the patch without those changes if someone would
rather have that. Everything you need to know about the netscape cck and
setting it up to work with this can be found at...

http://help.netscape.com/products/client/mc/acctproc4.html

-Kristian
<khoff at pc-intouch.com>

-------------- next part --------------
diff -r -u --new-file fs-1.2.3-orig/fs_signup/FS-SignupClient/SignupClient.pm fs-1.2.3/fs_signup/FS-SignupClient/SignupClient.pm
--- fs-1.2.3-orig/fs_signup/FS-SignupClient/SignupClient.pm	Tue Feb  1 23:44:00 2000
+++ fs-1.2.3/fs_signup/FS-SignupClient/SignupClient.pm	Sun Apr  2 03:46:00 2000
@@ -58,6 +58,7 @@
     'username'       => $username,
     '_password'       => $password,
     'popnum'         => $popnum,
+    'agentnum'       => $agentnum,
   } );
 
 =head1 DESCRIPTION
@@ -177,6 +178,7 @@
   username
   _password
   popnum
+  agentnum
 
 Returns a scalar error message, or the empty string for success.
 
@@ -192,7 +194,7 @@
   print SOCK join("\n", map { $hashref->{$_} } qw(
     first last ss company address1 address2 city county state zip country
     daytime night fax payby payinfo paydate payname invoicing_list
-    pkgpart username _password popnum
+    pkgpart username _password popnum agentnum
   ) ), "\n";
   SOCK->flush;
 
diff -r -u --new-file fs-1.2.3-orig/fs_signup/FS-SignupClient/cgi/signup.cgi fs-1.2.3/fs_signup/FS-SignupClient/cgi/signup.cgi
--- fs-1.2.3-orig/fs_signup/FS-SignupClient/cgi/signup.cgi	Wed Mar  1 00:14:30 2000
+++ fs-1.2.3/fs_signup/FS-SignupClient/cgi/signup.cgi	Sat Apr  8 12:50:39 2000
@@ -7,9 +7,9 @@
              $last $first $ss $company $address1 $address2 $city $state $county
              $country $zip $daytime $night $fax $invoicing_list $payby $payinfo
              $paydate $payname $pkgpart $username $password $popnum
-             $ieak_file $ieak_template $ac $exch $loc
+             $ieak_file $ieak_template $cck_file $cck_template $ac $exch $loc
            );
-             #$ieak_docroot $ieak_baseurl
+             #$ieak_docroot $ieak_baseurl $cck_docroot $cck_baseurl
 use subs qw( print_form print_okay expselect );
 
 use CGI;
@@ -22,10 +22,11 @@
 #
 #@payby = qw( CARD BILL COMP );
 #@payby = qw( CARD BILL );
-#@payby = qw( CARD );
- at payby = qw( CARD PREPAY );
+ at payby = qw( CARD );
+#@payby = qw( CARD PREPAY );
 
 $ieak_file = '/usr/local/freeside/ieak.template';
+$cck_file = '/usr/local/freeside/cck.template';
 
 if ( -e $ieak_file ) {
   $ieak_template = new Text::Template ( TYPE => 'FILE', SOURCE => $ieak_file )
@@ -39,6 +40,7 @@
 #	#
 #	$ieak_docroot = "/var/www/sisd.420.am/freeside/ieak";
 #	$ieak_baseurl = "http://sisd.420.am/freeside/ieak";
+#
 
 #srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
 
@@ -148,7 +150,6 @@
   <TD COLSPAN=3><INPUT TYPE="text" NAME="last" VALUE="$last">,
                 <INPUT TYPE="text" NAME="first" VALUE="$first"></TD>
   <TD ALIGN="right">SS#</TD>
-  <TD><INPUT TYPE="text" NAME="ss" SIZE=11 VALUE="$ss"></TD>
 </TR>
 <TR>
   <TD ALIGN="right">Company</TD>
@@ -293,15 +294,21 @@
 
 sub print_okay {
   my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
+
+  $cgi->param('username') =~ /^(\w{3,8})$/ or die "ERROR: Invalid username at print_okay phase!\n";
+  my $username = $1;
+  $cgi->param('_password') =~ /^(.{3,8})$/ or die "ERROR: Invalid password at print_okay phase!\n";
+  my $password = $1;
+  ($cgi->param('first'). ' '. $cgi->param('last')) =~ /^(.*)$/ or die "ERROR: Invalid email_name at print_okay phase!\n";
+  my $email_name = $1;
+
+
   if ( $ieak_template
        && $user_agent->platform eq 'ia32'
        && $user_agent->os =~ /^win/
        && ($user_agent->browser)[0] eq 'IE'
      )
   { #send an IEAK config
-    my $username = $cgi->param('username');
-    my $password = $cgi->param('_password');
-    my $email_name = $cgi->param('first'). ' '. $cgi->param('last');
 
     print $cgi->header('application/x-Internet-signup'),
           $ieak_template->fill_in();
@@ -312,6 +319,38 @@
 #    close INS_FILE;
 #    print $cgi->redirect("$ieak_docroot/$ins_file");
 
+  } elsif ( $user_agent->platform eq 'ia32'
+       && $user_agent->os =~ /^win/
+       && ($user_agent->browser)[0] eq 'Netscape'
+    )
+  { #send a Netscape config
+
+  print $cgi->header('application/x-netscape-autoconfigure-dialer-v2');
+
+  open(CCK, "<$cck_file") or
+    print pack("N", 6), "STATUS", pack("N", 5), "ERROR" and
+    die "Can't open file $cck_file";
+
+  my $pop = pop_info($cgi->param('popnum')) or die "POP #$popnum not found";
+
+  warn join ' ', 'pop:', %{$pop};
+  warn join ' ', 'cgi:', map { $_, $cgi->param($_) } $cgi->param;
+
+  my %cck_user_info;
+  $cck_user_info{username} = $cgi->param('username');
+  $cck_user_info{password} = $cgi->param('_password');
+  $cck_user_info{ac} = $pop->{'ac'};
+  $cck_user_info{exch} = $pop->{'exch'};
+  $cck_user_info{loc} = $pop->{'loc'};
+
+  warn join " ", '%cck_user_info:', %cck_user_info;
+
+  while (<CCK>) {
+    s/var_([a-z]+)/$cck_user_info{$1}/g;
+    m/(.*)\t(.*)/ &&
+    print pack("N", length($1)), $1, pack("N", length($2)), $2;
+  }
+
   } else { #send a simple confirmation
     print $cgi->header( '-expires' => 'now' ), <<END;
 <HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
@@ -323,6 +362,15 @@
   }
 }
 
+sub pop_info {
+  my $popnum = shift;
+  my $pop;
+
+  foreach $pop ( @{$pops} ) {
+    if ($pop->{'popnum'} == $popnum) { return $pop }
+  }
+}
+
 sub expselect {
   my $prefix = shift;
   my $date = shift || '';
@@ -348,4 +396,5 @@
 
   $return;
 }
+
 
diff -r -u --new-file fs-1.2.3-orig/fs_signup/FS-SignupClient/fs_signupd fs-1.2.3/fs_signup/FS-SignupClient/fs_signupd
--- fs-1.2.3-orig/fs_signup/FS-SignupClient/fs_signupd	Fri Jan 28 14:49:28 2000
+++ fs-1.2.3/fs_signup/FS-SignupClient/fs_signupd	Sun Apr  2 03:47:58 2000
@@ -117,15 +117,15 @@
       $first, $last, $ss, $company, $address1, $address2, $city, $county,
       $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
       $paydate, $payname, $invoicing_list, $pkgpart, $username, $password,
-      $popnum,
-    ) = map { scalar(<Client>) } ( 1 .. 23 );
+      $popnum, $agentnum,
+    ) = map { scalar(<Client>) } ( 1 .. 24 );
 
     warn "[fs_signupd] sending customer data to remote server...\n" if $Debug;
     print 
       $first, $last, $ss, $company, $address1, $address2, $city, $county,
       $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
       $paydate, $payname, $invoicing_list, $pkgpart, $username, $password,
-      $popnum,
+      $popnum, $agentnum,
     ;
 
     warn "[fs_signupd] reading error from remote server...\n" if $Debug;
diff -r -u --new-file fs-1.2.3-orig/fs_signup/cck.template fs-1.2.3/fs_signup/cck.template
--- fs-1.2.3-orig/fs_signup/cck.template	Wed Dec 31 16:00:00 1969
+++ fs-1.2.3/fs_signup/cck.template	Tue Mar  7 00:29:00 2000
@@ -0,0 +1,15 @@
+SITE_FILE	8chrfile
+SITE_NAME	YourISP
+LOGIN	{ $username )
+PASSWORD	{ $password }
+PHONE_NUM	+1({ $ac }){ $ex }-{ $local } 
+DNS_ADDR	10.0.0.1
+DNS_ADDR2	10.0.0.2
+NNTP_HOST	news.yourisp.com
+SMTP_HOST	mail.yourisp.com
+DOMAIN_NAME	yourisp.com
+POP_SERVER	{ $username }@mail.yourisp.com
+POP_PASSWORD	{ $password }
+HOME_URL	http://www.yourisp.com
+EMAIL_ADDR	{ $username }@yourisp.com
+
diff -r -u --new-file fs-1.2.3-orig/fs_signup/fs_signup_server fs-1.2.3/fs_signup/fs_signup_server
--- fs-1.2.3-orig/fs_signup/fs_signup_server	Wed Feb  2 12:22:18 2000
+++ fs-1.2.3/fs_signup/fs_signup_server	Sun Apr  2 04:01:17 2000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -Tw
+#!/usr/bin/perl
 #
 # fs_signup_server
 #
@@ -10,10 +10,11 @@
 use FS::Record qw( qsearch qsearchs );
 use FS::cust_main_county;
 use FS::cust_main;
+#use Devel::Trace;
 
 use vars qw( $opt $Debug );
 
-$Debug = 0;
+#$Debug = 1;
 
 my @payby = qw(CARD PREPAY);
 
@@ -22,8 +23,8 @@
 
 my $machine = shift or die &usage;
 
-my $agentnum = shift or die &usage;
-my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ) or die &usage;
+my $signup_agentnum = shift or die &usage;
+my $agent = qsearchs( 'agent', { 'agentnum' => $signup_agentnum } ) or die &usage;
 my $pkgpart = $agent->pkgpart_hashref;
 
 my $refnum = shift or die &usage;
@@ -57,7 +58,7 @@
   my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
     qsearch( 'part_pkg', {} );
   print $writer $data = join("\n",
-    ( scalar(@part_pkg) || die "no usable package definitions, agent $agentnum" ),
+    ( scalar(@part_pkg) || die "no usable package definitions, agent $signup_agentnum" ),
     map {
       $_->pkgpart,
       $_->pkg,
@@ -87,8 +88,8 @@
       $first, $last, $ss, $company, $address1, $address2, $city, $county,
       $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
       $paydate, $payname, $invoicing_list, $pkgpart, $username, $password,
-      $popnum,
-    ) = map { scalar(<$reader>) } ( 1 .. 23 ) );
+      $popnum, $agentnum,
+    ) = map { scalar(<$reader>) } ( 1 .. 24 ) );
 
     warn "[fs_signup_server] Processing signup...\n" if $Debug;
 
@@ -126,14 +127,17 @@
 
     $error ||= $cust_main->check_invoicing_list( \@invoicing_list );
 
+    $error ||= "Unknown Agent ID.  Please Re-enter." unless
+      qsearchs( 'agent', { 'agentnum' => $agentnum } );
+
     my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } )
       or $error ||= "WARNING: unknown pkgpart $pkgpart";
     my $svcpart = $part_pkg->svcpart unless $error;
 
     # this should wind up in FS::cust_pkg!
-    my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } );
+    my $agent = qsearchs( 'agent', { 'agentnum' => $signup_agentnum } );
     my $pkgpart_href = $agent->pkgpart_hashref;
-    $error ||= "WARNING: agent $agentnum can't purchase pkgpart $pkgpart"
+    $error ||= "WARNING: agent $signup_agentnum can't purchase pkgpart $pkgpart"
       unless $pkgpart_href->{ $pkgpart };
 
     my $cust_pkg = new FS::cust_pkg ( {


More information about the freeside-users mailing list