WP Statistics - Version 9.6.6

Version Description

Security update release, please update Immediately. Have you updated your database indexes and search table? If not please go to Statistics->Optimization->Database after you have installed the update and run the updates.

Download this release

Release Info

Developer GregRoss
Plugin Icon 128x128 WP Statistics
Version 9.6.6
Comparing to
See all releases

Code changes from version 9.6.5 to 9.6.6

ajax.php CHANGED
@@ -59,7 +59,7 @@ function wp_statistics_delete_platforms_action_callback() {
59
  $result = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform));
60
 
61
  if($result) {
62
- echo sprintf(__('%s platform data deleted successfully.', 'wp_statistics'), '<code>' . $platform . '</code>');
63
  }
64
  else {
65
  _e('No platform data found to remove!', 'wp_statistics');
59
  $result = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform));
60
 
61
  if($result) {
62
+ echo sprintf(__('%s platform data deleted successfully.', 'wp_statistics'), '<code>' . htmlentities( $platform, ENT_QUOTES ) . '</code>');
63
  }
64
  else {
65
  _e('No platform data found to remove!', 'wp_statistics');
includes/classes/statistics.class.php CHANGED
@@ -10,7 +10,7 @@
10
  // Setup our protected, private and public variables.
11
  protected $db;
12
  protected $tb_prefix;
13
- protected $ip;
14
  protected $ip_hash = false;
15
  protected $agent;
16
 
@@ -36,6 +36,8 @@
36
 
37
  if( get_option('timezone_string') ) {
38
  $this->tz_offset = timezone_offset_get( timezone_open( get_option('timezone_string') ), new DateTime() );
 
 
39
  }
40
 
41
  $this->db = $wpdb;
@@ -242,6 +244,9 @@
242
  // This function returns the current IP address of the remote client.
243
  public function get_IP() {
244
 
 
 
 
245
  // By default we use the remote address the server has.
246
  $temp_ip = $_SERVER['REMOTE_ADDR'];
247
 
@@ -274,6 +279,9 @@
274
  // If the headers are invalid, use the server variable which should be good always.
275
  $temp_ip = $_SERVER['REMOTE_ADDR'];
276
  }
 
 
 
277
 
278
  $this->ip = $temp_ip;
279
 
@@ -388,6 +396,14 @@
388
  return date_i18n($format, time() + $this->tz_offset);
389
  }
390
  }
 
 
 
 
 
 
 
 
391
 
392
  // This function checks to see if a search engine exists in the current list of search engines.
393
  public function Check_Search_Engines ($search_engine_name, $search_engine = null) {
10
  // Setup our protected, private and public variables.
11
  protected $db;
12
  protected $tb_prefix;
13
+ protected $ip = false;
14
  protected $ip_hash = false;
15
  protected $agent;
16
 
36
 
37
  if( get_option('timezone_string') ) {
38
  $this->tz_offset = timezone_offset_get( timezone_open( get_option('timezone_string') ), new DateTime() );
39
+ } else if( get_option('gmt_offset') ) {
40
+ $this->tz_offset = get_option('gmt_offset') * 60 * 60;
41
  }
42
 
43
  $this->db = $wpdb;
244
  // This function returns the current IP address of the remote client.
245
  public function get_IP() {
246
 
247
+ // Check to see if we've already retrieved the IP address and if so return the last result.
248
+ if( $this->ip !== FALSE ) { return $this->ip; }
249
+
250
  // By default we use the remote address the server has.
251
  $temp_ip = $_SERVER['REMOTE_ADDR'];
252
 
279
  // If the headers are invalid, use the server variable which should be good always.
280
  $temp_ip = $_SERVER['REMOTE_ADDR'];
281
  }
282
+
283
+ // If the ip address is blank, use 127.0.0.1 (aka localhost).
284
+ if( $temp_ip == '' ) { $temp_ip = '127.0.0.1'; }
285
 
286
  $this->ip = $temp_ip;
287
 
396
  return date_i18n($format, time() + $this->tz_offset);
397
  }
398
  }
399
+
400
+ public function strtotimetz( $timestring ) {
401
+ return strtotime( $timestring ) + $this->tz_offset;
402
+ }
403
+
404
+ public function timetz() {
405
+ return time() + $this->tz_offset;
406
+ }
407
 
408
  // This function checks to see if a search engine exists in the current list of search engines.
