Subversion Repositories Applications.papyrus

Rev

Rev 320 | Rev 1713 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 320 Rev 1173
Line 1... Line 1...
1
<?php
1
<?php
2
//
-
 
3
// +----------------------------------------------------------------------+
-
 
4
// | PHP Version 4                                                        |
-
 
5
// +----------------------------------------------------------------------+
-
 
6
// |                                                                      |
-
 
7
// +----------------------------------------------------------------------+
-
 
8
// | This source file is subject to version 2.02 of the PHP license,      |
-
 
9
// | that is bundled with this package in the file LICENSE, and is        |
-
 
10
// | available at through the world-wide-web at                           |
-
 
11
// | http://www.php.net/license/2_02.txt.                                 |
-
 
12
// | If you did not receive a copy of the PHP license and are unable to   |
-
 
13
// | obtain it through the world-wide-web, please send a note to          |
-
 
14
// | license@php.net so we can mail you a copy immediately.               |
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
15
// +----------------------------------------------------------------------+
-
 
16
// | Author: Lorenzo Alberton <l.alberton@quipo.it>                                  |
-
 
17
// +----------------------------------------------------------------------+
-
 
18
//
-
 
19
// $Id: MDB.php,v 1.1 2005-03-30 08:50:33 jpm Exp $
-
 
20
//
-
 
Line -... Line 3...
-
 
3
 
-
 
4
/**
-
 
5
 * Storage driver for use against PEAR MDB
-
 
6
 *
-
 
7
 * PHP versions 4 and 5
-
 
8
 *
-
 
9
 * LICENSE: This source file is subject to version 3.01 of the PHP license
-
 
10
 * that is available through the world-wide-web at the following URI:
-
 
11
 * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-
 
12
 * the PHP License and are unable to obtain it through the web, please
-
 
13
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
14
 *
-
 
15
 * @category   Authentication
-
 
16
 * @package    Auth
-
 
17
 * @author     Lorenzo Alberton <l.alberton@quipo.it> 
-
 
18
 * @author     Adam Ashley <aashley@php.net>
-
 
19
 * @copyright  2001-2006 The PHP Group
-
 
20
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
-
 
21
 * @version    CVS: $Id: MDB.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
-
 
22
 * @link       http://pear.php.net/package/Auth
-
 
23
 * @since      File available since Release 1.2.3
-
 
24
 */
-
 
25
 
-
 
26
/**
-
 
27
 * Include Auth_Container base class
21
 
28
 */
-
 
29
require_once 'Auth/Container.php';
-
 
30
/**
-
 
31
 * Include PEAR MDB package
22
require_once 'Auth/Container.php';
32
 */
Line 23... Line 33...
23
require_once 'MDB.php';
33
require_once 'MDB.php';
24
 
34
 
25
/**
35
/**
26
 * Storage driver for fetching login data from a database
36
 * Storage driver for fetching login data from a database
27
 *
37
 *
28
 * This storage driver can use all databases which are supported
38
 * This storage driver can use all databases which are supported
29
 * by the PEAR MDB abstraction layer to fetch login data.
39
 * by the PEAR MDB abstraction layer to fetch login data.
30
 *
40
 *
-
 
41
 * @category   Authentication
-
 
42
 * @package    Auth
-
 
43
 * @author     Lorenzo Alberton <l.alberton@quipo.it>
-
 
44
 * @author     Adam Ashley <aashley@php.net>
31
 * @author   Lorenzo Alberton <l.alberton@quipo.it>
45
 * @copyright  2001-2006 The PHP Group
-
 
46
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
-
 
47
 * @version    Release: 1.4.3  File: $Revision: 1.2 $
32
 * @package  Auth
48
 * @link       http://pear.php.net/package/Auth
33
 * @version  $Revision: 1.1 $
49
 * @since      Class available since Release 1.2.3
34
 */
50
 */
Line -... Line 51...
-
 
51
class Auth_Container_MDB extends Auth_Container
-
 
