Source for file webmail.php

Documentation is available at webmail.php

  1. <?php
  2. /**
  3. * webmail.php -- Displays the main frameset
  4. *
  5. * This file generates the main frameset. The files that are
  6. * shown can be given as parameters. If the user is not logged in
  7. * this file will verify username and password.
  8. *
  9. * @copyright 1999-2020 The SquirrelMail Project Team
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @version $Id: webmail.php 14840 2020年01月07日 07:42:38Z pdontthink $
  12. * @package squirrelmail
  13. */
  14. /** This is the webmail page */
  15. define ('PAGE_NAME', 'webmail');
  16. /**
  17. * Path for SquirrelMail required files.
  18. * @ignore
  19. */
  20. define ('SM_PATH','../');
  21. /* SquirrelMail required files. */
  22. require_once(SM_PATH . 'include/validate.php');
  23. require_once(SM_PATH . 'functions/imap.php');
  24. sqgetGlobalVar ('username', $username, SQ_SESSION );
  25. sqgetGlobalVar ('delimiter', $delimiter, SQ_SESSION );
  26. sqgetGlobalVar ('onetimepad', $onetimepad, SQ_SESSION );
  27. sqgetGlobalVar ('right_frame', $right_frame, SQ_GET );
  28. if (sqgetGlobalVar ('sort', $sort)) {
  29. $sort = (int) $sort;
  30. }
  31. if (sqgetGlobalVar ('startMessage', $startMessage)) {
  32. $startMessage = (int) $startMessage;
  33. }
  34. if (!sqgetGlobalVar ('mailbox', $mailbox)) {
  35. $mailbox = 'INBOX';
  36. }
  37. if(sqgetGlobalVar ('mailtodata', $mailtodata)) {
  38. $mailtourl = 'mailtodata='.urlencode ($mailtodata);
  39. } else {
  40. $mailtourl = '';
  41. }
  42. // this value may be changed by a plugin, but initialize
  43. // it first to avoid register_globals headaches
  44. //
  45. $right_frame_url = '';
  46. do_hook ('webmail_top');
  47. /**
  48. * We'll need this to later have a noframes version
  49. *
  50. * Check if the user has a language preference, but no cookie.
  51. * Send him a cookie with his language preference, if there is
  52. * such discrepancy.
  53. */
  54. $my_language = getPref ($data_dir, $username, 'language');
  55. if ($my_language != $squirrelmail_language) {
  56. sqsetcookie ('squirrelmail_language', $my_language, time ()+2592000, $base_uri);
  57. }
  58. set_up_language ($my_language);
  59. // prevent clickjack attempts
  60. // FIXME: should we use DENY instead? We can also make this a configurable value, including giving the admin the option of removing this entirely in case they WANT to be framed by an external domain
  61. header ('X-Frame-Options: SAMEORIGIN');
  62. global $browser_rendering_mode, $head_tag_extra;
  63. $output = ($browser_rendering_mode === 'standards' || $browser_rendering_mode === 'almost'
  64. ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
  65. : /* "quirks" */ '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">').
  66. "\n<html><head>\n"
  67. // For adding a favicon or anything else that should be inserted in *ALL* <head> for *ALL* documents,
  68. // define $head_tag_extra in config/config_local.php
  69. // The string "###SM BASEURI###" will be replaced with the base URI for this SquirrelMail installation.
  70. // When not defined, a default is provided that displays the default favicon.ico.
  71. // If you override this and still want to use the default favicon.ico, you'll have to include the following
  72. // following in your $head_tag_extra string:
  73. // $head_tag_extra = '<link rel="shortcut icon" href="###SM BASEURI###favicon.ico" />...<YOUR CONTENT HERE>...';
  74. //
  75. . (empty($head_tag_extra) ? '<link rel="shortcut icon" href="' . sqm_baseuri () . 'favicon.ico" />'
  76. : str_replace ('###SM BASEURI###', sqm_baseuri (), $head_tag_extra))
  77. // prevent clickjack attempts using JavaScript for browsers that
  78. // don't support the X-Frame-Options header...
  79. // we check to see if we are *not* the top page, and if not, check
  80. // whether or not the top page is in the same domain as we are...
  81. // if not, log out immediately -- this is an attempt to do the same
  82. // thing that the X-Frame-Options does using JavaScript (never a good
  83. // idea to rely on JavaScript-based solutions, though)
  84. . '<script type="text/javascript" language="JavaScript">'
  85. . "\n<!--\n"
  86. . 'if (self != top) { try { if (document.domain != top.document.domain) {'
  87. . ' throw "Clickjacking security violation! Please log out immediately!"; /* this code should never execute - exception should already have been thrown since it\'s a security violation in this case to even try to access top.document.domain (but it\'s left here just to be extra safe) */ } } catch (e) { self.location = "'
  88. . sqm_baseuri () . 'src/signout.php"; top.location = "'
  89. . sqm_baseuri () . 'src/signout.php" } }'
  90. . "\n// -->\n</script>\n"
  91. . "<meta name=\"robots\" content=\"noindex,nofollow\">\n"
  92. . "<title>$org_title</title>\n"
  93. . "</head>";
  94. $left_size = getPref ($data_dir, $username, 'left_size');
  95. $location_of_bar = getPref ($data_dir, $username, 'location_of_bar');
  96. if (isset($languages[$squirrelmail_language]['DIR']) &&
  97. strtolower ($languages[$squirrelmail_language]['DIR']) == 'rtl') {
  98. $temp_location_of_bar = 'right';
  99. } else {
  100. $temp_location_of_bar = 'left';
  101. }
  102. if ($location_of_bar == '') {
  103. $location_of_bar = $temp_location_of_bar;
  104. }
  105. $temp_location_of_bar = '';
  106. if ($left_size == "") {
  107. if (isset($default_left_size)) {
  108. $left_size = $default_left_size;
  109. }
  110. else {
  111. $left_size = 200;
  112. }
  113. }
  114. if ($location_of_bar == 'right') {
  115. $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
  116. }
  117. else {
  118. $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
  119. }
  120. /*
  121. * There are three ways to call webmail.php
  122. * 1. webmail.php
  123. * - This just loads the default entry screen.
  124. * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
  125. * - This loads the frames starting at the given values.
  126. * 3. webmail.php?right_frame=folders.php
  127. * - Loads the frames with the Folder options in the right frame.
  128. *
  129. * This was done to create a pure HTML way of refreshing the folder list since
  130. * we would like to use as little Javascript as possible.
  131. *
  132. * The test for // should catch any attempt to include off-site webpages into
  133. * our frameset.
  134. *
  135. * Note that plugins are allowed to completely and freely override the URI
  136. * used for the "right" (content) frame, and they do so by modifying the
  137. * global variable $right_frame_url.
  138. *
  139. */
  140. if (empty($right_frame) || (strpos (urldecode ($right_frame), '//') !== false)) {
  141. $right_frame = '';
  142. }
  143. if ( strpos ($right_frame,'?') ) {
  144. $right_frame_file = substr ($right_frame,0,strpos ($right_frame,'?'));
  145. } else {
  146. $right_frame_file = $right_frame;
  147. }
  148. if (empty($right_frame_url)) {
  149. switch($right_frame_file) {
  150. case 'right_main.php':
  151. $right_frame_url = "right_main.php?mailbox=".urlencode ($mailbox)
  152. . (!empty($sort)?"&amp;sort=$sort":'')
  153. . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
  154. break;
  155. case 'options.php':
  156. $right_frame_url = 'options.php';
  157. break;
  158. case 'folders.php':
  159. $right_frame_url = 'folders.php';
  160. break;
  161. case 'compose.php':
  162. $right_frame_url = 'compose.php?' . $mailtourl;
  163. break;
  164. case '':
  165. $right_frame_url = 'right_main.php';
  166. break;
  167. default:
  168. $right_frame_url = urlencode ($right_frame);
  169. break;
  170. }
  171. }
  172. if ($location_of_bar == 'right') {
  173. $output .= "<frame src=\"$right_frame_url\" name=\"right\" frameborder=\"1\">\n" .
  174. "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\">\n";
  175. }
  176. else {
  177. $output .= "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\">\n".
  178. "<frame src=\"$right_frame_url\" name=\"right\" frameborder=\"1\">\n";
  179. }
  180. $ret = concat_hook_function ('webmail_bottom', $output);
  181. if($ret != '') {
  182. $output = $ret;
  183. }
  184. echo $output;
  185. ?>
  186. </frameset>
  187. </html>

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

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