Multiple URLs on one line weren't getting parsed correctly
[squirrelmail.git] / plugins / info / options.php
... / ...
CommitLineData
1<?PHP
2/**
3 * options page for IMAP info plugin
4 *
5 * This is where it all happens :)
6 *
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
11 * @package plugins
12 * @subpackage info
13 */
14
15/** @ignore */
16define('SM_PATH','../../');
17
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');
22require_once(SM_PATH . 'functions/forms.php');
23require_once(SM_PATH . 'plugins/info/functions.php');
24
25global $username, $color, $folder_prefix, $default_charset;
26$default_charset = strtoupper($default_charset);
27displayPageHeader($color, 'None');
28$mailbox = 'INBOX';
29
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
42/* GLOBALS */
43sqgetGlobalVar('username', $username, SQ_SESSION);
44sqgetGlobalVar('key', $key, SQ_COOKIE);
45sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
46
47sqgetGlobalVar('submit', $submit, SQ_POST);
48
49for($i = 0; $i <= 9; $i++){
50 $varc = 'CHECK_TEST_'.$i;
51 sqgetGlobalVar($varc, $$varc, SQ_POST);
52 $vart = 'TEST_'.$i;
53 sqgetGlobalVar($vart, $$vart, SQ_POST);
54}
55
56/* END GLOBALS */
57
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
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";
81
82foreach($caps_array[0] as $value) {
83 print htmlspecialchars($value);
84}
85
86print "</td></tr><tr><td>\n";
87
88if (!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)) {
96 $submit = '';
97 }
98}
99else {
100 print 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
101 'default_charset = '.htmlspecialchars($default_charset)."\n";
102}
103
104print "<br /></td></tr></table></center><br />\n";
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
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>";
140
141foreach($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 == '')) {
144 print " checked";
145 }
146 $check = "CHECK_".$index;
147 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
148 print " checked";
149 }
150 print "></td><td width=\"30%\">$index</td><td width=\"60%\">\n";
151 print addInput($index, $value, 60);
152}
153
154print "</td></tr></table></center><br>\n";
155print "<center>".
156 addSubmit('submit','submit').
157 addSubmit('clear','submit').
158 addSubmit('default','submit').
159 "</center><br></form>\n";
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++) {
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";
179 print "<tr><td>";
180 print_response($response);
181 print "</td></tr></table></center><br />\n";
182 }
183}
184 print "</td></tr></table></center>";
185 sqimap_logout($imap_stream);
186
187/**
188 * Optional hook in info plugin
189 *
190 * Hook allows attaching plugin to bottom of info plugin
191 */
192do_hook('info_bottom');
193?>
194</body></html>