From 2f374d188317a30ed51df9647ec1bdc0f36313de Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 22 Sep 2013 09:21:00 +0200 Subject: Add FluxBB authentication driver To enable set: $config['authentication_driver'] = 'fluxbb'; $config['auth_fluxbb'] = array('database' => 'fluxbb'); Signed-off-by: Pierre Schmitz Add example array to config.php Remove $optional_functions from Duser_fluxbb to follow bb9f9274e8c2d661a1adffd87c87c3d81ec47b4d. Signed-off-by: Florian Pritz --- application/config/config.php | 5 ++ application/libraries/Duser/Duser.php | 2 +- .../libraries/Duser/drivers/Duser_fluxbb.php | 53 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 application/libraries/Duser/drivers/Duser_fluxbb.php diff --git a/application/config/config.php b/application/config/config.php index 388776cda..5d6ea5d1f 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -408,6 +408,11 @@ if (extension_loaded("ldap")) { ); } +// This is only used it the driver is set to fluxbb +$config['auth_fluxbb'] = array( + 'database' => 'fluxbb' +); + // possible values: production, development $config['environment'] = "production"; diff --git a/application/libraries/Duser/Duser.php b/application/libraries/Duser/Duser.php index 38ee967c9..07a16190c 100644 --- a/application/libraries/Duser/Duser.php +++ b/application/libraries/Duser/Duser.php @@ -49,7 +49,7 @@ class Duser extends CI_Driver_Library { protected $_adapter = null; protected $valid_drivers = array( - 'duser_db', 'duser_ldap' + 'duser_db', 'duser_ldap', 'duser_fluxbb' ); function __construct() diff --git a/application/libraries/Duser/drivers/Duser_fluxbb.php b/application/libraries/Duser/drivers/Duser_fluxbb.php new file mode 100644 index 000000000..b32e2ac8e --- /dev/null +++ b/application/libraries/Duser/drivers/Duser_fluxbb.php @@ -0,0 +1,53 @@ + + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +class Duser_fluxbb extends Duser_Driver { + + private $CI = null; + private $config = array(); + + function __construct() + { + $this->CI =& get_instance(); + $this->config = $this->CI->config->item('auth_fluxbb'); + } + + public function login($username, $password) + { + $query = $this->CI->db->query(' + SELECT username, id + FROM '.$this->config['database'].'.users + WHERE username LIKE ? AND password = ? + ', array($username, sha1($password)))->row_array(); + + if (!empty($query)) { + return array( + 'username' => $query['username'], + 'userid' => $query['id'] + ); + } else { + return false; + } + } + + public function username_exists($username) + { + $query = $this->CI->db->query(' + SELECT id + FROM '.$this->config['database'].'.users + WHERE username LIKE ? + ', array($username)); + + if ($query->num_rows() > 0) { + return true; + } else { + return false; + } + } +} -- cgit v1.2.3-24-g4f1b