1 | <?php |
---|
2 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ |
---|
3 | |
---|
4 | /** |
---|
5 | * Storage driver for use against PEAR website |
---|
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 Yavor Shahpasov <yavo@netsmart.com.cy> |
---|
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: PEAR.php 8713 2006-12-01 05:08:34Z kakinaka $ |
---|
22 | * @link http://pear.php.net/package/Auth |
---|
23 | * @since File available since Release 1.3.0 |
---|
24 | */ |
---|
25 | |
---|
26 | /** |
---|
27 | * Include Auth_Container base class |
---|
28 | */ |
---|
29 | require_once 'Auth/Container.php'; |
---|
30 | /** |
---|
31 | * Include PEAR XML_RPC |
---|
32 | */ |
---|
33 | require_once 'XML/RPC.php'; |
---|
34 | |
---|
35 | /** |
---|
36 | * Storage driver for authenticating against PEAR website |
---|
37 | * |
---|
38 | * This driver provides a method for authenticating against the pear.php.net |
---|
39 | * authentication system. |
---|
40 | * |
---|
41 | * @category Authentication |
---|
42 | * @package Auth |
---|
43 | * @author Yavor Shahpasov <yavo@netsmart.com.cy> |
---|
44 | * @author Adam Ashley <aashley@php.net> |
---|
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.2 File: $Revision: 8713 $ |
---|
48 | * @link http://pear.php.net/package/Auth |
---|
49 | * @since Class available since Release 1.3.0 |
---|
50 | */ |
---|
51 | class Auth_Container_Pear extends Auth_Container |
---|
52 | { |
---|
53 | |
---|
54 | // {{{ Auth_Container_Pear() [constructor] |
---|
55 | |
---|
56 | /** |
---|
57 | * Constructor |
---|
58 | * |
---|
59 | * Currently does nothing |
---|
60 | * |
---|
61 | * @return void |
---|
62 | */ |
---|
63 | function Auth_Container_Pear() |
---|
64 | { |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | // }}} |
---|
69 | // {{{ fetchData() |
---|
70 | |
---|
71 | /** |
---|
72 | * Get user information from pear.php.net |
---|
73 | * |
---|
74 | * This function uses the given username and password to authenticate |
---|
75 | * against the pear.php.net website |
---|
76 | * |
---|
77 | * @param string Username |
---|
78 | * @param string Password |
---|
79 | * @return mixed Error object or boolean |
---|
80 | */ |
---|
81 | function fetchData($username, $password) |
---|
82 | { |
---|
83 | $rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net'); |
---|
84 | $rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) ); |
---|
85 | |
---|
86 | // Error Checking howto ??? |
---|
87 | $result = $rpc->send($rpc_message); |
---|
88 | $value = $result->value(); |
---|
89 | $userinfo = xml_rpc_decode($value); |
---|
90 | if ($userinfo['password'] == md5($password)) { |
---|
91 | $this->activeUser = $userinfo['handle']; |
---|
92 | foreach ($userinfo as $uk=>$uv) { |
---|
93 | $this->_auth_obj->setAuthData($uk, $uv); |
---|
94 | } |
---|
95 | return true; |
---|
96 | } |
---|
97 | return false; |
---|
98 | } |
---|
99 | |
---|
100 | // }}} |
---|
101 | |
---|
102 | } |
---|
103 | ?> |
---|