added index.php in order to prevent indexing of directory.
[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-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 */
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 echo "<p align=\"center\"><big>";
37 echo _("Plugin is disabled.");
38 echo "</big></p></body></html>";
39 exit;
40 }
41
42 /* GLOBALS */
43 sqgetGlobalVar('username', $username, SQ_SESSION);
44 sqgetGlobalVar('key', $key, SQ_COOKIE);
45 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
46
47 sqgetGlobalVar('submit', $submit, SQ_POST);
48
49 for($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
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:");
80 print "</b><br />\n";
81
82 foreach($caps_array[0] as $value) {
83 print htmlspecialchars($value);
84 }
85
86 print "</td></tr><tr><td>\n";
87
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)) {
96 $submit = '';
97 }
98 }
99 else {
100 print 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
101 'default_charset = '.htmlspecialchars($default_charset)."\n";
102 }
103
104 print "<br /></td></tr></table></center><br />\n";
105
106
107 if ($submit == 'submit') {
108 $type = array();
109 for ($i=0;$i<count($list);$i++) {
110 $type[$list[$i]] = $$list[$i];
111 }
112 }
113
114 elseif ($submit == 'clear') {
115 for ($i=0;$i<count($list);$i++) {
116 $type[$list[$i]] = '';
117 }
118 }
119
120 elseif (!$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
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";
139 print "<tr><td>";
140
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 == '')) {
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
154 print "</td></tr></table></center><br>\n";
155 print "<center>".
156 addSubmit('submit','submit').
157 addSubmit('clear','submit').
158 addSubmit('default','submit').
159 "</center><br></form>\n";
160
161 $tests = array();
162
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);
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 */
192 do_hook('info_bottom');
193 ?>
194 </body></html>