Subversion Repositories VORC

Rev

Rev 206 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 206 Rev 207
Line 8... Line 8...
8
#  $ENV{HOME} = "/tmp" unless $ENV{HOME};
8
#  $ENV{HOME} = "/tmp" unless $ENV{HOME};
Line 9... Line 9...
9
  
9
  
10
  # Connect to MySQL server, using hardwired name and password
10
  # Connect to MySQL server, using hardwired name and password
11
  sub connect {
11
  sub connect {
12
		my $DB = shift // "vorc";
12
		my $DB = shift // "vorc";
Line 13... Line 13...
13
		my $dbuser = shift // "";
13
		my $dbuser = shift // undef;
14
		
14
		
Line 15... Line 15...
15
	  my $db_name = "rollerco_".$DB;
15
	  my $db_name = "rollerco_".$DB;
Line 24... Line 24...
24
  # Connect to MySQL server, using name and password from the current
24
  # Connect to MySQL server, using name and password from the current
25
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
25
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
26
  # when added to the DSN, specifies which option file to read.
26
  # when added to the DSN, specifies which option file to read.
27
  sub connect_with_option_file  {
27
  sub connect_with_option_file  {
28
  	my $dsn = shift;
28
  	my $dsn = shift;
29
  	my $dbuser = shift // "";
29
  	my $dbuser = shift // undef;
Line 30... Line 30...
30
  	
30
  	
Line 31... Line 31...
31
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
31
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
32
	  
32
	  
33
	  if ($dbuser eq "OG") {
33
	  if ($dbuser eq "OG") {
34
	  	my $connection = DBI->connect ($dsn, undef, undef, {PrintError => 0, RaiseError => 0});
34
	  	my $connection = DBI->connect ($dsn, undef, undef, {PrintError => 0, RaiseError => 0});
35
	  	return $connection unless !$connection;	    
35
	  	return $connection unless !$connection;	    
36
	  } elsif ($dbuser =~ /^[12345]$/) {
36
	  } elsif ($dbuser =~ /^[12345]$/) {
37
	  	my $connection = DBI->connect ($dsn.".$_", undef, undef, {PrintError => 0, RaiseError => 0});
37
	  	my $connection = DBI->connect ($dsn.".$_", undef, undef, {PrintError => 0, RaiseError => 0});
38
	  	return $connection unless !$connection;	    
38
	  	return $connection unless !$connection;	    
39
	  } else {
39
	  } elsif (defined $dbuser) {
Line 40... Line 40...
40
	    db_error ("Invalid User ID provided to WebDB::connect ($dbuser)");
40
	    db_error ("Invalid User ID provided to WebDB::connect ($dbuser)");
41
	  }
41
	  }