Move all of the auth configuration values into a config file
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 14 Feb 2009 17:52:08 +0000 (12:52 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 14 Feb 2009 17:52:08 +0000 (12:52 -0500)
* includes/auth/auth.php:
(Authentication::_setupDatabase): Create the database object in this method using the config values
* includes/auth/auth_default.php:
* includes/auth/auth_drupal.php:
* includes/auth/auth_phpbb2.php:
* includes/auth/auth_vbulletin.php:
(Authentication*::_setupDatabase): Remove the db creation from here and just call parent::
* includes/auth/config.php.new: New file

includes/auth/auth.php
includes/auth/auth_default.php
includes/auth/auth_drupal.php
includes/auth/auth_phpbb2.php
includes/auth/auth_vbulletin.php
includes/auth/config.php.new [new file with mode: 0644]

index 34f7cd053358c473be6cf223c13ddc8e650ea45a..f2e16addbe4951105c07fa0435a62c70ec2807d2 100644 (file)
@@ -117,7 +117,20 @@ class Authentication
        * database object here. Whatever you choose, you need to reference
        * Authentication->authDb to the object
        */
-       function _setupDatabase() {}
+       function _setupDatabase()
+       {
+               // connect to the DB
+               $this->authDb = new DB_MySQL($this->registry);
+               
+               require_once 'includes/auth/config.php';
+               $this->authDb->connect(
+                       $config['auth']['dbServer'],
+                       $config['auth']['dbUser'],
+                       $config['auth']['dbPassword'],
+                       $config['auth']['dbName'],
+                       false
+               );
+       }
        
        // ###################################################################
        /**
index 0fe42cae1e7b112ca0690ac56d7f0d0e29798cbe..01b7bbc711569597fe13389ba28ec34c4603ed94 100644 (file)
@@ -37,7 +37,7 @@ class AuthenticationDefault extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
-               $this->authDb =$this->db;
+               $this->authDb = &$this->db;
        }
        
        // ###################################################################
index abcf29682ee47bb3c56817c1d41244d1ceb91756..d9f3f5c5ee315f9bbd56cd903b887c89c275420c 100644 (file)
@@ -49,12 +49,12 @@ class AuthenticationDrupal extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
+               parent::_setupDatabase();
+               
                // check and see if we need to call session_name()
+               require_once 'includes/auth/config.php';
+               $this->cookieName = $config['auth']['Drupal']['cookieName'];
                $this->cookieName = ($this->cookieName == null ? session_name() : $this->cookieName);
-               
-               // connect to the DB
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('DRUPAL_DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME', false);
        }
        
        // ###################################################################
index acabf9a81a703abb3584359a769a84dee74e392f..7b6b3db8f46ff6d51d12cc1ed27d8f0477e6a4fa 100644 (file)
@@ -59,9 +59,11 @@ class AuthenticationPhpbb2 extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
-               // connect to the DB
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME', false);
+               parent::_setupDatabase();
+               
+               require_once 'includes/auth/config.php';
+               $this->phpBBTablePrefix = $config['auth']['phpBB2']['tablePrefix'];
+               $this->cookieName = $config['auth']['phpBB2']['cookieName'];
        }
        
        // ###################################################################
index 2d6da6be9be3eaf6329645d7b801009ffbc94c9a..412fe7905a68d55b8b8879a43176ec852dd39713 100644 (file)
@@ -62,8 +62,11 @@ class AuthenticationVbulletin extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('VBULLETIN_DATABASE_SERVER', 'VB_DATABASE_USER', 'VB_DATABASE_PASSWORD', 'VBULLETIN_DATABASE_NAME', false);
+               parent::_setupDatabase();
+               
+               require_once 'includes/auth/config.php';
+               $this->licenseKey = $config['auth']['vBulletin3']['licenseKey'];
+               $this->vBTablePrefix = $config['auth']['vBulletin3']['tablePrefix'];
        }
        
        // ###################################################################
diff --git a/includes/auth/config.php.new b/includes/auth/config.php.new
new file mode 100644 (file)
index 0000000..5371043
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/*=====================================================================*\
+|| ###################################################################
+|| # Bugdar
+|| # Copyright (c)2004-2009 Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version 2 of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+// ###################################################################
+// Database connectivity settings
+
+/**
+ * Name of the database server to connect to for authentication
+ */
+$config['auth']['dbServer'] = 'localhost';
+
+/**
+ * MySQL user of the authentication database
+ */
+$config['auth']['dbUser'] = 'mysql';
+
+/**
+ * Password of the authentication database
+ */
+$config['auth']['dbPassword'] = 'secret';
+
+/**
+ * Authentication database name
+ */
+$config['auth']['dbName'] = 'remote_auth_db';
+
+// ###################################################################
+// Drupal configuration
+
+/**
+ * The cookie name to use for Drupal. Leaving this NULL will get it from session_name()
+ */
+$config['auth']['Drupal']['cookieName'] = null;
+
+// ###################################################################
+// phpBB2 configuration
+
+/**
+ * Database table prefix
+ */
+$config['auth']['phpBB2']['tablePrefix'] = 'phpbb2_';
+
+/**
+ * The cookie name that is set in phpBB -> Administration -> General Admin -> Configuration -> Cookie Settings -> Cookie Name
+ */
+$config['auth']['phpBB2']['cookieName'] = 'phpbb2mysql';
+
+// ###################################################################
+// vBulletin 3 configuration
+
+/**
+ * Database table prefix
+ */
+$config['auth']['vBulletin3']['tablePrefix'] = '';
+
+/**
+ * This is the vBulletin license key that you can find in the Members' Area that is used in creating cookies
+ */
+$config['auth']['vBulletin3']['licenseKey'] = 'LXXXXXXX';
+
+?>
\ No newline at end of file