Show real values for error settings
[squirrelmail.git] / src / 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 &copy; 1999-2009 The SquirrelMail Project Team
31 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
32 * @version $Id$
33 * @package squirrelmail
34 */
35
36 /** This is the mailto page */
37 define('PAGE_NAME', 'mailto');
38
39 /**
40 * Include the SquirrelMail initialization file.
41 */
42 require('../include/init.php');
43
44
45 // Force users to login each time? Setting this to TRUE does NOT mean
46 // that if no user is logged in that it won't require a correct login
47 // first! Instead, setting it to TRUE will log out anyone currently
48 // logged in and force a re-login. Setting this to FALSE will still
49 // require a login if no one is logged in, but it will allow you to go
50 // directly to compose your message if you are already logged in.
51 //
52 // Note, however, that depending on how the client browser manages
53 // sessions and how the client operating system is set to handle
54 // mailto: links, you may have to log in every time no matter what
55 // (IE under WinXP appears to pop up a new window and thus always
56 // start a new session; Firefox under WinXP seems to start a new tab
57 // which will find a current login if one exists).
58 //
59 $force_login = FALSE;
60
61
62 // Open only the compose window, meaningless if $force_login is TRUE
63 //
64 $compose_only = FALSE;
65
66
67 header('Pragma: no-cache');
68
69 $trtable = array('cc' => 'cc',
70 'bcc' => 'bcc',
71 'body' => 'body',
72 'subject' => 'subject');
73 $url = '';
74
75 $data = array();
76
77 if (sqgetGlobalVar('emailaddress', $emailaddress)) {
78 $emailaddress = trim($emailaddress);
79 if (stristr($emailaddress, 'mailto:')) {
80 $emailaddress = substr($emailaddress, 7);
81 }
82 if (strpos($emailaddress, '?') !== FALSE) {
83 list($emailaddress, $a) = explode('?', $emailaddress, 2);
84 if (strlen(trim($a)) > 0) {
85 $a = explode('=', $a, 2);
86 $data[strtolower($a[0])] = $a[1];
87 }
88 }
89 $data['to'] = $emailaddress;
90
91 /* CC, BCC, etc could be any case, so we'll fix them here */
92 foreach($_GET as $k=>$g) {
93 $k = strtolower($k);
94 if (isset($trtable[$k])) {
95 $k = $trtable[$k];
96 $data[$k] = $g;
97 }
98 }
99 }
100 sqsession_is_active();
101
102 if (!$force_login && sqsession_is_registered('user_is_logged_in')) {
103 if ($compose_only) {
104 $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data));
105 } else {
106 $redirect = 'webmail.php?right_frame=compose.php&mailtodata=' . urlencode(serialize($data));
107 }
108 } else {
109 $redirect = 'login.php?mailtodata=' . urlencode(serialize($data));
110 }
111
112 session_write_close();
113 header('Location: ' . get_location() . '/' . $redirect);