Improve HTML escaping
[squirrelmail.git] / plugins / info / options.php
1 <?PHP
2
3 /**
4 * options page for IMAP info plugin
5 * Copyright (c) 1999-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This is where it all happens :)
9 *
10 * Written by: Jason Munro
11 * jason@stdbev.com
12 *
13 * $Id$
14 * @package plugins
15 * @subpackage info
16 */
17
18 /** @ignore */
19 define('SM_PATH','../../');
20
21 /* SquirrelMail required files. */
22 require_once(SM_PATH . 'include/validate.php');
23 require_once(SM_PATH . 'functions/page_header.php');
24 require_once(SM_PATH . 'functions/imap.php');
25 require_once(SM_PATH . 'functions/forms.php');
26 require_once(SM_PATH . 'plugins/info/functions.php');
27
28 global $username, $color, $folder_prefix, $default_charset;
29 $default_charset = strtoupper($default_charset);
30 displayPageHeader($color, 'None');
31 $mailbox = 'INBOX';
32
33 /* GLOBALS */
34 sqgetGlobalVar('username', $username, SQ_SESSION);
35 sqgetGlobalVar('key', $key, SQ_COOKIE);
36 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
37
38 sqgetGlobalVar('submit', $submit, SQ_POST);
39
40 for($i = 0; $i <= 9; $i++){
41 $varc = 'CHECK_TEST_'.$i;
42 sqgetGlobalVar($varc, $$varc, SQ_POST);
43 $vart = 'TEST_'.$i;
44 sqgetGlobalVar($vart, $$vart, SQ_POST);
45 }
46
47 /* END GLOBALS */
48
49 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
50 $caps_array = get_caps($imap_stream);
51 $list = array (
52 'TEST_0',
53 'TEST_1',
54 'TEST_2',
55 'TEST_3',
56 'TEST_4',
57 'TEST_5',
58 'TEST_6',
59 'TEST_7',
60 'TEST_8',
61 'TEST_9');
62
63 print "<BR><CENTER><B>IMAP server information</B></CENTER><BR>\n";
64 print "<CENTER><TABLE BGCOLOR=".$color[3]." WIDTH=\"100%\" BORDER=1 CELLPADDING=2><TR><TD BGCOLOR=".$color[3]."><BR>\n";
65 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=1 BGCOLOR=".$color[3].">\n";
66 print "<TR><TD BGCOLOR=".$color[4]."><B>Server Capability response:</B><BR>\n";
67
68 foreach($caps_array[0] as $value) {
69 print htmlspecialchars($value);
70 }
71
72 print "</TD></TR><TR><TD>\n";
73
74 if (!isset($submit) || $submit == 'default') {
75 print "<br><small><font color=".$color[6].">Select the IMAP commands you would like to run.
76 Most commands require a selected mailbox so the select command is already setup.
77 You can clear all the commands and test your own IMAP command strings. The commands are
78 executed in order. The default values are simple IMAP commands using your default_charset
79 and folder_prefix from SquirrelMail when needed.<br><br>
80 <b><center>NOTE: These commands are live, any changes made will effect your current
81 email account.</b></center></font></small><br>\n";
82 if (!isset($submit)) {
83 $submit = '';
84 }
85 }
86 else {
87 print 'folder_prefix = ' . htmlspecialchars($folder_prefix)."<br />\n" .
88 'default_charset = '.htmlspecialchars($default_charset)."\n";
89 }
90
91 print "<br /></td></tr></table></center><br />\n";
92
93
94 if ($submit == 'submit') {
95 $type = array();
96 for ($i=0;$i<count($list);$i++) {
97 $type[$list[$i]] = $$list[$i];
98 }
99 }
100
101 elseif ($submit == 'clear') {
102 for ($i=0;$i<count($list);$i++) {
103 $type[$list[$i]] = '';
104 }
105 }
106
107 elseif (!$submit || $submit == 'default') {
108 $type = array (
109 'TEST_0' => "SELECT $mailbox",
110 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
111 'TEST_2' => "EXAMINE $mailbox",
112 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
113 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
114 'TEST_5' => "SORT (DATE) $default_charset ALL",
115 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
116 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
117 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
118 'TEST_9' => "");
119 }
120
121 print "<FORM ACTION=\"options.php\" METHOD=POST>\n";
122 print "<CENTER><TABLE BORDER=1>\n";
123 print "<TR><TH>Select</TH><TH>Test Name</TH><TH>IMAP command string</TH>\n";
124 print "</TR><TR><TD>\n";
125
126 foreach($type as $index=>$value) {
127 print "</TD></TR><TR><TD WIDTH=\"10%\"><INPUT TYPE=CHECKBOX VALUE=1 NAME=CHECK_$index";
128 if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
129 print " CHECKED";
130 }
131 $check = "CHECK_".$index;
132 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
133 print " CHECKED";
134 }
135 print "></TD><TD WIDTH=\"30%\">$index</TD><TD WIDTH=\"60%\">\n";
136 print addInput($index, $value, 60);
137 }
138
139 print "</td></tr></table></center><br>\n";
140 print "<center>".
141 addSubmit('submit','submit').
142 addSubmit('clear','submit').
143 addSubmit('default','submit').
144 "</center><br>\n";
145
146 $tests = array();
147
148 if ($submit == 'submit') {
149 foreach ($type as $index=>$value) {
150 $check = "CHECK_".$index;
151 if (isset($$check)) {
152 $type[$index] = $$index;
153 array_push($tests, $index);
154 }
155 }
156 for ($i=0;$i<count($tests);$i++) {
157 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=0 BGCOLOR=".$color[4].">\n";
158 print "<TR><TD><B>".$tests[$i]."</B></TD><TR>";
159 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
160 ">Request:</FONT></SMALL></B></TD></TR>\n";
161 $response = imap_test($imap_stream, $type[$tests[$i]]);
162 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
163 ">Response:</FONT></SMALL></B></TD></TR>\n";
164 print "<TR><TD>";
165 print_response($response);
166 print "</TD><TR></TABLE></CENTER><BR>\n";
167 }
168 }
169 print "</TD></TR></TABLE></CENTER></BODY></HTML>";
170 sqimap_logout($imap_stream);
171 do_hook('info_bottom');
172 ?>