change configuration file layout to support multiple distinct databases (with
authorivan <ivan>
Fri, 13 Nov 1998 09:56:57 +0000 (09:56 +0000)
committerivan <ivan>
Fri, 13 Nov 1998 09:56:57 +0000 (09:56 +0000)
own set of config files, export, etc.)

24 files changed:
TODO
htdocs/docs/man/CGI.txt
htdocs/docs/man/Conf.txt
htdocs/docs/man/Record.txt
htdocs/docs/man/UID.txt
htdocs/docs/man/cust_bill.txt
htdocs/docs/man/cust_main.txt
htdocs/docs/man/cust_pkg.txt
htdocs/docs/man/cust_svc.txt
htdocs/docs/man/dbdef_table.txt
htdocs/docs/man/svc_acct.txt
htdocs/docs/man/svc_domain.txt
htdocs/edit/agent_type.cgi
htdocs/edit/svc_acct_pop.cgi
htdocs/edit/svc_domain.cgi
htdocs/view/cust_pkg.cgi
htdocs/view/svc_domain.cgi
site_perl/Record.pm
site_perl/UID.pm
site_perl/cust_bill.pm
site_perl/cust_main.pm
site_perl/svc_acct.pm
site_perl/svc_acct_sm.pm
site_perl/svc_domain.pm

diff --git a/TODO b/TODO
index 71535ac..1d21d81 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.12 1998-11-07 08:25:10 ivan Exp $
+$Id: TODO,v 1.13 1998-11-13 09:56:33 ivan Exp $
 
 If you are interested in helping with any of these, please join the mailing
 list (send a blank message to ivan-freeside-subscribe@sisd.com) to avoid 
@@ -6,14 +6,18 @@ duplication of effort.
 
 -- 1.1.x --
 
-qsearch[s] (or just put in new?) in FS::Record should bless the object
-into the appropriate derived class automagically, if possible?
+remove whois_hack set to 1 for svc_domain.pm?  add all known registries and
+whois accordingly.
+
+get rid of all relative URL's (have to make them on the fly) - see doc for
+->redirect in CGI.pm
 
 radius logfile parsing and perl expression check.
 
-mailing list archive, faq
+faq
 
