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