source: branches/feature-module-update/html/test/kakinaka/pear/Auth/Container/POP3.php @ 15532

Revision 15532, 3.9 KB checked in by nanasess, 17 years ago (diff)

svn:mime-type 修正

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
4/**
5 * Storage driver for use against a POP3 server
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     Stefan Ekman <stekman@sedata.org>
18 * @author     Martin Jansen <mj@php.net>
19 * @author     Mika Tuupola <tuupola@appelsiini.net>
20 * @author     Adam Ashley <aashley@php.net>
21 * @copyright  2001-2006 The PHP Group
22 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
23 * @version    CVS: $Id$
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 */
31require_once 'Auth/Container.php';
32/**
33 * Include PEAR package for error handling
34 */
35require_once 'PEAR.php';
36/**
37 * Include PEAR Net_POP3 package
38 */
39require_once 'Net/POP3.php';
40
41/**
42 * Storage driver for Authentication on a POP3 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.4.2  File: $Revision: 8713 $
52 * @link       http://pear.php.net/package/Auth
53 * @since      Class available since Release 1.2.0
54 */
55class Auth_Container_POP3 extends Auth_Container
56{
57
58    // {{{ properties
59
60    /**
61     * POP3 Server
62     * @var string
63     */
64    var $server='localhost';
65
66    /**
67     * POP3 Server port
68     * @var string
69     */
70    var $port='110';
71
72    /**
73     * POP3 Authentication method
74     *
75     * Prefered POP3 authentication method. Acceptable values:
76     *      Boolean TRUE    - Use Net_POP3's autodetection
77     *      String 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
78     *                      - Attempt this authentication style first
79     *                        then fallback to autodetection.
80     * @var mixed
81     */
82    var $method=true;
83
84    // }}}
85    // {{{ Auth_Container_POP3() [constructor]
86
87    /**
88     * Constructor of the container class
89     *
90     * @param  $server string server or server:port combination
91     * @return object Returns an error object if something went wrong
92     */
93    function Auth_Container_POP3($server=null)
94    {
95        if (isset($server)) {
96            if (is_array($server)) {
97                if (isset($server['host'])) {
98                    $this->server = $server['host'];
99                }
100                if (isset($server['port'])) {
101                    $this->port = $server['port'];
102                }
103                if (isset($server['method'])) {
104                    $this->method = $server['method'];
105                }
106            } else {
107                if (strstr($server, ':')) {
108                    $serverparts = explode(':', trim($server));
109                    $this->server = $serverparts[0];
110                    $this->port = $serverparts[1];
111                } else {
112                    $this->server = $server;
113                }
114            }
115        }
116    }
117
118    // }}}
119    // {{{ fetchData()
120
121    /**
122     * Try to login to the POP3 server
123     *
124     * @param   string Username
125     * @param   string Password
126     * @return  boolean
127     */
128    function fetchData($username, $password)
129    {
130        $pop3 =& new Net_POP3();
131        $res = $pop3->connect($this->server, $this->port, $this->method);
132        if (!$res) {
133            return $res;
134        }
135        $result = $pop3->login($username, $password);
136        $pop3->disconnect();
137        return $result;
138    }
139
140    // }}}
141
142}
143?>
Note: See TracBrowser for help on using the repository browser.