cleanup some plugins to make use of sqgetGlobalVar
[squirrelmail.git] / plugins / info / options.php
CommitLineData
a7b90f05 1<?PHP
2
3/* options page for IMAP info plugin
76911253 4 * Copyright (c) 1999-2003 The SquirrelMail Project Team
a7b90f05 5 * Licensed under the GNU GPL. For full terms see the file COPYING.
6 *
7 * This is where it all happens :)
8 *
9 * Written by: Jason Munro
10 * jason@stdbev.com
6a85a764 11 *
12 * $Id$
13 *
a7b90f05 14 */
8d6a115b 15
16define('SM_PATH','../../');
a7b90f05 17
cdf82d4a 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 . 'plugins/info/functions.php');
a7b90f05 23
24global $username, $color, $folder_prefix, $default_charset;
25$default_charset = strtoupper($default_charset);
26displayPageHeader($color, 'None');
27$mailbox = 'INBOX';
6a85a764 28
29/* GLOBALS */
b587ac51 30sqgetGlobalVar('username', $username, SQ_SESSION);
31sqgetGlobalVar('key', $key, SQ_COOKIE);
32sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
6a85a764 33
b587ac51 34sqgetGlobalVar('submit', $submit, SQ_POST);
6a85a764 35
36for($i = 0; $i <= 9; $i++){
b587ac51 37 $varc = 'CHECK_TEST_'.$i;
38 sqgetGlobalVar($varc, $$varc, SQ_POST);
39 $vart = 'TEST_'.$i;
40 sqgetGlobalVar($vart, $$vart, SQ_POST);
6a85a764 41}
42
43/* END GLOBALS */
44
a7b90f05 45$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
46$caps_array = get_caps($imap_stream);
47$list = array (
48 'TEST_0',
49 'TEST_1',
50 'TEST_2',
51 'TEST_3',
52 'TEST_4',
53 'TEST_5',
54 'TEST_6',
55 'TEST_7',
56 'TEST_8',
57 'TEST_9');
58
59print "<BR><CENTER><B>IMAP server information</B></CENTER><BR>\n";
60print "<CENTER><TABLE BGCOLOR=".$color[3]." WIDTH=\"100%\" BORDER=1 CELLPADDING=2><TR><TD BGCOLOR=".$color[3]."><BR>\n";
61print "<CENTER><TABLE WIDTH=\"95%\" BORDER=1 BGCOLOR=".$color[3].">\n";
62print "<TR><TD BGCOLOR=".$color[4]."><B>Server Capability response:</B><BR>\n";
63
64foreach($caps_array[0] as $value) {
65 print $value;
66}
67
68print "</TD></TR><TR><TD>\n";
69
70if (!isset($submit) || $submit == 'default') {
71 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";
72 if (!isset($submit)) {
73 $submit = '';
74 }
75}
76else {
77 print "folder_prefix = $folder_prefix<BR>\n";
78 print "default_charset = $default_charset\n";
79}
80
81print "<BR></TD></TR></TABLE></CENTER><BR>\n";
82
83
84if ($submit == 'submit') {
85 $type = array();
86 for ($i=0;$i<count($list);$i++) {
87 $type[$list[$i]] = $$list[$i];
88 }
89}
90
91elseif ($submit == 'clear') {
92 for ($i=0;$i<count($list);$i++) {
93 $type[$list[$i]] = '';
94 }
95}
96
97elseif (!$submit || $submit == 'default') {
98 $type = array (
99 'TEST_0' => "SELECT $mailbox",
100 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
101 'TEST_2' => "EXAMINE $mailbox",
102 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
103 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
104 'TEST_5' => "SORT (DATE) $default_charset ALL",
105 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
106 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
107 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
108 'TEST_9' => "");
109}
110
111print "<FORM ACTION=\"options.php\" METHOD=POST>\n";
112print "<CENTER><TABLE BORDER=1>\n";
113print "<TR><TH>Select</TH><TH>Test Name</TH><TH>IMAP command string</TH>\n";
114print "</TR><TR><TD>\n";
115
116foreach($type as $index=>$value) {
117 print "</TD></TR><TR><TD WIDTH=\"10%\"><INPUT TYPE=CHECKBOX VALUE=1 NAME=CHECK_$index";
118 if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
119 print " CHECKED";
120 }
121 $check = "CHECK_".$index;
122 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
123 print " CHECKED";
124 }
125 print "></TD><TD WIDTH=\"30%\">$index</TD><TD WIDTH=\"60%\">\n";
126 print "<INPUT TYPE=TEXT NAME=$index VALUE='$value' SIZE=60>\n";
127}
128
129print "</TD></TR></TABLE></CENTER><BR>\n";
130print "<CENTER><INPUT TYPE=SUBMIT NAME=submit value=submit>\n";
131print "<INPUT TYPE=SUBMIT NAME=submit value=clear>\n";
132print "<INPUT TYPE=SUBMIT NAME=submit value=default></CENTER><BR>\n";
133
134$tests = array();
135
136if ($submit == 'submit') {
137 foreach ($type as $index=>$value) {
138 $check = "CHECK_".$index;
139 if (isset($$check)) {
140 $type[$index] = $$index;
141 array_push($tests, $index);
142 }
143 }
144 for ($i=0;$i<count($tests);$i++) {
145 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=0 BGCOLOR=".$color[4].">\n";
146 print "<TR><TD><B>".$tests[$i]."</B></TD><TR>";
147 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
148 ">Request:</FONT></SMALL></B></TD></TR>\n";
149 $response = imap_test($imap_stream, $type[$tests[$i]]);
150 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
151 ">Response:</FONT></SMALL></B></TD></TR>\n";
152 print "<TR><TD>";
153 print_response($response);
154 print "</TD><TR></TABLE></CENTER><BR>\n";
155 }
156}
157 print "</TD></TR></TABLE></CENTER></BODY></HTML>";
158 sqimap_logout($imap_stream);
159 do_hook('info_bottom');
160?>