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