From a7b90f05ac8a08954d355b96ab133ddaa2690221 Mon Sep 17 00:00:00 2001 From: jmunro Date: Fri, 17 May 2002 14:27:42 +0000 Subject: [PATCH] Added IMAP server information plugin called 'info'. See the README for details :) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2846 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/info/README | 41 +++++++++++ plugins/info/functions.php | 50 ++++++++++++++ plugins/info/options.php | 138 +++++++++++++++++++++++++++++++++++++ plugins/info/setup.php | 29 ++++++++ 4 files changed, 258 insertions(+) create mode 100644 plugins/info/README create mode 100644 plugins/info/functions.php create mode 100644 plugins/info/options.php create mode 100644 plugins/info/setup.php diff --git a/plugins/info/README b/plugins/info/README new file mode 100644 index 00000000..812d0bfa --- /dev/null +++ b/plugins/info/README @@ -0,0 +1,41 @@ +README for the info plugin for Squirrelmail + + This plugin is designed to aid a system admin +or Squirrelmail developer troubleshoot IMAP commands +and responses. + +IMPORTANT NOTE: + +***************************************************** +* THIS PLUGIN IS NOT MEANT FOR END USERS. IT ALLOWS * +* UNVALIDATED DATA TO BE PASSED TO THE IMAP SERVER. * +* IT IS BY NO MEANS SECURE AND SHOULD ONLY BE USED * +* FOR TESTING, TROUBLESHOOTING AND DEVELOPMENT. * +***************************************************** + +You have been warned :) + +Ok, now to the good stuff. Enable this plugin as you would any other. +Its called 'info'. You will then have an "IMAP server information" section +on your options page. This will take you to an IMAP command workshop +where you can select pre-made commands, send them to the IMAP server +and see the response. All selected commands will be run one at a time +starting with the first selected command and working down. + +Commands can be modified however you like, but remember, you are +performing these commands on the account you are logged into, so +any command that changes the contents of your mailbox will ..er.. +change the contents of your mailbox :) + +Changes and custom commands are maintained as long as you are on +the IMAP server options page (even after submitting tests). +Once you leave this page and return then the commmands are reset +to the defaults. You can manually reset the commands using the +'default' button, or clear the contents of all the commands with +the 'clear' button. + +Questions, problems, comments welcome at + +jason@stdbev.com +Jason Munro + diff --git a/plugins/info/functions.php b/plugins/info/functions.php new file mode 100644 index 00000000..92f666dc --- /dev/null +++ b/plugins/info/functions.php @@ -0,0 +1,50 @@ +".$query.""; + fputs ($imap_stream, $query); + $response = sqimap_read_data_list($imap_stream, $sid, false, $responses, $message); + array_push($response, $message); + return $response; +} + +function print_response($response) { + foreach($response as $index=>$value) { + if (is_array($value)) { + print_response($value); + } + else { + $value = preg_replace("//", ">", $value); + print $value."
\n"; + } + } +} + +?> diff --git a/plugins/info/options.php b/plugins/info/options.php new file mode 100644 index 00000000..0578ffca --- /dev/null +++ b/plugins/info/options.php @@ -0,0 +1,138 @@ +
IMAP server information

\n"; +print "

\n"; +print "
\n"; +print "
Server Capability response:
\n"; + +foreach($caps_array[0] as $value) { + print $value; +} + +print "
\n"; + +if (!isset($submit) || $submit == 'default') { + print "
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.

NOTE: These commands are live, any changes made will effect your current email account.

\n"; + if (!isset($submit)) { + $submit = ''; + } +} +else { + print "folder_prefix = $folder_prefix
\n"; + print "default_charset = $default_charset\n"; +} + +print "

\n"; + + +if ($submit == 'submit') { + $type = array(); + for ($i=0;$i "SELECT $mailbox", + 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)", + 'TEST_2' => "EXAMINE $mailbox", + 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *", + 'TEST_4' => "THREAD REFERENCES $default_charset ALL", + 'TEST_5' => "SORT (DATE) $default_charset ALL", + 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])", + 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"", + 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"", + 'TEST_9' => ""); +} + +print "
\n"; +print "
\n"; +print "\n"; +print "
SelectTest NameIMAP command string
\n"; + +foreach($type as $index=>$value) { + print "
$index\n"; + print "\n"; +} + +print "

\n"; +print "
\n"; +print "\n"; +print "

\n"; + +$tests = array(); + +if ($submit == 'submit') { + foreach ($type as $index=>$value) { + $check = "CHECK_".$index; + if (isset($$check)) { + $type[$index] = $$index; + array_push($tests, $index); + } + } + for ($i=0;$i\n"; + print ""; + print "\n"; + $response = imap_test($imap_stream, $type[$tests[$i]]); + print "\n"; + print "
".$tests[$i]."
Request:
Response:
"; + print_response($response); + print "

\n"; + } +} + print "
"; + sqimap_logout($imap_stream); + do_hook('info_bottom'); +?> diff --git a/plugins/info/setup.php b/plugins/info/setup.php new file mode 100644 index 00000000..6973aaab --- /dev/null +++ b/plugins/info/setup.php @@ -0,0 +1,29 @@ + _("IMAP server information"), + 'url' => '../plugins/info/options.php', + 'desc' => _("Run some test IMAP commands, displaying both the command and the result. These tests use the Squirrelmail IMAP commands and your current Squirrelmail configuration. Custom command strings can be used."), + 'js' => false + ); +} + +?> -- 2.25.1