Subversion Repositories Applications.papyrus

Rev

Rev 1173 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1173 Rev 1713
1
<?php
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
 
3
 
4
/**
4
/**
5
 * Storage driver for use against a POP3 server
5
 * Storage driver for use against a POP3 server
6
 *
6
 *
7
 * PHP versions 4 and 5
7
 * PHP versions 4 and 5
8
 *
8
 *
9
 * LICENSE: This source file is subject to version 3.01 of the PHP license
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:
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
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
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.
13
 * send a note to license@php.net so we can mail you a copy immediately.
14
 *
14
 *
15
 * @category   Authentication
15
 * @category   Authentication
16
 * @package    Auth
16
 * @package    Auth
17
 * @author     Stefan Ekman <stekman@sedata.org> 
17
 * @author     Stefan Ekman <stekman@sedata.org>
18
 * @author     Martin Jansen <mj@php.net>
18
 * @author     Martin Jansen <mj@php.net>
19
 * @author     Mika Tuupola <tuupola@appelsiini.net> 
19
 * @author     Mika Tuupola <tuupola@appelsiini.net>
20
 * @author     Adam Ashley <aashley@php.net>
20
 * @author     Adam Ashley <aashley@php.net>
21
 * @copyright  2001-2006 The PHP Group
21
 * @copyright  2001-2006 The PHP Group
22
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
22
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
23
 * @version    CVS: $Id: POP3.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
23
 * @version    CVS: $Id: POP3.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
24
 * @link       http://pear.php.net/package/Auth
24
 * @link       http://pear.php.net/package/Auth
25
 * @since      File available since Release 1.2.0
25
 * @since      File available since Release 1.2.0
26
 */
26
 */
27
 
27
 
28
/**
28
/**
29
 * Include Auth_Container base class
29
 * Include Auth_Container base class
30
 */
30
 */
31
require_once 'Auth/Container.php';
31
require_once 'Auth/Container.php';
32
/**
32
/**
33
 * Include PEAR package for error handling
33
 * Include PEAR package for error handling
34
 */
34
 */
35
require_once 'PEAR.php';
35
require_once 'PEAR.php';
36
/**
36
/**
37
 * Include PEAR Net_POP3 package
37
 * Include PEAR Net_POP3 package
38
 */
38
 */
39
require_once 'Net/POP3.php';
39
require_once 'Net/POP3.php';
40
 
40
 
41
/**
41
/**
42
 * Storage driver for Authentication on a POP3 server.
42
 * Storage driver for Authentication on a POP3 server.
43
 *
43
 *
44
 * @category   Authentication
44
 * @category   Authentication
45
 * @package    Auth
45
 * @package    Auth
46
 * @author     Martin Jansen <mj@php.net>
46
 * @author     Martin Jansen <mj@php.net>
47
 * @author     Mika Tuupola <tuupola@appelsiini.net> 
47
 * @author     Mika Tuupola <tuupola@appelsiini.net>
48
 * @author     Adam Ashley <aashley@php.net>
48
 * @author     Adam Ashley <aashley@php.net>
49
 * @copyright  2001-2006 The PHP Group
49
 * @copyright  2001-2006 The PHP Group
50
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
50
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
51
 * @version    Release: 1.4.3  File: $Revision: 1.2 $
51
 * @version    Release: 1.5.4  File: $Revision: 1.3 $
52
 * @link       http://pear.php.net/package/Auth
52
 * @link       http://pear.php.net/package/Auth
53
 * @since      Class available since Release 1.2.0
53
 * @since      Class available since Release 1.2.0
54
 */
54
 */
