PluginProbe
Contact Forms by Cimatti / 1.5.8
Contact Forms by Cimatti v1.5.8
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / contact-forms.php

contact-forms.php in Contact Forms by Cimatti 1.5.8, at contact-forms.php

703 lines 18.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WordPress Contact Forms by Cimatti
4 Description: Quickly create and publish forms in your WordPress powered website.
5 Version: 1.5.8
6 Plugin URI: https://www.cimatti.it/wordpress/contact-forms/
7 Author: Cimatti Consulting
8 Author URI: https://www.cimatti.it
9 Text Domain: contact-forms
10 Domain Path: /languages
11 */
12
13 /*
14 WordPress Contact Forms by Cimatti
15 Copyright (c) 2011-2023 Andrea Cimatti
16
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License
19 as published by the Free Software Foundation; either version 2
20 of the License, or (at your option) any later version.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31
32 The full copy of the GNU General Public License is available here: http://www.gnu.org/licenses/gpl.txt
33
34 */
35
36 define('ACCUA_FORMS_DB_VERSION', '11');
37 define('ACCUA_FORMS_CSS_VERSION', '49');
38 define('ACCUA_FORMS_JS_VERSION', '7');
39 define('ACCUA_FORMS_DIR_URL', plugin_dir_url( __FILE__ ));
40 define('ACCUA_FORMS_DIR', dirname( __FILE__ ));
41
42 require_once('accua-form-api.php');
43 require_once('accua-forms.php');
44 require_once('accua-shortcode-button.php');
45
46 function accua_forms_dashboard_page_head(){
47 $screen = get_current_screen();
48 $screen->add_help_tab( array(
49 'id' => 'accua_help_tab',
50 'title' => __('Contact Forms Dashboard'),
51 'content' => '<p>' . __( 'Marketing tools for WordPress', 'contact-forms') . '</p>',
52 ) );
53
54 //wp_enqueue_script('accua', plugins_url('/flot/jquery.flot.js', __FILE__ ), array( 'jquery' ));
55 wp_enqueue_script('accua_chart_js', plugins_url('/chartjs/Chart.min.js', __FILE__ ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
56 //wp_enqueue_style('accua_flot', plugins_url('/flot/layout.css', __FILE__ ));
57 wp_enqueue_style('accua', plugins_url('accua.css', __FILE__ ), array(), ACCUA_FORMS_CSS_VERSION);
58
59 /* Tentativo x drag and drop
60 $page_hook_id = fx_smb_setings_page_id();
61 /* Load the JavaScript needed for the settings screen. * /
62 add_action( 'admin_enqueue_scripts', 'fx_smb_enqueue_scripts' );
63 add_action( "admin_footer-{$page_hook_id}", 'fx_smb_footer_scripts' );
64
65 /* Set number of column available. * /
66 add_filter( 'screen_layout_columns', 'fx_smb_screen_layout_column', 10, 2 );
67 */
68 }
69
70 /* COSA CARINA PER AGGIUNGERE WIDGET NELLA DASHBOARD DI WP
71 todo: posso scegliere la sua posizione di default?
72 */
73 add_action( 'wp_dashboard_setup', 'accua_contact_forms_dashboard_add_widgets' );
74 function accua_contact_forms_dashboard_add_widgets() {
75 wp_add_dashboard_widget( 'accua_contact_forms_dashboard_widget_news', __( 'Contact Forms', 'contact-forms' ), 'accua_contact_forms_dashboard_widget_news_handler' );
76 }
77
78 function accua_contact_forms_dashboard_widget_news_handler() {
79 global $wpdb; ?>
80 <table>
81 <tr class="first">
82 <?php $forms_data = get_option('accua_forms_saved_forms', array());
83 $active_forms = count($forms_data); ?>
84 <td class="first b"><?php echo $active_forms; ?></td><td class="t"><?php _e('Active forms', 'contact-forms'); ?></td>
85 </tr>
86 <tr class="first">
87 <?php $pages = $wpdb->get_var("SELECT COUNT(DISTINCT afs_uri) FROM `{$wpdb->prefix}accua_forms_submissions`"); ?>
88 <td class="first b"><?php echo $pages; ?></td><td class="t"><?php _e('Pages', 'contact-forms'); ?></td>
89 </tr>
90 <tr class="first">
91 <?php $active_submissions = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}accua_forms_submissions` WHERE afs_status >= 0"); ?>
92 <td class="first b"><?php echo $active_submissions; ?></td><td class="t"><?php _e('Submissions', 'contact-forms'); ?></td>
93 </tr>
94 <tr class="first">
95 <?php $emails = $wpdb->get_var("SELECT COUNT(DISTINCT afsv_value) FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_type LIKE 'autoreply_email'"); ?>
96 <td class="first b"><?php echo $emails; ?></td><td class="t"><?php _e('Distinct Emails', 'contact-forms'); ?></td>
97 </tr>
98 </table>
99 <br />
100 <span id="accua-forms-version"><a href="https://www.cimatti.it/wordpress/contact-forms/"><?php
101 $plugin_data = get_plugin_data( __FILE__ );
102 _e('Version', 'contact-forms'); echo " ".$plugin_data['Version']; ?></a> | <a href="admin.php?page=accua_forms" title="Contact Forms Dashboard"><?php _e('Dashboard', 'contact-forms'); ?></a>
103 </span>
104
105 <?php
106 }
107
108 function accua_forms_dashboard_page(){
109 require_once ACCUA_FORMS_DIR.'/accua-forms-dashboard.php';
110 return _accua_forms_dashboard_page();
111 }
112
113
114 register_activation_hook(__FILE__, 'accua_forms_install');
115 function accua_forms_install(){
116 load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH);
117 $modified = false;
118 $keys = get_option('accua_form_api_keys', array());
119 if (!isset($keys['hash'])) {
120 $modified = true;
121 $keys['hash'] = wp_generate_password(64,true,true);
122 }
123 if (!isset($keys['aes'])) {
124 $modified = true;
125 $keys['aes'] = wp_generate_password(64,true,true);
126 }
127 if ($modified) {
128 update_option('accua_form_api_keys', $keys);
129 }
130
131 global $wpdb;
132
133 require_once(ABSPATH.'wp-admin/includes/upgrade.php');
134
135 $charset_collate = '';
136 if ( ! empty($wpdb->charset) )
137 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
138 if ( ! empty($wpdb->collate) )
139 $charset_collate .= " COLLATE $wpdb->collate";
140
141 $old_db_version = (int) get_option('accua_forms_db_version', 0);
142
143 if ($old_db_version < 3) {
144 $wpdb_suppress_errors_status = $wpdb->suppress_errors();
145 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX uri");
146 $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX referrer");
147 $wpdb->suppress_errors($wpdb_suppress_errors_status);
148 }
149
150 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions` (
151 afs_id BIGINT(20) NOT NULL AUTO_INCREMENT,
152 afs_form_id VARCHAR(77) NOT NULL DEFAULT '',
153 afs_post_id BIGINT(20) NOT NULL DEFAULT 0,
154 afs_ip VARCHAR(255) NOT NULL DEFAULT '',
155 afs_uri TEXT NOT NULL DEFAULT '',
156 afs_referrer TEXT NOT NULL DEFAULT '',
157 afs_lang VARCHAR(60) NOT NULL DEFAULT '',
158 afs_created TIMESTAMP NOT NULL DEFAULT 0,
159 afs_submitted TIMESTAMP NOT NULL DEFAULT 0,
160 afs_status TINYINT(1) NOT NULL DEFAULT 0,
161 afs_stats TEXT NOT NULL DEFAULT '',
162 PRIMARY KEY (afs_id),
163 KEY form (afs_form_id, afs_status),
164 KEY uri (afs_uri(190)),
165 KEY pid (afs_post_id),
166 KEY referrer (afs_referrer(190)),
167 KEY status (afs_status, afs_id),
168 KEY submitted (afs_submitted)
169 ) $charset_collate;";
170 dbDelta($sql);
171
172 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_values` (
173 afsv_sub_id BIGINT(20) NOT NULL,
174 afsv_field_id VARCHAR(77) NOT NULL,
175 afsv_type varchar(255) NOT NULL DEFAULT '',
176 afsv_value TEXT NOT NULL DEFAULT '',
177 PRIMARY KEY (afsv_sub_id, afsv_field_id),
178 KEY value_index (afsv_field_id(77), afsv_value(114))
179 ) $charset_collate;";
180 dbDelta($sql);
181
182 /* creazione tabella per le note dell'utente
183 sono relative a una compilazione
184 possono esserci più note per ogni compilazione in date diverse
185
186 */
187 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
188 afsn_sub_id BIGINT(20) NOT NULL,
189 afsn_date TIMESTAMP NOT NULL DEFAULT 0,
190 afsn_text TEXT NOT NULL DEFAULT '',
191 afsn_user VARCHAR(100) NOT NULL DEFAULT '',
192 PRIMARY KEY (afsn_sub_id, afsn_date),
193 KEY afsn_sub_id (afsn_sub_id)
194 ) $charset_collate;";
195 dbDelta($sql);
196
197
198 $avail_fields = get_option('accua_forms_avail_fields', array());
199
200 if (!is_array($avail_fields)) {
201 $avail_fields = array();
202 }
203
204 if (empty($avail_fields) || ($old_db_version === 0)) {
205 $avail_fields += array(
206 'first_name' => array(
207 'id' => 'first_name',
208 'name' => 'First Name',
209 'type' => 'textfield',
210 'description' => '',
211 'default_value' => '',
212 'allowed_values' => '',
213 ),
214 'last_name' => array(
215 'id' => 'last_name',
216 'name' => 'Last Name',
217 'type' => 'textfield',
218 'description' => '',
219 'default_value' => '',
220 'allowed_values' => '',
221 ),
222 'email' => array(
223 'id' => 'email',
224 'name' => 'Email',
225 'type' => 'autoreply_email',
226 'description' => '',
227 'default_value' => '',
228 'allowed_values' => '',
229 ),
230 'address' => array(
231 'id' => 'address',
232 'name' => 'Address',
233 'type' => 'textfield',
234 'description' => '',
235 'default_value' => '',
236 'allowed_values' => '',
237 ),
238 'city' => array(
239 'id' => 'city',
240 'name' => 'City',
241 'type' => 'textfield',
242 'description' => '',
243 'default_value' => '',
244 'allowed_values' => '',
245 ),
246 'state_province' => array(
247 'id' => 'state_province',
248 'name' => 'State/Province',
249 'type' => 'textfield',
250 'description' => '',
251 'default_value' => '',
252 'allowed_values' => '',
253 ),
254 'country' => array(
255 'id' => 'country',
256 'name' => 'Country',
257 'type' => 'select',
258 'description' => '',
259 'default_value' => '-',
260 'allowed_values' => "-|Select...
261 Afghanistan
262 �
263 land Islands
264 Albania
265 Algeria
266 American Samoa
267 Andorra
268 Angola
269 Anguilla
270 Antarctica
271 Antigua And Barbuda
272 Argentina
273 Armenia
274 Aruba
275 Australia
276 Austria
277 Azerbaijan
278 Bahamas
279 Bahrain
280 Bangladesh
281 Barbados
282 Belarus
283 Belgium
284 Belize
285 Benin
286 Bermuda
287 Bhutan
288 Bolivia
289 Bosnia And Herzegovina
290 Botswana
291 Bouvet Island
292 Brazil
293 British Indian Ocean Territory
294 Brunei Darussalam
295 Bulgaria
296 Burkina Faso
297 Burundi
298 Cambodia
299 Cameroon
300 Canada
301 Cape Verde
302 Cayman Islands
303 Central African Republic
304 Chad
305 Chile
306 China
307 Christmas Island
308 Cocos (Keeling) Islands
309 Colombia
310 Comoros
311 Congo
312 Congo, The Democratic Republic Of The
313 Cook Islands
314 Costa Rica
315 Côte D'Ivoire
316 Croatia
317 Cuba
318 Cyprus
319 Czech Republic
320 Denmark
321 Djibouti
322 Dominica
323 Dominican Republic
324 Ecuador
325 Egypt
326 El Salvador
327 Equatorial Guinea
328 Eritrea
329 Estonia
330 Ethiopia
331 Falkland Islands (Malvinas)
332 Faroe Islands
333 Fiji
334 Finland
335 France
336 French Guiana
337 French Polynesia
338 French Southern Territories
339 Gabon
340 Gambia
341 Georgia
342 Germany
343 Ghana
344 Gibraltar
345 Greece
346 Greenland
347 Grenada
348 Guadeloupe
349 Guam
350 Guatemala
351 Guernsey
352 Guinea
353 Guinea-Bissau
354 Guyana
355 Haiti
356 Heard Island And Mcdonald Islands
357 Holy See (Vatican City State)
358 Honduras
359 Hong Kong
360 Hungary
361 Iceland
362 India
363 Indonesia
364 Iran, Islamic Republic Of
365 Iraq
366 Ireland
367 Isle Of Man
368 Israel
369 Italy
370 Jamaica
371 Japan
372 Jersey
373 Jordan
374 Kazakhstan
375 Kenya
376 Kiribati
377 Korea, Democratic People'S Republic Of
378 Korea, Republic Of
379 Kuwait
380 Kyrgyzstan
381 Lao People'S Democratic Republic
382 Latvia
383 Lebanon
384 Lesotho
385 Liberia
386 Libyan Arab Jamahiriya
387 Liechtenstein
388 Lithuania
389 Luxembourg
390 Macao
391 Macedonia, The Former Yugoslav Republic Of
392 Madagascar
393 Malawi
394 Malaysia
395 Maldives
396 Mali
397 Malta
398 Marshall Islands
399 Martinique
400 Mauritania
401 Mauritius
402 Mayotte
403 Mexico
404 Micronesia, Federated States Of
405 Moldova, Republic Of
406 Monaco
407 Mongolia
408 Montenegro
409 Montserrat
410 Morocco
411 Mozambique
412 Myanmar
413 Namibia
414 Nauru
415 Nepal
416 Netherlands
417 Netherlands Antilles
418 New Caledonia
419 New Zealand
420 Nicaragua
421 Niger
422 Nigeria
423 Niue
424 Norfolk Island
425 Northern Mariana Islands
426 Norway
427 Oman
428 Pakistan
429 Palau
430 Palestinian Territory, Occupied
431 Panama
432 Papua New Guinea
433 Paraguay
434 Peru
435 Philippines
436 Pitcairn
437 Poland
438 Portugal
439 Puerto Rico
440 Qatar
441 Réunion
442 Romania
443 Russian Federation
444 Rwanda
445 Saint Barthélemy
446 Saint Helena
447 Saint Kitts And Nevis
448 Saint Lucia
449 Saint Martin
450 Saint Pierre And Miquelon
451 Saint Vincent And The Grenadines
452 Samoa
453 San Marino
454 Sao Tome And Principe
455 Saudi Arabia
456 Senegal
457 Serbia
458 Seychelles
459 Sierra Leone
460 Singapore
461 Slovakia
462 Slovenia
463 Solomon Islands
464 Somalia
465 South Africa
466 South Georgia And The South Sandwich Islands
467 Spain
468 Sri Lanka
469 Sudan
470 Suriname
471 Svalbard And Jan Mayen
472 Swaziland
473 Sweden
474 Switzerland
475 Syrian Arab Republic
476 Taiwan, Province Of China
477 Tajikistan
478 Tanzania, United Republic Of
479 Thailand
480 Timor-Leste
481 Togo
482 Tokelau
483 Tonga
484 Trinidad And Tobago
485 Tunisia
486 Turkey
487 Turkmenistan
488 Turks And Caicos Islands
489 Tuvalu
490 Uganda
491 Ukraine
492 United Arab Emirates
493 United Kingdom
494 United States
495 United States Minor Outlying Islands
496 Uruguay
497 Uzbekistan
498 Vanuatu
499 Venezuela, Bolivarian Republic Of
500 Viet Nam
501 Virgin Islands, British
502 Virgin Islands, U.S.
503 Wallis And Futuna
504 Western Sahara
505 Yemen
506 Zambia
507 Zimbabwe",
508 ),
509 'message' => array(
510 'id' => 'message',
511 'name' => 'Message',
512 'type' => 'textarea',
513 'description' => '',
514 'default_value' => '',
515 'allowed_values' => '',
516 ),
517 'captcha' => array(
518 'id' => 'captcha',
519 'name' => 'Captcha',
520 'type' => 'captcha',
521 'description' => '',
522 'default_value' => '',
523 'allowed_values' => '',
524 ),
525 );
526 update_option('accua_forms_avail_fields', $avail_fields);
527 }
528
529 $form_data = get_option('accua_forms_default_form_data',array());
530 if (!is_array($form_data)) {
531 $form_data = array();
532 }
533
534 $form_data += array(
535 'success_message' => '<div style="padding: 0px 30px 10px; background-color: #f4f4f4; border: 1px solid #ddd;">
536 <h2>Thank you {first_name} {last_name},</h2>
537 We have received your contact request. Check your inbox for the confirmation message.
538
539 <strong>Can\'t find the email?</strong>
540
541 It doesn\'t happen often but your mailbox could apply strict spam rules that block our email from reaching your inbox. Try checking your spam folder.
542
543 Also check that the email you entered in the form (<strong>{email}</strong>) is correct. If it is not exact you can submit the form again.
544
545 For other possible problems you may have encountered do not hesitate to contact us
546
547 </div>',
548 'error_message' => '<div style="padding: 0px 30px 10px; background-color: #f4f4f4; border: 1px solid #ddd;">
549 <h2>Oops! Something went wrong.</h2>
550 Internet is an awfully complex place and even though we take every precaution to make sure things run smoothly every once in a while things can go wrong that are not under our control.
551
552 Please try filling in the form again.
553
554 For other possible problems you may have encountered do not hesitate to contact us
555
556 </div>',
557 'emails_from_name' => '',
558 'emails_from' => '',
559 'admin_emails_to' => get_option('admin_email', ''),
560 'emails_bcc' => '',
561 'admin_emails_subject' => 'A contact from your site',
562 'admin_emails_message' => '<table style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; background: #fff; margin-top: 10px; border: 1px solid #DDDDDD; max-width: 700px;" cellspacing="0" cellpadding="0" align="center">
563 <tbody>
564 <tr>
565 <td>
566 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
567 <tbody>
568 <tr>
569 <td>
570 <table style="padding: 10px; background-color: #f4f4f4; border: 1px solid #ddd; max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
571 <tbody>
572 <tr valign="top">
573 <td style="max-width:22px;"></td>
574 <td style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; padding: 0px 30px 10px; max-width: 645px;">
575 <table>
576 <tbody>
577 <tr>
578 <td>On {__submitted_day_month_year} at {__submitted_hour} the following form was filled in.
579
580 <hr />
581
582 <strong>Page where the form was filled in</strong>
583 <a href="{__url}">{__url}</a></td>
584 </tr>
585 <tr>
586 <td id="submitted_html">{__submitted_html}</td>
587 </tr>
588 <tr>
589 <td>[form_if {__referrer} [<strong>Referrer</strong> - where did the contact come from <em>before reaching the page</em>: {__referrer}]]</td>
590 </tr>
591 <tr>
592 <td><strong>Contact IP</strong> {__ip}
593 <hr />
594 </td>
595 </tr>
596 <tr>
597 <td>[form_if {__autoreply} [The contact received in his email <a href="mailto:{email}">{email}</a> the following confirmation message:
598 <table>
599 <tbody>
600 <tr>
601 <td>{__confirmation_emails_message}</td>
602 </tr>
603 </tbody>
604 </table> ]]
605 </td>
606 </tr>
607 </tbody>
608 </table>
609 </td>
610 <td style="max-width:23px"></td>
611 </tr>
612 </tbody>
613 </table>
614 </td>
615 </tr>
616 </tbody>
617 </table>
618 </td>
619 </tr>
620 </tbody>
621 </table>',
622 'confirmation_emails_subject' => 'Your message',
623 'confirmation_emails_message' => '<div>
624
625 <h2>Thank you {first_name} {last_name},</h2>
626 Thank Your for your contact request.
627
628 We will contact you as soon as possible.
629
630 Sincerely,
631
632 The Website Team
633
634 <hr />
635 </div>',
636
637 'layout' => 'sidebyside',
638 'style_margin' => '',
639 'style_border_color' => '',
640 'style_border_width' => '',
641 'style_border_radius' => '',
642 'style_background_color' => '',
643 'style_padding' => '',
644 'style_color' => '',
645 'style_font_size' => '',
646 'style_field_spacing' => '',
647 'style_field_border_color' => '',
648 'style_field_border_width' => '',
649 'style_field_border_radius' => '',
650 'style_field_background_color' => '',
651 'style_field_padding' => '',
652 'style_field_color' => '',
653 'style_submit_border_color' => '',
654 'style_submit_border_width' => '',
655 'style_submit_border_radius' => '',
656 'style_submit_background_color' => '',
657 'style_submit_padding' => '',
658 'style_submit_color' => '',
659 'style_submit_font_size' => '',
660 );
661
662 update_option('accua_forms_default_form_data', $form_data);
663 update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
664 }
665
666 add_action('plugins_loaded', 'accua_forms_check_db_version_and_update', 9);
667 function accua_forms_check_db_version_and_update() {
668 $db_version = get_option('accua_forms_db_version', '');
669 if (ACCUA_FORMS_DB_VERSION != $db_version) {
670 accua_forms_install();
671 }
672 }
673
674 add_filter( 'robots_txt', 'accua_forms_robots_txt', 10, 2);
675 function accua_forms_robots_txt($output, $public) {
676 if ($public) {
677 $site_url = parse_url( site_url() );
678 $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
679 $output .= "\nUser-agent: *\n";
680 $output .= "Allow: $path/wp-admin/js/\n";
681 $output .= "Allow: $path/wp-admin/css/\n";
682 }
683 return $output;
684 }
685
686 function _accua_forms_json_encode($item) {
687 static $version = NULL;
688 if ($version === NULL) {
689 $version = version_compare(PHP_VERSION, '5.3.0', '>=');
690 }
691 if ($version) {
692 return json_encode($item, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP);
693 } else {
694 return strtr(json_encode($item),
695 array(
696 '&' => '\\u0026',
697 '<' => '\\u003C',
698 '>' => '\\u003E',
699 ));
700 }
701 }
702
703