409
  public function Check_Search_Engines ($search_engine_name, $search_engine = null) {
includes/functions/functions.php CHANGED
@@ -938,8 +938,8 @@
938
 
939
  $rcount = count( $range );
940
 
941
- $rangestart = $WP_Statistics->Real_Current_Date('m/d/Y', '-' . $current);
942
- $rangeend = $WP_Statistics->Real_Current_Date('m/d/Y');
943
 
944
  $bold = true;
945
  if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; }
@@ -976,8 +976,8 @@
976
  }
977
  else {
978
  echo ' ' . __('Range', 'wp_statistics' ) . ': ';
979
- $rangeend = $WP_Statistics->Real_Current_Date('m/d/Y');
980
- $rangestart = $WP_Statistics->Real_Current_Date('m/d/Y','-'.$current);
981
  }
982
  echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' . $rangestart. '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> '.__('to', 'wp_statistics').' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' . $rangeend . '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> <input type="submit" value="'.__('Go', 'wp_statistics').'" class="button-primary">' . "\r\n";
983
 
@@ -987,23 +987,25 @@
987
  }
988
 
989
  function wp_statistics_date_range_calculator( $days, $start, $end ) {
 
 
990
  $daysToDisplay = $days;
991
  $rangestart = $start;
992
  $rangeend = $end;
993
 
994
  if( $daysToDisplay == -1 ) {
995
- $rangestart_utime = strtotime( $rangestart );
996
- $rangeend_utime = strtotime( $rangeend );
997
  $daysToDisplay = (int)( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
998
 
999
  if( $rangestart_utime == FALSE || $rangeend_utime == FALSE ) {
1000
  $daysToDisplay = 20;
1001
- $rangeend_utime = time();
1002
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1003
  }
1004
  }
1005
  else {
1006
- $rangeend_utime = time();
1007
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1008
  }
1009
 
938
 
939
  $rcount = count( $range );
940
 
941
+ $rangestart = $WP_Statistics->Current_Date('m/d/Y', '-' . $current);
942
+ $rangeend = $WP_Statistics->Current_Date('m/d/Y');
943
 
944
  $bold = true;
945
  if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; }
976
  }
977
  else {
978
  echo ' ' . __('Range', 'wp_statistics' ) . ': ';
979
+ $rangeend = $WP_Statistics->Current_Date('m/d/Y');
980
+ $rangestart = $WP_Statistics->Current_Date('m/d/Y','-'.$current);
981
  }
982
  echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' . $rangestart. '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> '.__('to', 'wp_statistics').' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' . $rangeend . '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> <input type="submit" value="'.__('Go', 'wp_statistics').'" class="button-primary">' . "\r\n";
983
 
987
  }
988
 