-(test cust_main.pm with cybercash v2 and v3)
+(test cust_main.pm with cybercash v2 and v3, especially with the callback
+ stuff)
 
 Fix in cust_bill BUGS: 
 There is an off-by-one error in print_text which causes a visual error (Page 1
@@ -25,8 +29,6 @@ rep silliness!
 fields should be a method against a FS::Record or derived object, as well as
 being something you can call as FS::Record::fields('tablename').  Might
 even be able to handle both in the same routine (that would be neato).
-Get rid of hfields and other assorted silliness.
-Clean up hfields/sfields/fields crap.  yuck.
 
 Override FS::Record new, add, rep and del (create, insert, replace and
 delete) in all derived classes.
@@ -297,9 +299,6 @@ export a debian-style (also redhat and?) /etc/group file aswell!
 seems to be an off-by-one error in the ascii invoice formatting which is saying
 "1 of 2" pages when there is only one.
 
-get rid of agrep?  needs the (non-free) glimpse distribution.  agrep used to
-be free?  what else can do fuzzy searching?
-
 site_perl/svc_domain.cgi (hmm... or maybe should have a button?  or maybe svc_domain.pm should handle this) should set $whois_hack for non-internic domains, so you can add them...
 
 svc_acct_sm.import qmail import should pull in recipientmap people too.
index 54f9b8a..15a5ca1 100644 (file)
@@ -2,7 +2,7 @@ NAME
     FS::CGI - Subroutines for the web interface
 
 SYNOPSIS
-      use FS::CGI qw(header menubar idiot eidiot);
+      use FS::CGI qw(header menubar idiot eidiot popurl);
 
       print header( 'Title', '' );
       print header( 'Title', menubar('item', 'URL', ... ) );
@@ -10,6 +10,9 @@ SYNOPSIS
       idiot "error message"; 
       eidiot "error message";
 
+      $url = popurl; #returns current url
+      $url = popurl(3); #three levels up
+
 DESCRIPTION
     Provides a few common subroutines for the web interface.
 
@@ -26,15 +29,20 @@ SUBROUTINES
     eidiot ERROR
         Sends headers and an HTML error message, then exits.
 
+    popurl LEVEL
+        Returns current URL with LEVEL levels of path removed from
+        the end (default 0).
+
+    table
+        Returns HTML tag for beginning a table.
+
 BUGS
     Not OO.
 
     Not complete.
 
-    Uses CGI-modules instead of CGI.pm
-
 SEE ALSO
-    the CGI::Base manpage
+    the CGI manpage, the CGI::Base manpage
 
 HISTORY
     subroutines for the HTML/CGI GUI, not properly OO. :(
@@ -45,3 +53,23 @@ HISTORY
 
     pod ivan@sisd.com 98-sep-12
 
+    $Log: CGI.txt,v $
+    Revision 1.2  1998-11-13 09:56:34  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.11 1998/11/12 07:43:54 ivan ***
+    empty log message ***
+
+    Revision 1.10 1998/11/12 01:53:47 ivan added table command
+
+    Revision 1.9 1998/11/09 08:51:49 ivan bug squash
+
+    Revision 1.7 1998/11/09 06:10:59 ivan added sub url
+
+    Revision 1.6 1998/11/09 05:44:20 ivan *** empty log message ***
+
+    Revision 1.4 1998/11/09 04:55:42 ivan support depriciated
+    CGI::Base as well as CGI.pm (for now)
+
+    Revision 1.3 1998/11/08 10:50:19 ivan s/CGI::Base/CGI/; etc.
+
index 5e7be7f..816df79 100644 (file)
@@ -4,8 +4,10 @@ NAME
 SYNOPSIS
       use FS::Conf;
 
+      $conf = new FS::Conf "/config/directory";
+
+      $FS::Conf::default_dir = "/config/directory";
       $conf = new FS::Conf;
-      $conf = new FS::Conf "/non/standard/config/directory";
 
       $dir = $conf->dir;
 
@@ -19,8 +21,8 @@ DESCRIPTION
 
 METHODS
     new [ DIRECTORY ]
-        Create a new configuration object. Optionally, a non-default
-        directory may be specified.
+        Create a new configuration object. A directory arguement is
+        required if $FS::Conf::default_dir has not been set.
 
     dir Returns the directory.
 
@@ -33,9 +35,6 @@ METHODS
         corresponding value is undefined.
 
 BUGS
-    The option to specify a non-default directory should probably be
-    removed.
-
     Write access (with locking) should be implemented.
 
 SEE ALSO
@@ -47,3 +46,9 @@ HISTORY
 
     sub exists forgot to fetch $dir ivan@sisd.com 98-sep-27
 
+    $Log: Conf.txt,v $
+    Revision 1.4  1999-02-09 09:37:48  ivan
+    regenerated perl api docs from embedded pod
+ Revision 1.2 1998/11/13 04:08:44 ivan no
+    default default_dir (ironic)
+
index 7570132..8409c2e 100644 (file)
@@ -77,15 +77,15 @@ METHODS
     qsearch TABLE, HASHREF
         Searches the database for all records matching (at least)
         the key/value pairs in HASHREF. Returns all the records
-        found as FS::Record objects.
+        found as `FS::TABLE' objects if that module is loaded (i.e.
+        via `use FS::cust_main;'), otherwise returns FS::Record
+        objects.
 
     qsearchs TABLE, HASHREF
-        Searches the database for a record matching (at least) the
-        key/value pairs in HASHREF, and returns the record found as
-        an FS::Record object. If more than one record matches, it
-        carps but returns the first. If this happens, you either
-        made a logic error in asking for a single item, or your data
-        is corrupted.
+        Same as qsearch, except that if more than one record
+        matches, it carps but returns the first. If this happens,
+        you either made a logic error in asking for a single item,
+        or your data is corrupted.
 
     table
         Returns the table name.
@@ -236,7 +236,7 @@ BUGS
 
         ut_sqltype (like ut_varchar) should all be defined
 
-        A fallback check method should be provided with uses the
+        A fallback check method should be provided whith uses the
         dbdef.
 
         The ut_money method assumes money has two decimal digits.
@@ -332,3 +332,14 @@ HISTORY
 
         ut_phonen got ''; at the end ivan@sisd.com 98-sep-27
 
+        $Log: Record.txt,v $
+        Revision 1.3  1998-11-13 09:56:36  ivan
+        change configuration file layout to support multiple distinct databases (with
+        own set of config files, export, etc.)
+ Revision 1.4 1998/11/10 07:45:25 ivan
+        doc clarification
+
+        Revision 1.2 1998/11/07 05:17:18 ivan In sub new, Pg wrapper
+        for money fields from dbdef (FS::Record::fields $table), not
+        keys of supplied hashref.
+
index bf9f6b4..e246364 100644 (file)
@@ -6,10 +6,9 @@ SYNOPSIS
       use FS::UID qw(adminsuidsetup cgisuidsetup dbh datasrc getotaker
       checkeuid checkruid swapuid);
 
-      adminsuidsetup;
+      adminsuidsetup $user;
 
-      $cgi = new CGI::Base;
-      $cgi->get;
+      $cgi = new CGI;
       $dbh = cgisuidsetup($cgi);
 
       $dbh = dbh;
@@ -20,20 +19,32 @@ DESCRIPTION
     Provides a hodgepodge of subroutines.
 
 SUBROUTINES
-    adminsuidsetup
-        Cleans the environment. Make sure the script is running as
-        freeside, or setuid freeside. Opens a connection to the
-        database. Swaps real and effective UIDs. Returns the DBI
+    adminsuidsetup USER
+        Sets the user to USER (see config.html from the base
+        documentation). Cleans the environment. Make sure the script
+        is running as freeside, or setuid freeside. Opens a
+        connection to the database. Swaps real and effective UIDs.
+        Runs any defined callbacks (see below). Returns the DBI
         database handle (usually you don't need this).
 
+    cgisuidsetup CGI_object
+        Stores the CGI (see the CGI manpage) object for later use.
+        (CGI::Base is depriciated) Runs adminsuidsetup.
+
+    cgi Returns the CGI (see the CGI manpage) object.
+
     dbh Returns the DBI database handle.
 
     datasrc
         Returns the DBI data source.
 
     getotaker
-        Returns the current Freeside user. Currently that means the
-        CGI REMOTE_USER, or 'freeside'.
+        Returns the current Freeside user.
+
+    cgisetotaker
+        Sets and returns the CGI REMOTE_USER. $cgi should be defined
+        as a CGI.pm object. Support for CGI::Base and derived
+        classes is depriciated.
 
     checkeuid
         Returns true if effective UID is that of the freeside user.
@@ -44,14 +55,36 @@ SUBROUTINES
     swapuid
         Swaps real and effective UIDs.
 
+    getsecrets [ USER ]
+        Sets the user to USER, if supplied. Sets and returns the DBI
+        datasource, username and password for this user from the
+        `/usr/local/etc/freeside/mapsecrets' file.
+
+CALLBACKS
+    Warning: this interface is likely to change in future releases.
+
+    A package can install a callback to be run in adminsuidsetup by
+    putting a coderef into the hash %FS::UID::callback :
+
+        $coderef = sub { warn "Hi, I'm returning your call!" };
+        $FS::UID::callback{'Package::Name'};
+
 BUGS
+    Too many package-global variables.
+
     Not OO.
 
     No capabilities yet. When mod_perl and Authen::DBI are
     implemented, cgisuidsetup will go away as well.
 
+    Goes through contortions to support non-OO syntax with multiple
+    datasrc's.
+
+    Callbacks are inelegant.
+
 SEE ALSO
-    the FS::Record manpage, the CGI::Base manpage, the DBI manpage
+    the FS::Record manpage, the CGI manpage, the DBI manpage,
+    config.html from the base documentation.
 
 HISTORY
     ivan@voicenet.com 97-jun-4 - 9 untaint otaker ivan@voicenet.com
@@ -77,3 +110,14 @@ HISTORY
     pod, use FS::Conf, implemented cgisuidsetup as adminsuidsetup,
     inlined suidsetup ivan@sisd.com 98-sep-12
 
+    $Log: UID.txt,v $
+    Revision 1.2  1998-11-13 09:56:37  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.3 1998/11/08 10:45:42 ivan got sub
+    cgi for FS::CGI
+
+    Revision 1.2 1998/11/08 09:38:43 ivan cgisuidsetup complains if
+    you pass it a isa CGI::Base instead of an isa CGI (first step in
+    migrating from CGI-modules to CGI.pm)
+
index 9762dd3..bc0b64d 100644 (file)
@@ -138,3 +138,11 @@ HISTORY
 
     pod, ingegrate with FS::Invoice ivan@sisd.com 98-sep-20
 
+    $Log: cust_bill.txt,v $
+    Revision 1.2  1998-11-13 09:56:38  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.2 1998/11/07 10:24:24 ivan
+    don't use depriciated FS::Bill and FS::Invoice, other
+    miscellania
+
index df78487..f0625c1 100644 (file)
@@ -198,3 +198,11 @@ HISTORY
     cybercash v3 support, don't need to import
     FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21
 
+    $Log: cust_main.txt,v $
+    Revision 1.2  1998-11-13 09:56:39  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.2 1998/11/07 10:24:25 ivan
+    don't use depriciated FS::Bill and FS::Invoice, other
+    miscellania
+
index 5409083..c5d143d 100644 (file)
@@ -21,6 +21,8 @@ SYNOPSIS
 
       $error = $record->unsuspend;
 
+      $part_pkg = $record->part_pkg;
+
       $error = FS::cust_pkg::order( $custnum, \@pkgparts );
       $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );
 
@@ -108,6 +110,10 @@ METHODS
         If there is an error, returns the error, otherwise returns
         false.
 
+    part_pkg
+        Returns the definition for this billing item, as an
+        FS::part_pkg object (see L<FS::part_pkg).
+
 SUBROUTINES
     order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF ]
         CUSTNUM is a customer (see the FS::cust_main manpage)
@@ -148,3 +154,10 @@ HISTORY
 
     pod ivan@sisd.com 98-sep-21
 
+    $Log: cust_pkg.txt,v $
+    Revision 1.2  1998-11-13 09:56:40  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.2 1998/11/12 03:42:45 ivan
+    added label method
+
index d863ea8..adc1ca2 100644 (file)
@@ -15,6 +15,8 @@ SYNOPSIS
 
       $error = $record->check;
 
+      ($label, $value) = $record->label;
+
 DESCRIPTION
     An FS::cust_svc represents a service. FS::cust_svc inherits from
     FS::Record. The following fields are currently supported:
@@ -51,12 +53,18 @@ METHODS
         there is an error, returns the error, otehrwise returns
         false. Called by the insert and replace methods.
 
+    label
+        Returns a list consisting of: - The name of this service
+        (from part_svc) - A meaningful identifier (username, domain,
+        or mail alias) - The table name (i.e. svc_domain) for this
+        service
+
 BUGS
     Behaviour of changing the svcpart of cust_svc records is
     undefined and should possibly be prohibited, and pkg_svc records
     are not checked.
 
-    pkg_svc records are not checket in general (here).
+    pkg_svc records are not checked in general (here).
 
 SEE ALSO
     the FS::Record manpage, the FS::cust_pkg manpage, the
@@ -70,3 +78,15 @@ HISTORY
 
     pod ivan@sisd.com 98-sep-21
 
+    $Log: cust_svc.txt,v $
+    Revision 1.2  1998-11-13 09:56:41  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.4 1998/11/12 07:58:15 ivan
+    added svcdb to label
+
+    Revision 1.3 1998/11/12 03:45:38 ivan use FS::table_name for all
+    tables qsearch()'ed
+
+    Revision 1.2 1998/11/12 03:32:46 ivan added label method
+
index 4fcb093..1a18871 100644 (file)
@@ -76,7 +76,7 @@ SEE ALSO
     manpage
 
 VERSION
-    $Id: dbdef_table.txt,v 1.2 1998-10-14 06:52:48 ivan Exp $
+    $Id: dbdef_table.txt,v 1.5 1999-04-08 13:39:32 ivan Exp $
 
 HISTORY
     class for dealing with table definitions
@@ -96,7 +96,8 @@ HISTORY
     pod ivan@sisd.com 98-sep-24
 
     $Log: dbdef_table.txt,v $
-    Revision 1.2  1998-10-14 06:52:48  ivan
-    1,1,4 release, fix postgresql quirks.
-
+    Revision 1.5  1999-04-08 13:39:32  ivan
+    convert from pod for 1.2.0 release
+ Revision 1.2 1998/10/14 07:05:06 ivan
+    1.1.4 release, fix postgresql
 
index 1c9caf5..4c4e8e2 100644 (file)
@@ -166,3 +166,9 @@ HISTORY
 
     pod and FS::conf ivan@sisd.com 98-sep-22
 
+    $Log: svc_acct.txt,v $
+    Revision 1.2  1998-11-13 09:56:44  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+
+
index 03d3dbc..da8c060 100644 (file)
@@ -47,6 +47,13 @@ METHODS
         A registration or transfer email will be submitted unless
         $FS::svc_domain::whois_hack is true.
 
+        The additional field *email* can be used to manually set the
+        admin contact email address on this email. Otherwise, the
+        svc_acct records for this package (see the FS::cust_pkg
+        manpage) are searched. If there is exactly one svc_acct
+        record in the same package, it is automatically used.
+        Otherwise an error is returned.
+
     delete
         Deletes this domain from the database. If there is an error,
         returns the error, otherwise returns false.
@@ -114,6 +121,9 @@ SEE ALSO
     schema.html from the base documentation, config.html from the
     base documentation.
 
+VERSION
+    $Id: svc_domain.txt,v 1.2 1998-11-13 09:56:45 ivan Exp $
+
 HISTORY
     ivan@voicenet.com 97-jul-21
 
@@ -129,3 +139,11 @@ HISTORY
 
     pod, some FS::Conf (not complete) ivan@sisd.com 98-sep-23
 
+    $Log: svc_domain.txt,v $
+    Revision 1.2  1998-11-13 09:56:45  ivan
+    change configuration file layout to support multiple distinct databases (with
+    own set of config files, export, etc.)
+ Revision 1.2 1998/10/14 08:18:21 ivan
+    More informative error messages and better doc for admin contact
+    email stuff
+
index b9fff45..9f3748d 100755 (executable)
@@ -9,22 +9,25 @@
 #      bmccane@maxbaud.net     98-apr-3
 #
 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
+#
+# $Log: agent_type.cgi,v $
+# Revision 1.2  1998-11-13 09:56:46  ivan
+# change configuration file layout to support multiple distinct databases (with
+# own set of config files, export, etc.)
+#
 
 use strict;
-use CGI::Base;
+use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearch qsearchs);
 use FS::agent_type;
 use FS::CGI qw(header menubar);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
+my($cgi) = new CGI;
 
 &cgisuidsetup($cgi);
 
-SendHeaders(); # one guess.
-
 my($agent_type,$action);
 if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
   $agent_type=qsearchs('agent_type',{'typenum'=>$1});
@@ -35,7 +38,7 @@ if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
 }
 my($hashref)=$agent_type->hashref;
 
-print header("$action Agent Type", menubar(
+print $cgi->header, header("$action Agent Type", menubar(
   'Main Menu' => '../',
   'View all agent types' => '../browse/agent_type.cgi',
 )), '<FORM ACTION="process/agent_type.cgi" METHOD=POST>';
index 46d803f..58e8b7e 100755 (executable)
@@ -8,24 +8,27 @@
 #       bmccane@maxbaud.net     98-apr-3
 #
 # lose background, FS::CGI ivan@sisd.com 98-sep-2
+#
+# $Log: svc_acct_pop.cgi,v $
+# Revision 1.2  1998-11-13 09:56:47  ivan
+# change configuration file layout to support multiple distinct databases (with
+# own set of config files, export, etc.)
+#
 
 use strict;
-use CGI::Base;
+use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearch qsearchs);
 use FS::svc_acct_pop;
 use FS::CGI qw(header menubar);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
+my($cgi) = new CGI;
 
 &cgisuidsetup($cgi);
 
-SendHeaders(); # one guess.
-
 my($svc_acct_pop,$action);
-if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
+if ( $cgi->query_string =~ /^(\d+)$/ ) { #editing
   $svc_acct_pop=qsearchs('svc_acct_pop',{'popnum'=>$1});
   $action='Edit';
 } else { #adding
@@ -34,7 +37,7 @@ if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
 }
 my($hashref)=$svc_acct_pop->hashref;
 
-print header("$action POP", menubar(
+print $cgi->header, header("$action POP", menubar(
   'Main Menu' => '../',
   'View all POPs' => "../browse/svc_acct_pop.cgi",
 )), <<END;
index 0717a2c..dd43633 100755 (executable)
 # rewrite ivan@sisd.com 98-mar-14
 #
 # no GOV in instructions ivan@sisd.com 98-jul-17
+#
+# $Log: svc_domain.cgi,v $
+# Revision 1.2  1998-11-13 09:56:48  ivan
+# change configuration file layout to support multiple distinct databases (with
+# own set of config files, export, etc.)
+#
 
 use strict;
-use CGI::Base qw(:DEFAULT :CGI);
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup getotaker);
 use FS::Record qw(qsearch qsearchs);
 use FS::svc_domain qw(fields);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
+my($cgi) = new CGI;
 &cgisuidsetup($cgi);
 
 my($action,$svcnum,$svc_domain,$pkgnum,$svcpart,$part_svc);
 
-if ( $QUERY_STRING =~ /^(\d+)$/ ) { #editing
+if ( $cgi->query_string =~ /^(\d+)$/ ) { #editing
 
   $svcnum=$1;
   $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum})
@@ -49,7 +55,7 @@ if ( $QUERY_STRING =~ /^(\d+)$/ ) { #editing
 
   $svc_domain=create FS::svc_domain({});
   
-  foreach $_ (split(/-/,$QUERY_STRING)) {
+  foreach $_ (split(/-/,$cgi->query_string)) {
     $pkgnum=$1 if /^pkgnum(\d+)$/;
     $svcpart=$1 if /^svcpart(\d+)$/;
   }
@@ -78,8 +84,7 @@ my($domain)=(
   $svc_domain->domain,
 );
 
-SendHeaders();
-print <<END;
+print $cgi->header, <<END;
 <HTML>
   <HEAD>
     <TITLE>$action $svc</TITLE>
@@ -112,7 +117,8 @@ Domain Name Registration Agreement</A>
 </UL>
 US state and local government agencies, schools, libraries, museums, and individuals should register under the US domain.  See RFC 1480 for a complete description of the US domain
 and registration procedures.
-<P>GOV registrations are limited to top-level US Federal Government agencies (see RFC 1816).
+<!--  <P>GOV registrations are limited to top-level US Federal Government agencies (see RFC 1816).
+!-->
     </FORM>
   </BODY>
 </HTML>
index 04e3832..d726928 100755 (executable)
 # ivan@voicenet.com 97-jul-29
 #
 # no FS::Search ivan@sisd.com 98-mar-7
+# 
+# $Log: cust_pkg.cgi,v $
+# Revision 1.2  1998-11-13 09:56:49  ivan
+# change configuration file layout to support multiple distinct databases (with
+# own set of config files, export, etc.)
+#
 
 use strict;
 use Date::Format;
-use CGI::Base qw(:DEFAULT :CGI); # CGI module
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
+use FS::CGI qw(url);
 use FS::Record qw(qsearch qsearchs);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
-&cgisuidsetup($cgi);
+my($cgi) = new CGI;
+cgisuidsetup($cgi);
 
 my(%uiview,%uiadd);
 my($part_svc);
 foreach $part_svc ( qsearch('part_svc',{}) ) {
-  $uiview{$part_svc->svcpart}="../view/". $part_svc->svcdb . ".cgi";
-  $uiadd{$part_svc->svcpart}="../edit/". $part_svc->svcdb . ".cgi";
+  $uiview{$part_svc->svcpart} = url(1). "/view/". $part_svc->svcdb . ".cgi";
+  $uiadd{$part_svc->svcpart}= url(1). "/edit/". $part_svc->svcdb . ".cgi";
 }
 
 SendHeaders(); # one guess.
index 78ff6ac..fa35a8c 100755 (executable)
 #
 # Changes to allow page to work at a relative position in server
 #       bmccane@maxbaud.net     98-apr-3
+#
+# $Log: svc_domain.cgi,v $
+# Revision 1.2  1998-11-13 09:56:50  ivan
+# change configuration file layout to support multiple distinct databases (with
+# own set of config files, export, etc.)
+#
 
 use strict;
-use CGI::Base qw(:DEFAULT :CGI);
+use CGI;
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearchs);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
+my($cgi) = new CGI;
 cgisuidsetup($cgi);
 
 #untaint svcnum
-$QUERY_STRING =~ /^(\d+)$/;
+$cgi->query_string =~ /^(\d+)$/;
 my($svcnum)=$1;
 my($svc_domain)=qsearchs('svc_domain',{'svcnum'=>$svcnum});
 die "Unknown svcnum" unless $svc_domain;
@@ -41,8 +46,7 @@ if ($pkgnum) {
 my($part_svc)=qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
 die "Unkonwn svcpart" unless $part_svc;
 
-SendHeaders(); # one guess.
-print <<END;
+print $cgi->header, <<END;
 <HTML>
   <HEAD>
     <TITLE>Domain View</TITLE>
index a90e76b..111bb82 100644 (file)
@@ -12,11 +12,12 @@ use FS::dbdef;
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef);
 
-$File::CounterFile::DEFAULT_DIR = "/var/spool/freeside/counters" ;
-
-$dbdef_file = "/var/spool/freeside/dbdef.". datasrc;
-
-reload_dbdef unless $setup_hack;
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::Record'} = sub { 
+  $File::CounterFile::DEFAULT_DIR = "/usr/local/etc/freeside/counters". datasrc;
+  $dbdef_file = "/usr/local/etc/freeside/dbdef.". datasrc;
+  &reload_dbdef unless $setup_hack; #$setup_hack needed now?
+};
 
 =head1 NAME
 
@@ -870,7 +871,11 @@ added pod documentation ivan@sisd.com 98-sep-6
 ut_phonen got ''; at the end ivan@sisd.com 98-sep-27
 
 $Log: Record.pm,v $
-Revision 1.4  1998-11-10 07:45:25  ivan
+Revision 1.5  1998-11-13 09:56:51  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+Revision 1.4  1998/11/10 07:45:25  ivan
 doc clarification
 
 Revision 1.2  1998/11/07 05:17:18  ivan
index 7959343..77c40aa 100644 (file)
@@ -2,7 +2,11 @@ package FS::UID;
 
 use strict;
 use vars qw(
-  @ISA @EXPORT_OK $cgi $dbh $freeside_uid $conf $datasrc $db_user $db_pass
+  @ISA @EXPORT_OK $cgi $dbh $freeside_uid $user 
+  $conf_dir $secrets $datasrc $db_user $db_pass %callback
+);
+use subs qw(
+  getsecrets cgisetotaker
 );
 use Exporter;
 use Carp;
@@ -15,9 +19,7 @@ use FS::Conf;
 
 $freeside_uid = scalar(getpwnam('freeside'));
 
-my $conf = new FS::Conf;
-($datasrc, $db_user, $db_pass) = $conf->config('secrets')
-  or die "Can't get secrets: $!";
+$conf_dir = "/usr/local/etc/freeside/";
 
 =head1 NAME
 
@@ -28,7 +30,7 @@ FS::UID - Subroutines for database login and assorted other stuff
   use FS::UID qw(adminsuidsetup cgisuidsetup dbh datasrc getotaker
   checkeuid checkruid swapuid);
 
-  adminsuidsetup;
+  adminsuidsetup $user;
 
   $cgi = new CGI;
   $dbh = cgisuidsetup($cgi);
@@ -45,18 +47,23 @@ Provides a hodgepodge of subroutines.
 
 =over 4
 
-=item adminsuidsetup
+=item adminsuidsetup USER
 
+Sets the user to USER (see config.html from the base documentation).
 Cleans the environment.
 Make sure the script is running as freeside, or setuid freeside.
 Opens a connection to the database.
 Swaps real and effective UIDs.
+Runs any defined callbacks (see below).
 Returns the DBI database handle (usually you don't need this).
 
 =cut
 
 sub adminsuidsetup {
 
+  $user = shift;
+  croak "fatal: adminsuidsetup called without arguements" unless $user;
+
   $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
   $ENV{'SHELL'} = '/bin/sh';
   $ENV{'IFS'} = " \t\n";
@@ -65,16 +72,18 @@ sub adminsuidsetup {
   $ENV{'BASH_ENV'} = '';
 
   croak "Not running uid freeside!" unless checkeuid();
+  getsecrets;
   $dbh = DBI->connect($datasrc,$db_user,$db_pass, {
-       # hack for web demo
-       #  my($user)=getotaker();
-       #  $dbh = DBI->connect("$datasrc:$user",$db_user,$db_pass, {
                           'AutoCommit' => 'true',
                           'ChopBlanks' => 'true',
-  } ) or die "DBI->connect error: $DBI::errstr\n";;
+  } ) or die "DBI->connect error: $DBI::errstr\n";
 
   swapuid(); #go to non-privledged user if running setuid freeside
 
+  foreach ( keys %callback ) {
+    &{$callback{$_}};
+  }
+
   $dbh;
 }
 
@@ -86,13 +95,14 @@ Runs adminsuidsetup.
 =cut
 
 sub cgisuidsetup {
-  $cgi=$_[0];
+  $cgi=shift;
   if ( $cgi->isa('CGI::Base') ) {
     carp "Use of CGI::Base is depriciated";
   } elsif ( ! $cgi->isa('CGI') ) {
     croak "Pass a CGI object to cgisuidsetup!";
   }
-  adminsuidsetup;
+  cgisetotaker; 
+  adminsuidsetup($user);
 }
 
 =item cgi
@@ -136,20 +146,31 @@ sub suidsetup {
 
 =item getotaker
 
-Returns the current Freeside user.  Currently that means the CGI REMOTE_USER,
-or 'freeside'.
+Returns the current Freeside user.
 
 =cut
 
 sub getotaker {
-  if ( $cgi && $cgi->can('var') && defined $cgi->var('REMOTE_USER')) {
+  $user;
+}
+
+=item cgisetotaker
+
+Sets and returns the CGI REMOTE_USER.  $cgi should be defined as a CGI.pm
+object.  Support for CGI::Base and derived classes is depriciated.
+
+=cut
+
+sub cgisetotaker {
+  if ( $cgi && $cgi->isa('CGI::Base') && defined $cgi->var('REMOTE_USER')) {
     carp "Use of CGI::Base is depriciated";
-    return $cgi->var('REMOTE_USER'); #for now
-  } elsif ( $cgi && $cgi->can('remote_user') && defined $cgi->remote_user ) {
-    return $cgi->remote_user;
+    $user = $cgi->var('REMOTE_USER');
+  } elsif ( $cgi && $cgi->isa('CGI') && defined $cgi->remote_user ) {
+    $user = $cgi->remote_user;
   } else {
-    return 'freeside';
+    die "fatal: Can't get REMOTE_USER!";
   }
+  return $user;
 }
 
 =item checkeuid
@@ -182,18 +203,57 @@ sub swapuid {
   ($<,$>) = ($>,$<);
 }
 
+=item getsecrets [ USER ]
+
+Sets the user to USER, if supplied.
+Sets and returns the DBI datasource, username and password for this user from
+the `/usr/local/etc/freeside/mapsecrets' file.
+
+=cut
+
+sub getsecrets {
+  my($setuser) = shift;
+  $user = $setuser if $setuser;
+  die "No user!" unless $user;
+  my($conf) = new FS::Conf $conf_dir;
+  my($line) = grep /^\s*$user\s/, $conf->config('mapsecrets');
+  $line =~ /^\s*$user\s+(.*)$/;
+  $secrets = $1;
+  die "User not found in mapsecrets file!" unless $secrets;
+  ($datasrc, $db_user, $db_pass) = $conf->config($secrets)
+    or die "Can't get secrets: $!";
+  $FS::Conf::default_dir .= "/conf.$datasrc";
+  ($datasrc, $db_user, $db_pass);
+}
+
 =back
 
+=head1 CALLBACKS
+
+Warning: this interface is likely to change in future releases.
+
+A package can install a callback to be run in adminsuidsetup by putting a
+coderef into the hash %FS::UID::callback :
+
+    $coderef = sub { warn "Hi, I'm returning your call!" };
+    $FS::UID::callback{'Package::Name'};
+
 =head1 BUGS
 
+Too many package-global variables.
+
 Not OO.
 
 No capabilities yet.  When mod_perl and Authen::DBI are implemented, 
 cgisuidsetup will go away as well.
 
+Goes through contortions to support non-OO syntax with multiple datasrc's.
+
+Callbacks are inelegant.
+
 =head1 SEE ALSO
 
-L<FS::Record>, L<CGI>, L<DBI>
+L<FS::Record>, L<CGI>, L<DBI>, config.html from the base documentation.
 
 =head1 HISTORY
 
@@ -222,7 +282,11 @@ inlined suidsetup
 ivan@sisd.com 98-sep-12
 
 $Log: UID.pm,v $
-Revision 1.3  1998-11-08 10:45:42  ivan
+Revision 1.4  1998-11-13 09:56:52  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+Revision 1.3  1998/11/08 10:45:42  ivan
 got sub cgi for FS::CGI
 
 Revision 1.2  1998/11/08 09:38:43  ivan
index bc94242..455fc2d 100644 (file)
@@ -8,9 +8,11 @@ use FS::Record qw(fields qsearch qsearchs);
 
 @ISA = qw(FS::Record Exporter);
 
-$conf = new FS::Conf;
-
-($add1,$add2,$add3,$add4) = $conf->config('address');
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::cust_bill'} = sub { 
+  $conf = new FS::Conf;
+  ( $add1, $add2, $add3, $add4 ) = $conf->config('address');
+};
 
 =head1 NAME
 
@@ -490,7 +492,11 @@ charges can be negative ivan@sisd.com 98-jul-13
 pod, ingegrate with FS::Invoice ivan@sisd.com 98-sep-20
 
 $Log: cust_bill.pm,v $
-Revision 1.2  1998-11-07 10:24:24  ivan
+Revision 1.3  1998-11-13 09:56:53  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+Revision 1.2  1998/11/07 10:24:24  ivan
 don't use depriciated FS::Bill and FS::Invoice, other miscellania
 
 
index 0ef69cb..83a7d78 100644 (file)
@@ -24,39 +24,43 @@ use FS::cust_pay;
 @ISA = qw(FS::Record Exporter);
 @EXPORT_OK = qw(hfields);
 
-$conf = new FS::Conf;
-$lpr = $conf->config('lpr');
-
-if ( $conf->exists('cybercash3.2') ) {
-  require CCMckLib3_2;
-    #qw($MCKversion %Config InitConfig CCError CCDebug CCDebug2);
-  require CCMckDirectLib3_2;
-    #qw(SendCC2_1Server);
-  require CCMckErrno3_2;
-    #qw(MCKGetErrorMessage $E_NoErr);
-  import CCMckErrno3_2 qw($E_NoErr);
-  my $merchant_conf;
-  ($merchant_conf,$xaction)= $conf->config('cybercash3.2');
-  my $status = &CCMckLib3_2::InitConfig($merchant_conf);
-  if ( $status != $E_NoErr ) {
-    warn "CCMckLib3_2::InitConfig error:\n";
-    foreach my $key (keys %CCMckLib3_2::Config) {
-      warn "  $key => $CCMckLib3_2::Config{$key}\n"
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::cust_main'} = sub { 
+  $conf = new FS::Conf;
+  $lpr = $conf->config('lpr');
+
+  if ( $conf->exists('cybercash3.2') ) {
+    require CCMckLib3_2;
+      #qw($MCKversion %Config InitConfig CCError CCDebug CCDebug2);
+    require CCMckDirectLib3_2;
+      #qw(SendCC2_1Server);
+    require CCMckErrno3_2;
+      #qw(MCKGetErrorMessage $E_NoErr);
+    import CCMckErrno3_2 qw($E_NoErr);
+
+    my $merchant_conf;
+    ($merchant_conf,$xaction)= $conf->config('cybercash3.2');
+    my $status = &CCMckLib3_2::InitConfig($merchant_conf);
+    if ( $status != $E_NoErr ) {
+      warn "CCMckLib3_2::InitConfig error:\n";
+      foreach my $key (keys %CCMckLib3_2::Config) {
+        warn "  $key => $CCMckLib3_2::Config{$key}\n"
+      }
+      my($errmsg) = &CCMckErrno3_2::MCKGetErrorMessage($status);
+      die "CCMckLib3_2::InitConfig fatal error: $errmsg\n";
     }
-    my($errmsg) = &CCMckErrno3_2::MCKGetErrorMessage($status);
-    die "CCMckLib3_2::InitConfig fatal error: $errmsg\n";
+    $processor='cybercash3.2';
+  } elsif ( $conf->exists('cybercash2') ) {
+    require CCLib;
+      #qw(sendmserver);
+    ( $main::paymentserverhost, 
+      $main::paymentserverport, 
+      $main::paymentserversecret,
+      $xaction,
+    ) = $conf->config('cybercash2');
+    $processor='cybercash2';
   }
-  $processor='cybercash3.2';
-} elsif ( $conf->exists('cybercash2') ) {
-  require CCLib;
-    #qw(sendmserver);
-  ( $main::paymentserverhost, 
-    $main::paymentserverport, 
-    $main::paymentserversecret,
-    $xaction,
-  ) = $conf->config('cybercash2');
-  $processor='cybercash2';
-}
+};
 
 =head1 NAME
 
@@ -864,7 +868,11 @@ enable cybercash, cybercash v3 support, don't need to import
 FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21
 
 $Log: cust_main.pm,v $
-Revision 1.2  1998-11-07 10:24:25  ivan
+Revision 1.3  1998-11-13 09:56:54  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+Revision 1.2  1998/11/07 10:24:25  ivan
 don't use depriciated FS::Bill and FS::Invoice, other miscellania
 
 
index a43af6b..fdc9f0b 100644 (file)
@@ -12,10 +12,13 @@ use FS::cust_svc;
 @ISA = qw(FS::Record Exporter);
 @EXPORT_OK = qw(fields);
 
-$conf = new FS::Conf;
-$dir_prefix = $conf->config('home');
-@shells = $conf->config('shells');
-$shellmachine = $conf->config('shellmachine');
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::svc_acct'} = sub { 
+  $conf = new FS::Conf;
+  $dir_prefix = $conf->config('home');
+  @shells = $conf->config('shells');
+  $shellmachine = $conf->config('shellmachine');
+};
 
 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
 @pw_set = ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' );
@@ -551,6 +554,12 @@ arbitrary radius attributes ivan@sisd.com 98-aug-13
 
 pod and FS::conf ivan@sisd.com 98-sep-22
 
+$Log: svc_acct.pm,v $
+Revision 1.2  1998-11-13 09:56:55  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+
 =cut
 
 1;
index c87ed2c..4293e03 100644 (file)
@@ -11,11 +11,13 @@ use FS::Conf;
 @ISA = qw(FS::Record Exporter);
 @EXPORT_OK = qw(fields);
 
-$conf = new FS::Conf;
-
-$shellmachine = $conf->exists('qmailmachines')
-                ? $conf->config('shellmachine')
-                : '';
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::svc_acct_sm'} = sub { 
+  $conf = new FS::Conf;
+  $shellmachine = $conf->exists('qmailmachines')
+                  ? $conf->config('shellmachine')
+                  : '';
+};
 
 =head1 NAME
 
index c12819e..69b225e 100644 (file)
@@ -1,7 +1,9 @@
 package FS::svc_domain;
 
 use strict;
-use vars qw(@ISA @EXPORT_OK $whois_hack $conf $mydomain $smtpmachine);
+use vars qw(@ISA @EXPORT_OK $whois_hack $conf $mydomain $smtpmachine
+  $tech_contact $from $to @nameservers @nameserver_ips @template
+);
 use Exporter;
 use Carp;
 use Mail::Internet;
@@ -14,60 +16,31 @@ use FS::Conf;
 @ISA = qw(FS::Record Exporter);
 @EXPORT_OK = qw(fields);
 
-$conf = new FS::Conf;
-
-$mydomain = $conf->config('domain');
-$smtpmachine = $conf->config('smtpmachine');
-
-my($internic)="/var/spool/freeside/conf/registries/internic";
-my($conf_tech)="$internic/tech_contact";
-my($conf_from)="$internic/from";
-my($conf_to)="$internic/to";
-my($nameservers)="$internic/nameservers";
-my($template)="$internic/template";
-
-open(TECH_CONTACT,$conf_tech) or die "Can't open $conf_tech: $!";
-my($tech_contact)=map {
-  /^(.*)$/ or die "Illegal line in $conf_tech!"; #yes, we trust the file
-  $1;
-} grep $_ !~ /^(#|$)/, <TECH_CONTACT>;
-close TECH_CONTACT;
-
-open(FROM,$conf_from) or die "Can't open $conf_from: $!";
-my($from)=map {
-  /^(.*)$/ or die "Illegal line in $conf_from!"; #yes, we trust the file
-  $1;
-} grep $_ !~ /^(#|$)/, <FROM>;
-close FROM;
-
-open(TO,$conf_to) or die "Can't open $conf_to: $!";
-my($to)=map {
-  /^(.*)$/ or die "Illegal line in $conf_to!"; #yes, we trust the file
-  $1;
-} grep $_ !~ /^(#|$)/, <TO>;
-close TO;
-
-open(NAMESERVERS,$nameservers) or die "Can't open $nameservers: $!";
-my(@nameservers)=map {
-  /^\s*\d+\.\d+\.\d+\.\d+\s+([^\s]+)\s*$/
-    or die "Illegal line in $nameservers!"; #yes, we trust the file
-  $1;
-} grep $_ !~ /^(#|$)/, <NAMESERVERS>;
-close NAMESERVERS;
-open(NAMESERVERS,$nameservers) or die "Can't open $nameservers: $!";
-my(@nameserver_ips)=map {
-  /^\s*(\d+\.\d+\.\d+\.\d+)\s+([^\s]+)\s*$/
-    or die "Illegal line in $nameservers!"; #yes, we trust the file
-  $1;
-} grep $_ !~ /^(#|$)/, <NAMESERVERS>;
-close NAMESERVERS;
-
-open(TEMPLATE,$template) or die "Can't open $template: $!";
-my(@template)=map {
-  /^(.*)$/ or die "Illegal line in $to!"; #yes, we trust the file
-  $1. "\n";
-} <TEMPLATE>;
-close TEMPLATE;
+#ask FS::UID to run this stuff for us later
+$FS::UID::callback{'FS::domain'} = sub { 
+  $conf = new FS::Conf;
+
+  $mydomain = $conf->config('domain');
+  $smtpmachine = $conf->config('smtpmachine');
+
+  my($internic)="/registries/internic";
+  $tech_contact = $conf->config("$internic/tech_contact");
+  $from = $conf->config("$internic/from");
+  $to = $conf->config("$internic/to");
+  my(@ns) = $conf->config("$internic/nameservers");
+  @nameservers=map {
+    /^\s*\d+\.\d+\.\d+\.\d+\s+([^\s]+)\s*$/
+      or die "Illegal line in $internic/nameservers";
+    $1;
+  } @ns;
+  @nameserver_ips=map {
+    /^\s*(\d+\.\d+\.\d+\.\d+)\s+([^\s]+)\s*$/
+      or die "Illegal line in $internic/nameservers!";
+    $1;
+  } @ns;
+  @template = map { $_. "\n" } $conf->config("$internic/template");
+
+};
 
 =head1 NAME
 
@@ -523,7 +496,7 @@ config.html from the base documentation.
 
 =head1 VERSION
 
-$Id: svc_domain.pm,v 1.2 1998-10-14 08:18:21 ivan Exp $
+$Id: svc_domain.pm,v 1.3 1998-11-13 09:56:57 ivan Exp $
 
 =head1 HISTORY
 
@@ -542,7 +515,11 @@ ivan@sisd.com 98-jul-17-19
 pod, some FS::Conf (not complete) ivan@sisd.com 98-sep-23
 
 $Log: svc_domain.pm,v $
-Revision 1.2  1998-10-14 08:18:21  ivan
+Revision 1.3  1998-11-13 09:56:57  ivan
+change configuration file layout to support multiple distinct databases (with
+own set of config files, export, etc.)
+
+Revision 1.2  1998/10/14 08:18:21  ivan
 More informative error messages and better doc for admin contact email stuff