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

650 lines 16.7 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.0
6 Plugin URI: http://www.cimatti.it/wordpress/contact-forms/
7 Author: Cimatti Consulting
8 Author URI: http://www.cimatti.it
9 */
10
11 /*
12 WordPress Contact Forms by Cimatti
13 Copyright (c) 2011-2013 Andrea Cimatti
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version 2
18 of the License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
29
30 The full copy of the GNU General Public License is available here: http://www.gnu.org/licenses/gpl.txt
31
32 */
33
34 require_once('accua-form-api.php');
35 require_once('accua-forms.php');
36 require_once('accua-shortcode-button.php');
37
38 function accua_dashboard_page_head(){
39 $screen = get_current_screen();
40 $screen->add_help_tab( array(
41 'id' => 'accua_help_tab',
42 'title' => __('WordPress Contact Forms by Cimatti'),
43 'content' => '<p>' . __( 'Marketing tools for WordPress', 'accua-form-api') . '</p>',
44 ) );
45
46 wp_enqueue_script('accua', plugins_url('/flot/jquery.flot.js', __FILE__ ), array( 'jquery' ));
47 //wp_enqueue_style('accua_flot', plugins_url('/flot/layout.css', __FILE__ ));
48 wp_enqueue_style('accua', plugins_url('accua.css', __FILE__ ));
49
50 }
51
52 function accua_dashboard_page()
53 {
54 global $wpdb;
55 $num_posts = $wpdb->get_results("SELECT count(DISTINCT afs_post_id ) as num_row
56 FROM {$wpdb->prefix}accua_forms_submissions WHERE afs_post_id <> 0", ARRAY_A);
57 $num_forms = $wpdb->get_results("SELECT count(DISTINCT afs_form_id ) as num_row
58 FROM {$wpdb->prefix}accua_forms_submissions", ARRAY_A);
59 $num_submissions = $wpdb->get_results("SELECT count(*) as num_row
60 FROM {$wpdb->prefix}accua_forms_submissions", ARRAY_A);
61
62 //seleziono i campi email
63 $email_fields = array();
64 $avail_fields = get_option('accua_forms_avail_fields', array());
65 foreach($avail_fields as $key=>$single_field){
66 if($single_field['type'] == 'email' || $single_field['type'] == 'autoreply_email')
67 $email_fields[] = "'".$key."'";
68 }
69 $email_fields_string = implode(',',$email_fields);
70 $num_emails = $wpdb->get_results("SELECT COUNT(DISTINCT (`afsv_value`)) as num_row
71 FROM {$wpdb->prefix}accua_forms_submissions, {$wpdb->prefix}accua_forms_submissions_values
72 WHERE `afs_id` = `afsv_sub_id`
73 AND afsv_field_id IN ({$email_fields_string})", ARRAY_A);
74
75 //costruisco il grafico
76
77 $query_grafico = $wpdb->get_results("SELECT YEAR( afs_submitted ) AS `year` , MONTH( afs_submitted ) AS `month` , COUNT( * ) AS `submissions` , COUNT( DISTINCT (`afsv_value`)) AS `unique_submissions`
78 FROM `{$wpdb->prefix}accua_forms_submissions` , `{$wpdb->prefix}accua_forms_submissions_values`
79 WHERE `afs_id` = `afsv_sub_id`
80 AND afsv_field_id IN ({$email_fields_string})
81 GROUP BY `year` , `month`
82 ORDER BY `year` DESC , `month` DESC");
83 ?>
84
85 <div class="wrap">
86 <div id="icon-contact-forms-cimatti-logo" class="icon32"><br></div>
87 <h2>WordPress Contact Forms by Cimatti</h2>
88 <div class="metabox-holder accua-forms-metabox-holder">
89 <div class="postbox ">
90 <h3 class="hndle"><span><?php _e('Forms Stats', 'accua-form-api'); ?></span></h3>
91 <div class="inside" id="dashboard_right_now">
92 <table>
93 <tr class="first"><td class="first b"><?php echo $num_forms[0]['num_row']; ?></td><td class="t"><?php _e('Forms', 'accua-form-api'); ?></td></tr>
94 <tr class="first"><td class="first b"><?php echo $num_posts[0]['num_row']; ?></td><td class="t"><?php _e('Pages', 'accua-form-api'); ?></td></tr>
95 <tr class="first"><td class="first b"><?php echo $num_submissions[0]['num_row']; ?></td><td class="t"><?php _e('Submissions', 'accua-form-api'); ?></td></tr>
96 <tr class="first"><td class="first b"><?php echo $num_emails[0]['num_row']; ?></td><td class="t"><?php _e('Distinct Emails', 'accua-form-api'); ?></td></tr>
97 </table>
98 <div id="accua-forms-graph-content" ><div id="accua-form-report-graph" style="width: 99%"></div>
99 </div>
100 <?php
101
102 if ($query_grafico) {
103 $data = array(
104 array( 'label' => __('Unique monthly Submissions', 'accua-form-api'), 'data' => array()),
105 array( 'label' => __('Total monthly Submissions', 'accua-form-api'), 'data' => array()),
106 );
107 for($i=date('Y'); $i>=$query_grafico[count($query_grafico)-1]->year; $i-- ) {
108 $start_month=12;
109 $end_month = 1;
110 if($i==date('Y')) $start_month= date('n');
111 if($i==$query_grafico[count($query_grafico)-1]->year) $end_month=$query_grafico[count($query_grafico)-1]->month;
112 for($j=$start_month;$j>=$end_month;$j--) {
113 $time = mktime(0, 0, 0, $j , 1, $i) * 1000;
114 $find=false;
115 foreach ($query_grafico as $result){
116 if(!$find && (int)$result->year == $i && (int)$result->month==$j) {
117 $data[0]['data'][] = array($time, (int)$result->unique_submissions,$j, $i);
118 $data[1]['data'][] = array($time, (int)$result->submissions,$j, $i);
119 $find=true;
120 }
121 }
122 if(!$find)
123 {
124 $data[0]['data'][] = array($time, 0,$j, $i);
125 $data[1]['data'][] = array($time, 0,$j, $i);
126 }
127 }
128 }
129 ?>
130 <script type="text/javascript">
131 var data = <?php echo json_encode($data); ?> ;
132 var options = {
133 xaxis: {
134 //autoscaleMargin: 0.005,
135 mode: "time",
136 timeformat: "%b %y",
137 minTickSize: [1, "month"]
138 },
139 legend: {
140 position: "nw"
141 },
142
143
144 };
145 jQuery(document).ready(function($) {
146 jQuery.plot($("#accua-form-report-graph"), data, options);
147 });
148
149 jQuery(window).resize(function() {
150 jQuery.plot(jQuery("#accua-form-report-graph"), data, options);
151 });
152 </script>
153 <?php
154 } ?>
155 <?php
156 $plugin_data = get_plugin_data(__FILE__);
157 _e('Version', 'accua-form-api'); echo " ".$plugin_data['Version'];
158 ?>
159 </div>
160
161 </div>
162 <span id="accua-forms-version">by Cimatti - <a href="http://www.cimatti.it/wordpress/contact-forms/">www.cimatti.it/wordpress/contact-forms</a>
163 <br /><?php
164 $plugin_data = get_plugin_data( __FILE__ );
165 _e('Version', 'accua-form-api'); echo " ".$plugin_data['Version'];
166 ?></span>
167 </div>
168 <?php
169
170 }
171
172
173 register_activation_hook(__FILE__, 'accua_forms_install');
174 function accua_forms_install(){
175 $modified = false;
176 $keys = get_option('accua_form_api_keys', array());
177 if (!isset($keys['hash'])) {
178 $modified = true;
179 $keys['hash'] = wp_generate_password(64,true,true);
180 }
181 if (!isset($keys['aes'])) {
182 $modified = true;
183 $keys['aes'] = wp_generate_password(64,true,true);
184 }
185 if ($modified) {
186 update_option('accua_form_api_keys', $keys);
187 }
188
189 global $wpdb;
190
191 require_once(ABSPATH.'wp-admin/upgrade-functions.php');
192
193 $charset_collate = '';
194 if ( ! empty($wpdb->charset) )
195 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
196 if ( ! empty($wpdb->collate) )
197 $charset_collate .= " COLLATE $wpdb->collate";
198
199 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions` (
200 afs_id BIGINT(20) NOT NULL AUTO_INCREMENT,
201 afs_form_id VARCHAR(77) NOT NULL DEFAULT '',
202 afs_post_id BIGINT(20) NOT NULL DEFAULT 0,
203 afs_ip VARCHAR(255) NOT NULL DEFAULT '',
204 afs_uri VARCHAR(255) NOT NULL DEFAULT '',
205 afs_referrer VARCHAR(255) NOT NULL DEFAULT '',
206 afs_lang VARCHAR(60) NOT NULL DEFAULT '',
207 afs_created TIMESTAMP NOT NULL DEFAULT 0,
208 afs_submitted TIMESTAMP NOT NULL DEFAULT 0,
209 afs_status TINYINT(1) NOT NULL DEFAULT 0,
210 afs_stats TEXT NOT NULL DEFAULT '',
211 PRIMARY KEY (afs_id),
212 KEY form (afs_form_id),
213 KEY uri (afs_uri),
214 KEY pid (afs_post_id),
215 KEY referrer (afs_referrer)
216 ) $charset_collate;";
217 dbDelta($sql);
218
219 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_values` (
220 afsv_sub_id BIGINT(20) NOT NULL,
221 afsv_field_id VARCHAR(77) NOT NULL,
222 afsv_type varchar(255) NOT NULL DEFAULT '',
223 afsv_value TEXT NOT NULL DEFAULT '',
224 PRIMARY KEY (afsv_sub_id, afsv_field_id),
225 KEY value_index (afsv_field_id(77), afsv_value(256))
226 ) $charset_collate;";
227 dbDelta($sql);
228
229 $avail_fields = get_option('accua_forms_avail_fields', array());
230 $avail_fields += array(
231 'first_name' => array(
232 'id' => 'first_name',
233 'name' => 'First Name',
234 'type' => 'textfield',
235 'description' => '',
236 'default_value' => '',
237 'allowed_values' => '',
238 ),
239 'last_name' => array(
240 'id' => 'last_name',
241 'name' => 'Last Name',
242 'type' => 'textfield',
243 'description' => '',
244 'default_value' => '',
245 'allowed_values' => '',
246 ),
247 'email' => array(
248 'id' => 'email',
249 'name' => 'Email',
250 'type' => 'autoreply_email',
251 'description' => '',
252 'default_value' => '',
253 'allowed_values' => '',
254 ),
255 'address' => array(
256 'id' => 'address',
257 'name' => 'Address',
258 'type' => 'textfield',
259 'description' => '',
260 'default_value' => '',
261 'allowed_values' => '',
262 ),
263 'city' => array(
264 'id' => 'city',
265 'name' => 'City',
266 'type' => 'textfield',
267 'description' => '',
268 'default_value' => '',
269 'allowed_values' => '',
270 ),
271 'state_province' => array(
272 'id' => 'state_province',
273 'name' => 'State/Province',
274 'type' => 'textfield',
275 'description' => '',
276 'default_value' => '',
277 'allowed_values' => '',
278 ),
279 'country' => array(
280 'id' => 'country',
281 'name' => 'Country',
282 'type' => 'select',
283 'description' => '',
284 'default_value' => '-',
285 'allowed_values' => "-|Select...
286 Afghanistan
287 �
288 land Islands
289 Albania
290 Algeria
291 American Samoa
292 Andorra
293 Angola
294 Anguilla
295 Antarctica
296 Antigua And Barbuda
297 Argentina
298 Armenia
299 Aruba
300 Australia
301 Austria
302 Azerbaijan
303 Bahamas
304 Bahrain
305 Bangladesh
306 Barbados
307 Belarus
308 Belgium
309 Belize
310 Benin
311 Bermuda
312 Bhutan
313 Bolivia
314 Bosnia And Herzegovina
315 Botswana
316 Bouvet Island
317 Brazil
318 British Indian Ocean Territory
319 Brunei Darussalam
320 Bulgaria
321 Burkina Faso
322 Burundi
323 Cambodia
324 Cameroon
325 Canada
326 Cape Verde
327 Cayman Islands
328 Central African Republic
329 Chad
330 Chile
331 China
332 Christmas Island
333 Cocos (Keeling) Islands
334 Colombia
335 Comoros
336 Congo
337 Congo, The Democratic Republic Of The
338 Cook Islands
339 Costa Rica
340 Côte D'Ivoire
341 Croatia
342 Cuba
343 Cyprus
344 Czech Republic
345 Denmark
346 Djibouti
347 Dominica
348 Dominican Republic
349 Ecuador
350 Egypt
351 El Salvador
352 Equatorial Guinea
353 Eritrea
354 Estonia
355 Ethiopia
356 Falkland Islands (Malvinas)
357 Faroe Islands
358 Fiji
359 Finland
360 France
361 French Guiana
362 French Polynesia
363 French Southern Territories
364 Gabon
365 Gambia
366 Georgia
367 Germany
368 Ghana
369 Gibraltar
370 Greece
371 Greenland
372 Grenada
373 Guadeloupe
374 Guam
375 Guatemala
376 Guernsey
377 Guinea
378 Guinea-Bissau
379 Guyana
380 Haiti
381 Heard Island And Mcdonald Islands
382 Holy See (Vatican City State)
383 Honduras
384 Hong Kong
385 Hungary
386 Iceland
387 India
388 Indonesia
389 Iran, Islamic Republic Of
390 Iraq
391 Ireland
392 Isle Of Man
393 Israel
394 Italy
395 Jamaica
396 Japan
397 Jersey
398 Jordan
399 Kazakhstan
400 Kenya
401 Kiribati
402 Korea, Democratic People'S Republic Of
403 Korea, Republic Of
404 Kuwait
405 Kyrgyzstan
406 Lao People'S Democratic Republic
407 Latvia
408 Lebanon
409 Lesotho
410 Liberia
411 Libyan Arab Jamahiriya
412 Liechtenstein
413 Lithuania
414 Luxembourg
415 Macao
416 Macedonia, The Former Yugoslav Republic Of
417 Madagascar
418 Malawi
419 Malaysia
420 Maldives
421 Mali
422 Malta
423 Marshall Islands
424 Martinique
425 Mauritania
426 Mauritius
427 Mayotte
428 Mexico
429 Micronesia, Federated States Of
430 Moldova, Republic Of
431 Monaco
432 Mongolia
433 Montenegro
434 Montserrat
435 Morocco
436 Mozambique
437 Myanmar
438 Namibia
439 Nauru
440 Nepal
441 Netherlands
442 Netherlands Antilles
443 New Caledonia
444 New Zealand
445 Nicaragua
446 Niger
447 Nigeria
448 Niue
449 Norfolk Island
450 Northern Mariana Islands
451 Norway
452 Oman
453 Pakistan
454 Palau
455 Palestinian Territory, Occupied
456 Panama
457 Papua New Guinea
458 Paraguay
459 Peru
460 Philippines
461 Pitcairn
462 Poland
463 Portugal
464 Puerto Rico
465 Qatar
466 Réunion
467 Romania
468 Russian Federation
469 Rwanda
470 Saint Barthélemy
471 Saint Helena
472 Saint Kitts And Nevis
473 Saint Lucia
474 Saint Martin
475 Saint Pierre And Miquelon
476 Saint Vincent And The Grenadines
477 Samoa
478 San Marino
479 Sao Tome And Principe
480 Saudi Arabia
481 Senegal
482 Serbia
483 Seychelles
484 Sierra Leone
485 Singapore
486 Slovakia
487 Slovenia
488 Solomon Islands
489 Somalia
490 South Africa
491 South Georgia And The South Sandwich Islands
492 Spain
493 Sri Lanka
494 Sudan
495 Suriname
496 Svalbard And Jan Mayen
497 Swaziland
498 Sweden
499 Switzerland
500 Syrian Arab Republic
501 Taiwan, Province Of China
502 Tajikistan
503 Tanzania, United Republic Of
504 Thailand
505 Timor-Leste
506 Togo
507 Tokelau
508 Tonga
509 Trinidad And Tobago
510 Tunisia
511 Turkey
512 Turkmenistan
513 Turks And Caicos Islands
514 Tuvalu
515 Uganda
516 Ukraine
517 United Arab Emirates
518 United Kingdom
519 United States
520 United States Minor Outlying Islands
521 Uruguay
522 Uzbekistan
523 Vanuatu
524 Venezuela, Bolivarian Republic Of
525 Viet Nam
526 Virgin Islands, British
527 Virgin Islands, U.S.
528 Wallis And Futuna
529 Western Sahara
530 Yemen
531 Zambia
532 Zimbabwe",
533 ),
534 'message' => array(
535 'id' => 'message',
536 'name' => 'Message',
537 'type' => 'textarea',
538 'description' => '',
539 'default_value' => '',
540 'allowed_values' => '',
541 ),
542 );
543 update_option('accua_forms_avail_fields', $avail_fields);
544
545
546 $form_data = get_option('accua_forms_default_form_data',array());
547 $form_data += array(
548 'layout' => 'sidebyside',
549 'success_message' => '<div style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b;">
550 <h2>Thank you {first_name} {last_name},</h2>
551 We have received your contact request. Check your inbox for the confirmation message.
552
553 <strong>Can\'t find the email?</strong>
554
555 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.
556
557 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.
558
559 For other possible problems you may have encountered do not hesitate to contact us
560
561 </div>',
562 'error_message' => '<div style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b;">
563 <h2>Oops! Something went wrong.</h2>
564 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.
565
566 Please try filling in the form again.
567
568 For other possible problems you may have encountered do not hesitate to contact us
569
570 </div>',
571 'emails_from' => '',
572 'admin_emails_to' => get_option('admin_email', ''),
573 'emails_bcc' => '',
574 'admin_emails_subject' => 'A contact from your site',
575 '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">
576 <tbody>
577 <tr>
578 <td>
579 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
580 <tbody>
581 <tr>
582 <td>
583 <table style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b; max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
584 <tbody>
585 <tr valign="top">
586 <td style="max-width:22px;"></td>
587 <td style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; padding: 15px 0px; max-width: 645px;">
588 <table>
589 <tbody>
590 <tr>
591 <td>On {__submitted_day_month_year} at {__submitted_hour} the following form was filled in.
592
593 <hr />
594
595 <strong>Page where the form was filled in</strong>
596 <a href="{__url}">{__url}</a></td>
597 </tr>
598 <tr>
599 <td id="submitted_html">{__submitted_html}</td>
600 </tr>
601 <tr>
602 <td>[form_if {__referrer} [<strong>Referrer</strong> - where did the contact come from <em>before reaching the page</em>: {__referrer}]]</td>
603 </tr>
604 <tr>
605 <td><strong>Contact IP</strong> {__ip}
606 <hr />
607 </td>
608 </tr>
609 <tr>
610 <td>[form_if {__autoreply} [The contact received in his email <a href="mailto:{email}">{email}</a> the following confirmation message:
611 <table>
612 <tbody>
613 <tr>
614 <td>{__confirmation_emails_message}</td>
615 </tr>
616 </tbody>
617 </table> ]]
618 </td>
619 </tr>
620 </tbody>
621 </table>
622 </td>
623 <td style="max-width:23px"></td>
624 </tr>
625 </tbody>
626 </table>
627 </td>
628 </tr>
629 </tbody>
630 </table>
631 </td>
632 </tr>
633 </tbody>
634 </table>',
635 'confirmation_emails_subject' => 'Your message',
636 'confirmation_emails_message' => '<h2>Thank you {first_name} {last_name},</h2>
637 Thank Your for your contact request.
638
639 We will contact you as soon as possible.
640
641 Sincerely,
642
643 The Website Team
644
645 <hr />',
646 );
647 update_option('accua_forms_default_form_data', $form_data);
648
649 }
650