1
+ <?php
2
+
3
+ error_reporting (0 );
4
+
5
+ define ('FC_SOURCE ' , 'frontend ' );
6
+
7
+ include_once '../../../config.php ' ;
8
+ include_once '../../../database.php ' ;
9
+ include_once '../../../global/functions.php ' ;
10
+
11
+ $ fc_prefs = fc_get_preferences ();
12
+
13
+ $ recipient ['name ' ] = $ fc_prefs ['prefs_mailer_name ' ];
14
+ $ recipient ['mail ' ] = $ fc_prefs ['prefs_mailer_adr ' ];
15
+
16
+ $ prefs_mailer_adr = $ recipient ['mail ' ];
17
+ $ prefs_mailer_name = $ recipient ['name ' ];
18
+
19
+ if (is_file ('../../../content/config_smtp.php ' )) {
20
+ include '../../../content/config_smtp.php ' ;
21
+ $ prefs_mailer_type = 'smtp ' ;
22
+ }
23
+
24
+ $ send_mail = 'true ' ;
25
+ $ error_msg = '' ;
26
+
27
+ if (!function_exists ('phpform_user_inputs ' )) {
28
+ function phpform_user_inputs ($ user_submit ) {
29
+ $ user_submit = strip_tags ($ user_submit );
30
+ $ user_submit = preg_replace ( "/(content-type:|bcc:|cc:|to:|from:)/im " , "" ,$ user_submit );
31
+ $ user_submit = preg_replace ('/\r\n|\r|\n/ ' , '<br> ' , $ user_submit );
32
+ return $ user_submit ;
33
+ }
34
+ }
35
+
36
+
37
+ foreach ($ _POST as $ key => $ val ) {
38
+ $ {"checked_ $ key " } = phpform_user_inputs ($ val );
39
+ }
40
+
41
+ /* check user inputs */
42
+
43
+ if ($ _POST ['visitor_csrf_token ' ] !== $ _SESSION ['visitor_csrf_token ' ]) {
44
+ $ send_mail = "false " ;
45
+ $ error_msg .= '<li>Unable to process your request.</li> ' ;
46
+ }
47
+
48
+ if (($ checked_af_sender_name == "" ) || ($ checked_af_sender_mail == "" ) || ($ checked_af_sender_message == "" )) {
49
+ $ send_mail = "false " ;
50
+ $ error_msg .= '<li>All mandatory fields (*) must be filled out</li> ' ;
51
+ }
52
+
53
+ if (!filter_var ($ checked_af_sender_mail , FILTER_VALIDATE_EMAIL )) {
54
+ $ send_mail = "false " ;
55
+ $ error_msg .= '<li>Something seems to be wrong with your email address.</li> ' ;
56
+ }
57
+
58
+ if ($ _POST ['privacy_policy ' ] != 'accept ' ) {
59
+ $ send_mail = "false " ;
60
+ $ error_msg .= '<li>You need to confirm that you have read the privacy policy</li> ' ;
61
+ }
62
+
63
+ if ($ error_msg !== '' ) {
64
+
65
+ $ response = '<strong>One or more errors occurred:</strong> ' ;
66
+ $ response .= '<ul> ' .$ error_msg .'</ul> ' ;
67
+
68
+ $ output = json_encode (array ('type ' => 'error ' , 'text ' => "$ response " ));
69
+ die ($ output );
70
+ }
71
+
72
+ /* checks passed succesfully */
73
+
74
+ $ send_date = date ('Y-m-d h:i:s ' );
75
+ $ send_subject = 'Message from ' .$ checked_af_sender_name ;
76
+
77
+ $ send_text = '<body> ' ;
78
+ $ send_text .= '<table cellpadding="2" border="0"> ' ;
79
+ $ send_text .= '<tr><td>Name:</td><td> ' .$ checked_af_sender_name .'</td></tr> ' ;
80
+ $ send_text .= '<tr><td>E-Mail:</td><td> ' .$ checked_af_sender_mail .'</td></tr> ' ;
81
+ $ send_text .= '<tr><td>Message:</td><td> ' .$ checked_af_sender_message .'</td></tr> ' ;
82
+ $ send_text .= '<tr><td>Time:</td><td> ' .$ send_date .'</td></tr> ' ;
83
+ $ send_text .= '</table> ' ;
84
+ $ send_text .= '</body> ' ;
85
+
86
+ $ phpform_sendmail = fc_send_mail ($ recipient ,$ send_subject ,$ send_text );
87
+ if ($ phpform_sendmail == 1 ) {
88
+ $ output = json_encode (array ('type ' => 'success ' , 'text ' => 'Thank you for your message. ' ));
89
+ die ($ output );
90
+ } else {
91
+
92
+ $ output = json_encode (array ('type ' => 'error ' , 'text ' => 'There has been an error. Please try again. ' ));
93
+ die ($ output );
94
+ }
95
+
96
+
97
+ ?>
0 commit comments