b921e852752d5ab2ec188fc7a2ad8e1bb41838e5
[squirrelmail.git] / src / mailto.php
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
17 * @package squirrelmail
18 */
19
20 /** Path for SquirrelMail required files. */
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 require_once(SM_PATH . 'functions/strings.php');
27
28 header('Pragma: no-cache');
29 if(!sqgetGlobalVar('emailaddress', $emailaddress)) {
30 return;
31 }
32
33 $mailto_pos = strpos(strtolower($emailaddress), 'mailto:');
34 if($mailto_pos !== false) {
35 $emailaddress = substr($emailaddress, $mailto_pos+7);
36 $_GET['emailaddress'] = $emailaddress;
37 }
38 if(($pos = strpos($emailaddress, '?')) !== false) {
39 $a = substr($emailaddress, $pos+1);
40 list($emailaddress, $a) = explode('?', $emailaddress, 2);
41 $a = explode('=', $a, 2);
42 $_GET['emailaddress'] = $emailaddress;
43 $_GET[$a[0]] = $a[1];
44 }
45 $trtable = array('emailaddress' => 'send_to',
46 'cc' => 'send_to_cc',
47 'bcc' => 'send_to_bcc',
48 'body' => 'body',
49 'subject' => 'subject');
50 $url = '';
51 /* CC, BCC, etc could be any case, so we'll fix them here */
52 foreach($_GET as $k=>$g) {
53 if($g != '') {
54 $k = strtolower($k);
55 $k = $trtable[$k];
56 $url .= $k . '=' . urlencode($g) . '&';
57 }
58 }
59 $url = substr($url, 0, -1);
60
61 sqsession_is_active();
62 /* Check to see if we're logged in */
63 /*
64 if (sqsession_is_registered('user_is_logged_in')) {
65 $redirect = 'webmail.php?right_frame=compose.php?';
66 } else {
67 $redirect = 'login.php?mailto=';
68 }
69 */
70 $url = urlencode($url);
71 /* $redirect .= $url; */
72 $redirect = 'login.php?mailto=' . $url;
73 session_write_close();
74 header('Location: ' . get_location() . '/' . $redirect);
75
76 ?>