01c372f1 |
1 | <?php |
4b4abf93 |
2 | |
ea5f4b8e |
3 | /** |
91e0dccc |
4 | * options page for IMAP info plugin |
5 | * |
a7b90f05 |
6 | * This is where it all happens :) |
91e0dccc |
7 | * |
4b4abf93 |
8 | * @author Jason Munro <jason at stdbev.com> |
4b5049de |
9 | * @copyright © 1999-2007 The SquirrelMail Project Team |
b11fe046 |
10 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
11 | * @version $Id$ |
ea5f4b8e |
12 | * @package plugins |
13 | * @subpackage info |
a7b90f05 |
14 | */ |
8d6a115b |
15 | |
202bcbcc |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
20 | require('../../include/init.php'); |
a7b90f05 |
21 | |
cdf82d4a |
22 | /* SquirrelMail required files. */ |
202bcbcc |
23 | require_once(SM_PATH . 'functions/imap_general.php'); |
a9e1e670 |
24 | require_once(SM_PATH . 'functions/forms.php'); |
cdf82d4a |
25 | require_once(SM_PATH . 'plugins/info/functions.php'); |
a7b90f05 |
26 | |
27 | global $username, $color, $folder_prefix, $default_charset; |
28 | $default_charset = strtoupper($default_charset); |
876fdb60 |
29 | displayPageHeader($color); |
a7b90f05 |
30 | $mailbox = 'INBOX'; |
6a85a764 |
31 | |
b11fe046 |
32 | /** |
33 | * testing installation |
34 | * |
35 | * prevent use of plugin if it is not enabled |
36 | */ |
37 | if (! is_plugin_enabled('info')) { |
1b858d86 |
38 | error_box(_("Plugin is disabled.")); |
39 | // display footer (closes html) and stop script execution |
40 | $oTemplate->display('footer.tpl'); |
01c372f1 |
41 | exit; |
b11fe046 |
42 | } |
43 | |
6a85a764 |
44 | /* GLOBALS */ |
b587ac51 |
45 | sqgetGlobalVar('submit', $submit, SQ_POST); |
6a85a764 |
46 | |
47 | for($i = 0; $i <= 9; $i++){ |
b587ac51 |
48 | $varc = 'CHECK_TEST_'.$i; |
49 | sqgetGlobalVar($varc, $$varc, SQ_POST); |
50 | $vart = 'TEST_'.$i; |
51 | sqgetGlobalVar($vart, $$vart, SQ_POST); |
6a85a764 |
52 | } |
53 | |
54 | /* END GLOBALS */ |
55 | |
045ec1a1 |
56 | $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
a7b90f05 |
57 | $caps_array = get_caps($imap_stream); |
01c372f1 |
58 | $list = array ('TEST_0', |
a7b90f05 |
59 | 'TEST_1', |
60 | 'TEST_2', |
61 | 'TEST_3', |
62 | 'TEST_4', |
63 | 'TEST_5', |
64 | 'TEST_6', |
65 | 'TEST_7', |
66 | 'TEST_8', |
67 | 'TEST_9'); |
68 | |
f265009a |
69 | echo '<br /><div style="text-align: center;"><b>'._("IMAP server information")."</b></div><br />\n". |
dd0bbc43 |
70 | '<table bgcolor="'.$color[3].'" width="100%" align="center" border="1" cellpadding="2">'. |
01c372f1 |
71 | '<tr><td bgcolor="'.$color[3]."\"><br />\n". |
dd0bbc43 |
72 | '<table width="95%" align="center" border="1" bgcolor="'.$color[3]."\">\n". |
01c372f1 |
73 | '<tr><td bgcolor="'.$color[4].'"><b>'. |
74 | _("Server Capability response:"). |
75 | "</b><br />\n"; |
a7b90f05 |
76 | |
77 | foreach($caps_array[0] as $value) { |
01c372f1 |
78 | echo htmlspecialchars($value); |
a7b90f05 |
79 | } |
80 | |
01c372f1 |
81 | echo "</td></tr><tr><td>\n"; |
a7b90f05 |
82 | |
83 | if (!isset($submit) || $submit == 'default') { |
01c372f1 |
84 | echo '<br /><p><small><font color="'.$color[6].'">'. |
85 | _("Select the IMAP commands you would like to run. Most commands require a selected mailbox so the select command is already setup. You can clear all the commands and test your own IMAP command strings. The commands are executed in order. The default values are simple IMAP commands using your default_charset and folder_prefix from SquirrelMail when needed."). |
86 | "</font></small></p>\n". |
87 | '<p align="center"><small><b>'. |
88 | _("NOTE: These commands are live, any changes made will effect your current email account."). |
89 | "</b></small></p><br />\n"; |
a7b90f05 |
90 | if (!isset($submit)) { |
91 | $submit = ''; |
92 | } |
93 | } |
94 | else { |
01c372f1 |
95 | echo 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" . |
96 | 'default_charset = '.htmlspecialchars($default_charset)."\n"; |
a7b90f05 |
97 | } |
98 | |
dd0bbc43 |
99 | echo "<br /></td></tr></table><br />\n"; |
a7b90f05 |
100 | |
101 | |
102 | if ($submit == 'submit') { |
103 | $type = array(); |
104 | for ($i=0;$i<count($list);$i++) { |
105 | $type[$list[$i]] = $$list[$i]; |
106 | } |
107 | } |
108 | |
109 | elseif ($submit == 'clear') { |
110 | for ($i=0;$i<count($list);$i++) { |
111 | $type[$list[$i]] = ''; |
112 | } |
113 | } |
114 | |
115 | elseif (!$submit || $submit == 'default') { |
116 | $type = array ( |
117 | 'TEST_0' => "SELECT $mailbox", |
118 | 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)", |
119 | 'TEST_2' => "EXAMINE $mailbox", |
120 | 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *", |
121 | 'TEST_4' => "THREAD REFERENCES $default_charset ALL", |
122 | 'TEST_5' => "SORT (DATE) $default_charset ALL", |
123 | 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])", |
124 | 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"", |
3f6dd931 |
125 | 'TEST_8' => "LIST \"$folder_prefix\" \"*\"", |
a7b90f05 |
126 | 'TEST_9' => ""); |
127 | } |
128 | |
01c372f1 |
129 | echo "<form action=\"options.php\" method=\"post\">\n". |
dd0bbc43 |
130 | "<table border=\"1\" align=\"center\">\n". |
01c372f1 |
131 | '<tr><th>'. _("Select"). |
132 | '</th><th>'._("Test Name"). |
133 | '</th><th>'._("IMAP command string")."</th></tr>\n". |
134 | '<tr><td>'; |
a7b90f05 |
135 | |
136 | foreach($type as $index=>$value) { |
01c372f1 |
137 | echo "</td></tr>\n<tr><td width=\"10%\">\n<input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\""; |
a7b90f05 |
138 | if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) { |
01c372f1 |
139 | echo ' checked="checked"'; |
a7b90f05 |
140 | } |
141 | $check = "CHECK_".$index; |
142 | if (isset($$check) && $submit != 'clear' && $submit != 'default') { |
01c372f1 |
143 | echo ' checked="checked"'; |
a7b90f05 |
144 | } |
01c372f1 |
145 | echo " /></td><td width=\"30%\">$index</td><td width=\"60%\">\n". |
146 | addInput($index, $value, 60); |
a7b90f05 |
147 | } |
148 | |
dd0bbc43 |
149 | echo "</td></tr></table><br />\n". |
f265009a |
150 | '<div style="text-align: center;">'. |
01c372f1 |
151 | addSubmit('submit','submit'). |
dd0bbc43 |
152 | addSubmit('clear','submit',array('id'=>'clear')). |
153 | addSubmit('default','submit',array('id'=>'default')). |
f265009a |
154 | "</div><br /></form>\n"; |
a7b90f05 |
155 | |
156 | $tests = array(); |
157 | |
158 | if ($submit == 'submit') { |
159 | foreach ($type as $index=>$value) { |
160 | $check = "CHECK_".$index; |
161 | if (isset($$check)) { |
162 | $type[$index] = $$index; |
91e0dccc |
163 | array_push($tests, $index); |
a7b90f05 |
164 | } |
165 | } |
166 | for ($i=0;$i<count($tests);$i++) { |
3f6dd931 |
167 | // make sure that microtime function is available before it is called |
168 | if (function_exists('microtime')) { |
169 | list($usec, $sec) = explode(" ", microtime()); |
170 | $starttime = (float)$sec + (float)$usec; |
171 | } |
172 | |
dd0bbc43 |
173 | echo '<table width="95%" align="center" border="0" bgcolor="'.$color[4]."\">\n". |
01c372f1 |
174 | '<tr><td><b>'.$tests[$i]."</b></td></tr>\n". |
175 | '<tr><td><small><b><font color="'.$color[7].'">'. |
7431eca9 |
176 | _("Request:")."</font></b></small></td></tr>\n"; |
177 | // imap_test function outputs imap command |
178 | $response = imap_test($imap_stream, $type[$tests[$i]]); |
179 | echo '<tr><td><small><b><font color="'.$color[7].'">'. |
01c372f1 |
180 | _("Response:")."</font></b></small></td></tr>\n". |
181 | '<tr><td>'; |
a7b90f05 |
182 | print_response($response); |
3f6dd931 |
183 | echo "</td></tr>\n"; |
184 | |
185 | if (function_exists('microtime')) { |
186 | // get script execution time |
187 | list($usec, $sec) = explode(" ", microtime()); |
188 | $endtime = (float)$sec + (float)$usec; |
189 | // i18n: ms = short for miliseconds |
190 | echo '<tr><td><small><b><font color="'.$color[7].'">'. |
191 | _("Execution time:")."</font></b></small></td></tr>\n". |
192 | '<tr><td>'.sprintf(_("%s ms"),round((($endtime - $starttime)*1000),3))."</td></tr>\n"; |
193 | } |
194 | |
dd0bbc43 |
195 | echo "</table><br />\n"; |
a7b90f05 |
196 | } |
197 | } |
dd0bbc43 |
198 | echo '</td></tr></table>'; |
7431eca9 |
199 | sqimap_logout($imap_stream); |
b11fe046 |
200 | |
201 | /** |
202 | * Optional hook in info plugin |
203 | * |
204 | * Hook allows attaching plugin to bottom of info plugin |
205 | */ |
6e515418 |
206 | do_hook('info_bottom', $null); |
a7b90f05 |
207 | ?> |
2128bbc6 |
208 | </body></html> |