PluginProbe
Postie / trunk
Postie vtrunk
1.9.80 1.9.79 1.9.78 1.9.77 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.10 1.7.11 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.2 1.7.20 All 239 releases
postie / lib / pConnection.php

pConnection.php in Postie trunk, at lib/pConnection.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 abstract class pConnection {
4
5 protected $username;
6 protected $host;
7 protected $password;
8 protected $port;
9 protected $secure;
10 protected $timeout;
11 protected $mailbox;
12 protected $type;
13
14 public function __construct($type, $host, $username, $password, $port, $secure = FALSE, $timeout = NULL) {
15
16 $valid_types = array('imap', 'pop3');
17 if (!in_array($type, $valid_types)) {
18 throw new fProgrammerException('The mailbox type specified, %1$s, in invalid. Must be one of: %2$s.', $type, join(', ', $valid_types));
19 }
20
21 if ($secure && !extension_loaded('openssl')) {
22 throw new fEnvironmentException('A secure connection was requested, but the %s extension is not installed', 'openssl');
23 }
24
25 if ($timeout === NULL) {
26 $timeout = ini_get('default_socket_timeout');
27 }
28
29 $this->type = $type;
30 $this->host = $host;
31 $this->username = $username;
32 if (($i = strpos($username, '/')) !== false) {
33 $this->username = substr($username, 0, $i);
34 $this->mailbox = substr($username, $i + 1);
35 } else {
36 $this->username = $username;
37 $this->mailbox = 'INBOX';
38 }
39 //DebugEcho('USERNAME: ' . $this->username);
40 DebugEcho('pConnection: mailbox: ' . $this->mailbox);
41
42 $this->password = $password;
43 $this->port = $port;
44 $this->secure = $secure;
45 $this->timeout = $timeout;
46 }
47
48 abstract function read($expect = NULL);
49
50 abstract function write($command, $expected = null);
51
52 abstract function close();
53
54 abstract function open();
55
56 abstract function isPersistant();
57
58 public function getMailbox() {
59 return $this->mailbox;
60 }
61
62 }
63