52718f891466103b0dbc32f3368262d72b761c27
4 * options page for IMAP info plugin
6 * This is where it all happens :)
8 * @author Jason Munro <jason at stdbev.com>
9 * @copyright 1999-2016 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
17 * Path for SquirrelMail required files.
20 require('../../include/init.php');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'functions/imap_general.php');
24 require_once(SM_PATH
. 'functions/forms.php');
25 require_once(SM_PATH
. 'plugins/info/functions.php');
27 global $username, $color, $folder_prefix, $default_charset;
28 $default_charset = strtoupper($default_charset);
29 displayPageHeader($color);
33 * testing installation
35 * prevent use of plugin if it is not enabled
37 if (! is_plugin_enabled('info')) {
38 error_box(_("Plugin is disabled."));
39 // display footer (closes html) and stop script execution
40 $oTemplate->display('footer.tpl');
45 sqgetGlobalVar('submit', $submit, SQ_POST
);
47 for($i = 0; $i <= 9; $i++
){
48 $varc = 'CHECK_TEST_'.$i;
49 sqgetGlobalVar($varc, $
$varc, SQ_POST
);
51 sqgetGlobalVar($vart, $
$vart, SQ_POST
);
56 global $imap_stream_options; // in case not defined in config
57 $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
58 $caps_array = get_caps($imap_stream);
59 $list = array ('TEST_0',
70 echo '<br /><div style="text-align: center;"><b>'._("IMAP server information")."</b></div><br />\n".
71 '<table bgcolor="'.$color[3].'" width="100%" align="center" border="1" cellpadding="2">'.
72 '<tr><td bgcolor="'.$color[3]."\"><br />\n".
73 '<table width="95%" align="center" border="1" bgcolor="'.$color[3]."\">\n".
74 '<tr><td bgcolor="'.$color[4].'"><b>'.
75 _("Server Capability response:").
78 foreach($caps_array[0] as $value) {
79 echo sm_encode_html_special_chars($value);
82 echo "</td></tr><tr><td>\n";
84 if (!isset($submit) ||
$submit == 'default') {
85 echo '<br /><p><small><font color="'.$color[6].'">'.
86 _("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.").
87 "</font></small></p>\n".
88 '<p align="center"><small><b>'.
89 _("NOTE: These commands are live, any changes made will effect your current email account.").
90 "</b></small></p><br />\n";
91 if (!isset($submit)) {
96 echo 'folder_prefix = ' . sm_encode_html_special_chars($folder_prefix)."<br />\n" .
97 'default_charset = '.sm_encode_html_special_chars($default_charset)."\n";
100 echo "<br /></td></tr></table><br />\n";
103 if ($submit == 'submit') {
105 for ($i=0;$i<count($list);$i++
) {
106 $type[$list[$i]] = $
$list[$i];
110 elseif ($submit == 'clear') {
111 for ($i=0;$i<count($list);$i++
) {
112 $type[$list[$i]] = '';
116 elseif (!$submit ||
$submit == 'default') {
118 'TEST_0' => "SELECT $mailbox",
119 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
120 'TEST_2' => "EXAMINE $mailbox",
121 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
122 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
123 'TEST_5' => "SORT (DATE) $default_charset ALL",
124 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
125 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
126 'TEST_8' => "LIST \"$folder_prefix\" \"*\"",
130 echo "<form action=\"options.php\" method=\"post\">\n".
131 "<table border=\"1\" align=\"center\">\n".
132 '<tr><th>'. _("Select").
133 '</th><th>'._("Test Name").
134 '</th><th>'._("IMAP command string")."</th></tr>\n".
137 foreach($type as $index=>$value) {
138 echo "</td></tr>\n<tr><td width=\"10%\">\n<input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\"";
139 if ($index == 'TEST_0' && ($submit == 'default' ||
$submit == '')) {
140 echo ' checked="checked"';
142 $check = "CHECK_".$index;
143 if (isset($
$check) && $submit != 'clear' && $submit != 'default') {
144 echo ' checked="checked"';
146 echo " /></td><td width=\"30%\">$index</td><td width=\"60%\">\n".
147 addInput($index, $value, 60);
150 echo "</td></tr></table><br />\n".
151 '<div style="text-align: center;">'.
152 addSubmit('submit','submit').
153 addSubmit('clear','submit',array('id'=>'clear')).
154 addSubmit('default','submit',array('id'=>'default')).
155 "</div><br /></form>\n";
159 if ($submit == 'submit') {
160 foreach ($type as $index=>$value) {
161 $check = "CHECK_".$index;
162 if (isset($
$check)) {
163 $type[$index] = $
$index;
164 array_push($tests, $index);
167 for ($i=0;$i<count($tests);$i++
) {
168 // make sure that microtime function is available before it is called
169 if (function_exists('microtime')) {
170 list($usec, $sec) = explode(" ", microtime());
171 $starttime = (float)$sec +
(float)$usec;
174 echo '<table width="95%" align="center" border="0" bgcolor="'.$color[4]."\">\n".
175 '<tr><td><b>'.$tests[$i]."</b></td></tr>\n".
176 '<tr><td><small><b><font color="'.$color[7].'">'.
177 _("Request:")."</font></b></small></td></tr>\n";
178 // imap_test function outputs imap command
179 $response = imap_test($imap_stream, $type[$tests[$i]]);
180 echo '<tr><td><small><b><font color="'.$color[7].'">'.
181 _("Response:")."</font></b></small></td></tr>\n".
183 print_response($response);
186 if (function_exists('microtime')) {
187 // get script execution time
188 list($usec, $sec) = explode(" ", microtime());
189 $endtime = (float)$sec +
(float)$usec;
190 // i18n: ms = short for miliseconds
191 echo '<tr><td><small><b><font color="'.$color[7].'">'.
192 _("Execution time:")."</font></b></small></td></tr>\n".
193 '<tr><td>'.sprintf(_("%s ms"),round((($endtime - $starttime)*1000),3))."</td></tr>\n";
196 echo "</table><br />\n";
199 echo '</td></tr></table>';
200 sqimap_logout($imap_stream);
203 * Optional hook in info plugin
205 * Hook allows attaching plugin to bottom of info plugin
207 do_hook('info_bottom', $null);