Visitors Traffic Real Time Statistics - Version 5.6

Version Description

  1. Shortcode improvements

You can use one of the following shortcodes:

  • [ahc_stats_widget] adds a front-end widget to display the site statistics
  • [ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ] adds a front-end widget to display the site statistics with custom parametrs

  • [ahc_today_visitors] this will return today's visitors

  • [ahc_today_visits] this will return today's visits

  • [ahc_total_visitors] this will return total visitors

  • [ahc_total_visits] this will return total visits

Download this release

Release Info

Developer osamaesh
Plugin Icon 128x128 Visitors Traffic Real Time Statistics
Version 5.6
Comparing to
See all releases

Code changes from version 5.5 to 5.6

Visitors-Traffic-Real-Time-Statistics.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visitor Traffic Real Time Statistics
4
  Description: Hits counter that shows analytical numbers of your WordPress site visitors and hits.
5
  Author: wp-buy
6
  Author URI: https://www.wp-buy.com/
7
- Version: 5.5
8
  Text Domain: visitors-traffic-real-time-statistics
9
  Domain Path: /languages
10
  */
@@ -21,16 +21,17 @@ if( !function_exists('get_plugin_data') or !function_exists('wp_get_current_user
21
  }
22
 
23
 
24
-
25
- if ( function_exists('get_plugin_data') ) {
26
- $woodhl_detail = get_plugin_data( __FILE__ );
27
- $installed_version = get_option( 'visitors-traffic-real-time-statistics-pro-version' );
28
- if( $installed_version != $woodhl_detail['Version'] ){
29
- add_action( 'plugins_loaded', 'ahcfree_init' );
30
-
31
- update_option( 'visitors-traffic-real-time-statistics-pro-version', $woodhl_detail['Version'] );
32
- }
33
- }
 
34
  /*
35
  $ahcfree_GetWPTimezoneString = isset(ahcfree_GetWPTimezoneString()) ? ahcfree_GetWPTimezoneString() : get_option( 'timezone_string' );
36
 
4
  Description: Hits counter that shows analytical numbers of your WordPress site visitors and hits.
5
  Author: wp-buy
6
  Author URI: https://www.wp-buy.com/
7
+ Version: 5.6
8
  Text Domain: visitors-traffic-real-time-statistics
9
  Domain Path: /languages
10
  */
21
  }
22
 
23
 
24
+ add_action( 'plugins_loaded', 'ahcfree_init' );
25
+ add_action( 'plugins_loaded', 'ahcfree_multisite_init',99 );
26
+ //if ( function_exists('get_plugin_data') ) {
27
+ // $woodhl_detail = get_plugin_data( __FILE__ );
28
+ // $installed_version = get_option( 'visitors-traffic-real-time-statistics-pro-version' );
29
+ // if( $installed_version != $woodhl_detail['Version'] ){
30
+ // add_action( 'plugins_loaded', 'ahcfree_init' );
31
+ //
32
+ // update_option( 'visitors-traffic-real-time-statistics-pro-version', $woodhl_detail['Version'] );
33
+ // }
34
+ //}
35
  /*
36
  $ahcfree_GetWPTimezoneString = isset(ahcfree_GetWPTimezoneString()) ? ahcfree_GetWPTimezoneString() : get_option( 'timezone_string' );
37
 
WPHitsCounter.php CHANGED
@@ -220,14 +220,15 @@ class WPHitsCounter {
220
  'date' => ahcfree_localtime('Y-m-d H:i:s'),
221
  'hit_ip_address' => $this->ipAddress,
222
  'hit_page_id' => $this->pageId,
 
223
  )
224
  );
225
 
226
  //$sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(`hit_date`) = '". ahcfree_localtime("Y-m-d") ."' AND `hit_ip_address` = %s AND `hit_page_id` = %s";
227
 
228
- $sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(CONVERT_TZ(CONCAT_WS(' ',hit_date,hit_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '".ahcfree_localtime("Y-m-d")."' AND `hit_ip_address` = %s AND `hit_page_id` = %s";
229
 
230
- $result = $wpdb->get_results($wpdb->prepare($sql, $this->ipAddress, $this->pageId), OBJECT);
231
 
232
  if ($result !== false) {
233
 
@@ -254,9 +255,10 @@ class WPHitsCounter {
254
 
255
  /*$sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(`hit_date`) = '". gmdate("Y-m-d") ."' AND `hit_ip_address` = %s";*/
256
 
