This commit was manufactured by cvs2svn to create tag 'freeside_1_4_1beta1'. freeside_1_4_1beta1
authorcvs2git <cvs2git>
Sun, 8 Sep 2002 11:36:18 +0000 (11:36 +0000)
committercvs2git <cvs2git>
Sun, 8 Sep 2002 11:36:18 +0000 (11:36 +0000)
21 files changed:
ANNOUCE.1.4.0 [deleted file]
FS/FS/Record.pm
FS/FS/cust_bill.pm
FS/FS/cust_main.pm
FS/FS/part_export/vpopmail.pm
FS/FS/part_pkg.pm
FS/FS/pkg_svc.pm
FS/FS/svc_acct.pm
fs_selfadmin/FS-MailAdminServer/MailAdminClient.pm [deleted file]
fs_selfadmin/FS-MailAdminServer/cgi/mailadmin.cgi [deleted file]
fs_selfadmin/FS-MailAdminServer/fs_mailadmind [deleted file]
fs_selfadmin/README [deleted file]
fs_selfadmin/fs_mailadmin_server [deleted file]
fs_signup/FS-SignupClient/cgi/signup.cgi
httemplate/browse/part_svc.cgi
httemplate/docs/index.html
httemplate/docs/upgrade9.html [new file with mode: 0644]
httemplate/edit/cust_main.cgi
httemplate/index.html
httemplate/misc/cust_main-import_charges.cgi [new file with mode: 0644]
httemplate/misc/process/cust_main-import_charges.cgi [new file with mode: 0644]

diff --git a/ANNOUCE.1.4.0 b/ANNOUCE.1.4.0
deleted file mode 100644 (file)
index d110c6f..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-Hi,
-
-I'm pleased to announce the first beta release of Freeside 1.4.0.
-Freeside is a web-based, open-source billing and account administration
-package for ISPs, web hosts, and similar businesses.
-
-You can see a web demo, read the documentation, and download the new beta
-at <http://www.sisd.com/freeside/>.
-
-Although Freeside is free software, it is supported commercially with
-installation, customization, training and support services.  Please
-consider our services and help support the development of the software!
-
-
-Major new features in 1.4.0 include:
-
-- Billing engine has been rewritten and now has support for easily added
-  "price plans".  Included price plans include anniversary billing,
-  1st-of-the-month billing (pro-rated and subscription), free for N days,
-  commissions for referrals and per-minute/per-hour charges.
-
-- Customer-to-customer referrals, tracking and commissions.
-
-- Configurable invoice events triggered for delinquent customers can
-  re-send invoices, suspend accounts, charge late fees, and so on.
-
-- Export and provisioning system has been rewritten.  New provisioning
-  methods can now be "plugged-in" for any service type.  Included exports
-  include BSD and Linux password files, configurable shell commands,
-  RADIUS (both text and SQL, including groups), BIND configuration files,
-  Cyrus, vpopmail, and many others.
-
-- Complete set of history tables tracking all changes to the database.
-
-- Job queue with display and retry for provisioning tasks.
-
-- UI overhaul - easier to navigate and use.  Quick package order and
-  one-time charges.  Separate billing and service contact information.
-  Customer comments.
-
-- Performance optimizations.
-
-- Financials have been rewritten.  Apply payments and credits against
-  specific invoices (in whole or in part), or have the system apply
-  automatically.
-
-- Texas tax.
-
-- Improved documentation and easier install.
-
index c247ed2..e6126a1 100644 (file)
@@ -930,7 +930,7 @@ sub ut_ip {
   $self->getfield($field) =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
     or return "Illegal (IP address) $field: ". $self->getfield($field);
   for ( $1, $2, $3, $4 ) { return "Illegal (IP address) $field" if $_ > 255; }
-  $self->setfield($field, "$1.$2.$3.$4");
+  $self->setfield($field, "$1.$2.$3.$3");
   '';
 }
 
