| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * mailto.php -- mailto: url handler |
| 5 | * |
| 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: |
| 12 | * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress=%1 |
| 13 | * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file |
| 14 | * @copyright © 1999-2006 The SquirrelMail Project Team |
| 15 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 16 | * @version $Id$ |
| 17 | * @package squirrelmail |
| 18 | */ |
| 19 | |
| 20 | // reduce the included files in int.php |
| 21 | $bLogin = true; |
| 22 | |
| 23 | /** |
| 24 | * Include the SquirrelMail initialization file. |
| 25 | */ |
| 26 | require('../include/init.php'); |
| 27 | |
| 28 | /* Force users to login each time? */ |
| 29 | $force_login = true; |
| 30 | /* Open only the compose window, meaningless if $force_login is true */ |
| 31 | $compose_only = false; |
| 32 | |
| 33 | header('Pragma: no-cache'); |
| 34 | |
| 35 | $trtable = array('cc' => 'send_to_cc', |
| 36 | 'bcc' => 'send_to_bcc', |
| 37 | 'body' => 'body', |
| 38 | 'subject' => 'subject'); |
| 39 | $url = ''; |
| 40 | |
| 41 | $data = array(); |
| 42 | |
| 43 | if(sqgetGlobalVar('emailaddress', $emailaddress)) { |
| 44 | $emailaddress = trim($emailaddress); |
| 45 | if(stristr($emailaddress, 'mailto:')) { |
| 46 | $emailaddress = substr($emailaddress, 7); |
| 47 | } |
| 48 | if(strpos($emailaddress, '?') !== false) { |
| 49 | list($emailaddress, $a) = explode('?', $emailaddress, 2); |
| 50 | if(strlen(trim($a)) > 0) { |
| 51 | $a = explode('=', $a, 2); |
| 52 | $data[strtolower($a[0])] = $a[1]; |
| 53 | } |
| 54 | } |
| 55 | $data['to'] = $emailaddress; |
| 56 | |
| 57 | /* CC, BCC, etc could be any case, so we'll fix them here */ |
| 58 | foreach($_GET as $k=>$g) { |
| 59 | $k = strtolower($k); |
| 60 | if(isset($trtable[$k])) { |
| 61 | $k = $trtable[$k]; |
| 62 | $data[$k] = $g; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | sqsession_is_active(); |
| 67 | |
| 68 | if($force_login == false && sqsession_is_registered('user_is_logged_in')) { |
| 69 | if($compose_only == true) { |
| 70 | $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data)); |
| 71 | } else { |
| 72 | $redirect = 'webmail.php?mailtodata=' . urlencode(serialize($data)); |
| 73 | } |
| 74 | } else { |
| 75 | $redirect = 'login.php?mailtodata=' . urlencode(serialize($data)); |
| 76 | } |
| 77 | |
| 78 | session_write_close(); |
| 79 | header('Location: ' . get_location() . '/' . $redirect); |
| 80 | |
| 81 | ?> |