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 &copy; 1999-2006 The SquirrelMail Project Team
  11.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  12.  * @version $Id: webmail.php,v 1.92.2.19 2006/08/03 14:48:09 kink Exp $
  13.  * @package squirrelmail
  14.  */
  15.  
  16. /**
  17.  * Path for SquirrelMail required files.
  18.  * @ignore
  19.  */
  20. define('SM_PATH','../');
  21.  
  22. /* SquirrelMail required files. */
  23. require_once(SM_PATH . 'functions/global.php');
  24. require_once(SM_PATH . 'functions/strings.php');
  25. require_once(SM_PATH . 'config/config.php');
  26. require_once(SM_PATH . 'functions/prefs.php');
  27. require_once(SM_PATH . 'functions/imap.php');
  28. require_once(SM_PATH . 'functions/plugin.php');
  29. require_once(SM_PATH . 'functions/i18n.php');
  30. require_once(SM_PATH . 'functions/auth.php');
  31.  
  32. if (!function_exists('sqm_baseuri')){
  33.     require_once(SM_PATH . 'functions/display_messages.php');
  34. }
  35. $base_uri = sqm_baseuri();
  36.  
  37.  
  38. sqgetGlobalVar('username', $username, SQ_SESSION);
  39. sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
  40. sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
  41. sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
  42. if (sqgetGlobalVar('sort', $sort)) {
  43.     $sort = (int) $sort;
  44. }
  45.  
  46. if (sqgetGlobalVar('startMessage', $startMessage)) {
  47.     $startMessage = (int) $startMessage;
  48. }
  49.  
  50. if (!sqgetGlobalVar('mailbox', $mailbox)) {
  51.     $mailbox = 'INBOX';
  52. }
  53.  
  54. if(!sqgetGlobalVar('mailto', $mailto)) {
  55.     $mailto = '';
  56. }
  57.  
  58.  
  59.  
  60. do_hook('webmail_top');
  61.  
  62. /**
  63.  * We'll need this to later have a noframes version
  64.  *
  65.  * Check if the user has a language preference, but no cookie.
  66.  * Send him a cookie with his language preference, if there is
  67.  * such discrepancy.
  68.  */
  69. $my_language = getPref($data_dir, $username, 'language');
  70. if ($my_language != $squirrelmail_language) {
  71.     setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
  72. }
  73.  
  74. set_up_language(getPref($data_dir, $username, 'language'));
  75.  
  76. $output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
  77.           "<html><head>\n" .
  78.           "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
  79.           "<title>$org_title</title>\n".
  80.           "</head>";
  81.  
  82. $left_size = getPref($data_dir, $username, 'left_size');
  83. $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
  84.  
  85. if (isset($languages[$squirrelmail_language]['DIR']) &&
  86.     strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
  87.     $temp_location_of_bar = 'right';
  88. } else {
  89.     $temp_location_of_bar = 'left';
  90. }
  91.  
  92. if ($location_of_bar == '') {
  93.     $location_of_bar = $temp_location_of_bar;
  94. }
  95. $temp_location_of_bar = '';
  96.  
  97. if ($left_size == "") {
  98.     if (isset($default_left_size)) {
  99.          $left_size = $default_left_size;
  100.     }
  101.     else {
  102.         $left_size = 200;
  103.     }
  104. }
  105.  
  106. if ($location_of_bar == 'right') {
  107.     $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
  108. }
  109. else {
  110.     $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
  111. }
  112.  
  113. /*
  114.  * There are three ways to call webmail.php
  115.  * 1.  webmail.php
  116.  *      - This just loads the default entry screen.
  117.  * 2.  webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
  118.  *      - This loads the frames starting at the given values.
  119.  * 3.  webmail.php?right_frame=folders.php
  120.  *      - Loads the frames with the Folder options in the right frame.
  121.  *
  122.  * This was done to create a pure HTML way of refreshing the folder list since
  123.  * we would like to use as little Javascript as possible.
  124.  *
  125.  * The test for // should catch any attempt to include off-site webpages into
  126.  * our frameset.
  127.  */
  128.  
  129. if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
  130.     $right_frame = '';
  131. }
  132.  
  133. if ( strpos($right_frame,'?') ) {
  134.     $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
  135. } else {
  136.     $right_frame_file = $right_frame;
  137. }
  138.  
  139. switch($right_frame_file) {
  140.     case 'right_main.php':
  141.         $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
  142.                        . (!empty($sort)?"&amp;sort=$sort":'')
  143.                        . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
  144.         break;
  145.     case 'options.php':
  146.         $right_frame_url = 'options.php';
  147.         break;
  148.     case 'folders.php':
  149.         $right_frame_url = 'folders.php';
  150.         break;
  151.     case 'compose.php':
  152.         $right_frame_url = 'compose.php?' . $mailto;
  153.         break;
  154.     case '':
  155.         $right_frame_url = 'right_main.php';
  156.         break;
  157.     default:
  158.         $right_frame_url =  urlencode($right_frame);
  159.         break;
  160. } 
  161.  
  162. if ($location_of_bar == 'right') {
  163.     $output .= "<frame src=\"$right_frame_url\" name=\"right\" frameborder=\"1\" />\n" .
  164.                "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\" />\n";
  165. }
  166. else {
  167.     $output .= "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\" />\n".
  168.                "<frame src=\"$right_frame_url\" name=\"right\" frameborder=\"1\" />\n";
  169. }
  170. $ret = concat_hook_function('webmail_bottom', $output);
  171. if($ret != '') {
  172.     $output = $ret;
  173. }
  174. echo $output;
  175. ?>
  176. </frameset>
  177. </html>

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