-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcontact.php
More file actions
141 lines (114 loc) · 4.4 KB
/
contact.php
File metadata and controls
141 lines (114 loc) · 4.4 KB
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
139
140
141
<?php
define( 'PMR', 'true' );
$page = 'contact';
include './config.php';
include PATH . '/defaults.php';
// Title of page
$title = $conf['website_name_short'] . ' - ' . $lang['Mailer'];
// Header template
include PATH . '/templates/' . $cookie_template . '/header.php';
$output_message = '';
$error_message = '';
$contact_form = '';
$custom['display_form'] = true;
$tpl = PATH . '/templates/' . $cookie_template . '/tpl/contact.tpl';
$template = new Template;
$template->load ( $tpl );
if ( $_POST['submit'] == true )
{
$form = array();
// Strip anything that shouldn't be submitted
$form = array_map( 'safehtml', $_POST );
$errors = 0;
// Email field
if ( empty( $form['email'] ) || strlen( $form['email'] ) < 4 || !valid_email( $form['email'] ) )
{
$error_message = $lang['Field_Empty'] . ': ' . $lang['Mailer_e_mail'];
$errors++;
}
// Captcha
// Only validate captcha if we're on the contact page (otherwise, skip it)
if ( $_REQUEST['external'] == false && $conf['captcha_private_key'] != '' && $conf['captcha_public_key'] != '' && $conf['captcha_status'] == 'ON' )
{
if ( captcha_check() == false )
{
$error_message = $lang['Captcha_Fail'];
$errors++;
}
}
// Protect against flooding/abuse of this form
if ( (time() - $session->fetch( 'mail_time') ) < 30 )
{
$error_message = $lang['Flood_Detected'];
$errors++;
}
// Body of message is required and must be at least 4 characters long
if ( empty( $form['message'] ) || strlen( $form['message'] ) < 4 )
{
$error_message = $lang['Field_Empty'] . ': ' . $lang['Mailer_Message'];
$errors++;
}
// Name field
if ( empty( $form['name'] ) || strlen( $form['name'] ) < 2 )
{
$error_message = $lang['Field_Empty'] . ': ' . $lang['Mailer_Name'];
$errors++;
}
if ( $errors > 0 )
{
$output_message = error( $lang['Error'], $error_message, true );
}
else
{
// Replace some variables in the subject
$lang['Mailer_Subject'] = str_replace( '{website_name}', $conf['website_name'], $lang['Mailer_Subject'] );
$lang['Mailer_Subject'] = str_replace( '{user_e_mail}', $form['email'] , $lang['Mailer_Subject'] );
// Body of email
$lang['Main_Site_Contact_Form'] = str_replace( '{message}', $form['message'], $lang['Main_Site_Contact_Form'] );
$lang['Main_Site_Contact_Form'] = str_replace( '{name}', $form['name'], $lang['Main_Site_Contact_Form'] );
$lang['Main_Site_Contact_Form'] = str_replace( '{email}', $form['email'], $lang['Main_Site_Contact_Form'] );
send_mailing(
$conf['general_e_mail'],
$conf['general_e_mail_name'],
$conf['general_e_mail'],
$lang['Mailer_Subject'],
$lang['Main_Site_Contact_Form']
);
// Thank the user
$lang['Mailer_Sent'] = str_replace( '{name}', $conf['website_name'], $lang['Mailer_Sent'] );
$output_message = success( $lang['Success'], $lang['Mailer_Sent'], true );
// Prevent flooding/abuse of this mail form by saving when this was last submitted successfully
$session->set( 'mail_time', time() );
// Don't load the contact form template again
$custom['display_form'] = false;
}
}
$template->set( '@email', $lang['Realtor_e_mail'] );
$template->set( '@phone', $lang['Realtor_Phone'] );
$template->set( '@address', $lang['Realtor_Address'] );
$template->set( 'contact_form', $contact_form );
$template->set( 'output_message', $output_message );
$template->set( 'contact_text', $lang['Contact_Text'] );
$template->set( 'header', $lang['Mailer'] );
$template->set( 'latitude', $conf['latitude'] );
$template->set( 'longitude', $conf['longitude'] );
// Contact Form
$template->set( '@name', $lang['Mailer_Name'] );
$template->set( '@email', $lang['Realtor_e_mail'] );
$template->set( '@message', $lang['Mail_Friend_Message'] );
$template->set( 'name', $_REQUEST['name'] );
$template->set( 'email', $_REQUEST['email'] );
$template->set( 'message', $_REQUEST['message'] );
$template->set( 'send', $lang['Admin_Mailer_Submit'] );
$template->set( 'math', $_REQUEST['math'] );
$template->set( '@math', $lang['Math'] . ' ' . $_SESSION['rand_1'] . ' + ' . $_SESSION['rand_2'] );
$template->set( 'conf_address1', $conf['address1'] );
$template->set( 'conf_city', $conf['city'] );
$template->set( 'conf_state', $conf['state'] );
$template->set( 'conf_country', $conf['country'] );
$template->set( 'conf_phone', $conf['phone'] );
$template->set( 'conf_email', $conf['general_e_mail'] );
$template->publish();
// Footer template
include PATH . '/templates/' . $cookie_template . '/footer.php';
?>