52
{
35
class Auth_Container_MDB extends Auth_Container
53
 
36
{
54
    // {{{ properties
37
 
55
 
38
    /**
56
    /**
39
     * Additional options for the storage container
57
     * Additional options for the storage container
Line 40... Line 58...
40
     * @var array
58
     * @var array
41
     */
59
     */
42
    var $options = array();
60
    var $options = array();
43
 
61
 
44
    /**
62
    /**
45
     * DB object
63
     * MDB object
Line 52... Line 70...
52
     * User that is currently selected from the DB.
70
     * User that is currently selected from the DB.
53
     * @var string
71
     * @var string
54
     */
72
     */
55
    var $activeUser = '';
73
    var $activeUser = '';
Line -... Line 74...
-
 
74
 
56
 
75
    // }}}
Line 57... Line 76...
57
    // {{{ Constructor
76
    // {{{ Auth_Container_MDB() [constructor]
58
 
77
 
59
    /**
78
    /**
60
     * Constructor of the container class
79
     * Constructor of the container class
61
     *
80
     *
62
     * Initate connection to the database via PEAR::DB
81
     * Initate connection to the database via PEAR::MDB
63
     *
82
     *
64
     * @param  string Connection data or DB object
83
     * @param  string Connection data or MDB object
65
     * @return object Returns an error object if something went wrong
84
     * @return object Returns an error object if something went wrong
66
     */
85
     */
67
    function Auth_Container_MDB($dsn)
86
    function Auth_Container_MDB($dsn)
Line 83... Line 102...
83
 
102
 
84
    /**
103
    /**
85
     * Connect to database by using the given DSN string
104
     * Connect to database by using the given DSN string
86
     *
105
     *
87
     * @access private
106
     * @access private
88
     * @param  string DSN string
107
     * @param  mixed DSN string | array | mdb object
89
     * @return mixed  Object on error, otherwise bool
108
     * @return mixed  Object on error, otherwise bool
90
     */
109
     */
91
    function _connect($dsn)
110
    function _connect($dsn)
92
    {
111
    {
93
        if (is_string($dsn) || is_array($dsn)) {
112
        if (is_string($dsn) || is_array($dsn)) {
94
            $this->db =& MDB::Connect($dsn);
113
            $this->db =& MDB::connect($dsn, $this->options['db_options']);
95
        } elseif (get_parent_class($dsn) == "mdb_common") {
114
        } elseif (is_subclass_of($dsn, 'mdb_common')) {
96
            $this->db = $dsn;
115
            $this->db = $dsn;
97
        } elseif (is_object($dsn) && MDB::isError($dsn)) {
116
        } elseif (is_object($dsn) && MDB::isError($dsn)) {
98
            return PEAR::raiseError($dsn->getMessage(), $dsn->code);
117
            return PEAR::raiseError($dsn->getMessage(), $dsn->code);
99
        } else {
118
        } else {
Line 106... Line 125...
106
 
125
 
Line 107... Line 126...
107
        }
126
        }
108
 
127
 
-
 
128
        if (MDB::isError($this->db) || PEAR::isError($this->db)) {
-
 
129
            return PEAR::raiseError($this->db->getMessage(), $this->db->code);
-
 
130
        }
-
 
131
 
-
 
132
        if ($this->options['auto_quote']) {
-
 
133
            $this->options['final_table'] = $this->db->quoteIdentifier($this->options['table']);
109
        if (MDB::isError($this->db) || PEAR::isError($this->db)) {
134
            $this->options['final_usernamecol'] = $this->db->quoteIdentifier($this->options['usernamecol']);
110
            return PEAR::raiseError($this->db->getMessage(), $this->db->code);
135
            $this->options['final_passwordcol'] = $this->db->quoteIdentifier($this->options['passwordcol']);
-
 
136
        } else {
-
 
137
            $this->options['final_table'] = $this->options['table'];
111
        } else {
138
            $this->options['final_usernamecol'] = $this->options['usernamecol'];
-
 
139
            $this->options['final_passwordcol'] = $this->options['passwordcol'];
-
 
140
        }
112
            return true;
141
 
Line 113... Line 142...
113
        }
142
        return true;
114
    }
143
    }
Line 121... Line 150...
121
     *
150
     *
122
     * This function checks if we have already opened a connection to
151
     * This function checks if we have already opened a connection to
123
     * the database. If that's not the case, a new connection is opened.
152
     * the database. If that's not the case, a new connection is opened.
124
     *
153
     *
125
     * @access private
154
     * @access private
126
     * @return mixed True or a DB error object.
155
     * @return mixed True or a MDB error object.
127
     */
156
     */
128
    function _prepare()
157
    function _prepare()
129
    {
158
    {
-
 
159
        if (is_subclass_of($this->db, 'mdb_common')) {
-
 
160
            return true;
-
 
161
        }
130
        return $this->_connect($this->options['dsn']);
162
        return $this->_connect($this->options['dsn']);
131
    }
163
    }
Line 132... Line 164...
132
 
164
 
133
    // }}}
165
    // }}}
Line 169... Line 201...
169
        $this->options['usernamecol'] = 'username';
201
        $this->options['usernamecol'] = 'username';
170
        $this->options['passwordcol'] = 'password';
202
        $this->options['passwordcol'] = 'password';
171
        $this->options['dsn']         = '';
203
        $this->options['dsn']         = '';
172
        $this->options['db_fields']   = '';
204
        $this->options['db_fields']   = '';
173
        $this->options['cryptType']   = 'md5';
205
        $this->options['cryptType']   = 'md5';
-
 
206
        $this->options['db_options']  = array();
-
 
207
        $this->options['auto_quote']  = true;
174
    }
208
    }
