Subversion Repositories VORC

Rev

Rev 50 | Rev 92 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 - 1
package WebDB;
2
  use strict;
3
  use DBI;
4
  my $host_name = "192.168.1.5";
47 - 5
  my $db_name = "rollerco_vorc";
7 - 6
  my $dsn = "DBI:mysql:host=$host_name;database=$db_name";
63 bgadell 7
  $ENV{HOME} = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco" : "/tmp";
8
#  $ENV{HOME} = "/tmp" unless $ENV{HOME};
7 - 9
 
10
  # Connect to MySQL server, using hardwired name and password
11
  sub connect  {
50 bgadell 12
    return connect_with_option_file() unless !(-f $ENV{HOME}.'/.my.cnf');
13
 
14
    warn "using hardcoded password (not $ENV{HOME}/.my.cnf)...";
7 - 15
 	  return (DBI->connect ($dsn, "root", "********",
16
	  {PrintError => 0, RaiseError => 1}));
17
  }
18
 
19
  # Connect to MySQL server, using name and password from the current
20
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
21
  # when added to the DSN, specifies which option file to read.
22
  sub connect_with_option_file  {
23
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
24
	  return (DBI->connect ($dsn, undef, undef,
25
	  {PrintError => 0, RaiseError => 1}));
26
  }
27
 
50 bgadell 28
  # Quash any leading or trailing whitespace
7 - 29
  sub trim {
30
    my $str = shift;
31
 
32
  	return "" if !defined $str;
33
  	$str =~ s/^\s+//;
34
  	$str =~ s/\s+$//;
35
  	return ($str);
36
  }
50 bgadell 37
 
38
1; # return true