[vhffs-dev] [svn] commit: r191 - in /trunk: vhffs-api/src/Vhffs/Functions.pm vhffs-backend/conf/vhffs.conf

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Author: soda
Date: Tue May  2 20:28:04 2006
New Revision: 191

Log:
Add db_port directive
Improve connexion to the database


Modified:
    trunk/vhffs-api/src/Vhffs/Functions.pm
    trunk/vhffs-backend/conf/vhffs.conf

Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm Tue May  2 20:28:04 2006
@@ -203,22 +203,24 @@
     my $dbparams;
     my $dbh;
     my $driver;
+	my $port;
+	my $host;
 
 
     ($backend_config) = @_;
 
 
+	#Default port;
+
     if( $backend_config->{'driver'} =~  /pg/ )
     {
-        $driver = "Pg";
-        if( ( $backend_config->{'db_host'} =~ /localhost/i ) || ( $backend_config->{'db_host'} eq "127.0.0.1" ) )
-		{
-			$dbparams = "dbname=$backend_config->{'db_name'}";
-		}
-		else
-		{
-			$dbparams = "dbname=$backend_config->{'db_name'};host=$backend_config->{'db_host'}";
-		}
+		$port 	= 5433;
+    	$driver = "Pg";
+		$host 	= "localhost";
+		$port 	= $backend_config->{'db_port'} if( defined( $backend_config->{'db_port'} ) );
+		$host 	= $backend_config->{'db_host'} if( defined( $backend_config->{'db_host'} ) );
+
+		$dbparams = "dbname=$backend_config->{'db_name'};host=$host;port=$port";
         $dbh = DBI->connect("DBI:$driver:$dbparams",$backend_config->{'db_username'}, $backend_config->{'db_password'}) || (print STDERR "Cant connect: $DBI::errstr\n" and exit 1);
 	
         return( $dbh );

Modified: trunk/vhffs-backend/conf/vhffs.conf
==============================================================================
--- trunk/vhffs-backend/conf/vhffs.conf (original)
+++ trunk/vhffs-backend/conf/vhffs.conf Tue May  2 20:28:04 2006
@@ -107,20 +107,6 @@
 #################################################
 # Backend configuration
 #################################################
-<backend>
-	#Database Driver (DBI Driver Name) : mysql, pgsql or ldap
-	backend_driver=pgsql
-	driver = pg
-	#Database to use
-	db_name=vhffs
-	#Read Write User Name
-	db_username=vhffs
-	#Password
-	db_password=vhffs
-	#DataBase Server
-	db_host=localhost
-</backend>
-
 <databases>
 	<dbread>
 		driver = pg
@@ -132,6 +118,8 @@
 		db_password=vhffs
 		#DataBase Server
 		db_host=localhost
+		#Database port
+		db_port = 5433
 	</dbread>
 
 	<dbwrite>
@@ -144,6 +132,8 @@
 		db_password=vhffs
 		#DataBase Server
 		db_host=localhost
+		#Database port
+		db_port = 5433
 	</dbwrite>
 
 </databases>




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/