Version Description
- Fixed: Bug on triming recipients addresses
Download this release
Release Info
Developer | webdorado |
Plugin | Contact Form Builder – a plugin for creating contact and feedback forms |
Version | 1.0.54 |
Comparing to | |
See all releases |
Code changes from version 1.0.53 to 1.0.54
- contact-form-builder.php +2 -2
- frontend/models/CFMModelForm_maker.php +951 -949
- readme.txt +4 -1
contact-form-builder.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
* Plugin Name: Contact Form Builder
|
4 |
* Plugin URI: http://web-dorado.com/products/wordpress-contact-form-builder.html
|
5 |
* Description: Contact Form Builder is an advanced plugin to add contact forms into your website. It comes along with multiple default templates which can be customized.
|
6 |
-
* Version: 1.0.
|
7 |
* Author: WebDorado
|
8 |
* Author URI: http://web-dorado.com/
|
9 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
*/
|
11 |
define('WD_CFM_DIR', WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)));
|
12 |
define('WD_CFM_URL', plugins_url(plugin_basename(dirname(__FILE__))));
|
13 |
-
define('WD_CFM_VERSION', '1.0.
|
14 |
|
15 |
// Plugin menu.
|
16 |
function contact_form_maker_options_panel() {
|
3 |
* Plugin Name: Contact Form Builder
|
4 |
* Plugin URI: http://web-dorado.com/products/wordpress-contact-form-builder.html
|
5 |
* Description: Contact Form Builder is an advanced plugin to add contact forms into your website. It comes along with multiple default templates which can be customized.
|
6 |
+
* Version: 1.0.54
|
7 |
* Author: WebDorado
|
8 |
* Author URI: http://web-dorado.com/
|
9 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
*/
|
11 |
define('WD_CFM_DIR', WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)));
|
12 |
define('WD_CFM_URL', plugins_url(plugin_basename(dirname(__FILE__))));
|
13 |
+
define('WD_CFM_VERSION', '1.0.54');
|
14 |
|
15 |
// Plugin menu.
|
16 |
function contact_form_maker_options_panel() {
|
frontend/models/CFMModelForm_maker.php
CHANGED
@@ -1,950 +1,952 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class CFMModelForm_maker {
|
4 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
5 |
-
// Events //
|
6 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
7 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
8 |
-
// Constants //
|
9 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
10 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
11 |
-
// Variables //
|
12 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
13 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
14 |
-
// Constructor & Destructor //
|
15 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
16 |
-
public function __construct() {
|
17 |
-
}
|
18 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
19 |
-
// Public Methods //
|
20 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
21 |
-
public function showform($id) {
|
22 |
-
global $wpdb;
|
23 |
-
$row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'contactformmaker WHERE id="%d"', $id));
|
24 |
-
if (!$row || !$row->published) {
|
25 |
-
return FALSE;
|
26 |
-
}
|
27 |
-
if (isset($_GET['test_theme']) && (esc_html(stripslashes($_GET['test_theme'])) != '')) {
|
28 |
-
/* From preview.*/
|
29 |
-
$theme_id = esc_html(stripslashes($_GET['test_theme']));
|
30 |
-
}
|
31 |
-
else {
|
32 |
-
$theme_id = $row->theme;
|
33 |
-
}
|
34 |
-
$form_theme = $wpdb->get_var($wpdb->prepare('SELECT css FROM ' . $wpdb->prefix . 'contactformmaker_themes WHERE id="%d"', $theme_id));
|
35 |
-
if (!$form_theme) {
|
36 |
-
$form_theme = $wpdb->get_var('SELECT css FROM ' . $wpdb->prefix . 'contactformmaker_themes');
|
37 |
-
if (!$form_theme) {
|
38 |
-
return FALSE;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
$pattern = '/\/\/(.+)(\r\n|\r|\n)/';
|
42 |
-
$form_theme = preg_replace($pattern, ' ', $form_theme);
|
43 |
-
$form_theme = str_replace('//', ' ', $form_theme);
|
44 |
-
$label_id = array();
|
45 |
-
$label_type = array();
|
46 |
-
$label_all = explode('#****#', $row->label_order);
|
47 |
-
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
48 |
-
foreach ($label_all as $key => $label_each) {
|
49 |
-
$label_id_each = explode('#**id**#', $label_each);
|
50 |
-
array_push($label_id, $label_id_each[0]);
|
51 |
-
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
52 |
-
array_push($label_type, $label_order_each[1]);
|
53 |
-
}
|
54 |
-
return array(
|
55 |
-
$row,
|
56 |
-
1,
|
57 |
-
$label_id,
|
58 |
-
$label_type,
|
59 |
-
$form_theme
|
60 |
-
);
|
61 |
-
}
|
62 |
-
|
63 |
-
public function savedata($form, $id) {
|
64 |
-
$fm_settings = get_option('cfm_settings');
|
65 |
-
$all_files = array();
|
66 |
-
$correct = FALSE;
|
67 |
-
$id_for_old = $id;
|
68 |
-
if (!$form->form_front) {
|
69 |
-
$id = '';
|
70 |
-
}
|
71 |
-
if (isset($_POST["counter" . $id])) {
|
72 |
-
$counter = esc_html($_POST["counter" . $id]);
|
73 |
-
if (isset($_POST["captcha_input"])) {
|
74 |
-
$captcha_input = esc_html($_POST["captcha_input"]);
|
75 |
-
$session_wd_captcha_code = isset($_SESSION[$id . '_wd_captcha_code']) ? $_SESSION[$id . '_wd_captcha_code'] : '-';
|
76 |
-
if ($captcha_input == $session_wd_captcha_code) {
|
77 |
-
$correct = TRUE;
|
78 |
-
}
|
79 |
-
else {
|
80 |
-
?>
|
81 |
-
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
82 |
-
<?php
|
83 |
-
}
|
84 |
-
}
|
85 |
-
elseif (isset($_POST["recaptcha_response_field"])) {
|
86 |
-
$recaptcha_response_field = esc_html($_POST["recaptcha_response_field"]);
|
87 |
-
$privatekey= isset($fm_settings['private_key']) ? $fm_settings['private_key'] : '';
|
88 |
-
$recaptcha_challenge_field = ((isset($_POST['recaptcha_challenge_field'])) ? esc_html($_POST['recaptcha_challenge_field']) : '');
|
89 |
-
require_once(WD_CFM_DIR . '/recaptchalib.php');
|
90 |
-
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
|
91 |
-
if ($resp->is_valid) {
|
92 |
-
$correct = TRUE;
|
93 |
-
}
|
94 |
-
else {
|
95 |
-
?>
|
96 |
-
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
97 |
-
<?php
|
98 |
-
}
|
99 |
-
}
|
100 |
-
elseif (isset($_POST["g-recaptcha-response"])) {
|
101 |
-
$privatekey= isset($fm_settings['private_key']) ? $fm_settings['private_key'] : '';
|
102 |
-
$w = stream_get_wrappers();
|
103 |
-
if (in_array('https', $w)) {
|
104 |
-
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $privatekey . "&response=" . $_POST['g-recaptcha-response']);
|
105 |
-
$response = json_decode($response, true);
|
106 |
-
if ($response["success"] === true) {
|
107 |
-
$correct = TRUE;
|
108 |
-
}
|
109 |
-
else {
|
110 |
-
?>
|
111 |
-
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
112 |
-
<?php
|
113 |
-
}
|
114 |
-
}
|
115 |
-
else {
|
116 |
-
?>
|
117 |
-
<script>alert("<?php echo addslashes(__('`php_openssl` extension is not enabled.', 'contact_form_maker')); ?>");</script>
|
118 |
-
<?php
|
119 |
-
}
|
120 |
-
}
|
121 |
-
else {
|
122 |
-
$correct = TRUE;
|
123 |
-
}
|
124 |
-
if ($correct) {
|
125 |
-
$ip = $_SERVER['REMOTE_ADDR'];
|
126 |
-
global $wpdb;
|
127 |
-
$blocked_ip = $wpdb->get_var($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'contactformmaker_blocked WHERE ip="%s"', $ip));
|
128 |
-
if ($blocked_ip) {
|
129 |
-
$_SESSION['cfm_massage_after_submit' . $id] = addslashes(__('Your ip is blacklisted. Please contact the website administrator.', 'contact_form_maker'));
|
130 |
-
wp_redirect($_SERVER["REQUEST_URI"]);
|
131 |
-
exit;
|
132 |
-
}
|
133 |
-
|
134 |
-
$all_files = $this->save_db($counter, $id_for_old);
|
135 |
-
if (is_numeric($all_files)) {
|
136 |
-
$this->remove($all_files, $id_for_old);
|
137 |
-
}
|
138 |
-
elseif (isset($counter)) {
|
139 |
-
$this->gen_mail($counter, $all_files, $id_for_old);
|
140 |
-
}
|
141 |
-
}
|
142 |
-
return $all_files;
|
143 |
-
}
|
144 |
-
return $all_files;
|
145 |
-
}
|
146 |
-
|
147 |
-
public function save_db($counter, $id) {
|
148 |
-
global $wpdb;
|
149 |
-
$chgnac = TRUE;
|
150 |
-
$all_files = array();
|
151 |
-
$form = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "contactformmaker WHERE id= %d", $id));
|
152 |
-
$id_old = $id;
|
153 |
-
if (!$form->form_front) {
|
154 |
-
$id = '';
|
155 |
-
}
|
156 |
-
$label_id = array();
|
157 |
-
$label_label = array();
|
158 |
-
$label_type = array();
|
159 |
-
$label_all = explode('#****#',$form->label_order_current);
|
160 |
-
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
161 |
-
foreach ($label_all as $key => $label_each) {
|
162 |
-
$label_id_each = explode('#**id**#', $label_each);
|
163 |
-
array_push($label_id, $label_id_each[0]);
|
164 |
-
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
165 |
-
array_push($label_label, $label_order_each[0]);
|
166 |
-
array_push($label_type, $label_order_each[1]);
|
167 |
-
}
|
168 |
-
$disabled_fields = explode(',', $form->disabled_fields);
|
169 |
-
$disabled_fields = array_slice($disabled_fields, 0, count($disabled_fields) - 1);
|
170 |
-
$max = $wpdb->get_var("SELECT MAX( group_id ) FROM " . $wpdb->prefix . "contactformmaker_submits");
|
171 |
-
foreach ($label_type as $key => $type) {
|
172 |
-
$value = '';
|
173 |
-
if ($type == "type_submit_reset" or $type == "type_map" or $type == "type_editor" or $type == "type_captcha" or $type == "type_recaptcha" or $type == "type_send_copy") {
|
174 |
-
continue;
|
175 |
-
}
|
176 |
-
$i = $label_id[$key];
|
177 |
-
if (!in_array($i, $disabled_fields)) {
|
178 |
-
switch ($type) {
|
179 |
-
case 'type_text':
|
180 |
-
case 'type_password':
|
181 |
-
case 'type_textarea':
|
182 |
-
case "type_submitter_mail":
|
183 |
-
case "type_own_select":
|
184 |
-
case "type_number": {
|
185 |
-
$value = isset($_POST['wdform_'.$i."_element".$id]) ? esc_html($_POST['wdform_'.$i."_element".$id]) : "";
|
186 |
-
break;
|
187 |
-
}
|
188 |
-
case "type_phone": {
|
189 |
-
$value = (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "");
|
190 |
-
break;
|
191 |
-
}
|
192 |
-
case "type_name": {
|
193 |
-
$element_title = isset($_POST['wdform_'.$i."_element_title".$id]) ? esc_html($_POST['wdform_'.$i."_element_title".$id]) : NULL;
|
194 |
-
if (isset($element_title)) {
|
195 |
-
$value = (isset($_POST['wdform_'.$i."_element_title".$id]) ? esc_html($_POST['wdform_'.$i."_element_title".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_middle".$id]) ? esc_html($_POST['wdform_'.$i."_element_middle".$id]) : "");
|
196 |
-
}
|
197 |
-
else {
|
198 |
-
$value = (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "");
|
199 |
-
}
|
200 |
-
break;
|
201 |
-
}
|
202 |
-
case 'type_address': {
|
203 |
-
$value = '*#*#*#';
|
204 |
-
$element = isset($_POST['wdform_'.$i."_street1".$id]) ? esc_html($_POST['wdform_'.$i."_street1".$id]) : NULL;
|
205 |
-
if (isset($element)) {
|
206 |
-
$value = $element;
|
207 |
-
break;
|
208 |
-
}
|
209 |
-
|
210 |
-
$element = isset($_POST['wdform_'.$i."_street2".$id]) ? esc_html($_POST['wdform_'.$i."_street2".$id]) : NULL;
|
211 |
-
if (isset($element)) {
|
212 |
-
$value = $element;
|
213 |
-
break;
|
214 |
-
}
|
215 |
-
|
216 |
-
$element = isset($_POST['wdform_'.$i."_city".$id]) ? esc_html($_POST['wdform_'.$i."_city".$id]) : NULL;
|
217 |
-
if(isset($element)) {
|
218 |
-
$value = $element;
|
219 |
-
break;
|
220 |
-
}
|
221 |
-
|
222 |
-
$element = isset($_POST['wdform_'.$i."_state".$id]) ? esc_html($_POST['wdform_'.$i."_state".$id]) : NULL;
|
223 |
-
if(isset($element)) {
|
224 |
-
$value = $element;
|
225 |
-
break;
|
226 |
-
}
|
227 |
-
|
228 |
-
$element = isset($_POST['wdform_'.$i."_postal".$id]) ? esc_html($_POST['wdform_'.$i."_postal".$id]) : NULL;
|
229 |
-
if(isset($element)) {
|
230 |
-
$value = $element;
|
231 |
-
break;
|
232 |
-
}
|
233 |
-
|
234 |
-
$element = isset($_POST['wdform_'.$i."_country".$id]) ? esc_html($_POST['wdform_'.$i."_country".$id]) : NULL;
|
235 |
-
if(isset($element)) {
|
236 |
-
$value = $element;
|
237 |
-
break;
|
238 |
-
}
|
239 |
-
break;
|
240 |
-
}
|
241 |
-
case "type_radio": {
|
242 |
-
$element = isset($_POST['wdform_'.$i."_other_input".$id]) ? esc_html($_POST['wdform_'.$i."_other_input".$id]) : NULL;
|
243 |
-
if(isset($element)) {
|
244 |
-
$value = $element;
|
245 |
-
break;
|
246 |
-
}
|
247 |
-
$value = isset($_POST['wdform_'.$i."_element".$id]) ? esc_html($_POST['wdform_'.$i."_element".$id]) : "";
|
248 |
-
break;
|
249 |
-
}
|
250 |
-
case "type_checkbox": {
|
251 |
-
$start = -1;
|
252 |
-
$value = '';
|
253 |
-
for($j = 0; $j < 100; $j++) {
|
254 |
-
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : NULL;
|
255 |
-
if(isset($element)) {
|
256 |
-
$start = $j;
|
257 |
-
break;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
$other_element_id = -1;
|
262 |
-
$is_other = isset($_POST['wdform_'.$i."_allow_other".$id]) ? esc_html($_POST['wdform_'.$i."_allow_other".$id]) : "";
|
263 |
-
if($is_other == "yes") {
|
264 |
-
$other_element_id = isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? esc_html($_POST['wdform_'.$i."_allow_other_num".$id]) : "";
|
265 |
-
}
|
266 |
-
|
267 |
-
if($start != -1) {
|
268 |
-
for($j = $start; $j < 100; $j++) {
|
269 |
-
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : NULL;
|
270 |
-
if(isset($element)) {
|
271 |
-
if($j == $other_element_id) {
|
272 |
-
$value = $value . (isset($_POST['wdform_'.$i."_other_input".$id]) ? esc_html($_POST['wdform_'.$i."_other_input".$id]) : "") . '***br***';
|
273 |
-
}
|
274 |
-
else {
|
275 |
-
$value = $value . (isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : "") . '***br***';
|
276 |
-
}
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
break;
|
281 |
-
}
|
282 |
-
}
|
283 |
-
if ($type == "type_address") {
|
284 |
-
if( $value == '*#*#*#') {
|
285 |
-
continue;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
if ($type == "type_text" or $type == "type_password" or $type == "type_textarea" or $type == "type_name" or $type == "type_submitter_mail" or $type == "type_number" or $type == "type_phone") {
|
289 |
-
$untilupload = $form->form_fields;
|
290 |
-
$untilupload = substr($untilupload, strpos($untilupload, $i.'*:*id*:*'.$type), -1);
|
291 |
-
$untilupload = substr($untilupload, 0, strpos($untilupload, '*:*new_field*:'));
|
292 |
-
$untilupload = explode('*:*w_required*:*', $untilupload);
|
293 |
-
$untilupload = $untilupload[1];
|
294 |
-
$untilupload = explode('*:*w_unique*:*', $untilupload);
|
295 |
-
$unique_element = $untilupload[0];
|
296 |
-
if ($unique_element == 'yes') {
|
297 |
-
$unique = $wpdb->get_col($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "contactformmaker_submits WHERE form_id= %d and element_label= %s and element_value= %s", $id, $i, addslashes($value)));
|
298 |
-
if ($unique) {
|
299 |
-
echo "<script> alert('" . addslashes(__('This field %s requires a unique entry and this value was already submitted.', 'contact_form_maker')) . "'.replace('%s','" . $label_label[$key] . "'));</script>";
|
300 |
-
return array($max + 1);
|
301 |
-
}
|
302 |
-
}
|
303 |
-
}
|
304 |
-
if ($form->savedb) {
|
305 |
-
$save_or_no = $wpdb->insert($wpdb->prefix . "contactformmaker_submits", array(
|
306 |
-
'form_id' => $id,
|
307 |
-
'element_label' => $i,
|
308 |
-
'element_value' => stripslashes($value),
|
309 |
-
'group_id' => ($max + 1),
|
310 |
-
'date' => date('Y-m-d H:i:s'),
|
311 |
-
'ip' => $_SERVER['REMOTE_ADDR'],
|
312 |
-
), array(
|
313 |
-
'%d',
|
314 |
-
'%s',
|
315 |
-
'%s',
|
316 |
-
'%d',
|
317 |
-
'%s',
|
318 |
-
'%s'
|
319 |
-
));
|
320 |
-
}
|
321 |
-
if (!$save_or_no) {
|
322 |
-
return FALSE;
|
323 |
-
}
|
324 |
-
$chgnac = FALSE;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
if ($chgnac) {
|
328 |
-
global $wpdb;
|
329 |
-
if ($form->submit_text_type != 4) {
|
330 |
-
$_SESSION['cfm_massage_after_submit' . $id] = addslashes(addslashes(__('Nothing was submitted.', 'contact_form_maker')));
|
331 |
-
}
|
332 |
-
$_SESSION['cfm_error_or_no' . $id] = 1;
|
333 |
-
$_SESSION['cfm_form_submit_type' . $id] = $form->submit_text_type . "," . $form->id;
|
334 |
-
wp_redirect($_SERVER["REQUEST_URI"]);
|
335 |
-
exit;
|
336 |
-
}
|
337 |
-
return array($all_files);
|
338 |
-
}
|
339 |
-
|
340 |
-
public function remove($group_id) {
|
341 |
-
global $wpdb;
|
342 |
-
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'contactformmaker_submits WHERE group_id= %d', $group_id));
|
343 |
-
}
|
344 |
-
|
345 |
-
public function get_after_submission_text($form_id) {
|
346 |
-
global $wpdb;
|
347 |
-
return $wpdb->get_var("SELECT submit_text FROM " . $wpdb->prefix . "contactformmaker WHERE id='" . $form_id . "'");
|
348 |
-
}
|
349 |
-
|
350 |
-
public function increment_views_count($id) {
|
351 |
-
global $wpdb;
|
352 |
-
$vives_form = $wpdb->get_var($wpdb->prepare("SELECT views FROM " . $wpdb->prefix . "contactformmaker_views WHERE form_id=%d", $id));
|
353 |
-
if (isset($vives_form)) {
|
354 |
-
$vives_form = $vives_form + 1;
|
355 |
-
$wpdb->update($wpdb->prefix . "contactformmaker_views", array(
|
356 |
-
'views' => $vives_form,
|
357 |
-
), array('form_id' => $id), array(
|
358 |
-
'%d',
|
359 |
-
), array('%d'));
|
360 |
-
}
|
361 |
-
else {
|
362 |
-
$wpdb->insert($wpdb->prefix . 'contactformmaker_views', array(
|
363 |
-
'form_id' => $id,
|
364 |
-
'views' => 1
|
365 |
-
), array(
|
366 |
-
'%d',
|
367 |
-
'%d'
|
368 |
-
));
|
369 |
-
}
|
370 |
-
}
|
371 |
-
|
372 |
-
public function gen_mail($counter, $all_files, $id) {
|
373 |
-
global $wpdb;
|
374 |
-
$row = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "contactformmaker WHERE id=%d", $id));
|
375 |
-
if (!$row->form_front) {
|
376 |
-
$id = '';
|
377 |
-
}
|
378 |
-
$ip = $_SERVER['REMOTE_ADDR'];
|
379 |
-
$replyto = '';
|
380 |
-
$label_order_original = array();
|
381 |
-
$label_order_ids = array();
|
382 |
-
$label_label = array();
|
383 |
-
$label_type = array();
|
384 |
-
$cc = array();
|
385 |
-
$row_mail_one_time = 1;
|
386 |
-
$label_type = array();
|
387 |
-
$label_all = explode('#****#', $row->label_order_current);
|
388 |
-
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
389 |
-
foreach ($label_all as $key => $label_each) {
|
390 |
-
$label_id_each = explode('#**id**#', $label_each);
|
391 |
-
$label_id = $label_id_each[0];
|
392 |
-
array_push($label_order_ids, $label_id);
|
393 |
-
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
394 |
-
$label_order_original[$label_id] = $label_order_each[0];
|
395 |
-
$label_type[$label_id] = $label_order_each[1];
|
396 |
-
array_push($label_label, $label_order_each[0]);
|
397 |
-
array_push($label_type, $label_order_each[1]);
|
398 |
-
}
|
399 |
-
$disabled_fields = explode(',', $row->disabled_fields);
|
400 |
-
$disabled_fields = array_slice($disabled_fields, 0, count($disabled_fields) - 1);
|
401 |
-
$list = '<table border="1" cellpadding="3" cellspacing="0" style="width:600px;">';
|
402 |
-
$list_text_mode = '';
|
403 |
-
foreach ($label_order_ids as $key => $label_order_id) {
|
404 |
-
$i = $label_order_id;
|
405 |
-
$type = $label_type[$i];
|
406 |
-
if ($type != "type_map" and $type != "type_submit_reset" and $type != "type_editor" and $type != "type_captcha" and $type != "type_recaptcha" and $type != "type_send_copy") {
|
407 |
-
$element_label = $label_order_original[$i];
|
408 |
-
if (!in_array($i, $disabled_fields)) {
|
409 |
-
switch ($type) {
|
410 |
-
case 'type_text':
|
411 |
-
case 'type_password':
|
412 |
-
case 'type_textarea':
|
413 |
-
case "type_own_select":
|
414 |
-
case "type_number": {
|
415 |
-
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
416 |
-
if (isset($element)) {
|
417 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
418 |
-
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
419 |
-
}
|
420 |
-
break;
|
421 |
-
}
|
422 |
-
case "type_submitter_mail": {
|
423 |
-
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
424 |
-
if (isset($element)) {
|
425 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td ><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
426 |
-
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
427 |
-
}
|
428 |
-
break;
|
429 |
-
}
|
430 |
-
case "type_phone": {
|
431 |
-
$element_first = isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL;
|
432 |
-
if (isset($element_first)) {
|
433 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . '</td></tr>';
|
434 |
-
$list_text_mode .= $element_label . ' - ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . "\r\n";
|
435 |
-
}
|
436 |
-
break;
|
437 |
-
}
|
438 |
-
case "type_name": {
|
439 |
-
$element_first = isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL;
|
440 |
-
if (isset($element_first)) {
|
441 |
-
$element_title = isset($_POST['wdform_'.$i."_element_title".$id]) ? $_POST['wdform_'.$i."_element_title".$id] : NULL;
|
442 |
-
if (isset($element_title)) {
|
443 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_title . ' ' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . ' ' . (isset($_POST['wdform_'.$i."_element_middle".$id]) ? $_POST['wdform_'.$i."_element_middle".$id] : "") . '</td></tr>';
|
444 |
-
$list_text_mode .= $element_label . ' - ' . $element_title . ' ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . ' ' . (isset($_POST['wdform_' . $i . "_element_middle" . $id]) ? $_POST['wdform_' . $i . "_element_middle" . $id] : "") . "\r\n";
|
445 |
-
}
|
446 |
-
else {
|
447 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . '</td></tr>';
|
448 |
-
$list_text_mode .= $element_label . ' - ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . "\r\n";
|
449 |
-
}
|
450 |
-
}
|
451 |
-
break;
|
452 |
-
}
|
453 |
-
case "type_address": {
|
454 |
-
$element = isset($_POST['wdform_'.$i."_street1".$id]) ? $_POST['wdform_'.$i."_street1".$id] : NULL;
|
455 |
-
if (isset($element)) {
|
456 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
457 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
458 |
-
break;
|
459 |
-
}
|
460 |
-
$element = isset($_POST['wdform_'.$i."_street2".$id]) ? $_POST['wdform_'.$i."_street2".$id] : NULL;
|
461 |
-
if (isset($element)) {
|
462 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
463 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
464 |
-
break;
|
465 |
-
}
|
466 |
-
$element = isset($_POST['wdform_'.$i."_city".$id]) ? $_POST['wdform_'.$i."_city".$id] : NULL;
|
467 |
-
if (isset($element)) {
|
468 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
469 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
470 |
-
break;
|
471 |
-
}
|
472 |
-
$element = isset($_POST['wdform_'.$i."_state".$id]) ? $_POST['wdform_'.$i."_state".$id] : NULL;
|
473 |
-
if (isset($element)) {
|
474 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
475 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
476 |
-
break;
|
477 |
-
}
|
478 |
-
$element = isset($_POST['wdform_'.$i."_postal".$id]) ? $_POST['wdform_'.$i."_postal".$id] : NULL;
|
479 |
-
if (isset($element)) {
|
480 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
481 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
482 |
-
break;
|
483 |
-
}
|
484 |
-
$element = isset($_POST['wdform_'.$i."_country".$id]) ? $_POST['wdform_'.$i."_country".$id] : NULL;
|
485 |
-
if (isset($element)) {
|
486 |
-
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
487 |
-
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
488 |
-
break;
|
489 |
-
}
|
490 |
-
break;
|
491 |
-
}
|
492 |
-
case "type_radio": {
|
493 |
-
$element = isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : NULL;
|
494 |
-
if (isset($element)) {
|
495 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element . '</td></tr>';
|
496 |
-
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
497 |
-
break;
|
498 |
-
}
|
499 |
-
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
500 |
-
if(isset($element)) {
|
501 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td ><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
502 |
-
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
503 |
-
}
|
504 |
-
break;
|
505 |
-
}
|
506 |
-
case "type_checkbox": {
|
507 |
-
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >';
|
508 |
-
$list_text_mode .= $element_label . ' - ';
|
509 |
-
$start = -1;
|
510 |
-
for ($j = 0; $j < 100; $j++) {
|
511 |
-
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL;
|
512 |
-
if (isset($element)) {
|
513 |
-
$start = $j;
|
514 |
-
break;
|
515 |
-
}
|
516 |
-
}
|
517 |
-
$other_element_id = -1;
|
518 |
-
$is_other = isset($_POST['wdform_'.$i."_allow_other".$id]) ? $_POST['wdform_'.$i."_allow_other".$id] : "";
|
519 |
-
if ($is_other == "yes") {
|
520 |
-
$other_element_id = isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? $_POST['wdform_'.$i."_allow_other_num".$id] : "";
|
521 |
-
}
|
522 |
-
if ($start != -1) {
|
523 |
-
for ($j = $start; $j < 100; $j++) {
|
524 |
-
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL;
|
525 |
-
if (isset($element)) {
|
526 |
-
if ($j == $other_element_id) {
|
527 |
-
$list = $list . (isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : "") . '<br>';
|
528 |
-
$list_text_mode .= (isset($_POST['wdform_' . $i . "_other_input" . $id]) ? $_POST['wdform_' . $i . "_other_input" . $id] : "") . ', ';
|
529 |
-
}
|
530 |
-
else {
|
531 |
-
$list = $list . (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : "") . '<br>';
|
532 |
-
$list_text_mode .= (isset($_POST['wdform_' . $i . "_element" . $id . $j]) ? $_POST['wdform_' . $i . "_element" . $id . $j] : "") . ', ';
|
533 |
-
}
|
534 |
-
}
|
535 |
-
}
|
536 |
-
$list = $list . '</td></tr>';
|
537 |
-
}
|
538 |
-
break;
|
539 |
-
}
|
540 |
-
default: break;
|
541 |
-
}
|
542 |
-
}
|
543 |
-
}
|
544 |
-
}
|
545 |
-
$list = $list . '</table>';
|
546 |
-
// $list = wordwrap($list, 70, "\n", TRUE);
|
547 |
-
|
548 |
-
|
549 |
-
if ($row->sendemail) {
|
550 |
-
if ($row->send_to) {
|
551 |
-
$fromname = $row->mail_from_name_user;
|
552 |
-
if ($row->mail_subject_user) {
|
553 |
-
$subject = $row->mail_subject_user;
|
554 |
-
}
|
555 |
-
else {
|
556 |
-
$subject = $row->title;
|
557 |
-
}
|
558 |
-
/*if (isset($_REQUEST['wdform_22_element' . $id])) {
|
559 |
-
$subject = ($row->title) . ' : ' . $_REQUEST['wdform_22_element' . $id];
|
560 |
-
}
|
561 |
-
else {
|
562 |
-
$subject = $row->title;
|
563 |
-
}*/
|
564 |
-
if ($row->reply_to_user) {
|
565 |
-
$replyto = $row->reply_to_user;
|
566 |
-
}
|
567 |
-
if ($row->mail_mode_user) {
|
568 |
-
$content_type = "text/html";
|
569 |
-
$list_user = wordwrap($list, 70, "\n", TRUE);
|
570 |
-
$new_script = $row->script_mail_user;
|
571 |
-
}
|
572 |
-
else {
|
573 |
-
$content_type = "text/plain";
|
574 |
-
$list_user = wordwrap($list_text_mode, 1000, "\n", TRUE);
|
575 |
-
$new_script = str_replace(array('<p>', '</p>'), '', $row->script_mail_user);
|
576 |
-
}
|
577 |
-
foreach ($label_order_original as $key => $label_each) {
|
578 |
-
$type = $label_type[$key];
|
579 |
-
if (strpos($row->script_mail_user, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
580 |
-
$new_value = $this->custom_fields_mail($type, $key, $id);
|
581 |
-
$new_script = str_replace("%" . $label_each . "%", $new_value, $new_script);
|
582 |
-
}
|
583 |
-
if (strpos($fromname, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
584 |
-
$new_value = str_replace('<br>', ', ', $this->custom_fields_mail($type, $key, $id));
|
585 |
-
if (substr($new_value, -2) == ', ') {
|
586 |
-
$new_value = substr($new_value, 0, -2);
|
587 |
-
}
|
588 |
-
$fromname = str_replace("%" . $label_each . "%", $new_value, $fromname);
|
589 |
-
}
|
590 |
-
if (strpos($subject, "%" . $label_each . "%") > -1) {
|
591 |
-
$new_value = str_replace('<br>', ', ', $this->custom_fields_mail($type, $key, $id));
|
592 |
-
if (substr($new_value, -2) == ', ') {
|
593 |
-
$new_value = substr($new_value, 0, -2);
|
594 |
-
}
|
595 |
-
$subject = str_replace("%" . $label_each . "%", $new_value, $subject);
|
596 |
-
}
|
597 |
-
}
|
598 |
-
$recipient = '';
|
599 |
-
$cca = $row->mail_cc_user;
|
600 |
-
$bcc = $row->mail_bcc_user;
|
601 |
-
$send_tos = explode('**', $row->send_to);
|
602 |
-
if ($row->mail_from_user != '') {
|
603 |
-
if ($row->mail_from_name_user != '') {
|
604 |
-
$from = "From: '" . htmlspecialchars_decode($row->mail_from_name_user, ENT_QUOTES) . "' <" . $row->mail_from_user . ">" . "\r\n";
|
605 |
-
}
|
606 |
-
else {
|
607 |
-
$from = "From: '" . $row->mail_from_user . "' <" . $row->mail_from_user . ">" . "\r\n";
|
608 |
-
}
|
609 |
-
}
|
610 |
-
else {
|
611 |
-
$from = '';
|
612 |
-
}
|
613 |
-
|
614 |
-
$headers = ''; //'MIME-Version: 1.0' . "\r\n";
|
615 |
-
$headers .= $from;
|
616 |
-
$headers .= 'Content-type: ' . $content_type . '; charset="' . get_option('blog_charset') . '"' . "\r\n";
|
617 |
-
|
618 |
-
if ($replyto) {
|
619 |
-
$headers .= "Reply-To: <" . $replyto . ">\r\n";
|
620 |
-
}
|
621 |
-
if ($cca) {
|
622 |
-
$headers .= "Cc: " . $cca . "\r\n";
|
623 |
-
}
|
624 |
-
if ($bcc) {
|
625 |
-
$headers .= "Bcc: " . $bcc . "\r\n";
|
626 |
-
}
|
627 |
-
if (strpos($new_script, "%ip%") > -1) {
|
628 |
-
$new_script = str_replace("%ip%", $ip, $new_script);
|
629 |
-
}
|
630 |
-
if (strpos($new_script, "%all%") > -1) {
|
631 |
-
$new_script = str_replace("%all%", $list_user, $new_script);
|
632 |
-
}
|
633 |
-
$body = $new_script;
|
634 |
-
$send_copy = isset($_POST["wdform_send_copy_".$id]) ? $_POST["wdform_send_copy_".$id] : NULL;
|
635 |
-
if (isset($send_copy)) {
|
636 |
-
$send = TRUE;
|
637 |
-
}
|
638 |
-
else {
|
639 |
-
foreach ($send_tos as $send_to) {
|
640 |
-
$recipient = isset($_POST['wdform_'.str_replace('*', '', $send_to)."_element".$id]) ? $_POST['wdform_'.str_replace('*', '', $send_to)."_element".$id] : NULL;
|
641 |
-
if ($recipient) {
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
$
|
684 |
-
$
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
$
|
689 |
-
$list =
|
690 |
-
$
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
$
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
$headers
|
726 |
-
$headers .=
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
$
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
$
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
$
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
case '
|
829 |
-
case '
|
830 |
-
case '
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
944 |
-
|
945 |
-
|
946 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
947 |
-
|
948 |
-
|
949 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
950 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class CFMModelForm_maker {
|
4 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
5 |
+
// Events //
|
6 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
7 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
8 |
+
// Constants //
|
9 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
10 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
11 |
+
// Variables //
|
12 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
13 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
14 |
+
// Constructor & Destructor //
|
15 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
16 |
+
public function __construct() {
|
17 |
+
}
|
18 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
19 |
+
// Public Methods //
|
20 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
21 |
+
public function showform($id) {
|
22 |
+
global $wpdb;
|
23 |
+
$row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'contactformmaker WHERE id="%d"', $id));
|
24 |
+
if (!$row || !$row->published) {
|
25 |
+
return FALSE;
|
26 |
+
}
|
27 |
+
if (isset($_GET['test_theme']) && (esc_html(stripslashes($_GET['test_theme'])) != '')) {
|
28 |
+
/* From preview.*/
|
29 |
+
$theme_id = esc_html(stripslashes($_GET['test_theme']));
|
30 |
+
}
|
31 |
+
else {
|
32 |
+
$theme_id = $row->theme;
|
33 |
+
}
|
34 |
+
$form_theme = $wpdb->get_var($wpdb->prepare('SELECT css FROM ' . $wpdb->prefix . 'contactformmaker_themes WHERE id="%d"', $theme_id));
|
35 |
+
if (!$form_theme) {
|
36 |
+
$form_theme = $wpdb->get_var('SELECT css FROM ' . $wpdb->prefix . 'contactformmaker_themes');
|
37 |
+
if (!$form_theme) {
|
38 |
+
return FALSE;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
$pattern = '/\/\/(.+)(\r\n|\r|\n)/';
|
42 |
+
$form_theme = preg_replace($pattern, ' ', $form_theme);
|
43 |
+
$form_theme = str_replace('//', ' ', $form_theme);
|
44 |
+
$label_id = array();
|
45 |
+
$label_type = array();
|
46 |
+
$label_all = explode('#****#', $row->label_order);
|
47 |
+
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
48 |
+
foreach ($label_all as $key => $label_each) {
|
49 |
+
$label_id_each = explode('#**id**#', $label_each);
|
50 |
+
array_push($label_id, $label_id_each[0]);
|
51 |
+
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
52 |
+
array_push($label_type, $label_order_each[1]);
|
53 |
+
}
|
54 |
+
return array(
|
55 |
+
$row,
|
56 |
+
1,
|
57 |
+
$label_id,
|
58 |
+
$label_type,
|
59 |
+
$form_theme
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
public function savedata($form, $id) {
|
64 |
+
$fm_settings = get_option('cfm_settings');
|
65 |
+
$all_files = array();
|
66 |
+
$correct = FALSE;
|
67 |
+
$id_for_old = $id;
|
68 |
+
if (!$form->form_front) {
|
69 |
+
$id = '';
|
70 |
+
}
|
71 |
+
if (isset($_POST["counter" . $id])) {
|
72 |
+
$counter = esc_html($_POST["counter" . $id]);
|
73 |
+
if (isset($_POST["captcha_input"])) {
|
74 |
+
$captcha_input = esc_html($_POST["captcha_input"]);
|
75 |
+
$session_wd_captcha_code = isset($_SESSION[$id . '_wd_captcha_code']) ? $_SESSION[$id . '_wd_captcha_code'] : '-';
|
76 |
+
if ($captcha_input == $session_wd_captcha_code) {
|
77 |
+
$correct = TRUE;
|
78 |
+
}
|
79 |
+
else {
|
80 |
+
?>
|
81 |
+
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
82 |
+
<?php
|
83 |
+
}
|
84 |
+
}
|
85 |
+
elseif (isset($_POST["recaptcha_response_field"])) {
|
86 |
+
$recaptcha_response_field = esc_html($_POST["recaptcha_response_field"]);
|
87 |
+
$privatekey= isset($fm_settings['private_key']) ? $fm_settings['private_key'] : '';
|
88 |
+
$recaptcha_challenge_field = ((isset($_POST['recaptcha_challenge_field'])) ? esc_html($_POST['recaptcha_challenge_field']) : '');
|
89 |
+
require_once(WD_CFM_DIR . '/recaptchalib.php');
|
90 |
+
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
|
91 |
+
if ($resp->is_valid) {
|
92 |
+
$correct = TRUE;
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
?>
|
96 |
+
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
97 |
+
<?php
|
98 |
+
}
|
99 |
+
}
|
100 |
+
elseif (isset($_POST["g-recaptcha-response"])) {
|
101 |
+
$privatekey= isset($fm_settings['private_key']) ? $fm_settings['private_key'] : '';
|
102 |
+
$w = stream_get_wrappers();
|
103 |
+
if (in_array('https', $w)) {
|
104 |
+
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $privatekey . "&response=" . $_POST['g-recaptcha-response']);
|
105 |
+
$response = json_decode($response, true);
|
106 |
+
if ($response["success"] === true) {
|
107 |
+
$correct = TRUE;
|
108 |
+
}
|
109 |
+
else {
|
110 |
+
?>
|
111 |
+
<script>alert("<?php echo addslashes(__('Error, incorrect Security code.', 'contact_form_maker')); ?>");</script>
|
112 |
+
<?php
|
113 |
+
}
|
114 |
+
}
|
115 |
+
else {
|
116 |
+
?>
|
117 |
+
<script>alert("<?php echo addslashes(__('`php_openssl` extension is not enabled.', 'contact_form_maker')); ?>");</script>
|
118 |
+
<?php
|
119 |
+
}
|
120 |
+
}
|
121 |
+
else {
|
122 |
+
$correct = TRUE;
|
123 |
+
}
|
124 |
+
if ($correct) {
|
125 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
126 |
+
global $wpdb;
|
127 |
+
$blocked_ip = $wpdb->get_var($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'contactformmaker_blocked WHERE ip="%s"', $ip));
|
128 |
+
if ($blocked_ip) {
|
129 |
+
$_SESSION['cfm_massage_after_submit' . $id] = addslashes(__('Your ip is blacklisted. Please contact the website administrator.', 'contact_form_maker'));
|
130 |
+
wp_redirect($_SERVER["REQUEST_URI"]);
|
131 |
+
exit;
|
132 |
+
}
|
133 |
+
|
134 |
+
$all_files = $this->save_db($counter, $id_for_old);
|
135 |
+
if (is_numeric($all_files)) {
|
136 |
+
$this->remove($all_files, $id_for_old);
|
137 |
+
}
|
138 |
+
elseif (isset($counter)) {
|
139 |
+
$this->gen_mail($counter, $all_files, $id_for_old);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
return $all_files;
|
143 |
+
}
|
144 |
+
return $all_files;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function save_db($counter, $id) {
|
148 |
+
global $wpdb;
|
149 |
+
$chgnac = TRUE;
|
150 |
+
$all_files = array();
|
151 |
+
$form = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "contactformmaker WHERE id= %d", $id));
|
152 |
+
$id_old = $id;
|
153 |
+
if (!$form->form_front) {
|
154 |
+
$id = '';
|
155 |
+
}
|
156 |
+
$label_id = array();
|
157 |
+
$label_label = array();
|
158 |
+
$label_type = array();
|
159 |
+
$label_all = explode('#****#',$form->label_order_current);
|
160 |
+
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
161 |
+
foreach ($label_all as $key => $label_each) {
|
162 |
+
$label_id_each = explode('#**id**#', $label_each);
|
163 |
+
array_push($label_id, $label_id_each[0]);
|
164 |
+
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
165 |
+
array_push($label_label, $label_order_each[0]);
|
166 |
+
array_push($label_type, $label_order_each[1]);
|
167 |
+
}
|
168 |
+
$disabled_fields = explode(',', $form->disabled_fields);
|
169 |
+
$disabled_fields = array_slice($disabled_fields, 0, count($disabled_fields) - 1);
|
170 |
+
$max = $wpdb->get_var("SELECT MAX( group_id ) FROM " . $wpdb->prefix . "contactformmaker_submits");
|
171 |
+
foreach ($label_type as $key => $type) {
|
172 |
+
$value = '';
|
173 |
+
if ($type == "type_submit_reset" or $type == "type_map" or $type == "type_editor" or $type == "type_captcha" or $type == "type_recaptcha" or $type == "type_send_copy") {
|
174 |
+
continue;
|
175 |
+
}
|
176 |
+
$i = $label_id[$key];
|
177 |
+
if (!in_array($i, $disabled_fields)) {
|
178 |
+
switch ($type) {
|
179 |
+
case 'type_text':
|
180 |
+
case 'type_password':
|
181 |
+
case 'type_textarea':
|
182 |
+
case "type_submitter_mail":
|
183 |
+
case "type_own_select":
|
184 |
+
case "type_number": {
|
185 |
+
$value = isset($_POST['wdform_'.$i."_element".$id]) ? esc_html($_POST['wdform_'.$i."_element".$id]) : "";
|
186 |
+
break;
|
187 |
+
}
|
188 |
+
case "type_phone": {
|
189 |
+
$value = (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "");
|
190 |
+
break;
|
191 |
+
}
|
192 |
+
case "type_name": {
|
193 |
+
$element_title = isset($_POST['wdform_'.$i."_element_title".$id]) ? esc_html($_POST['wdform_'.$i."_element_title".$id]) : NULL;
|
194 |
+
if (isset($element_title)) {
|
195 |
+
$value = (isset($_POST['wdform_'.$i."_element_title".$id]) ? esc_html($_POST['wdform_'.$i."_element_title".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_middle".$id]) ? esc_html($_POST['wdform_'.$i."_element_middle".$id]) : "");
|
196 |
+
}
|
197 |
+
else {
|
198 |
+
$value = (isset($_POST['wdform_'.$i."_element_first".$id]) ? esc_html($_POST['wdform_'.$i."_element_first".$id]) : "") . '@@@' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? esc_html($_POST['wdform_'.$i."_element_last".$id]) : "");
|
199 |
+
}
|
200 |
+
break;
|
201 |
+
}
|
202 |
+
case 'type_address': {
|
203 |
+
$value = '*#*#*#';
|
204 |
+
$element = isset($_POST['wdform_'.$i."_street1".$id]) ? esc_html($_POST['wdform_'.$i."_street1".$id]) : NULL;
|
205 |
+
if (isset($element)) {
|
206 |
+
$value = $element;
|
207 |
+
break;
|
208 |
+
}
|
209 |
+
|
210 |
+
$element = isset($_POST['wdform_'.$i."_street2".$id]) ? esc_html($_POST['wdform_'.$i."_street2".$id]) : NULL;
|
211 |
+
if (isset($element)) {
|
212 |
+
$value = $element;
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
|
216 |
+
$element = isset($_POST['wdform_'.$i."_city".$id]) ? esc_html($_POST['wdform_'.$i."_city".$id]) : NULL;
|
217 |
+
if(isset($element)) {
|
218 |
+
$value = $element;
|
219 |
+
break;
|
220 |
+
}
|
221 |
+
|
222 |
+
$element = isset($_POST['wdform_'.$i."_state".$id]) ? esc_html($_POST['wdform_'.$i."_state".$id]) : NULL;
|
223 |
+
if(isset($element)) {
|
224 |
+
$value = $element;
|
225 |
+
break;
|
226 |
+
}
|
227 |
+
|
228 |
+
$element = isset($_POST['wdform_'.$i."_postal".$id]) ? esc_html($_POST['wdform_'.$i."_postal".$id]) : NULL;
|
229 |
+
if(isset($element)) {
|
230 |
+
$value = $element;
|
231 |
+
break;
|
232 |
+
}
|
233 |
+
|
234 |
+
$element = isset($_POST['wdform_'.$i."_country".$id]) ? esc_html($_POST['wdform_'.$i."_country".$id]) : NULL;
|
235 |
+
if(isset($element)) {
|
236 |
+
$value = $element;
|
237 |
+
break;
|
238 |
+
}
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
case "type_radio": {
|
242 |
+
$element = isset($_POST['wdform_'.$i."_other_input".$id]) ? esc_html($_POST['wdform_'.$i."_other_input".$id]) : NULL;
|
243 |
+
if(isset($element)) {
|
244 |
+
$value = $element;
|
245 |
+
break;
|
246 |
+
}
|
247 |
+
$value = isset($_POST['wdform_'.$i."_element".$id]) ? esc_html($_POST['wdform_'.$i."_element".$id]) : "";
|
248 |
+
break;
|
249 |
+
}
|
250 |
+
case "type_checkbox": {
|
251 |
+
$start = -1;
|
252 |
+
$value = '';
|
253 |
+
for($j = 0; $j < 100; $j++) {
|
254 |
+
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : NULL;
|
255 |
+
if(isset($element)) {
|
256 |
+
$start = $j;
|
257 |
+
break;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
$other_element_id = -1;
|
262 |
+
$is_other = isset($_POST['wdform_'.$i."_allow_other".$id]) ? esc_html($_POST['wdform_'.$i."_allow_other".$id]) : "";
|
263 |
+
if($is_other == "yes") {
|
264 |
+
$other_element_id = isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? esc_html($_POST['wdform_'.$i."_allow_other_num".$id]) : "";
|
265 |
+
}
|
266 |
+
|
267 |
+
if($start != -1) {
|
268 |
+
for($j = $start; $j < 100; $j++) {
|
269 |
+
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : NULL;
|
270 |
+
if(isset($element)) {
|
271 |
+
if($j == $other_element_id) {
|
272 |
+
$value = $value . (isset($_POST['wdform_'.$i."_other_input".$id]) ? esc_html($_POST['wdform_'.$i."_other_input".$id]) : "") . '***br***';
|
273 |
+
}
|
274 |
+
else {
|
275 |
+
$value = $value . (isset($_POST['wdform_'.$i."_element".$id.$j]) ? esc_html($_POST['wdform_'.$i."_element".$id.$j]) : "") . '***br***';
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
break;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
if ($type == "type_address") {
|
284 |
+
if( $value == '*#*#*#') {
|
285 |
+
continue;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
if ($type == "type_text" or $type == "type_password" or $type == "type_textarea" or $type == "type_name" or $type == "type_submitter_mail" or $type == "type_number" or $type == "type_phone") {
|
289 |
+
$untilupload = $form->form_fields;
|
290 |
+
$untilupload = substr($untilupload, strpos($untilupload, $i.'*:*id*:*'.$type), -1);
|
291 |
+
$untilupload = substr($untilupload, 0, strpos($untilupload, '*:*new_field*:'));
|
292 |
+
$untilupload = explode('*:*w_required*:*', $untilupload);
|
293 |
+
$untilupload = $untilupload[1];
|
294 |
+
$untilupload = explode('*:*w_unique*:*', $untilupload);
|
295 |
+
$unique_element = $untilupload[0];
|
296 |
+
if ($unique_element == 'yes') {
|
297 |
+
$unique = $wpdb->get_col($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "contactformmaker_submits WHERE form_id= %d and element_label= %s and element_value= %s", $id, $i, addslashes($value)));
|
298 |
+
if ($unique) {
|
299 |
+
echo "<script> alert('" . addslashes(__('This field %s requires a unique entry and this value was already submitted.', 'contact_form_maker')) . "'.replace('%s','" . $label_label[$key] . "'));</script>";
|
300 |
+
return array($max + 1);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
if ($form->savedb) {
|
305 |
+
$save_or_no = $wpdb->insert($wpdb->prefix . "contactformmaker_submits", array(
|
306 |
+
'form_id' => $id,
|
307 |
+
'element_label' => $i,
|
308 |
+
'element_value' => stripslashes($value),
|
309 |
+
'group_id' => ($max + 1),
|
310 |
+
'date' => date('Y-m-d H:i:s'),
|
311 |
+
'ip' => $_SERVER['REMOTE_ADDR'],
|
312 |
+
), array(
|
313 |
+
'%d',
|
314 |
+
'%s',
|
315 |
+
'%s',
|
316 |
+
'%d',
|
317 |
+
'%s',
|
318 |
+
'%s'
|
319 |
+
));
|
320 |
+
}
|
321 |
+
if (!$save_or_no) {
|
322 |
+
return FALSE;
|
323 |
+
}
|
324 |
+
$chgnac = FALSE;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
if ($chgnac) {
|
328 |
+
global $wpdb;
|
329 |
+
if ($form->submit_text_type != 4) {
|
330 |
+
$_SESSION['cfm_massage_after_submit' . $id] = addslashes(addslashes(__('Nothing was submitted.', 'contact_form_maker')));
|
331 |
+
}
|
332 |
+
$_SESSION['cfm_error_or_no' . $id] = 1;
|
333 |
+
$_SESSION['cfm_form_submit_type' . $id] = $form->submit_text_type . "," . $form->id;
|
334 |
+
wp_redirect($_SERVER["REQUEST_URI"]);
|
335 |
+
exit;
|
336 |
+
}
|
337 |
+
return array($all_files);
|
338 |
+
}
|
339 |
+
|
340 |
+
public function remove($group_id) {
|
341 |
+
global $wpdb;
|
342 |
+
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'contactformmaker_submits WHERE group_id= %d', $group_id));
|
343 |
+
}
|
344 |
+
|
345 |
+
public function get_after_submission_text($form_id) {
|
346 |
+
global $wpdb;
|
347 |
+
return $wpdb->get_var("SELECT submit_text FROM " . $wpdb->prefix . "contactformmaker WHERE id='" . $form_id . "'");
|
348 |
+
}
|
349 |
+
|
350 |
+
public function increment_views_count($id) {
|
351 |
+
global $wpdb;
|
352 |
+
$vives_form = $wpdb->get_var($wpdb->prepare("SELECT views FROM " . $wpdb->prefix . "contactformmaker_views WHERE form_id=%d", $id));
|
353 |
+
if (isset($vives_form)) {
|
354 |
+
$vives_form = $vives_form + 1;
|
355 |
+
$wpdb->update($wpdb->prefix . "contactformmaker_views", array(
|
356 |
+
'views' => $vives_form,
|
357 |
+
), array('form_id' => $id), array(
|
358 |
+
'%d',
|
359 |
+
), array('%d'));
|
360 |
+
}
|
361 |
+
else {
|
362 |
+
$wpdb->insert($wpdb->prefix . 'contactformmaker_views', array(
|
363 |
+
'form_id' => $id,
|
364 |
+
'views' => 1
|
365 |
+
), array(
|
366 |
+
'%d',
|
367 |
+
'%d'
|
368 |
+
));
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
public function gen_mail($counter, $all_files, $id) {
|
373 |
+
global $wpdb;
|
374 |
+
$row = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "contactformmaker WHERE id=%d", $id));
|
375 |
+
if (!$row->form_front) {
|
376 |
+
$id = '';
|
377 |
+
}
|
378 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
379 |
+
$replyto = '';
|
380 |
+
$label_order_original = array();
|
381 |
+
$label_order_ids = array();
|
382 |
+
$label_label = array();
|
383 |
+
$label_type = array();
|
384 |
+
$cc = array();
|
385 |
+
$row_mail_one_time = 1;
|
386 |
+
$label_type = array();
|
387 |
+
$label_all = explode('#****#', $row->label_order_current);
|
388 |
+
$label_all = array_slice($label_all, 0, count($label_all) - 1);
|
389 |
+
foreach ($label_all as $key => $label_each) {
|
390 |
+
$label_id_each = explode('#**id**#', $label_each);
|
391 |
+
$label_id = $label_id_each[0];
|
392 |
+
array_push($label_order_ids, $label_id);
|
393 |
+
$label_order_each = explode('#**label**#', $label_id_each[1]);
|
394 |
+
$label_order_original[$label_id] = $label_order_each[0];
|
395 |
+
$label_type[$label_id] = $label_order_each[1];
|
396 |
+
array_push($label_label, $label_order_each[0]);
|
397 |
+
array_push($label_type, $label_order_each[1]);
|
398 |
+
}
|
399 |
+
$disabled_fields = explode(',', $row->disabled_fields);
|
400 |
+
$disabled_fields = array_slice($disabled_fields, 0, count($disabled_fields) - 1);
|
401 |
+
$list = '<table border="1" cellpadding="3" cellspacing="0" style="width:600px;">';
|
402 |
+
$list_text_mode = '';
|
403 |
+
foreach ($label_order_ids as $key => $label_order_id) {
|
404 |
+
$i = $label_order_id;
|
405 |
+
$type = $label_type[$i];
|
406 |
+
if ($type != "type_map" and $type != "type_submit_reset" and $type != "type_editor" and $type != "type_captcha" and $type != "type_recaptcha" and $type != "type_send_copy") {
|
407 |
+
$element_label = $label_order_original[$i];
|
408 |
+
if (!in_array($i, $disabled_fields)) {
|
409 |
+
switch ($type) {
|
410 |
+
case 'type_text':
|
411 |
+
case 'type_password':
|
412 |
+
case 'type_textarea':
|
413 |
+
case "type_own_select":
|
414 |
+
case "type_number": {
|
415 |
+
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
416 |
+
if (isset($element)) {
|
417 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
418 |
+
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
419 |
+
}
|
420 |
+
break;
|
421 |
+
}
|
422 |
+
case "type_submitter_mail": {
|
423 |
+
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
424 |
+
if (isset($element)) {
|
425 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td ><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
426 |
+
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
427 |
+
}
|
428 |
+
break;
|
429 |
+
}
|
430 |
+
case "type_phone": {
|
431 |
+
$element_first = isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL;
|
432 |
+
if (isset($element_first)) {
|
433 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . '</td></tr>';
|
434 |
+
$list_text_mode .= $element_label . ' - ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . "\r\n";
|
435 |
+
}
|
436 |
+
break;
|
437 |
+
}
|
438 |
+
case "type_name": {
|
439 |
+
$element_first = isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL;
|
440 |
+
if (isset($element_first)) {
|
441 |
+
$element_title = isset($_POST['wdform_'.$i."_element_title".$id]) ? $_POST['wdform_'.$i."_element_title".$id] : NULL;
|
442 |
+
if (isset($element_title)) {
|
443 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_title . ' ' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . ' ' . (isset($_POST['wdform_'.$i."_element_middle".$id]) ? $_POST['wdform_'.$i."_element_middle".$id] : "") . '</td></tr>';
|
444 |
+
$list_text_mode .= $element_label . ' - ' . $element_title . ' ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . ' ' . (isset($_POST['wdform_' . $i . "_element_middle" . $id]) ? $_POST['wdform_' . $i . "_element_middle" . $id] : "") . "\r\n";
|
445 |
+
}
|
446 |
+
else {
|
447 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element_first . ' ' . (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : "") . '</td></tr>';
|
448 |
+
$list_text_mode .= $element_label . ' - ' . $element_first . ' ' . (isset($_POST['wdform_' . $i . "_element_last" . $id]) ? $_POST['wdform_' . $i . "_element_last" . $id] : "") . "\r\n";
|
449 |
+
}
|
450 |
+
}
|
451 |
+
break;
|
452 |
+
}
|
453 |
+
case "type_address": {
|
454 |
+
$element = isset($_POST['wdform_'.$i."_street1".$id]) ? $_POST['wdform_'.$i."_street1".$id] : NULL;
|
455 |
+
if (isset($element)) {
|
456 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
457 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
458 |
+
break;
|
459 |
+
}
|
460 |
+
$element = isset($_POST['wdform_'.$i."_street2".$id]) ? $_POST['wdform_'.$i."_street2".$id] : NULL;
|
461 |
+
if (isset($element)) {
|
462 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
463 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
464 |
+
break;
|
465 |
+
}
|
466 |
+
$element = isset($_POST['wdform_'.$i."_city".$id]) ? $_POST['wdform_'.$i."_city".$id] : NULL;
|
467 |
+
if (isset($element)) {
|
468 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
469 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
470 |
+
break;
|
471 |
+
}
|
472 |
+
$element = isset($_POST['wdform_'.$i."_state".$id]) ? $_POST['wdform_'.$i."_state".$id] : NULL;
|
473 |
+
if (isset($element)) {
|
474 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
475 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
476 |
+
break;
|
477 |
+
}
|
478 |
+
$element = isset($_POST['wdform_'.$i."_postal".$id]) ? $_POST['wdform_'.$i."_postal".$id] : NULL;
|
479 |
+
if (isset($element)) {
|
480 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
481 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
482 |
+
break;
|
483 |
+
}
|
484 |
+
$element = isset($_POST['wdform_'.$i."_country".$id]) ? $_POST['wdform_'.$i."_country".$id] : NULL;
|
485 |
+
if (isset($element)) {
|
486 |
+
$list = $list . '<tr valign="top"><td >' . $label_order_original[$i] . '</td><td >' . $element . '</td></tr>';
|
487 |
+
$list_text_mode .= $label_order_original[$i] . ' - ' . $element . "\r\n";
|
488 |
+
break;
|
489 |
+
}
|
490 |
+
break;
|
491 |
+
}
|
492 |
+
case "type_radio": {
|
493 |
+
$element = isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : NULL;
|
494 |
+
if (isset($element)) {
|
495 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >' . $element . '</td></tr>';
|
496 |
+
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
497 |
+
break;
|
498 |
+
}
|
499 |
+
$element = isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL;
|
500 |
+
if(isset($element)) {
|
501 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td ><pre style="font-family:inherit; margin:0px; padding:0px">' . $element . '</pre></td></tr>';
|
502 |
+
$list_text_mode .= $element_label . ' - ' . $element . "\r\n";
|
503 |
+
}
|
504 |
+
break;
|
505 |
+
}
|
506 |
+
case "type_checkbox": {
|
507 |
+
$list = $list . '<tr valign="top"><td >' . $element_label . '</td><td >';
|
508 |
+
$list_text_mode .= $element_label . ' - ';
|
509 |
+
$start = -1;
|
510 |
+
for ($j = 0; $j < 100; $j++) {
|
511 |
+
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL;
|
512 |
+
if (isset($element)) {
|
513 |
+
$start = $j;
|
514 |
+
break;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
$other_element_id = -1;
|
518 |
+
$is_other = isset($_POST['wdform_'.$i."_allow_other".$id]) ? $_POST['wdform_'.$i."_allow_other".$id] : "";
|
519 |
+
if ($is_other == "yes") {
|
520 |
+
$other_element_id = isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? $_POST['wdform_'.$i."_allow_other_num".$id] : "";
|
521 |
+
}
|
522 |
+
if ($start != -1) {
|
523 |
+
for ($j = $start; $j < 100; $j++) {
|
524 |
+
$element = isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL;
|
525 |
+
if (isset($element)) {
|
526 |
+
if ($j == $other_element_id) {
|
527 |
+
$list = $list . (isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : "") . '<br>';
|
528 |
+
$list_text_mode .= (isset($_POST['wdform_' . $i . "_other_input" . $id]) ? $_POST['wdform_' . $i . "_other_input" . $id] : "") . ', ';
|
529 |
+
}
|
530 |
+
else {
|
531 |
+
$list = $list . (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : "") . '<br>';
|
532 |
+
$list_text_mode .= (isset($_POST['wdform_' . $i . "_element" . $id . $j]) ? $_POST['wdform_' . $i . "_element" . $id . $j] : "") . ', ';
|
533 |
+
}
|
534 |
+
}
|
535 |
+
}
|
536 |
+
$list = $list . '</td></tr>';
|
537 |
+
}
|
538 |
+
break;
|
539 |
+
}
|
540 |
+
default: break;
|
541 |
+
}
|
542 |
+
}
|
543 |
+
}
|
544 |
+
}
|
545 |
+
$list = $list . '</table>';
|
546 |
+
// $list = wordwrap($list, 70, "\n", TRUE);
|
547 |
+
|
548 |
+
|
549 |
+
if ($row->sendemail) {
|
550 |
+
if ($row->send_to) {
|
551 |
+
$fromname = $row->mail_from_name_user;
|
552 |
+
if ($row->mail_subject_user) {
|
553 |
+
$subject = $row->mail_subject_user;
|
554 |
+
}
|
555 |
+
else {
|
556 |
+
$subject = $row->title;
|
557 |
+
}
|
558 |
+
/*if (isset($_REQUEST['wdform_22_element' . $id])) {
|
559 |
+
$subject = ($row->title) . ' : ' . $_REQUEST['wdform_22_element' . $id];
|
560 |
+
}
|
561 |
+
else {
|
562 |
+
$subject = $row->title;
|
563 |
+
}*/
|
564 |
+
if ($row->reply_to_user) {
|
565 |
+
$replyto = $row->reply_to_user;
|
566 |
+
}
|
567 |
+
if ($row->mail_mode_user) {
|
568 |
+
$content_type = "text/html";
|
569 |
+
$list_user = wordwrap($list, 70, "\n", TRUE);
|
570 |
+
$new_script = $row->script_mail_user;
|
571 |
+
}
|
572 |
+
else {
|
573 |
+
$content_type = "text/plain";
|
574 |
+
$list_user = wordwrap($list_text_mode, 1000, "\n", TRUE);
|
575 |
+
$new_script = str_replace(array('<p>', '</p>'), '', $row->script_mail_user);
|
576 |
+
}
|
577 |
+
foreach ($label_order_original as $key => $label_each) {
|
578 |
+
$type = $label_type[$key];
|
579 |
+
if (strpos($row->script_mail_user, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
580 |
+
$new_value = $this->custom_fields_mail($type, $key, $id);
|
581 |
+
$new_script = str_replace("%" . $label_each . "%", $new_value, $new_script);
|
582 |
+
}
|
583 |
+
if (strpos($fromname, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
584 |
+
$new_value = str_replace('<br>', ', ', $this->custom_fields_mail($type, $key, $id));
|
585 |
+
if (substr($new_value, -2) == ', ') {
|
586 |
+
$new_value = substr($new_value, 0, -2);
|
587 |
+
}
|
588 |
+
$fromname = str_replace("%" . $label_each . "%", $new_value, $fromname);
|
589 |
+
}
|
590 |
+
if (strpos($subject, "%" . $label_each . "%") > -1) {
|
591 |
+
$new_value = str_replace('<br>', ', ', $this->custom_fields_mail($type, $key, $id));
|
592 |
+
if (substr($new_value, -2) == ', ') {
|
593 |
+
$new_value = substr($new_value, 0, -2);
|
594 |
+
}
|
595 |
+
$subject = str_replace("%" . $label_each . "%", $new_value, $subject);
|
596 |
+
}
|
597 |
+
}
|
598 |
+
$recipient = '';
|
599 |
+
$cca = $row->mail_cc_user;
|
600 |
+
$bcc = $row->mail_bcc_user;
|
601 |
+
$send_tos = explode('**', $row->send_to);
|
602 |
+
if ($row->mail_from_user != '') {
|
603 |
+
if ($row->mail_from_name_user != '') {
|
604 |
+
$from = "From: '" . htmlspecialchars_decode($row->mail_from_name_user, ENT_QUOTES) . "' <" . $row->mail_from_user . ">" . "\r\n";
|
605 |
+
}
|
606 |
+
else {
|
607 |
+
$from = "From: '" . $row->mail_from_user . "' <" . $row->mail_from_user . ">" . "\r\n";
|
608 |
+
}
|
609 |
+
}
|
610 |
+
else {
|
611 |
+
$from = '';
|
612 |
+
}
|
613 |
+
|
614 |
+
$headers = ''; //'MIME-Version: 1.0' . "\r\n";
|
615 |
+
$headers .= $from;
|
616 |
+
$headers .= 'Content-type: ' . $content_type . '; charset="' . get_option('blog_charset') . '"' . "\r\n";
|
617 |
+
|
618 |
+
if ($replyto) {
|
619 |
+
$headers .= "Reply-To: <" . $replyto . ">\r\n";
|
620 |
+
}
|
621 |
+
if ($cca) {
|
622 |
+
$headers .= "Cc: " . $cca . "\r\n";
|
623 |
+
}
|
624 |
+
if ($bcc) {
|
625 |
+
$headers .= "Bcc: " . $bcc . "\r\n";
|
626 |
+
}
|
627 |
+
if (strpos($new_script, "%ip%") > -1) {
|
628 |
+
$new_script = str_replace("%ip%", $ip, $new_script);
|
629 |
+
}
|
630 |
+
if (strpos($new_script, "%all%") > -1) {
|
631 |
+
$new_script = str_replace("%all%", $list_user, $new_script);
|
632 |
+
}
|
633 |
+
$body = $new_script;
|
634 |
+
$send_copy = isset($_POST["wdform_send_copy_".$id]) ? $_POST["wdform_send_copy_".$id] : NULL;
|
635 |
+
if (isset($send_copy)) {
|
636 |
+
$send = TRUE;
|
637 |
+
}
|
638 |
+
else {
|
639 |
+
foreach ($send_tos as $send_to) {
|
640 |
+
$recipient = isset($_POST['wdform_'.str_replace('*', '', $send_to)."_element".$id]) ? $_POST['wdform_'.str_replace('*', '', $send_to)."_element".$id] : NULL;
|
641 |
+
if ($recipient) {
|
642 |
+
$recipient = trim(str_replace(' ', '', $recipient), ',');
|
643 |
+
if ($row->wpmail) {
|
644 |
+
$send = wp_mail($recipient, $subject, stripslashes($body), $headers);
|
645 |
+
}
|
646 |
+
else {
|
647 |
+
$send = mail($recipient, $subject, stripslashes($body), $headers);
|
648 |
+
}
|
649 |
+
}
|
650 |
+
}
|
651 |
+
}
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
if ($row->sendemail) {
|
656 |
+
if ($row->mail) {
|
657 |
+
if ($row->reply_to) {
|
658 |
+
$replyto = isset($_POST['wdform_'.$row->reply_to."_element".$id]) ? $_POST['wdform_'.$row->reply_to."_element".$id] : NULL;
|
659 |
+
if (!isset($replyto)) {
|
660 |
+
$replyto = $row->reply_to;
|
661 |
+
}
|
662 |
+
}
|
663 |
+
$recipient = $row->mail;
|
664 |
+
/*if (isset($_REQUEST['wdform_22_element' . $id])) {
|
665 |
+
$subject = $row->title . ' : ' . $_REQUEST['wdform_22_element' . $id];
|
666 |
+
}
|
667 |
+
else {
|
668 |
+
$subject = $row->title;
|
669 |
+
}*/
|
670 |
+
if ($row->mail_subject) {
|
671 |
+
$subject = $row->mail_subject;
|
672 |
+
}
|
673 |
+
else {
|
674 |
+
$subject = $row->title;
|
675 |
+
}
|
676 |
+
if ($row->mail_from_name) {
|
677 |
+
$fromname = $row->mail_from_name;
|
678 |
+
}
|
679 |
+
else {
|
680 |
+
$fromname = '';
|
681 |
+
}
|
682 |
+
if ($row->mail_mode) {
|
683 |
+
$content_type = "text/html";
|
684 |
+
$list = wordwrap($list, 70, "\n", TRUE);
|
685 |
+
$new_script = $row->script_mail;
|
686 |
+
}
|
687 |
+
else {
|
688 |
+
$content_type = "text/plain";
|
689 |
+
$list = $list_text_mode;
|
690 |
+
$list = wordwrap($list, 1000, "\n", TRUE);
|
691 |
+
$new_script = str_replace(array('<p>', '</p>'), '', $row->script_mail);
|
692 |
+
}
|
693 |
+
foreach ($label_order_original as $key => $label_each) {
|
694 |
+
$type = $label_type[$key];
|
695 |
+
if (strpos($row->script_mail, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
696 |
+
$new_value = $this->custom_fields_mail($type, $key, $id);
|
697 |
+
$new_script = str_replace("%" . $label_each . "%", $new_value, $new_script);
|
698 |
+
}
|
699 |
+
if (strpos($fromname, "%" . $label_each . "%") !== FALSE && !in_array($key,$disabled_fields)) {
|
700 |
+
$new_value = str_replace('<br>',', ',$this->custom_fields_mail($type, $key, $id));
|
701 |
+
if (substr($new_value, -2) == ', ') {
|
702 |
+
$new_value = substr($new_value, 0, -2);
|
703 |
+
}
|
704 |
+
$fromname = str_replace("%".$label_each."%", $new_value, $fromname);
|
705 |
+
}
|
706 |
+
if (strpos($subject, "%" . $label_each . "%") > -1) {
|
707 |
+
$new_value = str_replace('<br>', ', ', $this->custom_fields_mail($type, $key, $id));
|
708 |
+
if (substr($new_value, -2) == ', ') {
|
709 |
+
$new_value = substr($new_value, 0, -2);
|
710 |
+
}
|
711 |
+
$subject = str_replace("%" . $label_each . "%", $new_value, $subject);
|
712 |
+
}
|
713 |
+
}
|
714 |
+
if ($row->mail_from) {
|
715 |
+
$from = isset($_POST['wdform_' . $row->mail_from . "_element" . $id]) ? $_POST['wdform_' . $row->mail_from . "_element" . $id] : NULL;
|
716 |
+
if (!isset($from)) {
|
717 |
+
$from = $row->mail_from;
|
718 |
+
}
|
719 |
+
$from = "From: '" . htmlspecialchars_decode($fromname, ENT_QUOTES) . "' <" . $from . ">" . "\r\n";
|
720 |
+
}
|
721 |
+
else {
|
722 |
+
$from = "";
|
723 |
+
}
|
724 |
+
|
725 |
+
$headers = ''; //'MIME-Version: 1.0' . "\r\n";
|
726 |
+
$headers .= $from;
|
727 |
+
$headers .= 'Content-type: ' . $content_type . '; charset="' . get_option('blog_charset') . '"' . "\r\n";
|
728 |
+
|
729 |
+
if ($replyto) {
|
730 |
+
$headers .= "Reply-To: <" . $replyto . ">\r\n";
|
731 |
+
}
|
732 |
+
$cca = $row->mail_cc;
|
733 |
+
$bcc = $row->mail_bcc;
|
734 |
+
if ($cca) {
|
735 |
+
$headers .= "Cc: " . $cca . "\r\n";
|
736 |
+
}
|
737 |
+
if ($bcc) {
|
738 |
+
$headers .= "Bcc: " . $bcc . "\r\n";
|
739 |
+
}
|
740 |
+
if (strpos($new_script, "%ip%") > -1) {
|
741 |
+
$new_script = str_replace("%ip%", $ip, $new_script);
|
742 |
+
}
|
743 |
+
if (strpos($new_script, "%all%") > -1) {
|
744 |
+
$new_script = str_replace("%all%", $list, $new_script);
|
745 |
+
}
|
746 |
+
$body = $new_script;
|
747 |
+
if ($row->sendemail) {
|
748 |
+
$recipient = trim(str_replace(' ', '', $recipient), ',');
|
749 |
+
if ($row->wpmail) {
|
750 |
+
$send = wp_mail($recipient, $subject, stripslashes($body), $headers);
|
751 |
+
}
|
752 |
+
else {
|
753 |
+
$send = mail($recipient, $subject, stripslashes($body), $headers);
|
754 |
+
}
|
755 |
+
}
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
$_SESSION['cfm_error_or_no' . $id] = 0;
|
760 |
+
$msg = addslashes(__('Your form was successfully submitted.', 'contact_form_maker'));
|
761 |
+
$succes = 1;
|
762 |
+
|
763 |
+
if ($row->sendemail) {
|
764 |
+
if ($row->mail || $row->send_to) {
|
765 |
+
if ($send) {
|
766 |
+
if ($send !== TRUE) {
|
767 |
+
$_SESSION['cfm_error_or_no' . $id] = 1;
|
768 |
+
$msg = addslashes(__('Error, email was not sent.', 'contact_form_maker'));
|
769 |
+
$succes = 0;
|
770 |
+
}
|
771 |
+
else {
|
772 |
+
$_SESSION['cfm_error_or_no' . $id] = 0;
|
773 |
+
$msg = addslashes(__('Your form was successfully submitted.', 'contact_form_maker'));
|
774 |
+
}
|
775 |
+
}
|
776 |
+
}
|
777 |
+
}
|
778 |
+
|
779 |
+
$https = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
|
780 |
+
switch ($row->submit_text_type) {
|
781 |
+
case "2":
|
782 |
+
case "5": {
|
783 |
+
if ($row->submit_text_type != 4) {
|
784 |
+
$_SESSION['cfm_massage_after_submit' . $id] = $msg;
|
785 |
+
}
|
786 |
+
$_SESSION['cfm_form_submit_type' . $id] = $row->submit_text_type . "," . $row->id;
|
787 |
+
if ($row->article_id) {
|
788 |
+
$redirect_url = $row->article_id;
|
789 |
+
}
|
790 |
+
else {
|
791 |
+
$redirect_url = $https . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
|
792 |
+
}
|
793 |
+
break;
|
794 |
+
}
|
795 |
+
case "3": {
|
796 |
+
if ($row->submit_text_type != 4) {
|
797 |
+
$_SESSION['cfm_massage_after_submit' . $id] = $msg;
|
798 |
+
}
|
799 |
+
$_SESSION['cfm_form_submit_type' . $id] = $row->submit_text_type . "," . $row->id;
|
800 |
+
$redirect_url = $https . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
|
801 |
+
break;
|
802 |
+
}
|
803 |
+
case "4": {
|
804 |
+
if ($row->submit_text_type != 4) {
|
805 |
+
$_SESSION['cfm_massage_after_submit' . $id] = $msg;
|
806 |
+
}
|
807 |
+
$_SESSION['cfm_form_submit_type' . $id] = $row->submit_text_type . "," . $row->id;
|
808 |
+
$redirect_url = $row->url;
|
809 |
+
break;
|
810 |
+
}
|
811 |
+
default: {
|
812 |
+
if ($row->submit_text_type != 4) {
|
813 |
+
$_SESSION['cfm_massage_after_submit' . $id] = $msg;
|
814 |
+
}
|
815 |
+
$_SESSION['cfm_form_submit_type' . $id] = $row->submit_text_type . "," . $row->id;
|
816 |
+
$redirect_url = $https . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
|
817 |
+
break;
|
818 |
+
}
|
819 |
+
}
|
820 |
+
wp_redirect($redirect_url);
|
821 |
+
exit;
|
822 |
+
}
|
823 |
+
|
824 |
+
public function custom_fields_mail($type, $key, $id) {
|
825 |
+
$new_value = "";
|
826 |
+
if ($type != "type_submit_reset" or $type != "type_map" or $type != "type_editor" or $type != "type_captcha" or $type != "type_recaptcha" or $type != "type_button") {
|
827 |
+
switch ($type) {
|
828 |
+
case 'type_text':
|
829 |
+
case 'type_password':
|
830 |
+
case 'type_textarea':
|
831 |
+
case 'type_own_select':
|
832 |
+
case 'type_number': {
|
833 |
+
if (isset($_POST['wdform_' . $key . "_element" . $id])) {
|
834 |
+
$new_value = $_POST['wdform_'.$key."_element".$id];
|
835 |
+
}
|
836 |
+
break;
|
837 |
+
}
|
838 |
+
case "type_submitter_mail": {
|
839 |
+
if (isset($_POST['wdform_' . $key . "_element" . $id])) {
|
840 |
+
$new_value = $_POST['wdform_' . $key . "_element" . $id];
|
841 |
+
}
|
842 |
+
break;
|
843 |
+
}
|
844 |
+
case "type_phone": {
|
845 |
+
if (isset($_POST['wdform_' . $key . "_element_first" . $id])) {
|
846 |
+
$new_value = $_POST['wdform_'.$key."_element_first".$id] . ' ' . (isset($_POST['wdform_'.$key."_element_last".$id]) ? $_POST['wdform_'.$key."_element_last".$id] : "");
|
847 |
+
}
|
848 |
+
break;
|
849 |
+
}
|
850 |
+
case "type_name": {
|
851 |
+
$element_first = isset($_POST['wdform_'.$key."_element_first".$id]) ? $_POST['wdform_'.$key."_element_first".$id] : NULL;
|
852 |
+
if (isset($element_first)) {
|
853 |
+
$element_title = isset($_POST['wdform_'.$key."_element_title".$id]) ? $_POST['wdform_'.$key."_element_title".$id] : NULL;
|
854 |
+
if (isset($element_title)) {
|
855 |
+
$new_value = $element_title . ' ' . $element_first . ' ' . (isset($_POST['wdform_'.$key."_element_last".$id]) ? $_POST['wdform_'.$key."_element_last".$id] : "") . ' ' . (isset($_POST['wdform_'.$key."_element_middle".$id]) ? $_POST['wdform_'.$key."_element_middle".$id] : "");
|
856 |
+
}
|
857 |
+
else {
|
858 |
+
$new_value = $element_first . ' ' . (isset($_POST['wdform_'.$key."_element_last".$id]) ? $_POST['wdform_'.$key."_element_last".$id] : "");
|
859 |
+
}
|
860 |
+
}
|
861 |
+
break;
|
862 |
+
}
|
863 |
+
case "type_address": {
|
864 |
+
$street1 = isset($_POST['wdform_'.$key."_street1".$id]) ? $_POST['wdform_'.$key."_street1".$id] : NULL;
|
865 |
+
if (isset($street1)) {
|
866 |
+
$new_value = $street1;
|
867 |
+
break;
|
868 |
+
}
|
869 |
+
$street2 = isset($_POST['wdform_'.$key."_street2".$id]) ? $_POST['wdform_'.$key."_street2".$id] : NULL;
|
870 |
+
if (isset($street2)) {
|
871 |
+
$new_value = $street2;
|
872 |
+
break;
|
873 |
+
}
|
874 |
+
$city = isset($_POST['wdform_'.$key."_city".$id]) ? $_POST['wdform_'.$key."_city".$id] : NULL;
|
875 |
+
if (isset($city)) {
|
876 |
+
$new_value = $city;
|
877 |
+
break;
|
878 |
+
}
|
879 |
+
$state = isset($_POST['wdform_'.$key."_state".$id]) ? $_POST['wdform_'.$key."_state".$id] : NULL;
|
880 |
+
if (isset($state)) {
|
881 |
+
$new_value = $state;
|
882 |
+
break;
|
883 |
+
}
|
884 |
+
$postal = isset($_POST['wdform_'.$key."_postal".$id]) ? $_POST['wdform_'.$key."_postal".$id] : NULL;
|
885 |
+
if (isset($postal)) {
|
886 |
+
$new_value = $postal;
|
887 |
+
break;
|
888 |
+
}
|
889 |
+
$country = isset($_POST['wdform_'.$key."_country".$id]) ? $_POST['wdform_'.$key."_country".$id] : NULL;
|
890 |
+
if (isset($country)) {
|
891 |
+
$new_value = $country;
|
892 |
+
break;
|
893 |
+
}
|
894 |
+
break;
|
895 |
+
}
|
896 |
+
case "type_radio": {
|
897 |
+
$element = isset($_POST['wdform_'.$key."_other_input".$id]) ? $_POST['wdform_'.$key."_other_input".$id] : NULL;
|
898 |
+
if (isset($element)) {
|
899 |
+
$new_value = $element;
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
$element = isset($_POST['wdform_'.$key."_element".$id]) ? $_POST['wdform_'.$key."_element".$id] : NULL;
|
903 |
+
if(isset($element)) {
|
904 |
+
$new_value = $element;
|
905 |
+
}
|
906 |
+
break;
|
907 |
+
}
|
908 |
+
case "type_checkbox": {
|
909 |
+
$start = -1;
|
910 |
+
for ($j = 0; $j < 100; $j++) {
|
911 |
+
$element = isset($_POST['wdform_'.$key."_element".$id.$j]) ? $_POST['wdform_'.$key."_element".$id.$j] : NULL;
|
912 |
+
if (isset($element)) {
|
913 |
+
$start = $j;
|
914 |
+
break;
|
915 |
+
}
|
916 |
+
}
|
917 |
+
$other_element_id = -1;
|
918 |
+
$is_other = isset($_POST['wdform_'.$key."_allow_other".$id]) ? $_POST['wdform_'.$key."_allow_other".$id] : "";
|
919 |
+
if ($is_other == "yes") {
|
920 |
+
$other_element_id = isset($_POST['wdform_'.$key."_allow_other_num".$id]) ? $_POST['wdform_'.$key."_allow_other_num".$id] : "";
|
921 |
+
}
|
922 |
+
if ($start != -1) {
|
923 |
+
for ($j = $start; $j < 100; $j++) {
|
924 |
+
$element = isset($_POST['wdform_'.$key."_element".$id.$j]) ? $_POST['wdform_'.$key."_element".$id.$j] : NULL;
|
925 |
+
if (isset($element)) {
|
926 |
+
if ($j == $other_element_id) {
|
927 |
+
$new_value = $new_value . (isset($_POST['wdform_'.$key."_other_input".$id]) ? $_POST['wdform_'.$key."_other_input".$id] : "") . '<br>';
|
928 |
+
}
|
929 |
+
else {
|
930 |
+
$new_value = $new_value . $element . '<br>';
|
931 |
+
}
|
932 |
+
}
|
933 |
+
}
|
934 |
+
}
|
935 |
+
break;
|
936 |
+
}
|
937 |
+
default: break;
|
938 |
+
}
|
939 |
+
}
|
940 |
+
return $new_value;
|
941 |
+
}
|
942 |
+
|
943 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
944 |
+
// Getters & Setters //
|
945 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
946 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
947 |
+
// Private Methods //
|
948 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
949 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
950 |
+
// Listeners //
|
951 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
952 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://web-dorado.com/products/wordpress-contact-form-builder.html
|
|
4 |
Tags: captcha, contact, contact form, contact forms, custom form, email, feedback, form, form builder, form manager, forms, survey
|
5 |
Requires at least: 3.0.0
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -137,6 +137,9 @@ After downloading the ZIP file,
|
|
137 |
|
138 |
|
139 |
== Changelog ==
|
|
|
|
|
|
|
140 |
= 1.0.53 =
|
141 |
* Changed: Featured plugins page
|
142 |
|
4 |
Tags: captcha, contact, contact form, contact forms, custom form, email, feedback, form, form builder, form manager, forms, survey
|
5 |
Requires at least: 3.0.0
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 1.0.54
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
137 |
|
138 |
|
139 |
== Changelog ==
|
140 |
+
= 1.0.54 =
|
141 |
+
* Fixed: Bug on triming recipients addresses
|
142 |
+
|
143 |
= 1.0.53 =
|
144 |
* Changed: Featured plugins page
|
145 |
|