Line 175... Line 209...
175
 
209
 
176
    // }}}
210
    // }}}
Line 187... Line 221...
187
        foreach ($array as $key => $value) {
221
        foreach ($array as $key => $value) {
188
            if (isset($this->options[$key])) {
222
            if (isset($this->options[$key])) {
189
                $this->options[$key] = $value;
223
                $this->options[$key] = $value;
190
            }
224
            }
191
        }
225
        }
-
 
226
    }
-
 
227
 
-
 
228
    // }}}
-
 
229
    // {{{ _quoteDBFields()
Line -... Line 230...
-
 
230
 
192
 
231
    /**
-
 
232
     * Quote the db_fields option to avoid the possibility of SQL injection.
-
 
233
     *
-
 
234
     * @access private
-
 
235
     * @return string A properly quoted string that can be concatenated into a
-
 
236
     * SELECT clause.
-
 
237
     */
-
 
238
    function _quoteDBFields()
193
        // Include additional fields if they exist
239
    {
194
        if (!empty($this->options['db_fields'])) {
240
        if (isset($this->options['db_fields'])) {
-
 
241
            if (is_array($this->options['db_fields'])) {
-
 
242
                if ($this->options['auto_quote']) {
-
 
243
                    $fields = array();
-
 
244
                    foreach ($this->options['db_fields'] as $field) {
-
 
245
                        $fields[] = $this->db->quoteIdentifier($field);
-
 
246
                    }
-
 
247
                    return implode(', ', $fields);
195
            if (is_array($this->options['db_fields'])) {
248
                } else {
-
 
249
                    return implode(', ', $this->options['db_fields']);
-
 
250
                }
-
 
251
            } else {
-
 
252
                if (strlen($this->options['db_fields']) > 0) {
-
 
253
                    if ($this->options['auto_quote']) {
-
 
254
                        return $this->db->quoteIdentifier($this->options['db_fields']);
-
 
255
                    } else {
-
 
256
                        return $this->options['db_fields'];
-
 
257
                    }
196
                $this->options['db_fields'] = join($this->options['db_fields'], ', ');
258
                }
197
            }
-
 
198
            $this->options['db_fields'] = ', ' . $this->options['db_fields'];
259
            }
Line -... Line 260...
-
 
260
        }
199
        }
261
 
Line 200... Line 262...
200
 
262
        return '';
201
    }
263
    }
Line 212... Line 274...
212
     * and password is found, the function returns true.
274
     * and password is found, the function returns true.
213
     * Otherwise it returns false.
275
     * Otherwise it returns false.
214
     *
276
     *
215
     * @param   string Username
277
     * @param   string Username
216
     * @param   string Password
278
     * @param   string Password
-
 
279
     * @param   boolean If true password is secured using a md5 hash
-
 
280
     *                  the frontend and auth are responsible for making sure the container supports
-
 
281
     *                  challenge response password authentication
217
     * @return  mixed  Error object or boolean
282
     * @return  mixed  Error object or boolean
218
     */
283
     */
219
    function fetchData($username, $password)
284
    function fetchData($username, $password, $isChallengeResponse=false)
