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