| 1 |
aurelien |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* Storage driver for use with a Vpopmaild server
|
|
|
6 |
*
|
|
|
7 |
* PHP versions 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 Bill Shupp <hostmaster@shupp.org>
|
|
|
18 |
* @author Stefan Ekman <stekman@sedata.org>
|
|
|
19 |
* @author Martin Jansen <mj@php.net>
|
|
|
20 |
* @author Mika Tuupola <tuupola@appelsiini.net>
|
|
|
21 |
* @author Adam Ashley <aashley@php.net>
|
|
|
22 |
* @copyright 2001-2006 The PHP Group
|
|
|
23 |
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
|
|
24 |
* @link http://pear.php.net/package/Auth
|
|
|
25 |
* @since File available since Release 1.2.0
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Include Auth_Container base class
|
|
|
30 |
*/
|
|
|
31 |
require_once 'Auth/Container.php';
|
|
|
32 |
/**
|
|
|
33 |
* Include PEAR package for error handling
|
|
|
34 |
*/
|
|
|
35 |
require_once 'PEAR.php';
|
|
|
36 |
/**
|
|
|
37 |
* Include PEAR Net_Vpopmaild package
|
|
|
38 |
*/
|
|
|
39 |
require_once 'Net/Vpopmaild.php';
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Storage driver for Authentication on a Vpopmaild server.
|
|
|
43 |
*
|
|
|
44 |
* @category Authentication
|
|
|
45 |
* @package Auth
|
|
|
46 |
* @author Martin Jansen <mj@php.net>
|
|
|
47 |
* @author Mika Tuupola <tuupola@appelsiini.net>
|
|
|
48 |
* @author Adam Ashley <aashley@php.net>
|
|
|
49 |
* @copyright 2001-2006 The PHP Group
|
|
|
50 |
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
|
|
51 |
* @version Release: 1.5.4 File: $Revision: 1.1 $
|
|
|
52 |
* @link http://pear.php.net/package/Auth
|
|
|
53 |
* @since Class available since Release 1.6.0
|
|
|
54 |
*/
|
|
|
55 |
class Auth_Container_Vpopmaild extends Auth_Container
|
|
|
56 |
{
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Vpopmaild Server
|
|
|
60 |
* @var string
|
|
|
61 |
*/
|
|
|
62 |
var $server = 'localhost';
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Vpopmaild Server port
|
|
|
66 |
* @var string
|
|
|
67 |
*/
|
|
|
68 |
var $port = 89;
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Constructor of the container class
|
|
|
72 |
*
|
|
|
73 |
* @param $server string server or server:port combination
|
|
|
74 |
* @return object Returns an error object if something went wrong
|
|
|
75 |
*/
|
|
|
76 |
function Auth_Container_Vpopmaild($server=null)
|
|
|
77 |
{
|
|
|
78 |
if (isset($server) && !is_null($server)) {
|
|
|
79 |
if (is_array($server)) {
|
|
|
80 |
if (isset($server['host'])) {
|
|
|
81 |
$this->server = $server['host'];
|
|
|
82 |
}
|
|
|
83 |
if (isset($server['port'])) {
|
|
|
84 |
$this->port = $server['port'];
|
|
|
85 |
}
|
|
|
86 |
} else {
|
|
|
87 |
if (strstr($server, ':')) {
|
|
|
88 |
$serverparts = explode(':', trim($server));
|
|
|
89 |
$this->server = $serverparts[0];
|
|
|
90 |
$this->port = $serverparts[1];
|
|
|
91 |
} else {
|
|
|
92 |
$this->server = $server;
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
/**
|
|
|
99 |
* fetchData()
|
|
|
100 |
*
|
|
|
101 |
* Try to login to the Vpopmaild server
|
|
|
102 |
*
|
|
|
103 |
* @param string username
|
|
|
104 |
* @param string password
|
|
|
105 |
*
|
|
|
106 |
* @return boolean
|
|
|
107 |
*/
|
|
|
108 |
function fetchData($username, $password)
|
|
|
109 |
{
|
|
|
110 |
$this->log('Auth_Container_Vpopmaild::fetchData() called.', AUTH_LOG_DEBUG);
|
|
|
111 |
$vpopmaild =& new Net_Vpopmaild();
|
|
|
112 |
// Connect
|
|
|
113 |
try {
|
|
|
114 |
$res = $vpopmaild->connect($this->server, $this->port, $this->method);
|
|
|
115 |
} catch (Net_Vpopmaild_FatalException $e) {
|
|
|
116 |
$this->log('Connection to Vpopmaild server failed.', AUTH_LOG_DEBUG);
|
|
|
117 |
return PEAR::raiseError($e->getMessage(), $e->getCode());
|
|
|
118 |
}
|
|
|
119 |
// Authenticate
|
|
|
120 |
try {
|
|
|
121 |
$result = $vpopmaild->clogin($username, $password);
|
|
|
122 |
$vpopmaild->quit();
|
|
|
123 |
} catch (Net_Vpopmaild_Exception $e) {
|
|
|
124 |
return PEAR::raiseError($e->getMessage(), $e->getCode());
|
|
|
125 |
}
|
|
|
126 |
return $result;
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
?>
|