c67e4479 |
1 | <?php |
2 | |
3 | /** |
4 | * mailto.php -- mailto: url handler |
5 | * |
c67e4479 |
6 | * This checks to see if we're logged in. If we are we open up a new |
7 | * compose window for this email, otherwise we go to login.php |
8 | * (the above functionality has been disabled, by default you are required to |
9 | * login first) |
10 | * |
11 | * Use the following url to use mailto: |
d69119eb |
12 | * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress=%1 |
c67e4479 |
13 | * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file |
4b5049de |
14 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
15 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
16 | * @version $Id$ |
8f6f9ba5 |
17 | * @package squirrelmail |
c67e4479 |
18 | */ |
19 | |
ebd2391c |
20 | /** This is the mailto page */ |
21 | define('PAGE_NAME', 'mailto'); |
22 | |
202bcbcc |
23 | // reduce the included files in int.php |
24 | $bLogin = true; |
25 | |
30967a1e |
26 | /** |
202bcbcc |
27 | * Include the SquirrelMail initialization file. |
30967a1e |
28 | */ |
202bcbcc |
29 | require('../include/init.php'); |
c67e4479 |
30 | |
d69119eb |
31 | /* Force users to login each time? */ |
32 | $force_login = true; |
33 | /* Open only the compose window, meaningless if $force_login is true */ |
34 | $compose_only = false; |
35 | |
c67e4479 |
36 | header('Pragma: no-cache'); |
c67e4479 |
37 | |
d69119eb |
38 | $trtable = array('cc' => 'send_to_cc', |
c67e4479 |
39 | 'bcc' => 'send_to_bcc', |
40 | 'body' => 'body', |
41 | 'subject' => 'subject'); |
42 | $url = ''; |
d69119eb |
43 | |
7e2ff844 |
44 | $data = array(); |
45 | |
d69119eb |
46 | if(sqgetGlobalVar('emailaddress', $emailaddress)) { |
47 | $emailaddress = trim($emailaddress); |
48 | if(stristr($emailaddress, 'mailto:')) { |
49 | $emailaddress = substr($emailaddress, 7); |
50 | } |
51 | if(strpos($emailaddress, '?') !== false) { |
52 | list($emailaddress, $a) = explode('?', $emailaddress, 2); |
53 | if(strlen(trim($a)) > 0) { |
54 | $a = explode('=', $a, 2); |
7e2ff844 |
55 | $data[strtolower($a[0])] = $a[1]; |
d69119eb |
56 | } |
57 | } |
7e2ff844 |
58 | $data['to'] = $emailaddress; |
d69119eb |
59 | |
60 | /* CC, BCC, etc could be any case, so we'll fix them here */ |
61 | foreach($_GET as $k=>$g) { |
c67e4479 |
62 | $k = strtolower($k); |
d69119eb |
63 | if(isset($trtable[$k])) { |
64 | $k = $trtable[$k]; |
7e2ff844 |
65 | $data[$k] = $g; |
d69119eb |
66 | } |
c67e4479 |
67 | } |
68 | } |
7e2ff844 |
69 | sqsession_is_active(); |
d69119eb |
70 | |
71 | if($force_login == false && sqsession_is_registered('user_is_logged_in')) { |
72 | if($compose_only == true) { |
7e2ff844 |
73 | $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data)); |
d69119eb |
74 | } else { |
7e2ff844 |
75 | $redirect = 'webmail.php?mailtodata=' . urlencode(serialize($data)); |
d69119eb |
76 | } |
c67e4479 |
77 | } else { |
7e2ff844 |
78 | $redirect = 'login.php?mailtodata=' . urlencode(serialize($data)); |
c67e4479 |
79 | } |
d69119eb |
80 | |
c67e4479 |
81 | session_write_close(); |
3ae35858 |
82 | header('Location: ' . get_location() . '/' . $redirect); |
a2b193bc |
83 | |