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-2006 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,v 1.6.2.7 2006/06/12 13:31:55 kink Exp $
  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. $imap_stream sqimap_login($username$key$imapServerAddress$imapPort0);
  58. $caps_array get_caps($imap_stream);
  59. $list array (
  60.                'TEST_0',
  61.                'TEST_1',
  62.                'TEST_2',
  63.                'TEST_3',
  64.                'TEST_4',
  65.                'TEST_5',
  66.                'TEST_6',
  67.                'TEST_7',
  68.                'TEST_8',
  69.                'TEST_9');
  70.  
  71. print "<br><center><b>IMAP server information</b></center><br>\n";
  72. print "<center><table bgcolor=\"".$color[3]."\" width=\"100%\" border=\"1\" cellpadding=\"2\"><tr><td bgcolor=".$color[3]."><br>\n";
  73. print "<center><table width=\"95%\" border=\"1\" bgcolor=\"".$color[3]."\">\n";
  74. print "<tr><td bgcolor=\"".$color[4]."\"><b>Server Capability response:</b><br>\n";
  75.  
  76. foreach($caps_array[0as $value{
  77.     print htmlspecialchars($value);
  78. }
  79.  
  80. print "</td></tr><tr><td>\n";
  81.  
  82. if (!isset($submit|| $submit == 'default'{
  83.     print "<br><font color=".$color[6]."><small>Select the IMAP commands you would like to run.
  84.         Most commands require a selected mailbox so the SELECT-command is already setup.
  85.         You can clear all the commands and test your own IMAP command strings. The
  86.         commands are executed in order. The default values are simple IMAP commands using
  87.         your default_charset and folder_prefix from SquirrelMail when needed.<br><br>
  88.         </small></font><center><font color=".$color[6]."><small><b>NOTE: These commands
  89.         are live, any changes made will effect your current
  90.         email account.</b></small></font></center><br>\n";
  91.     if (!isset($submit)) {
  92.         $submit '';
  93.     }
  94. }
  95. else {
  96.     print 'folder_prefix = ' htmlspecialchars($folder_prefix"<br>\n".
  97.           'default_charset = ' htmlspecialchars($default_charset"\n";
  98. }
  99.  
  100. print "<br></td></tr></table></center><br>\n";
  101.  
  102.  
  103. if ($submit == 'submit'{
  104.     $type array();
  105.     for ($i=0;$i<count($list);$i++{
  106.         $type[$list[$i]] = $$list[$i];
  107.     }
  108. }
  109.  
  110. elseif ($submit == 'clear'{
  111.     for ($i=0;$i<count($list);$i++{
  112.         $type[$list[$i]] '';
  113.     }
  114. }
  115.  
  116. elseif (!$submit || $submit == 'default')  {
  117.     $type array (
  118.         'TEST_0' => "SELECT $mailbox",
  119.         'TEST_1' => "STATUS $mailbox (MESSAGES RECENT)",
  120.         'TEST_2' => "EXAMINE $mailbox",
  121.         'TEST_3' => "SEARCH CHARSET \"$default_charset\" ALL *",
  122.         'TEST_4' => "THREAD REFERENCES $default_charset ALL",
  123.         'TEST_5' => "SORT (DATE$default_charset ALL",
  124.         'TEST_6' => "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (FROM DATE TO)])",
  125.         'TEST_7' => "LSUB \"$folder_prefix\" \"*%\"",
  126.         'TEST_8' => "LIST \"$folder_prefix*\" \"*\"",
  127.         'TEST_9' => "");
  128. }
  129.  
  130. print "<form action=\"options.php\" method=\"post\">\n";
  131. print "<center><table border=\"1\">\n";
  132. print "<tr><th>Select</th><th>Test Name</th><th>IMAP command string</th>\n";
  133. print "</tr><tr><td>\n";
  134.  
  135. foreach($type as $index=>$value{
  136.     print "</td></tr><tr><td width=\"10%\"><input type=\"checkbox\" value=\"1\" name=\"CHECK_$index\"";
  137.     if ($index == 'TEST_0' && ($submit == 'default' || $submit == '')) {
  138.         print " checked";
  139.     }
  140.     $check "CHECK_".$index;
  141.     if (isset($$check&& $submit != 'clear' && $submit != 'default'{
  142.         print " checked";
  143.     }
  144.     print "></td><td width=\"30%\">$index</td><td width=\"60%\">\n";
  145.     print addInput($index$value60);
  146. }
  147.  
  148. print "</td></tr></table></center><br>\n";
  149. print "<center>".
  150. addSubmit('submit','submit').
  151. addSubmit('clear','submit').
  152. addSubmit('default','submit').
  153. "</center><br>\n";
  154.  
  155. $tests array();
  156.  
  157. if ($submit == 'submit'{
  158.     foreach ($type as $index=>$value{
  159.         $check "CHECK_".$index;
  160.         if (isset($$check)) {
  161.             $type[$index= $$index;
  162.             array_push($tests$index)
  163.         }
  164.     }
  165.     for ($i=0;$i<count($tests);$i++{
  166.         print "<center><table width=\"95%\" border=\"0\" bgcolor=\"".$color[4]."\">\n";
  167.         print "<tr><td><b>".$tests[$i]."</b></td></tr>";
  168.         print "<tr><td><font color=\"".$color[7]."\"><small><b>".
  169.               "Request:</b></small></font></td></tr>\n";
  170.         $response imap_test($imap_stream$type[$tests[$i]]);
  171.         print "<tr><td><font color=\"".$color[7]."\"><small><b>".
  172.               "Response:</b></small></font></td></tr>\n";
  173.         print "<tr><td>";
  174.         print_response($response);
  175.         print "</td></tr></table></center><br>\n";
  176.     }
  177. }
  178.     print "</form></td></tr></table></center></body></html>";
  179.     sqimap_logout($imap_stream);
  180.     do_hook('info_bottom');
  181. ?>

Documentation generated on Sat, 07 Oct 2006 16:32:46 +0300 by phpDocumentor 1.3.0RC6