Source for file webmail.php

Documentation is available at webmail.php

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

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