forked from avscms/avscms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.php
executable file
·137 lines (126 loc) · 4.09 KB
/
feedback.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
<?php
define('_VALID', true);
require 'include/config.php';
require 'include/function_global.php';
require 'include/function_smarty.php';
require 'classes/validation.class.php';
require 'classes/filter.class.php';
$feedback = array('department' => 'General', 'email' => '', 'name' => '', 'message' => '');
$departments = array('General', 'Violations', 'Advertising');
if ( $config['captcha'] == '1' ) {
$captcha_language = substr($_SESSION['language'], 0, 2);
switch ($_SESSION['language']) {
case 'sa_SA':
$captcha_language = 'ar';
break;
case 'he_IL':
$captcha_language = 'iw';
break;
case 'jp_JP':
$captcha_language = 'ja';
break;
case 'cn_CS':
$captcha_language = 'zh-CN';
break;
case 'cn_CT':
$captcha_language = 'zh-TW';
break;
case 'dk_DK':
$captcha_language = 'da';
break;
case 'cz_CZ':
$captcha_language = 'cs';
break;
case 'rs_RS':
$captcha_language = 'sr';
break;
case 'si_SI':
$captcha_language = 'sl';
break;
case 'ba_BA':
$captcha_language = 'sl';
break;
}
}
if ( isset($_POST['submit_feedback']) ) {
$filter = new VFilter();
$valid = new VValidation();
$department = $filter->get('department');
$email = $filter->get('email');
$name = $filter->get('name');
$message = $filter->get('message');
if ( !in_array($department, $departments) ) {
$errors[] = $lang['feedback.department_invalid'];
$err['department'] = 1;
} else {
$feedback['department'] = $department;
}
if ( $email == '' ) {
$errors[] = $lang['global.email_empty'];
$err['email'] = 1;
} elseif ( !$valid->email($email) ) {
$errors[] = $lang['global.email_invalid'];
$err['email'] = 1;
} else {
$feedback['email'] = $email;
}
if ( $name == '' ) {
$errors[] = $lang['feedback.name_empty'];
$err['name'] = 1;
} else {
$feedback['name'] = $name;
}
if ( $message == '' ) {
$errors[] = $lang['global.message_empty'];
$err['message'] = 1;
} elseif ( mb_strlen($message) > 1000 ) {
$errors[] = translate('message_length', '1000');
$err['email'] = 1;
} else {
$feedback['message'] = $message;
}
if ( $config['captcha'] == '1' ) {
$secret = $config['recaptcha_secret_key'];
require('modules/captcha/recaptchalib.php');
$response = null;
$reCaptcha = new ReCaptcha($secret);
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
if ($response != null && $response->success) {
// verified!
} else {
$errors[] = $lang['signup.captcha'];
}
}
if ( !$errors ) {
require $config['BASE_DIR']. '/classes/email.class.php';
$message = "Department: " .$department. "\n\nMessage: " .$message;
$mail = new VMail();
$mail->From = $email;
$mail->FromName = $name;
$mail->Sender = $email;
$mail->AddReplyTo($email, $name);
$mail->Subject = 'Feedback from ' .htmlspecialchars($name);
$mail->AltBody = $message;
$mail->Body = nl2br($message);
$mail->AddAddress($config['admin_email']);
$mail->Send();
$messages[] = $lang['feedback.sent'];
}
}
$smarty->assign('errors',$errors);
$smarty->assign('err',$err);
$smarty->assign('messages',$messages);
$smarty->assign('menu', 'home');
$smarty->assign('feedback', $feedback);
$smarty->assign('self_title', $seo['feedback_title']);
$smarty->assign('self_description', $seo['feedback_desc']);
$smarty->assign('self_keywords', $seo['feedback_keywords']);
$smarty->assign('captcha_language',$captcha_language);
$smarty->loadFilter('output', 'trimwhitespace');
$smarty->display('header.tpl');
$smarty->display('feedback.tpl');
$smarty->display('footer.tpl');
?>