Rev 50 | Rev 121 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package WebDB;use strict;use DBI;my $host_name = "192.168.1.5";my $db_name = "rollerco_vorc";my $dsn = "DBI:mysql:host=$host_name;database=$db_name";$ENV{HOME} = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco" : "/tmp";# $ENV{HOME} = "/tmp" unless $ENV{HOME};# Connect to MySQL server, using hardwired name and passwordsub connect {return connect_with_option_file() unless !(-f $ENV{HOME}.'/.my.cnf');warn "using hardcoded password (not $ENV{HOME}/.my.cnf)...";return (DBI->connect ($dsn, "root", "********",{PrintError => 0, RaiseError => 1}));}# Connect to MySQL server, using name and password from the current# user's ~/.my.cnf option file. The mysql_read_default_file option,# when added to the DSN, specifies which option file to read.sub connect_with_option_file {$dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";return (DBI->connect ($dsn, undef, undef,{PrintError => 0, RaiseError => 1}));}# Quash any leading or trailing whitespacesub trim {my $str = shift;return "" if !defined $str;$str =~ s/^\s+//;$str =~ s/\s+$//;return ($str);}1; # return true