Multiple URLs on one line weren't getting parsed correctly
[squirrelmail.git] / plugins / info / options.php
CommitLineData
a7b90f05 1<?PHP
ea5f4b8e 2/**
3 * options page for IMAP info plugin
b11fe046 4 *
a7b90f05 5 * This is where it all happens :)
6a85a764 6 *
b11fe046 7 * @copyright (c) 1999-2004 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * @version $Id$
10 * @author Jason Munro jason@stdbev.com
ea5f4b8e 11 * @package plugins
12 * @subpackage info
a7b90f05 13 */
8d6a115b 14
ea5f4b8e 15/** @ignore */
8d6a115b 16define('SM_PATH','../../');
a7b90f05 17
cdf82d4a 18/* SquirrelMail required files. */
19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/page_header.php');
21require_once(SM_PATH . 'functions/imap.php');
a9e1e670 22require_once(SM_PATH . 'functions/forms.php');
cdf82d4a 23require_once(SM_PATH . 'plugins/info/functions.php');
a7b90f05 24
25global $username, $color, $folder_prefix, $default_charset;
26$default_charset = strtoupper($default_charset);
27displayPageHeader($color, 'None');
28$mailbox = 'INBOX';
6a85a764 29
b11fe046 30/**
31 * testing installation
32 *
33 * prevent use of plugin if it is not enabled
34 */
35if (! is_plugin_enabled('info')) {
36 echo "<p align=\"center\"><big>";
37 echo _("Plugin is disabled.");
38 echo "</big></p></body></html>";
39 exit;
40}
41
6a85a764 42/* GLOBALS */
b11fe046 43sqgetGlobalVar('username', $username, SQ_SESSION);
44sqgetGlobalVar('key', $key, SQ_COOKIE);
45sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
6a85a764 46
b587ac51 47sqgetGlobalVar('submit', $submit, SQ_POST);
6a85a764 48
49for($i = 0; $i <= 9; $i++){
b587ac51 50 $varc = 'CHECK_TEST_'.$i;
51 sqgetGlobalVar($varc, $$varc, SQ_POST);
52 $vart = 'TEST_'.$i;
53 sqgetGlobalVar($vart, $$vart, SQ_POST);
6a85a764 54}
55
56/* END GLOBALS */
57
a7b90f05 58$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
59$caps_array = get_caps($imap_stream);
60$list = array (
61 'TEST_0',
62 'TEST_1',
63 'TEST_2',
64 'TEST_3',
65 'TEST_4',
66 'TEST_5',
67 'TEST_6',
68 'TEST_7',
69 'TEST_8',
70 'TEST_9');
71
b11fe046 72print "<br /><center><b>";
73echo _("IMAP server information");
74print "</b></center><br />\n";
75print "<center><table bgcolor=\"".$color[3]."\" width=\"100%\" border=\"1\" cellpadding=\"2\">";
76print "<tr><td bgcolor=\"".$color[3]."\"><br />\n";
77print "<center><table width=\"95%\" border=\"1\" bgcolor=\"".$color[3]."\">\n";
78print "<tr><td bgcolor=\"".$color[4]."\"><b>";
79echo _("Server Capability response:");
80print "</b><br />\n";
a7b90f05 81
82foreach($caps_array[0] as $value) {
a9e1e670 83 print htmlspecialchars($value);
a7b90f05 84}
85
b11fe046 86print "</td></tr><tr><td>\n";
a7b90f05 87
88if (!isset($submit) || $submit == 'default') {
b11fe046 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";
a7b90f05 95 if (!isset($submit)) {
96 $submit = '';
97 }
98}
99else {
a9e1e670 100 print 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
101 'default_charset = '.htmlspecialchars($default_charset)."\n";
a7b90f05 102}
103
a9e1e670 104print "<br /></td></tr></table></center><br />\n";
a7b90f05 105
106
107if ($submit == 'submit') {
108 $type = array();
109 for ($i=0;$i<count($list);$i++) {
110 $type[$list[$i]] = $$list[$i];
111 }
112}
113
114elseif ($submit == 'clear') {
115 for ($i=0;$i<count($list);$i++) {
116 $type[$list[$i]] = '';
117 }
118}
119
120elseif (!$submit || $submit == 'default') {
121 $type = array (
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*\" \"*\"",
131 'TEST_9' => "");
132}
133
b11fe046 134print "<form action=\"options.php\" method=\"post\">\n";
135print "<center><table border=\"1\">\n";
136echo "<tr><th>" . _("Select") .
137 "</th><th>" . _("Test Name") .
138 "</th><th>" . _("IMAP command string") . "</th></tr>\n";
139print "<tr><td>";
a7b90f05 140
141foreach($type as $index=>$value) {
b11fe046 142 print "</td></tr>\n<tr><td width=\"10%\">\n<input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\"";
a7b90f05 143 if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
b11fe046 144 print " checked";
a7b90f05 145 }
146 $check = "CHECK_".$index;
147 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
b11fe046 148 print " checked";
a7b90f05 149 }
b11fe046 150 print "></td><td width=\"30%\">$index</td><td width=\"60%\">\n";
a9e1e670 151 print addInput($index, $value, 60);
a7b90f05 152}
153
a9e1e670 154print "</td></tr></table></center><br>\n";
155print "<center>".
156 addSubmit('submit','submit').
157 addSubmit('clear','submit').
158 addSubmit('default','submit').
b11fe046 159 "</center><br></form>\n";
a7b90f05 160
161$tests = array();
162
163if ($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);
169 }
170 }
171 for ($i=0;$i<count($tests);$i++) {
b11fe046 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";
a7b90f05 176 $response = imap_test($imap_stream, $type[$tests[$i]]);
b11fe046 177 print "<tr><td><small><b><font color=\"".$color[7]."\">";
178 echo _("Response:") . "</font></b></small></td></tr>\n";
179 print "<tr><td>";
a7b90f05 180 print_response($response);
b11fe046 181 print "</td></tr></table></center><br />\n";
a7b90f05 182 }
183}
b11fe046 184 print "</td></tr></table></center>";
a7b90f05 185 sqimap_logout($imap_stream);
b11fe046 186
187/**
188 * Optional hook in info plugin
189 *
190 * Hook allows attaching plugin to bottom of info plugin
191 */
192do_hook('info_bottom');
a7b90f05 193?>
b11fe046 194</body></html>