index fd79f23..5e041ea 100644 (file)
@@ -681,7 +681,8 @@ sub realtime_card {
     my $capture =
       new Business::OnlinePayment( $bop_processor, @bop_options );
 
-    $capture->content(
+    my %capture = (
+      type           => 'CC',
       action         => $action2,
       login          => $bop_login,
       password       => $bop_password,
@@ -689,8 +690,18 @@ sub realtime_card {
       amount         => $amount,
       authorization  => $auth,
       description    => $description,
+      card_number    => $cust_main->payinfo,
+      expiration     => $exp,
     );
 
+    foreach my $field (qw( authorization_source_code returned_ACI                                          transaction_identifier validation_code           
+                           transaction_sequence_num local_transaction_date    
+                           local_transaction_time AVS_result_code          )) {
+      $capture{$field} = $transaction->$field() if $transaction->can($field);
+    }
+
+    $capture->content( %capture );
+
     $capture->submit();
 
     unless ( $capture->is_success ) {
@@ -1101,7 +1112,7 @@ sub print_text {
 
 =head1 VERSION
 
-$Id: cust_bill.pm,v 1.40 2002-08-30 23:48:43 ivan Exp $
+$Id: cust_bill.pm,v 1.41 2002-09-05 16:51:49 ivan Exp $
 
 =head1 BUGS
 
index 8e47f23..cfa6b8b 100644 (file)
@@ -2075,6 +2075,91 @@ sub batch_import {
 
 }
 
+=item batch_charge
+
+=cut
+
+sub batch_charge {
+  my $param = shift;
+  #warn join('-',keys %$param);
+  my $fh = $param->{filehandle};
+  my @fields = @{$param->{fields}};
+
+  eval "use Date::Parse;";
+  die $@ if $@;
+  eval "use Text::CSV_XS;";
+  die $@ if $@;
+
+  my $csv = new Text::CSV_XS;
+  #warn $csv;
+  #warn $fh;
+
+  my $imported = 0;
+  #my $columns;
+
+  local $SIG{HUP} = 'IGNORE';
+  local $SIG{INT} = 'IGNORE';
+  local $SIG{QUIT} = 'IGNORE';
+  local $SIG{TERM} = 'IGNORE';
+  local $SIG{TSTP} = 'IGNORE';
+  local $SIG{PIPE} = 'IGNORE';
+
+  my $oldAutoCommit = $FS::UID::AutoCommit;
+  local $FS::UID::AutoCommit = 0;
+  my $dbh = dbh;
+  
+  #while ( $columns = $csv->getline($fh) ) {
+  my $line;
+  while ( defined($line=<$fh>) ) {
+
+    $csv->parse($line) or do {
+      $dbh->rollback if $oldAutoCommit;
+      return "can't parse: ". $csv->error_input();
+    };
+
+    my @columns = $csv->fields();
+    #warn join('-',@columns);
+
+    my %row = ();
+    foreach my $field ( @fields ) {
+      $row{$field} = shift @columns;
+    }
+
+    my $cust_main = qsearchs('cust_main', { 'custnum' => $row{'custnum'} } );
+    unless ( $cust_main ) {
+      $dbh->rollback if $oldAutoCommit;
+      return "unknown custnum $row{'custnum'}";
+    }
+
+    if ( $row{'amount'} > 0 ) {
+      my $error = $cust_main->charge($row{'amount'}, $row{'pkg'});
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return $error;
+      }
+      $imported++;
+    } elsif ( $row{'amount'} < 0 ) {
+      my $error = $cust_main->credit( sprintf( "%.2f", 0-$row{'amount'} ),
+                                      $row{'pkg'}                         );
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return $error;
+      }
+      $imported++;
+    } else {
+      #hmm?
+    }
+
+  }
+
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+  return "Empty file!" unless $imported;
+
+  ''; #no error
+
+}
+
 =back
 
 =head1 BUGS
index cc8136e..561e274 100644 (file)
@@ -1,6 +1,7 @@
 package FS::part_export::vpopmail;
 
-use vars qw(@ISA @saltset $exportdir $rsync $ssh);
+use vars qw(@ISA @saltset $exportdir);
+use Fcntl qw(:flock);
 use File::Path;
 use FS::UID qw( datasrc );
 use FS::part_export;
@@ -9,9 +10,6 @@ use FS::part_export;
 
 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
 
-$rsync = "rsync";
-$ssh = "ssh";
-
 sub rebless { shift; }
 
 sub _export_insert {
@@ -60,7 +58,15 @@ sub _export_delete {
 #a good idea to queue anything that could fail or take any time
 sub vpopmail_queue {
   my( $self, $svcnum, $method ) = (shift, shift, shift);
+
   my $exportdir = "/usr/local/etc/freeside/export." . datasrc;
+  mkdir $exportdir, 0700 or die $! unless -d $exportdir;
+  $exportdir .= "/vpopmail";
+  mkdir $exportdir, 0700 or die $! unless -d $exportdir;
+  $exportdir .= '/'. $self->machine;
+  mkdir $exportdir, 0700 or die $! unless -d $exportdir;
+  mkdir "$exportdir/domains", 0700 or die $! unless -d "$exportdir/domains";
+
   my $queue = new FS::queue {
     'svcnum' => $svcnum,
     'job'    => "FS::part_export::vpopmail::vpopmail_$method",
@@ -78,7 +84,10 @@ sub vpopmail_queue {
 sub vpopmail_insert { #subroutine, not method
   my( $exportdir, $machine, $dir, $uid, $gid ) = splice @_,0,5;
   my( $username, $password, $domain, $quota ) = @_;
-  
+
+  mkdir "$exportdir/domains/$domain", 0700 or die $!
+    unless -d "$exportdir/domains/$domain";
+
   (open(VPASSWD, ">>$exportdir/domains/$domain/vpasswd")
     and flock(VPASSWD,LOCK_EX)
   ) or die "can't open vpasswd file for $username\@$domain: ".
index e914636..9c33e9a 100644 (file)
@@ -297,7 +297,7 @@ sub payby {
 
 =head1 VERSION
 
-$Id: part_pkg.pm,v 1.16 2002-06-10 01:39:50 khoff Exp $
+$Id: part_pkg.pm,v 1.14 2002-05-09 12:38:39 ivan Exp $
 
 =head1 BUGS
 
index 3c544ff..1812dbf 100644 (file)
@@ -137,7 +137,7 @@ sub part_svc {
 
 =head1 VERSION
 
-$Id: pkg_svc.pm,v 1.3 2002-06-10 01:39:50 khoff Exp $
+$Id: pkg_svc.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
 
 =head1 BUGS
 
index 6fe26c8..e62cdd7 100644 (file)
@@ -708,7 +708,7 @@ sub check {
 
 
     $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
-      or return "Illegal directory";
+      or return "Illegal directory: ". $recref->{dir};
     $recref->{dir} = $1;
     return "Illegal directory"
       if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
diff --git a/fs_selfadmin/FS-MailAdminServer/MailAdminClient.pm b/fs_selfadmin/FS-MailAdminServer/MailAdminClient.pm
deleted file mode 100755 (executable)
index 46cde4c..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-package FS::MailAdminClient;
-
-use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $fs_mailadmind_socket);
-use Exporter;
-use Socket;
-use FileHandle;
-use IO::Handle;
-
-$VERSION = '0.01';
-
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( signup_info authenticate list_packages list_mailboxes delete_mailbox password_mailbox add_mailbox list_forwards list_pkg_forwards delete_forward add_forward new_customer );
-
-$fs_mailadmind_socket = "/usr/local/freeside/fs_mailadmind_socket";
-
-$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
-$ENV{'SHELL'} = '/bin/sh';
-$ENV{'IFS'} = " \t\n";
-$ENV{'CDPATH'} = '';
-$ENV{'ENV'} = '';
-$ENV{'BASH_ENV'} = '';
-
-my $freeside_uid = scalar(getpwnam('freeside'));
-die "not running as the freeside user\n" if $> != $freeside_uid;
-
-=head1 NAME
-
-FS::MailAdminClient - Freeside mail administration client API
-
-=head1 SYNOPSIS
-
-  use FS::MailAdminClient qw( signup_info list_mailboxes  new_customer );
-
-  ( $locales, $packages, $pops ) = signup_info;
-
-  ( $accounts ) = list_mailboxes;
-
-  $error = new_customer ( {
-    'first'          => $first,
-    'last'           => $last,
-    'ss'             => $ss,
-    'comapny'        => $company,
-    'address1'       => $address1,
-    'address2'       => $address2,
-    'city'           => $city,
-    'county'         => $county,
-    'state'          => $state,
-    'zip'            => $zip,
-    'country'        => $country,
-    'daytime'        => $daytime,
-    'night'          => $night,
-    'fax'            => $fax,
-    'payby'          => $payby,
-    'payinfo'        => $payinfo,
-    'paydate'        => $paydate,
-    'payname'        => $payname,
-    'invoicing_list' => $invoicing_list,
-    'pkgpart'        => $pkgpart,
-    'username'       => $username,
-    '_password'       => $password,
-    'popnum'         => $popnum,
-  } );
-
-=head1 DESCRIPTION
-
-This module provides an API for a remote mail administration server.
-
-It needs to be run as the freeside user.  Because of this, the program which
-calls these subroutines should be written very carefully.
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item signup_info
-
-Returns three array references of hash references.
-
-The first set of hash references is of allowable locales.  Each hash reference
-has the following keys:
-  taxnum
-  state
-  county
-  country
-
-The second set of hash references is of allowable packages.  Each hash
-reference has the following keys:
-  pkgpart
-  pkg
-
-The third set of hash references is of allowable POPs (Points Of Presence).
-Each hash reference has the following keys:
-  popnum
-  city
-  state
-  ac
-  exch
-
-=cut
-
-sub signup_info {
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "signup_info\n";
-  SOCK->flush;
-
-  chop ( my $n_cust_main_county = <SOCK> );
-  my @cust_main_county = map {
-    chop ( my $taxnum  = <SOCK> ); 
-    chop ( my $state   = <SOCK> ); 
-    chop ( my $county  = <SOCK> ); 
-    chop ( my $country = <SOCK> );
-    {
-      'taxnum'  => $taxnum,
-      'state'   => $state,
-      'county'  => $county,
-      'country' => $country,
-    };
-  } 1 .. $n_cust_main_county;
-
-  chop ( my $n_part_pkg = <SOCK> );
-  my @part_pkg = map {
-    chop ( my $pkgpart = <SOCK> ); 
-    chop ( my $pkg     = <SOCK> ); 
-    {
-      'pkgpart' => $pkgpart,
-      'pkg'     => $pkg,
-    };
-  } 1 .. $n_part_pkg;
-
-  chop ( my $n_svc_acct_pop = <SOCK> );
-  my @svc_acct_pop = map {
-    chop ( my $popnum = <SOCK> ); 
-    chop ( my $city   = <SOCK> ); 
-    chop ( my $state  = <SOCK> ); 
-    chop ( my $ac     = <SOCK> );
-    chop ( my $exch   = <SOCK> );
-    chop ( my $loc    = <SOCK> );
-    {
-      'popnum' => $popnum,
-      'city'   => $city,
-      'state'  => $state,
-      'ac'     => $ac,
-      'exch'   => $exch,
-      'loc'    => $loc,
-    };
-  } 1 .. $n_svc_acct_pop;
-
-  close SOCK;
-
-  \@cust_main_county, \@part_pkg, \@svc_acct_pop;
-}
-
-=item authenticate
-
-Authentictes against a service on the remote Freeside system.  Requires a hash
-reference as a parameter with the following keys:
-    authuser
-    _password
-
-Returns a scalar error message of the form "authuser OK|FAILED" or an error
-message.
-
-=cut
-
-sub authenticate {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "authenticate", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser _password
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item list_packages
-
-Returns one array reference of hash references.
-
-The set of hash references is of existing packages.  Each hash reference
-has the following keys:
-  pkgnum
-  domain
-  account
-
-=cut
-
-sub list_packages {
-  my $user = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "list_packages\n", $user, "\n";
-  SOCK->flush;
-
-  chop ( my $n_packages = <SOCK> );
-  my @packages = map {
-    chop ( my $pkgnum  = <SOCK> ); 
-    chop ( my $domain  = <SOCK> ); 
-    chop ( my $account = <SOCK> ); 
-    {
-      'pkgnum'  => $pkgnum,
-      'domain'  => $domain,
-      'account' => $account,
-    };
-  } 1 .. $n_packages;
-
-  close SOCK;
-
-  \@packages;
-}
-
-=item list_mailboxes
-
-Returns one array references of hash references.
-
-The set of hash references is of existing accounts.  Each hash reference
-has the following keys:
-  svcnum
-  username
-  _password
-
-=cut
-
-sub list_mailboxes {
-  my ($user, $package) = @_;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "list_mailboxes\n", $user, "\n", $package, "\n";
-  SOCK->flush;
-
-  chop ( my $n_svc_acct = <SOCK> );
-  my @svc_acct = map {
-    chop ( my $svcnum  = <SOCK> ); 
-    chop ( my $username  = <SOCK> ); 
-    chop ( my $_password   = <SOCK> ); 
-    {
-      'svcnum'  => $svcnum,
-      'username'  => $username,
-      '_password'   => $_password,
-    };
-  } 1 .. $n_svc_acct;
-
-  close SOCK;
-
-  \@svc_acct;
-}
-
-=item delete_mailbox
-
-Deletes a mailbox service from the remote Freeside system.  Requires a hash
-reference as a paramater with the following keys:
-    authuser
-    account
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub delete_mailbox {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "delete_mailbox", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser account
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item password_mailbox
-
-Changes the password for a mailbox service on the remote Freeside system.
-  Requires a hash reference as a paramater with the following keys:
-    authuser
-    account
-    _password
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub password_mailbox {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "password_mailbox", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser account _password
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item add_mailbox
-
-Creates a mailbox service on the remote Freeside system.  Requires a hash
-reference as a parameter with the following keys:
-    authuser
-    package
-    account
-    _password
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub add_mailbox {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "add_mailbox", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser package account _password
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item list_forwards
-
-Returns one array references of hash references.
-
-The set of hash references is of existing forwards.  Each hash reference
-has the following keys:
-  svcnum
-  dest
-
-=cut
-
-sub list_forwards {
-  my ($user, $service) = @_;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "list_forwards\n", $user, "\n", $service, "\n";
-  SOCK->flush;
-
-  chop ( my $n_svc_forward = <SOCK> );
-  my @svc_forward = map {
-    chop ( my $svcnum  = <SOCK> ); 
-    chop ( my $dest  = <SOCK> ); 
-    {
-      'svcnum'  => $svcnum,
-      'dest'  => $dest,
-    };
-  } 1 .. $n_svc_forward;
-
-  close SOCK;
-
-  \@svc_forward;
-}
-
-=item list_pkg_forwards
-
-Returns one array references of hash references.
-
-The set of hash references is of existing forwards.  Each hash reference
-has the following keys:
-  svcnum
-  srcsvc
-  dest
-
-=cut
-
-sub list_pkg_forwards {
-  my ($user, $package) = @_;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "list_pkg_forwards\n", $user, "\n", $package, "\n";
-  SOCK->flush;
-
-  chop ( my $n_svc_forward = <SOCK> );
-  my @svc_forward = map {
-    chop ( my $svcnum  = <SOCK> ); 
-    chop ( my $srcsvc  = <SOCK> ); 
-    chop ( my $dest  = <SOCK> ); 
-    {
-      'svcnum'  => $svcnum,
-      'srcsvc'  => $srcsvc,
-      'dest'  => $dest,
-    };
-  } 1 .. $n_svc_forward;
-
-  close SOCK;
-
-  \@svc_forward;
-}
-
-=item delete_forward
-
-Deletes a forward service from the remote Freeside system.  Requires a hash
-reference as a paramater with the following keys:
-    authuser
-    svcnum
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub delete_forward {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "delete_forward", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser svcnum
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item add_forward
-
-Creates a forward service on the remote Freeside system.  Requires a hash
-reference as a parameter with the following keys:
-    authuser
-    package
-    source
-    dest
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub add_forward {
-  my $hashref = shift;
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "add_forward", "\n";
-  SOCK->flush;
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    authuser package source dest
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  close SOCK;
-
-  $error;
-}
-
-=item new_customer HASHREF
-
-Adds a customer to the remote Freeside system.  Requires a hash reference as
-a paramater with the following keys:
-  first
-  last
-  ss
-  comapny
-  address1
-  address2
-  city
-  county
-  state
-  zip
-  country
-  daytime
-  night
-  fax
-  payby
-  payinfo
-  paydate
-  payname
-  invoicing_list
-  pkgpart
-  username
-  _password
-  popnum
-
-Returns a scalar error message, or the empty string for success.
-
-=cut
-
-sub new_customer {
-  my $hashref = shift;
-
-  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
-  connect(SOCK, sockaddr_un($fs_mailadmind_socket)) or die "connect: $!";
-  print SOCK "new_customer\n";
-
-  print SOCK join("\n", map { $hashref->{$_} } qw(
-    first last ss company address1 address2 city county state zip country
-    daytime night fax payby payinfo paydate payname invoicing_list
-    pkgpart username _password popnum
-  ) ), "\n";
-  SOCK->flush;
-
-  chop( my $error = <SOCK> );
-  $error;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: MailAdminClient.pm,v 1.1 2001-10-18 15:04:54 jeff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<fs_signupd>, L<FS::SignupServer>, L<FS::cust_main>
-
-=cut
-
-1;
-
diff --git a/fs_selfadmin/FS-MailAdminServer/cgi/mailadmin.cgi b/fs_selfadmin/FS-MailAdminServer/cgi/mailadmin.cgi
deleted file mode 100755 (executable)
index c26c3dc..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-#!/usr/bin/perl
-########################################################################
-#                                                                      #
-#    mailadmin.cgi                NCI2000                              #
-#                                 Jeff Finucane <jeff@nci2000.net>     #
-#                                 26 April 2001                        #
-#                                                                      #
-########################################################################
-
-use DBI;
-use strict;
-use CGI;
-use FS::MailAdminClient qw(authenticate list_packages list_mailboxes delete_mailbox password_mailbox add_mailbox list_forwards list_pkg_forwards delete_forward add_forward);
-
-my $sessionfile = '/usr/local/apache/htdocs/mailadmin/adminsess';   # session file
-my $tmpdir = '/usr/local/apache/htdocs/mailadmin/tmp';         # Location to store temp files
-my $cookiedomain = ".your.dom";      # domain if THIS server, should prepend with a '.'
-my $cookieexpire = '+12h';              # expire the cookie session after this much idle time
-my $sessexpire = 43200;                 # expire session after this long of no use (in seconds)
-
-my $body = "<body bgcolor=dddddd>";
-
-#### Should not have to change anything under this line ####
-my $printmainpage = 1;
-my $i = 0;
-my $printheader = 1;
-my $query = new CGI;
-my $cgi = $query->url();
-my $now = getdatetime();
-my $current_package = 0;
-my $current_account = 0;
-my $current_domname = "";
-
-# if they are trying to login we wont check the session yet
-if ($query->param('login') eq '' && $query->param('action') ne 'login') {
-  checksession();
-  printheader();
-}
-
-if ($query->param('login') ne '') {
-
-   my $username = $query->param('username');
-   my $password = $query->param('password');
-
-   if (!checkuserpass($username, $password)) {
-      printheader();
-      error('not_admin');
-   }
-
-   my @alpha = ('A'..'Z', 'a'..'z', 0..9);
-   my $sessid = '';
-   for (my $i = 0; $i < 10; $i++) {
-       $sessid .= @alpha[rand(@alpha)];
-   }
-
-   my $cookie1 = $query->cookie(-name=>'username',
-                               -value=>$username,
-                               -expires=>$cookieexpire,
-                               -domain=>$cookiedomain);
-
-   my $cookie2 = $query->cookie(-name=>'ma_sessionid',
-                               -value=>$sessid,
-                               -expires=>$cookieexpire,
-                               -domain=>$cookiedomain);
-
-   my $now = time();
-   open(NEWSESS, ">>$sessionfile") || error('open');
-   print NEWSESS "$username $sessid $now 0 0\n";
-   close(NEWSESS);
-
-   print $query->header(-COOKIE=>[$cookie1, $cookie2]);
-   $printmainpage = 1;
-
-} elsif ($query->param('action') eq 'blankframe') {
-   
-  print "<html>$body</body></html>\n";
-   $printmainpage = 0;
-
-} elsif ($query->param('action') eq 'list_packages') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  my $list = list_packages($username);
-  print "<html>$body\n";
-  print "<center><table border=0>\n";
-  print "<tr><td></td><td><p>Package Number</td><td><p>Description</td></tr>\n";
-  foreach my $package ( @{$list} ) {
-    print "<tr>";
-    print "<td></td><td><p>$package->{'pkgnum'}</td><td><p>$package->{'domain'}</td>\n";
-    print "<td></td><td><a href=\"$cgi\?action=select&package=$package->{'pkgnum'}&account=$package->{'account'}&domname=$package->{'domain'}\" target=\"rightmainframe\">select</td>\n";
-    print "</tr>";
-  }
-  print "</table>\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'list_mailboxes') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username)  unless $current_package;
-  my $list = list_mailboxes($username, $current_package);
-  my $forwardlist = list_pkg_forwards($username, $current_package);
-  print "<html>$body\n";
-  print "<center><table border=0>\n";
-  print "<tr><td></td><td><p>Username</td><td><p>Password</td></tr>\n";
-  foreach my $account ( @{$list} ) {
-    print "<tr>";
-    print "<td></td><td><p>$account->{'username'}</td><td><p>$account->{'_password'}</td>\n";
-    print "<td></td><td><a href=\"$cgi\?action=change&account=$account->{'svcnum'}&mailbox=$account->{'username'}\" target=\"rightmainframe\">change</td>\n";
-    print "</tr>";
-
-#    my $forwardlist = list_forwards($username, $account->{'svcnum'});
-#    foreach my $forward ( @{$forwardlist} ) {
-#      my $label = qq!=> ! . $forward->{'dest'};
-#      print "<tr><td></td><td></td><td><p>$label</td></tr>\n";
-#    }
-    foreach my $forward ( @{$forwardlist} ) {
-      if ($forward->{'srcsvc'} == $account->{'svcnum'}) {
-        my $label = qq!=> ! . $forward->{'dest'};
-        print "<tr><td></td><td></td><td><p>$label</td></tr>\n";
-      }
-    }
-
-  }
-  print "</table>\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'select') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  $current_package = $query->param('package');
-  $current_account = $query->param('account');
-  $current_domname = $query->param('domname');
-  set_package();
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<center>\n";
-  print "<p>Selected package $current_package\n";
-  print "</center>\n";
-  print "</form>\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'change') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $mailbox  = $query->param('mailbox');
-  my $list = list_forwards($username, $account);
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<center><table border=0>\n";
-  print "<tr><td></td><td><p>Username</td><td><p>$mailbox</td></tr>\n";
-  print "<input type=hidden name=\"account\" value=\"$account\">\n";
-  print "<input type=hidden name=\"mailbox\" value=\"$mailbox\">\n";
-  foreach my $forward ( @{$list} ) {
-    my $label = qq!=> ! . $forward->{'dest'};
-#    print "<tr><td></td><td></td><td><p>$label</td></tr>\n";
-    print "<tr><td></td><td></td><td><p>$label</td><td><a href=\"$cgi\?action=deleteforward&service=$forward->{'svcnum'}&mailbox=$mailbox&dest=$forward->{'dest'}\" target=\"rightmainframe\">remove</td></tr>\n";
-  }
-  print "<tr><td></td><td><p>Password</td><td><input type=text name=\"_password\" value=\"\"></td></tr>\n";
-  print "</table>\n";
-  print "<input type=submit name=\"deleteaccount\" value=\"Delete This User\">\n";
-  print "<input type=submit name=\"changepassword\" value=\"Change The Password\">\n";
-  print "<input type=submit name=\"addforward\" value=\"Add Forwarding\">\n";
-  print "</center>\n";
-  print "</form>\n";
-  print "<br>\n";
-  print "<p> You may delete this user and all mailforwarding by pressing <B>Delete This User</B>.\n";
-  print "<p> To set or change the password for this user, type the new password in the box next to <B>Password</B> and press <B>Change The Password</B>.\n";
-  print "<p> If you would like to have mail destined for this user forwarded to another email address then press the <B>Add Forwarding</B> button.\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('deleteaccount') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $mailbox  = $query->param('mailbox');
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<p>Are you certain you want to delete user $mailbox?\n";
-  print "<p><input type=hidden name=\"account\" value=\"$account\">\n";
-  print "<input type=submit name=\"deleteaccounty\" value=\"Confirm\">\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('deleteaccounty') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  
-  if  ( my $error = delete_mailbox ( {
-      'authuser'         => $username,
-      'account'          => $account,
-    } ) ) {
-    print "<html>$body\n";
-    print "<p>$error\n";
-    print "</body></html>\n";
-      
-  } else {
-    print "<html>$body\n";
-    print "<p>Deleted\n";
-    print "</body></html>\n";
-  }
-
-  $printmainpage=0;
-
-} elsif ($query->param('changepassword') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $_password  = $query->param('_password');
-  
-  if  ( my $error = password_mailbox ( {
-      'authuser'         => $username,
-      'account'          => $account,
-      '_password'        => $_password,
-    } ) ) {
-    print "<html>$body\n";
-    print "<p>$error\n";
-    print "</body></html>\n";
-      
-  } else {
-    print "<html>$body\n";
-    print "<p>Changed\n";
-    print "</body></html>\n";
-  }
-
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'newmailbox') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<center><table border=0>\n";
-  print "<tr><td></td><td><p>Username </td><td><input type=text name=\"account\" value=\"\"></td><td>@ " . $current_domname . "</td></tr>\n";
-  print "<tr><td></td><td><p>Password</td><td><input type=text name=\"_password\" value=\"\"></td></tr>\n";
-  print "</table>\n";
-  print "<input type=submit name=\"addmailbox\" value=\"Add This User\">\n";
-  print "</center>\n";
-  print "</form>\n";
-  print "<br>\n";
-  print "<p>Use this screen to add a new mailbox user.  If the domain name of the email address (the part after the <B>@</B> sign) is not what you expect then you may need to use <B>List Packages</B> to select the package with the correct domain.\n";
-  print "<p>Enter the first portion of the email address in the box adjacent to <B>Username</B> and enter the password for that user in the space next to <B>Password</B>.  Then press the button labeled <B>Add The User</B>.\n";
-  print "<p>If you do not want to add a new user at this time then select a choice from the menu at the left, such as <B>List Mailboxes</B>.\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('addmailbox') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $_password  = $query->param('_password');
-  
-  if  ( my $error = add_mailbox ( {
-      'authuser'         => $username,
-      'package'          => $current_package,
-      'account'          => $account,
-      '_password'        => $_password,
-    } ) ) {
-    print "<html>$body\n";
-    print "<p>$error\n";
-    print "</body></html>\n";
-      
-  } else {
-    print "<html>$body\n";
-    print "<p>Created\n";
-    print "</body></html>\n";
-  }
-
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'deleteforward') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $svcnum   = $query->param('service');
-  my $mailbox  = $query->param('mailbox');
-  my $dest  = $query->param('dest');
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<p>Are you certain you want to remove the forwarding from $mailbox to $dest?\n";
-  print "<p><input type=hidden name=\"service\" value=\"$svcnum\">\n";
-  print "<input type=submit name=\"deleteforwardy\" value=\"Confirm\">\n";
-  print "</body></html>\n";
-  $printmainpage=0;
-
-} elsif ($query->param('deleteforwardy') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $service  = $query->param('service');
-  
-  if  ( my $error = delete_forward ( {
-      'authuser'        => $username,
-      'svcnum'          => $service,
-    } ) ) {
-    print "<html>$body\n";
-    print "<p>$error\n";
-    print "</body></html>\n";
-      
-  } else {
-    print "<html>$body\n";
-    print "<p>Forwarding Removed\n";
-    print "</body></html>\n";
-  }
-
-  $printmainpage=0;
-
-} elsif ($query->param('addforward') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $mailbox  = $query->param('mailbox');
-  
-  print "<html>$body\n";
-  print "<form name=form1 action=\"$cgi\" method=post target=\"rightmainframe\">\n";
-  print "<center><table border=0>\n";
-  print "<input type=hidden name=\"account\" value=\"$account\">\n";
-  print "<input type=hidden name=\"mailbox\" value=\"$mailbox\">\n";
-  print "<tr><td>Forward mail from </td><td><p>$mailbox:</td><td> to </td></tr>\n";
-  print "<tr><td></td><td><p>Destination:</td><td><input type=text name=\"dest\" value=\"\"></td></tr>\n";
-  print "</table>\n";
-  print "<input type=submit name=\"addforwarddst\" value=\"Add the Forwarding\">\n";
-  print "</center>\n";
-  print "</form>\n";
-  print "<br>\n";
-  print "<p> If you would like mail originally destined for the above address to be forwarded to a different email address then type that email address in the box next to <B>Destination:</B> and press the <B>Add the Forwarding</B> button.\n";
-  print "<p> If you do not want to add mail forwarding then select a choice from the menu at the left, such as <B>List Accounts</B>.\n";
-
-  $printmainpage=0;
-
-} elsif ($query->param('addforwarddst') ne '') {
-
-  my $username = $query->cookie(-name=>'username');  # session checked
-  select_package($username) unless $current_package;
-  my $account  = $query->param('account');
-  my $dest  = $query->param('dest');
-  
-  if  ( my $error = add_forward ( {
-      'authuser'         => $username,
-      'package'          => $current_package,
-      'source'           => $account,
-      'dest'             => $dest,
-    } ) ) {
-    print "<html>$body\n";
-    print "<p>$error\n";
-    print "</body></html>\n";
-      
-  } else {
-    print "<html>$body\n";
-    print "<p>Forwarding Created\n";
-    print "</body></html>\n";
-  }
-
-  $printmainpage=0;
-
-} elsif ($query->param('action') eq 'navframe') {
-
-  print "<html><body bgcolor=bbbbbb>\n";
-  print "<center><h2>NCI2000 MAIL ADMIN Web Interface</h2></center>\n";
-
-  print "<br><center>Choose Action:</center><br>\n";
-  print "<center><table border=0>\n";
-  print "<ul>\n";
-  print "<tr><td><li><a href=\"$cgi\?action=logout\" target=\"_top\">Log Off</a></td><tr>\n";
-  print "<tr><td><li><a href=\"$cgi\?action=list_packages\" target=\"rightmainframe\">List Packages</a></td><tr>\n";
-  print "<tr><td><li><a href=\"$cgi\?action=list_mailboxes\" target=\"rightmainframe\">List Accounts</a></td><tr>\n";
-  print "<tr><td><li><a href=\"$cgi\?action=newmailbox\" target=\"rightmainframe\">Add Account</a></td><tr>\n";
-  print "</ul>\n";
-  print "</table></center>\n";
-
-  print "<br><br><br>\n";
-  print "</body></html>\n";
-
-  $printmainpage = 0;
-
-} elsif ($query->param('action') eq 'rightmainframe') {
-
-  print "<html>$body\n";
-  print "<br><br><br>\n";
-  print "<font size=4><----- Please choose function on the left menu</font>\n";
-  print "<br><br>\n";
-  print "<p> Choose <B>Log Off</B> when you are finished.  This helps prevent unauthorized access to your accounts.\n";
-  print "<p> Use <B>List Packages</B> when you administer multiple packages.  When you have multiple domains at NCI2000 you are likely to have multiple packages.  Use of <B>List Packages</B> is not necessary if administer only one package.\n";
-  print "<p> Use <B>List Accounts</B> to view your current arrangement of mailboxes.  From this list you my choose to make changes to existing mailboxes or delete mailboxes.  If you would like to modify the forwarding associated with a mailbox then choose it from this list.\n";
-  print "<p> Use <B>Add Account</B> when you would like an additional mailbox.  After you have added the mailbox you may choose to make additional changes from the list provided by <B>List Accounts<B>.\n";
-  print "</body></html>\n";
-
-  $printmainpage = 0;
-
-}
-
-
-if ($query->param('action') eq 'login') {
-
-    printheader();
-    printlogin();
-
-} elsif ($query->param('action') eq 'logout') {
-
-    destroysession();
-    printheader();
-    printlogin();
-
-} elsif ($printmainpage) {
-
-
-  print "<html><head><title>NCI2000 MAIL ADMIN Web Interface</title></head>\n";
-  print "<FRAMESET cols=\"160,*\" BORDER=\"3\">\n";
-  print "<FRAME NAME=\"navframe\" src=\"$cgi?action=navframe\">\n";
-  print "<FRAME NAME=\"rightmainframe\" src=\"$cgi?action=rightmainframe\">\n";
-  print "</FRAMESET>\n";
-  print "</html>\n";
-
-
-}
-
-sub getdatetime {
-  my $today = localtime(time());
-  my ($day,$mon,$dayofmon,$time,$year) = split(/\s+/,$today);
-  my @datemonths = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
-
-  my $numidx = "01";
-  my ($nummon);
-  foreach my $mons (@datemonths) {
-    if ($mon eq $mons) {
-     $nummon = $numidx;
-    }
-    $numidx++;
-  }
-
-  return "$year-$nummon-$dayofmon $time";
-
-}
-
-sub error {
-
-  my $error = shift;
-  my $arg1 = shift;
-
-   printheader();
-
-   if ($error eq 'not_admin') {
-     print "<html><head><title>Error!</title></head>\n";
-     print "$body\n";
-     print "<center><h1><font face=arial>Error!</font></h1></center>\n";
-     print "<font face=arial>Unauthorized attempt to access mail administration.</font>\n";
-     print "<br><font face=arial>Please login again if you think this is an error.</font>\n";
-     print "<form><input type=button value=\"<<Back\" OnClick=\"history.back()\"></form>\n";
-     print "</body></html>\n";
-   } elsif ($error eq 'exists') {
-     print "<html><head><title>Error!</title></head>\n";
-     print "$body\n";
-     print "<center><h1><font face=arial>Error!</font></h1></center>\n";
-     print "<font face=arial>The user you are trying to enter already exists. Please go back and enter a different username</font>\n";
-     print "</font></body></html>\n";
-   } elsif ($error eq 'ingroup') {
-     print "<html><head><title>Error!</title></head>\n";
-     print "$body\n";
-     print "<center><h1><font face=arial>Error!</font></h1></center>\n";
-     print "<font face=arial>This user is already in the group <i>$arg1</i>. Please go back and deselect group <i>$arg1</i> from the list.</font>\n";
-     print "<form><input type=button value=\"<<Back\" OnClick=\"history.back()\"></form>\n";
-     print "</font></body></html>\n";
-   } elsif ($error eq 'sess_expired') {
-     print "<html>$body\n";
-     print "<center><font size=4>Your session has expired.</font></center>\n";
-     print "<br><br><center>Please login again <a href=\"$cgi\?action=login\" target=\"_top\"> HERE</a></center>\n";
-     print "</body></html>\n";
-   } elsif ($error eq 'open') {
-     print "<html>$body\n";
-     print "<center><font size=4>Unable to open or rename file.</font></center>\n";
-     print "<br><br><center>If this continues, please contact your administrator</center>\n";
-     print "</body></html>\n";
-   }
-
-
-   exit;
-
-}
-
-
-#print a html header if not printed yet
-sub printheader {
-
-  if ($printheader) {
-     print "Content-Type: text/html\n\n";
-     $printheader = 0;
-  }
-
-}
-
-
-#verify user can access administration
-sub checksession {
-
-  my $username = $query->cookie(-name=>'username');
-  my $sessionid = $query->cookie(-name=>'ma_sessionid');
-
-  if ($sessionid eq '') {
-     printheader();
-     if ($query->param()) {
-        error('sess_expired');
-     } else {
-        printlogin();
-        exit;
-    }
-  }
-
-  my $now = time();
-  my $founduser = 0;
-  open(SESSFILE, "$sessionfile") || error('open');
-  error('open') if -l "$tmpdir/adminsess.$$";
-  open(NEWSESS, ">$tmpdir/adminsess.$$") || error('open');
-  while (<SESSFILE>) {
-       chomp();
-       my ($user, $sess, $time, $pkgnum, $svcdomain, $domname) = split(/\s+/);
-       next if $now - $sessexpire > $time;
-       if ($username eq $user && !$founduser) {
-               if ($sess eq $sessionid) {
-                       $founduser = 1;
-                       print NEWSESS "$user $sess $now $pkgnum $svcdomain $domname\n";
-                        $current_package=$pkgnum;
-                        $current_account=$svcdomain;
-                        $current_domname=$domname;
-                       next;
-               }
-       }
-       print NEWSESS "$user $sess $time $pkgnum $svcdomain $domname\n";
-  }
-  close(SESSFILE);
-  close(NEWSESS);
-  system("mv $tmpdir/adminsess.$$ $sessionfile");
-  error('sess_expired') unless $founduser;
-
-  my $cookie1 = $query->cookie(-name=>'username',
-                               -value=>$username,
-                               -expires=>$cookieexpire,
-                               -domain=>$cookiedomain);
-
-  my $cookie2 = $query->cookie(-name=>'ma_sessionid',
-                               -value=>$sessionid,
-                               -expires=>$cookieexpire,
-                               -domain=>$cookiedomain);
-
-  print $query->header(-COOKIE=>[$cookie1, $cookie2]);
-  
-  $printheader = 0;
-
-  return 0;
-
-}
-
-sub destroysession {
-
-  my $username = $query->cookie(-name=>'username');
-  my $sessionid = $query->cookie(-name=>'ma_sessionid');
-
-  if ($sessionid eq '') {
-     printheader();
-     if ($query->param()) {
-        error('sess_expired');
-     } else {
-        printlogin();
-        exit;
-    }
-  }
-
-  my $now = time();
-  my $founduser = 0;
-  open(SESSFILE, "$sessionfile") || error('open');
-  error('open') if -l "$tmpdir/adminsess.$$";
-  open(NEWSESS, ">$tmpdir/adminsess.$$") || error('open');
-  while (<SESSFILE>) {
-       chomp();
-       my ($user, $sess, $time, $pkgnum, $svcdomain, $domname) = split(/\s+/);
-       next if $now - $sessexpire > $time;
-       if ($username eq $user && !$founduser) {
-               if ($sess eq $sessionid) {
-                       $founduser = 1;
-                       next;
-               }
-       }
-       print NEWSESS "$user $sess $time $pkgnum $svcdomain $domname\n";
-  }
-  close(SESSFILE);
-  close(NEWSESS);
-  system("mv $tmpdir/adminsess.$$ $sessionfile");
-  error('sess_expired') unless $founduser;
-
-  $printheader = 0;
-
-  return 0;
-
-}
-
-# checks the username and pass against the database
-sub checkuserpass {
-
-  my $username = shift;
-  my $password = shift;
-
-  my $error = authenticate ( {
-      'authuser'         => $username,
-      '_password'        => $password,
-    } ); 
-
-  if ($error eq "$username OK") {
-    return 1;
-  }else{
-    return 0;
-  }
-
-}
-
-#printlogin prints a login page
-sub printlogin {
-
-        print "<html>$body\n";
-        print "<center><font size=4>Please login to access MAIL ADMIN</font></center>\n";
-        print "<form action=\"$cgi\" method=post>\n";
-        print "<center>Email Address: &nbsp; <input type=text name=\"username\">\n";
-        print "<br>Email Password: <input type=password name=\"password\">\n";
-        print "<br><input type=submit name=\"login\" value=\"Login\">\n";
-        print "</form></center>\n";
-        print "</body></html>\n";
-}
-
-
-#select_package chooses a administrable package if more than one exists
-sub select_package {
-        my $user = shift;
-        my $packages = list_packages($user);
-        if (scalar(@{$packages}) eq 1) {
-          $current_package = @{$packages}[0]->{'pkgnum'};
-          set_package();
-        }
-        if (scalar(@{$packages}) > 1) {
-#          print $query->redirect("$cgi\?action=list_packages");
-           print "<p>No package selected.  You must first <a href=\"$cgi\?action=list_packages\" target=\"rightmainframe\">select a package</a>.\n";
-          exit;
-        }
-}
-
-sub set_package {
-
-  my $username = $query->cookie(-name=>'username');
-  my $sessionid = $query->cookie(-name=>'ma_sessionid');
-
-  if ($sessionid eq '') {
-     printheader();
-     if ($query->param()) {
-        error('sess_expired');
-     } else {
-        printlogin();
-        exit;
-    }
-  }
-
-  my $now = time();
-  my $founduser = 0;
-  open(SESSFILE, "$sessionfile") || error('open');
-  error('open') if -l "$tmpdir/adminsess.$$";
-  open(NEWSESS, ">$tmpdir/adminsess.$$") || error('open');
-  while (<SESSFILE>) {
-       chomp();
-       my ($user, $sess, $time, $pkgnum, $svcdomain, $domname) = split(/\s+/);
-       next if $now - $sessexpire > $time;
-       if ($username eq $user && !$founduser) {
-               if ($sess eq $sessionid) {
-                       $founduser = 1;
-                       print NEWSESS "$user $sess $time $current_package $current_account $current_domname\n";
-                       next;
-               }
-       }
-       print NEWSESS "$user $sess $time $pkgnum $svcdomain $domname\n";
-  }
-  close(SESSFILE);
-  close(NEWSESS);
-  system("mv $tmpdir/adminsess.$$ $sessionfile");
-  error('sess_expired') unless $founduser;
-
-  $printheader = 0;
-
-  return 0;
-
-}
-
diff --git a/fs_selfadmin/FS-MailAdminServer/fs_mailadmind b/fs_selfadmin/FS-MailAdminServer/fs_mailadmind
deleted file mode 100755 (executable)
index 746d782..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-#!/usr/bin/perl -Tw
-
-eval 'exec /usr/bin/perl -Tw -S $0 ${1+"$@"}'
-    if 0; # not running under some shell
-#
-# fs_mailadmind
-#
-# This is run REMOTELY over ssh by fs_mailadmin_server.
-#
-
-use strict;
-use Socket;
-
-use vars qw( $Debug );
-
-$Debug = 0;
-
-my($fs_mailadmind_socket)="/usr/local/freeside/fs_mailadmind_socket";
-
-$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
-$ENV{'SHELL'} = '/bin/sh';
-$ENV{'IFS'} = " \t\n";
-$ENV{'CDPATH'} = '';
-$ENV{'ENV'} = '';
-$ENV{'BASH_ENV'} = '';
-
-$|=1;
-
-warn "[fs_mailadmind] Reading locales...\n" if $Debug;
-chomp( my $n_cust_main_county = <STDIN> );
-my @cust_main_county = map {
-  chomp( my $taxnum = <STDIN> );
-  chomp( my $state = <STDIN> );
-  chomp( my $county = <STDIN> );
-  chomp( my $country = <STDIN> );
-  {
-    'taxnum'  => $taxnum,
-    'state'   => $state,
-    'county'  => $county,
-    'country' => $country,
-  };
-} ( 1 .. $n_cust_main_county );
-
-warn "[fs_mailadmind] Reading package definitions...\n" if $Debug;
-chomp( my $n_part_pkg = <STDIN> );
-my @part_pkg = map {
-  chomp( my $pkgpart = <STDIN> );
-  chomp( my $pkg = <STDIN> );
-  {
-    'pkgpart' => $pkgpart,
-    'pkg'     => $pkg,
-  };
-} ( 1 .. $n_part_pkg );
-
-warn "[fs_mailadmind] Reading POPs...\n" if $Debug;
-chomp( my $n_svc_acct_pop = <STDIN> );
-my @svc_acct_pop = map {
-  chomp( my $popnum = <STDIN> );
-  chomp( my $city = <STDIN> );
-  chomp( my $state = <STDIN> );
-  chomp( my $ac = <STDIN> );
-  chomp( my $exch = <STDIN> );
-  chomp( my $loc = <STDIN> );
-  {
-    'popnum' => $popnum,
-    'city'   => $city,
-    'state'  => $state,
-    'ac'     => $ac,
-    'exch'   => $exch,
-    'loc'    => $loc,
-  };
-} ( 1 .. $n_svc_acct_pop );
-
-warn "[fs_mailadmind] Creating $fs_mailadmind_socket\n" if $Debug;
-my $uaddr = sockaddr_un($fs_mailadmind_socket);
-my $proto = getprotobyname('tcp');
-socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!";
-unlink($fs_mailadmind_socket);
-bind(Server, $uaddr) or die "bind: $!";
-listen(Server,SOMAXCONN) or die "listen: $!";
-
-warn "[fs_mailadmind] Entering main loop...\n" if $Debug;
-my $paddr;
-for ( ; $paddr = accept(Client,Server); close Client) {
-
-  chop( my $command = <Client> );
-
-  if ( $command eq "signup_info" ) {
-    warn "[fs_mailadmind] sending signup info...\n" if $Debug; 
-    print Client join("\n", $n_cust_main_county,
-      map {
-        $_->{taxnum},
-        $_->{state},
-        $_->{county},
-        $_->{country},
-      } @cust_main_county
-    ), "\n";
-
-    print Client join("\n", $n_part_pkg,
-      map {
-        $_->{pkgpart},
-        $_->{pkg},
-      } @part_pkg
-    ), "\n";
-
-    print Client join("\n", $n_svc_acct_pop,
-      map {
-        $_->{popnum},
-        $_->{city},
-        $_->{state},
-        $_->{ac},
-        $_->{exch},
-        $_->{loc},
-      } @svc_acct_pop
-    ), "\n";
-
-  } elsif ( $command eq "new_customer" ) {
-    warn "[fs_mailadmind] reading customer signup...\n" if $Debug;
-    my(
-      $first, $last, $ss, $company, $address1, $address2, $city, $county,
-      $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
-      $paydate, $payname, $invoicing_list, $pkgpart, $username, $password,
-      $popnum,
-    ) = map { scalar(<Client>) } ( 1 .. 23 );
-
-    warn "[fs_mailadmind] sending customer data to remote server...\n" if $Debug;
-    print 
-      $first, $last, $ss, $company, $address1, $address2, $city, $county,
-      $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo,
-      $paydate, $payname, $invoicing_list, $pkgpart, $username, $password,
-      $popnum,
-    ;
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "authenticate" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading authentication material...\n" if $Debug;
-    chop( my $password = <Client> );
-    warn "[fs_mailadmind] sending information to remote server...\n" if $Debug;
-    print "authenticate\n", $user, "\n", $password, "\n";
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-    
-  } elsif ( $command eq "list_packages" ) {
-    warn "[fs_mailadmind] reading user information to list_packages...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] sending user information to remote server...\n" if $Debug;
-    print "list_packages\n", $user, "\n";
-
-    warn "[fs_mailadmind] reading data from remote server...\n" if $Debug;
-    chomp( my $n_packages = <STDIN> );
-    my @packages = map {
-      chomp( my $pkgnum  = <STDIN> );
-      chomp( my $domain  = <STDIN> );
-      chomp( my $account = <STDIN> );
-      {
-        'pkgnum'  => $pkgnum,
-        'domain'  => $domain,
-        'account' => $account,
-      };
-    } ( 1 .. $n_packages );
-
-    warn "[fs_mailadmind] sending data to local client...\n" if $Debug;
-
-    print Client join("\n", $n_packages,
-      map {
-        $_->{pkgnum},
-        $_->{domain},
-        $_->{account},
-      } @packages
-    ), "\n";
-
-  } elsif ( $command eq "list_mailboxes" ) {
-    warn "[fs_mailadmind] reading user information to list_mailboxes...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading package number to list_mailboxes...\n" if $Debug;
-    chop( my $package = <Client> );
-    warn "[fs_mailadmind] sending user information to remote server...\n" if $Debug;
-    print "list_mailboxes\n", $user, "\n", $package, "\n";
-
-    warn "[fs_mailadmind] reading data from remote server...\n" if $Debug;
-    chomp( my $n_svc_acct = <STDIN> );
-    my @svc_acct = map {
-      chomp( my $svcnum = <STDIN> );
-      chomp( my $username = <STDIN> );
-      chomp( my $_password = <STDIN> );
-      {
-        'svcnum' => $svcnum,
-        'username' => $username,
-        '_password'     => $_password,
-      };
-    } ( 1 .. $n_svc_acct );
-
-    warn "[fs_mailadmind] sending data to local client...\n" if $Debug;
-
-    print Client join("\n", $n_svc_acct,
-      map {
-        $_->{svcnum},
-        $_->{username},
-        $_->{_password},
-      } @svc_acct
-    ), "\n";
-
-  } elsif ( $command eq "delete_mailbox" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading account information to delete...\n" if $Debug;
-    chop( my $account = <Client> );
-    warn "[fs_mailadmind] sending information to remote server...\n" if $Debug;
-    print "delete_mailbox\n", $user, "\n", $account, "\n";
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "password_mailbox" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading account information to password...\n" if $Debug;
-    my(
-      $account, $_password,
-    ) = map { scalar(<Client>) } ( 1 .. 2 );
-
-    warn "[fs_mailadmind] sending password data to remote server...\n" if $Debug;
-    print "password_mailbox", "\n";
-    print 
-      $user, "\n", $account, $_password,
-    ;
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "add_mailbox" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading account information to create...\n" if $Debug;
-    my(
-      $package, $account, $_password,
-    ) = map { scalar(<Client>) } ( 1 .. 3 );
-
-    warn "[fs_mailadmind] sending service data to remote server...\n" if $Debug;
-    print "add_mailbox", "\n";
-    print 
-      $user, "\n", $package, $account, $_password,
-    ;
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "add_forward" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading forward information to create...\n" if $Debug;
-    my(
-      $package, $source, $dest,
-    ) = map { scalar(<Client>) } ( 1 .. 3 );
-
-    warn "[fs_mailadmind] sending service data to remote server...\n" if $Debug;
-    print "add_forward", "\n";
-    print 
-      $user, "\n", $package, $source, $dest,
-    ;
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "delete_forward" ) {
-    warn "[fs_mailadmind] reading user information to auth...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading forward information to delete...\n" if $Debug;
-    chop( my $service = <Client> );
-    warn "[fs_mailadmind] sending information to remote server...\n" if $Debug;
-    print "delete_forward\n", $user, "\n", $service, "\n";
-
-    warn "[fs_mailadmind] reading error from remote server...\n" if $Debug;
-    my $error = <STDIN>;
-
-    warn "[fs_mailadmind] sending error to local client...\n" if $Debug;
-    print Client $error;
-
-  } elsif ( $command eq "list_forwards" ) {
-    warn "[fs_mailadmind] reading user information to list_forwards...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading service number to list_forwards...\n" if $Debug;
-    chop( my $service = <Client> );
-    warn "[fs_mailadmind] sending user information to remote server...\n" if $Debug;
-    print "list_forwards\n", $user, "\n", $service, "\n";
-
-    warn "[fs_mailadmind] reading data from remote server...\n" if $Debug;
-    chomp( my $n_svc_forward = <STDIN> );
-    my @svc_forward = map {
-      chomp( my $svcnum = <STDIN> );
-      chomp( my $dest = <STDIN> );
-      {
-        'svcnum' => $svcnum,
-        'dest' => $dest,
-      };
-    } ( 1 .. $n_svc_forward );
-
-    warn "[fs_mailadmind] sending data to local client...\n" if $Debug;
-
-    print Client join("\n", $n_svc_forward,
-      map {
-        $_->{svcnum},
-        $_->{dest},
-      } @svc_forward
-    ), "\n";
-
-  } elsif ( $command eq "list_pkg_forwards" ) {
-    warn "[fs_mailadmind] reading user information to list_pkg_forwards...\n" if $Debug;
-    chop( my $user = <Client> );
-    warn "[fs_mailadmind] reading service number to list_forwards...\n" if $Debug;
-    chop( my $package = <Client> );
-    warn "[fs_mailadmind] sending user information to remote server...\n" if $Debug;
-    print "list_pkg_forwards\n", $user, "\n", $package, "\n";
-
-    warn "[fs_mailadmind] reading data from remote server...\n" if $Debug;
-    chomp( my $n_svc_forward = <STDIN> );
-    my @svc_forward = map {
-      chomp( my $svcnum = <STDIN> );
-      chomp( my $srcsvc = <STDIN> );
-      chomp( my $dest = <STDIN> );
-      {
-        'svcnum' => $svcnum,
-        'srcsvc' => $srcsvc,
-        'dest' => $dest,
-      };
-    } ( 1 .. $n_svc_forward );
-
-    warn "[fs_mailadmind] sending data to local client...\n" if $Debug;
-
-    print Client join("\n", $n_svc_forward,
-      map {
-        $_->{svcnum},
-        $_->{srcsvc},
-        $_->{dest},
-      } @svc_forward
-    ), "\n";
-
-  } else {
-    die "unexpected command from client: $command";
-  }
-
-}
-
diff --git a/fs_selfadmin/README b/fs_selfadmin/README
deleted file mode 100644 (file)
index d9857f0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-
-This collection of files implements a 'self-administered mail service.'
-Configuration is similar to fs_signupd
-
-Additionally you will need to modify the database:
-
-CREATE TABLE svc_acct_admin (
-  svcnum int primary key,
-  adminsvc int not null
-);
-
-creating both as keys might be good
-
-(and perform the dbdef-create)
-
-
-As it exists now, a package containing one svc_domain, at least one
-svc_acct_admin, and other services can have its svc_acct's and svc_forward's
-manipulated by the svc_acct referenced by a svc_acct_admin in the package.
-
-One svc_acct may be referenced as svc_acct_admin for multiple packages.
-
-fs_mailadmin_server contains hard coded references to service numbers which
-will require editing for your system.
-
-It's not a lot, but it might provide inspiration.
-
diff --git a/fs_selfadmin/fs_mailadmin_server b/fs_selfadmin/fs_mailadmin_server
deleted file mode 100755 (executable)
index ef47885..0000000
+++ /dev/null
@@ -1,642 +0,0 @@
-#!/usr/bin/perl -Tw
-#
-# fs_mailadmin_server
-#
-
-use strict;
-use IO::Handle;
-use FS::SSH qw(sshopen2);
-use FS::UID qw(adminsuidsetup);
-use FS::Conf;
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_main_county;
-use FS::cust_main;
-use FS::svc_acct_admin;
-
-use vars qw( $opt $Debug $conf $default_domain );
-
-$Debug = 1;
-
-#my @payby = qw(CARD PREPAY);
-
-my $user = shift or die &usage;
-&adminsuidsetup( $user ); 
-
-$conf = new FS::Conf;
-$default_domain = $conf->config('domain');
-
-my $machine = shift or die &usage;
-
-my $agentnum = shift or die &usage;
-my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } ) or die &usage;
-my $pkgpart = $agent->pkgpart_hashref;
-
-my $refnum = shift or die &usage;
-
-#causing trouble for some folks
-#$SIG{CHLD} = sub { wait() };
-
-my($fs_mailadmind)=$conf->config('fs_mailadmind');
-
-while (1) {
-  my($reader,$writer)=(new IO::Handle, new IO::Handle);
-  $writer->autoflush(1);
-  warn "[fs_mailadmin_server] Connecting to $machine...\n" if $Debug;
-  sshopen2($machine,$reader,$writer,$fs_mailadmind);
-
-  my $data;
-
-  warn "[fs_mailadmin_server] Sending locales...\n" if $Debug;
-  my @cust_main_county = qsearch('cust_main_county', {} );
-  print $writer $data = join("\n",
-    ( scalar(@cust_main_county) || die "no tax rates (cust_main_county records)" ),
-    map {
-      $_->taxnum,
-      $_->state,
-      $_->county,
-      $_->country,
-    } @cust_main_county
-  ),"\n";
-  warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-  warn "[fs_mailadmin_server] Sending package definitions...\n" if $Debug;
-  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" ),
-    map {
-      $_->pkgpart,
-      $_->pkg,
-    } @part_pkg
-  ), "\n";
-  warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-  warn "[fs_mailadmin_server] Sending POPs...\n" if $Debug;
-  my @svc_acct_pop = qsearch ('svc_acct_pop',{} );
-  print $writer $data = join("\n",
-    ( scalar(@svc_acct_pop) || die "No points of presence (svc_acct_pop records)" ),
-    map {
-      $_->popnum,
-      $_->city,
-      $_->state,
-      $_->ac,
-      $_->exch,
-      $_->loc,
-    } @svc_acct_pop
-  ), "\n";
-  warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-  warn "[fs_mailadmin_server] Entering main loop...\n" if $Debug;
-COMMAND:  while (1) {
-    warn "[fs_mailadmin_server] Reading (waiting for) command...\n" if $Debug;
-    chop( my($command, $user) = map { scalar(<$reader>) } ( 1 .. 2 ) );
-    my $domain = $default_domain;
-    $user =~ /^([\w\.\-]+)\@(([\w\-]+\.)+\w+)$/;
-    ($user, $domain) = ($1, $2);
-
-    if ($command eq 'authenticate'){
-      warn "[fs_mailadmin_server] Processing authenticate command for $user \n" if $Debug;
-      chop( my($password) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-
-      my $error = '';
-
-      my @svc_domain = qsearchs('svc_domain', { 'domain'   => $domain });
-
-      if (scalar(@svc_domain) != 1) {
-        warn "Nonexistant or duplicate service account for \"$domain\"";
-        next COMMAND;
-      }
-
-      my @svc_acct = qsearchs('svc_acct', { 'username' => $user,
-                                            'domsvc'   => $svc_domain[0]->svcnum });
-      if (scalar(@svc_acct) != 1) {
-        die "Nonexistant or duplicate service account for \"$user\"";
-        next COMMAND;
-      }
-
-      if ($svc_acct[0]->_password eq $password) {
-        $error = "$user\@$domain OK";
-      }else{
-        $error = "$user\@$domain FAILED";
-      }
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-    }
-    elsif ($command eq 'list_packages'){
-      warn "[fs_mailadmin_server] Processing list_packages command for $user \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval {find_administrable_packages( $user, $domain )};
-      warn "$@" if $@; 
-
-      my %packages;
-      my %accounts;
-
-      foreach my $package (@packages) {
-        $packages{my $pkgnum = $package->getfield('pkgnum')} = $default_domain;
-        $accounts{$pkgnum} = 0;
-        my @services = qsearch('cust_svc', { 'pkgnum' => $pkgnum });
-        foreach my $service (@services) {
-          if ($service->getfield('svcpart') eq '4'){
-            my $account=qsearchs('svc_domain', { 'svcnum' => $service->getfield('svcnum') });
-            $packages{$pkgnum}=$account->getfield('domain');
-            $accounts{$pkgnum}=$account->getfield('svcnum');
-          }
-        }
-      }
-      
-      print $writer $data = join("\n",
-        ( scalar(keys(%packages)) ),
-        map {
-          $_,
-          $packages{$_},
-          $accounts{$_},
-        } keys(%packages)
-      ), "\n";
-      warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-    }elsif ($command eq 'list_mailboxes'){
-
-      warn "[fs_mailadmin_server] Processing list_mailboxes command for $user" if $Debug;
-      chop( my($pkgnum) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-      warn "package $pkgnum \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval {find_administrable_packages( $user, $domain )};
-      warn "$@" if $@; 
-
-      my @accounts;
-
-      foreach my $package (@packages) {
-        next unless ($pkgnum eq $package->getfield('pkgnum'));
-        my @services = qsearch('cust_svc', { 'pkgnum' => $package->getfield('pkgnum') });
-        foreach my $service (@services) {
-          if ($service->getfield('svcpart') eq '2'){
-            my $account=qsearchs('svc_acct', { 'svcnum' => $service->getfield('svcnum') });
-#           $accounts[$#accounts+1]=$account->getfield('username');
-            $accounts[$#accounts+1]=$account;
-          }
-        }
-      }
-      
-      print $writer $data = join("\n",
-#        ( scalar(@accounts) || die "No accounts (svc_acct records)" ),
-        ( scalar(@accounts) ),
-        map {
-          $_->svcnum,
-#          $_->username,
-          $_->email,
-#          $_->_password,
-          '*****',
-        } @accounts
-      ), "\n";
-      warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-      
-    } elsif ($command eq 'delete_mailbox'){
-      warn "[fs_mailadmin_server] Processing delete_mailbox command for $user " if $Debug;
-      chop( my($account) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-      warn "account $account \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval { find_administrable_packages($user, $domain) };
-      warn "$@" if $@; 
-      $error ||= "$@" if $@; 
-
-      my @svc_acct = qsearchs('svc_acct', { 'svcnum' => $account }) unless $error;
-      if (scalar(@svc_acct) != 1) { $error ||= 'Nonexistant or duplicate service account for user.' };
-      if (! $error && check_administrator(\@packages, $svc_acct[0])){
-# not sure about the next three lines... do we delete? or return error
-        foreach my $svc_forward (qsearch('svc_forward', { 'dstsvc' => $svc_acct[0]->getfield('svcnum') })) {
-          $error ||= $svc_forward->delete;
-        }
-        foreach my $svc_forward (qsearch('svc_forward', { 'srcsvc' => $svc_acct[0]->getfield('svcnum') })) {
-          $error ||= $svc_forward->delete;
-        }
-        $error ||= $svc_acct[0]->delete;
-      } else {
-        $error ||= "Illegal attempt to remove service";
-      }
-
-      
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-      
-    } elsif ($command eq 'password_mailbox'){
-      warn "[fs_mailadmin_server] Processing password_mailbox command for $user " if $Debug;
-      chop( my($account, $_password) = map { scalar(<$reader>) } ( 1 .. 2 ) );
-      warn "account $account with password $_password \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval { find_administrable_packages($user, $domain) };
-      warn "$@" if $@; 
-      $error ||= "$@" if $@; 
-
-      my @svc_acct = qsearchs('svc_acct', { 'svcnum' => $account }) unless $error;
-      if (scalar(@svc_acct) != 1) { $error ||= 'Nonexistant or duplicate service account.' };
-
-      if (! $error && check_administrator(\@packages, $svc_acct[0])){
-        my $new = new FS::svc_acct ({$svc_acct[0]->hash});
-        $new->setfield('_password' => $_password);
-        $error ||= $new->replace($svc_acct[0]);
-      } else {
-        $error ||= "Illegal attempt to change password";
-      }
-
-      
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-      
-    } elsif ($command eq 'add_mailbox'){
-      warn "[fs_mailadmin_server] Processing add_mailbox command for $user " if $Debug;
-      chop( my($target_package, $account, $_password) = map { scalar(<$reader>) } ( 1 .. 3 ) );
-      warn "in package $target_package account $account with password $_password \n" if $Debug;
-
-      my $found_package;
-      my $domainsvc=0;
-      my $svcpart=2;    # this is 'email box'
-      my $svcpartsm=3;  # this is 'domain alias'
-      my $error = '';
-      my $found = 0;
-
-      my @packages = eval { find_administrable_packages($user, $domain) };
-      warn "$@" if $@; 
-      $error ||= "$@" if $@; 
-
-      foreach my $package (@packages) {
-        if ($package->getfield('pkgnum') eq $target_package) {
-          $found = 1;
-          $found_package=$package;
-          my @services = qsearch('cust_svc', { 'pkgnum' => $target_package });
-          foreach my $service (@services) {
-            if ($service->getfield('svcpart') eq '4'){
-              my @svc_domain=qsearchs('svc_domain', { 'svcnum' => $service->getfield('svcnum') });
-              if (scalar(@svc_domain) eq 1) {
-                $domainsvc=$svc_domain[0]->getfield('svcnum');
-              }
-            }
-          }
-          last;
-        }
-      }
-      warn "User $user does not have administration rights to package $target_package\n" unless $found;
-      $error ||= "User $user does not have administration rights to package $target_package\n" unless $found;
-
-      my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$found_package->getfield('pkgpart')});
-
-      #list of services this pkgpart includes (although at the moment we only care
-      #  about $svcpart
-      my $pkg_svc;
-      my %pkg_svc = ();
-      foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $found_package->pkgpart }) ) {
-        $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity;
-      }
-
-      my @services = qsearch('cust_svc', {'pkgnum'  => $found_package->getfield('pkgnum'),
-                                          'svcpart' => $svcpart,
-                                         });
-
-      if (scalar(@services) >= $pkg_svc{$svcpart}) {
-        $error="Maximum allowed already reached.";
-      }
-      
-      my $svc_acct = new FS::svc_acct ( {
-        'pkgnum'    => $found_package->pkgnum,
-        'svcpart'   => $svcpart,
-        'username'  => $account,
-        'domsvc'    => $domainsvc,
-        '_password' => $_password,
-      } );
-
-      my $y = $svc_acct->setdefault; # arguably should be in new method
-      $error ||= $y unless ref($y);
-      #and just in case you were silly
-      $svc_acct->pkgnum($found_package->pkgnum);
-      $svc_acct->svcpart($svcpart);
-      $svc_acct->username($account);
-      $svc_acct->domsvc($domainsvc);
-      $svc_acct->_password($_password);
-
-      $error ||= $svc_acct->check;
-
-      if ( ! $error ) { #in this case, $cust_pkg should always
-                                     #be definied, but....
-        $error ||= $svc_acct->insert;
-        warn "WARNING: $error on pre-checked svc_acct record!" if $error;
-      }
-
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-      
-    }elsif ($command eq 'list_forwards'){
-
-      warn "[fs_mailadmin_server] Processing list_forwards command for $user" if $Debug;
-      chop( my($svcnum) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-      warn "service $svcnum \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval {find_administrable_packages( $user, $domain )};
-      warn "$@" if $@; 
-
-      my @forwards;
-
-      foreach my $package (@packages) {
-#        next unless ($pkgnum eq $package->getfield('pkgnum'));
-        my @services = qsearch('cust_svc', { 'pkgnum' => $package->getfield('pkgnum') });
-        foreach my $service (@services) {
-          if ($service->getfield('svcpart') eq '10'){
-            my $forward=qsearchs('svc_forward', { 'svcnum' => $service->getfield('svcnum') });
-            $forwards[$#forwards+1]=$forward if ($forward->getfield('srcsvc') == $svcnum);
-          }
-        }
-      }
-      
-      print $writer $data = join("\n",
-        ( scalar(@forwards) ),
-        map {
-          $_->svcnum,
-          ($_->dstsvc ? qsearchs('svc_acct', {'svcnum' => $_->dstsvc})->email : $_->dst),
-        } @forwards
-      ), "\n";
-      warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-      
-    }elsif ($command eq 'list_pkg_forwards'){
-
-      warn "[fs_mailadmin_server] Processing list_pkg_forwards command for $user" if $Debug;
-      chop( my($pkgnum) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-      warn "package $pkgnum \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval {find_administrable_packages( $user, $domain )};
-      warn "$@" if $@; 
-
-      my @forwards;
-
-      foreach my $package (@packages) {
-        next unless ($pkgnum eq $package->getfield('pkgnum'));
-        my @services = qsearch('cust_svc', { 'pkgnum' => $package->getfield('pkgnum') });
-        foreach my $service (@services) {
-          if ($service->getfield('svcpart') eq '10'){
-            my $forward=qsearchs('svc_forward', { 'svcnum' => $service->getfield('svcnum') });
-            $forwards[$#forwards+1]=$forward;
-          }
-        }
-      }
-      
-      print $writer $data = join("\n",
-        ( scalar(@forwards) ),
-        map {
-          $_->svcnum,
-          $_->srcsvc,
-          ($_->dstsvc ? qsearchs('svc_acct', {'svcnum' => $_->dstsvc})->email : $_->dst),
-        } @forwards
-      ), "\n";
-      warn "[fs_mailadmin_server] $data\n" if $Debug > 2;
-
-      
-    } elsif ($command eq 'delete_forward'){
-      warn "[fs_mailadmin_server] Processing delete_forward command for $user " if $Debug;
-      chop( my($forward) = map { scalar(<$reader>) } ( 1 .. 1 ) );
-      warn "forward $forward \n" if $Debug;
-
-      my $error = '';
-
-      my @packages = eval { find_administrable_packages($user, $domain) };
-      warn "$@" if $@; 
-      $error ||= "$@" if $@; 
-
-      my @svc_forward = qsearchs('svc_forward', { 'svcnum' => $forward }) unless $error;
-      if (scalar(@svc_forward) != 1) { $error ||= 'Nonexistant or duplicate service account for user.' };
-      if (! $error && check_administrator(\@packages, $svc_forward[0])){
-# not sure about the next three lines... do we delete? or return error
-        $error ||= $svc_forward[0]->delete;
-      } else {
-        $error ||= "Illegal attempt to remove service";
-      }
-
-      
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-      
-    } elsif ($command eq 'add_forward'){
-      warn "[fs_mailadmin_server] Processing add_forward command for $user " if $Debug;
-      chop( my($target_package, $source, $dest) = map { scalar(<$reader>) } ( 1 .. 3 ) );
-      warn "in package $target_package source $source with destination $dest \n" if $Debug;
-
-      my $found_package;
-      my $domainsvc=0;
-      my $svcpart=10;   # this is 'forward service'
-      my $error = '';
-      my $found = 0;
-
-      my @packages = eval { find_administrable_packages($user, $domain) };
-      warn "$@" if $@; 
-      $error ||= "$@" if $@; 
-
-      foreach my $package (@packages) {
-        if ($package->getfield('pkgnum') eq $target_package) {
-          $found = 1;
-          $found_package=$package;
-          last;
-        }
-      }
-      warn "User $user does not have administration rights to package $target_package\n" unless $found;
-      $error ||= "User $user does not have administration rights to package $target_package\n" unless $found;
-
-      my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $source });
-      warn "Forwarding source $source does not exist.\n" unless $svc_acct;
-      $error ||= "Forwarding source $source does not exist.\n" unless $svc_acct;
-
-      my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $source });
-      warn "Forwarding source $source not attached to any account.\n" unless $cust_svc;
-      $error ||= "Forwarding source $source not attached to any account.\n" unless $cust_svc;
-
-      if ( ! $error ) {
-        warn "Forwarding source $source is not in package $target_package\n"
-          unless ($cust_svc->getfield('pkgnum') == $target_package);
-        $error ||= "Forwarding source $source is not in package $target_package\n"
-          unless ($cust_svc->getfield('pkgnum') == $target_package);
-      }
-
-      my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$found_package->getfield('pkgpart')});
-
-      #list of services this pkgpart includes (although at the moment we only care
-      #  about $svcpart
-      my $pkg_svc;
-      my %pkg_svc = ();
-      foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $found_package->pkgpart }) ) {
-        $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity;
-      }
-
-      my @services = qsearch('cust_svc', {'pkgnum'  => $found_package->getfield('pkgnum'),
-                                          'svcpart' => $svcpart,
-                                         });
-
-      if (scalar(@services) >= $pkg_svc{$svcpart}) {
-        $error="Maximum allowed already reached.";
-      }
-      
-      my $svc_forward = new FS::svc_forward ( {
-        'pkgnum'    => $found_package->pkgnum,
-        'svcpart'   => $svcpart,
-        'srcsvc'  => $source,
-        'dstsvc'    => 0,
-        'dst' => $dest,
-      } );
-
-      my $y = $svc_forward->setdefault; # arguably should be in new method
-      $error ||= $y unless ref($y);
-      #and just in case you were silly
-      $svc_forward->pkgnum($found_package->pkgnum);
-      $svc_forward->svcpart($svcpart);
-      $svc_forward->srcsvc($source);
-      $svc_forward->dstsvc(0);
-      $svc_forward->dst($dest);
-
-      $error ||= $svc_forward->check;
-
-      if ( ! $error ) { #in this case, $cust_pkg should always
-                                     #be definied, but....
-        $error ||= $svc_forward->insert;
-        warn "WARNING: $error on pre-checked svc_forward record!" if $error;
-      }
-
-      warn "[fs_mailadmin_server] Sending results...\n" if $Debug;
-      print $writer $error, "\n";
-      
-    } else {
-      warn "[fs_mailadmin_server] Bad command: $command \n" if $Debug;
-      print $writer "Bad command \n";
-    }
-  }
-  close $writer;
-  close $reader;
-  warn "connection to $machine lost!  waiting 60 seconds...\n";
-  sleep 60;
-  warn "reconnecting...\n";
-}
-
-sub usage {
-  die "Usage:\n\n  fs_mailadmin_server user machine agentnum refnum\n";
-}
-
-#sub find_administrable_packages {
-#      my $user = shift;
-#
-#      my $error = '';
-#
-#      my @svc_acct = qsearchs('svc_acct', { 'username' => $user });
-#      if (scalar(@svc_acct) != 1) {
-#        die "Nonexistant or duplicate service account for \"$user\"";
-#      }
-#
-#      my @cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct[0]->getfield('svcnum') });
-#      if (scalar(@cust_svc) != 1 ) {
-#        die "Nonexistant or duplicate customer service for \"$user\"";
-#      }
-#
-#      my @cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc[0]->getfield('pkgnum') });
-#      if (scalar(@cust_pkg) != 1) {
-#        die "Nonexistant or duplicate customer package for \"$user\"";
-#      }
-#
-#      my @cust_main = qsearchs('cust_main', { 'custnum' => $cust_pkg[0]->getfield('custnum') });
-#      if (scalar(@cust_main) != 1 ) {
-#        die "Nonexistant or duplicate customer for \"$user\"";
-#      }
-#
-#      my @packages = $cust_main[0]->ncancelled_pkgs;
-#}
-
-sub find_administrable_packages {
-      my $user = shift;
-      my $domain = shift;
-
-      my @packages;
-      my $error = '';
-
-      my @svc_domain = qsearchs('svc_domain', { 'domain'   => $domain });
-
-      if (scalar(@svc_domain) != 1) {
-        die "Nonexistant or duplicate service account for \"$domain\"";
-      }
-
-      my @svc_acct = qsearchs('svc_acct', { 'username' => $user,
-                                            'domsvc'   => $svc_domain[0]->svcnum });
-      if (scalar(@svc_acct) != 1) {
-        die "Nonexistant or duplicate service account for \"$user\"";
-      }
-
-      my @svc_acct_admin = qsearch('svc_acct_admin', {'adminsvc' => $svc_acct[0]->getfield('svcnum') });
-      die "Nonexistant or duplicate customer service for \"$user\"" unless scalar(@svc_acct_admin);
-
-      foreach my $svc_acct_admin (@svc_acct_admin) {
-        my @cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct_admin->getfield('svcnum') });
-        if (scalar(@cust_svc) != 1 ) {
-          die "Nonexistant or duplicate customer service for admin \"$svc_acct_admin->getfield('svcnum')\"";
-        }
-
-        my @cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc[0]->getfield('pkgnum') });
-        if (scalar(@cust_pkg) != 1) {
-          die "Nonexistant or duplicate customer package for admin \"$user\"";
-        }
-
-        push @packages, $cust_pkg[0] unless $cust_pkg[0]->getfield('cancel');
-
-      }
-      (@packages);
-}
-
-sub check_administrator {
-      my ($allowed_packages_aref, $svc_acct_ref) = @_;
-
-      my $error = '';
-      my $found = 0;
-
-      {
-        my @cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_acct_ref->getfield('svcnum') });
-        if (scalar(@cust_svc) != 1 ) {
-          warn "Nonexistant or duplicate customer service for \"$svc_acct_ref->getfield('username')\"";
-          last;
-        }
-
-        my @cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_svc[0]->getfield('pkgnum') });
-        if (scalar(@cust_pkg) != 1) {
-          warn "Nonexistant or duplicate customer package for \"$svc_acct_ref->getfield('username')\"";
-          last;
-        }
-
-        foreach my $package (@$allowed_packages_aref) {
-          if ($package->getfield('pkgnum') eq $cust_pkg[0]->getfield('pkgnum')) {
-            $found = 1;
-            last;
-          }
-        }
-      }
-
-      $found;
-}
-
-sub check_add {
-      my ($allowed_packages_aref, $target_package) = @_;
-
-      my $error = '';
-      my $found = 0;
-
-      foreach my $package (@$allowed_packages_aref) {
-        if ($package->getfield('pkgnum') eq $target_package) {
-          $found = 1;
-          last;
-        }
-      }
-
-      $found;
-}
-
index 816b821..08d8a4d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: signup.cgi,v 1.30 2002-08-26 19:07:10 khoff Exp $
+# $Id: signup.cgi,v 1.29 2002-05-30 22:45:20 ivan Exp $
 
 use strict;
 use vars qw( @payby $cgi $locales $packages $pops $init_data $error
@@ -359,8 +359,7 @@ sub pop_info {
 
 #horrible false laziness with FS/FS/svc_acct_pop.pm::popselector
 sub popselector {
-
-  my( $popnum ) = @_;
+  my( $popnum, $state ) = @_;
 
   return '<INPUT TYPE="hidden" NAME="popnum" VALUE="">' unless @$pops;
   return $pops->[0]{city}. ', '. $pops->[0]{state}.
@@ -369,9 +368,7 @@ sub popselector {
     if scalar(@$pops) == 1;
 
   my %pop = ();
-  foreach (@$pops) {
-    push @{ $pop{ $_->{state} }->{ $_->{ac} } }, $_;
-  }
+  push @{ $pop{$_->{state}} }, $_ foreach @$pops;
 
   my $text = <<END;
     <SCRIPT>
@@ -380,82 +377,45 @@ sub popselector {
       var length = what.length;
       what.options[length] = optionName;
     }
-
-    function acstate_changed(what) {
+    
+    function popstate_changed(what) {
       state = what.options[what.selectedIndex].text;
-      for (var i = what.form.popac.length;i > 0;i--)
-                what.form.popac.options[i] = null;
-      what.form.popac.options[0] = new Option("Area code", "-1", false, true);
-END
-
-  foreach my $state ( sort { $a cmp $b } keys %pop ) {
-    $text .= "\nif ( state == \"$state\" ) {\n";
-
-    foreach my $ac ( sort { $a cmp $b } keys %{ $pop{$state} }) {
-      $text .= "opt(what.form.popac, \"$ac\", \"$ac\");\n";
-      if ($ac eq $cgi->param('popac')) {
-        $text .= "what.form.popac.options[what.form.popac.length-1].selected = true;\n";
-      }
-    }
-    $text .= "}\n";
-  }
-  $text .= "popac_changed(what.form.popac)}\n";
-
-  $text .= <<END;
-  function popac_changed(what) {
-    ac = what.options[what.selectedIndex].text;
-    for (var i = what.form.popnum.length;i > 0;i--)
-        what.form.popnum.options[i] = null;
-    what.form.popnum.options[0] = new Option("City", "-1", false, true);
-
+      for (var i = what.form.popnum.length;i > 0;i--)
+                what.form.popnum.options[i] = null;
+      what.form.popnum.options[0] = new Option("", "", false, true);
 END
 
-  foreach my $state ( keys %pop ) {
-    foreach my $popac ( keys %{ $pop{$state} } ) {
-      $text .= "\nif ( ac == \"$popac\" ) {\n";
+  foreach my $popstate ( sort { $a cmp $b } keys %pop ) {
+    $text .= "\nif ( state == \"$popstate\" ) {\n";
 
-      foreach my $pop ( @{$pop{$state}->{$popac}}) {
-        my $o_popnum = $pop->{popnum};
-        my $poptext =  $pop->{city}. ', '. $pop->{state}.
-                       ' ('. $pop->{ac}. ')/'. $pop->{exch};
+    foreach my $pop ( @{$pop{$popstate}}) {
+      my $o_popnum = $pop->{popnum};
+      my $poptext =  $pop->{city}. ', '. $pop->{state}.
+                     ' ('. $pop->{ac}. ')/'. $pop->{exch};
 
-        $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 .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
     }
+    $text .= "}\n";
   }
 
-
   $text .= "}\n</SCRIPT>\n";
 
   $text .=
-    qq!<TABLE CELLPADDING="0"><TR><TD><SELECT NAME="acstate"! .
-    qq!SIZE=1 onChange="acstate_changed(this)"><OPTION VALUE=-1>State!;
-  $text .= "<OPTION" . ($_ eq $cgi->param('acstate') ? " SELECTED" : "") .
-           ">$_" foreach sort { $a cmp $b } keys %pop;
-  $text .= '</SELECT>'; #callback? return 3 html pieces?  #'</TD>';
+    qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
+    qq!<OPTION> !;
+  $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %pop;
+  $text .= '</SELECT>'; #callback? return 3 html pieces?  #'</TD><TD>';
 
-  $text .=
-    qq!<SELECT NAME="popac" SIZE=1 onChange="popac_changed(this)">!.
-    qq!<OPTION>Area code</SELECT></TR><TR VALIGN="top">!;
-
-  $text .= qq!<TR><TD><SELECT NAME="popnum" SIZE=1 STYLE="width: 20em"><OPTION>City!;
-
-  #comment this block to disable initial list polulation
-  foreach my $pop ( sort { $a->{state} cmp $b->{state} } @$pops ) {
+  $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
+  foreach my $pop ( @$pops ) {
     $text .= qq!<OPTION VALUE="!. $pop->{popnum}. '"'.
              ( ( $popnum && $pop->{popnum} == $popnum ) ? ' SELECTED' : '' ). ">".
              $pop->{city}. ', '. $pop->{state}.
                ' ('. $pop->{ac}. ')/'. $pop->{exch};
   }
-
-  $text .= qq!</SELECT></TD></TR></TABLE>!;
+  $text .= '</SELECT>';
 
   $text;
-
 }
 
 sub expselect {
index 9fb359d..0a06d8d 100755 (executable)
@@ -25,11 +25,13 @@ function part_export_areyousure(href) {
 
     Services are items you offer to your customers.<BR><BR>
 
-<FORM METHOD="POST" ACTION="<%= $p %>edit/part_svc.cgi"><A HREF="<%= $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A>&nbsp;or&nbsp;<SELECT NAME="clone"><OPTION></OPTION>
+<FORM METHOD="POST" ACTION="<%= $p %>edit/part_svc.cgi">
+<A HREF="<%= $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A><% if ( @part_svc ) { %>&nbsp;or&nbsp;<SELECT NAME="clone"><OPTION></OPTION>
 <% foreach my $part_svc ( @part_svc ) { %>
   <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION>
 <% } %>
 </SELECT><INPUT TYPE="submit" VALUE="Clone existing service">
+<% } %>
 </FORM><BR>
 
 <%= $total %> services
index 00c863b..eaa5b9b 100644 (file)
@@ -11,6 +11,7 @@
   <li><a href="upgrade6.html">Upgrading from 1.2.3 to 1.3.0</a>
   <li><a href="upgrade7.html">Upgrading from 1.3.0 to 1.3.1</a>
   <li><a href="upgrade8.html">Upgrading from 1.3.1 to 1.4.0</a>
+  <li><a href="upgrade9.html">Upgrading from 1.4.0 to 1.4.1</a>
 <!--
   <li><a href="config.html">Configuration files</a>
 !-->
diff --git a/httemplate/docs/upgrade9.html b/httemplate/docs/upgrade9.html
new file mode 100644 (file)
index 0000000..fff1d86
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+  <title>Upgrading to 1.4.1</title>
+</head>
+<body>
+<h1>Upgrading to 1.4.1 from 1.4.0</h1>
+<ul>
+  <li>If migrating from less than 1.4.0, see these <a href="upgrade8.html">instructions</a> first.
+  <li>Back up your data and current Freeside installation.
+  <li>Run <code>make aspdocs</code> or <code>make masondocs</code>.
+  <li>Copy <code>aspdocs/</code> or <code>masondocs/</code> to your web server's document space.
+  <li>Run <code>make install-perl-modules</code>.
+  <li>Restart Apache and freeside-queued.
+</body>
index 831b2ab..3a5df08 100755 (executable)
@@ -231,7 +231,7 @@ END
 
   print '<BR>Service address ',
         '(<INPUT TYPE="checkbox" NAME="same" VALUE="Y" onClick="samechanged(this)"';
-  unless ( $cust_main->ship_last ) {
+  unless ( $cust_main->ship_last && $cgi->param('same') ne 'Y' ) {
     print ' CHECKED';
     foreach (
       qw( last first company address1 address2 city county state zip country
index 35a5fc1..dce020b 100644 (file)
       <A HREF="browse/nas.cgi">View active NAS ports</A>
       <BR><A HREF="browse/queue.cgi">View pending job queue</A>
       <BR><A HREF="misc/cust_main-import.cgi">Batch import customers from CSV file</A>
+      <BR><A HREF="misc/cust_main-import_charges.cgi">Batch import charges from CSV file</A>
       <BR><BR><CENTER><HR WIDTH="94%" NOSHADE></CENTER><BR>
       <A NAME="config" HREF="config/config-view.cgi">Configuration</a><!-- - <font size="+2" color="#ff0000">start here</font> -->
       <BR><BR><A NAME="admin">Administration</a>
diff --git a/httemplate/misc/cust_main-import_charges.cgi b/httemplate/misc/cust_main-import_charges.cgi
new file mode 100644 (file)
index 0000000..0822b9e
--- /dev/null
@@ -0,0 +1,14 @@
+<!-- mason kludge -->
+<%= header('Batch Customer Charge') %>
+<FORM ACTION="process/cust_main-import_charges.cgi" METHOD="post" ENCTYPE="multipart/form-data">
+Import a CSV file containing customer charges.<BR><BR>
+Default file format is CSV, with the following field order: <i>custnum, amount, description</i><BR><BR>
+If <i>amount</i> is negative, a credit will be applied instead.<BR><BR>
+<BR><BR>
+
+    CSV Filename: <INPUT TYPE="file" NAME="csvfile"><BR><BR>
+    <INPUT TYPE="submit" VALUE="Import">
+    </FORM>
+  </BODY>
+<HTML>
+
diff --git a/httemplate/misc/process/cust_main-import_charges.cgi b/httemplate/misc/process/cust_main-import_charges.cgi
new file mode 100644 (file)
index 0000000..14df1bd
--- /dev/null
@@ -0,0 +1,26 @@
+<%
+
+  my $fh = $cgi->upload('csvfile');
+  #warn $cgi;
+  #warn $fh;
+
+  my $error = defined($fh)
+    ? FS::cust_main::batch_charge( {
+        filehandle => $fh,
+        'fields'    => [qw( custnum amount pkg )],
+      } )
+    : 'No file';
+
+  if ( $error ) {
+    %>
+    <!-- mason kludge -->
+    <%
+    eidiot($error);
+#    $cgi->param('error', $error);
+#    print $cgi->redirect( "${p}cust_main-import_charges.cgi
+  } else {
+    %>
+    <!-- mason kludge -->
+    <%= header('Import sucessful') %> <%
+  }
+%>