| 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. */ |
| 20 | define('SM_PATH','../'); |
| 21 | |
| 22 | /* SquirrelMail required files. */ |
| 23 | require_once(SM_PATH . 'config/config.php'); |
| 24 | require_once(SM_PATH . 'functions/global.php'); |
| 25 | |
| 26 | header('Pragma: no-cache'); |
| 27 | if(!sqgetGlobalVar('emailaddress', $emailaddress)) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | $mailto_pos = strpos(strtolower($emailaddress), 'mailto:'); |
| 32 | if($mailto_pos !== false) { |
| 33 | $emailaddress = substr($emailaddress, $mailto_pos+7); |
| 34 | $_GET['emailaddress'] = $emailaddress; |
| 35 | } |
| 36 | if(($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 | } |
| 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 */ |
| 50 | foreach($_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 | |
| 59 | sqsession_is_active(); |
| 60 | /* Check to see if we're logged in */ |
| 61 | /* |
| 62 | if (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; |
| 71 | session_write_close(); |
| 72 | header('Location: ' .get_location(). $redirect); |
| 73 | ?> |