add PAGE_NAME constant to every page under src/.
[squirrelmail.git] / src / mailto.php
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 &copy; 1999-2007 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 /** This is the mailto page */
21 define('PAGE_NAME', 'mailto');
22
23 // reduce the included files in int.php
24 $bLogin = true;
25
26 /**
27 * Include the SquirrelMail initialization file.
28 */
29 require('../include/init.php');
30
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
36 header('Pragma: no-cache');
37
38 $trtable = array('cc' => 'send_to_cc',
39 'bcc' => 'send_to_bcc',
40 'body' => 'body',
41 'subject' => 'subject');
42 $url = '';
43
44 $data = array();
45
46 if(sqgetGlobalVar('emailaddress', $emailaddress)) {
47 $emailaddress = trim($emailaddress);
48 if(stristr($emailaddress, 'mailto:')) {
49 $emailaddress = substr($emailaddress, 7);
50 }
51 if(strpos($emailaddress, '?') !== false) {
52 list($emailaddress, $a) = explode('?', $emailaddress, 2);
53 if(strlen(trim($a)) > 0) {
54 $a = explode('=', $a, 2);
55 $data[strtolower($a[0])] = $a[1];
56 }
57 }
58 $data['to'] = $emailaddress;
59
60 /* CC, BCC, etc could be any case, so we'll fix them here */
61 foreach($_GET as $k=>$g) {
62 $k = strtolower($k);
63 if(isset($trtable[$k])) {
64 $k = $trtable[$k];
65 $data[$k] = $g;
66 }
67 }
68 }
69 sqsession_is_active();
70
71 if($force_login == false && sqsession_is_registered('user_is_logged_in')) {
72 if($compose_only == true) {
73 $redirect = 'compose.php?mailtodata=' . urlencode(serialize($data));
74 } else {
75 $redirect = 'webmail.php?mailtodata=' . urlencode(serialize($data));
76 }
77 } else {
78 $redirect = 'login.php?mailtodata=' . urlencode(serialize($data));
79 }
80
81 session_write_close();
82 header('Location: ' . get_location() . '/' . $redirect);
83