c67e4479 |
1 | <?php |
2 | |
3 | /** |
4 | * mailto.php -- mailto: url handler |
5 | * |
f0d28f44 |
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. |
c67e4479 |
29 | * |
4b5049de |
30 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
31 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
32 | * @version $Id$ |
8f6f9ba5 |
33 | * @package squirrelmail |
c67e4479 |
34 | */ |
35 | |
ebd2391c |
36 | /** This is the mailto page */ |
37 | define('PAGE_NAME', 'mailto'); |
38 | |
30967a1e |
39 | /** |
202bcbcc |
40 | * Include the SquirrelMail initialization file. |
30967a1e |
41 | */ |
202bcbcc |
42 | require('../include/init.php'); |
c67e4479 |
43 | |
f0d28f44 |
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 | |
d69119eb |
66 | |
c67e4479 |
67 | header('Pragma: no-cache'); |
c67e4479 |
68 | |
f0d28f44 |
69 | $trtable = array('cc' => 'cc', |
70 | 'bcc' => 'bcc', |
c67e4479 |
71 | 'body' => 'body', |
72 | 'subject' => 'subject'); |
73 | $url = ''; |
d69119eb |
74 | |
7e2ff844 |
75 | $data = array(); |
76 | |
f0d28f44 |
77 | if (sqgetGlobalVar('emailaddress', $emailaddress)) { |
d69119eb |
78 | $emailaddress = trim($emailaddress); |
f0d28f44 |
79 | if (stristr($emailaddress, 'mailto:')) { |
d69119eb |
80 | $emailaddress = substr($emailaddress, 7); |
81 | } |
f0d28f44 |
82 | if (strpos($emailaddress, '?') !== FALSE) { |
d69119eb |
83 | list($emailaddress, $a) = explode('?', $emailaddress, 2); |
f0d28f44 |
84 | if (strlen(trim($a)) > 0) { |
d69119eb |
85 | $a = explode('=', $a, 2); |
7e2ff844 |
86 | $data[strtolower($a[0])] = $a[1]; |
d69119eb |
87 | } |
88 | } |
7e2ff844 |
89 | $data['to'] = $emailaddress; |
d69119eb |
90 | |
91 | /* CC, BCC, etc could be any case, so we'll fix them here */ |
92 | foreach($_GET as $k=>$g) { |
c67e4479 |
93 | $k = strtolower($k); |
f0d28f44 |
94 | if (isset($trtable[$k])) { |
d69119eb |
95 | $k = $trtable[$k]; |
7e2ff844 |
96 | $data[$k] = $g; |
d69119eb |
97 | } |
c67e4479 |
98 | } |
99 | } |
7e2ff844 |
100 | sqsession_is_active(); |
d69119eb |
101 | |
f0d28f44 |
102 | if (!$force_login && sqsession_is_registered('user_is_logged_in')) { |
103 | if ($compose_only) { |
7e2ff844 |
104 | $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data)); |
d69119eb |
105 | } else { |
f0d28f44 |
106 | $redirect = 'webmail.php?right_frame=compose.php&mailtodata=' . urlencode(serialize($data)); |
d69119eb |
107 | } |
c67e4479 |
108 | } else { |
7e2ff844 |
109 | $redirect = 'login.php?mailtodata=' . urlencode(serialize($data)); |
c67e4479 |
110 | } |
d69119eb |
111 | |
c67e4479 |
112 | session_write_close(); |
3ae35858 |
113 | header('Location: ' . get_location() . '/' . $redirect); |