3 * Send an Email Message Page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2010 (c) Franck Villaume
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once './env.inc.php';
27 require_once $gfcommon.'include/pre.php';
29 $toaddress = getStringFromRequest('toaddress');
30 $touser = getStringFromRequest('touser');
32 if (!$toaddress && !$touser) {
33 exit_missing_param('',array(_('toaddress'),_('touser')),'home');
38 check to see if that user even exists
39 Get their name and email if it does
41 $result=db_query_params ('SELECT email,user_name FROM users WHERE user_id=$1',
44 if (!$result || db_numrows($result) < 1) {
45 exit_error(_('That user does not exist'),'home');
49 if ($toaddress && !preg_match('/'.forge_get_config('web_host').'/i',$toaddress)) {
50 exit_error(sprintf(_('You can only send to addresses @<em>%1$s</em>.'),forge_get_config('web_host')),'home');
54 if (getStringFromRequest('send_mail')) {
55 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
56 exit_form_double_submit('home');
59 $subject = getStringFromRequest('subject');
60 $body = getStringFromRequest('body');
61 $name = getStringFromRequest('name');
62 $email = getStringFromRequest('email');
64 if (!$subject || !$body || !$name || !$email) {
66 force them to enter all vars
68 form_release_key(getStringFromRequest('form_key'));
69 exit_missing_param('',array(_('Subject'),_('Body'),_('Name'),_('Email')),'home');
72 // we remove the CRLF in all thoses vars. This is to make sure that there will be no CRLF Injection
73 $name = util_remove_CRLF($name);
74 // Really don't see what wrong could happen with CRLF in message body
75 //$email = util_remove_CRLF($email);
76 $subject = util_remove_CRLF($subject);
80 send it to the toaddress
82 $to=preg_replace('/_maillink_/i','@',$toaddress);
83 $to = util_remove_CRLF($to);
84 util_send_message($to,$subject,$body,$email,'',$name);
85 $HTML->header(array('title'=>forge_get_config ('forge_name').' ' ._('Contact') ));
86 echo '<p>'._('Message has been sent').'.</p>';
87 $HTML->footer(array());
91 figure out the user's email and send it there
93 $to=db_result($result,0,'email');
94 $to = util_remove_CRLF($to);
95 util_send_message($to,$subject,$body,$email,'',$name);
96 $HTML->header(array('title'=>forge_get_config ('forge_name').' '._('Contact')));
97 echo '<p>'._('Message has been sent').'</p>';
98 $HTML->footer(array());
104 $titleaddress = $toaddress;
106 $titleaddress = db_result($result,0,'user_name');
109 if (session_loggedin()) {
110 $user =& session_get_user();
111 $name = $user->getRealName();
112 $email = $user->getEmail();
117 $subject = getStringFromRequest('subject');
119 $HTML->header(array('title'=>forge_get_config ('forge_name').' Staff'));
124 <?php echo _('In an attempt to reduce spam, we are using this form to send email.'); ?>
128 <?php echo _('Fill it out accurately and completely or the receiver may not be able to respond.'); ?>
131 <p class="important">
132 <?php echo _('<b>IF YOU ARE WRITING FOR HELP:</b> Did you read the site documentation? Did you include your <b>user_id</b> and <b>user_name?</b> If you are writing about a project, include your <b>project id</b> (<b>group_id</b>) and <b>Project Name</b>.'); ?>
135 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
138 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>" />
139 <input type="hidden" name="toaddress" value="<?php echo $toaddress; ?>" />
140 <input type="hidden" name="touser" value="<?php echo $touser; ?>" />
142 <strong><?php echo _('Your Name').utils_requiredField() ?> :</strong><br />
143 <input type="text" required="required" name="name" size="40" maxlength="40" value="<?php echo $name ?>" />
146 <strong><?php echo _('Your Email Address').utils_requiredField() ?> :</strong><br />
147 <input type="text" required="required" name="email" size="40" maxlength="255" value="<?php echo $email ?>" />
150 <strong><?php echo _('Subject').utils_requiredField() ?> :</strong><br />
151 <input type="text" required="required" name="subject" size="60" maxlength="255" value="<?php echo $subject; ?>" />
154 <strong><?php echo _('Message').utils_requiredField() ?> :</strong><br />
155 <textarea name="body" required="required" rows="15" cols="60"></textarea>
158 <input type="submit" name="send_mail" value="<?php echo _('Send Message') ?>" />
162 $HTML->footer(array());
166 // c-file-style: "bsd"