Changeset 432


Ignore:
Timestamp:
Jul 16, 2010, 5:31:13 PM (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Clarify, clean up, and make sane configuration for database
host, db name, user, and password. See #17.

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r429 r432  
    130130# Set up for a PostgreSQL db;  could be any transactional DBMS with the
    131131# right changes.
    132 # This definition should be sub connectDB($$$) to be technically correct,
    133 # but this breaks.  GRR.
    134132sub connectDB {
    135   my ($dbname,$user,$pass) = @_;
     133  my $dbname = shift;
     134  my $user = shift;
     135  my $pass = shift;
     136  my $dbhost = shift;
     137
    136138  my $dbh;
    137   my $DSN = "DBI:Pg:host=ipdb-db;dbname=$dbname";
    138 #  my $user = 'ipdb';
    139 #  my $pw   = 'ipdbpwd';
     139  my $DSN = "DBI:Pg:".($dbhost ? "host=$dbhost;" : '')."dbname=$dbname";
    140140
    141141# Note that we want to autocommit by default, and we will turn it off locally as necessary.
  • trunk/cgi-bin/MyIPDB.pm

    r420 r432  
    1515use IPDB 2.0 qw(:ALL);
    1616
    17 ## connectDB_My()
    18 # Wrapper for IPDB::connectDB
    19 # Takes no arguments, returns whatever IPDB::connectDB returns.
    20 sub connectDB_My {
    21   return connectDB("ipdb", "ipdb", "ipdbpwd");
    22 } # end connectDB_My()
     17
     18# DSN, user, and password for database.  These **MUST** be set.
     19my $dbname = 'ipdb';
     20my $dbuser = 'ipdb';
     21my $dbpass = 'ipdbpwd';
     22# DB host is optional.
     23my $dbhost = 'ipdb-db';
    2324
    2425# Set some globals declared in IPDB.pm.  Most of these only affect mailNotify().
     
    4445#$IPDB::syslog_facility = 'daemon';
    4546
     47
     48## connectDB_My()
     49# Wrapper for IPDB::connectDB
     50# Takes no arguments, returns whatever IPDB::connectDB returns.
     51sub connectDB_My {
     52  return connectDB($dbname, $dbuser, $dbpass, $dbhost);
     53} # end connectDB_My()
     54
    4655# Keep Perl from complaining.
    47561;
Note: See TracChangeset for help on using the changeset viewer.