55
class Auth_Container_POP3 extends Auth_Container
55
class Auth_Container_POP3 extends Auth_Container
56
{
56
{
57
 
57
 
58
    // {{{ properties
58
    // {{{ properties
59
 
59
 
60
    /**
60
    /**
61
     * POP3 Server
61
     * POP3 Server
62
     * @var string
62
     * @var string
63
     */
63
     */
64
    var $server='localhost';
64
    var $server='localhost';
65
 
65
 
66
    /**
66
    /**
67
     * POP3 Server port
67
     * POP3 Server port
68
     * @var string
68
     * @var string
69
     */
69
     */
70
    var $port='110';
70
    var $port='110';
71
 
71
 
72
    /**
72
    /**
73
     * POP3 Authentication method
73
     * POP3 Authentication method
74
     *
74
     *
75
     * Prefered POP3 authentication method. Acceptable values:
75
     * Prefered POP3 authentication method. Acceptable values:
76
     *      Boolean TRUE    - Use Net_POP3's autodetection
76
     *      Boolean TRUE    - Use Net_POP3's autodetection
77
     *      String 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
77
     *      String 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
78
     *                      - Attempt this authentication style first
78
     *                      - Attempt this authentication style first
79
     *                        then fallback to autodetection.
79
     *                        then fallback to autodetection.
80
     * @var mixed 
80
     * @var mixed
81
     */
81
     */
82
    var $method=true;
82
    var $method=true;
83
 
83
 
84
    // }}}
84
    // }}}
85
    // {{{ Auth_Container_POP3() [constructor]
85
    // {{{ Auth_Container_POP3() [constructor]
86
 
86
 
87
    /**
87
    /**
88
     * Constructor of the container class
88
     * Constructor of the container class
89
     *
89
     *
90
     * @param  $server string server or server:port combination
90
     * @param  $server string server or server:port combination
91
     * @return object Returns an error object if something went wrong
91
     * @return object Returns an error object if something went wrong
92
     */
92
     */
93
    function Auth_Container_POP3($server=null)
93
    function Auth_Container_POP3($server=null)
94
    {
94
    {
95
        if (isset($server) && !is_null($server)) {
95
        if (isset($server) && !is_null($server)) {
96
            if (is_array($server)) {
96
            if (is_array($server)) {
97
                if (isset($server['host'])) {
97
                if (isset($server['host'])) {
98
                    $this->server = $server['host'];
98
                    $this->server = $server['host'];
99
                }
99
                }
100
                if (isset($server['port'])) {
100
                if (isset($server['port'])) {
101
                    $this->port = $server['port'];
101
                    $this->port = $server['port'];
102
                }
102
                }
103
                if (isset($server['method'])) {
103
                if (isset($server['method'])) {
104
                    $this->method = $server['method'];
104
                    $this->method = $server['method'];
105
                }
105
                }
106
            } else {
106
            } else {
107
                if (strstr($server, ':')) {
107
                if (strstr($server, ':')) {
108
                    $serverparts = explode(':', trim($server));
108
                    $serverparts = explode(':', trim($server));
109
                    $this->server = $serverparts[0];
109
                    $this->server = $serverparts[0];
110
                    $this->port = $serverparts[1];
110
                    $this->port = $serverparts[1];
111
                } else {
111
                } else {
112
                    $this->server = $server;
112
                    $this->server = $server;
113
                }
113
                }
114
            }
114
            }
115
        }
115
        }
116
    }
116
    }
117
 
117
 
118
    // }}}
118
    // }}}
119
    // {{{ fetchData()
119
    // {{{ fetchData()
120
 
120
 
121
    /**
121
    /**
122
     * Try to login to the POP3 server
122
     * Try to login to the POP3 server
123
     *
123
     *
124
     * @param   string Username
124
     * @param   string Username
125
     * @param   string Password
125
     * @param   string Password
126
     * @return  boolean
126
     * @return  boolean
127
     */
127
     */
128
    function fetchData($username, $password)
128
    function fetchData($username, $password)
129
    {
129
    {
-
 
130
        $this->log('Auth_Container_POP3::fetchData() called.', AUTH_LOG_DEBUG);
130
        $pop3 =& new Net_POP3();
131
        $pop3 =& new Net_POP3();
131
        $res = $pop3->connect($this->server, $this->port, $this->method);
132
        $res = $pop3->connect($this->server, $this->port, $this->method);
132
        if (!$res) {
133
        if (!$res) {
-
 
134
            $this->log('Connection to POP3 server failed.', AUTH_LOG_DEBUG);
133
            return $res;
135
            return $res;
134
        }
136
        }
135
        $result = $pop3->login($username, $password);
137
        $result = $pop3->login($username, $password);
136
        $pop3->disconnect();
138
        $pop3->disconnect();
137
        return $result;
139
        return $result;
138
    }
140
    }
139
 
141
 
140
    // }}}
142
    // }}}
141
 
143
 
142
}
144
}
143
?>
145
?>