| 1 | <?php |
| 2 | /** |
| 3 | ** help.php |
| 4 | ** |
| 5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | ** |
| 8 | ** Displays help for the user |
| 9 | ** |
| 10 | **/ |
| 11 | |
| 12 | session_start(); |
| 13 | |
| 14 | if (!isset($config_php)) |
| 15 | include("../config/config.php"); |
| 16 | if (!isset($strings_php)) |
| 17 | include("../functions/strings.php"); |
| 18 | if (!isset($page_header_php)) |
| 19 | include("../functions/page_header.php"); |
| 20 | if (!isset($display_messages_php)) |
| 21 | include("../functions/display_messages.php"); |
| 22 | if (!isset($imap_php)) |
| 23 | include("../functions/imap.php"); |
| 24 | if (!isset($array_php)) |
| 25 | include("../functions/array.php"); |
| 26 | if (!isset($i18n_php)) |
| 27 | include("../functions/i18n.php"); |
| 28 | if (!isset($auth_php)) |
| 29 | include ("../functions/auth.php"); |
| 30 | |
| 31 | include("../src/load_prefs.php"); |
| 32 | displayPageHeader($color, "None"); |
| 33 | is_logged_in(); |
| 34 | |
| 35 | $helpdir[0] = "basic.hlp"; |
| 36 | $helpdir[1] = "main_folder.hlp"; |
| 37 | $helpdir[2] = "read_mail.hlp"; |
| 38 | $helpdir[3] = "compose.hlp"; |
| 39 | $helpdir[4] = "addresses.hlp"; |
| 40 | $helpdir[5] = "folders.hlp"; |
| 41 | $helpdir[6] = "options.hlp"; |
| 42 | $helpdir[7] = "search.hlp"; |
| 43 | $helpdir[8] = "FAQ.hlp"; |
| 44 | |
| 45 | /****************[ HELP FUNCTIONS ]********************/ |
| 46 | // parses through and gets the information from the different documents. |
| 47 | // this returns one section at a time. You must keep track of the position |
| 48 | // so that it knows where to start to look for the next section. |
| 49 | |
| 50 | function get_info($doc, $pos) { |
| 51 | for ($n=$pos; $n < count($doc); $n++) { |
| 52 | if (trim(strtolower($doc[$n])) == "<chapter>" || trim(strtolower($doc[$n])) == "<section>") { |
| 53 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</section>") && (trim(strtolower($doc[$n])) != "</chapter>"); $n++) { |
| 54 | if (trim(strtolower($doc[$n])) == "<title>") { |
| 55 | $n++; |
| 56 | $ary[0] = trim($doc[$n]); |
| 57 | } |
| 58 | if (trim(strtolower($doc[$n])) == "<description>") { |
| 59 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</description>"); $n++) { |
| 60 | $ary[1] .= $doc[$n]; |
| 61 | } |
| 62 | } |
| 63 | if (trim(strtolower($doc[$n])) == "<summary>") { |
| 64 | for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != "</summary>"); $n++) { |
| 65 | $ary[2] .= $doc[$n]; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | if ($ary) { |
| 70 | $ary[3] = $n; |
| 71 | return $ary; |
| 72 | } else { |
| 73 | $ary[0] = "ERROR: Help files are not in the right format!"; |
| 74 | $ary[1] = "ERROR: Help files are not in the right format!"; |
| 75 | $ary[2] = "ERROR: Help files are not in the right format!"; |
| 76 | return $ary; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | $ary[0] = "ERROR: Help files are not in the right format!"; |
| 81 | $ary[1] = "ERROR: Help files are not in the right format!"; |
| 82 | return $ary; |
| 83 | } |
| 84 | |
| 85 | /**************[ END HELP FUNCTIONS ]******************/ |
| 86 | |
| 87 | ?> |
| 88 | |
| 89 | <br> |
| 90 | <table width=95% align=center cellpadding=2 cellspacing=2 border=0> |
| 91 | <tr><td bgcolor="<?php echo $color[0] ?>"> |
| 92 | <center><b><?php echo _("Help") ?></b></center> |
| 93 | </td></tr></table> |
| 94 | |
| 95 | <?php do_hook("help_top") ?> |
| 96 | |
| 97 | <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><td> |
| 98 | <?php |
| 99 | if ($HTTP_REFERER) { |
| 100 | $ref = strtolower($HTTP_REFERER); |
| 101 | if (strpos($ref, "src/compose")) |
| 102 | $context = "compose"; |
| 103 | else if (strpos($ref, "src/addr")) |
| 104 | $context = "address"; |
| 105 | else if (strpos($ref, "src/folders")) |
| 106 | $context = "folders"; |
| 107 | else if (strpos($ref, "src/options")) |
| 108 | $context = "options"; |
| 109 | else if (strpos($ref, "src/right_main")) |
| 110 | $context = "index"; |
| 111 | else if (strpos($ref, "src/read_body")) |
| 112 | $context = "read"; |
| 113 | else if (strpos($ref, "src/search")) |
| 114 | $context = "search"; |
| 115 | } |
| 116 | |
| 117 | if (file_exists("../help/$squirrelmail_language")) { |
| 118 | $help_exists = true; |
| 119 | $user_language = $squirrelmail_language; |
| 120 | } else if (file_exists("../help/en")) { |
| 121 | $help_exists = true; |
| 122 | echo "<center><font color=\"$color[2]\">"; |
| 123 | printf (_("The help has not been translated to %s. It will be displayed in English instead."), $languages[$squirrelmail_language]["NAME"]); |
| 124 | echo "</font></center><br>"; |
| 125 | $user_language = "en"; |
| 126 | } else { |
| 127 | $help_exists = false; |
| 128 | echo "<br><center><font color=\"$color[2]\">"; |
| 129 | echo _("Some or all of the help documents are not present!"); |
| 130 | echo "</font></center>"; |
| 131 | echo "</td></tr></table>"; |
| 132 | exit; |
| 133 | } |
| 134 | |
| 135 | if ($help_exists) { |
| 136 | if ($context == "compose") |
| 137 | $chapter = 4; |
| 138 | else if ($context == "address") |
| 139 | $chapter = 5; |
| 140 | else if ($context == "folders") |
| 141 | $chapter = 6; |
| 142 | else if ($context == "options") |
| 143 | $chapter = 7; |
| 144 | else if ($context == "index") |
| 145 | $chapter = 2; |
| 146 | else if ($context == "read") |
| 147 | $chapter = 3; |
| 148 | else if ($context == "search") |
| 149 | $chapter = 8; |
| 150 | |
| 151 | if (!$chapter) { |
| 152 | echo "<table cellpadding=0 cellspacing=0 border=0 align=center><tr><td>\n"; |
| 153 | echo "<b><center>" . _("Table of Contents") . "</center></b><br>"; |
| 154 | do_hook("help_chapter"); |
| 155 | echo "<ol>\n"; |
| 156 | for ($i=0; $i < count($helpdir); $i++) { |
| 157 | $doc = file("../help/$user_language/$helpdir[$i]"); |
| 158 | $help_info = get_info($doc, 0); |
| 159 | echo "<li><a href=\"../src/help.php?chapter=". ($i+1) ."\">$help_info[0]</a>\n"; |
| 160 | echo "<ul>$help_info[2]</ul>"; |
| 161 | } |
| 162 | echo "</ol>\n"; |
| 163 | echo "</td></tr></table>\n"; |
| 164 | } else { |
| 165 | $doc = file("../help/$user_language/".$helpdir[$chapter-1]); |
| 166 | $help_info = get_info($doc, 0); |
| 167 | |
| 168 | echo "<small><center>"; |
| 169 | |
| 170 | if ($chapter <= 1) echo "<font color=\"$color[9]\">Previous</font> | "; |
| 171 | else echo "<a href=\"../src/help.php?chapter=".($chapter-1)."\">Previous</a> | "; |
| 172 | echo "<a href=\"../src/help.php\">Table of Contents</a>"; |
| 173 | if ($chapter >= count($helpdir)) echo " | <font color=\"$color[9]\">Next</font>"; |
| 174 | else echo " | <a href=\"../src/help.php?chapter=".($chapter+1)."\">Next</a>"; |
| 175 | echo "</center></small><br>\n"; |
| 176 | |
| 177 | echo "<font size=5><b>$chapter - $help_info[0]</b></font><br><br>\n"; |
| 178 | if ($help_info[1]) |
| 179 | echo "$help_info[1]"; |
| 180 | else |
| 181 | echo "<p>$help_info[2]</p>"; |
| 182 | |
| 183 | for ($n = $help_info[3]; $n < count($doc); $n++) { |
| 184 | $section++; |
| 185 | $help_info = get_info($doc, $n); |
| 186 | echo "<b>$chapter.$section - $help_info[0]</b>"; |
| 187 | echo "<ul>"; |
| 188 | echo "$help_info[1]"; |
| 189 | echo "</ul>"; |
| 190 | $n = $help_info[3]; |
| 191 | } |
| 192 | |
| 193 | echo "<br><center><a href=\"#pagetop\">" . _("Top") . "</a></center>"; |
| 194 | } |
| 195 | } |
| 196 | do_hook("help_bottom"); |
| 197 | ?> |
| 198 | <tr><td bgcolor="<?php echo $color[0] ?>"> </td></tr></table> |
| 199 | <td></tr></table> |
| 200 | </body></html> |