3 * options page for IMAP info plugin
5 * This is where it all happens :)
7 * @copyright (c) 1999-2004 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @author Jason Munro jason@stdbev.com
16 define('SM_PATH','../../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/page_header.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/forms.php');
23 require_once(SM_PATH
. 'plugins/info/functions.php');
25 global $username, $color, $folder_prefix, $default_charset;
26 $default_charset = strtoupper($default_charset);
27 displayPageHeader($color, 'None');
31 * testing installation
33 * prevent use of plugin if it is not enabled
35 if (! is_plugin_enabled('info')) {
36 echo "<p align=\"center\"><big>";
37 echo _("Plugin is disabled.");
38 echo "</big></p></body></html>";
43 sqgetGlobalVar('username', $username, SQ_SESSION
);
44 sqgetGlobalVar('key', $key, SQ_COOKIE
);
45 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
47 sqgetGlobalVar('submit', $submit, SQ_POST
);
49 for($i = 0; $i <= 9; $i++
){
50 $varc = 'CHECK_TEST_'.$i;
51 sqgetGlobalVar($varc, $
$varc, SQ_POST
);
53 sqgetGlobalVar($vart, $
$vart, SQ_POST
);
58 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
59 $caps_array = get_caps($imap_stream);
72 print "<br /><center><b>";
73 echo _("IMAP server information");
74 print "</b></center><br />\n";
75 print "<center><table bgcolor=\"".$color[3]."\" width=\"100%\" border=\"1\" cellpadding=\"2\">";
76 print "<tr><td bgcolor=\"".$color[3]."\"><br />\n";
77 print "<center><table width=\"95%\" border=\"1\" bgcolor=\"".$color[3]."\">\n";
78 print "<tr><td bgcolor=\"".$color[4]."\"><b>";
79 echo _("Server Capability response:");
82 foreach($caps_array[0] as $value) {
83 print htmlspecialchars($value);
86 print "</td></tr><tr><td>\n";
88 if (!isset($submit) ||
$submit == 'default') {
89 print "<br /><p><small><font color=\"".$color[6]."\">";
90 echo _("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.");
91 echo "</font></small></p>\n";
92 echo "<p align=\"center\"><small><b>";
93 echo _("NOTE: These commands are live, any changes made will effect your current email account.");
94 echo "</b></small></p><br />\n";
95 if (!isset($submit)) {
100 print 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
101 'default_charset = '.htmlspecialchars($default_charset)."\n";
104 print "<br /></td></tr></table></center><br />\n";
107 if ($submit == 'submit') {
109 for ($i=0;$i<count($list);$i++
) {
110 $type[$list[$i]] = $
$list[$i];
114 elseif ($submit == 'clear') {
115 for ($i=0;$i<count($list);$i++
) {
116 $type[$list[$i]] = '';
120 elseif (!$submit ||
$submit == 'default') {
122 'TEST_0' => "SELECT $mailbox",
123 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
124 'TEST_2' => "EXAMINE $mailbox",
125 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
126 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
127 'TEST_5' => "SORT (DATE) $default_charset ALL",
128 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
129 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
130 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
134 print "<form action=\"options.php\" method=\"post\">\n";
135 print "<center><table border=\"1\">\n";
136 echo "<tr><th>" . _("Select") .
137 "</th><th>" . _("Test Name") .
138 "</th><th>" . _("IMAP command string") . "</th></tr>\n";
141 foreach($type as $index=>$value) {
142 print "</td></tr>\n<tr><td width=\"10%\">\n<input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\"";
143 if ($index == 'TEST_0' && ($submit == 'default' ||
$submit == '')) {
146 $check = "CHECK_".$index;
147 if (isset($
$check) && $submit != 'clear' && $submit != 'default') {
150 print "></td><td width=\"30%\">$index</td><td width=\"60%\">\n";
151 print addInput($index, $value, 60);
154 print "</td></tr></table></center><br>\n";
156 addSubmit('submit','submit').
157 addSubmit('clear','submit').
158 addSubmit('default','submit').
159 "</center><br></form>\n";
163 if ($submit == 'submit') {
164 foreach ($type as $index=>$value) {
165 $check = "CHECK_".$index;
166 if (isset($
$check)) {
167 $type[$index] = $
$index;
168 array_push($tests, $index);
171 for ($i=0;$i<count($tests);$i++
) {
172 print "<center><table width=\"95%\" border=\"0\" bgcolor=\"".$color[4]."\">\n";
173 print "<tr><td><b>".$tests[$i]."</b></td></tr>\n";
174 print "<tr><td><small><b><font color=\"".$color[7]."\">";
175 echo _("Request:") . "</font></b></small></td></tr>\n";
176 $response = imap_test($imap_stream, $type[$tests[$i]]);
177 print "<tr><td><small><b><font color=\"".$color[7]."\">";
178 echo _("Response:") . "</font></b></small></td></tr>\n";
180 print_response($response);
181 print "</td></tr></table></center><br />\n";
184 print "</td></tr></table></center>";
185 sqimap_logout($imap_stream);
188 * Optional hook in info plugin
190 * Hook allows attaching plugin to bottom of info plugin
192 do_hook('info_bottom');