Source for file mailto.php

Documentation is available at mailto.php

  1. <?php
  2.  
  3. /**
  4.  * mailto.php -- mailto: url handler
  5.  *
  6.  * This page facilitates handling mailto: links in SquirrelMail.  It checks
  7.  * to see if we're logged in, and if we are, it refers the user to the
  8.  * compose screen (embedded in a normal, full SquirrelMail interface) with
  9.  * the mailto: data auto-populated in the corresponding fields.  If there
  10.  * is no user currently logged in, the user is redirected to the login screen
  11.  * first, but after login, the compose screen is shown with the correct
  12.  * fields pre-populated.
  13.  *
  14.  * If the administrator desires, $compose_only can be set to TRUE, in which
  15.  * case only a compose screen will show, not embedded in the normal
  16.  * SquirrelMail interface.
  17.  *
  18.  * If the administrator wants to force a re-login every time a mailto: link
  19.  * is clicked on (no matter if a user was already logged in), set $force_login
  20.  * to TRUE.
  21.  *
  22.  * Use the following URI when configuring a computer to handle mailto: links
  23.  * by using SquirrelMail:
  24.  *
  25.  *  http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress=%1
  26.  *
  27.  * see ../contrib/squirrelmail.mailto.NT2KXP.reg for a Windows Registry file
  28.  * that will set this up in the most robust manner.
  29.  *
  30.  * @copyright 1999-2020 The SquirrelMail Project Team
  31.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  32.  * @version $Id: mailto.php 14840 2020-01-07 07:42:38Z pdontthink $
  33.  * @package squirrelmail
  34.  */
  35.  
  36. /** This is the mailto page */
  37. define('PAGE_NAME''mailto');
  38.  
  39. /**
  40.  * Path for SquirrelMail required files.
  41.  * @ignore
  42.  */
  43. define('SM_PATH','../');
  44.  
  45. /* SquirrelMail required files. */
  46. require_once(SM_PATH 'functions/global.php');
  47.  
  48.  
  49. // Force users to login each time?  Setting this to TRUE does NOT mean 
  50. // that if no user is logged in that it won't require a correct login 
  51. // first!  Instead, setting it to TRUE will log out anyone currently
  52. // logged in and force a re-login.  Setting this to FALSE will still
  53. // require a login if no one is logged in, but it will allow you to go
  54. // directly to compose your message if you are already logged in.  
  55. //
  56. // Note, however, that depending on how the client browser manages 
  57. // sessions and how the client operating system is set to handle 
  58. // mailto: links, you may have to log in every time no matter what
  59. // (IE under WinXP appears to pop up a new window and thus always 
  60. // start a new session; Firefox under WinXP seems to start a new tab 
  61. // which will find a current login if one exists). 
  62. //
  63. $force_login FALSE;
  64.  
  65.  
  66. // Open only the compose window, meaningless if $force_login is TRUE
  67. //
  68. $compose_only FALSE;
  69.  
  70.  
  71. // Disable Browser Caching
  72. //
  73. header('Cache-Control: no-cache, no-store, must-revalidate');
  74. header('Pragma: no-cache');
  75. header('Expires: Sat, 1 Jan 2000 00:00:00 GMT');
  76.  
  77. $trtable array('cc'           => 'cc',
  78.                  'bcc'          => 'bcc',
  79.                  'body'         => 'body',
  80.                  'subject'      => 'subject');
  81. $url '';
  82.  
  83. $data array();
  84.  
  85. if (sqgetGlobalVar('emailaddress'$emailaddress)) {
  86.     $emailaddress trim($emailaddress);
  87.     if (stristr($emailaddress'mailto:')) {
  88.         $emailaddress substr($emailaddress7);
  89.     }
  90.     if (strpos($emailaddress'?'!== FALSE{
  91.         list($emailaddress$aexplode('?'$emailaddress2);
  92.         if (strlen(trim($a)) 0{
  93.             $a explode('='$a2);
  94.             $data[strtolower($a[0])$a[1];
  95.         }
  96.     }
  97.     $data['to'$emailaddress;
  98.  
  99.     /* CC, BCC, etc could be any case, so we'll fix them here */
  100.     foreach($_GET as $k=>$g{
  101.         $k strtolower($k);
  102.         if (isset($trtable[$k])) {
  103.             $k $trtable[$k];
  104.             $data[$k$g;
  105.         }
  106.     }
  107. }
  108.  
  109. if (!$force_login && sqsession_is_registered('user_is_logged_in')) {
  110.     if ($compose_only{
  111.         $redirect 'compose.php?mailtodata=' urlencode(serialize($data));
  112.     else {
  113.         $redirect 'webmail.php?right_frame=compose.php&mailtodata=' urlencode(serialize($data));
  114.     }
  115. else {
  116.     $redirect 'login.php?mailtodata=' urlencode(serialize($data));
  117. }
  118.  
  119. header('Location: ' get_location('/' $redirect);

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