220
    {
285
    {
221
        // Prepare for a database query
286
        // Prepare for a database query
222
        $err = $this->_prepare();
287
        $err = $this->_prepare();
223
        if ($err !== true) {
288
        if ($err !== true) {
224
            return PEAR::raiseError($err->getMessage(), $err->getCode());
289
            return PEAR::raiseError($err->getMessage(), $err->getCode());
225
        }
290
        }
Line 226... Line 291...
226
 
291
 
-
 
292
        //Check if db_fields contains a *, if so assume all columns are selected
227
        // Find if db_fileds contains a *, i so assume all col are selected
293
        if (is_string($this->options['db_fields'])
228
        if (strstr($this->options['db_fields'], '*')) {
294
            && strstr($this->options['db_fields'], '*')) {
229
            $sql_from = '*';
295
            $sql_from = '*';
230
        } else{
296
        } else {
-
 
297
            $sql_from = $this->options['final_usernamecol'].
-
 
298
                ", ".$this->options['final_passwordcol'];
-
 
299
 
-
 
300
            if (strlen($fields = $this->_quoteDBFields()) > 0) {
-
 
301
                $sql_from .= ', '.$fields;
231
            $sql_from = $this->options['usernamecol'] . ', '. $this->options['passwordcol'] . $this->options['db_fields'];
302
            }
Line 232... Line 303...
232
        }
303
        }
233
 
304
 
234
        $query = sprintf("SELECT %s FROM %s WHERE %s = %s",
305
        $query = sprintf("SELECT %s FROM %s WHERE %s = %s",
235
                         $sql_from,
306
                         $sql_from,
236
                         $this->options['table'],
307
                         $this->options['final_table'],
237
                         $this->options['usernamecol'],
308
                         $this->options['final_usernamecol'],
Line 238... Line 309...
238
                         $this->db->getTextValue($username)
309
                         $this->db->getTextValue($username)
Line 245... Line 316...
245
        }
316
        }
246
        if (!is_array($res)) {
317
        if (!is_array($res)) {
247
            $this->activeUser = '';
318
            $this->activeUser = '';
248
            return false;
319
            return false;
249
        }
320
        }
-
 
321
 
-
 
322
        // Perform trimming here before the hashing
-
 
323
        $password = trim($password, "\r\n");
-
 
324
        $res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n");
-
 
325
        
-
 
326
        // If using Challenge Response md5 the pass with the secret
-
 
327
        if ($isChallengeResponse) {
-
 
328
            $res[$this->options['passwordcol']] =
-
 
329
                md5($res[$this->options['passwordcol']].$this->_auth_obj->session['loginchallenege']);
-
 
330
            // UGLY cannot avoid without modifying verifyPassword
-
 
331
            if ($this->options['cryptType'] == 'md5') {
-
 
332
                $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
-
 
333
            }
-
 
334
        }
-
 
335
        
250
        if ($this->verifyPassword(trim($password, "\r\n"),
336
        if ($this->verifyPassword($password,
251
                                  trim($res[$this->options['passwordcol']], "\r\n"),
337
                                  $res[$this->options['passwordcol']],
252
                                  $this->options['cryptType'])) {
338
                                  $this->options['cryptType'])) {
253
            // Store additional field values in the session
339
            // Store additional field values in the session
254
            foreach ($res as $key => $value) {
340
            foreach ($res as $key => $value) {
255
                if ($key == $this->options['passwordcol'] ||
341
                if ($key == $this->options['passwordcol'] ||
256
                    $key == $this->options['usernamecol']) {
342
                    $key == $this->options['usernamecol']) {
257
                    continue;
343
                    continue;
258
                }
344
                }
259
                // Use reference to the auth object if exists
345
                // Use reference to the auth object if exists
260
                // This is because the auth session variable can change so a static call to setAuthData does not make sence
346
                // This is because the auth session variable can change so a static
261
                if(is_object($this->_auth_obj)){
347
                // call to setAuthData does not make sense
262
                    $this->_auth_obj->setAuthData($key, $value);
348
                $this->_auth_obj->setAuthData($key, $value);
263
                } else {
-
 
264
                    Auth::setAuthData($key, $value);
-
 
265
                }
-
 
266
            }
349
            }
267
 
-
 
268
            return true;
350
            return true;
269
        }
351
        }
Line 270... Line 352...
270
 
352
 
271
        $this->activeUser = $res[$this->options['usernamecol']];
353
        $this->activeUser = $res[$this->options['usernamecol']];
272
        return false;
354
        return false;
Line 273... Line 355...
273
    }
355
    }
274
 
356
 
Line -... Line 357...
-
 
357
    // }}}
-
 
358
    // {{{ listUsers()
-
 
359
 
-
 
