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 . 'plugins/info/functions.php');
26
27 global $username, $color, $folder_prefix, $default_charset;
28 $default_charset = strtoupper($default_charset);
29 displayPageHeader($color, 'None');
30 $mailbox = 'INBOX';
31
32 /* GLOBALS */
33 sqgetGlobalVar('username', $username, SQ_SESSION);
34 sqgetGlobalVar('key', $key, SQ_COOKIE);
35 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
36
37 sqgetGlobalVar('submit', $submit, SQ_POST);
38
39 for($i = 0; $i <= 9; $i++){
40 $varc = 'CHECK_TEST_'.$i;
41 sqgetGlobalVar($varc, $$varc, SQ_POST);
42 $vart = 'TEST_'.$i;
43 sqgetGlobalVar($vart, $$vart, SQ_POST);
44 }
45
46 /* END GLOBALS */
47
48 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
49 $caps_array = get_caps($imap_stream);
50 $list = array (
51 'TEST_0',
52 'TEST_1',
53 'TEST_2',
54 'TEST_3',
55 'TEST_4',
56 'TEST_5',
57 'TEST_6',
58 'TEST_7',
59 'TEST_8',
60 'TEST_9');
61
62 print "<BR><CENTER><B>IMAP server information</B></CENTER><BR>\n";
63 print "<CENTER><TABLE BGCOLOR=".$color[3]." WIDTH=\"100%\" BORDER=1 CELLPADDING=2><TR><TD BGCOLOR=".$color[3]."><BR>\n";
64 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=1 BGCOLOR=".$color[3].">\n";
65 print "<TR><TD BGCOLOR=".$color[4]."><B>Server Capability response:</B><BR>\n";
66
67 foreach($caps_array[0] as $value) {
68 print $value;
69 }
70
71 print "</TD></TR><TR><TD>\n";
72
73 if (!isset($submit) || $submit == 'default') {
74 print "<BR><SMALL><FONT COLOR=".$color[6].">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.<BR><BR><B><CENTER>NOTE: These commands are live, any changes made will effect your current email account.</B></CENTER></FONT></SMALL><BR>\n";
75 if (!isset($submit)) {
76 $submit = '';
77 }
78 }
79 else {
80 print "folder_prefix = $folder_prefix<BR>\n";
81 print "default_charset = $default_charset\n";
82 }
83
84 print "<BR></TD></TR></TABLE></CENTER><BR>\n";
85
86
87 if ($submit == 'submit') {
88 $type = array();
89 for ($i=0;$i<count($list);$i++) {
90 $type[$list[$i]] = $$list[$i];
91 }
92 }
93
94 elseif ($submit == 'clear') {
95 for ($i=0;$i<count($list);$i++) {
96 $type[$list[$i]] = '';
97 }
98 }
99
100 elseif (!$submit || $submit == 'default') {
101 $type = array (
102 'TEST_0' => "SELECT $mailbox",
103 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
104 'TEST_2' => "EXAMINE $mailbox",
105 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
106 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
107 'TEST_5' => "SORT (DATE) $default_charset ALL",
108 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
109 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
110 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
111 'TEST_9' => "");
112 }
113
114 print "<FORM ACTION=\"options.php\" METHOD=POST>\n";
115 print "<CENTER><TABLE BORDER=1>\n";
116 print "<TR><TH>Select</TH><TH>Test Name</TH><TH>IMAP command string</TH>\n";
117 print "</TR><TR><TD>\n";
118
119 foreach($type as $index=>$value) {
120 print "</TD></TR><TR><TD WIDTH=\"10%\"><INPUT TYPE=CHECKBOX VALUE=1 NAME=CHECK_$index";
121 if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
122 print " CHECKED";
123 }
124 $check = "CHECK_".$index;
125 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
126 print " CHECKED";
127 }
128 print "></TD><TD WIDTH=\"30%\">$index</TD><TD WIDTH=\"60%\">\n";
129 print "<INPUT TYPE=TEXT NAME=$index VALUE='$value' SIZE=60>\n";
130 }
131
132 print "</TD></TR></TABLE></CENTER><BR>\n";
133 print "<CENTER><INPUT TYPE=SUBMIT NAME=submit value=submit>\n";
134 print "<INPUT TYPE=SUBMIT NAME=submit value=clear>\n";
135 print "<INPUT TYPE=SUBMIT NAME=submit value=default></CENTER><BR>\n";
136
137 $tests = array();
138
139 if ($submit == 'submit') {
140 foreach ($type as $index=>$value) {
141 $check = "CHECK_".$index;
142 if (isset($$check)) {
143 $type[$index] = $$index;
144 array_push($tests, $index);
145 }
146 }
147 for ($i=0;$i<count($tests);$i++) {
148 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=0 BGCOLOR=".$color[4].">\n";
149 print "<TR><TD><B>".$tests[$i]."</B></TD><TR>";
150 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
151 ">Request:</FONT></SMALL></B></TD></TR>\n";
152 $response = imap_test($imap_stream, $type[$tests[$i]]);
153 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
154 ">Response:</FONT></SMALL></B></TD></TR>\n";
155 print "<TR><TD>";
156 print_response($response);
157 print "</TD><TR></TABLE></CENTER><BR>\n";
158 }
159 }
160 print "</TD></TR></TABLE></CENTER></BODY></HTML>";
161 sqimap_logout($imap_stream);
162 do_hook('info_bottom');
163 ?>