PluginProbe
Contact Forms by Cimatti / 1.9.0
Contact Forms by Cimatti v1.9.0
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.9.0, at contact-forms.php

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