Source for file options.php

Documentation is available at options.php

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

Documentation generated on Mon, 13 Jan 2020 04:25:05 +0100 by phpDocumentor 1.4.3