360
    /**
-
 
361
     * Returns a list of users from the container
-
 
362
     *
275
    // }}}
363
     * @return mixed array|PEAR_Error
276
    // {{{ listUsers()
364
     * @access public
277
 
365
     */
278
    function listUsers()
366
    function listUsers()
279
    {
367
    {
280
        $err = $this->_prepare();
368
        $err = $this->_prepare();
Line 281... Line 369...
281
        if ($err !== true) {
369
        if ($err !== true) {
Line 282... Line 370...
282
            return PEAR::raiseError($err->getMessage(), $err->getCode());
370
            return PEAR::raiseError($err->getMessage(), $err->getCode());
-
 
371
        }
283
        }
372
 
284
 
373
        $retVal = array();
285
        $retVal = array();
374
 
286
 
375
        //Check if db_fields contains a *, if so assume all columns are selected
-
 
376
        if (   is_string($this->options['db_fields'])
-
 
377
            && strstr($this->options['db_fields'], '*')) {
-
 
378
            $sql_from = '*';
-
 
379
        } else {
-
 
380
            $sql_from = $this->options['final_usernamecol']
287
        // Find if db_fileds contains a *, i so assume all col are selected
381
                .', '.$this->options['final_passwordcol'];
Line 288... Line 382...
288
        if (strstr($this->options['db_fields'], '*')) {
382
            
289
            $sql_from = '*';
383
            if (strlen($fields = $this->_quoteDBFields()) > 0) {
290
        } else{
384
                $sql_from .= ', '.$fields;
291
            $sql_from = $this->options['db_fields'];
385
            }
Line 292... Line 386...
292
        }
386
        }
Line 293... Line 387...
293
 
387
 
Line 322... Line 416...
322
     *
416
     *
323
     * @return mixed True on success, otherwise error object
417
     * @return mixed True on success, otherwise error object
324
     */
418
     */
325
    function addUser($username, $password, $additional = "")
419
    function addUser($username, $password, $additional = "")
326
    {
420
    {
-
 
421
        $err = $this->_prepare();
-
 
422
        if ($err !== true) {
-
 
423
            return PEAR::raiseError($err->getMessage(), $err->getCode());
-
 
424
        }
-
 
425
 
-
 
426
        if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') {
-
 
427
            $cryptFunction = 'strval';
327
        if (function_exists($this->options['cryptType'])) {
428
        } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) {
328
            $cryptFunction = $this->options['cryptType'];
429
            $cryptFunction = $this->options['cryptType'];
329
        } else {
430
        } else {
330
            $cryptFunction = 'md5';
431
            $cryptFunction = 'md5';
331
        }
432
        }
Line -... Line 433...
-
 
433
 
-
 
434
        $password = $cryptFunction($password);
332
 
435
 
333
        $additional_key   = '';
436
        $additional_key   = '';
Line 334... Line 437...
334
        $additional_value = '';
437
        $additional_value = '';
335
 
438
 
-
 
439
        if (is_array($additional)) {
-
 
440
            foreach ($additional as $key => $value) {
-
 
441
                if ($this->options['auto_quote']) {
336
        if (is_array($additional)) {
442
                    $additional_key   .= ', ' . $this->db->quoteIdentifier($key);
-
 
443
                } else {
337
            foreach ($additional as $key => $value) {
444
                    $additional_key   .= ', ' . $key;
338
                $additional_key   .= ', ' . $key;
445
                }
339
                $additional_value .= ', ' . $this->db->getTextValue($value);
446
                $additional_value .= ', ' . $this->db->getTextValue($value);
Line 340... Line 447...
340
            }
447
            }
341
        }
448
        }
342
 
449
 
343
        $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES (%s, %s%s)",
450
        $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES (%s, %s%s)",
344
                         $this->options['table'],
451
                         $this->options['final_table'],
345
                         $this->options['usernamecol'],
452
                         $this->options['final_usernamecol'],
346
                         $this->options['passwordcol'],
453
                         $this->options['final_passwordcol'],
347
                         $additional_key,
454
                         $additional_key,
348
                         $this->db->getTextValue($username),
455
                         $this->db->getTextValue($username),
Line 349... Line 456...
349
                         $this->db->getTextValue($cryptFunction($password)),
456
                         $this->db->getTextValue($password),
Line 350... Line 457...
350
                         $additional_value
457
                         $additional_value
351
                         );
458
                         );
352
 
-
 
353
        $res = $this->query($query);
-
 
354
 
459
 
-
 
