Keep on going... rg=0
[squirrelmail.git] / plugins / info / options.php
CommitLineData
a7b90f05 1<?PHP
2
3/* options page for IMAP info plugin
4 * Copyright (c) 1999-2002 The SquirrelMail Project Team
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
11 */
8d6a115b 12
13define('SM_PATH','../../');
a7b90f05 14
cdf82d4a 15/* SquirrelMail required files. */
16require_once(SM_PATH . 'include/validate.php');
17require_once(SM_PATH . 'functions/page_header.php');
18require_once(SM_PATH . 'functions/imap.php');
19require_once(SM_PATH . 'plugins/info/functions.php');
a7b90f05 20
21global $username, $color, $folder_prefix, $default_charset;
22$default_charset = strtoupper($default_charset);
23displayPageHeader($color, 'None');
24$mailbox = 'INBOX';
25$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
26$caps_array = get_caps($imap_stream);
27$list = array (
28 'TEST_0',
29 'TEST_1',
30 'TEST_2',
31 'TEST_3',
32 'TEST_4',
33 'TEST_5',
34 'TEST_6',
35 'TEST_7',
36 'TEST_8',
37 'TEST_9');
38
39print "<BR><CENTER><B>IMAP server information</B></CENTER><BR>\n";
40print "<CENTER><TABLE BGCOLOR=".$color[3]." WIDTH=\"100%\" BORDER=1 CELLPADDING=2><TR><TD BGCOLOR=".$color[3]."><BR>\n";
41print "<CENTER><TABLE WIDTH=\"95%\" BORDER=1 BGCOLOR=".$color[3].">\n";
42print "<TR><TD BGCOLOR=".$color[4]."><B>Server Capability response:</B><BR>\n";
43
44foreach($caps_array[0] as $value) {
45 print $value;
46}
47
48print "</TD></TR><TR><TD>\n";
49
50if (!isset($submit) || $submit == 'default') {
51 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";
52 if (!isset($submit)) {
53 $submit = '';
54 }
55}
56else {
57 print "folder_prefix = $folder_prefix<BR>\n";
58 print "default_charset = $default_charset\n";
59}
60
61print "<BR></TD></TR></TABLE></CENTER><BR>\n";
62
63
64if ($submit == 'submit') {
65 $type = array();
66 for ($i=0;$i<count($list);$i++) {
67 $type[$list[$i]] = $$list[$i];
68 }
69}
70
71elseif ($submit == 'clear') {
72 for ($i=0;$i<count($list);$i++) {
73 $type[$list[$i]] = '';
74 }
75}
76
77elseif (!$submit || $submit == 'default') {
78 $type = array (
79 'TEST_0' => "SELECT $mailbox",
80 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
81 'TEST_2' => "EXAMINE $mailbox",
82 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
83 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
84 'TEST_5' => "SORT (DATE) $default_charset ALL",
85 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
86 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
87 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
88 'TEST_9' => "");
89}
90
91print "<FORM ACTION=\"options.php\" METHOD=POST>\n";
92print "<CENTER><TABLE BORDER=1>\n";
93print "<TR><TH>Select</TH><TH>Test Name</TH><TH>IMAP command string</TH>\n";
94print "</TR><TR><TD>\n";
95
96foreach($type as $index=>$value) {
97 print "</TD></TR><TR><TD WIDTH=\"10%\"><INPUT TYPE=CHECKBOX VALUE=1 NAME=CHECK_$index";
98 if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
99 print " CHECKED";
100 }
101 $check = "CHECK_".$index;
102 if (isset($$check) && $submit != 'clear' && $submit != 'default') {
103 print " CHECKED";
104 }
105 print "></TD><TD WIDTH=\"30%\">$index</TD><TD WIDTH=\"60%\">\n";
106 print "<INPUT TYPE=TEXT NAME=$index VALUE='$value' SIZE=60>\n";
107}
108
109print "</TD></TR></TABLE></CENTER><BR>\n";
110print "<CENTER><INPUT TYPE=SUBMIT NAME=submit value=submit>\n";
111print "<INPUT TYPE=SUBMIT NAME=submit value=clear>\n";
112print "<INPUT TYPE=SUBMIT NAME=submit value=default></CENTER><BR>\n";
113
114$tests = array();
115
116if ($submit == 'submit') {
117 foreach ($type as $index=>$value) {
118 $check = "CHECK_".$index;
119 if (isset($$check)) {
120 $type[$index] = $$index;
121 array_push($tests, $index);
122 }
123 }
124 for ($i=0;$i<count($tests);$i++) {
125 print "<CENTER><TABLE WIDTH=\"95%\" BORDER=0 BGCOLOR=".$color[4].">\n";
126 print "<TR><TD><B>".$tests[$i]."</B></TD><TR>";
127 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
128 ">Request:</FONT></SMALL></B></TD></TR>\n";
129 $response = imap_test($imap_stream, $type[$tests[$i]]);
130 print "<TR><TD><SMALL><B><FONT COLOR=".$color[7].
131 ">Response:</FONT></SMALL></B></TD></TR>\n";
132 print "<TR><TD>";
133 print_response($response);
134 print "</TD><TR></TABLE></CENTER><BR>\n";
135 }
136}
137 print "</TD></TR></TABLE></CENTER></BODY></HTML>";
138 sqimap_logout($imap_stream);
139 do_hook('info_bottom');
140?>