forked from e107inc/e107
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
181 lines (151 loc) · 4.3 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* /contact.php
*
*/
require_once("class2.php");
// security image may be disabled by removing the appropriate shortcodes from the template.
require_once(e_HANDLER."secure_img_handler.php");
$sec_img = new secure_image;
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
require_once(HEADERF);
if (!vartrue($CONTACT_FORM))
{
if (file_exists(THEME."contact_template.php"))
{
require_once(THEME."contact_template.php");
}
else
{
// Redirect Page if no contact-form or contact-info is available.
if(($pref['sitecontacts']== e_UC_NOBODY) && trim(SITECONTACTINFO) == "")
{
e107::getRedirect()->redirect(e_BASE."index.php");
exit;
}
$CONTACT_FORM = e107::getCoreTemplate('contact','form'); // require_once(e_THEME."templates/contact_template.php");
}
}
if(isset($_POST['send-contactus']))
{
$error = "";
$sender_name = $tp->toEmail($_POST['author_name'],TRUE,'RAWTEXT');
$sender = check_email($_POST['email_send']);
$subject = $tp->toEmail($_POST['subject'],TRUE,'RAWTEXT');
$body = $tp->toEmail($_POST['body'],TRUE,'RAWTEXT');
// Check Image-Code
if (isset($_POST['rand_num']) && !$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
{
$error .= LANCONTACT_15."\\n";
}
// Check message body.
if(strlen(trim($_POST['body'])) < 15)
{
$error .= LANCONTACT_12."\\n";
}
// Check subject line.
if(varset($_POST['subject']) && strlen(trim($_POST['subject'])) < 2)
{
$error .= LANCONTACT_13."\\n";
}
if(!strpos(trim($_POST['email_send']),"@"))
{
$error .= LANCONTACT_11."\\n";
}
// Check email address on remote server (if enabled).
if ($pref['signup_remote_emailcheck'] && $error == '')
{
require_once(e_HANDLER."mail_validation_class.php");
list($adminuser,$adminhost) = explode('@', SITEADMINEMAIL, 2);
$validator = new email_validation_class;
$validator->localuser= $adminuser;
$validator->localhost= $adminhost;
$validator->timeout=3;
// $validator->debug=1;
// $validator->html_debug=1;
if($validator->ValidateEmailBox($sender) != 1)
{
$error .= LANCONTACT_11."\\n";
}
}
// No errors - so proceed to email the admin and the user (if selected).
if(!$error)
{
$body .= "\n\nIP:\t".USERIP."\n";
if (USER)
{
$body .= "User:\t#".USERID." ".USERNAME."\n";
}
if(!$_POST['contact_person'] && isset($pref['sitecontacts'])) // only 1 person, so contact_person not posted.
{
if($pref['sitecontacts'] == e_UC_MAINADMIN)
{
$query = "user_perms = '0' OR user_perms = '0.' ";
}
elseif($pref['sitecontacts'] == e_UC_ADMIN)
{
$query = "user_admin = 1 ";
}
else
{
$query = "FIND_IN_SET(".$pref['sitecontacts'].",user_class) ";
}
}
else
{
$query = "user_id = ".intval($_POST['contact_person']);
}
if($sql -> db_Select("user", "user_name,user_email",$query." LIMIT 1"))
{
$row = $sql -> db_Fetch();
$send_to = $row['user_email'];
$send_to_name = $row['user_name'];
}
else
{
$send_to = SITEADMINEMAIL;
$send_to_name = ADMIN;
}
require_once(e_HANDLER."mail.php");
$message = (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
if(isset($pref['contact_emailcopy']) && $pref['contact_emailcopy'] && $_POST['email_copy'] == 1){
sendemail($sender,"[".SITENAME."] ".$subject, $body,ADMIN,$sender,$sender_name);
}
$ns -> tablerender('', $message);
require_once(FOOTERF);
exit;
}
else
{
message_handler("P_ALERT", $error);
}
}
if(SITECONTACTINFO)
{
if(!isset($CONTACT_INFO))
{
$CONTACT_INFO = e107::getCoreTemplate('contact','info');
}
$text = $tp->parseTemplate($CONTACT_INFO, TRUE, vartrue($contact_shortcodes));
$ns -> tablerender(LANCONTACT_01, $text,"contact");
}
if(isset($pref['sitecontacts']) && $pref['sitecontacts'] != 255)
{
$contact_shortcodes = e107::getScBatch('contact');
// Wrapper support
$contact_shortcodes->wrapper('contact/form');
$text = $tp->parseTemplate($CONTACT_FORM, TRUE, $contact_shortcodes);
if(trim($text) != "")
{
$ns -> tablerender(LANCONTACT_02, $text, "contact");
}
}
require_once(FOOTERF);
exit;
?>