phpDocumentor updates
[squirrelmail.git] / src / mailto.php
CommitLineData
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
4b4abf93 14 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
15 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 16 * @version $Id$
8f6f9ba5 17 * @package squirrelmail
c67e4479 18 */
19
30967a1e 20/**
21 * Path for SquirrelMail required files.
22 * @ignore
23 */
c67e4479 24define('SM_PATH','../');
25
26/* SquirrelMail required files. */
27require_once(SM_PATH . 'config/config.php');
28require_once(SM_PATH . 'functions/global.php');
3ae35858 29require_once(SM_PATH . 'functions/strings.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 36header('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
44if(sqgetGlobalVar('emailaddress', $emailaddress)) {
45 $emailaddress = trim($emailaddress);
46 if(stristr($emailaddress, 'mailto:')) {
47 $emailaddress = substr($emailaddress, 7);
48 }
49 if(strpos($emailaddress, '?') !== false) {
50 list($emailaddress, $a) = explode('?', $emailaddress, 2);
51 if(strlen(trim($a)) > 0) {
52 $a = explode('=', $a, 2);
53 $url .= $trtable[strtolower($a[0])] . '=' . urlencode($a[1]) . '&';
54 }
55 }
56 $url = 'send_to=' . urlencode($emailaddress) . '&' . $url;
57
58 /* CC, BCC, etc could be any case, so we'll fix them here */
59 foreach($_GET as $k=>$g) {
c67e4479 60 $k = strtolower($k);
d69119eb 61 if(isset($trtable[$k])) {
62 $k = $trtable[$k];
63 $url .= $k . '=' . urlencode($g) . '&';
64 }
c67e4479 65 }
d69119eb 66 $url = substr($url, 0, -1);
c67e4479 67}
c67e4479 68sqsession_is_active();
d69119eb 69
70if($force_login == false && sqsession_is_registered('user_is_logged_in')) {
71 if($compose_only == true) {
72 $redirect = 'compose.php?' . $url;
73 } else {
74 $redirect = 'webmail.php?right_frame=compose.php?' . urlencode($url);
75 }
c67e4479 76} else {
d69119eb 77 $redirect = 'login.php?mailto=' . urlencode($url);
c67e4479 78}
d69119eb 79
c67e4479 80session_write_close();
3ae35858 81header('Location: ' . get_location() . '/' . $redirect);
a2b193bc 82
134e4174 83?>