diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-09-22 09:21:00 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-09-22 10:57:41 +0200 |
commit | 2f374d188317a30ed51df9647ec1bdc0f36313de (patch) | |
tree | 5cd696d0d8196b1971ed7465357633caf2097400 /application/libraries/Duser/drivers/Duser_fluxbb.php | |
parent | d1d83c9e97fc4542a0b8c19ddf27fef3a0beb46e (diff) |
Add FluxBB authentication driver
To enable set:
$config['authentication_driver'] = 'fluxbb';
$config['auth_fluxbb'] = array('database' => 'fluxbb');
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
Add example array to config.php
Remove $optional_functions from Duser_fluxbb to follow
bb9f9274e8c2d661a1adffd87c87c3d81ec47b4d.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries/Duser/drivers/Duser_fluxbb.php')
-rw-r--r-- | application/libraries/Duser/drivers/Duser_fluxbb.php | 53 |
1 files changed, 53 insertions, 0 deletions
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 @@ +<?php +/* + * Copyright 2013 Pierre Schmitz <pierre@archlinux.de> + * + * 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; + } + } +} |