989
  function wp_statistics_date_range_calculator( $days, $start, $end ) {
990
+ GLOBAL $WP_Statistics;
991
+
992
  $daysToDisplay = $days;
993
  $rangestart = $start;
994
  $rangeend = $end;
995
 
996
  if( $daysToDisplay == -1 ) {
997
+ $rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
998
+ $rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
999
  $daysToDisplay = (int)( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
1000
 
1001
  if( $rangestart_utime == FALSE || $rangeend_utime == FALSE ) {
1002
  $daysToDisplay = 20;
1003
+ $rangeend_utime = $WP_Statistics->timetz();
1004
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1005
  }
1006
  }
1007
  else {
1008
+ $rangeend_utime = $WP_Statistics->timetz();
1009
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1010
  }
1011
 
includes/log/page-statistics.php CHANGED
@@ -5,7 +5,7 @@
5
  </script>
6
  <?php
7
  if( array_key_exists( 'page-uri', $_GET ) ) { $pageuri = $_GET['page-uri']; } else { $pageuri = null; }
8
- if( array_key_exists( 'page-id', $_GET ) ) { $pageid = $_GET['page-id']; } else { $pageid = null; }
9
 
10
  if( $pageuri && !$pageid ) { $pageid = wp_statistics_uri_to_id( $pageuri ); }
11
 
5
  </script>
6
  <?php
7
  if( array_key_exists( 'page-uri', $_GET ) ) { $pageuri = $_GET['page-uri']; } else { $pageuri = null; }
8
+ if( array_key_exists( 'page-id', $_GET ) ) { $pageid = (int) $_GET['page-id']; } else { $pageid = null; }
9
 
10
  if( $pageuri && !$pageid ) { $pageid = wp_statistics_uri_to_id( $pageuri ); }
11
 
includes/log/top-referring.php CHANGED
@@ -49,7 +49,7 @@
49
  <ul class="subsubsub">
50
  <?php if($referr) { ?>
51
  <li class="all"><a <?php if(!$referr) { echo 'class="current"'; } ?>href="?page=wps_referrers_menu"><?php _e('All', 'wp_statistics'); ?></a></li>
52
- | <li><a class="current" href="?page=wps_referrers_menu&referr=<?php echo htmlentities($referr, ENT_QUOTES); ?>"> <?php echo $title; ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
53
  <?php } else { ?>
54
  <li class="all"><a <?php if(!$referr) { echo 'class="current"'; } ?>href="?page=wps_referrers_menu"><?php _e('All', 'wp_statistics'); ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
55
  <?php }?>
49
  <ul class="subsubsub">
50
  <?php if($referr) { ?>
51
  <li class="all"><a <?php if(!$referr) { echo 'class="current"'; } ?>href="?page=wps_referrers_menu"><?php _e('All', 'wp_statistics'); ?></a></li>
52
+ | <li><a class="current" href="?page=wps_referrers_menu&referr=<?php echo htmlentities($referr, ENT_QUOTES); ?>"> <?php echo htmlentities( $title, ENT_QUOTES ); ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
53
  <?php } else { ?>
54
  <li class="all"><a <?php if(!$referr) { echo 'class="current"'; } ?>href="?page=wps_referrers_menu"><?php _e('All', 'wp_statistics'); ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
55
  <?php }?>
includes/log/top-visitors.php CHANGED
@@ -17,7 +17,7 @@
17
 
18
  $current = 0;
19
 
20
- $statsdate = $WP_Statistics->Real_Current_Date('m/d/Y', '-' . $current);
21
 
22
  if( array_key_exists( 'statsdate', $_GET ) ) { $statsdate = $_GET['statsdate']; }
23
 
@@ -26,7 +26,7 @@
26
  echo ' ' . __('Date', 'wp_statistics' ) . ': ';
27
 
28
  echo '<input type="hidden" name="page" value="wps_top_visitors_menu">' . "\r\n";
29
- echo '<input type="text" size="10" name="statsdate" id="statsdate" value="' . $statsdate. '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> <input type="submit" value="'.__('Go', 'wp_statistics').'" class="button-primary">' . "\r\n";
30
 
31
  echo '</form>' . "\r\n";
32
 
17
 
18
  $current = 0;
19
 
20
+ $statsdate = $WP_Statistics->Current_Date('m/d/Y', '-' . $current);
21
 
22
  if( array_key_exists( 'statsdate', $_GET ) ) { $statsdate = $_GET['statsdate']; }
23
 
26
  echo ' ' . __('Date', 'wp_statistics' ) . ': ';
27
 
28
  echo '<input type="hidden" name="page" value="wps_top_visitors_menu">' . "\r\n";
29
+ echo '<input type="text" size="10" name="statsdate" id="statsdate" value="' . htmlentities( $statsdate, ENT_QUOTES ) . '" placeholder="' . __('MM/DD/YYYY', 'wp_statistics') .'"> <input type="submit" value="'.__('Go', 'wp_statistics').'" class="button-primary">' . "\r\n";
30
 
31
  echo '</form>' . "\r\n";
32
 
includes/log/widgets/page.php CHANGED
@@ -74,7 +74,7 @@
74
  show: true,
75
  location: 's',
76
  placement: 'outsideGrid',
77
- labels: [ '<?php echo $pageid . ' - ' . $title; ?>' ],
78
  renderer: jQuery.jqplot.EnhancedLegendRenderer,
79
  rendererOptions:
80
  {
74
  show: true,
75
  location: 's',
76
  placement: 'outsideGrid',
77
+ labels: [ '<?php echo (int) $pageid . ' - ' . $title; ?>' ],
78
  renderer: jQuery.jqplot.EnhancedLegendRenderer,
79
  rendererOptions:
80
  {
includes/optimization/tabs/wps-optimization-resources.php CHANGED
@@ -279,7 +279,7 @@
279
  </th>
280
 
281
  <td>
282
- <strong><?php echo $_SERVER['HTTP_USER_AGENT']; ?></strong>
283
  <p class="description"><?php _e('The client user agent string.', 'wp_statistics'); ?></p>
284
  </td>
285
  </tr>
279
  </th>
280
 
281
  <td>
282
+ <strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong>
283
  <p class="description"><?php _e('The client user agent string.', 'wp_statistics'); ?></p>
284
  </td>
285
  </tr>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mostafa.s1990, GregRoss
3
  Donate link: http://wp-statistics.com/donate/
4
  Tags: statistics, stats, visit, visitors, chart, browser, blog, today, yesterday, week, month, year, total, post, page, sidebar, summary, feedburner, hits, pagerank, google, alexa, live visit
5
  Requires at least: 3.0
6
- Tested up to: 4.3
7
- Stable tag: 9.6.5
8
  License: GPL3
9
 
10
  Complete statistics for your WordPress site.
@@ -235,6 +235,9 @@ If you still have issues open a new thread on the support forum and we'll try an
235
  10. View latest search engine referrers Statistics page.
236
 
237
  == Upgrade Notice ==
 
 
 
238
  = 9.6.5 =
239
  Have you updated your database indexes and search table? If not please go to Statistics->Optimization->Database after you have installed the update and run the updates.
240
 
@@ -298,6 +301,12 @@ BACKUP YOUR DATABASE BEFORE INSTALLING! This release alters the table structure
298
  This release updates some core code to do with timezones, hence the change to version 9.0, if you see any issues with timezones, please let us know. In addition, you may see an increase in your visits count as a race condition that dropped some visits has been resolved.
299
 
300
  == Changelog ==
 
 
 
 
 
 
301
  = 9.6.5 =
302
  * Release Date: September 18, 2015
303
  * Updated: Updated support libraries, including browscap (2.0.5) and GeoIP (webservices).
3
  Donate link: http://wp-statistics.com/donate/
4
  Tags: statistics, stats, visit, visitors, chart, browser, blog, today, yesterday, week, month, year, total, post, page, sidebar, summary, feedburner, hits, pagerank, google, alexa, live visit
5
  Requires at least: 3.0
6
+ Tested up to: 4.4
7
+ Stable tag: 9.6.6
8
  License: GPL3
9
 
10
  Complete statistics for your WordPress site.
235
  10. View latest search engine referrers Statistics page.
236
 
237
  == Upgrade Notice ==
238
+ = 9.6.6 =
239
+ Security update release, please update Immediately. Have you updated your database indexes and search table? If not please go to Statistics->Optimization->Database after you have installed the update and run the updates.
240
+
241
  = 9.6.5 =
242
  Have you updated your database indexes and search table? If not please go to Statistics->Optimization->Database after you have installed the update and run the updates.
243
 
301
  This release updates some core code to do with timezones, hence the change to version 9.0, if you see any issues with timezones, please let us know. In addition, you may see an increase in your visits count as a race condition that dropped some visits has been resolved.
302
 
303
  == Changelog ==
304
+ = 9.6.6 =
305
+ * Release Date: November 1, 2015
306
+ * Updated: Use timezone corrected dates for date pickers.
307
+ * Updated the get_ip code to return 127.0.0.1 if no IP address is found (can happen when a user runs WordPress from a command line function, like when setting up a scheduled cron job).
308
+ * Fixed: Several security related updates, thanks CodeV.
309
+
310
  = 9.6.5 =
311
  * Release Date: September 18, 2015
312
  * Updated: Updated support libraries, including browscap (2.0.5) and GeoIP (webservices).
wp-statistics.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Statistics
4
  Plugin URI: http://wp-statistics.com/
5
  Description: Complete statistics for your WordPress site.
6
- Version: 9.6.5
7
  Author: Mostafa Soufi & Greg Ross
8
  Author URI: http://wp-statistics.com/
9
  Text Domain: wp_statistics
@@ -12,7 +12,7 @@ License: GPL2
12
  */
13
 
14
  // These defines are used later for various reasons.
15
- define('WP_STATISTICS_VERSION', '9.6.5');
16
  define('WP_STATISTICS_MANUAL', 'manual/WP Statistics Admin Manual.');
17
  define('WP_STATISTICS_REQUIRED_PHP_VERSION', '5.3.0');
18
  define('WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION', WP_STATISTICS_REQUIRED_PHP_VERSION);
3
  Plugin Name: WP Statistics
4
  Plugin URI: http://wp-statistics.com/
5
  Description: Complete statistics for your WordPress site.
6
+ Version: 9.6.6
7
  Author: Mostafa Soufi & Greg Ross
8
  Author URI: http://wp-statistics.com/
9
  Text Domain: wp_statistics
12
  */
13
 
14
  // These defines are used later for various reasons.
15
+ define('WP_STATISTICS_VERSION', '9.6.6');
16
  define('WP_STATISTICS_MANUAL', 'manual/WP Statistics Admin Manual.');
17
  define('WP_STATISTICS_REQUIRED_PHP_VERSION', '5.3.0');
18
  define('WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION', WP_STATISTICS_REQUIRED_PHP_VERSION);