Source for file options.php

Documentation is available at options.php

  1. <?php
  2. /* options page for IMAP info plugin
  3. * Copyright (c) 1999-2020 The SquirrelMail Project Team
  4. * Licensed under the GNU GPL. For full terms see the file COPYING.
  5. *
  6. * This is where it all happens :)
  7. *
  8. * Written by: Jason Munro
  9. *
  10. * $Id: options.php 14840 2020年01月07日 07:42:38Z pdontthink $
  11. *
  12. */
  13. define ('SM_PATH','../../');
  14. /* SquirrelMail required files. */
  15. require_once(SM_PATH . 'include/validate.php');
  16. require_once(SM_PATH . 'functions/page_header.php');
  17. require_once(SM_PATH . 'functions/imap.php');
  18. require_once(SM_PATH . 'functions/forms.php');
  19. require_once(SM_PATH . 'plugins/info/functions.php');
  20. global $username, $color, $folder_prefix, $default_charset;
  21. $default_charset = strtoupper ($default_charset);
  22. displayPageHeader ($color, 'None');
  23. $mailbox = 'INBOX';
  24. /**
  25. * testing installation
  26. *
  27. * prevent use of plugin if it is not enabled
  28. */
  29. if (! info_is_plugin_enabled ('info')) {
  30. echo '<p align="center"><big>'.
  31. _ ("Plugin is disabled.").
  32. '</big></p></body></html>';
  33. exit;
  34. }
  35. /* GLOBALS */
  36. sqgetGlobalVar ('username', $username, SQ_SESSION );
  37. sqgetGlobalVar ('key', $key, SQ_COOKIE );
  38. sqgetGlobalVar ('onetimepad', $onetimepad, SQ_SESSION );
  39. sqgetGlobalVar ('submit', $submit, SQ_POST );
  40. for($i = 0; $i <= 9; $i++){
  41. $varc = 'CHECK_TEST_'.$i;
  42. sqgetGlobalVar ($varc, $$varc, SQ_POST );
  43. $vart = 'TEST_'.$i;
  44. sqgetGlobalVar ($vart, $$vart, SQ_POST );
  45. }
  46. /* END GLOBALS */
  47. global $imap_stream_options; // in case not defined in config
  48. $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  49. $caps_array = get_caps ($imap_stream);
  50. $list = array (
  51. 'TEST_0',
  52. 'TEST_1',
  53. 'TEST_2',
  54. 'TEST_3',
  55. 'TEST_4',
  56. 'TEST_5',
  57. 'TEST_6',
  58. 'TEST_7',
  59. 'TEST_8',
  60. 'TEST_9');
  61. print "<br><center><b>IMAP server information</b></center><br>\n";
  62. print "<center><table bgcolor=\"".$color[3]."\" width=\"100%\" border=\"1\" cellpadding=\"2\"><tr><td bgcolor=".$color[3]."><br>\n";
  63. print "<center><table width=\"95%\" border=\"1\" bgcolor=\"".$color[3]."\">\n";
  64. print "<tr><td bgcolor=\"".$color[4]."\"><b>Server Capability response:</b><br>\n";
  65. foreach($caps_array[0] as $value) {
  66. }
  67. print "</td></tr><tr><td>\n";
  68. if (!isset($submit) || $submit == 'default') {
  69. print "<br><font color=".$color[6]."><small>Select the IMAP commands you would like to run.
  70. Most commands require a selected mailbox so the SELECT-command is already setup.
  71. You can clear all the commands and test your own IMAP command strings. The
  72. commands are executed in order. The default values are simple IMAP commands using
  73. your default_charset and folder_prefix from SquirrelMail when needed.<br><br>
  74. </small></font><center><font color=".$color[6]."><small><b>NOTE: These commands
  75. are live, any changes made will effect your current
  76. email account.</b></small></font></center><br>\n";
  77. if (!isset($submit)) {
  78. $submit = '';
  79. }
  80. }
  81. else {
  82. print 'folder_prefix = ' . sm_encode_html_special_chars ($folder_prefix) . "<br>\n".
  83. 'default_charset = ' . sm_encode_html_special_chars ($default_charset) . "\n";
  84. }
  85. print "<br></td></tr></table></center><br>\n";
  86. if ($submit == 'submit') {
  87. $type = array();
  88. for ($i=0;$i<count ($list);$i++) {
  89. $temp = $list[$i];
  90. $type[$list[$i]] = $$temp;
  91. }
  92. }
  93. elseif ($submit == 'clear') {
  94. for ($i=0;$i<count ($list);$i++) {
  95. $type[$list[$i]] = '';
  96. }
  97. }
  98. elseif (!$submit || $submit == 'default') {
  99. $type = array (
  100. 'TEST_0' => "SELECT $mailbox",
  101. 'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
  102. 'TEST_2' => "EXAMINE $mailbox",
  103. 'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
  104. 'TEST_4' => "THREAD REFERENCES $default_charset ALL",
  105. 'TEST_5' => "SORT (DATE) $default_charset ALL",
  106. 'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
  107. 'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
  108. 'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
  109. 'TEST_9' => "");
  110. }
  111. print "<form action=\"options.php\" method=\"post\">\n";
  112. print "<center><table border=\"1\">\n";
  113. print "<tr><th>Select</th><th>Test Name</th><th>IMAP command string</th>\n";
  114. print "</tr><tr><td>\n";
  115. foreach($type as $index=>$value) {
  116. print "</td></tr><tr><td width=\"10%\"><input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\"";
  117. if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
  118. print " checked";
  119. }
  120. $check = "CHECK_".$index;
  121. if (isset($$check) && $submit != 'clear' && $submit != 'default') {
  122. print " checked";
  123. }
  124. print "></td><td width=\"30%\">$index</td><td width=\"60%\">\n";
  125. print addInput ($index, $value, 60);
  126. }
  127. print "</td></tr></table></center><br>\n";
  128. print "<center>".
  129. addSubmit ('submit','submit').
  130. addSubmit ('clear','submit').
  131. addSubmit ('default','submit').
  132. "</center><br>\n";
  133. $tests = array();
  134. if ($submit == 'submit') {
  135. foreach ($type as $index=>$value) {
  136. $check = "CHECK_".$index;
  137. if (isset($$check)) {
  138. $type[$index] = $$index;
  139. array_push ($tests, $index);
  140. }
  141. }
  142. for ($i=0;$i<count ($tests);$i++) {
  143. print "<center><table width=\"95%\" border=\"0\" bgcolor=\"".$color[4]."\">\n";
  144. print "<tr><td><b>".$tests[$i]."</b></td></tr>";
  145. print "<tr><td><font color=\"".$color[7]."\"><small><b>".
  146. "Request:</b></small></font></td></tr>\n";
  147. $response = imap_test ($imap_stream, $type[$tests[$i]]);
  148. print "<tr><td><font color=\"".$color[7]."\"><small><b>".
  149. "Response:</b></small></font></td></tr>\n";
  150. print "<tr><td>";
  151. print_response ($response);
  152. print "</td></tr></table></center><br>\n";
  153. }
  154. }
  155. print "</form></td></tr></table></center></body></html>";
  156. sqimap_logout ($imap_stream);
  157. do_hook ('info_bottom');

Documentation generated on 2020年1月13日 04:25:05 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /