String fix
[squirrelmail.git] / plugins / info / options.php
1 <?php
2 /**
3 * options page for IMAP info plugin
4 *
5 * This is where it all happens :)
6 *
7 * @copyright (c) 1999-2005 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 */
16 define('SM_PATH','../../');
17
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');
24
25 global $username, $color, $folder_prefix, $default_charset;
26 $default_charset = strtoupper($default_charset);
27 displayPageHeader($color, 'None');
28 $mailbox = 'INBOX';
29
30 /**
31 * testing installation
32 *
33 * prevent use of plugin if it is not enabled
34 */
35 if (! is_plugin_enabled('info')) {
36 error_box(_("Plugin is disabled."),$color);
37 echo '</body></html>';
38 exit;
39 }
40
41 /* GLOBALS */
42 sqgetGlobalVar('username', $username, SQ_SESSION);
43 sqgetGlobalVar('key', $key, SQ_COOKIE);
44 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
45
46 sqgetGlobalVar('submit', $submit, SQ_POST);
47
48 for($i = 0; $i <= 9; $i++){
49 $varc = 'CHECK_TEST_'.$i;
50 sqgetGlobalVar($varc, $$varc, SQ_POST);
51 $vart = 'TEST_'.$i;
52 sqgetGlobalVar($vart, $$vart, SQ_POST);
53 }
54
55 /* END GLOBALS */
56
57 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
58 $caps_array = get_caps($imap_stream);
59 $list = array ('TEST_0',
60 'TEST_1',
61 'TEST_2',
62 'TEST_3',
63 'TEST_4',
64 'TEST_5',
65 'TEST_6',
66 'TEST_7',
67 'TEST_8',
68 'TEST_9');
69
70 echo '<br /><center><b>'._("IMAP server information")."</b></center><br />\n".
71 '<center><table bgcolor="'.$color[3].'" width="100%" border="1" cellpadding="2">'.
72 '<tr><td bgcolor="'.$color[3]."\"><br />\n".
73 '<center><table width="95%" border="1" bgcolor="'.$color[3]."\">\n".
74 '<tr><td bgcolor="'.$color[4].'"><b>'.
75 _("Server Capability response:").
76 "</b><br />\n";
77
78 foreach($caps_array[0] as $value) {
79 echo htmlspecialchars($value);
80 }
81
82 echo "</td></tr><tr><td>\n";
83
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)) {
92 $submit = '';
93 }
94 }
95 else {
96 echo 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
97 'default_charset = '.htmlspecialchars($default_charset)."\n";
98 }
99
100 echo "<br /></td></tr></table></center><br />\n";
101
102
103 if ($submit == 'submit') {
104 $type = array();
105 for ($i=0;$i<count($list);$i++) {
106 $type[$list[$i]] = $$list[$i];
107 }
108 }
109
110 elseif ($submit == 'clear') {
111 for ($i=0;$i<count($list);$i++) {
112 $type[$list[$i]] = '';
113 }
114 }
115
116 elseif (!$submit || $submit == 'default') {
117 $type = array (
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*\" \"*\"",
127 'TEST_9' => "");
128 }
129
130 echo "<form action=\"options.php\" method=\"post\">\n".
131 "<center><table border=\"1\">\n".
132 '<tr><th>'. _("Select").
133 '</th><th>'._("Test Name").
134 '</th><th>'._("IMAP command string")."</th></tr>\n".
135 '<tr><td>';
136
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"';
141 }
142 $check = "CHECK_".$index;
143 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
144 echo ' checked="checked"';
145 }
146 echo " /></td><td width=\"30%\">$index</td><td width=\"60%\">\n".
147 addInput($index, $value, 60);
148 }
149
150 echo "</td></tr></table></center><br />\n".
151 '<center>'.
152 addSubmit('submit','submit').
153 addSubmit('clear','submit').
154 addSubmit('default','submit').
155 "</center><br /></form>\n";
156
157 $tests = array();
158
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);
165 }
166 }
167 for ($i=0;$i<count($tests);$i++) {
168 echo '<center><table width="95%" border="0" bgcolor="'.$color[4]."\">\n".
169 '<tr><td><b>'.$tests[$i]."</b></td></tr>\n".
170 '<tr><td><small><b><font color="'.$color[7].'">'.
171 _("Request:")."</font></b></small></td></tr>\n";
172 // imap_test function outputs imap command
173 $response = imap_test($imap_stream, $type[$tests[$i]]);
174 echo '<tr><td><small><b><font color="'.$color[7].'">'.
175 _("Response:")."</font></b></small></td></tr>\n".
176 '<tr><td>';
177 print_response($response);
178 echo "</td></tr></table></center><br />\n";
179 }
180 }
181 echo '</td></tr></table></center>';
182 sqimap_logout($imap_stream);
183
184 /**
185 * Optional hook in info plugin
186 *
187 * Hook allows attaching plugin to bottom of info plugin
188 */
189 do_hook('info_bottom');
190 ?>
191 </body></html>