X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fmailto.php;h=94a8e7261006309d7718154388ee28e817bed574;hb=e04de0b9d163343c246f327b27edbd307a9a1029;hp=1a4098487a9171562e63b03a501de36eb362a9bb;hpb=d7746ca528435f81ef08a354eb5c2399a27b15cc;p=squirrelmail.git diff --git a/src/mailto.php b/src/mailto.php index 1a409848..94a8e726 100644 --- a/src/mailto.php +++ b/src/mailto.php @@ -3,71 +3,81 @@ /** * mailto.php -- mailto: url handler * - * Copyright (c) 1999-2003 The SquirrelMail Project Team - * Licensed under the GNU GPL. For full terms see the file COPYING. - * * This checks to see if we're logged in. If we are we open up a new * compose window for this email, otherwise we go to login.php * (the above functionality has been disabled, by default you are required to * login first) * * Use the following url to use mailto: - * http:////src/mailto.php?emailaddress="%1" + * http:////src/mailto.php?emailaddress=%1 * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file + * @copyright © 1999-2007 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package squirrelmail */ -/* Path for SquirrelMail required files. */ -define('SM_PATH','../'); +/** This is the mailto page */ +define('PAGE_NAME', 'mailto'); + +// reduce the included files in int.php +$bLogin = true; + +/** + * Include the SquirrelMail initialization file. + */ +require('../include/init.php'); -/* SquirrelMail required files. */ -require_once(SM_PATH . 'config/config.php'); -require_once(SM_PATH . 'functions/global.php'); +/* Force users to login each time? */ +$force_login = true; +/* Open only the compose window, meaningless if $force_login is true */ +$compose_only = false; header('Pragma: no-cache'); -if(!sqgetGlobalVar('emailaddress', $emailaddress)) { - return; -} -$mailto_pos = strpos(strtolower($emailaddress), 'mailto:'); -if($mailto_pos !== false) { - $emailaddress = substr($emailaddress, $mailto_pos+7); - $_GET['emailaddress'] = $emailaddress; -} -if(($pos = strpos($emailaddress, '?')) !== false) { - $a = substr($emailaddress, $pos+1); - list($emailaddress, $a) = explode('?', $emailaddress, 2); - $a = explode('=', $a, 2); - $_GET['emailaddress'] = $emailaddress; - $_GET[$a[0]] = $a[1]; -} -$trtable = array('emailaddress' => 'send_to', - 'cc' => 'send_to_cc', +$trtable = array('cc' => 'send_to_cc', 'bcc' => 'send_to_bcc', 'body' => 'body', 'subject' => 'subject'); $url = ''; -/* CC, BCC, etc could be any case, so we'll fix them here */ -foreach($_GET as $k=>$g) { - if($g != '') { + +$data = array(); + +if(sqgetGlobalVar('emailaddress', $emailaddress)) { + $emailaddress = trim($emailaddress); + if(stristr($emailaddress, 'mailto:')) { + $emailaddress = substr($emailaddress, 7); + } + if(strpos($emailaddress, '?') !== false) { + list($emailaddress, $a) = explode('?', $emailaddress, 2); + if(strlen(trim($a)) > 0) { + $a = explode('=', $a, 2); + $data[strtolower($a[0])] = $a[1]; + } + } + $data['to'] = $emailaddress; + + /* CC, BCC, etc could be any case, so we'll fix them here */ + foreach($_GET as $k=>$g) { $k = strtolower($k); - $k = $trtable[$k]; - $url .= $k . '=' . urlencode($g) . '&'; + if(isset($trtable[$k])) { + $k = $trtable[$k]; + $data[$k] = $g; + } } } -$url = substr($url, 0, -1); - sqsession_is_active(); -/* Check to see if we're logged in */ -/* -if (sqsession_is_registered('user_is_logged_in')) { - $redirect = 'webmail.php?right_frame=compose.php?'; + +if($force_login == false && sqsession_is_registered('user_is_logged_in')) { + if($compose_only == true) { + $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data)); + } else { + $redirect = 'webmail.php?mailtodata=' . urlencode(serialize($data)); + } } else { - $redirect = 'login.php?mailto='; + $redirect = 'login.php?mailtodata=' . urlencode(serialize($data)); } -*/ -$url = urlencode($url); -/* $redirect .= $url; */ -$redirect = 'login.php?mailto=' . $url; + session_write_close(); -header('Location: ' .get_location(). $redirect); -?> +header('Location: ' . get_location() . '/' . $redirect); +