Subversion Repositories VORC

Rev

Rev 121 | Rev 151 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 121 Rev 150
Line 1... Line 1...
1
package WebDB;
1
package WebDB;
2
  use strict;
2
  use strict;
3
  use DBI;
3
  use DBI;
4
  my $host_name = "192.168.1.5";
4
  use List::Util 'shuffle';
-
 
5
  
-
 
6
  my $host_name = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "localhost" : "192.168.1.5";
5
  my $db_name = "rollerco_vorc";
7
  my $db_name = "rollerco_vorc";
6
  my $dsn = "DBI:mysql:host=$host_name;database=$db_name";
8
  my $dsn = "DBI:mysql:host=$host_name;database=$db_name";
7
  $ENV{HOME} = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco" : "/tmp";
9
  $ENV{HOME} = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco" : "/tmp";
8
#  $ENV{HOME} = "/tmp" unless $ENV{HOME};
10
#  $ENV{HOME} = "/tmp" unless $ENV{HOME};
Line 18... Line 20...
18
  # Connect to MySQL server, using name and password from the current
20
  # Connect to MySQL server, using name and password from the current
19
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
21
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
20
  # when added to the DSN, specifies which option file to read.
22
  # when added to the DSN, specifies which option file to read.
21
  sub connect_with_option_file  {
23
  sub connect_with_option_file  {
22
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
24
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
23
	  
-
 
-
 
25
	  for (shuffle qw(1 2 3 4 5)) {
-
 
26
	    # warn "Trying connection $_";
24
	  return (DBI->connect ($dsn, undef, undef, {PrintError => 0, RaiseError => 0}) or db_error ($DBI::errstr));
27
	  	my $connection = DBI->connect ($dsn.".$_", undef, undef, {PrintError => 0, RaiseError => 0});
-
 
28
	  	return $connection unless !$connection;
-
 
29
	  }
-
 
30
	  db_error ($DBI::errstr);
25
  }
31
  }
Line 26... Line 32...
26
  
32
  
27
  # Quash any leading or trailing whitespace
33
  # Quash any leading or trailing whitespace
28
  sub trim {
34
  sub trim {