460
        $res = $this->query($query);
355
        if (MDB::isError($res)) {
461
 
Line 356... Line 462...
356
            return PEAR::raiseError($res->getMessage(), $res->code);
462
        if (MDB::isError($res)) {
357
        } else {
463
            return PEAR::raiseError($res->getMessage(), $res->code);
Line 370... Line 476...
370
     *
476
     *
371
     * @return mixed True on success, otherwise error object
477
     * @return mixed True on success, otherwise error object
372
     */
478
     */
373
    function removeUser($username)
479
    function removeUser($username)
374
    {
480
    {
-
 
481
        $err = $this->_prepare();
-
 
482
        if ($err !== true) {
-
 
483
            return PEAR::raiseError($err->getMessage(), $err->getCode());
-
 
484
        }
-
 
485
 
375
        $query = sprintf("DELETE FROM %s WHERE %s = %s",
486
        $query = sprintf("DELETE FROM %s WHERE %s = %s",
376
                         $this->options['table'],
487
                         $this->options['final_table'],
377
                         $this->options['usernamecol'],
488
                         $this->options['final_usernamecol'],
378
                         $this->db->getTextValue($username)
489
                         $this->db->getTextValue($username)
379
                         );
490
                         );
Line 380... Line 491...
380
 
491
 
Line 381... Line 492...
381
        $res = $this->query($query);
492
        $res = $this->query($query);
382
 
493
 
-
 
494
        if (MDB::isError($res)) {
-
 
495
            return PEAR::raiseError($res->getMessage(), $res->code);
-
 
496
        }
-
 
497
        return true;
-
 
498
    }
-
 
499
 
-
 
500
    // }}}
-
 
501
    // {{{ changePassword()
-
 
502
 
-
 
503
    /**
-
 
504
     * Change password for user in the storage container
-
 
505
     *
-
 
506
     * @param string Username
-
 
507
     * @param string The new password (plain text)
-
 
508
     */
-
 
509
    function changePassword($username, $password)
-
 
510
    {
-
 
511
        $err = $this->_prepare();
-
 
512
        if ($err !== true) {
-
 
513
            return PEAR::raiseError($err->getMessage(), $err->getCode());
-
 
514
        }
-
 
515
 
-
 
516
        if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') {
-
 
517
            $cryptFunction = 'strval';
383
        if (MDB::isError($res)) {
518
        } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) {
-
 
519
            $cryptFunction = $this->options['cryptType'];
-
 
520
        } else {
-
 
521
            $cryptFunction = 'md5';
-
 
522
        }
-
 
523
 
-
 
524
        $password = $cryptFunction($password);
-
 
525
 
-
 
526
        $query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s",
-
 
527
                         $this->options['final_table'],
-
 
528
                         $this->options['final_passwordcol'],
-
 
529
                         $this->db->getTextValue($password),
-
 
530
                         $this->options['final_usernamecol'],
-
 
531
                         $this->db->getTextValue($username)
-
 
532
                         );
-
 
533
 
-
 
534
        $res = $this->query($query);
-
 
535
 
-
 
536
        if (MDB::isError($res)) {
384
           return PEAR::raiseError($res->getMessage(), $res->code);
537
            return PEAR::raiseError($res->getMessage(), $res->code);
385
        } else {
538
        }
-
 
539
        return true;
-
 
540
    }
-
 
541
 
-
 
542
    // }}}
-
 
543
    // {{{ supportsChallengeResponse()
-
 
544
 
-
 
545
    /**
-
 
546
     * Determine if this container supports
-
 
547
     * password authentication with challenge response
-
 
548
     *
-
 
549
     * @return bool
-
 
550
     * @access public
-
 
551
     */
-
 
552
    function supportsChallengeResponse()
-
 
553
    {
-
 
554
        return in_array($this->options['cryptType'], array('md5', 'none', ''));
-
 
555
    }
-
 
556
 
-
 
557
    // }}}
-
 
558
    // {{{ getCryptType()
-
 
559
 
-
 
560
    /**
-
 
561
     * Returns the selected crypt type for this container
-
 
562
     *
-
 
563
     * @return string Function used to crypt the password
-
 
564
     */
-
 
565
    function getCryptType()
386
          return true;
566
    {
Line 387... Line 567...
387
        }
567
        return $this->options['cryptType'];
-
 
568
    }
388
    }
569
 
389
 
570
    // }}}
390
    // }}}
571