Update
[squirrelmail.git] / src / mailto.php
CommitLineData
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 21define('SM_PATH','../');
22
23/* SquirrelMail required files. */
24require_once(SM_PATH . 'config/config.php');
25require_once(SM_PATH . 'functions/global.php');
3ae35858 26require_once(SM_PATH . 'functions/strings.php');
c67e4479 27
28header('Pragma: no-cache');
29if(!sqgetGlobalVar('emailaddress', $emailaddress)) {
30 return;
31}
32
609999ad 33$mailto_pos = strpos(strtolower($emailaddress), 'mailto:');
34if($mailto_pos !== false) {
35 $emailaddress = substr($emailaddress, $mailto_pos+7);
36 $_GET['emailaddress'] = $emailaddress;
c67e4479 37}
38if(($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}
c67e4479 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 */
52foreach($_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
61sqsession_is_active();
62/* Check to see if we're logged in */
63/*
64if (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;
73session_write_close();
3ae35858 74header('Location: ' . get_location() . '/' . $redirect);
75
76?>