Source for file help.php

Documentation is available at help.php

  1. <?php
  2.  
  3. /**
  4.  * help.php
  5.  *
  6.  * Displays help for the user
  7.  *
  8.  * @copyright 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: help.php 14840 2020-01-07 07:42:38Z pdontthink $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** This is the help page */
  15. define('PAGE_NAME''help');
  16.  
  17. /**
  18.  * Path for SquirrelMail required files.
  19.  * @ignore
  20.  */
  21. define('SM_PATH','../');
  22.  
  23. /* SquirrelMail required files. */
  24. require_once(SM_PATH 'include/validate.php');
  25. require_once(SM_PATH 'functions/global.php');
  26. require_once(SM_PATH 'functions/display_messages.php');
  27.  
  28. displayPageHeader($color'None' );
  29.  
  30. $helpdir[0'basic.hlp';
  31. $helpdir[1'main_folder.hlp';
  32. $helpdir[2'read_mail.hlp';
  33. $helpdir[3'compose.hlp';
  34. $helpdir[4'addresses.hlp';
  35. $helpdir[5'folders.hlp';
  36. $helpdir[6'options.hlp';
  37. $helpdir[7'search.hlp';
  38. $helpdir[8'FAQ.hlp';
  39.  
  40. /****************[ HELP FUNCTIONS ]********************/
  41.  
  42. /**
  43.  * parses through and gets the information from the different documents.
  44.  * this returns one section at a time.  You must keep track of the position
  45.  * so that it knows where to start to look for the next section.
  46.  */
  47.  
  48. function get_info($doc$pos{
  49.     $ary array(0,0,0);
  50.  
  51.     $cntdoc count($doc);
  52.  
  53.     for ($n=$pos$n $cntdoc$n++{
  54.         if (trim(strtolower($doc[$n])) == '<chapter>'
  55.             || trim(strtolower($doc[$n])) == '<section>'{
  56.             for ($n++$n $cntdoc
  57.                  && (trim(strtolower($doc[$n])) != '</section>')
  58.                  && (trim(strtolower($doc[$n])) != '</chapter>')$n++{
  59.                 if (trim(strtolower($doc[$n])) == '<title>'{
  60.                     $n++;
  61.                     $ary[0trim($doc[$n]);
  62.                 }
  63.                 if (trim(strtolower($doc[$n])) == '<description>'{
  64.                     $ary[1'';
  65.                     for ($n++;$n $cntdoc
  66.                          && (trim(strtolower($doc[$n])) != '</description>');
  67.                          $n++{
  68.                         $ary[1.= $doc[$n];
  69.                     }
  70.                 }
  71.                 if (trim(strtolower($doc[$n])) == '<summary>'{
  72.                     $ary[2'';
  73.                     for ($n++$n $cntdoc
  74.                          && (trim(strtolower($doc[$n])) != '</summary>');
  75.                          $n++{
  76.                         $ary[2.= $doc[$n];
  77.                     }
  78.                 }
  79.             }
  80.             if (isset($ary)) {
  81.                 $ary[3$n;
  82.             else {
  83.                 $ary[0_("ERROR: Help files are not in the right format!");
  84.                 $ary[1$ary[0];
  85.                 $ary[2$ary[0];
  86.             }
  87.             return$ary );
  88.         else if (!trim(strtolower($doc[$n]))) {
  89.             $ary[0'';
  90.             $ary[1'';
  91.             $ary[2'';
  92.             $ary[3$n;
  93.         }
  94.     }
  95.     $ary[0_("ERROR: Help files are not in the right format!");
  96.     $ary[1$ary[0];
  97.     $ary[2$ary[0];
  98.     $ary[3$n;
  99.     return$ary );
  100. }
  101.  
  102. /**************[ END HELP FUNCTIONS ]******************/
  103.  
  104. echo html_tag'table',
  105.         html_tag'tr',
  106.             html_tag'td','<div style="text-align: center;"><b>' _("Help".'</b></div>''center'$color[0)
  107.         ,
  108.     'center''''width="95%" cellpadding="1" cellspacing="2" border="0"' );
  109.  
  110. do_hook('help_top');
  111.  
  112. echo html_tag'table''''center''''width="90%" cellpadding="0" cellspacing="10" border="0"' .
  113.         html_tag'tr' .
  114.             html_tag'td' );
  115.  
  116. if (!isset($squirrelmail_language)) {
  117.     $squirrelmail_language 'en_US';
  118. }
  119.  
  120. if (file_exists("../help/$squirrelmail_language")) {
  121.     $user_language $squirrelmail_language;
  122. else if (file_exists('../help/en_US')) {
  123.     error_box(_("Help is not available in the selected language. It will be displayed in English instead.")$color);
  124.     echo '<br />';
  125.     $user_language 'en_US';
  126. else {
  127.     error_box_("Help is not available. Please contact your system administrator for assistance.")$color );
  128.     echo '</td></tr></table>';
  129.     exit;
  130. }
  131.  
  132.  
  133. /* take the chapternumber from the GET-vars,
  134.  * else see if we can get a relevant chapter from the referer */
  135. $chapter 0;
  136.  
  137. if sqgetGlobalVar('chapter'$tempSQ_GET) ) {
  138.     $chapter = (int) $temp;
  139. elseif sqgetGlobalVar('HTTP_REFERER'$tempSQ_SERVER) ) {
  140.     $ref strtolower($temp);
  141.  
  142.     $contexts array 'src/compose' => 4'src/addr' => 5,
  143.         'src/folders' => 6'src/options' => 7'src/right_main' => 2,
  144.         'src/read_body' => 3'src/search' => );
  145.  
  146.     foreach($contexts as $path => $chap{
  147.         if(strpos($ref$path)) {
  148.             $chapter $chap;
  149.             break;
  150.         }
  151.     }
  152. }
  153.  
  154. if $chapter == || !isset$helpdir[$chapter-1) ) {
  155.     // Initialise the needed variables.
  156.     $toc array();
  157.  
  158.     // Get the chapter numbers, title and decriptions.
  159.     for ($i=0$cnt count($helpdir)$i $cnt$i++{
  160.         if (file_exists("../help/$user_language/$helpdir[$i]")) {
  161.             if (is_readable("../help/$user_language/$helpdir[$i]")) {
  162.                 // First try the selected language.
  163.                 $doc file("../help/$user_language/$helpdir[$i]");
  164.                 $help_info get_info($doc0);
  165.                 $toc[array($i+1$help_info[0]$help_info[2]);
  166.             else {
  167.                 $toc[array($i+1_("This chapter file is not readable"),
  168.                          sprintf(_("For some reason, the file for chapter %s is not readable.")$i+1));
  169.             }
  170.         elseif (file_exists("../help/en_US/$helpdir[$i]")) {
  171.             if (is_readable("../help/en_US/$helpdir[$i]")) {
  172.                 // If the selected language can't be found, try English.
  173.                 $doc file("../help/en_US/$helpdir[$i]");
  174.                 $help_info get_info($doc0);
  175.                 $toc[array($i+1$help_info[0],
  176.                         _("This chapter is not available in the selected language. It will be displayed in English instead.".
  177.                         '<br />' $help_info[2]);
  178.             else {
  179.                 $toc[array($i+1_("This chapter file is not readable"),
  180.                          sprintf(_("For some reason, the file for chapter %s is not readable.")$i+1));
  181.             }
  182.         else {
  183.             // If English can't be found, the chapter went MIA.
  184.             $toc[array($i+1_("This chapter is missing"),
  185.                     sprintf(_("For some reason, chapter %s is not available.")$i+1));
  186.         }
  187.     }
  188.  
  189.     // Write the TOC header
  190.     echo html_tag'table''''center''''cellpadding="0" cellspacing="0" border="0"' .
  191.          html_tag'tr' .
  192.          html_tag'td' .
  193.          '<div style="text-align: center;"><b>' _("Table of Contents"'</b></div><br />';
  194.     echo html_tag'ol' );
  195.  
  196.     // Write the TOC chapters.
  197.     // FIXME: HTML code is not compliant.
  198.     for ($i=0$cnt count($toc)$i $cnt$i++{
  199.         echo '<li><a href="../src/help.php?chapter=' $toc[$i][0]'">' .
  200.             $toc[$i][1'</a>' html_tag'ul'$toc[$i][2);
  201.     }
  202.  
  203.     // Provide hook for external help scripts.
  204.     do_hook('help_chapter');
  205.  
  206.     // Write the TOC footer.
  207.     echo '</ol></td></tr></table>';
  208. else {
  209.     // Initialise the needed variables.
  210.     $display_chapter TRUE;
  211.  
  212.     // Get the chapter.
  213.     if (file_exists("../help/$user_language/$helpdir[$chapter-1])) {
  214.         if (is_readable("../help/$user_language/$helpdir[$chapter-1])) {
  215.             // First try the selected language.
  216.            $doc file("../help/$user_language/$helpdir[$chapter-1]);
  217.         else {
  218.             error_box(sprintf(_("For some reason, the file for chapter %s is not readable.")$chapter)$color);
  219.             echo '<br />';
  220.         }
  221.     elseif (file_exists("../help/en_US/" $helpdir[$chapter-1])) {
  222.         if (is_readable("../help/en_US/" $helpdir[$chapter-1])) {
  223.             // If the selected language can't be found, try English.
  224.             $doc file("../help/en_US/" $helpdir[$chapter-1]);
  225.             error_box(_("This chapter is not available in the selected language. It will be displayed in English instead.")$color);
  226.             echo '<br />';
  227.         else {
  228.             error_box(sprintf(_("For some reason, the file for chapter %s is not readable.")$chapter)$color);
  229.             echo '<br />';
  230.         }
  231.     else {
  232.         // If English can't be found, the chapter went MIA.
  233.         $display_chapter FALSE;
  234.     }
  235.  
  236.     // Write the chapter header.
  237.     echo '<div style="text-align: center;"><small>';
  238.     if ($chapter <= 1){
  239.         echo '<font color="' $color[9'">' _("Previous")
  240.              . '</font> | ';
  241.     else {
  242.         echo '<a href="../src/help.php?chapter=' ($chapter-1)
  243.              . '">' _("Previous"'</a> | ';
  244.     }
  245.     echo '<a href="../src/help.php">' _("Table of Contents"'</a>';
  246.     if ($chapter >= count($helpdir)){
  247.         echo ' | <font color="' $color[9'">' _("Next"'</font>';
  248.     else {
  249.         echo ' | <a href="../src/help.php?chapter=' ($chapter+1)
  250.              . '">' _("Next"'</a>';
  251.     }
  252.     echo '</small></div><br />';
  253.  
  254.     // Write the chapter.
  255.     if ($display_chapter{
  256.         // If there is a valid chapter, display it.
  257.         $help_info get_info($doc0);
  258.         echo '<font size="5"><b>' $chapter ' - ' $help_info[0]
  259.             . '</b></font><br /><br />';
  260.  
  261.         if (isset($help_info[1]&& $help_info[1]{
  262.             echo $help_info[1];
  263.         else {
  264.             echo html_tag'p'$help_info[2]'left' );
  265.         }
  266.  
  267.         $section 0;
  268.         for ($n $help_info[3]$cnt count($doc)$n $cnt$n++{
  269.             $section++;
  270.             $help_info get_info($doc$n);
  271.             echo "<b>$chapter.$section - $help_info[0]</b>.
  272.                 $help_info[1];
  273.             $n $help_info[3];
  274.         }
  275.  
  276.         echo '<br /><div style="text-align: center;"><a href="#pagetop">' _("Top"'</a></div>';
  277.     else {
  278.         // If the help file went MIA, display an error message.
  279.         error_box(sprintf(_("For some reason, chapter %s is not available.")$chapter)$color);
  280.     }
  281. }
  282.  
  283. do_hook('help_bottom');
  284.  
  285. echo html_tag'tr',
  286.             html_tag'td''&nbsp;''left'$color[0)
  287.         );
  288.  
  289. ?>
  290. </table></body></html>

Documentation generated on Mon, 13 Jan 2020 04:24:41 +0100 by phpDocumentor 1.4.3