1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class IMP_Test extends Horde_Test
16: {
17: 18: 19: 20: 21:
22: protected $_moduleList = array(
23: 'zip' => array(
24: 'descrip' => 'Zip Support',
25: 'error' => 'The zip extension is used when importing compress mailboxes. IMP will fallback to using the zlib extension (if available) to read this data which should be sufficient for most installations. If zip support is desired, compile PHP with <code>--with-zip</code> to activate.'
26: )
27: );
28:
29: 30: 31: 32: 33:
34: protected $_settingsList = array(
35: 'file_uploads' => array(
36: 'error' => 'file_uploads must be enabled to use various features of IMP. See the INSTALL file for more information.',
37: 'setting' => true
38: )
39: );
40:
41: 42: 43: 44: 45:
46: protected $_pearList = array();
47:
48: 49: 50: 51: 52:
53: protected $_fileList = array(
54: 'config/conf.php' => 'The file <code>./config/conf.php</code> appears to be missing. You must generate this file as an administrator via Horde. See horde/docs/INSTALL.',
55: );
56:
57: 58: 59: 60: 61:
62: protected $_appList = array(
63: 'gollem' => array(
64: 'error' => 'Gollem provides access to local VFS filesystems to attach files.',
65: 'version' => '2.0'
66: ),
67: 'ingo' => array(
68: 'error' => 'Ingo provides basic mail filtering capabilities to IMP.',
69: 'version' => '2.0'
70: ),
71: 'nag' => array(
72: 'error' => 'Nag allows tasks to be directly created from e-mail data.',
73: 'version' => '3.0'
74: ),
75: 'turba' => array(
76: 'error' => 'Turba provides addressbook/contacts capabilities to IMP.',
77: 'version' => '3.0'
78: )
79: );
80:
81: 82: 83: 84: 85:
86: public function appTests()
87: {
88: $ret = '<h1>Mail Server Support Test</h1>';
89:
90: if (Horde_Util::getPost('user') && Horde_Util::getPost('passwd')) {
91: $ret .= $this->_doConnectionTest();
92: }
93:
94: $self_url = Horde::selfUrl()->add('app', 'imp');
95:
96: Horde::startBuffer();
97: require IMP_TEMPLATES . '/test/mailserver.inc';
98:
99: return $ret . Horde::endBuffer();
100: }
101:
102: 103: 104: 105: 106:
107: protected function _doConnectionTest()
108: {
109: $imap_config = array(
110: 'username' => Horde_Util::getPost('user'),
111: 'password' => Horde_Util::getPost('passwd'),
112: 'hostspec' => Horde_Util::getPost('server'),
113: 'port' => Horde_Util::getPost('port'),
114: 'secure' => Horde_Util::getPost('encrypt')
115: );
116:
117: $driver = (Horde_Util::getPost('server_type') == 'imap')
118: ? 'Socket'
119: : 'Socket_Pop3';
120:
121: try {
122: $imap_client = Horde_Imap_Client::factory($driver, $imap_config);
123: } catch (Horde_Imap_Client_Exception $e) {
124: return $this->_errorMsg($e);
125: }
126:
127: $ret = '<strong>Attempting to login to the server:</strong> ';
128:
129: try {
130: $imap_client->login();
131: } catch (Horde_Imap_Client_Exception $e) {
132: return $this->_errorMsg($e);
133: }
134:
135: $ret .= '<span style="color:green">SUCCESS</span><p />';
136:
137: if ($driver == 'Socket') {
138: $ret .= '<strong>The following IMAP server information was discovered from the server:</strong>' .
139: '<blockquote><em>Namespace Information</em><blockquote><pre>';
140:
141: try {
142: $namespaces = $imap_client->getNamespaces();
143: foreach ($namespaces as $val) {
144: switch ($val['type']) {
145: case Horde_Imap_Client::NS_PERSONAL:
146: $type = 'Personal';
147: break;
148:
149: case Horde_Imap_Client::NS_OTHER:
150: $type = 'Other Users\'';
151: break;
152:
153: case Horde_Imap_Client::NS_SHARED:
154: $type = 'Shared';
155: break;
156: }
157:
158: $ret .= 'NAMESPACE: "' . htmlspecialchars($val['name']) . "\"\n" .
159: 'DELIMITER: ' . htmlspecialchars($val['delimiter']) . "\n" .
160: 'TYPE: ' . htmlspecialchars($type) . "\n\n";
161: }
162: } catch (Horde_Imap_Client_Exception $e) {
163: $this->_errorMsg($e);
164: }
165:
166: $ret .= '</pre></blockquote></blockquote>' .
167: '<blockquote><em>IMAP server capabilities:</em><blockquote><pre>';
168:
169: try {
170: foreach ($imap_client->capability() as $key => $val) {
171: if (is_array($val)) {
172: foreach ($val as $val2) {
173: $ret .= htmlspecialchars($key) . '=' . htmlspecialchars($val2) . "\n";
174: }
175: } else {
176: $ret .= htmlspecialchars($key) . "\n";
177: }
178: }
179: } catch (Horde_Imap_Client_Exception $e) {
180: $this->_errorMsg($e);
181: }
182:
183: $ret .= '</pre></blockquote></blockquote>' .
184: '<blockquote><em>Does IMAP server support UTF-8 in search queries?</em> ';
185:
186: if ($imap_client->validSearchCharset('UTF-8')) {
187: $ret .= '<span style="color:green">YES</span>';
188: } else {
189: $ret .= '<span style="color:red">NO</span>';
190: }
191:
192: $ret .= '</blockquote>';
193:
194: try {
195: $id_info = $imap_client->getID();
196: if (!empty($id_info)) {
197: $ret .= '<blockquote><em>IMAP server information:</em><blockquote><pre>';
198: foreach ($id_info as $key => $val) {
199: $ret .= htmlspecialchars("$key: $val") . "\n";
200: }
201: $ret .= '</pre></blockquote></blockquote>';
202: }
203: } catch (Horde_Imap_Client_Exception $e) {
204:
205: }
206:
207:
208: } else {
209: $ret .= '<strong>Checking for the UIDL capability:</strong> ';
210:
211: if ($imap_client->queryCapability('UIDL')) {
212: $ret .= '<span style="color:green">SUCCESS</span><p />';
213: } else {
214: return $this->_errorMsg(new Exception('The POP3 server does not support the *REQUIRED* UIDL capability.'));
215: }
216: }
217:
218: return $ret;
219: }
220:
221: 222: 223: 224: 225:
226: protected function _errorMsg($e)
227: {
228: return '<span style="color:red">ERROR</span> - The server returned the following error message:' .
229: '<pre>' . $e->getMessage() . '</pre><p />';
230: }
231:
232: }
233: