c67e4479 |
1 | <?php |
2 | |
3 | /** |
4 | * mailto.php -- mailto: url handler |
5 | * |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This checks to see if we're logged in. If we are we open up a new |
10 | * compose window for this email, otherwise we go to login.php |
11 | * (the above functionality has been disabled, by default you are required to |
12 | * login first) |
13 | * |
14 | * Use the following url to use mailto: |
15 | * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress="%1" |
16 | * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file |
8f6f9ba5 |
17 | * @package squirrelmail |
c67e4479 |
18 | */ |
19 | |
8f6f9ba5 |
20 | /** Path for SquirrelMail required files. */ |
c67e4479 |
21 | define('SM_PATH','../'); |
22 | |
23 | /* SquirrelMail required files. */ |
24 | require_once(SM_PATH . 'config/config.php'); |
25 | require_once(SM_PATH . 'functions/global.php'); |
26 | |
27 | header('Pragma: no-cache'); |
28 | if(!sqgetGlobalVar('emailaddress', $emailaddress)) { |
29 | return; |
30 | } |
31 | |
609999ad |
32 | $mailto_pos = strpos(strtolower($emailaddress), 'mailto:'); |
33 | if($mailto_pos !== false) { |
34 | $emailaddress = substr($emailaddress, $mailto_pos+7); |
35 | $_GET['emailaddress'] = $emailaddress; |
c67e4479 |
36 | } |
37 | if(($pos = strpos($emailaddress, '?')) !== false) { |
38 | $a = substr($emailaddress, $pos+1); |
39 | list($emailaddress, $a) = explode('?', $emailaddress, 2); |
40 | $a = explode('=', $a, 2); |
41 | $_GET['emailaddress'] = $emailaddress; |
42 | $_GET[$a[0]] = $a[1]; |
43 | } |
c67e4479 |
44 | $trtable = array('emailaddress' => 'send_to', |
45 | 'cc' => 'send_to_cc', |
46 | 'bcc' => 'send_to_bcc', |
47 | 'body' => 'body', |
48 | 'subject' => 'subject'); |
49 | $url = ''; |
50 | /* CC, BCC, etc could be any case, so we'll fix them here */ |
51 | foreach($_GET as $k=>$g) { |
52 | if($g != '') { |
53 | $k = strtolower($k); |
54 | $k = $trtable[$k]; |
55 | $url .= $k . '=' . urlencode($g) . '&'; |
56 | } |
57 | } |
58 | $url = substr($url, 0, -1); |
59 | |
60 | sqsession_is_active(); |
61 | /* Check to see if we're logged in */ |
62 | /* |
63 | if (sqsession_is_registered('user_is_logged_in')) { |
64 | $redirect = 'webmail.php?right_frame=compose.php?'; |
65 | } else { |
66 | $redirect = 'login.php?mailto='; |
67 | } |
68 | */ |
69 | $url = urlencode($url); |
70 | /* $redirect .= $url; */ |
71 | $redirect = 'login.php?mailto=' . $url; |
72 | session_write_close(); |
d7746ca5 |
73 | header('Location: ' .get_location(). $redirect); |
c67e4479 |
74 | ?> |