-
Notifications
You must be signed in to change notification settings - Fork 3
/
contact.php
138 lines (118 loc) · 4.14 KB
/
contact.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/* phpMyProfiler
* Copyright (C) 2004 by Tim Reckmann [www.reckmann.org] & Powerplant [www.powerplant.de]
* Copyright (C) 2005-2014 The phpMyProfiler project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
// No direct access
defined('_PMP_REL_PATH') or die('Not allowed! Possible hacking attempt detected!');
$pmp_module = 'contact';
require_once('include/formkey.class.php');
require_once('Validate.php');
$formKey = new formKey();
$validate = new Validate();
$smarty = new pmp_Smarty;
$smarty->loadFilter('output', 'trimwhitespace');
// Initialize the captcha object with our configuration options
if ( $pmp_guestbook_showcode == true ) {
require_once('include/b2evo_captcha/b2evo_captcha.config.php');
require_once('include/b2evo_captcha/b2evo_captcha.class.php');
$captcha = new b2evo_captcha($CAPTCHA_CONFIG);
$imgLoc = $captcha->get_b2evo_captcha();
$smarty->assign('imgLoc', $imgLoc);
}
// Add new entry
if ( (isset($_GET['action'])) && ($_GET['action'] == 'send') ) {
// First check the form key
if ( !isset($_POST['form_key']) || !$formKey->validate() ) {
//Form key is invalid, show an error
$smarty->assign('Failed', 'Form key error!');
}
else {
$msg = array();
// Check all values we get from contact form
if ( $_POST['name'] != "" ) {
$name = html2txt($_POST['name']);
}
else {
$msg[]= 'Please enter your name!';
}
if ( $_POST['email'] != "" ) {
$email = $_POST['email'];
if ( !$validate->email($email, array('use_rfc822' => true)) ) {
$msg[] = "$email is <strong>NOT</strong> a valid email address!";
}
}
else {
$msg[]= 'Please enter a valid email address!';
}
if ( $_POST['subject'] != "" ) {
$subject = html2txt($_POST['subject']);
}
else {
$msg[]= 'Please enter a subject!';
}
if ( $_POST['message'] != "" ) {
$message = html2txt($_POST['message']);
}
else {
$msg[]= 'Please enter a message to send!';
}
if ( count($msg) == 0 ) {
// Check captcha
if ( ($pmp_guestbook_showcode == true) && ($captcha->validate_submit($_POST['image'], $_POST['code']) == false) ) {
$smarty->assign('Failed', t('Wrong security code!'));
}
// Make Bot-Check
else if ( !empty($_POST['username']) ) {
$smarty->assign('Failed', t('Bot Attack!'));
}
else {
$subject = "[phpMyProfiler] " . $subject;
$subject= mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
// Wordwrap after 72 chars in message
$message = wordwrap($message, 72);
$header = 'From: "' . $name . '" <' . $email . '>' . "\r\n"
. 'MIME-Version: 1.0' . "\r\n"
. 'Content-Type: text/plain; charset="UTF-8"' . "\r\n"
. 'Content-Transfer-Encoding: quoted-printable' . "\r\n"
. 'Message-ID: <' . md5(uniqid(microtime())) . '@' . $_SERVER['SERVER_NAME'] . '>' . "\r\n"
. 'X-Mailer: phpMyProfiler ' . $pmp_version . "\r\n";
// Send e-mail
if ( mail($pmp_admin_mail, $subject, $message, $header) ) {
$smarty->assign('Success', t('Thank you for your message.'));
}
else {
$smarty->assign('Failed', t('Failed to send E-mail.'));
}
// Clean the input values
$_POST['name'] = '';
$_POST['email'] = '';
$_POST['subject'] = '';
$_POST['message'] = '';
}
}
else {
$smarty->assign('Failed', implode($msg, ' <br />'));
}
}
}
// Try to obscure email against spammers
$pmp_admin_mail_s = str_replace('@', ' [at] ', $pmp_admin_mail);
$pmp_admin_mail_s = str_replace('.', ' dot ', $pmp_admin_mail_s);
$smarty->assign('formkey', $formKey->outputKey());
$smarty->display('contact.tpl');
?>