257
- $sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(CONVERT_TZ(CONCAT_WS(' ',hit_date,hit_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '".ahcfree_localtime("Y-m-d")."' AND `hit_ip_address` = %s";
258
 
259
  $result = $wpdb->get_results($wpdb->prepare($sql, $this->ipAddress), OBJECT);
 
260
  if ($result !== false) {
261
 
262
  return ((int) $result[0]->ct > 0);
@@ -274,56 +276,67 @@ class WPHitsCounter {
274
  * @return void
275
 
276
  */
 
 
 
 
 
 
 
 
 
 
 
277
  protected function getBrowser() {
278
 
279
  if (strpos($this->userAgent, 'MSIE') !== false) {
280
 
281
- $this->browser = 1;
282
  } elseif (strpos($this->userAgent, 'Trident') !== false) {
283
 
284
- $this->browser = 1;
285
  } elseif (strpos($this->userAgent, 'Gecko') !== false) {
286
 
287
  if (strpos($this->userAgent, 'Firefox') !== false) {
288
 
289
- $this->browser = 2;
290
  } elseif (strpos($this->userAgent, 'Netscape') !== false) {
291
 
292
- $this->browser = 3;
293
  } elseif (strpos($this->userAgent, 'Chrome') !== false) {
294
 
295
- $this->browser = 4;
296
  } else {
297
 
298
- $this->browser = 5;
299
  }
300
  } elseif (strpos($this->userAgent, 'Opera Mini') !== false) {
301
 
302
- $this->browser = 6;
303
  } elseif (strpos($this->userAgent, 'Opera') !== false) {
304
 
305
- $this->browser = 7;
306
  } elseif (strpos($this->userAgent, 'Safari') !== false) {
307
 
308
- $this->browser = 8;
309
  } elseif (strpos($this->userAgent, 'iPad') !== false) {
310
 
311
- $this->browser = 9;
312
  } elseif (strpos($this->userAgent, 'Android') !== false) {
313
 
314
- $this->browser = 10;
315
  } elseif (strpos($this->userAgent, 'AIR') !== false) {
316
 
317
- $this->browser = 11;
318
  } elseif (strpos($this->userAgent, 'Fluid') !== false) {
319
 
320
- $this->browser = 12;
321
  } elseif (strpos($this->userAgent, 'Maxthon') !== false) {
322
 
323
- $this->browser = 13;
324
  } else {
325
 
326
- $this->browser = 14;
327
  }
328
  }
329
 
@@ -406,9 +419,9 @@ class WPHitsCounter {
406
 
407
  if (!empty($this->countryInternetCode)) {
408
 
409
- $sql = "SELECT `ctr_id` FROM `ahc_countries` WHERE `ctr_internet_code` = %s ";
410
 
411
- $results = $wpdb->get_results($wpdb->prepare($sql, $this->countryInternetCode), OBJECT);
412
 
413
  if ($results !== false && !empty($results)) {
414
 
@@ -517,7 +530,7 @@ class WPHitsCounter {
517
  $del_result = $wpdb->get_results($del_sql, OBJECT);
518
 
519
 
520
- $sql = "SELECT COUNT(`vst_id`) AS ct FROM `ahc_visitors` WHERE DATE(`vst_date`) = '".gmdate("Y-m-d")."'";
521
 
522
  //$sql = "SELECT COUNT(`vst_id`) AS ct FROM `ahc_visitors` WHERE DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = DATE(CONVERT_TZ(NOW( ),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
523
 
@@ -548,7 +561,7 @@ class WPHitsCounter {
548
 
549
  global $wpdb;
550
 
551
- $sql = "INSERT INTO `ahc_visitors` (`vst_date`, `vst_visitors`, `vst_visits`) VALUES ('".gmdate("Y-m-d H:i:s")."', 0, 0)";
552
 
553
  if ($wpdb->query($sql) !== false) {
554
 
@@ -615,9 +628,9 @@ class WPHitsCounter {
615
 
616
  global $wpdb;
617
 
618
- $sql = "UPDATE `ahc_browsers` SET bsr_visits = bsr_visits + 1 WHERE bsr_id = %d";
619
 
620
- if ($wpdb->query($wpdb->prepare($sql, $bsr_id)) !== false) {
621
 
622
  return true;
623
  }
@@ -652,9 +665,9 @@ class WPHitsCounter {
652
 
653
  global $wpdb;
654
 
655
- $sql = "UPDATE `ahc_countries` SET ctr_visitors = ctr_visitors + %d, ctr_visits = ctr_visits + %d WHERE ctr_id = %d";
656
 
657
- return ($wpdb->query($wpdb->prepare($sql, $visitors, $visits, $ctr_id)) !== false);
658
  }
659
 
660
  //--------------------------------------------
@@ -684,25 +697,25 @@ class WPHitsCounter {
684
 
685
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
686
 
687
- $sql = "SELECT vtsh_id FROM `ahc_searching_visits` WHERE srh_id = %d AND DATE(vtsh_date) = '".gmdate("Y-m-d")."'";
688
  //$sql = "SELECT vtsh_id FROM `ahc_searching_visits` WHERE srh_id = %d AND DATE(CONVERT_TZ(vtsh_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = DATE(CONVERT_TZ(NOW( ),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
689
 
690
- $result = $wpdb->get_results($wpdb->prepare($sql, $srh_id), OBJECT);
691
 
692
  if ($result !== false) {
693
 
694
  if ($wpdb->num_rows > 0) {
695
 
696
- $sql2 = "UPDATE `ahc_searching_visits` SET vtsh_visits = vtsh_visits + 1 WHERE vtsh_id = %d";
697
 
698
- return ($wpdb->query($wpdb->prepare($sql2, $result[0]->vtsh_id)) !== false);
699
  } else {
700
 
701
- $sql2 = "INSERT INTO `ahc_searching_visits` (srh_id, vtsh_date, vtsh_visits)
702
 
703
- VALUES (%d, %s, 1)";
704
 
705
- return ($wpdb->query($wpdb->prepare($sql2, $srh_id, gmdate("Y-m-d H:i:s"))) !== false);
706
  }
707
  } else {
708
 
@@ -736,14 +749,14 @@ class WPHitsCounter {
736
  global $wpdb;
737
 
738
 
739
- $sql = "INSERT INTO `ahc_daily_visitors_stats` (vst_date, vst_visitors, vst_visits) values(%s, %d, %d )";
740
 
741
  $wpdb->query($wpdb->prepare($sql, gmdate("Y-m-d H:i:s"), $visitors, $visits));
742
 
743
- $sql = "INSERT INTO `ahc_visitors` (vst_date, vst_visitors, vst_visits) values(%s, %d, %d )";
744
  //$sql = "UPDATE `ahc_visitors` SET vst_visitors = vst_visitors + %d, vst_visits = vst_visits + %d WHERE DATE(vst_date) = DATE(NOW())";
745
 
746
- return ($wpdb->query($wpdb->prepare($sql, gmdate("Y-m-d H:i:s"), $visitors, $visits)) !== false);
747
  }
748
 
749
  //--------------------------------------------
@@ -771,24 +784,24 @@ class WPHitsCounter {
771
 
772
  global $wpdb;
773
 
774
- $sql = "SELECT rfr_id FROM `ahc_refering_sites` where rfr_site_name = %s";
775
 
776
- $result = $wpdb->get_results($wpdb->prepare($sql, $rfr_site_name), OBJECT);
777
 
778
  if ($result !== false) {
779
 
780
  if (!empty($result)) {
781
 
782
- $sql2 = "UPDATE `ahc_refering_sites` SET rfr_visits = rfr_visits + 1 WHERE rfr_id = %d";
783
 
784
- return ($wpdb->query($wpdb->prepare($sql2, $result[0]->rfr_id)) !== false);
785
  } else {
786
 
787
- $sql2 = "INSERT INTO `ahc_refering_sites` (rfr_site_name, rfr_visits)
788
 
789
- VALUES(%s, 1)";
790
 
791
- return ($wpdb->query($wpdb->prepare($sql2, $rfr_site_name)) !== false);
792
  }
793
  } else {
794
 
@@ -859,11 +872,11 @@ class WPHitsCounter {
859
 
860
  }
861
 
862
- $sql = "INSERT INTO `ahc_recent_visitors` (vtr_ip_address, vtr_referer, srh_id, bsr_id, ctr_id, ahc_city, ahc_region, vtr_date, vtr_time) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)";
863
 
864
 
865
 
866
- return ($wpdb->query($wpdb->prepare($sql, $vtr_ip_address, $vtr_referer, $srh_id, $bsr_id, $ctr_id, $ahc_city, $ahc_region, gmdate("Y-m-d"), gmdate("H:i:s") )) !== false);
867
  }
868
 
869
  //--------------------------------------------
@@ -899,11 +912,11 @@ class WPHitsCounter {
899
 
900
  global $wpdb;
901
 
902
- $sql = "INSERT INTO `ahc_keywords` (kwd_ip_address, kwd_keywords, kwd_referer, srh_id, ctr_id, bsr_id, kwd_date, kwd_time)
903
 
904
- VALUES (%s, %s, %s, %d, %d, %d, %s, %s)";
905
 
906
- return ($wpdb->query($wpdb->prepare($sql, $kwd_ip_address, $kwd_keywords, $kwd_referer, $srh_id, $ctr_id, $bsr_id, gmdate("Y-m-d"), gmdate("H:i:s"))) !== false);
907
  }
908
 
909
  //--------------------------------------------
@@ -929,9 +942,9 @@ class WPHitsCounter {
929
 
930
  global $wpdb;
931
 
932
- $sql11 = "SELECT vtr_id FROM `ahc_recent_visitors` ORDER BY vtr_id LIMIT %d";
933
 
934
- $result = $wpdb->get_results($wpdb->prepare($sql11, AHCFREE_RECENT_VISITORS_LIMIT), OBJECT);
935
 
936
  if ($result !== false) {
937
 
@@ -946,13 +959,13 @@ class WPHitsCounter {
946
 
947
  $ids1 = implode(',', $ids1);
948
 
949
- $sql12 = "DELETE FROM `ahc_recent_visitors`" . ((!empty($ids1)) ? " WHERE vtr_id NOT IN (" . $ids1 . ")" : "");
950
 
951
 
952
 
953
- $sql21 = "SELECT kwd_id FROM `ahc_keywords` ORDER BY kwd_id LIMIT %d";
954
 
955
- $result2 = $wpdb->get_results($wpdb->prepare($sql21, AHCFREE_RECENT_KEYWORDS_LIMIT), OBJECT);
956
 
957
  if ($result2 !== false) {
958
 
@@ -1006,9 +1019,9 @@ class WPHitsCounter {
1006
 
1007
  global $wpdb;
1008
 
1009
- $sql = "SELECT til_id FROM `ahc_title_traffic` where til_page_id = %s";
1010
 
1011
- $result = $wpdb->get_results($wpdb->prepare($sql, $til_page_id), OBJECT);
1012
 
1013
  if ($result !== false) {
1014
 
@@ -1018,16 +1031,16 @@ class WPHitsCounter {
1018
 
1019
  SET til_hits = til_hits + 1, til_page_title = %s
1020
 
1021
- WHERE til_id = %d";
1022
 
1023
- return ($wpdb->query($wpdb->prepare($sql2, $til_page_title, $result[0]->til_id)) !== false);
1024
  } else {
1025
 
1026
- $sql2 = "INSERT INTO `ahc_title_traffic` (til_page_id, til_page_title, til_hits)
1027
 
1028
- VALUES(%s, %s, 1)";
1029
 
1030
- return ($wpdb->query($wpdb->prepare($sql2, $til_page_id, $til_page_title)) !== false);
1031
  }
1032
  } else {
1033
 
@@ -1062,18 +1075,18 @@ class WPHitsCounter {
1062
  $time = gmdate('H:i:s');
1063
  $sql = "UPDATE `ahc_visits_time` SET vtm_visitors = vtm_visitors + %d, vtm_visits = vtm_visits + %d
1064
 
1065
- WHERE TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time'";
1066
  $query = $wpdb->prepare($sql, $visitors, $visits);
1067
  $result = ($wpdb->query($query) !== false);
1068
 
1069
  $sql = "UPDATE `ahc_visits_time` SET vtm_visitors = 1
1070
 
1071
- WHERE vtm_visitors = 0 AND TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time'";
1072
  $query = $wpdb->query($sql);
1073
 
1074
  $sql = "UPDATE `ahc_visits_time` SET vtm_visits = 1
1075
 
1076
- WHERE vtm_visits = 0 AND TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time'";
1077
  $query = $wpdb->query($sql);
1078
 
1079
  return $result;
@@ -1104,12 +1117,11 @@ class WPHitsCounter {
1104
 
1105
  (`hit_ip_address`, `hit_user_agent`, `hit_request_uri`, `hit_page_id`, `hit_page_title`, `ctr_id`, `hit_referer`, `hit_referer_site`,
1106
 
1107
- `srh_id`, `hit_search_words`, `bsr_id`, `hit_date`, `hit_time`)
1108
-
1109
- VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %s, %d, %s, %s)";
1110
 
1111
- $result = $wpdb->query($wpdb->prepare($sql, $this->ipAddress, $this->userAgent, $this->requestUri, $this->pageId, $this->pageTitle, $this->countryId, $this->referer, $this->refererSite, $this->searchEngine, $this->keyWords, $this->browser, gmdate("Y-m-d"), gmdate("H:i:s") ));
1112
 
 
1113
  return ($result !== false);
1114
  }
1115
 
220
  'date' => ahcfree_localtime('Y-m-d H:i:s'),
221
  'hit_ip_address' => $this->ipAddress,
222
  'hit_page_id' => $this->pageId,
223
+ 'site_id' => get_current_blog_id()
224
  )
225
  );
226
 
227
  //$sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(`hit_date`) = '". ahcfree_localtime("Y-m-d") ."' AND `hit_ip_address` = %s AND `hit_page_id` = %s";
228
 
229
+ $sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(CONVERT_TZ(CONCAT_WS(' ',hit_date,hit_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '".ahcfree_localtime("Y-m-d")."' AND `hit_ip_address` = %s AND `hit_page_id` = %s AND `site_id` = %d ";
230
 
231
+ $result = $wpdb->get_results($wpdb->prepare($sql, $this->ipAddress, $this->pageId,get_current_blog_id()), OBJECT);
232
 
233
  if ($result !== false) {
234
 
255
 
256
  /*$sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE DATE(`hit_date`) = '". gmdate("Y-m-d") ."' AND `hit_ip_address` = %s";*/
257
 
258
+ $sql = "SELECT COUNT(`hit_id`) AS ct FROM `ahc_hits` WHERE site_id = ".get_current_blog_id()." and DATE(CONVERT_TZ(CONCAT_WS(' ',hit_date,hit_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '".ahcfree_localtime("Y-m-d")."' AND `hit_ip_address` = %s";
259
 
260
  $result = $wpdb->get_results($wpdb->prepare($sql, $this->ipAddress), OBJECT);
261
+ print_r($result);
262
  if ($result !== false) {
263
 
264
  return ((int) $result[0]->ct > 0);
276
  * @return void
277
 
278
  */
279
+ public function get_browser_id($browser){
280
+ global $wpdb;
281
+ $sql = "SELECT `bsr_id` FROM `ahc_browsers` WHERE `bsr_name` = %s and site_id = %d ";
282
+
283
+ $results = $wpdb->get_results($wpdb->prepare($sql, $browser,get_current_blog_id()), OBJECT);
284
+
285
+ if ($results !== false && !empty($results)) {
286
+ return $results[0]->bsr_id;
287
+ }
288
+ return 0;
289
+ }
290
  protected function getBrowser() {
291
 
292
  if (strpos($this->userAgent, 'MSIE') !== false) {
293
 
294
+ $this->browser = $this->get_browser_id('IE');
295
  } elseif (strpos($this->userAgent, 'Trident') !== false) {
296
 
297
+ $this->browser = $this->get_browser_id('IE');
298
  } elseif (strpos($this->userAgent, 'Gecko') !== false) {
299
 
300
  if (strpos($this->userAgent, 'Firefox') !== false) {
301
 
302
+ $this->browser = $this->get_browser_id('Firefox');
303
  } elseif (strpos($this->userAgent, 'Netscape') !== false) {
304
 
305
+ $this->browser = $this->get_browser_id('Netscape');
306
  } elseif (strpos($this->userAgent, 'Chrome') !== false) {
307
 
308
+ $this->browser = $this->get_browser_id('Chrome');
309
  } else {
310
 
311
+ $this->browser = $this->get_browser_id('Gecko/Mozilla');
312
  }
313
  } elseif (strpos($this->userAgent, 'Opera Mini') !== false) {
314
 
315
+ $this->browser = $this->get_browser_id('Opera Mini');
316
  } elseif (strpos($this->userAgent, 'Opera') !== false) {
317
 
318
+ $this->browser = $this->get_browser_id('Opera');
319
  } elseif (strpos($this->userAgent, 'Safari') !== false) {
320
 
321
+ $this->browser = $this->get_browser_id('Safari');
322
  } elseif (strpos($this->userAgent, 'iPad') !== false) {
323
 
324
+ $this->browser = $this->get_browser_id('iPad');
325
  } elseif (strpos($this->userAgent, 'Android') !== false) {
326
 
327
+ $this->browser = $this->get_browser_id('Android');
328
  } elseif (strpos($this->userAgent, 'AIR') !== false) {
329
 
330
+ $this->browser = $this->get_browser_id('AIR');
331
  } elseif (strpos($this->userAgent, 'Fluid') !== false) {
332
 
333
+ $this->browser = $this->get_browser_id('Fluid');
334
  } elseif (strpos($this->userAgent, 'Maxthon') !== false) {
335
 
336
+ $this->browser = $this->get_browser_id('Maxthon');
337
  } else {
338
 
339
+ $this->browser = $this->get_browser_id('unknown');
340
  }
341
  }
342
 
419
 
420
  if (!empty($this->countryInternetCode)) {
421
 
422
+ $sql = "SELECT `ctr_id` FROM `ahc_countries` WHERE `ctr_internet_code` = %s and site_id = %d ";
423
 
424
+ $results = $wpdb->get_results($wpdb->prepare($sql, $this->countryInternetCode,get_current_blog_id()), OBJECT);
425
 
426
  if ($results !== false && !empty($results)) {
427
 
530
  $del_result = $wpdb->get_results($del_sql, OBJECT);
531
 
532
 
533
+ $sql = "SELECT COUNT(`vst_id`) AS ct FROM `ahc_visitors` WHERE site_id = ".get_current_blog_id()." and DATE(`vst_date`) = '".gmdate("Y-m-d")."'";
534
 
535
  //$sql = "SELECT COUNT(`vst_id`) AS ct FROM `ahc_visitors` WHERE DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = DATE(CONVERT_TZ(NOW( ),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
536
 
561
 
562
  global $wpdb;
563
 
564
+ $sql = "INSERT INTO `ahc_visitors` (`vst_date`, `vst_visitors`, `vst_visits`, `site_id`) VALUES ('".gmdate("Y-m-d H:i:s")."', 0, 0,'".get_current_blog_id()."')";
565
 
566
  if ($wpdb->query($sql) !== false) {
567
 
628
 
629
  global $wpdb;
630
 
631
+ $sql = "UPDATE `ahc_browsers` SET bsr_visits = bsr_visits + 1 WHERE bsr_id = %d and site_id=%d";
632
 
633
+ if ($wpdb->query($wpdb->prepare($sql, $bsr_id,get_current_blog_id())) !== false) {
634
 
635
  return true;
636
  }
665
 
666
  global $wpdb;
667
 
668
+ $sql = "UPDATE `ahc_countries` SET ctr_visitors = ctr_visitors + %d, ctr_visits = ctr_visits + %d WHERE ctr_id = %d and site_id = %d";
669
 
670
+ return ($wpdb->query($wpdb->prepare($sql, $visitors, $visits, $ctr_id,get_current_blog_id())) !== false);
671
  }
672
 
673
  //--------------------------------------------
697
 
698
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
699
 
700
+ $sql = "SELECT vtsh_id FROM `ahc_searching_visits` WHERE site_id = %d AND srh_id = %d AND DATE(vtsh_date) = '".gmdate("Y-m-d")."'";
701
  //$sql = "SELECT vtsh_id FROM `ahc_searching_visits` WHERE srh_id = %d AND DATE(CONVERT_TZ(vtsh_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = DATE(CONVERT_TZ(NOW( ),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
702
 
703
+ $result = $wpdb->get_results($wpdb->prepare($sql, get_current_blog_id(),$srh_id), OBJECT);
704
 
705
  if ($result !== false) {
706
 
707
  if ($wpdb->num_rows > 0) {
708
 
709
+ $sql2 = "UPDATE `ahc_searching_visits` SET vtsh_visits = vtsh_visits + 1 WHERE vtsh_id = %d and site_id=%d";
710
 
711
+ return ($wpdb->query($wpdb->prepare($sql2, $result[0]->vtsh_id,get_current_blog_id())) !== false);
712
  } else {
713
 
714
+ $sql2 = "INSERT INTO `ahc_searching_visits` (srh_id, vtsh_date, vtsh_visits,site_id)
715
 
716
+ VALUES (%d, %s, 1,%d)";
717
 
718
+ return ($wpdb->query($wpdb->prepare($sql2, $srh_id, gmdate("Y-m-d H:i:s"),get_current_blog_id())) !== false);
719
  }
720
  } else {
721
 
749
  global $wpdb;
750
 
751
 
752
+ $sql = "INSERT INTO `ahc_daily_visitors_stats` (vst_date, vst_visitors, vst_visits,site_id) values(%s, %d, %d, %d )";
753
 
754
  $wpdb->query($wpdb->prepare($sql, gmdate("Y-m-d H:i:s"), $visitors, $visits));
755
 
756
+ $sql = "INSERT INTO `ahc_visitors` (vst_date, vst_visitors, vst_visits,site_id) values(%s, %d, %d, %d)";
757
  //$sql = "UPDATE `ahc_visitors` SET vst_visitors = vst_visitors + %d, vst_visits = vst_visits + %d WHERE DATE(vst_date) = DATE(NOW())";
758
 
759
+ return ($wpdb->query($wpdb->prepare($sql, gmdate("Y-m-d H:i:s"), $visitors, $visits,get_current_blog_id())) !== false);
760
  }
761
 
762
  //--------------------------------------------
784
 
785
  global $wpdb;
786
 
787
+ $sql = "SELECT rfr_id FROM `ahc_refering_sites` where rfr_site_name = %s and site_id=%d";
788
 
789
+ $result = $wpdb->get_results($wpdb->prepare($sql, $rfr_site_name,get_current_blog_id()), OBJECT);
790
 
791
  if ($result !== false) {
792
 
793
  if (!empty($result)) {
794
 
795
+ $sql2 = "UPDATE `ahc_refering_sites` SET rfr_visits = rfr_visits + 1 WHERE rfr_id = %d and site_id=%d";
796
 
797
+ return ($wpdb->query($wpdb->prepare($sql2, $result[0]->rfr_id,get_current_blog_id())) !== false);
798
  } else {
799
 
800
+ $sql2 = "INSERT INTO `ahc_refering_sites` (rfr_site_name, rfr_visits,site_id)
801
 
802
+ VALUES(%s, 1,%d)";
803
 
804
+ return ($wpdb->query($wpdb->prepare($sql2, $rfr_site_name,get_current_blog_id())) !== false);
805
  }
806
  } else {
807
 
872
 
873
  }
874
 
875
+ $sql = "INSERT INTO `ahc_recent_visitors` (vtr_ip_address, vtr_referer, srh_id, bsr_id, ctr_id, ahc_city, ahc_region, vtr_date, vtr_time,site_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %d)";
876
 
877
 
878
 
879
+ return ($wpdb->query($wpdb->prepare($sql, $vtr_ip_address, $vtr_referer, $srh_id, $bsr_id, $ctr_id, $ahc_city, $ahc_region, gmdate("Y-m-d"), gmdate("H:i:s"),get_current_blog_id() )) !== false);
880
  }
881
 
882
  //--------------------------------------------
912
 
913
  global $wpdb;
914
 
915
+ $sql = "INSERT INTO `ahc_keywords` (kwd_ip_address, kwd_keywords, kwd_referer, srh_id, ctr_id, bsr_id, kwd_date, kwd_time,site_id)
916
 
917
+ VALUES (%s, %s, %s, %d, %d, %d, %s, %s, %d)";
918
 
919
+ return ($wpdb->query($wpdb->prepare($sql, $kwd_ip_address, $kwd_keywords, $kwd_referer, $srh_id, $ctr_id, $bsr_id, gmdate("Y-m-d"), gmdate("H:i:s"),get_current_blog_id())) !== false);
920
  }
921
 
922
  //--------------------------------------------
942
 
943
  global $wpdb;
944
 
945
+ $sql11 = "SELECT vtr_id FROM `ahc_recent_visitors` where site_id = %d ORDER BY vtr_id LIMIT %d";
946
 
947
+ $result = $wpdb->get_results($wpdb->prepare($sql11, get_current_blog_id(),AHCFREE_RECENT_VISITORS_LIMIT), OBJECT);
948
 
949
  if ($result !== false) {
950
 
959
 
960
  $ids1 = implode(',', $ids1);
961
 
962
+ $sql12 = "DELETE FROM `ahc_recent_visitors`" . ((!empty($ids1)) ? " WHERE site_id = ".get_current_blog_id()." and vtr_id NOT IN (" . $ids1 . ")" : "");
963
 
964
 
965
 
966
+ $sql21 = "SELECT kwd_id FROM `ahc_keywords` where site_id=%d ORDER BY kwd_id LIMIT %d";
967
 
968
+ $result2 = $wpdb->get_results($wpdb->prepare($sql21, get_current_blog_id(),AHCFREE_RECENT_KEYWORDS_LIMIT), OBJECT);
969
 
970
  if ($result2 !== false) {
971
 
1019
 
1020
  global $wpdb;
1021
 
1022
+ $sql = "SELECT til_id FROM `ahc_title_traffic` where til_page_id = %s and site_id=%d";
1023
 
1024
+ $result = $wpdb->get_results($wpdb->prepare($sql, $til_page_id,get_current_blog_id()), OBJECT);
1025
 
1026
  if ($result !== false) {
1027
 
1031
 
1032
  SET til_hits = til_hits + 1, til_page_title = %s
1033
 
1034
+ WHERE til_id = %d and site_id = %d";
1035
 
1036
+ return ($wpdb->query($wpdb->prepare($sql2, $til_page_title, $result[0]->til_id,get_current_blog_id())) !== false);
1037
  } else {
1038
 
1039
+ $sql2 = "INSERT INTO `ahc_title_traffic` (til_page_id, til_page_title, til_hits,site_id)
1040
 
1041
+ VALUES(%s, %s, 1, %d)";
1042
 
1043
+ return ($wpdb->query($wpdb->prepare($sql2, $til_page_id, $til_page_title,get_current_blog_id())) !== false);
1044
  }
1045
  } else {
1046
 
1075
  $time = gmdate('H:i:s');
1076
  $sql = "UPDATE `ahc_visits_time` SET vtm_visitors = vtm_visitors + %d, vtm_visits = vtm_visits + %d
1077
 
1078
+ WHERE TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time' and site_id=".get_current_blog_id();
1079
  $query = $wpdb->prepare($sql, $visitors, $visits);
1080
  $result = ($wpdb->query($query) !== false);
1081
 
1082
  $sql = "UPDATE `ahc_visits_time` SET vtm_visitors = 1
1083
 
1084
+ WHERE vtm_visitors = 0 AND TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time' and site_id=".get_current_blog_id();
1085
  $query = $wpdb->query($sql);
1086
 
1087
  $sql = "UPDATE `ahc_visits_time` SET vtm_visits = 1
1088
 
1089
+ WHERE vtm_visits = 0 AND TIME(vtm_time_from) <= '$time' AND TIME(vtm_time_to) >= '$time' and site_id=".get_current_blog_id();
1090
  $query = $wpdb->query($sql);
1091
 
1092
  return $result;
1117
 
1118
  (`hit_ip_address`, `hit_user_agent`, `hit_request_uri`, `hit_page_id`, `hit_page_title`, `ctr_id`, `hit_referer`, `hit_referer_site`,
1119
 
1120
+ `srh_id`, `hit_search_words`, `bsr_id`, `hit_date`, `hit_time`, `site_id`)
 
 
1121
 
1122
+ VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %s, %d, %s, %s, %d)";
1123
 
1124
+ $result = $wpdb->query($wpdb->prepare($sql, $this->ipAddress, $this->userAgent, $this->requestUri, $this->pageId, $this->pageTitle, $this->countryId, $this->referer, $this->refererSite, $this->searchEngine, $this->keyWords, $this->browser, gmdate("Y-m-d"), gmdate("H:i:s") ,get_current_blog_id()));
1125
  return ($result !== false);
1126
  }
1127
 
css/custom.css CHANGED
@@ -64,9 +64,9 @@
64
  transition: .3s all;
65
  border-radius: 4px !important;
66
  }
67
- input[type="text"] , .wp-core-ui select , .ss-multi-selected{
68
  height: 38px !important;
69
- }
70
  .wp-core-ui select:hover ,.wp-core-ui select:focus ,input[type="text"]:hover ,input[type="text"]:focus , textarea:hover , textarea:focus {
71
  background-color: #ebebeb !important ;
72
  color: #2c3338;
64
  transition: .3s all;
65
  border-radius: 4px !important;
66
  }
67
+ input[type="text"] , .wp-core-ui select , .ss-multi-selected{
68
  height: 38px !important;
69
+ width: 25%;min-width: 200px;}
70
  .wp-core-ui select:hover ,.wp-core-ui select:focus ,input[type="text"]:hover ,input[type="text"]:focus , textarea:hover , textarea:focus {
71
  background-color: #ebebeb !important ;
72
  color: #2c3338;
functions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  add_shortcode( 'ahc_stats_widget', 'ahc_stats_widget_func');
4
  //[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]
5
 
@@ -53,6 +52,53 @@ function ahc_stats_widget_func( $instance = [] )
53
 
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  function vtrts_free_top_bar_enqueue_style()
57
  {
58
 
@@ -157,12 +203,21 @@ function vtrts_free_remove_dokan_js_files() {
157
  add_action( 'admin_print_scripts', 'vtrts_free_remove_dokan_js_files', 1 );
158
 
159
 
160
- function ahcfree_getVisitsTime()
161
  {
 
 
 
162
  global $wpdb;
163
- $result = $wpdb->get_results("SELECT COUNT( `vtm_id` ) cnt FROM ahc_visits_time", OBJECT);
164
- if ($result !== false) {
165
- return $result[0]->cnt;
 
 
 
 
 
 
166
  }
167
  return false;
168
  }
@@ -206,7 +261,7 @@ function ahcfree_savesettings()
206
 
207
  $ahcproExcludeRoles = (isset($_POST['ahcproExcludeRoles']) && is_array($_POST['ahcproExcludeRoles'])) ? ahc_free_sanitize_text_or_array_field($_POST['ahcproExcludeRoles']) : ''; // sanitize inside the loop
208
 
209
- if (isset($ahcproExcludeRoles)) {
210
  foreach ($ahcproExcludeRoles as $v) {
211
 
212
  $ahcproExcludeRoles_ .= $v . ",";
@@ -230,14 +285,19 @@ function ahcfree_savesettings()
230
  }
231
 
232
  ahcfree_update_tables();
233
-
234
- $sql = $wpdb->prepare(
235
- "UPDATE `ahc_settings` set `set_hits_days` = %s, `set_ajax_check` = %s, `set_ips` = %s, `set_google_map` = %s ",
236
- $set_hits_days,
237
- $set_ajax_check,
238
- $set_ips,
239
- $set_google_map
240
- );
 
 
 
 
 
241
 
242
  if ($wpdb->query($sql) !== false) {
243
 
@@ -322,7 +382,10 @@ function ahcfree_get_save_settings()
322
  global $wpdb;
323
  $table_exist = ahcfree_check_table_exists('ahc_settings');
324
  if ($table_exist) {
325
- $result = $wpdb->get_results("SELECT set_hits_days, set_ajax_check, set_ips, set_google_map FROM ahc_settings", OBJECT);
 
 
 
326
  if ($result !== false) {
327
  return $result;
328
  }
@@ -430,7 +493,7 @@ function ahcfree_last_hit_date()
430
  {
431
  global $wpdb;
432
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
433
- $sql = "SELECT max(CONVERT_TZ(vtr_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as last_date FROM ahc_recent_visitors";
434
  //echo $sql = "SELECT max(vtr_date)) as last_date FROM ahc_recent_visitors";
435
  $result = $wpdb->get_results($sql, OBJECT);
436
  if ($result !== false) {
@@ -439,22 +502,40 @@ function ahcfree_last_hit_date()
439
  return ahcfree_localtime('Y-m-d', time());
440
  }
441
 
442
- function ahcfree_getCountriesCount()
443
  {
 
 
 
444
  global $wpdb;
445
- $result = $wpdb->get_results("SELECT COUNT( `ctr_id` ) cnt FROM ahc_countries", OBJECT);
446
- if ($result !== false) {
447
- return $result[0]->cnt;
 
 
 
 
 
 
448
  }
449
  return false;
450
  }
451
 
452
- function ahcfree_getBrowsersCount()
453
  {
 
 
 
454
  global $wpdb;
455
- $result = $wpdb->get_results("SELECT COUNT( `bsr_id` ) cnt FROM ahc_browsers", OBJECT);
456
- if ($result !== false) {
457
- return $result[0]->cnt;
 
 
 
 
 
 
458
  }
459
  return false;
460
  }
@@ -473,8 +554,8 @@ function ahcfree_set_default_options()
473
  {
474
 
475
 
476
- if (is_multisite())
477
- die('<b style="color:red">Sorry, This plugin can\'t be activated networkwide :(</b>');
478
 
479
 
480
  // plugin activation
@@ -496,31 +577,57 @@ function ahcfree_set_default_options()
496
  set_time_limit(300);
497
  if (ahcfree_create_database_tables()) {
498
 
499
- if (ahcfree_getVisitsTime() > 25) {
500
- global $wpdb;
501
- $result = $wpdb->get_results("DELETE FROM ahc_visits_time where `vtm_id` > 24", OBJECT);
502
- }
503
-
504
- if (ahcfree_getCountriesCount() == 0) {
505
- ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng);
506
- }
 
 
 
 
 
507
 
508
- if (ahcfree_getVisitsTime() == 0) {
509
- ahcfree_insert_visit_times_into_table($dayHours);
 
 
 
 
 
 
 
 
510
  }
511
 
512
  if (ahcfree_getSearchEnginesCount() == 0) {
513
  ahcfree_insert_search_engines_into_table($searchEngines);
514
  }
515
 
516
- if (ahcfree_getBrowsersCount() == 0) {
517
- ahcfree_insert_browsers_into_table($browsers);
518
- }
519
  }
520
  }
521
 
522
 
523
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  //--------------------------------------------
525
  /**
526
  * Creates plugin page link in the admin menu
@@ -880,6 +987,7 @@ function ahcfree_add_settings()
880
  `set_ajax_check` int(10) unsigned NOT NULL DEFAULT '10',
881
  `set_ips` text DEFAULT NULL,
882
  `set_google_map` varchar(100) NOT NULL DEFAULT 'today_visitors',
 
883
 
884
  PRIMARY KEY (`set_id`)
885
  ) DEFAULT CHARSET=utf8";
@@ -887,14 +995,14 @@ function ahcfree_add_settings()
887
  $wpdb->query($sql_ahc_settings);
888
 
889
 
890
- $sql1 = "truncate table `ahc_settings`";
891
- $wpdb->query($sql1);
892
 
893
- $sql = "insert into `ahc_settings` (set_id, set_hits_days, set_ajax_check, set_ips, set_google_map) values (1, 14, 15, null, 'today_visitors')";
894
 
895
 
896
  if ($wpdb->query($sql) === false) {
897
- return false;
898
  }
899
  return true;
900
  }
@@ -1096,6 +1204,61 @@ function ahcfree_create_database_tables()
1096
  }
1097
  return true;
1098
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1099
 
1100
  //--------------------------------------------
1101
  /**
@@ -1107,7 +1270,7 @@ function ahcfree_create_database_tables()
1107
  * @param array $contriesLatLng. LatLng of countries
1108
  * @return boolean
1109
  */
1110
- function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng)
1111
  {
1112
  global $wpdb;
1113
  $c = 1;
@@ -1124,10 +1287,11 @@ function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLat
1124
  'ctr_name' => $countryName,
1125
  'ctr_internet_code' => $internetCode,
1126
  'ctr_latitude' => $ctr_latitude,
1127
- 'ctr_longitude' => $ctr_longitude
 
1128
  ),
1129
  array(
1130
- '%s', '%s', '%s', '%s'
1131
  )
1132
  );
1133
  if ($result === false) {
@@ -1165,19 +1329,43 @@ function ahcfree_insert_search_engines_into_table($searchEngines)
1165
  );
1166
  if ($result !== false) {
1167
  $srh_id = $wpdb->insert_id;
1168
- foreach ($se['crawlers'] as $crawler) {
1169
- $result2 = $wpdb->insert(
1170
- 'ahc_search_engine_crawlers',
1171
- array(
1172
- 'bot_name' => $crawler,
1173
- 'srh_id' => $srh_id
1174
- ),
1175
- array(
1176
- '%s', '%d'
1177
- )
1178
- );
1179
- if ($result2 === false) {
1180
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1181
  }
1182
  }
1183
  } else {
@@ -1196,7 +1384,7 @@ function ahcfree_insert_search_engines_into_table($searchEngines)
1196
  * @param array $browsers
1197
  * @return boolean
1198
  */
1199
- function ahcfree_insert_browsers_into_table($browsers)
1200
  {
1201
  global $wpdb;
1202
  foreach ($browsers as $browser) {
@@ -1205,10 +1393,11 @@ function ahcfree_insert_browsers_into_table($browsers)
1205
  array(
1206
  'bsr_id' => $browser['bsr_id'],
1207
  'bsr_name' => $browser['bsr_name'],
1208
- 'bsr_icon' => $browser['bsr_icon']
 
1209
  ),
1210
  array(
1211
- '%d', '%s', '%s'
1212
  )
1213
  );
1214
  if ($result === false) {
@@ -1227,7 +1416,7 @@ function ahcfree_insert_browsers_into_table($browsers)
1227
  * @param array $dayHours
1228
  * @return boolean
1229
  */
1230
- function ahcfree_insert_visit_times_into_table($dayHours)
1231
  {
1232
  global $wpdb;
1233
  foreach ($dayHours as $t) {
@@ -1236,10 +1425,11 @@ function ahcfree_insert_visit_times_into_table($dayHours)
1236
  array(
1237
  'vtm_time_from' => $t['vtm_time_from'],
1238
  'vtm_time_to' => $t['vtm_time_to'],
1239
- 'vtm_visitors' => 0
 
1240
  ),
1241
  array(
1242
- '%s', '%s', '%d'
1243
  )
1244
  );
1245
  if ($result === false) {
@@ -1352,7 +1542,7 @@ function ahcfree_get_visitors_visits_in_period($period = 'total')
1352
 
1353
  $sql = "SELECT SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits
1354
  FROM `ahc_visitors`
1355
- WHERE 1 = 1";
1356
  $results = false;
1357
  switch ($period) {
1358
  case 'today':
@@ -1451,7 +1641,7 @@ function ahcfree_get_visitors_visits_by_date()
1451
 
1452
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visitors, vst_visits
1453
  FROM ahc_visitors
1454
- WHERE DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1455
 
1456
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
1457
  if ($results !== false) {
@@ -1491,7 +1681,7 @@ function ahcfree_get_visitors_by_date()
1491
 
1492
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visitors
1493
  FROM ahc_visitors
1494
- WHERE DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1495
 
1496
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
1497
 
@@ -1523,7 +1713,7 @@ function ahcfree_get_visits_by_date()
1523
 
1524
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visits
1525
  FROM ahc_visitors
1526
- WHERE DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1527
 
1528
 
1529
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
@@ -1559,7 +1749,7 @@ function ahcfree_get_serch_visits_by_date()
1559
  global $wpdb;
1560
 
1561
  $response = array();
1562
- $sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.srh_id = ase.srh_id GROUP by asv.srh_id order by SUM(asv.vtsh_visits) DESC";
1563
 
1564
 
1565
  $results = $wpdb->get_results($sql, OBJECT);
@@ -1594,7 +1784,7 @@ function ahcfree_get_serch_visits_by_date()
1594
  function ahcfree_get_total_visits_by_search_engines()
1595
  {
1596
  global $wpdb;
1597
- $result = $wpdb->get_results("SELECT SUM(vtsh_visits) AS total FROM ahc_searching_visits", OBJECT);
1598
  if ($result !== false) {
1599
  return $result[0]->total;
1600
  }
@@ -1618,7 +1808,7 @@ function ahcfree_get_hits_search_engines_referers($period = 'total')
1618
  $custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
1619
  $date = new DateTime();
1620
  $date->setTimezone($custom_timezone);
1621
- $sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.srh_id = ase.srh_id ";
1622
  $results = false;
1623
  switch ($period) {
1624
  case 'today':
@@ -1710,7 +1900,7 @@ function ahcfree_get_browsers_hits_counts()
1710
  global $wpdb;
1711
  $sql = "SELECT `bsr_id`, `bsr_name`, `bsr_visits`
1712
  FROM `ahc_browsers`
1713
- WHERE `bsr_visits` > 0";
1714
  $results = $wpdb->get_results($sql, OBJECT);
1715
  $response = array();
1716
  if ($results !== false) {
@@ -1744,12 +1934,14 @@ function ahcfree_get_top_refering_sites($start = '', $limit = '')
1744
  if ($start != '' && $limit != '') {
1745
  $sql = "SELECT rfr_site_name, rfr_visits
1746
  FROM `ahc_refering_sites`
 
1747
  ORDER BY rfr_visits DESC LIMIT %d, %d ";
1748
 
1749
  $results = $wpdb->get_results($wpdb->prepare($sql, $start, $limit), OBJECT);
1750
  } else {
1751
  $sql = "SELECT rfr_site_name, rfr_visits
1752
  FROM `ahc_refering_sites`
 
1753
  ORDER BY rfr_visits DESC LIMIT 20 ";
1754
  $results = $wpdb->get_results($sql, OBJECT);
1755
  }
@@ -1788,7 +1980,7 @@ function ahcfree_get_top_countries($limit = 0, $start = '', $pagelimit = '', $al
1788
  }
1789
 
1790
  if ($cnt == true) {
1791
- $sql = "SELECT count(*) FROM `ahc_countries` WHERE ctr_visits > 0 ORDER BY ctr_visitors DESC";
1792
  $count = $wpdb->get_var($sql);
1793
  return $count;
1794
  }
@@ -1802,14 +1994,14 @@ function ahcfree_get_top_countries($limit = 0, $start = '', $pagelimit = '', $al
1802
 
1803
  if ($limit > 0 && $pagelimit == "") {
1804
  $sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
1805
- FROM `ahc_countries` WHERE ctr_visits > 0
1806
  ORDER BY ctr_visitors DESC
1807
  LIMIT %d OFFSET 0";
1808
 
1809
  $results = $wpdb->get_results($wpdb->prepare($sql, $limit), OBJECT);
1810
  } else {
1811
  $sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
1812
- FROM `ahc_countries` WHERE ctr_visits > 0
1813
  ORDER BY ctr_visitors DESC $limitCond";
1814
  $results = $wpdb->get_results($sql, OBJECT);
1815
  }
@@ -1891,7 +2083,7 @@ function ahcfree_get_vsitors_by_country($all, $cnt = true, $start = '', $limit =
1891
  if ($cnt == true) {
1892
  /*$sql = "select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id $cond group by ctr_name) as tot order by tot.total desc";
1893
  $results = $wpdb->get_results($sql, OBJECT);*/
1894
- $sql = $wpdb->prepare("select count(*) as cnt from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc", $cond);
1895
 
1896
  return $wpdb->get_var($sql);
1897
  }
@@ -1904,7 +2096,7 @@ function ahcfree_get_vsitors_by_country($all, $cnt = true, $start = '', $limit =
1904
  $limitCond = "";
1905
  }
1906
 
1907
- $sql = $wpdb->prepare("select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc %s", $cond, $limitCond);
1908
  $results = $wpdb->get_results($sql, OBJECT);
1909
  //echo $sql;
1910
  if ($results !== false) {
@@ -2028,7 +2220,7 @@ function ahcfree_get_recent_visitors($all, $cnt = true, $start = '', $limit = ''
2028
 
2029
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
2030
  if ($cnt == true) {
2031
- $sql_query = "SELECT count(*) from (Select DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as dt FROM `ahc_recent_visitors` AS v LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id WHERE 1=1 and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond ORDER BY v.vtr_id DESC) as res";
2032
  $count = $wpdb->get_var($sql_query);
2033
  return $count;
2034
  }
@@ -2047,7 +2239,7 @@ function ahcfree_get_recent_visitors($all, $cnt = true, $start = '', $limit = ''
2047
  FROM `ahc_recent_visitors` AS v
2048
  LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id
2049
  LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id
2050
- WHERE 1=1 and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond
2051
  ORDER BY v.vtr_id DESC $limitCond";
2052
 
2053
  $results = $wpdb->get_results($sql_query);
@@ -2147,7 +2339,7 @@ function ahcfree_get_latest_search_key_words_used($all, $cnt = true, $start = ''
2147
  }
2148
 
2149
  if ($cnt == true) {
2150
- $sql = "SELECT count(*) FROM `ahc_keywords` AS k LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id JOIN `ahc_browsers` AS b ON k.bsr_id = b.bsr_id JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id WHERE k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond1 ORDER BY k.kwd_date DESC, k.kwd_time DESC ";
2151
  $count = $wpdb->get_var($sql);
2152
  return $count;
2153
  }
@@ -2167,7 +2359,7 @@ function ahcfree_get_latest_search_key_words_used($all, $cnt = true, $start = ''
2167
  LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id
2168
  JOIN `ahc_browsers` AS b ON k.bsr_id = b.bsr_id
2169
  JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id
2170
- WHERE k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond
2171
  ORDER BY k.kwd_date DESC, k.kwd_time DESC $limitCond";
2172
  $results = $wpdb->get_results($sql, OBJECT);
2173
 
@@ -2281,7 +2473,7 @@ function ahcfree_get_today_visitors_for_map($map_status = '')
2281
  $whr = " and DATE(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '" . ahcfree_localtime("Y-m-d") . "'";
2282
  }
2283
 
2284
- $sql = "select count(vtr_id) as visitors, c.* from `ahc_recent_visitors` recent, `ahc_countries` c where recent.ctr_id = c.ctr_id
2285
  and c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 " . $whr . " GROUP by ctr_id";
2286
 
2287
 
@@ -2307,7 +2499,7 @@ function ahcfree_get_today_visitors_for_map($map_status = '')
2307
  function ahcfree_get_all_visitors_for_map()
2308
  {
2309
  global $wpdb;
2310
- $sql = "SELECT c.`ctr_visitors` as visitors, c.ctr_id, c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude from `ahc_countries` c where c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 group by `ctr_name` ORDER BY ctr_visitors desc LIMIT 10";
2311
 
2312
  $results = $wpdb->get_results($sql, OBJECT);
2313
  $response = array();
@@ -2344,12 +2536,12 @@ function ahcfree_get_online_visitors_for_map()
2344
  c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude FROM (
2345
  SELECT COUNT(v.visitor) AS visitors, v.ctr_id FROM (
2346
  SELECT ctr_id, 1 AS visitor FROM `ahc_hits`
2347
- WHERE ctr_id IS NOT NULL AND hit_ip_address NOT LIKE 'UNKNOWN%' and hit_date = DATE( CONVERT_TZ( '" . ahcfree_localtime("Y-m-d H:i:s") . "' ,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) and TIME( CONVERT_TZ(hit_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) between TIME(CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') - INTERVAL 60 SECOND) and TIME( CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') )
2348
  GROUP BY hit_ip_address
2349
  ) AS v
2350
  GROUP BY ctr_id) AS hits
2351
  JOIN `ahc_countries` AS c ON hits.ctr_id = c.ctr_id
2352
- WHERE c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 ";
2353
 
2354
  $results = $wpdb->get_results($sql, OBJECT);
2355
  $response = array();
@@ -2382,7 +2574,7 @@ function ahcfree_get_online_visitors_for_map()
2382
  function ahcfree_is_search_engine_bot()
2383
  {
2384
  global $wpdb, $_SERVER;
2385
- $results = $wpdb->get_results("SELECT `bot_name` FROM `ahc_search_engine_crawlers`", OBJECT);
2386
  foreach ($results as $crawler) {
2387
  if (stripos($_SERVER['HTTP_USER_AGENT'], $crawler->bot_name) !== false) {
2388
  return true;
@@ -2433,22 +2625,22 @@ function ahcfree_detect_requested_page($query)
2433
  global $wpdb;
2434
  $vars = $query->query_vars;
2435
  if (isset($vars['p']) && !empty($vars['p'])) {
2436
- $result = $wpdb->get_results($wpdb->prepare("SELECT post_title FROM " . $wpdb->prefix . "posts WHERE ID = %d ", $vars['p']));
2437
  if ($result !== false && $wpdb->num_rows > 0) {
2438
  return array('page_id' => $vars['p'], 'page_title' => $result[0]->post_title, 'post_type' => 'post');
2439
  }
2440
  } else if (isset($vars['name']) && !empty($vars['name'])) {
2441
- $result = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE post_name = %s ", $vars['name']));
2442
  if ($result !== false && $wpdb->num_rows > 0) {
2443
  return array('page_id' => $result[0]->ID, 'page_title' => $result[0]->post_title, 'post_type' => 'post');
2444
  }
2445
  } else if (isset($vars['pagename']) && !empty($vars['pagename'])) {
2446
- $result = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE post_name = %s AND post_type = %s", ahcfree_get_subpage_name($vars['pagename']), 'page'));
2447
  if ($result !== false && $wpdb->num_rows > 0) {
2448
  return array('page_id' => $result[0]->ID, 'page_title' => $result[0]->post_title, 'post_type' => 'page');
2449
  }
2450
  } else if (isset($vars['page_id']) && !empty($vars['page_id'])) {
2451
- $result = $wpdb->get_results($wpdb->prepare("SELECT post_title FROM " . $wpdb->prefix . "posts WHERE ID = %s AND post_type = %s", $vars['page_id'], 'page'));
2452
  if ($result !== false && $wpdb->num_rows > 0) {
2453
  return array('page_id' => $page_id, 'page_title' => $result[0]->post_title, 'post_type' => 'page');
2454
  }
@@ -2592,6 +2784,7 @@ function ahcfree_get_traffic_by_title($all, $cnt = false, $start = '0', $limit =
2592
  $sql1 = "SELECT SUM(hits) AS sm FROM (
2593
  SELECT SUM(til_hits) AS hits
2594
  FROM ahc_title_traffic
 
2595
  GROUP BY til_page_id
2596
  ) myTable";
2597
 
@@ -2603,7 +2796,7 @@ function ahcfree_get_traffic_by_title($all, $cnt = false, $start = '0', $limit =
2603
 
2604
  if ($cnt == true) {
2605
  $sql2 = "SELECT til_page_id, til_page_title, til_hits
2606
- FROM ahc_title_traffic where 1=1 $cond
2607
  GROUP BY til_page_id , til_page_title, til_hits
2608
  ORDER BY til_hits DESC limit %d, %d";
2609
 
@@ -2614,7 +2807,7 @@ function ahcfree_get_traffic_by_title($all, $cnt = false, $start = '0', $limit =
2614
  $limitCond = "";
2615
  if ($start != '' && $limit != '') {
2616
  $sql2 = "SELECT til_page_id, til_page_title, til_hits
2617
- FROM ahc_title_traffic where 1=1 $cond
2618
  GROUP BY til_page_id , til_page_title, til_hits
2619
  ORDER BY til_hits DESC limit %d, %d";
2620
  }
@@ -2692,11 +2885,11 @@ function ahcfree_get_time_visits($all, $start = '', $limit = '', $fdt = '', $tdt
2692
  $groupby = " hour($vst_date)";
2693
  }
2694
 
2695
- $sql1 = "SELECT SUM(vtm_visitors) AS sm FROM ahc_visits_time WHERE DATE($vst_date) = '" . ahcfree_localtime('Y-m-d') . "'";
2696
 
2697
 
2698
  $sql2 = "SELECT date(vst_date) as dt,hour($vst_date) AS hour, SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits FROM `ahc_visitors`
2699
- WHERE $cond GROUP BY $groupby";
2700
 
2701
  //echo $sql2;
2702
  //$result1 = $wpdb->get_results($sql1);
@@ -2917,6 +3110,9 @@ function ahcfree_include_scripts()
2917
  wp_enqueue_script('ahc_main_js');
2918
 
2919
  wp_localize_script('ahc_main_js', 'ahc_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
 
 
 
2920
  }
2921
 
2922
 
@@ -3092,13 +3288,13 @@ function ahcfree_get_visits_by_custom_duration_callback($start_date, $end_date,
3092
  $cond = "DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE('" . $start_date . " 00:00:00') AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE('" . $end_date . " 23:59:59')";
3093
 
3094
  if ($stat == 'year') {
3095
- $sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors WHERE " . $cond . " GROUP BY group_date";
3096
  }
3097
  if ($stat == 'all') {
3098
- $sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors GROUP BY group_date ORDER BY vst_date ASC";
3099
  }
3100
  if ($stat == '' || $stat == 'current_month' || $stat == 'last_month') {
3101
- $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, SUM(vst_visits) AS vst_visits,SUM(vst_visitors) as vst_visitors FROM ahc_visitors WHERE " . $cond . " GROUP BY DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
3102
  }
3103
  //echo $sql;
3104
  $results = $wpdb->get_results($sql, OBJECT);
1
  <?php
 
2
  add_shortcode( 'ahc_stats_widget', 'ahc_stats_widget_func');
3
  //[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]
4
 
52
 
53
  }
54
 
55
+
56
+ add_shortcode( 'ahc_today_visitors', 'ahc_today_visitors_func');
57
+
58
+ function ahc_today_visitors_func()
59
+ {
60
+
61
+ $ahc_sum_stats = ahcfree_get_visitors_visits_in_period('today');
62
+ return ahcfree_NumFormat(intval($ahc_sum_stats['visitors']));
63
+
64
+
65
+ }
66
+
67
+
68
+ add_shortcode( 'ahc_today_visits', 'ahc_today_visits_func');
69
+
70
+ function ahc_today_visits_func()
71
+ {
72
+
73
+ $ahc_sum_stats = ahcfree_get_visitors_visits_in_period('today');
74
+ return ahcfree_NumFormat(intval($ahc_sum_stats['visits']));
75
+
76
+
77
+ }
78
+
79
+ add_shortcode( 'ahc_total_visitors', 'ahc_total_visitors_func');
80
+
81
+ function ahc_total_visitors_func()
82
+ {
83
+
84
+ $ahc_sum_stats = ahcfree_get_visitors_visits_in_period('total');
85
+ return ahcfree_NumFormat(intval($ahc_sum_stats['visitors']));
86
+
87
+
88
+ }
89
+
90
+ add_shortcode( 'ahc_total_visits', 'ahc_total_visits_func');
91
+
92
+ function ahc_total_visits_func()
93
+ {
94
+
95
+ $ahc_sum_stats = ahcfree_get_visitors_visits_in_period('total');
96
+ return ahcfree_NumFormat(intval($ahc_sum_stats['visits']));
97
+
98
+
99
+ }
100
+
101
+
102
  function vtrts_free_top_bar_enqueue_style()
103
  {
104
 
203
  add_action( 'admin_print_scripts', 'vtrts_free_remove_dokan_js_files', 1 );
204
 
205
 
206
+ function ahcfree_getVisitsTime($site_id='')
207
  {
208
+ if($site_id == ''){
209
+ $site_id = get_current_blog_id();
210
+ }
211
  global $wpdb;
212
+ $table_exist = ahcfree_check_table_exists('ahc_visits_time');
213
+ if ($table_exist) {
214
+ if (!ahcfree_check_table_column_exists('ahc_visits_time', 'site_id')) {
215
+ ahcfree_multisite_init();
216
+ }
217
+ $result = $wpdb->get_results("SELECT COUNT( `vtm_id` ) cnt FROM ahc_visits_time where site_id =" . $site_id, OBJECT);
218
+ if ($result !== false) {
219
+ return $result[0]->cnt;
220
+ }
221
  }
222
  return false;
223
  }
261
 
262
  $ahcproExcludeRoles = (isset($_POST['ahcproExcludeRoles']) && is_array($_POST['ahcproExcludeRoles'])) ? ahc_free_sanitize_text_or_array_field($_POST['ahcproExcludeRoles']) : ''; // sanitize inside the loop
263
 
264
+ if (isset($ahcproExcludeRoles) && is_array($ahcproExcludeRoles)) {
265
  foreach ($ahcproExcludeRoles as $v) {
266
 
267
  $ahcproExcludeRoles_ .= $v . ",";
285
  }
286
 
287
  ahcfree_update_tables();
288
+ $post_id = $wpdb->get_results("SELECT `set_id` FROM `ahc_settings` WHERE `site_id` =".get_current_blog_id());
289
+ if(empty($post_id)){
290
+ $sql = $wpdb->prepare("INSERT INTO `ahc_settings` (`set_id`, `set_hits_days`, `set_ajax_check`, `set_ips`, `set_google_map`, `site_id`) VALUES (NULL, %s, %s, %s, %s ,%s); ", $set_hits_days, $set_ajax_check, $set_ips, $set_google_map,get_current_blog_id());
291
+ }else{
292
+ $sql = $wpdb->prepare(
293
+ "UPDATE `ahc_settings` set `set_hits_days` = %s, `set_ajax_check` = %s, `set_ips` = %s, `set_google_map` = %s where `site_id`= %d",
294
+ $set_hits_days,
295
+ $set_ajax_check,
296
+ $set_ips,
297
+ $set_google_map,
298
+ get_current_blog_id()
299
+ );
300
+ }
301
 
302
  if ($wpdb->query($sql) !== false) {
303
 
382
  global $wpdb;
383
  $table_exist = ahcfree_check_table_exists('ahc_settings');
384
  if ($table_exist) {
385
+ if(!ahcfree_check_table_column_exists('ahc_settings', 'site_id')){
386
+ ahcfree_multisite_init();
387
+ }
388
+ $result = $wpdb->get_results("SELECT set_hits_days, set_ajax_check, set_ips, set_google_map FROM ahc_settings where site_id=".get_current_blog_id(), OBJECT);
389
  if ($result !== false) {
390
  return $result;
391
  }
493
  {
494
  global $wpdb;
495
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
496
+ $sql = "SELECT max(CONVERT_TZ(vtr_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as last_date FROM ahc_recent_visitors where site_id =".get_current_blog_id();
497
  //echo $sql = "SELECT max(vtr_date)) as last_date FROM ahc_recent_visitors";
498
  $result = $wpdb->get_results($sql, OBJECT);
499
  if ($result !== false) {
502
  return ahcfree_localtime('Y-m-d', time());
503
  }
504
 
505
+ function ahcfree_getCountriesCount($site_id='')
506
  {
507
+ if($site_id == ''){
508
+ $site_id = get_current_blog_id();
509
+ }
510
  global $wpdb;
511
+ $table_exist = ahcfree_check_table_exists('ahc_countries');
512
+ if ($table_exist) {
513
+ if (!ahcfree_check_table_column_exists('ahc_countries', 'site_id')) {
514
+ ahcfree_multisite_init();
515
+ }
516
+ $result = $wpdb->get_results("SELECT COUNT( `ctr_id` ) cnt FROM ahc_countries where site_id = " . $site_id, OBJECT);
517
+ if ($result !== false) {
518
+ return isset($result[0]->cnt)?$result[0]->cnt:0;
519
+ }
520
  }
521
  return false;
522
  }
523
 
524
+ function ahcfree_getBrowsersCount($site_id='')
525
  {
526
+ if($site_id == ''){
527
+ $site_id = get_current_blog_id();
528
+ }
529
  global $wpdb;
530
+ $table_exist = ahcfree_check_table_exists('ahc_browsers');
531
+ if ($table_exist) {
532
+ if (!ahcfree_check_table_column_exists('ahc_browsers', 'site_id')) {
533
+ ahcfree_multisite_init();
534
+ }
535
+ $result = $wpdb->get_results("SELECT COUNT( `bsr_id` ) cnt FROM ahc_browsers where site_id = " . $site_id, OBJECT);
536
+ if ($result !== false) {
537
+ return $result[0]->cnt;
538
+ }
539
  }
540
  return false;
541
  }
554
  {
555
 
556
 
557
+ //if (is_multisite())
558
+ // die('<b style="color:red">Sorry, This plugin can\'t be activated networkwide :(</b>');
559
 
560
 
561
  // plugin activation
577
  set_time_limit(300);
578
  if (ahcfree_create_database_tables()) {
579
 
580
+ if(is_multisite()) {
581
+ $get_site_ids = get_sites();
582
+ foreach ($get_site_ids as $row) {
583
+ if (ahcfree_getCountriesCount($row->blog_id) == 0) {
584
+ ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng,$row->blog_id);
585
+ }
586
+ if (ahcfree_getVisitsTime($row->blog_id) == 0) {
587
+ ahcfree_insert_visit_times_into_table($dayHours,$row->blog_id);
588
+ }
589
+ if (ahcfree_getBrowsersCount($row->blog_id) == 0) {
590
+ ahcfree_insert_browsers_into_table($browsers,$row->blog_id);
591
+ }
592
+ }
593
 
594
+ }else{
595
+ if (ahcfree_getCountriesCount(1) == 0) {
596
+ ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng,1);
597
+ }
598
+ if (ahcfree_getVisitsTime(1) == 0) {
599
+ ahcfree_insert_visit_times_into_table($dayHours,1);
600
+ }
601
+ if (ahcfree_getBrowsersCount(1) == 0) {
602
+ ahcfree_insert_browsers_into_table($browsers,1);
603
+ }
604
  }
605
 
606
  if (ahcfree_getSearchEnginesCount() == 0) {
607
  ahcfree_insert_search_engines_into_table($searchEngines);
608
  }
609
 
610
+
 
 
611
  }
612
  }
613
 
614
 
615
+ if(is_multisite()){
616
+ add_action( 'wp_initialize_site', 'ahcfree_action_wp_initialize_site', 900 );
617
+ function ahcfree_action_wp_initialize_site( WP_Site $new_site ){
618
+ $site_id = $new_site->blog_id;
619
+ require_once("database_basics_data.php");
620
+ if (ahcfree_getCountriesCount($site_id) == 0) {
621
+ ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng,$site_id);
622
+ }
623
+ if (ahcfree_getVisitsTime($site_id) == 0) {
624
+ ahcfree_insert_visit_times_into_table($dayHours,$site_id);
625
+ }
626
+ if (ahcfree_getBrowsersCount($site_id) == 0) {
627
+ ahcfree_insert_browsers_into_table($browsers,$site_id);
628
+ }
629
+ }
630
+ }
631
  //--------------------------------------------
632
  /**
633
  * Creates plugin page link in the admin menu
987
  `set_ajax_check` int(10) unsigned NOT NULL DEFAULT '10',
988
  `set_ips` text DEFAULT NULL,
989
  `set_google_map` varchar(100) NOT NULL DEFAULT 'today_visitors',
990
+ `site_id` INT(11) NOT NULL DEFAULT '1',
991
 
992
  PRIMARY KEY (`set_id`)
993
  ) DEFAULT CHARSET=utf8";
995
  $wpdb->query($sql_ahc_settings);
996
 
997
 
998
+ // $sql1 = "truncate table `ahc_settings`";
999
+ // $wpdb->query($sql1);
1000
 
1001
+ $sql = "insert ignore into `ahc_settings` ( set_hits_days, set_ajax_check, set_ips, set_google_map,site_id) values (14, 15, null, 'today_visitors',".get_current_blog_id().")";
1002
 
1003
 
1004
  if ($wpdb->query($sql) === false) {
1005
+ //return false;
1006
  }
1007
  return true;
1008
  }
1204
  }
1205
  return true;
1206
  }
1207
+ function ahcfree_multisite_init(){
1208
+
1209
+ global $wpdb;
1210
+ $sqlQueries = array();
1211
+ if (ahcfree_check_table_exists('ahc_browsers') === true && !ahcfree_check_table_column_exists('ahc_browsers', 'site_id')) {
1212
+ $sqlQueries[] = "ALTER TABLE `ahc_browsers` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1213
+ }
1214
+ if (ahcfree_check_table_exists('ahc_countries') === true && !ahcfree_check_table_column_exists('ahc_countries', 'site_id')) {
1215
+ $sqlQueries[] = "ALTER TABLE `ahc_countries` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1216
+ }
1217
+ if (ahcfree_check_table_exists('ahc_daily_visitors_stats') === true && !ahcfree_check_table_column_exists('ahc_daily_visitors_stats', 'site_id')) {
1218
+ $sqlQueries[] = "ALTER TABLE `ahc_daily_visitors_stats` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1219
+ }
1220
+ if (ahcfree_check_table_exists('ahc_hits') === true && !ahcfree_check_table_column_exists('ahc_hits', 'site_id')) {
1221
+ $sqlQueries[] = "ALTER TABLE `ahc_hits` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1222
+ }
1223
+ if (ahcfree_check_table_exists('ahc_keywords') === true && !ahcfree_check_table_column_exists('ahc_keywords', 'site_id')) {
1224
+ $sqlQueries[] = "ALTER TABLE `ahc_keywords` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1225
+ }
1226
+ if (ahcfree_check_table_exists('ahc_online_users') === true && !ahcfree_check_table_column_exists('ahc_online_users', 'site_id')) {
1227
+ $sqlQueries[] = "ALTER TABLE `ahc_online_users` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1228
+ }
1229
+ if (ahcfree_check_table_exists('ahc_recent_visitors') === true && !ahcfree_check_table_column_exists('ahc_recent_visitors', 'site_id')) {
1230
+ $sqlQueries[] = "ALTER TABLE `ahc_recent_visitors` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1231
+ }
1232
+ if (ahcfree_check_table_exists('ahc_refering_sites') === true && !ahcfree_check_table_column_exists('ahc_refering_sites', 'site_id')) {
1233
+ $sqlQueries[] = "ALTER TABLE `ahc_refering_sites` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1234
+ }
1235
+ if (ahcfree_check_table_exists('ahc_searching_visits') === true && !ahcfree_check_table_column_exists('ahc_searching_visits', 'site_id')) {
1236
+ $sqlQueries[] = "ALTER TABLE `ahc_searching_visits` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1237
+ }
1238
+ if (ahcfree_check_table_exists('ahc_search_engine_crawlers') === true && !ahcfree_check_table_column_exists('ahc_search_engine_crawlers', 'site_id')) {
1239
+ $sqlQueries[] = "ALTER TABLE `ahc_search_engine_crawlers` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1240
+ }
1241
+ if (ahcfree_check_table_exists('ahc_settings') === true && !ahcfree_check_table_column_exists('ahc_settings', 'site_id')) {
1242
+ $sqlQueries[] = "ALTER TABLE `ahc_settings` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1243
+ }
1244
+ if (ahcfree_check_table_exists('ahc_title_traffic') === true && !ahcfree_check_table_column_exists('ahc_title_traffic', 'site_id')) {
1245
+ $sqlQueries[] = "ALTER TABLE `ahc_title_traffic` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1246
+ }
1247
+ if (ahcfree_check_table_exists('ahc_visitors') === true && !ahcfree_check_table_column_exists('ahc_visitors', 'site_id')) {
1248
+ $sqlQueries[] = "ALTER TABLE `ahc_visitors` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1249
+ }
1250
+ if (ahcfree_check_table_exists('ahc_visits_time') === true && !ahcfree_check_table_column_exists('ahc_visits_time', 'site_id')) {
1251
+ $sqlQueries[] = "ALTER TABLE `ahc_visits_time` ADD `site_id` INT(11) NOT NULL DEFAULT '1';";
1252
+ }
1253
+ $sqlQueries[] = "ALTER TABLE `ahc_settings` CHANGE `set_id` `set_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT";
1254
+
1255
+ $sqlQueries[] = "ALTER TABLE `ahc_browsers` CHANGE `bsr_id` `bsr_id` INT(3) UNSIGNED NOT NULL AUTO_INCREMENT";
1256
+ if (count($sqlQueries)) {
1257
+ foreach ($sqlQueries as $sql) {
1258
+ $wpdb->query($sql);
1259
+ }
1260
+ }
1261
+ }
1262
 
1263
  //--------------------------------------------
1264
  /**
1270
  * @param array $contriesLatLng. LatLng of countries
1271
  * @return boolean
1272
  */
1273
+ function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng,$site_id=1)
1274
  {
1275
  global $wpdb;
1276
  $c = 1;
1287
  'ctr_name' => $countryName,
1288
  'ctr_internet_code' => $internetCode,
1289
  'ctr_latitude' => $ctr_latitude,
1290
+ 'ctr_longitude' => $ctr_longitude,
1291
+ 'site_id' => $site_id
1292
  ),
1293
  array(
1294
+ '%s', '%s', '%s', '%s', '%d'
1295
  )
1296
  );
1297
  if ($result === false) {
1329
  );
1330
  if ($result !== false) {
1331
  $srh_id = $wpdb->insert_id;
1332
+ if(is_multisite()) {
1333
+ $get_site_ids = get_sites();
1334
+ foreach ($get_site_ids as $row) {
1335
+
1336
+ foreach ($se['crawlers'] as $crawler) {
1337
+ $result2 = $wpdb->insert(
1338
+ 'ahc_search_engine_crawlers',
1339
+ array(
1340
+ 'bot_name' => $crawler,
1341
+ 'srh_id' => $srh_id,
1342
+ 'site_id' => $row->blog_id
1343
+ ),
1344
+ array(
1345
+ '%s', '%d', '%d'
1346
+ )
1347
+ );
1348
+ if ($result2 === false) {
1349
+ return false;
1350
+ }
1351
+ }
1352
+ }
1353
+ }else{
1354
+ foreach ($se['crawlers'] as $crawler) {
1355
+ $result2 = $wpdb->insert(
1356
+ 'ahc_search_engine_crawlers',
1357
+ array(
1358
+ 'bot_name' => $crawler,
1359
+ 'srh_id' => $srh_id,
1360
+ 'site_id' => 1
1361
+ ),
1362
+ array(
1363
+ '%s', '%d', '%d'
1364
+ )
1365
+ );
1366
+ if ($result2 === false) {
1367
+ return false;
1368
+ }
1369
  }
1370
  }
1371
  } else {
1384
  * @param array $browsers
1385
  * @return boolean
1386
  */
1387
+ function ahcfree_insert_browsers_into_table($browsers,$site_id=1)
1388
  {
1389
  global $wpdb;
1390
  foreach ($browsers as $browser) {
1393
  array(
1394
  'bsr_id' => $browser['bsr_id'],
1395
  'bsr_name' => $browser['bsr_name'],
1396
+ 'bsr_icon' => $browser['bsr_icon'],
1397
+ 'site_id' => $site_id
1398
  ),
1399
  array(
1400
+ '%d', '%s', '%s', '%d'
1401
  )
1402
  );
1403
  if ($result === false) {
1416
  * @param array $dayHours
1417
  * @return boolean
1418
  */
1419
+ function ahcfree_insert_visit_times_into_table($dayHours,$site_id = 1)
1420
  {
1421
  global $wpdb;
1422
  foreach ($dayHours as $t) {
1425
  array(
1426
  'vtm_time_from' => $t['vtm_time_from'],
1427
  'vtm_time_to' => $t['vtm_time_to'],
1428
+ 'vtm_visitors' => 0,
1429
+ 'site_id' => $site_id
1430
  ),
1431
  array(
1432
+ '%s', '%s', '%d', '%d'
1433
  )
1434
  );
1435
  if ($result === false) {
1542
 
1543
  $sql = "SELECT SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits
1544
  FROM `ahc_visitors`
1545
+ WHERE site_id = ".get_current_blog_id();
1546
  $results = false;
1547
  switch ($period) {
1548
  case 'today':
1641
 
1642
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visitors, vst_visits
1643
  FROM ahc_visitors
1644
+ WHERE site_id = ".get_current_blog_id()." and DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1645
 
1646
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
1647
  if ($results !== false) {
1681
 
1682
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visitors
1683
  FROM ahc_visitors
1684
+ WHERE site_id = ".get_current_blog_id()." and DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1685
 
1686
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
1687
 
1713
 
1714
  $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, vst_visits
1715
  FROM ahc_visitors
1716
+ WHERE site_id = ".get_current_blog_id()." and DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
1717
 
1718
 
1719
  $results = $wpdb->get_results($wpdb->prepare($sql, $beginning->format('Y-m-d')), OBJECT);
1749
  global $wpdb;
1750
 
1751
  $response = array();
1752
+ $sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.site_id = ".get_current_blog_id()." and asv.srh_id = ase.srh_id GROUP by asv.srh_id order by SUM(asv.vtsh_visits) DESC";
1753
 
1754
 
1755
  $results = $wpdb->get_results($sql, OBJECT);
1784
  function ahcfree_get_total_visits_by_search_engines()
1785
  {
1786
  global $wpdb;
1787
+ $result = $wpdb->get_results("SELECT SUM(vtsh_visits) AS total FROM ahc_searching_visits where site_id = ".get_current_blog_id(), OBJECT);
1788
  if ($result !== false) {
1789
  return $result[0]->total;
1790
  }
1808
  $custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
1809
  $date = new DateTime();
1810
  $date->setTimezone($custom_timezone);
1811
+ $sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.site_id = ".get_current_blog_id()." and asv.srh_id = ase.srh_id ";
1812
  $results = false;
1813
  switch ($period) {
1814
  case 'today':
1900
  global $wpdb;
1901
  $sql = "SELECT `bsr_id`, `bsr_name`, `bsr_visits`
1902
  FROM `ahc_browsers`
1903
+ WHERE site_id = ".get_current_blog_id()." and `bsr_visits` > 0";
1904
  $results = $wpdb->get_results($sql, OBJECT);
1905
  $response = array();
1906
  if ($results !== false) {
1934
  if ($start != '' && $limit != '') {
1935
  $sql = "SELECT rfr_site_name, rfr_visits
1936
  FROM `ahc_refering_sites`
1937
+ where site_id = ".get_current_blog_id()."
1938
  ORDER BY rfr_visits DESC LIMIT %d, %d ";
1939
 
1940
  $results = $wpdb->get_results($wpdb->prepare($sql, $start, $limit), OBJECT);
1941
  } else {
1942
  $sql = "SELECT rfr_site_name, rfr_visits
1943
  FROM `ahc_refering_sites`
1944
+ where site_id = ".get_current_blog_id()."
1945
  ORDER BY rfr_visits DESC LIMIT 20 ";
1946
  $results = $wpdb->get_results($sql, OBJECT);
1947
  }
1980
  }
1981
 
1982
  if ($cnt == true) {
1983
+ $sql = "SELECT count(*) FROM `ahc_countries` WHERE site_id = ".get_current_blog_id()." and ctr_visits > 0 ORDER BY ctr_visitors DESC";
1984
  $count = $wpdb->get_var($sql);
1985
  return $count;
1986
  }
1994
 
1995
  if ($limit > 0 && $pagelimit == "") {
1996
  $sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
1997
+ FROM `ahc_countries` WHERE site_id = ".get_current_blog_id()." and ctr_visits > 0
1998
  ORDER BY ctr_visitors DESC
1999
  LIMIT %d OFFSET 0";
2000
 
2001
  $results = $wpdb->get_results($wpdb->prepare($sql, $limit), OBJECT);
2002
  } else {
2003
  $sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
2004
+ FROM `ahc_countries` WHERE site_id = ".get_current_blog_id()." and ctr_visits > 0
2005
  ORDER BY ctr_visitors DESC $limitCond";
2006
  $results = $wpdb->get_results($sql, OBJECT);
2007
  }
2083
  if ($cnt == true) {
2084
  /*$sql = "select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id $cond group by ctr_name) as tot order by tot.total desc";
2085
  $results = $wpdb->get_results($sql, OBJECT);*/
2086
+ $sql = $wpdb->prepare("select count(*) as cnt from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.site_id = ".get_current_blog_id()." and v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc", $cond);
2087
 
2088
  return $wpdb->get_var($sql);
2089
  }
2096
  $limitCond = "";
2097
  }
2098
 
2099
+ $sql = $wpdb->prepare("select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.site_id = ".get_current_blog_id()." and v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc %s", $cond, $limitCond);
2100
  $results = $wpdb->get_results($sql, OBJECT);
2101
  //echo $sql;
2102
  if ($results !== false) {
2220
 
2221
  $custom_timezone_offset = ahcfree_get_current_timezone_offset();
2222
  if ($cnt == true) {
2223
+ $sql_query = "SELECT count(*) from (Select DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as dt FROM `ahc_recent_visitors` AS v LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id WHERE v.site_id = ".get_current_blog_id()." and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond ORDER BY v.vtr_id DESC) as res";
2224
  $count = $wpdb->get_var($sql_query);
2225
  return $count;
2226
  }
2239
  FROM `ahc_recent_visitors` AS v
2240
  LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id
2241
  LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id
2242
+ WHERE v.site_id = ".get_current_blog_id()." and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond
2243
  ORDER BY v.vtr_id DESC $limitCond";
2244
 
2245
  $results = $wpdb->get_results($sql_query);
2339
  }
2340
 
2341
  if ($cnt == true) {
2342
+ $sql = "SELECT count(*) FROM `ahc_keywords` AS k LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id JOIN `ahc_browsers` AS b ON k.bsr_id = b.bsr_id JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id WHERE k.site_id = ".get_current_blog_id()." and k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond1 ORDER BY k.kwd_date DESC, k.kwd_time DESC ";
2343
  $count = $wpdb->get_var($sql);
2344
  return $count;
2345
  }
2359
  LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id
2360
  JOIN `ahc_browsers` AS b ON k.bsr_id = b.bsr_id
2361
  JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id
2362
+ WHERE k.site_id = ".get_current_blog_id()." and k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond
2363
  ORDER BY k.kwd_date DESC, k.kwd_time DESC $limitCond";
2364
  $results = $wpdb->get_results($sql, OBJECT);
2365
 
2473
  $whr = " and DATE(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '" . ahcfree_localtime("Y-m-d") . "'";
2474
  }
2475
 
2476
+ $sql = "select count(vtr_id) as visitors, c.* from `ahc_recent_visitors` recent, `ahc_countries` c where recent.site_id = ".get_current_blog_id()." and recent.ctr_id = c.ctr_id
2477
  and c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 " . $whr . " GROUP by ctr_id";
2478
 
2479
 
2499
  function ahcfree_get_all_visitors_for_map()
2500
  {
2501
  global $wpdb;
2502
+ $sql = "SELECT c.`ctr_visitors` as visitors, c.ctr_id, c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude from `ahc_countries` c where c.site_id = ".get_current_blog_id()." and c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 group by `ctr_name` ORDER BY ctr_visitors desc LIMIT 10";
2503
 
2504
  $results = $wpdb->get_results($sql, OBJECT);
2505
  $response = array();
2536
  c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude FROM (
2537
  SELECT COUNT(v.visitor) AS visitors, v.ctr_id FROM (
2538
  SELECT ctr_id, 1 AS visitor FROM `ahc_hits`
2539
+ WHERE site_id = ".get_current_blog_id()." and ctr_id IS NOT NULL AND hit_ip_address NOT LIKE 'UNKNOWN%' and hit_date = DATE( CONVERT_TZ( '" . ahcfree_localtime("Y-m-d H:i:s") . "' ,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) and TIME( CONVERT_TZ(hit_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) between TIME(CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') - INTERVAL 60 SECOND) and TIME( CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') )
2540
  GROUP BY hit_ip_address
2541
  ) AS v
2542
  GROUP BY ctr_id) AS hits
2543
  JOIN `ahc_countries` AS c ON hits.ctr_id = c.ctr_id
2544
+ WHERE c.site_id = ".get_current_blog_id()." and c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 ";
2545
 
2546
  $results = $wpdb->get_results($sql, OBJECT);
2547
  $response = array();
2574
  function ahcfree_is_search_engine_bot()
2575
  {
2576
  global $wpdb, $_SERVER;
2577
+ $results = $wpdb->get_results("SELECT `bot_name` FROM `ahc_search_engine_crawlers` where site_id = ".get_current_blog_id(), OBJECT);
2578
  foreach ($results as $crawler) {
2579
  if (stripos($_SERVER['HTTP_USER_AGENT'], $crawler->bot_name) !== false) {
2580
  return true;
2625
  global $wpdb;
2626
  $vars = $query->query_vars;
2627
  if (isset($vars['p']) && !empty($vars['p'])) {
2628
+ $result = $wpdb->get_results($wpdb->prepare("SELECT post_title FROM " . $wpdb->prefix . "posts WHERE site_id = %d and ID = %d ", get_current_blog_id(),$vars['p']));
2629
  if ($result !== false && $wpdb->num_rows > 0) {
2630
  return array('page_id' => $vars['p'], 'page_title' => $result[0]->post_title, 'post_type' => 'post');
2631
  }
2632
  } else if (isset($vars['name']) && !empty($vars['name'])) {
2633
+ $result = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE site_id = %d and post_name = %s ", get_current_blog_id(),$vars['name']));
2634
  if ($result !== false && $wpdb->num_rows > 0) {
2635
  return array('page_id' => $result[0]->ID, 'page_title' => $result[0]->post_title, 'post_type' => 'post');
2636
  }
2637
  } else if (isset($vars['pagename']) && !empty($vars['pagename'])) {
2638
+ $result = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM " . $wpdb->prefix . "posts WHERE site_id = %d and post_name = %s AND post_type = %s", get_current_blog_id(),ahcfree_get_subpage_name($vars['pagename']), 'page'));
2639
  if ($result !== false && $wpdb->num_rows > 0) {
2640
  return array('page_id' => $result[0]->ID, 'page_title' => $result[0]->post_title, 'post_type' => 'page');
2641
  }
2642
  } else if (isset($vars['page_id']) && !empty($vars['page_id'])) {
2643
+ $result = $wpdb->get_results($wpdb->prepare("SELECT post_title FROM " . $wpdb->prefix . "posts WHERE site_id = %d and ID = %s AND post_type = %s", get_current_blog_id(),$vars['page_id'], 'page'));
2644
  if ($result !== false && $wpdb->num_rows > 0) {
2645
  return array('page_id' => $page_id, 'page_title' => $result[0]->post_title, 'post_type' => 'page');
2646
  }
2784
  $sql1 = "SELECT SUM(hits) AS sm FROM (
2785
  SELECT SUM(til_hits) AS hits
2786
  FROM ahc_title_traffic
2787
+ where site_id =".get_current_blog_id()."
2788
  GROUP BY til_page_id
2789
  ) myTable";
2790
 
2796
 
2797
  if ($cnt == true) {
2798
  $sql2 = "SELECT til_page_id, til_page_title, til_hits
2799
+ FROM ahc_title_traffic where site_id =".get_current_blog_id()." $cond
2800
  GROUP BY til_page_id , til_page_title, til_hits
2801
  ORDER BY til_hits DESC limit %d, %d";
2802
 
2807
  $limitCond = "";
2808
  if ($start != '' && $limit != '') {
2809
  $sql2 = "SELECT til_page_id, til_page_title, til_hits
2810
+ FROM ahc_title_traffic where site_id =".get_current_blog_id()." $cond
2811
  GROUP BY til_page_id , til_page_title, til_hits
2812
  ORDER BY til_hits DESC limit %d, %d";
2813
  }
2885
  $groupby = " hour($vst_date)";
2886
  }
2887
 
2888
+ $sql1 = "SELECT SUM(vtm_visitors) AS sm FROM ahc_visits_time WHERE site_id = ".get_current_blog_id()." and DATE($vst_date) = '" . ahcfree_localtime('Y-m-d') . "'";
2889
 
2890
 
2891
  $sql2 = "SELECT date(vst_date) as dt,hour($vst_date) AS hour, SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits FROM `ahc_visitors`
2892
+ WHERE site_id = ".get_current_blog_id()." and $cond GROUP BY $groupby";
2893
 
2894
  //echo $sql2;
2895
  //$result1 = $wpdb->get_results($sql1);
3110
  wp_enqueue_script('ahc_main_js');
3111
 
3112
  wp_localize_script('ahc_main_js', 'ahc_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
3113
+
3114
+ wp_enqueue_script('sweetalert', plugins_url('/js/sweetalert.min.js', AHCFREE_PLUGIN_MAIN_FILE));
3115
+ wp_enqueue_style( 'sweetalert', plugins_url('/css/sweetalerts.css', AHCFREE_PLUGIN_MAIN_FILE));
3116
  }
3117
 
3118
 
3288
  $cond = "DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE('" . $start_date . " 00:00:00') AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE('" . $end_date . " 23:59:59')";
3289
 
3290
  if ($stat == 'year') {
3291
+ $sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors WHERE ahc_visitors.site_id = ".get_current_blog_id()." and " . $cond . " GROUP BY group_date";
3292
  }
3293
  if ($stat == 'all') {
3294
+ $sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors where ahc_visitors.site_id = ".get_current_blog_id()." GROUP BY group_date ORDER BY vst_date ASC";
3295
  }
3296
  if ($stat == '' || $stat == 'current_month' || $stat == 'last_month') {
3297
+ $sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, SUM(vst_visits) AS vst_visits,SUM(vst_visitors) as vst_visitors FROM ahc_visitors WHERE ahc_visitors.site_id = ".get_current_blog_id()." and " . $cond . " GROUP BY DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
3298
  }
3299
  //echo $sql;
3300
  $results = $wpdb->get_results($sql, OBJECT);
init.php CHANGED
@@ -48,7 +48,7 @@ $set_google_map = $ahcfree_get_save_settings[0]->set_google_map;
48
  }else{
49
 
50
  $hits_days = 30;
51
- $ajax_check = 10;
52
  $set_ips = '';
53
  $set_google_map = 'today_visitors';
54
  }
48
  }else{
49
 
50
  $hits_days = 30;
51
+ $ajax_check = 10000;
52
  $set_ips = '';
53
  $set_google_map = 'today_visitors';
54
  }
overview.php CHANGED
@@ -83,7 +83,7 @@ $mystart_date = $mystart_date->format('Y-m-d');
83
  <div class="row">
84
  <div class="col-lg-12">
85
  <br />
86
- <div id="vtrts_subscribe" class="alert alert-success is-dismissible alert alert-info is-dismissible" role="alert" style="font-size:12px">
87
 
88
  <input type="text" width="400px" name="ahc_admin_email" id="ahc_admin_email" value="<?php echo get_bloginfo("admin_email"); ?>">
89
  <button type="button" class="btn btn-primary" onclick="vtrts_open_subscribe_page('<?php echo get_bloginfo("admin_email") ?>')">Subscribe</button><br /><br />Subscribe now to get latest news and updates, plugin recommendations and configuration help, promotional email with<b style="color:red"> discount codes :) </b><br />
@@ -895,7 +895,70 @@ $mystart_date = $mystart_date->format('Y-m-d');
895
  if (typeof drawSrhEngVstLineChart === "function") {
896
  drawSrhEngVstLineChart();
897
  }
898
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
 
900
  });
901
 
83
  <div class="row">
84
  <div class="col-lg-12">
85
  <br />
86
+ <div id="vtrts_subscribe" class="alert alert-success is-dismissible alert is-dismissible" role="alert" style="font-size:12px">
87
 
88
  <input type="text" width="400px" name="ahc_admin_email" id="ahc_admin_email" value="<?php echo get_bloginfo("admin_email"); ?>">
89
  <button type="button" class="btn btn-primary" onclick="vtrts_open_subscribe_page('<?php echo get_bloginfo("admin_email") ?>')">Subscribe</button><br /><br />Subscribe now to get latest news and updates, plugin recommendations and configuration help, promotional email with<b style="color:red"> discount codes :) </b><br />
895
  if (typeof drawSrhEngVstLineChart === "function") {
896
  drawSrhEngVstLineChart();
897
  }
898
+
899
+
900
+
901
+
902
+
903
+ jQuery(document).on('click', '.SwalBtn1', function() {
904
+ swal.clickConfirm();
905
+ });
906
+ jQuery(document).on('click', '.SwalBtn2', function() {
907
+ window.open(
908
+ "https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?popup=1",
909
+ '_blank'
910
+ );
911
+
912
+ swal.clickConfirm();
913
+ });
914
+ jQuery(document).on('click', '.SwalBtn3', function() {
915
+ localStorage.setItem("ahcfreemsg", "1");
916
+ swal.clickConfirm();
917
+ });
918
+
919
+ var save_method; //for save method string
920
+ var host=window.location.hostname;
921
+ var fullpath=window.location.pathname;
922
+ var fullparam=window.location.search.split('&');
923
+
924
+ var firstparam=fullparam[0];
925
+
926
+ if(localStorage && (firstparam=="?page=ahc_hits_counter_menu_free"))
927
+ {
928
+
929
+ var today_visitors_box = document.getElementById('today_visitors_box').innerHTML;
930
+ if (!localStorage.getItem("ahcfreemsg")==true)
931
+ {
932
+ if(today_visitors_box > 5)
933
+ {
934
+ setTimeout(function(){
935
+
936
+ swal({
937
+ title: '',
938
+ text: '',
939
+ imageUrl: 'https://www.wp-buy.com/wp-content/uploads/2018/10/output_ZD6GUg-1-2.gif',
940
+ imageWidth: 'auto',
941
+ imageHeight: 'auto',
942
+ imageAlt: 'Need more statistics, GEO locations & online counter?',
943
+ animation: true,
944
+ customClass: 'swal-noscroll',
945
+ allowEscapeKey:true,
946
+ showCancelButton: false,
947
+ showConfirmButton: false,
948
+ html: 'Need more statistics, GEO locations & online counter?<br><br><center><button type="button" role="button" class="confirm btn btn-success SwalBtn2">' + 'Upgrade to pro' + '</button>&nbsp;&nbsp;' +
949
+ '<button type="button" role="button" class="cancel btn btn-info SwalBtn1">' + 'Close' + '</button>&nbsp;&nbsp;'+
950
+ '<button type="button" role="button" class="confirm btn btn-warning SwalBtn3">' + "Dismiss" + '</button></center>'
951
+ });
952
+ }, 5000);
953
+ }
954
+
955
+
956
+ }
957
+
958
+
959
+
960
+
961
+ }
962
 
963
  });
964
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wp-buy, osamaesh
3
  Tags: visitor, traffic, statistics, analytics, stats, online, Visit, WordPress analytics ,visitors online, count visitor, google analytics, analytics, GeoIP, Geo locations, analytics dashboard, visits, chart, browser, blog, today, yesterday, week, month, wp Statistics, year, post, page, sidebar, summary, feedburner, hits, pagerank, google, histats, alexa, live visit, counter, diagram, graph
4
  Requires at least: 3.0.1
5
  Tested up to: 5.9.2
6
- Stable tag: 5.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -18,15 +18,15 @@ This plugin will help you to track your visitors, browsers, operating systems, v
18
 
19
  And you can use one the summary statistics shortcodes:
20
 
 
 
21
  * **[ahc_stats_widget]** adds a front-end widget to display the site statistics
22
  * **[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]** adds a front-end widget to display the site statistics with custom parametrs
23
- * **title** The widget title, keep it empty to display the widget without a title
24
- * **fontsize** the widget font size, default is 14 (in px)
25
- * **fonttype** the widget font type, default is empty (the theme font type will be applied
26
- * **display_today_visitors** true or false (Display today's visitors count, default is true
27
- * **display_today_pageviwes** true or false (Display today's page views (visits) count, default is true
28
- * **display_total_visitors** true or false (Display total visitors count, default is true
29
- * **display_total_pageviwes** true or false (Display total visits count, default is true
30
 
31
 
32
  <strong>Visitor Traffic Real Time Statistics Basic version includes: </strong>
@@ -118,14 +118,11 @@ You can use one of the following shortcodes:
118
 
119
  * **[ahc_stats_widget]** adds a front-end widget to display the site statistics
120
  * **[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]** adds a front-end widget to display the site statistics with custom parametrs
121
- * **title** The widget title, keep it empty to display the widget without a title
122
- * **fontsize** the widget font size, default is 14 (in px)
123
- * **fonttype** the widget font type, default is empty (the theme font type will be applied
124
- * **display_today_visitors** true or false (Display today's visitors count, default is true
125
- * **display_today_pageviwes** true or false (Display today's page views (visits) count, default is true
126
- * **display_total_visitors** true or false (Display total visitors count, default is true
127
- * **display_total_pageviwes** true or false (Display total visits count, default is true
128
 
 
 
 
 
129
 
130
 
131
  = GDPR Compliant? =
@@ -178,6 +175,19 @@ This plugin supports IPv6; however, PHP must be compiled with IPv6 support enabl
178
 
179
  == Changelog ==
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  = 5.5 =
182
  1. new feature (Shortcode instead of widget)
183
  2. [ahc_stats_widget] Please read the plugin description for more details
3
  Tags: visitor, traffic, statistics, analytics, stats, online, Visit, WordPress analytics ,visitors online, count visitor, google analytics, analytics, GeoIP, Geo locations, analytics dashboard, visits, chart, browser, blog, today, yesterday, week, month, wp Statistics, year, post, page, sidebar, summary, feedburner, hits, pagerank, google, histats, alexa, live visit, counter, diagram, graph
4
  Requires at least: 3.0.1
5
  Tested up to: 5.9.2
6
+ Stable tag: 5.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
18
 
19
  And you can use one the summary statistics shortcodes:
20
 
21
+ You can use one of the following shortcodes:
22
+
23
  * **[ahc_stats_widget]** adds a front-end widget to display the site statistics
24
  * **[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]** adds a front-end widget to display the site statistics with custom parametrs
25
+
26
+ * **[ahc_today_visitors]** this will return today's visitors
27
+ * **[ahc_today_visits]** this will return today's visits
28
+ * **[ahc_total_visitors]** this will return total visitors
29
+ * **[ahc_total_visits]** this will return total visits
 
 
30
 
31
 
32
  <strong>Visitor Traffic Real Time Statistics Basic version includes: </strong>
118
 
119
  * **[ahc_stats_widget]** adds a front-end widget to display the site statistics
120
  * **[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]** adds a front-end widget to display the site statistics with custom parametrs
 
 
 
 
 
 
 
121
 
122
+ * **[ahc_today_visitors]** this will return today's visitors
123
+ * **[ahc_today_visits]** this will return today's visits
124
+ * **[ahc_total_visitors]** this will return total visitors
125
+ * **[ahc_total_visits]** this will return total visits
126
 
127
 
128
  = GDPR Compliant? =
175
 
176
  == Changelog ==
177
 
178
+ = 5.6 =
179
+ 1. Shortcode improvements
180
+
181
+ You can use one of the following shortcodes:
182
+
183
+ * **[ahc_stats_widget]** adds a front-end widget to display the site statistics
184
+ * **[ahc_stats_widget title="" fontsize="16" fonttype="" display_today_visitors=true display_today_pageviwes=true display_total_visitors=true display_total_pageviwes=true ]** adds a front-end widget to display the site statistics with custom parametrs
185
+
186
+ * **[ahc_today_visitors]** this will return today's visitors
187
+ * **[ahc_today_visits]** this will return today's visits
188
+ * **[ahc_total_visitors]** this will return total visitors
189
+ * **[ahc_total_visits]** this will return total visits
190
+
191
  = 5.5 =
192
  1. new feature (Shortcode instead of widget)
193
  2. [ahc_stats_widget] Please read the plugin description for more details