PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
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
← All changes | accua-forms-dashboard.php +52 -381 2.2.01.9.2 View file →
@@ -1,9 +1,5 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) exit;
3 -
4 -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Internal helper function with underscore prefix
5 -function _accua_forms_dashboard_page(){
1 +<?php function _accua_forms_dashboard_page(){
6 2 /* global vars */
7 3 global $hook_suffix;
8 4 /* enable add_meta_boxes function in this page. */
9 5 do_action( 'add_meta_boxes', $hook_suffix, 10, 2 ); ?>
@@ -14,9 +10,8 @@
14 10 </div>
15 11 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
16 12 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
17 13
18 - // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Dashboard statistics queries, dynamic field filtering
19 14 global $wpdb;
20 15 $email_fields = array();
21 16 $num_submissions = $wpdb->get_var("SELECT count(*) as num_row
22 17 FROM {$wpdb->prefix}accua_forms_submissions WHERE afs_status >= 0");
@@ -51,56 +46,12 @@
51 46
52 47
53 48 $forms_data = get_option('accua_forms_saved_forms', array());
54 49
55 - $all_public_post_types = function_exists('accua_forms_get_public_post_types') ? accua_forms_get_public_post_types() : array();
56 - $submitted_posts = $wpdb->get_results("SELECT DISTINCT s.afs_post_id AS post_id, p.post_type, p.post_title
57 - FROM {$wpdb->prefix}accua_forms_submissions s
58 - INNER JOIN {$wpdb->posts} p ON p.ID = s.afs_post_id
59 - WHERE s.afs_post_id > 0
60 - AND s.afs_status >= 0
61 - AND p.post_type <> 'attachment'
62 - ORDER BY p.post_type ASC, p.post_title ASC, s.afs_post_id DESC", ARRAY_A);
63 -
64 - $submitted_post_types = array();
65 - foreach ($submitted_posts as $submitted_post) {
66 - if (isset($all_public_post_types[$submitted_post['post_type']])) {
67 - $submitted_post_types[$submitted_post['post_type']] = $all_public_post_types[$submitted_post['post_type']];
68 - }
69 - }
70 -
71 - $filter_post_type = '';
72 - if (isset($_GET['ptype'])) {
73 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only filter for dashboard view
74 - $requested_post_type = sanitize_key(wp_unslash($_GET['ptype']));
75 - if (isset($submitted_post_types[$requested_post_type])) {
76 - $filter_post_type = $requested_post_type;
77 - }
78 - }
79 -
80 - $id_posts = array();
81 - foreach ($submitted_posts as $submitted_post) {
82 - if ($filter_post_type !== '' && $submitted_post['post_type'] !== $filter_post_type) {
83 - continue;
84 - }
85 - $id_posts[] = $submitted_post;
86 - }
87 -
88 - $ptype_param = '';
89 - if ($filter_post_type !== '') {
90 - $ptype_param = $wpdb->prepare("AND EXISTS (
91 - SELECT 1
92 - FROM {$wpdb->posts} p_filter
93 - WHERE p_filter.ID = afs_post_id
94 - AND p_filter.post_type = %s
95 - )", $filter_post_type);
96 - }
97 -
98 50 $fid = '';
99 51 $fid_param = '';
100 52 if (isset($_GET['fid'])) {
101 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only filter for dashboard view
102 - $fid = sanitize_text_field(wp_unslash($_GET['fid']));
53 + $fid = stripslashes( (string) $_GET['fid'] );
103 54 if (isset($forms_data[$fid])) {
104 55 $fid_param = $wpdb->prepare('AND afs_form_id = %s', $fid);
105 56 } else {
106 57 $fid = '';
@@ -106,26 +57,9 @@
106 57 $fid = '';
107 58 }
108 59 }
109 60
110 - $filter_post = -1;
111 - $pid_param = '';
112 - if (isset($_GET['pid'])) {
113 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only filter for dashboard view
114 - $filter_post = (int) $_GET['pid'];
115 - if ($filter_post > 0 && get_post($filter_post)) {
116 - if ($filter_post_type !== '' && get_post_type($filter_post) !== $filter_post_type) {
117 - $filter_post = -1;
118 - }
119 - }
120 - if ($filter_post > 0) {
121 - $pid_param = $wpdb->prepare('AND afs_post_id = %d', $filter_post);
122 - } else {
123 - $filter_post = -1;
124 - }
125 - }
126 61
127 -
128 62 if (isset($_GET['period'])) {
129 63 $period = (int) $_GET['period'];
130 64 if($period <= 0 && $period != -1){
131 65 $period = 24; //default
@@ -133,17 +67,8 @@
133 67 } else{
134 68 $period = 24; //default
135 69 }
136 70
137 - $period2 = 24;
138 - if (isset($_GET['period2'])) {
139 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only filter for dashboard view
140 - $period2 = (int) $_GET['period2'];
141 - if ($period2 <= 0 && $period2 != -1) {
142 - $period2 = 24; //default
143 - }
144 - }
145 -
146 71 if(isset($_POST['del_sub_form'])) {
147 72 $id = (int)$_POST['del_sub_form'];
148 73 check_admin_referer("del_sub_form_{$id}", "_wpnonce_del_sub_form");
149 74 accua_forms_trash_submission($id);
@@ -161,19 +86,17 @@
161 86 LEFT JOIN `{$wpdb->prefix}accua_forms_submissions_values` ON `afs_id` = `afsv_sub_id`
162 87 WHERE afsv_field_id IN ({$email_fields_string})
163 88 AND afs_status >= 0
164 89 $fid_param
165 - $ptype_param
166 - $pid_param
167 90 GROUP BY `year` , `month`
168 91 ORDER BY `year` DESC , `month` DESC");
169 92
170 93 if ($query_grafico) {
171 94 /* cicliamo per ogni mese in modo da riempire con 0 i mesi senza compilazioni */
172 - for ($i = (int) wp_date('Y'); $i >= $query_grafico[count($query_grafico) - 1]->year; $i--) {
95 + for ($i = date('Y'); $i >= $query_grafico[count($query_grafico) - 1]->year; $i--) {
173 96 $start_month = 12;
174 97 $end_month = 1;
175 - if ($i == (int) wp_date('Y')) $start_month = (int) wp_date('n');
98 + if ($i == date('Y')) $start_month = date('n');
176 99 if ($i == $query_grafico[count($query_grafico) - 1]->year) $end_month = $query_grafico[count($query_grafico) - 1]->month;
177 100 for ($j = $start_month; $j >= $end_month; $j--) {
178 101 $find = false;
179 102 foreach ($query_grafico as $result) {
@@ -207,86 +130,33 @@
207 130 $unique_submissions = array_reverse($unique_submissions);
208 131 }
209 132 }
210 133
211 - // Second chart: submissions and distinct pages per month (no form/page filter)
212 - $label_my2 = array();
213 - $submissions2 = array();
214 - $unique_posts2 = array();
215 - $origin_label_my2 = array();
216 - $origin_submissions2 = array();
217 - $origin_unique_posts2 = array();
218 134
219 - $query_grafico2 = $wpdb->get_results("SELECT YEAR(afs_submitted) AS `year`, MONTH(afs_submitted) AS `month`, COUNT(DISTINCT afs_id) AS `submissions`, COUNT(DISTINCT afs_post_id) AS `unique_posts`
220 - FROM `{$wpdb->prefix}accua_forms_submissions`
221 - WHERE afs_status >= 0 AND afs_post_id > 0
222 - $ptype_param
223 - $pid_param
224 - GROUP BY `year`, `month`
225 - ORDER BY `year` DESC, `month` DESC");
135 + ?>
226 136
227 - if ($query_grafico2) {
228 - for ($i = (int) wp_date('Y'); $i >= $query_grafico2[count($query_grafico2) - 1]->year; $i--) {
229 - $start_month2 = 12;
230 - $end_month2 = 1;
231 - if ($i == (int) wp_date('Y')) $start_month2 = (int) wp_date('n');
232 - if ($i == $query_grafico2[count($query_grafico2) - 1]->year) $end_month2 = $query_grafico2[count($query_grafico2) - 1]->month;
233 - for ($j = $start_month2; $j >= $end_month2; $j--) {
234 - $find2 = false;
235 - foreach ($query_grafico2 as $result) {
236 - if (!$find2 && (int)$result->year == $i && (int)$result->month == $j) {
237 - $label_my2[] = $j . '/' . $i;
238 - $submissions2[] = (int)$result->submissions;
239 - $unique_posts2[] = (int)$result->unique_posts;
240 - $find2 = true;
241 - }
242 - }
243 - if (!$find2) {
244 - $label_my2[] = $j . '/' . $i;
245 - $submissions2[] = 0;
246 - $unique_posts2[] = 0;
247 - }
248 - }
249 - }
250 - $origin_label_my2 = $label_my2;
251 - $origin_submissions2 = $submissions2;
252 - $origin_unique_posts2 = $unique_posts2;
253 -
254 - if ($period2 != -1) {
255 - $label_my2 = array_slice($label_my2, 0, $period2);
256 - $submissions2 = array_slice($submissions2, 0, $period2);
257 - $unique_posts2 = array_slice($unique_posts2, 0, $period2);
258 - }
259 -
260 - $label_my2 = array_reverse($label_my2);
261 - $submissions2 = array_reverse($submissions2);
262 - $unique_posts2 = array_reverse($unique_posts2);
263 - } ?>
264 -
265 137 <div id="accua_dashboard_page" class="accua_forms_admin_page wrap">
266 - <h1><?php esc_html_e('Contact Forms - Dashboard', 'contact-forms'); ?></h1>
267 - <div class="metabox-holder">
268 - <div class="postbox">
269 - <div class="postbox-header"><h2><?php esc_html_e('Monthly number of forms submitted', 'contact-forms'); ?></h2></div>
138 + <h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Dashboard', 'contact-forms'); ?></h2>
139 + <div class="metabox-holder accua-forms-metabox-holder">
140 + <div class="postbox ">
141 + <h2><span><?php _e('Monthly number of forms submitted', 'contact-forms'); ?></span></h2>
270 142 <div class="inside" id="dashboard_right_now">
271 143
272 144 <form method="get">
273 145 <input type="hidden" name="page" value="accua_forms" />
274 146
275 - <label><?php esc_html_e('Period: ', 'contact-forms'); ?></label>
276 147 <select name="period">
277 - <option value='3' <?php if($period == 3){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 3 <?php esc_html_e('months', 'contact-forms'); ?></option>
278 - <option value='6' <?php if($period == 6){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 6 <?php esc_html_e('months', 'contact-forms'); ?></option>
279 - <option value='12' <?php if($period == 12){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 12 <?php esc_html_e('months', 'contact-forms'); ?></option>
280 - <option value='24' <?php if($period == 24 || !$period ){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 24 <?php esc_html_e('months', 'contact-forms'); ?></option>
281 - <option value='-1' <?php if($period == -1 ){ echo 'selected="selected"'; } ?>><?php esc_html_e('All', 'contact-forms'); ?></option>
148 + <option value='3' <?php if($period == 3){ echo 'selected="selected"'; } ?>><?php _e('last', 'contact-forms'); ?> 3 <?php _e('months', 'contact-forms'); ?></option>
149 + <option value='6' <?php if($period == 6){ echo 'selected="selected"'; } ?>><?php _e('last', 'contact-forms'); ?> 6 <?php _e('months', 'contact-forms'); ?></option>
150 + <option value='12' <?php if($period == 12){ echo 'selected="selected"'; } ?>><?php _e('last', 'contact-forms'); ?> 12 <?php _e('months', 'contact-forms'); ?></option>
151 + <option value='24' <?php if($period == 24 || !$period ){ echo 'selected="selected"'; } ?>><?php _e('last', 'contact-forms'); ?> 24 <?php _e('months', 'contact-forms'); ?></option>
152 + <option value='-1' <?php if($period == -1 ){ echo 'selected="selected"'; } ?>><?php _e('All', 'contact-forms'); ?></option>
282 153 </select>
283 154
284 - <label><?php esc_html_e('Form: ', 'contact-forms'); ?></label>
285 155 <select name="fid">
286 156 <?php
287 157 $selected = ($fid === '') ? 'selected="selected"' : '';
288 - echo '<option value="" ' . esc_attr($selected) . '>' . esc_html__('Submissions from all forms', 'contact-forms') . '</option>';
158 + echo "<option value='' $selected >", __('Submissions from all forms', 'contact-forms'),'</option>';
289 159 foreach($forms_data as $ffid => $form) {
290 160 $selected = ($fid == $ffid) ? 'selected="selected"' : '';
291 161 $title = isset($form['title']) ? trim($form['title']) : '';
292 162 if ($title === '') {
@@ -291,17 +161,16 @@
291 161 $title = isset($form['title']) ? trim($form['title']) : '';
292 162 if ($title === '') {
293 163 $title = $ffid;
294 164 }
295 - echo '<option value="' . esc_attr($ffid) . '" ' . esc_attr($selected) . '>' . esc_html($title) . '</option>';
165 + $ffid = htmlspecialchars($ffid, ENT_QUOTES);
166 + $title = htmlspecialchars($title, ENT_QUOTES);
167 + echo "<option value='$ffid' $selected >$title</option>";
296 168 }
297 169 ?>
298 - </select>
170 + </select>
299 171
300 - <?php if ($period2 != 24) { ?>
301 - <input type="hidden" name="period2" value="<?php echo esc_attr($period2); ?>" />
302 - <?php } ?>
303 - <input type="submit" class="button button-secondary" value="<?php esc_attr_e('Apply', 'contact-forms') ?>" />
172 + <input type="submit" class="button button-secondary" value="<?php _e('Apply', 'contact-forms') ?>" />
304 173 </form>
305 174
306 175
307 176 <form method="get" action="" style="margin-bottom:70px;">
@@ -407,12 +276,11 @@
407 276
408 277 });
409 278 </script>
410 279 ";
411 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Chart.js configuration with pre-escaped values
412 280 echo $script_grafico;
413 281 } else {
414 - echo '<div style="height: 350px"><p>', esc_html__('No forms submitted', 'contact-forms'), '</p></div>';
282 + echo '<div style="height: 350px"><p>', __('No forms submitted', 'contact-forms'), '</p></div>';
415 283 } ?>
416 284 </div>
417 285
418 286 </div>
@@ -417,206 +285,11 @@
417 285
418 286 </div>
419 287
420 288
421 - <div class="postbox">
422 - <div class="postbox-header"><h2><?php esc_html_e('Monthly submissions by page', 'contact-forms'); ?></h2></div>
423 - <div class="inside" id="dashboard_right_now_posts">
289 + <div class="postbox ">
290 + <h2><span><?php _e('Last 10 submissions', 'contact-forms'); ?></span></h2>
424 291
425 - <form method="get">
426 - <input type="hidden" name="page" value="accua_forms" />
427 - <?php if ($fid !== '') echo '<input type="hidden" name="fid" value="' . esc_attr($fid) . '" />'; ?>
428 - <?php if ($period != 24) echo '<input type="hidden" name="period" value="' . esc_attr($period) . '" />'; ?>
429 -
430 - <label><?php esc_html_e('Period: ', 'contact-forms'); ?></label>
431 - <select name="period2">
432 - <option value='3' <?php if($period2 == 3){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 3 <?php esc_html_e('months', 'contact-forms'); ?></option>
433 - <option value='6' <?php if($period2 == 6){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 6 <?php esc_html_e('months', 'contact-forms'); ?></option>
434 - <option value='12' <?php if($period2 == 12){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 12 <?php esc_html_e('months', 'contact-forms'); ?></option>
435 - <option value='24' <?php if($period2 == 24 || !$period2 ){ echo 'selected="selected"'; } ?>><?php esc_html_e('last', 'contact-forms'); ?> 24 <?php esc_html_e('months', 'contact-forms'); ?></option>
436 - <option value='-1' <?php if($period2 == -1 ){ echo 'selected="selected"'; } ?>><?php esc_html_e('All', 'contact-forms'); ?></option>
437 - </select>
438 -
439 - <label><?php esc_html_e('Content type: ', 'contact-forms'); ?></label>
440 - <select name="ptype" id="accua-post-type-filter-2">
441 - <option value=""><?php esc_html_e('Show all content types', 'contact-forms'); ?></option>
442 - <?php foreach ($submitted_post_types as $post_type_slug => $post_type_label) { ?>
443 - <option value="<?php echo esc_attr($post_type_slug); ?>" <?php selected($filter_post_type, $post_type_slug); ?>><?php echo esc_html($post_type_label); ?></option>
444 - <?php } ?>
445 - </select>
446 -
447 - <label><?php esc_html_e('Content: ', 'contact-forms'); ?></label>
448 - <select name="pid" id="accua-post-filter-2">
449 - <option value="-1" <?php selected($filter_post, -1); ?>><?php esc_html_e('Show all contents', 'contact-forms'); ?></option>
450 - <?php foreach ($submitted_posts as $submitted_post) {
451 - $post_type_label = isset($submitted_post_types[$submitted_post['post_type']]) ? $submitted_post_types[$submitted_post['post_type']] : $submitted_post['post_type'];
452 - $post_title = $submitted_post['post_title'] !== '' ? $submitted_post['post_title'] : '#' . $submitted_post['post_id'];
453 - $option_label = '[' . $post_type_label . '] ' . $post_title;
454 - ?>
455 - <option value="<?php echo esc_attr($submitted_post['post_id']); ?>" data-post-type="<?php echo esc_attr($submitted_post['post_type']); ?>" <?php selected($filter_post, (int) $submitted_post['post_id']); ?>><?php echo esc_html($option_label); ?></option>
456 - <?php } ?>
457 - </select>
458 -
459 - <input type="submit" class="button button-secondary" value="<?php esc_attr_e('Apply', 'contact-forms') ?>" />
460 - </form>
461 -
462 - <form method="get" action="" style="margin-bottom:70px;">
463 - <div class="div-inside-form-slider">
464 - <div>
465 - <input type="range" min="1" max="<?php echo !empty($origin_label_my2) ? count($origin_label_my2) : 24; ?>" value="24" class="slider" name="slide_period2" id="slide_period2" step="1">
466 - <p>Last <span id="slide_period2_value" class="span-value"></span> months</p>
467 - </div>
468 - </div>
469 - </form>
470 -
471 - <?php
472 - if (!empty($query_grafico2)) {
473 -
474 - echo "<div class='fixed-height-chart' style='height: 350px'>";
475 - echo '<canvas id="ContactChart2"></canvas>';
476 - echo "</div>";
477 -
478 - $script_grafico2 = "
479 - <script>
480 - jQuery(document).ready(function(){
481 - /* slider */
482 - var slider_periodo2 = document.getElementById('slide_period2');
483 - var output_slider_periodo2 = document.getElementById('slide_period2_value');
484 - output_slider_periodo2.innerHTML = slider_periodo2.value;
485 -
486 - var labels2 = " . _accua_forms_json_encode($label_my2) . ";
487 - const dataa2 = {
488 - labels: labels2,
489 - datasets: [
490 - {
491 - label: 'Submissions',
492 - data: " . _accua_forms_json_encode($submissions2) . ",
493 - backgroundColor: 'rgba(21, 202, 255, 0.35)',
494 - borderColor: 'rgba(21, 202, 255, 1)',
495 - borderWidth: 1,
496 - },
497 - {
498 - label: 'Unique pages',
499 - data: " . _accua_forms_json_encode($unique_posts2) . ",
500 - backgroundColor: 'rgba(46, 204, 113, 1)',
501 - borderColor: 'rgba(46, 204, 113, 1)',
502 - borderWidth: 1,
503 - xAxisID: 'axis1',
504 - }
505 - ]
506 - };
507 -
508 - const config2 = {
509 - type: 'bar',
510 - data: dataa2,
511 - options: {
512 - responsive: true,
513 - scales:{
514 - x: {
515 - ticks:{
516 - display: false
517 - },
518 - grid: {
519 - offset:false
520 - }
521 - }
522 - },
523 - maintainAspectRatio: false,
524 - plugins: {
525 - title: {
526 - display: false,
527 - },
528 - },
529 - interaction: {
530 - intersect: false,
531 - }
532 - }
533 - };
534 -
535 - var ctx2 = document.getElementById('ContactChart2').getContext('2d');
536 - var myChart2 = new Chart(ctx2, config2);
537 -
538 - function update_mychart2_submissions(item, index) {
539 - myChart2.data.datasets[0].data[index] = item;
540 - }
541 - function update_mychart2_unique_posts(item, index) {
542 - myChart2.data.datasets[1].data[index] = item;
543 - }
544 -
545 - slider_periodo2.oninput = function() {
546 - slider_periodo2_val = this.value;
547 - output_slider_periodo2.innerHTML = slider_periodo2_val;
548 -
549 - label2 = " . _accua_forms_json_encode($origin_label_my2) . ";
550 - subs2 = " . _accua_forms_json_encode($origin_submissions2) . ";
551 - uposts2 = " . _accua_forms_json_encode($origin_unique_posts2) . ";
552 -
553 - label2 = label2.slice(0, slider_periodo2_val).reverse();
554 - subs2 = subs2.slice(0, slider_periodo2_val).reverse();
555 - uposts2 = uposts2.slice(0, slider_periodo2_val).reverse();
556 -
557 - subs2.forEach(update_mychart2_submissions);
558 - uposts2.forEach(update_mychart2_unique_posts);
559 - myChart2.data.labels = label2;
560 - myChart2.update();
561 - }
562 -
563 - });
564 - </script>
565 - ";
566 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Chart.js configuration with pre-escaped values
567 - echo $script_grafico2;
568 - echo '<script>
569 - jQuery(function($) {
570 - function bindDependentPostSelect(postTypeSelector, postSelector) {
571 - var $postType = $(postTypeSelector);
572 - var $post = $(postSelector);
573 -
574 - if (!$postType.length || !$post.length) {
575 - return;
576 - }
577 -
578 - function updateOptions() {
579 - var selectedType = $postType.val();
580 - var hasVisibleSelection = false;
581 -
582 - $post.find("option").each(function() {
583 - var $option = $(this);
584 - var optionType = $option.data("post-type");
585 - var visible = !selectedType || !optionType || optionType === selectedType;
586 -
587 - $option.prop("hidden", !visible);
588 - $option.prop("disabled", !visible);
589 -
590 - if (visible && $option.is(":selected")) {
591 - hasVisibleSelection = true;
592 - }
593 - });
594 -
595 - if (!hasVisibleSelection) {
596 - $post.val("-1");
597 - }
598 - }
599 -
600 - $postType.on("change", updateOptions);
601 - updateOptions();
602 - }
603 -
604 - bindDependentPostSelect("#accua-post-type-filter", "#accua-post-filter");
605 - bindDependentPostSelect("#accua-post-type-filter-2", "#accua-post-filter-2");
606 - });
607 - </script>';
608 - } else {
609 - echo '<div style="height: 350px"><p>', esc_html__('No forms submitted', 'contact-forms'), '</p></div>';
610 - } ?>
611 - </div>
612 -
613 - </div>
614 -
615 -
616 - <div class="postbox">
617 - <div class="postbox-header"><h2><?php esc_html_e('Last 10 submissions', 'contact-forms'); ?></h2></div>
618 - <div class="inside">
619 292 <?php
620 293 $query_last_submissions = "SELECT `afs_id`, `afs_submitted`
621 294 FROM `{$wpdb->prefix}accua_forms_submissions`
622 295 WHERE `afs_status` >= 0
@@ -621,21 +294,20 @@
621 294 FROM `{$wpdb->prefix}accua_forms_submissions`
622 295 WHERE `afs_status` >= 0
623 296 ORDER BY `afs_id` DESC LIMIT 10";
624 297
625 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query has no user input, uses static LIMIT
626 298 $data_last_submissions = $wpdb->get_results($query_last_submissions);
627 299
628 300 if ($data_last_submissions) { ?>
629 301 <table class="table_last_submit">
630 302 <tr>
631 - <th><?php esc_html_e('Date', 'contact-forms'); ?></th>
632 - <!--<th><?php // esc_html_e('Firstname Lastname', 'contact-forms'); ?></th>-->
633 - <th><?php esc_html_e('Email', 'contact-forms'); ?></th>
634 - <th><?php esc_html_e('Referrer', 'contact-forms'); ?></th>
635 - <th><?php esc_html_e('URI', 'contact-forms'); ?></th>
636 - <!--<th><?php // esc_html_e('Status', 'contact-forms'); ?></th>-->
637 - <th><?php esc_html_e('Review', 'contact-forms'); ?></th>
303 + <th><?php _e('Date', 'contact-forms'); ?></th>
304 + <!--<th><?php // _e('Firstname Lastname', 'contact-forms'); ?></th>-->
305 + <th><?php _e('Email', 'contact-forms'); ?></th>
306 + <th><?php _e('Referrer', 'contact-forms'); ?></th>
307 + <th><?php _e('URI', 'contact-forms'); ?></th>
308 + <!--<th><?php // _e('Status', 'contact-forms'); ?></th>-->
309 + <th><?php _e('Review', 'contact-forms'); ?></th>
638 310 </tr>
639 311
640 312
641 313
@@ -669,38 +341,35 @@
669 341 WHERE `afs_id` = %d";
670 342
671 343 //$data_meta_submission_nome = $wpdb->get_var($wpdb->prepare($query_meta_submission_nome, $row->afs_id));
672 344 //$data_meta_submission_cognome = $wpdb->get_var($wpdb->prepare($query_meta_submission_cognome, $row->afs_id));
673 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query templates are prepared with $wpdb->prepare() call
674 345 $data_meta_submission_email = (string) $wpdb->get_var($wpdb->prepare($query_meta_submission_email, $row->afs_id));
675 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query templates are prepared with $wpdb->prepare() call
676 346 $data_meta_submission_uri = (string) $wpdb->get_var($wpdb->prepare($query_data_submission_uri, $row->afs_id));
677 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query templates are prepared with $wpdb->prepare() call
678 347 $data_meta_submission_ref = (string) $wpdb->get_var($wpdb->prepare($query_data_submission_ref, $row->afs_id));
679 348
680 349 echo '<tr>';
681 350 $date = new DateTime($row->afs_submitted);
682 351 if(get_locale() == 'it_IT'){
683 - echo '<td>' . esc_html($date->format('j M Y')) . '</td>';
352 + echo '<td>'.$date->format('j M Y').'</td>'; //todo: date in italiano? strftime?
684 353 } else{
685 - echo '<td>' . esc_html($date->format(' M j, Y')) . '</td>';
354 + echo '<td>'.$date->format(' M j, Y').'</td>';
686 355 }
687 356 //echo '<td>'.$data_meta_submission_nome.' '.$data_meta_submission_cognome.'</td>';
688 - echo '<td>'.esc_html($data_meta_submission_email).'</td>';
357 + echo '<td>'.htmlspecialchars($data_meta_submission_email).'</td>';
689 358 echo '<td>';
690 359 //referrer
691 - echo '<a href="'.esc_url($data_meta_submission_ref).'" title="" target="_blank">'.esc_html($data_meta_submission_ref).'</a>';
360 + echo '<a href="'.htmlspecialchars($data_meta_submission_ref, ENT_QUOTES).'" title="" target="_blank">'.htmlspecialchars($data_meta_submission_ref, ENT_QUOTES).'</a>';
692 361 echo '</td>';
693 362 echo '<td>';
694 - echo '<a href="'.esc_url(get_bloginfo('url').$data_meta_submission_uri).'" title="" target="_blank">'.esc_html($data_meta_submission_uri).'</a>';
363 + echo '<a href="'.htmlspecialchars(get_bloginfo('url').$data_meta_submission_uri, ENT_QUOTES).'" title="" target="_blank">'.htmlspecialchars($data_meta_submission_uri, ENT_QUOTES).'</a>';
695 364 echo '</td>';
696 365 //echo '<td>valido/non valido/ecc..</td>';
697 - echo '<td><a href="?page=accua_forms_submissions_list&sid='.absint($row->afs_id).'" class="">Review</a>'; ?>
366 + echo '<td><a href="?page=accua_forms_submissions_list&sid='.$row->afs_id.'" class="">Review</a>'; ?>
698 367 <div id="delete" class="submitbox">
699 368 <form id="delete-sub" method="post" action="">
700 - <input type="hidden" name="del_sub_form" value="<?php echo absint($row->afs_id); ?>" />
369 + <input type="hidden" name="del_sub_form" value="<?php echo $row->afs_id; ?>" />
701 370 <?php wp_nonce_field("del_sub_form_{$row->afs_id}", "_wpnonce_del_sub_form"); ?>
702 - <input type="submit" id="delete-sub-data" class="accua_forms_trash" value="<?php esc_attr_e('Trash', 'contact-forms') ?>" onclick='return window.confirm("Are you sure you want to trash this submission?");'/>
371 + <input type="submit" id="delete-sub-data" class="accua_forms_trash" value="<?php _e('Trash', 'contact-forms') ?>" onclick='return window.confirm("Are you sure you want to trash this submission?");'/>
703 372 </form>
704 373 </div>
705 374 <?php echo '</td>';
706 375 echo '</tr>';
@@ -706,35 +375,37 @@
706 375 echo '</tr>';
707 376 } ?>
708 377 </table>
709 378 <?php } ?>
710 - </div>
711 379 </div>
712 380
713 381 <?php if ($num_submissions) { ?>
714 - <div class="postbox">
715 - <div class="postbox-header"><h2><?php esc_html_e('Total forms submitted', 'contact-forms'); ?></h2></div>
716 - <div class="inside">
382 + <div class="postbox ">
383 + <h2><span><?php _e('Total forms submitted', 'contact-forms'); ?></span></h2>
717 384 <table>
718 - <tr class="first"><td class="first b"><?php echo esc_html($num_forms); ?></td><td class="t"><?php esc_html_e('Forms', 'contact-forms'); ?></td></tr>
719 - <tr class="first"><td class="first b"><?php echo esc_html($num_posts); ?></td><td class="t"><?php esc_html_e('Pages', 'contact-forms'); ?></td></tr>
720 - <tr class="first"><td class="first b"><?php echo esc_html($num_submissions); ?></td><td class="t"><?php esc_html_e('Submissions', 'contact-forms'); ?></td></tr>
721 - <tr class="first"><td class="first b"><?php echo esc_html($num_emails); ?></td><td class="t"><?php esc_html_e('Distinct Emails', 'contact-forms'); ?></td></tr>
385 + <tr class="first"><td class="first b"><?php echo $num_forms; ?></td><td class="t"><?php _e('Forms', 'contact-forms'); ?></td></tr>
386 + <tr class="first"><td class="first b"><?php echo $num_posts; ?></td><td class="t"><?php _e('Pages', 'contact-forms'); ?></td></tr>
387 + <tr class="first"><td class="first b"><?php echo $num_submissions; ?></td><td class="t"><?php _e('Submissions', 'contact-forms'); ?></td></tr>
388 + <tr class="first"><td class="first b"><?php echo $num_emails; ?></td><td class="t"><?php _e('Distinct Emails', 'contact-forms'); ?></td></tr>
722 389 </table>
723 - <h3><?php esc_html_e('Submissions per lead status', 'contact-forms'); ?></h3>
390 + <h2><span><?php _e('Submissions per lead status', 'contact-forms'); ?></span></h2>
724 391 <table>
725 392 <?php
726 393 $lead_statuses = accua_forms_get_lead_statuses();
727 394 foreach ($lead_statuses as $k => $v) {
728 395 if (isset($num_submissions_per_lead_status[$k])) {
729 - echo '<tr class="first"><td class="first b">'.absint($num_submissions_per_lead_status[$k]->n).'</td><td class="t">'.esc_html($v).'</td></tr>';
396 + echo '<tr class="first"><td class="first b">'.$num_submissions_per_lead_status[$k]->n.'</td><td class="t">'.htmlspecialchars($v).'</td></tr>';
730 397 }
731 398 }
732 399 ?>
733 400 </table>
734 - </div>
735 401 </div>
736 402 <?php } ?>
403 +
404 + <span id="accua-forms-version">by Cimatti - <a href="http://www.cimatti.it/wordpress/contact-forms/">www.cimatti.it/wordpress/contact-forms</a>
405 + <br /><?php
406 + $plugin_data = get_plugin_data( ACCUA_FORMS_FILE );
407 + _e('Version', 'contact-forms'); echo " ".$plugin_data['Version'];
408 + ?></span>
737 409 </div>
738 410 <?php
739 - // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
740 411 }