WP Statistics - Version 12.0.7

Version Description

  • Release Date: June 8, 2017
  • WordPress 4.8 compatibility
  • Updated WP-Statistics logo! Thanks Arin Hacopian for design the logo.
  • Remove manual file and moved to wp-statistics.com/category/documentation
  • Fixed items show issue in referring page.
  • Fixed recent visitor link in dashboard widget.
Download this release

Release Info

Developer mostafa.s1990
Plugin Icon 128x128 WP Statistics
Version 12.0.7
Comparing to
See all releases

Code changes from version 12.0.6 to 12.0.7

Files changed (75) hide show
  1. ajax.php +146 -126
  2. assets/css/admin-old.css +0 -1
  3. assets/css/admin.css +12 -6
  4. assets/css/jquery-ui-1.10.4.custom.css +185 -144
  5. assets/css/jquery-ui-smoothness.css +1395 -712
  6. assets/css/log.css +55 -53
  7. assets/css/pagination.css +7 -0
  8. assets/css/rtl.css +11 -11
  9. assets/css/style.css +2 -0
  10. assets/images/HTML.png +0 -0
  11. assets/images/ODT.png +0 -0
  12. assets/images/logo-250.png +0 -0
  13. assets/js/dashboard.js +63 -62
  14. assets/js/editor.js +50 -49
  15. assets/js/log.js +57 -56
  16. changelog.txt +0 -101
  17. dashboard.php +219 -183
  18. editor.php +96 -83
  19. includes/classes/hits.class.php +169 -175
  20. includes/classes/hits.geoip.class.php +19 -16
  21. includes/classes/pagination.class.php +516 -468
  22. includes/classes/php-export-data.class.php +93 -90
  23. includes/classes/statistics.class.php +281 -218
  24. includes/functions/country-codes.php +279 -279
  25. includes/functions/country-coordinates.php +243 -243
  26. includes/functions/export.php +87 -75
  27. includes/functions/functions.php +1049 -921
  28. includes/functions/geoip-populate.php +40 -37
  29. includes/functions/manual.php +0 -39
  30. includes/functions/purge-hits.php +43 -42
  31. includes/functions/purge.php +116 -101
  32. includes/log/all-browsers.php +306 -288
  33. includes/log/authors.php +256 -235
  34. includes/log/categories.php +245 -228
  35. includes/log/exclusions.php +295 -200
  36. includes/log/hit-statistics.php +179 -161
  37. includes/log/last-search.php +152 -145
  38. includes/log/last-visitor.php +157 -132
  39. includes/log/log.php +116 -114
  40. includes/log/online.php +111 -105
  41. includes/log/page-statistics.php +60 -33
  42. includes/log/search-statistics.php +156 -133
  43. includes/log/tags.php +269 -246
  44. includes/log/top-countries.php +66 -57
  45. includes/log/top-pages.php +204 -186
  46. includes/log/top-referring.php +166 -154
  47. includes/log/top-visitors.php +32 -30
  48. includes/log/widgets/about.php +29 -25
  49. includes/log/widgets/browsers.php +85 -80
  50. includes/log/widgets/countries.php +45 -44
  51. includes/log/widgets/hits.php +131 -128
  52. includes/log/widgets/jqv.map.php +109 -101
  53. includes/log/widgets/page.php +139 -125
  54. includes/log/widgets/pages.php +23 -19
  55. includes/log/widgets/quickstats.php +211 -139
  56. includes/log/widgets/recent.php +49 -43
  57. includes/log/widgets/referring.php +52 -52
  58. includes/log/widgets/search.php +138 -128
  59. includes/log/widgets/summary.php +203 -131
  60. includes/log/widgets/top.visitors.php +56 -50
  61. includes/log/widgets/words.php +74 -61
  62. includes/optimization/tabs/wps-optimization-database.php +119 -122
  63. includes/optimization/tabs/wps-optimization-export.php +59 -59
  64. includes/optimization/tabs/wps-optimization-historical.php +54 -54
  65. includes/optimization/tabs/wps-optimization-purging.php +285 -279
  66. includes/optimization/tabs/wps-optimization-resources.php +373 -335
  67. includes/optimization/tabs/wps-optimization-updates.php +43 -43
  68. includes/optimization/wps-optimization.php +242 -212
  69. includes/settings/tabs/wps-about.php +92 -86
  70. includes/settings/tabs/wps-access-level.php +80 -64
  71. includes/settings/tabs/wps-exclusions.php +242 -208
  72. includes/settings/tabs/wps-externals.php +291 -260
  73. includes/settings/tabs/wps-general.php +328 -330
  74. includes/settings/tabs/wps-maintenance.php +91 -81
  75. includes/settings/tabs/wps-notifications.php +152 -147
ajax.php CHANGED
@@ -4,298 +4,318 @@
4
  function wp_statistics_close_donation_nag_action_callback() {
5
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
6
 
7
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
8
-
9
- if( current_user_can( $manage_cap ) ) {
10
  $WP_Statistics->update_option( 'disable_donation_nag', true );
11
  }
12
-
13
  wp_die(); // this is required to terminate immediately and return a proper response
14
  }
 
15
  add_action( 'wp_ajax_wp_statistics_close_donation_nag', 'wp_statistics_close_donation_nag_action_callback' );
16
 
17
  // Setup an AJAX action to delete an agent in the optimization page.
18
  function wp_statistics_delete_agents_action_callback() {
19
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
20
 
21
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
22
 
23
- if( current_user_can( $manage_cap ) ) {
24
  $agent = $_POST['agent-name'];
25
-
26
- if( $agent ) {
27
-
28
- $result = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent ));
29
-
30
- if($result) {
31
- echo sprintf(__('%s agent data deleted successfully.', 'wp_statistics'), '<code>' . $agent . '</code>');
32
- }
33
- else {
34
- _e('No agent data found to remove!', 'wp_statistics');
35
  }
36
-
37
  } else {
38
- _e('Please select the desired items.', 'wp_statistics');
39
  }
40
  } else {
41
- _e('Access denied!', 'wp_statistics');
42
  }
43
-
44
  wp_die(); // this is required to terminate immediately and return a proper response
45
  }
 
46
  add_action( 'wp_ajax_wp_statistics_delete_agents', 'wp_statistics_delete_agents_action_callback' );
47
 
48
  // Setup an AJAX action to delete a platform in the optimization page.
49
  function wp_statistics_delete_platforms_action_callback() {
50
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
51
 
52
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
53
 
54
- if( current_user_can( $manage_cap ) ) {
55
  $platform = $_POST['platform-name'];
56
-
57
- if( $platform ) {
58
-
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');
66
  }
67
  } else {
68
- _e('Please select the desired items.', 'wp_statistics');
69
  }
70
  } else {
71
- _e('Access denied!', 'wp_statistics');
72
  }
73
-
74
  wp_die(); // this is required to terminate immediately and return a proper response
75
  }
 
76
  add_action( 'wp_ajax_wp_statistics_delete_platforms', 'wp_statistics_delete_platforms_action_callback' );
77
 
78
  // Setup an AJAX action to empty a table in the optimization page.
79
  function wp_statistics_empty_table_action_callback() {
80
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
81
 
82
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
83
 
84
- if( current_user_can( $manage_cap ) ) {
85
  $table_name = $_POST['table-name'];
86
 
87
- if($table_name) {
88
 
89
- switch( $table_name ) {
90
  case 'useronline':
91
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_useronline');
92
  break;
93
  case 'visit':
94
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visit');
95
  break;
96
  case 'visitors':
97
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visitor');
98
  break;
99
  case 'exclusions':
100
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_exclusions');
101
  break;
102
  case 'pages':
103
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_pages');
104
  break;
105
  case 'search':
106
- echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_search');
107
  break;
108
  case 'all':
109
- $result_string = wp_statitiscs_empty_table($wpdb->prefix . 'statistics_useronline');
110
- $result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visit');
111
- $result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visitor');
112
- $result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_exclusions');
113
- $result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_pages');
114
- $result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_search');
115
 
116
  echo $result_string;
117
-
118
  break;
119
  default:
120
- _e('Please select the desired items.', 'wp_statistics');
121
  }
122
 
123
  $WP_Statistics->Primary_Values();
124
-
125
  } else {
126
- _e('Please select the desired items.', 'wp_statistics');
127
  }
128
  } else {
129
- _e('Access denied!', 'wp_statistics');
130
  }
131
-
132
  wp_die(); // this is required to terminate immediately and return a proper response
133
  }
 
134
  add_action( 'wp_ajax_wp_statistics_empty_table', 'wp_statistics_empty_table_action_callback' );
135
 
136
  // Setup an AJAX action to purge old data in the optimization page.
137
  function wp_statistics_purge_data_action_callback() {
138
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
139
 
140
- require($WP_Statistics->plugin_dir . '/includes/functions/purge.php');
141
-
142
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
143
 
144
- if( current_user_can( $manage_cap ) ) {
145
  $purge_days = 0;
146
 
147
- if( array_key_exists( 'purge-days', $_POST ) ) {
148
  // Get the number of days to purge data before.
149
- $purge_days = intval($_POST['purge-days']);
150
  }
151
-
152
  echo wp_statistics_purge_data( $purge_days );
153
  } else {
154
- _e('Access denied!', 'wp_statistics');
155
  }
156
-
157
  wp_die(); // this is required to terminate immediately and return a proper response
158
  }
 
159
  add_action( 'wp_ajax_wp_statistics_purge_data', 'wp_statistics_purge_data_action_callback' );
160
 
161
  // Setup an AJAX action to purge visitors with more than a defined number of hits.
162
  function wp_statistics_purge_visitor_hits_action_callback() {
163
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
164
 
165
- require($WP_Statistics->plugin_dir . '/includes/functions/purge-hits.php');
166
-
167
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
168
 
169
- if( current_user_can( $manage_cap ) ) {
170
  $purge_hits = 10;
171
 
172
- if( array_key_exists( 'purge-hits', $_POST ) ) {
173
  // Get the number of days to purge data before.
174
- $purge_hits = intval($_POST['purge-hits']);
175
  }
176
-
177
- if( $purge_hits < 10 ) {
178
- _e('Number of hits must be greater than or equal to 10!', 'wp_statistics');
179
- }
180
- else {
181
  echo wp_statistics_purge_visitor_hits( $purge_hits );
182
  }
183
  } else {
184
- _e('Access denied!', 'wp_statistics');
185
  }
186
-
187
  wp_die(); // this is required to terminate immediately and return a proper response
188
  }
 
189
  add_action( 'wp_ajax_wp_statistics_purge_visitor_hits', 'wp_statistics_purge_visitor_hits_action_callback' );
190
 
191
  // Setup an AJAX action to purge visitors with more than a defined number of hits.
192
  function wp_statistics_get_widget_contents_callback() {
193
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
194
 
195
- $widgets = array( 'about', 'browsers', 'map', 'countries', 'hits', 'hitsmap', 'page', 'pages', 'quickstats', 'recent', 'referring', 'search', 'summary', 'top.visitors', 'words' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
- $view_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('read_capability', 'manage_options') );
198
 
199
- if( current_user_can( $view_cap ) ) {
200
  $widget = '';
201
-
202
- if( array_key_exists( 'widget', $_POST ) ) {
203
  // Get the widget we're going to display.
204
-
205
- if( in_array( $_POST['widget'], $widgets ) ) {
206
  $widget = $_POST['widget'];
207
  }
208
  }
209
 
210
- if( 'map' == $widget || 'hitsmap' == $widget ) {
211
  $widget = 'jqv.map';
212
  }
213
-
214
- if( '' == $widget ) {
215
- _e('No matching widget found!', 'wp_statistics');
216
  wp_die();
217
  }
218
-
219
  $ISOCountryCode = $WP_Statistics->get_country_codes();
220
  $search_engines = wp_statistics_searchengine_list();
221
 
222
  require( $WP_Statistics->plugin_dir . '/includes/log/widgets/' . $widget . '.php' );
223
-
224
- switch( $widget ) {
225
  case 'summary':
226
- wp_statistics_generate_summary_postbox_content($search_engines);
227
-
228
  break;
229
  case 'quickstats':
230
- wp_statistics_generate_quickstats_postbox_content($search_engines);
231
-
232
  break;
233
-
234
  case 'browsers':
235
  wp_statistics_generate_browsers_postbox_content();
236
-
237
  break;
238
  case 'referring':
239
  wp_statistics_generate_referring_postbox_content();
240
-
241
  break;
242
  case 'countries':
243
- wp_statistics_generate_countries_postbox_content($ISOCountryCode);
244
-
245
  break;
246
  case 'jqv.map':
247
- wp_statistics_generate_map_postbox_content($ISOCountryCode);
248
-
249
  break;
250
  case 'hits':
251
  wp_statistics_generate_hits_postbox_content();
252
-
253
  break;
254
  case 'search':
255
- wp_statistics_generate_search_postbox_content($search_engines);
256
-
257
  break;
258
  case 'words':
259
- wp_statistics_generate_words_postbox_content($ISOCountryCode);
260
-
261
  break;
262
  case 'page':
263
- if( array_key_exists( 'page-id', $_POST ) ) {
264
- $pageid = (int)$_POST['page-id'];
265
  wp_statistics_generate_page_postbox_content( null, $pageid );
266
  }
267
-
268
  break;
269
  case 'pages':
270
  list( $total, $uris ) = wp_statistics_get_top_pages();
271
- wp_statistics_generate_pages_postbox_content($total, $uris);
272
-
273
  break;
274
  case 'recent':
275
- wp_statistics_generate_recent_postbox_content($ISOCountryCode);
276
-
277
  break;
278
  case 'top.visitors':
279
  $format = null;
280
-
281
- if( array_key_exists( 'format', $_POST ) ) {
282
  $format = 'compact';
283
  }
284
-
285
- wp_statistics_generate_top_visitors_postbox_content($ISOCountryCode, 'today', 10, $format);
286
-
287
  break;
288
  case 'about':
289
- wp_statistics_generate_about_postbox_content($ISOCountryCode);
290
-
291
  break;
292
  default:
293
  _e( 'ERROR: Widget not found!', 'wp_statistics' );
294
- }
295
  } else {
296
- _e('Access denied!', 'wp_statistics');
297
  }
298
-
299
  wp_die(); // this is required to terminate immediately and return a proper response
300
  }
 
301
  add_action( 'wp_ajax_wp_statistics_get_widget_contents', 'wp_statistics_get_widget_contents_callback' );
4
  function wp_statistics_close_donation_nag_action_callback() {
5
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
6
 
7
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
8
+
9
+ if ( current_user_can( $manage_cap ) ) {
10
  $WP_Statistics->update_option( 'disable_donation_nag', true );
11
  }
12
+
13
  wp_die(); // this is required to terminate immediately and return a proper response
14
  }
15
+
16
  add_action( 'wp_ajax_wp_statistics_close_donation_nag', 'wp_statistics_close_donation_nag_action_callback' );
17
 
18
  // Setup an AJAX action to delete an agent in the optimization page.
19
  function wp_statistics_delete_agents_action_callback() {
20
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
21
 
22
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
23
 
24
+ if ( current_user_can( $manage_cap ) ) {
25
  $agent = $_POST['agent-name'];
26
+
27
+ if ( $agent ) {
28
+
29
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent ) );
30
+
31
+ if ( $result ) {
32
+ echo sprintf( __( '%s agent data deleted successfully.', 'wp_statistics' ), '<code>' . $agent . '</code>' );
33
+ } else {
34
+ _e( 'No agent data found to remove!', 'wp_statistics' );
 
35
  }
36
+
37
  } else {
38
+ _e( 'Please select the desired items.', 'wp_statistics' );
39
  }
40
  } else {
41
+ _e( 'Access denied!', 'wp_statistics' );
42
  }
43
+
44
  wp_die(); // this is required to terminate immediately and return a proper response
45
  }
46
+
47
  add_action( 'wp_ajax_wp_statistics_delete_agents', 'wp_statistics_delete_agents_action_callback' );
48
 
49
  // Setup an AJAX action to delete a platform in the optimization page.
50
  function wp_statistics_delete_platforms_action_callback() {
51
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
52
 
53
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
54
 
55
+ if ( current_user_can( $manage_cap ) ) {
56
  $platform = $_POST['platform-name'];
57
+
58
+ if ( $platform ) {
59
+
60
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform ) );
61
+
62
+ if ( $result ) {
63
+ echo sprintf( __( '%s platform data deleted successfully.', 'wp_statistics' ), '<code>' . htmlentities( $platform, ENT_QUOTES ) . '</code>' );
64
+ } else {
65
+ _e( 'No platform data found to remove!', 'wp_statistics' );
 
66
  }
67
  } else {
68
+ _e( 'Please select the desired items.', 'wp_statistics' );
69
  }
70
  } else {
71
+ _e( 'Access denied!', 'wp_statistics' );
72
  }
73
+
74
  wp_die(); // this is required to terminate immediately and return a proper response
75
  }
76
+
77
  add_action( 'wp_ajax_wp_statistics_delete_platforms', 'wp_statistics_delete_platforms_action_callback' );
78
 
79
  // Setup an AJAX action to empty a table in the optimization page.
80
  function wp_statistics_empty_table_action_callback() {
81
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
82
 
83
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
84
 
85
+ if ( current_user_can( $manage_cap ) ) {
86
  $table_name = $_POST['table-name'];
87
 
88
+ if ( $table_name ) {
89
 
90
+ switch ( $table_name ) {
91
  case 'useronline':
92
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_useronline' );
93
  break;
94
  case 'visit':
95
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visit' );
96
  break;
97
  case 'visitors':
98
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visitor' );
99
  break;
100
  case 'exclusions':
101
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_exclusions' );
102
  break;
103
  case 'pages':
104
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_pages' );
105
  break;
106
  case 'search':
107
+ echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_search' );
108
  break;
109
  case 'all':
110
+ $result_string = wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_useronline' );
111
+ $result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visit' );
112
+ $result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visitor' );
113
+ $result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_exclusions' );
114
+ $result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_pages' );
115
+ $result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_search' );
116
 
117
  echo $result_string;
118
+
119
  break;
120
  default:
121
+ _e( 'Please select the desired items.', 'wp_statistics' );
122
  }
123
 
124
  $WP_Statistics->Primary_Values();
125
+
126
  } else {
127
+ _e( 'Please select the desired items.', 'wp_statistics' );
128
  }
129
  } else {
130
+ _e( 'Access denied!', 'wp_statistics' );
131
  }
132
+
133
  wp_die(); // this is required to terminate immediately and return a proper response
134
  }
135
+
136
  add_action( 'wp_ajax_wp_statistics_empty_table', 'wp_statistics_empty_table_action_callback' );
137
 
138
  // Setup an AJAX action to purge old data in the optimization page.
139
  function wp_statistics_purge_data_action_callback() {
140
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
141
 
142
+ require( $WP_Statistics->plugin_dir . '/includes/functions/purge.php' );
143
+
144
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
145
 
146
+ if ( current_user_can( $manage_cap ) ) {
147
  $purge_days = 0;
148
 
149
+ if ( array_key_exists( 'purge-days', $_POST ) ) {
150
  // Get the number of days to purge data before.
151
+ $purge_days = intval( $_POST['purge-days'] );
152
  }
153
+
154
  echo wp_statistics_purge_data( $purge_days );
155
  } else {
156
+ _e( 'Access denied!', 'wp_statistics' );
157
  }
158
+
159
  wp_die(); // this is required to terminate immediately and return a proper response
160
  }
161
+
162
  add_action( 'wp_ajax_wp_statistics_purge_data', 'wp_statistics_purge_data_action_callback' );
163
 
164
  // Setup an AJAX action to purge visitors with more than a defined number of hits.
165
  function wp_statistics_purge_visitor_hits_action_callback() {
166
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
167
 
168
+ require( $WP_Statistics->plugin_dir . '/includes/functions/purge-hits.php' );
169
+
170
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
171
 
172
+ if ( current_user_can( $manage_cap ) ) {
173
  $purge_hits = 10;
174
 
175
+ if ( array_key_exists( 'purge-hits', $_POST ) ) {
176
  // Get the number of days to purge data before.
177
+ $purge_hits = intval( $_POST['purge-hits'] );
178
  }
179
+
180
+ if ( $purge_hits < 10 ) {
181
+ _e( 'Number of hits must be greater than or equal to 10!', 'wp_statistics' );
182
+ } else {
 
183
  echo wp_statistics_purge_visitor_hits( $purge_hits );
184
  }
185
  } else {
186
+ _e( 'Access denied!', 'wp_statistics' );
187
  }
188
+
189
  wp_die(); // this is required to terminate immediately and return a proper response
190
  }
191
+
192
  add_action( 'wp_ajax_wp_statistics_purge_visitor_hits', 'wp_statistics_purge_visitor_hits_action_callback' );
193
 
194
  // Setup an AJAX action to purge visitors with more than a defined number of hits.
195
  function wp_statistics_get_widget_contents_callback() {
196
  GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
197
 
198
+ $widgets = array(
199
+ 'about',
200
+ 'browsers',
201
+ 'map',
202
+ 'countries',
203
+ 'hits',
204
+ 'hitsmap',
205
+ 'page',
206
+ 'pages',
207
+ 'quickstats',
208
+ 'recent',
209
+ 'referring',
210
+ 'search',
211
+ 'summary',
212
+ 'top.visitors',
213
+ 'words'
214
+ );
215
 
216
+ $view_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_options' ) );
217
 
218
+ if ( current_user_can( $view_cap ) ) {
219
  $widget = '';
220
+
221
+ if ( array_key_exists( 'widget', $_POST ) ) {
222
  // Get the widget we're going to display.
223
+
224
+ if ( in_array( $_POST['widget'], $widgets ) ) {
225
  $widget = $_POST['widget'];
226
  }
227
  }
228
 
229
+ if ( 'map' == $widget || 'hitsmap' == $widget ) {
230
  $widget = 'jqv.map';
231
  }
232
+
233
+ if ( '' == $widget ) {
234
+ _e( 'No matching widget found!', 'wp_statistics' );
235
  wp_die();
236
  }
237
+
238
  $ISOCountryCode = $WP_Statistics->get_country_codes();
239
  $search_engines = wp_statistics_searchengine_list();
240
 
241
  require( $WP_Statistics->plugin_dir . '/includes/log/widgets/' . $widget . '.php' );
242
+
243
+ switch ( $widget ) {
244
  case 'summary':
245
+ wp_statistics_generate_summary_postbox_content( $search_engines );
246
+
247
  break;
248
  case 'quickstats':
249
+ wp_statistics_generate_quickstats_postbox_content( $search_engines );
250
+
251
  break;
252
+
253
  case 'browsers':
254
  wp_statistics_generate_browsers_postbox_content();
255
+
256
  break;
257
  case 'referring':
258
  wp_statistics_generate_referring_postbox_content();
259
+
260
  break;
261
  case 'countries':
262
+ wp_statistics_generate_countries_postbox_content( $ISOCountryCode );
263
+
264
  break;
265
  case 'jqv.map':
266
+ wp_statistics_generate_map_postbox_content( $ISOCountryCode );
267
+
268
  break;
269
  case 'hits':
270
  wp_statistics_generate_hits_postbox_content();
271
+
272
  break;
273
  case 'search':
274
+ wp_statistics_generate_search_postbox_content( $search_engines );
275
+
276
  break;
277
  case 'words':
278
+ wp_statistics_generate_words_postbox_content( $ISOCountryCode );
279
+
280
  break;
281
  case 'page':
282
+ if ( array_key_exists( 'page-id', $_POST ) ) {
283
+ $pageid = (int) $_POST['page-id'];
284
  wp_statistics_generate_page_postbox_content( null, $pageid );
285
  }
286
+
287
  break;
288
  case 'pages':
289
  list( $total, $uris ) = wp_statistics_get_top_pages();
290
+ wp_statistics_generate_pages_postbox_content( $total, $uris );
291
+
292
  break;
293
  case 'recent':
294
+ wp_statistics_generate_recent_postbox_content( $ISOCountryCode );
295
+
296
  break;
297
  case 'top.visitors':
298
  $format = null;
299
+
300
+ if ( array_key_exists( 'format', $_POST ) ) {
301
  $format = 'compact';
302
  }
303
+
304
+ wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, 'today', 10, $format );
305
+
306
  break;
307
  case 'about':
308
+ wp_statistics_generate_about_postbox_content( $ISOCountryCode );
309
+
310
  break;
311
  default:
312
  _e( 'ERROR: Widget not found!', 'wp_statistics' );
313
+ }
314
  } else {
315
+ _e( 'Access denied!', 'wp_statistics' );
316
  }
317
+
318
  wp_die(); // this is required to terminate immediately and return a proper response
319
  }
320
+
321
  add_action( 'wp_ajax_wp_statistics_get_widget_contents', 'wp_statistics_get_widget_contents_callback' );
assets/css/admin-old.css CHANGED
@@ -3,7 +3,6 @@
3
  background: url("../images/icon.png") no-repeat scroll center center rgba(0, 0, 0, 0) !important;
4
  }
5
 
6
-
7
  #adminmenu #toplevel_page_wps_overview_page div.wp-menu-image:before {
8
  content: "";
9
  }
3
  background: url("../images/icon.png") no-repeat scroll center center rgba(0, 0, 0, 0) !important;
4
  }
5
 
 
6
  #adminmenu #toplevel_page_wps_overview_page div.wp-menu-image:before {
7
  content: "";
8
  }
assets/css/admin.css CHANGED
@@ -1,11 +1,17 @@
1
  #adminmenu #toplevel_page_wps_overview_page .wp-menu-image:before {
2
- content: "\f184";
3
  }
4
 
5
- #wp-admin-bar-wp-statistic-menu .ab-icon:before{
6
- font-family: "dashicons" !important;
7
- content: "\f184" !important;
8
  }
9
- .wps-center{
10
- text-align: center;
 
 
 
 
 
 
11
  }
1
  #adminmenu #toplevel_page_wps_overview_page .wp-menu-image:before {
2
+ content: "\f184";
3
  }
4
 
5
+ #wp-admin-bar-wp-statistic-menu .ab-icon:before {
6
+ font-family: "dashicons" !important;
7
+ content: "\f184" !important;
8
  }
9
+
10
+ .wps-center {
11
+ text-align: center;
12
+ }
13
+
14
+ #wps_about_postbox #about_postbox img {
15
+ max-width: 170px;
16
+ margin: 0 0 9px 0;
17
  }
assets/css/jquery-ui-1.10.4.custom.css CHANGED
@@ -7,185 +7,209 @@
7
  /* Layout helpers
8
  ----------------------------------*/
9
  .ui-helper-hidden {
10
- display: none;
11
  }
 
12
  .ui-helper-hidden-accessible {
13
- border: 0;
14
- clip: rect(0 0 0 0);
15
- height: 1px;
16
- margin: -1px;
17
- overflow: hidden;
18
- padding: 0;
19
- position: absolute;
20
- width: 1px;
21
  }
 
22
  .ui-helper-reset {
23
- margin: 0;
24
- padding: 0;
25
- border: 0;
26
- outline: 0;
27
- line-height: 1.3;
28
- text-decoration: none;
29
- font-size: 100%;
30
- list-style: none;
31
  }
 
32
  .ui-helper-clearfix:before,
33
  .ui-helper-clearfix:after {
34
- content: "";
35
- display: table;
36
- border-collapse: collapse;
37
  }
 
38
  .ui-helper-clearfix:after {
39
- clear: both;
40
  }
 
41
  .ui-helper-clearfix {
42
- min-height: 0; /* support: IE7 */
43
  }
 
44
  .ui-helper-zfix {
45
- width: 100%;
46
- height: 100%;
47
- top: 0;
48
- left: 0;
49
- position: absolute;
50
- opacity: 0;
51
- filter:Alpha(Opacity=0);
52
  }
53
 
54
  .ui-front {
55
- z-index: 100;
56
  }
57
 
58
-
59
  /* Interaction Cues
60
  ----------------------------------*/
61
  .ui-state-disabled {
62
- cursor: default !important;
63
  }
64
 
65
-
66
  /* Icons
67
  ----------------------------------*/
68
 
69
  /* states and images */
70
  .ui-icon {
71
- display: block;
72
- text-indent: -99999px;
73
- overflow: hidden;
74
- background-repeat: no-repeat;
75
  }
76
 
77
-
78
  /* Misc visuals
79
  ----------------------------------*/
80
 
81
  /* Overlays */
82
  .ui-widget-overlay {
83
- position: fixed;
84
- top: 0;
85
- left: 0;
86
- width: 100%;
87
- height: 100%;
88
  }
 
89
  .ui-progressbar {
90
- height: 2em;
91
- text-align: left;
92
- overflow: hidden;
93
  }
 
94
  .ui-progressbar .ui-progressbar-value {
95
- margin: -1px;
96
- height: 100%;
97
  }
 
98
  .ui-progressbar .ui-progressbar-overlay {
99
- background: url("images/animated-overlay.gif");
100
- height: 100%;
101
- filter: alpha(opacity=25);
102
- opacity: 0.25;
103
  }
 
104
  .ui-progressbar-indeterminate .ui-progressbar-value {
105
- background-image: none;
106
  }
107
 
108
- #tabs { border:none; padding:0px; margin:0px; }
 
 
 
 
109
 
110
  .ui-tabs {
111
- position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
112
- padding: .2em;
113
  }
 
114
  .ui-tabs .ui-tabs-nav {
115
- margin: 0;
116
- padding: .2em .2em 0;
117
  }
 
118
  .ui-tabs .ui-tabs-nav li {
119
- list-style: none;
120
- float: left;
121
- position: relative;
122
- top: 0;
123
- margin: 1px .2em 0 0;
124
- margin-right: 10px;
125
- border-bottom-width: 0;
126
- padding: 0;
127
- white-space: nowrap;
128
  }
 
129
  .ui-tabs .ui-tabs-nav .ui-tabs-anchor {
130
- float: left;
131
- padding: .5em 1em;
132
- text-decoration: none;
133
  }
 
134
  .ui-tabs .ui-tabs-nav li.ui-tabs-active {
135
- margin-bottom: -1px;
136
- padding-bottom: 1px;
137
- margin-right: 10px;
138
  }
 
139
  .ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
140
  .ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
141
  .ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
142
- cursor: text;
143
  }
 
144
  .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
145
- cursor: pointer;
146
  }
 
147
  .ui-tabs .ui-tabs-panel {
148
- display: block;
149
- border-width: 0;
150
- padding: 1em 1.4em;
151
- background: none;
152
  }
153
 
154
  /* Component containers
155
  ----------------------------------*/
156
  .ui-widget {
157
- font-family: Verdana,Arial,sans-serif;
158
- font-size: 1.1em;
159
  }
 
160
  .ui-widget .ui-widget {
161
- font-size: 1em;
162
  }
 
163
  .ui-widget input,
164
  .ui-widget select,
165
  .ui-widget textarea,
166
  .ui-widget button {
167
- font-family: Verdana,Arial,sans-serif;
168
- font-size: 1em;
169
  }
 
170
  .ui-widget-content {
171
- border: 1px solid #aaaaaa;
172
- background: transparent;
173
- color: #222222;
174
  }
 
175
  .ui-widget-content a {
176
- color: #222222;
177
  }
 
178
  .ui-widget-header {
179
- border-left: none;
180
- border-top: none;
181
- border-right: none;
182
- border-bottom: 1px solid #aaaaaa;
183
- background: transparent;
184
- color: #222222;
185
- font-weight: bold;
186
  }
 
187
  .ui-widget-header a {
188
- color: #222222;
189
  }
190
 
191
  /* Interaction states
@@ -193,28 +217,31 @@
193
  .ui-state-default,
194
  .ui-widget-content .ui-state-default,
195
  .ui-widget-header .ui-state-default {
196
- border: 1px solid #d3d3d3;
197
- background: #e6e6e6;
198
- font-weight: normal;
199
- color: #555555;
200
  }
 
201
  .ui-state-default a,
202
  .ui-state-default a:link,
203
  .ui-state-default a:visited {
204
- color: #555555;
205
- text-decoration: none;
206
  }
 
207
  .ui-state-hover,
208
  .ui-widget-content .ui-state-hover,
209
  .ui-widget-header .ui-state-hover,
210
  .ui-state-focus,
211
  .ui-widget-content .ui-state-focus,
212
  .ui-widget-header .ui-state-focus {
213
- border: 1px solid #999999;
214
- background: #dadada;
215
- font-weight: normal;
216
- color: #212121;
217
  }
 
218
  .ui-state-hover a,
219
  .ui-state-hover a:hover,
220
  .ui-state-hover a:link,
@@ -223,22 +250,24 @@
223
  .ui-state-focus a:hover,
224
  .ui-state-focus a:link,
225
  .ui-state-focus a:visited {
226
- color: #212121;
227
- text-decoration: none;
228
  }
 
229
  .ui-state-active,
230
  .ui-widget-content .ui-state-active,
231
  .ui-widget-header .ui-state-active {
232
- border: 1px solid #aaaaaa;
233
- background: #ffffff;
234
- font-weight: normal;
235
- color: #212121;
236
  }
 
237
  .ui-state-active a,
238
  .ui-state-active a:link,
239
  .ui-state-active a:visited {
240
- color: #212121;
241
- text-decoration: none;
242
  }
243
 
244
  /* Interaction Cues
@@ -246,53 +275,61 @@
246
  .ui-state-highlight,
247
  .ui-widget-content .ui-state-highlight,
248
  .ui-widget-header .ui-state-highlight {
249
- border: 1px solid #fcefa1;
250
- background: #fbf9ee;
251
- color: #363636;
252
  }
 
253
  .ui-state-highlight a,
254
  .ui-widget-content .ui-state-highlight a,
255
  .ui-widget-header .ui-state-highlight a {
256
- color: #363636;
257
  }
 
258
  .ui-state-error,
259
  .ui-widget-content .ui-state-error,
260
  .ui-widget-header .ui-state-error {
261
- border: 1px solid #cd0a0a;
262
- background: #fef1ec;
263
- color: #cd0a0a;
264
  }
 
265
  .ui-state-error a,
266
  .ui-widget-content .ui-state-error a,
267
  .ui-widget-header .ui-state-error a {
268
- color: #cd0a0a;
269
  }
 
270
  .ui-state-error-text,
271
  .ui-widget-content .ui-state-error-text,
272
  .ui-widget-header .ui-state-error-text {
273
- color: #cd0a0a;
274
  }
 
275
  .ui-priority-primary,
276
  .ui-widget-content .ui-priority-primary,
277
  .ui-widget-header .ui-priority-primary {
278
- font-weight: bold;
279
  }
 
280
  .ui-priority-secondary,
281
  .ui-widget-content .ui-priority-secondary,
282
  .ui-widget-header .ui-priority-secondary {
283
- opacity: .7;
284
- filter:Alpha(Opacity=70);
285
- font-weight: normal;
286
  }
 
287
  .ui-state-disabled,
288
  .ui-widget-content .ui-state-disabled,
289
  .ui-widget-header .ui-state-disabled {
290
- opacity: .35;
291
- filter:Alpha(Opacity=35);
292
- background-image: none;
293
  }
 
294
  .ui-state-disabled .ui-icon {
295
- filter:Alpha(Opacity=35); /* For IE8 - See #6059 */
296
  }
297
 
298
  /* Misc visuals
@@ -303,38 +340,42 @@
303
  .ui-corner-top,
304
  .ui-corner-left,
305
  .ui-corner-tl {
306
- border-top-left-radius: 0px;
307
  }
 
308
  .ui-corner-all,
309
  .ui-corner-top,
310
  .ui-corner-right,
311
  .ui-corner-tr {
312
- border-top-right-radius: 0px;
313
  }
 
314
  .ui-corner-all,
315
  .ui-corner-bottom,
316
  .ui-corner-left,
317
  .ui-corner-bl {
318
- border-bottom-left-radius: 0px;
319
  }
 
320
  .ui-corner-all,
321
  .ui-corner-bottom,
322
  .ui-corner-right,
323
  .ui-corner-br {
324
- border-bottom-right-radius: 0px;
325
  }
326
 
327
  /* Overlays */
328
  .ui-widget-overlay {
329
- background: #aaaaaa;
330
- opacity: .3;
331
- filter: Alpha(Opacity=30);
332
  }
 
333
  .ui-widget-shadow {
334
- margin: -8px 0 0 -8px;
335
- padding: 8px;
336
- background: #aaaaaa;
337
- opacity: .3;
338
- filter: Alpha(Opacity=30);
339
- border-radius: 8px;
340
  }
7
  /* Layout helpers
8
  ----------------------------------*/
9
  .ui-helper-hidden {
10
+ display: none;
11
  }
12
+
13
  .ui-helper-hidden-accessible {
14
+ border: 0;
15
+ clip: rect(0 0 0 0);
16
+ height: 1px;
17
+ margin: -1px;
18
+ overflow: hidden;
19
+ padding: 0;
20
+ position: absolute;
21
+ width: 1px;
22
  }
23
+
24
  .ui-helper-reset {
25
+ margin: 0;
26
+ padding: 0;
27
+ border: 0;
28
+ outline: 0;
29
+ line-height: 1.3;
30
+ text-decoration: none;
31
+ font-size: 100%;
32
+ list-style: none;
33
  }
34
+
35
  .ui-helper-clearfix:before,
36
  .ui-helper-clearfix:after {
37
+ content: "";
38
+ display: table;
39
+ border-collapse: collapse;
40
  }
41
+
42
  .ui-helper-clearfix:after {
43
+ clear: both;
44
  }
45
+
46
  .ui-helper-clearfix {
47
+ min-height: 0; /* support: IE7 */
48
  }
49
+
50
  .ui-helper-zfix {
51
+ width: 100%;
52
+ height: 100%;
53
+ top: 0;
54
+ left: 0;
55
+ position: absolute;
56
+ opacity: 0;
57
+ filter: Alpha(Opacity=0);
58
  }
59
 
60
  .ui-front {
61
+ z-index: 100;
62
  }
63
 
 
64
  /* Interaction Cues
65
  ----------------------------------*/
66
  .ui-state-disabled {
67
+ cursor: default !important;
68
  }
69
 
 
70
  /* Icons
71
  ----------------------------------*/
72
 
73
  /* states and images */
74
  .ui-icon {
75
+ display: block;
76
+ text-indent: -99999px;
77
+ overflow: hidden;
78
+ background-repeat: no-repeat;
79
  }
80
 
 
81
  /* Misc visuals
82
  ----------------------------------*/
83
 
84
  /* Overlays */
85
  .ui-widget-overlay {
86
+ position: fixed;
87
+ top: 0;
88
+ left: 0;
89
+ width: 100%;
90
+ height: 100%;
91
  }
92
+
93
  .ui-progressbar {
94
+ height: 2em;
95
+ text-align: left;
96
+ overflow: hidden;
97
  }
98
+
99
  .ui-progressbar .ui-progressbar-value {
100
+ margin: -1px;
101
+ height: 100%;
102
  }
103
+
104
  .ui-progressbar .ui-progressbar-overlay {
105
+ background: url("images/animated-overlay.gif");
106
+ height: 100%;
107
+ filter: alpha(opacity=25);
108
+ opacity: 0.25;
109
  }
110
+
111
  .ui-progressbar-indeterminate .ui-progressbar-value {
112
+ background-image: none;
113
  }
114
 
115
+ #tabs {
116
+ border: none;
117
+ padding: 0px;
118
+ margin: 0px;
119
+ }
120
 
121
  .ui-tabs {
122
+ position: relative; /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
123
+ padding: .2em;
124
  }
125
+
126
  .ui-tabs .ui-tabs-nav {
127
+ margin: 0;
128
+ padding: .2em .2em 0;
129
  }
130
+
131
  .ui-tabs .ui-tabs-nav li {
132
+ list-style: none;
133
+ float: left;
134
+ position: relative;
135
+ top: 0;
136
+ margin: 1px .2em 0 0;
137
+ margin-right: 10px;
138
+ border-bottom-width: 0;
139
+ padding: 0;
140
+ white-space: nowrap;
141
  }
142
+
143
  .ui-tabs .ui-tabs-nav .ui-tabs-anchor {
144
+ float: left;
145
+ padding: .5em 1em;
146
+ text-decoration: none;
147
  }
148
+
149
  .ui-tabs .ui-tabs-nav li.ui-tabs-active {
150
+ margin-bottom: -1px;
151
+ padding-bottom: 1px;
152
+ margin-right: 10px;
153
  }
154
+
155
  .ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
156
  .ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
157
  .ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
158
+ cursor: text;
159
  }
160
+
161
  .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
162
+ cursor: pointer;
163
  }
164
+
165
  .ui-tabs .ui-tabs-panel {
166
+ display: block;
167
+ border-width: 0;
168
+ padding: 1em 1.4em;
169
+ background: none;
170
  }
171
 
172
  /* Component containers
173
  ----------------------------------*/
174
  .ui-widget {
175
+ font-family: Verdana, Arial, sans-serif;
176
+ font-size: 1.1em;
177
  }
178
+
179
  .ui-widget .ui-widget {
180
+ font-size: 1em;
181
  }
182
+
183
  .ui-widget input,
184
  .ui-widget select,
185
  .ui-widget textarea,
186
  .ui-widget button {
187
+ font-family: Verdana, Arial, sans-serif;
188
+ font-size: 1em;
189
  }
190
+
191
  .ui-widget-content {
192
+ border: 1px solid #aaaaaa;
193
+ background: transparent;
194
+ color: #222222;
195
  }
196
+
197
  .ui-widget-content a {
198
+ color: #222222;
199
  }
200
+
201
  .ui-widget-header {
202
+ border-left: none;
203
+ border-top: none;
204
+ border-right: none;
205
+ border-bottom: 1px solid #aaaaaa;
206
+ background: transparent;
207
+ color: #222222;
208
+ font-weight: bold;
209
  }
210
+
211
  .ui-widget-header a {
212
+ color: #222222;
213
  }
214
 
215
  /* Interaction states
217
  .ui-state-default,
218
  .ui-widget-content .ui-state-default,
219
  .ui-widget-header .ui-state-default {
220
+ border: 1px solid #d3d3d3;
221
+ background: #e6e6e6;
222
+ font-weight: normal;
223
+ color: #555555;
224
  }
225
+
226
  .ui-state-default a,
227
  .ui-state-default a:link,
228
  .ui-state-default a:visited {
229
+ color: #555555;
230
+ text-decoration: none;
231
  }
232
+
233
  .ui-state-hover,
234
  .ui-widget-content .ui-state-hover,
235
  .ui-widget-header .ui-state-hover,
236
  .ui-state-focus,
237
  .ui-widget-content .ui-state-focus,
238
  .ui-widget-header .ui-state-focus {
239
+ border: 1px solid #999999;
240
+ background: #dadada;
241
+ font-weight: normal;
242
+ color: #212121;
243
  }
244
+
245
  .ui-state-hover a,
246
  .ui-state-hover a:hover,
247
  .ui-state-hover a:link,
250
  .ui-state-focus a:hover,
251
  .ui-state-focus a:link,
252
  .ui-state-focus a:visited {
253
+ color: #212121;
254
+ text-decoration: none;
255
  }
256
+
257
  .ui-state-active,
258
  .ui-widget-content .ui-state-active,
259
  .ui-widget-header .ui-state-active {
260
+ border: 1px solid #aaaaaa;
261
+ background: #ffffff;
262
+ font-weight: normal;
263
+ color: #212121;
264
  }
265
+
266
  .ui-state-active a,
267
  .ui-state-active a:link,
268
  .ui-state-active a:visited {
269
+ color: #212121;
270
+ text-decoration: none;
271
  }
272
 
273
  /* Interaction Cues
275
  .ui-state-highlight,
276
  .ui-widget-content .ui-state-highlight,
277
  .ui-widget-header .ui-state-highlight {
278
+ border: 1px solid #fcefa1;
279
+ background: #fbf9ee;
280
+ color: #363636;
281
  }
282
+
283
  .ui-state-highlight a,
284
  .ui-widget-content .ui-state-highlight a,
285
  .ui-widget-header .ui-state-highlight a {
286
+ color: #363636;
287
  }
288
+
289
  .ui-state-error,
290
  .ui-widget-content .ui-state-error,
291
  .ui-widget-header .ui-state-error {
292
+ border: 1px solid #cd0a0a;
293
+ background: #fef1ec;
294
+ color: #cd0a0a;
295
  }
296
+
297
  .ui-state-error a,
298
  .ui-widget-content .ui-state-error a,
299
  .ui-widget-header .ui-state-error a {
300
+ color: #cd0a0a;
301
  }
302
+
303
  .ui-state-error-text,
304
  .ui-widget-content .ui-state-error-text,
305
  .ui-widget-header .ui-state-error-text {
306
+ color: #cd0a0a;
307
  }
308
+
309
  .ui-priority-primary,
310
  .ui-widget-content .ui-priority-primary,
311
  .ui-widget-header .ui-priority-primary {
312
+ font-weight: bold;
313
  }
314
+
315
  .ui-priority-secondary,
316
  .ui-widget-content .ui-priority-secondary,
317
  .ui-widget-header .ui-priority-secondary {
318
+ opacity: .7;
319
+ filter: Alpha(Opacity=70);
320
+ font-weight: normal;
321
  }
322
+
323
  .ui-state-disabled,
324
  .ui-widget-content .ui-state-disabled,
325
  .ui-widget-header .ui-state-disabled {
326
+ opacity: .35;
327
+ filter: Alpha(Opacity=35);
328
+ background-image: none;
329
  }
330
+
331
  .ui-state-disabled .ui-icon {
332
+ filter: Alpha(Opacity=35); /* For IE8 - See #6059 */
333
  }
334
 
335
  /* Misc visuals
340
  .ui-corner-top,
341
  .ui-corner-left,
342
  .ui-corner-tl {
343
+ border-top-left-radius: 0px;
344
  }
345
+
346
  .ui-corner-all,
347
  .ui-corner-top,
348
  .ui-corner-right,
349
  .ui-corner-tr {
350
+ border-top-right-radius: 0px;
351
  }
352
+
353
  .ui-corner-all,
354
  .ui-corner-bottom,
355
  .ui-corner-left,
356
  .ui-corner-bl {
357
+ border-bottom-left-radius: 0px;
358
  }
359
+
360
  .ui-corner-all,
361
  .ui-corner-bottom,
362
  .ui-corner-right,
363
  .ui-corner-br {
364
+ border-bottom-right-radius: 0px;
365
  }
366
 
367
  /* Overlays */
368
  .ui-widget-overlay {
369
+ background: #aaaaaa;
370
+ opacity: .3;
371
+ filter: Alpha(Opacity=30);
372
  }
373
+
374
  .ui-widget-shadow {
375
+ margin: -8px 0 0 -8px;
376
+ padding: 8px;
377
+ background: #aaaaaa;
378
+ opacity: .3;
379
+ filter: Alpha(Opacity=30);
380
+ border-radius: 8px;
381
  }
assets/css/jquery-ui-smoothness.css CHANGED
@@ -7,178 +7,199 @@
7
  /* Layout helpers
8
  ----------------------------------*/
9
  .ui-helper-hidden {
10
- display: none;
11
  }
 
12
  .ui-helper-hidden-accessible {
13
- border: 0;
14
- clip: rect(0 0 0 0);
15
- height: 1px;
16
- margin: -1px;
17
- overflow: hidden;
18
- padding: 0;
19
- position: absolute;
20
- width: 1px;
21
  }
 
22
  .ui-helper-reset {
23
- margin: 0;
24
- padding: 0;
25
- border: 0;
26
- outline: 0;
27
- line-height: 1.3;
28
- text-decoration: none;
29
- font-size: 100%;
30
- list-style: none;
31
  }
 
32
  .ui-helper-clearfix:before,
33
  .ui-helper-clearfix:after {
34
- content: "";
35
- display: table;
36
- border-collapse: collapse;
37
  }
 
38
  .ui-helper-clearfix:after {
39
- clear: both;
40
  }
 
41
  .ui-helper-clearfix {
42
- min-height: 0; /* support: IE7 */
43
  }
 
44
  .ui-helper-zfix {
45
- width: 100%;
46
- height: 100%;
47
- top: 0;
48
- left: 0;
49
- position: absolute;
50
- opacity: 0;
51
- filter:Alpha(Opacity=0); /* support: IE8 */
52
  }
53
 
54
  .ui-front {
55
- z-index: 100;
56
  }
57
 
58
-
59
  /* Interaction Cues
60
  ----------------------------------*/
61
  .ui-state-disabled {
62
- cursor: default !important;
63
  }
64
 
65
-
66
  /* Icons
67
  ----------------------------------*/
68
 
69
  /* states and images */
70
  .ui-icon {
71
- display: block;
72
- text-indent: -99999px;
73
- overflow: hidden;
74
- background-repeat: no-repeat;
75
  }
76
 
77
-
78
  /* Misc visuals
79
  ----------------------------------*/
80
 
81
  /* Overlays */
82
  .ui-widget-overlay {
83
- position: fixed;
84
- top: 0;
85
- left: 0;
86
- width: 100%;
87
- height: 100%;
88
  }
 
89
  .ui-accordion .ui-accordion-header {
90
- display: block;
91
- cursor: pointer;
92
- position: relative;
93
- margin: 2px 0 0 0;
94
- padding: .5em .5em .5em .7em;
95
- min-height: 0; /* support: IE7 */
96
- font-size: 100%;
97
  }
 
98
  .ui-accordion .ui-accordion-icons {
99
- padding-left: 2.2em;
100
  }
 
101
  .ui-accordion .ui-accordion-icons .ui-accordion-icons {
102
- padding-left: 2.2em;
103
  }
 
104
  .ui-accordion .ui-accordion-header .ui-accordion-header-icon {
105
- position: absolute;
106
- left: .5em;
107
- top: 50%;
108
- margin-top: -8px;
109
  }
 
110
  .ui-accordion .ui-accordion-content {
111
- padding: 1em 2.2em;
112
- border-top: 0;
113
- overflow: auto;
114
  }
 
115
  .ui-autocomplete {
116
- position: absolute;
117
- top: 0;
118
- left: 0;
119
- cursor: default;
120
  }
 
121
  .ui-button {
122
- display: inline-block;
123
- position: relative;
124
- padding: 0;
125
- line-height: normal;
126
- margin-right: .1em;
127
- cursor: pointer;
128
- vertical-align: middle;
129
- text-align: center;
130
- overflow: visible; /* removes extra width in IE */
131
  }
 
132
  .ui-button,
133
  .ui-button:link,
134
  .ui-button:visited,
135
  .ui-button:hover,
136
  .ui-button:active {
137
- text-decoration: none;
138
  }
 
139
  /* to make room for the icon, a width needs to be set here */
140
  .ui-button-icon-only {
141
- width: 2.2em;
142
  }
 
143
  /* button elements seem to need a little more width */
144
  button.ui-button-icon-only {
145
- width: 2.4em;
146
  }
 
147
  .ui-button-icons-only {
148
- width: 3.4em;
149
  }
 
150
  button.ui-button-icons-only {
151
- width: 3.7em;
152
  }
153
 
154
  /* button text element */
155
  .ui-button .ui-button-text {
156
- display: block;
157
- line-height: normal;
158
  }
 
159
  .ui-button-text-only .ui-button-text {
160
- padding: .4em 1em;
161
  }
 
162
  .ui-button-icon-only .ui-button-text,
163
  .ui-button-icons-only .ui-button-text {
164
- padding: .4em;
165
- text-indent: -9999999px;
166
  }
 
167
  .ui-button-text-icon-primary .ui-button-text,
168
  .ui-button-text-icons .ui-button-text {
169
- padding: .4em 1em .4em 2.1em;
170
  }
 
171
  .ui-button-text-icon-secondary .ui-button-text,
172
  .ui-button-text-icons .ui-button-text {
173
- padding: .4em 2.1em .4em 1em;
174
  }
 
175
  .ui-button-text-icons .ui-button-text {
176
- padding-left: 2.1em;
177
- padding-right: 2.1em;
178
  }
 
179
  /* no icon support for input elements, provide padding by default */
180
  input.ui-button {
181
- padding: .4em 1em;
182
  }
183
 
184
  /* button icon element(s) */
@@ -187,678 +208,793 @@ input.ui-button {
187
  .ui-button-text-icon-secondary .ui-icon,
188
  .ui-button-text-icons .ui-icon,
189
  .ui-button-icons-only .ui-icon {
190
- position: absolute;
191
- top: 50%;
192
- margin-top: -8px;
193
  }
 
194
  .ui-button-icon-only .ui-icon {
195
- left: 50%;
196
- margin-left: -8px;
197
  }
 
198
  .ui-button-text-icon-primary .ui-button-icon-primary,
199
  .ui-button-text-icons .ui-button-icon-primary,
200
  .ui-button-icons-only .ui-button-icon-primary {
201
- left: .5em;
202
  }
 
203
  .ui-button-text-icon-secondary .ui-button-icon-secondary,
204
  .ui-button-text-icons .ui-button-icon-secondary,
205
  .ui-button-icons-only .ui-button-icon-secondary {
206
- right: .5em;
207
  }
208
 
209
  /* button sets */
210
  .ui-buttonset {
211
- margin-right: 7px;
212
  }
 
213
  .ui-buttonset .ui-button {
214
- margin-left: 0;
215
- margin-right: -.3em;
216
  }
217
 
218
  /* workarounds */
219
  /* reset extra padding in Firefox, see h5bp.com/l */
220
  input.ui-button::-moz-focus-inner,
221
  button.ui-button::-moz-focus-inner {
222
- border: 0;
223
- padding: 0;
224
  }
 
225
  .ui-datepicker {
226
- width: 17em;
227
- padding: .2em .2em 0;
228
- display: none;
229
  }
 
230
  .ui-datepicker .ui-datepicker-header {
231
- position: relative;
232
- padding: .2em 0;
233
  }
 
234
  .ui-datepicker .ui-datepicker-prev,
235
  .ui-datepicker .ui-datepicker-next {
236
- position: absolute;
237
- top: 2px;
238
- width: 1.8em;
239
- height: 1.8em;
240
  }
 
241
  .ui-datepicker .ui-datepicker-prev-hover,
242
  .ui-datepicker .ui-datepicker-next-hover {
243
- top: 1px;
244
  }
 
245
  .ui-datepicker .ui-datepicker-prev {
246
- left: 2px;
247
  }
 
248
  .ui-datepicker .ui-datepicker-next {
249
- right: 2px;
250
  }
 
251
  .ui-datepicker .ui-datepicker-prev-hover {
252
- left: 1px;
253
  }
 
254
  .ui-datepicker .ui-datepicker-next-hover {
255
- right: 1px;
256
  }
 
257
  .ui-datepicker .ui-datepicker-prev span,
258
  .ui-datepicker .ui-datepicker-next span {
259
- display: block;
260
- position: absolute;
261
- left: 50%;
262
- margin-left: -8px;
263
- top: 50%;
264
- margin-top: -8px;
265
  }
 
266
  .ui-datepicker .ui-datepicker-title {
267
- margin: 0 2.3em;
268
- line-height: 1.8em;
269
- text-align: center;
270
  }
 
271
  .ui-datepicker .ui-datepicker-title select {
272
- font-size: 1em;
273
- margin: 1px 0;
274
  }
 
275
  .ui-datepicker select.ui-datepicker-month,
276
  .ui-datepicker select.ui-datepicker-year {
277
- width: 45%;
278
  }
 
279
  .ui-datepicker table {
280
- width: 100%;
281
- font-size: .9em;
282
- border-collapse: collapse;
283
- margin: 0 0 .4em;
284
  }
 
285
  .ui-datepicker th {
286
- padding: .7em .3em;
287
- text-align: center;
288
- font-weight: bold;
289
- border: 0;
290
  }
 
291
  .ui-datepicker td {
292
- border: 0;
293
- padding: 1px;
294
  }
 
295
  .ui-datepicker td span,
296
  .ui-datepicker td a {
297
- display: block;
298
- padding: .2em;
299
- text-align: right;
300
- text-decoration: none;
301
  }
 
302
  .ui-datepicker .ui-datepicker-buttonpane {
303
- background-image: none;
304
- margin: .7em 0 0 0;
305
- padding: 0 .2em;
306
- border-left: 0;
307
- border-right: 0;
308
- border-bottom: 0;
309
  }
 
310
  .ui-datepicker .ui-datepicker-buttonpane button {
311
- float: right;
312
- margin: .5em .2em .4em;
313
- cursor: pointer;
314
- padding: .2em .6em .3em .6em;
315
- width: auto;
316
- overflow: visible;
317
  }
 
318
  .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current {
319
- float: left;
320
  }
321
 
322
  /* with multiple calendars */
323
  .ui-datepicker.ui-datepicker-multi {
324
- width: auto;
325
  }
 
326
  .ui-datepicker-multi .ui-datepicker-group {
327
- float: left;
328
  }
 
329
  .ui-datepicker-multi .ui-datepicker-group table {
330
- width: 95%;
331
- margin: 0 auto .4em;
332
  }
 
333
  .ui-datepicker-multi-2 .ui-datepicker-group {
334
- width: 50%;
335
  }
 
336
  .ui-datepicker-multi-3 .ui-datepicker-group {
337
- width: 33.3%;
338
  }
 
339
  .ui-datepicker-multi-4 .ui-datepicker-group {
340
- width: 25%;
341
  }
 
342
  .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,
343
  .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header {
344
- border-left-width: 0;
345
  }
 
346
  .ui-datepicker-multi .ui-datepicker-buttonpane {
347
- clear: left;
348
  }
 
349
  .ui-datepicker-row-break {
350
- clear: both;
351
- width: 100%;
352
- font-size: 0;
353
  }
354
 
355
  /* RTL support */
356
  .ui-datepicker-rtl {
357
- direction: rtl;
358
  }
 
359
  .ui-datepicker-rtl .ui-datepicker-prev {
360
- right: 2px;
361
- left: auto;
362
  }
 
363
  .ui-datepicker-rtl .ui-datepicker-next {
364
- left: 2px;
365
- right: auto;
366
  }
 
367
  .ui-datepicker-rtl .ui-datepicker-prev:hover {
368
- right: 1px;
369
- left: auto;
370
  }
 
371
  .ui-datepicker-rtl .ui-datepicker-next:hover {
372
- left: 1px;
373
- right: auto;
374
  }
 
375
  .ui-datepicker-rtl .ui-datepicker-buttonpane {
376
- clear: right;
377
  }
 
378
  .ui-datepicker-rtl .ui-datepicker-buttonpane button {
379
- float: left;
380
  }
 
381
  .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,
382
  .ui-datepicker-rtl .ui-datepicker-group {
383
- float: right;
384
  }
 
385
  .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,
386
  .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header {
387
- border-right-width: 0;
388
- border-left-width: 1px;
389
  }
 
390
  .ui-dialog {
391
- overflow: hidden;
392
- position: absolute;
393
- top: 0;
394
- left: 0;
395
- padding: .2em;
396
- outline: 0;
397
  }
 
398
  .ui-dialog .ui-dialog-titlebar {
399
- padding: .4em 1em;
400
- position: relative;
401
  }
 
402
  .ui-dialog .ui-dialog-title {
403
- float: left;
404
- margin: .1em 0;
405
- white-space: nowrap;
406
- width: 90%;
407
- overflow: hidden;
408
- text-overflow: ellipsis;
409
  }
 
410
  .ui-dialog .ui-dialog-titlebar-close {
411
- position: absolute;
412
- right: .3em;
413
- top: 50%;
414
- width: 20px;
415
- margin: -10px 0 0 0;
416
- padding: 1px;
417
- height: 20px;
418
  }
 
419
  .ui-dialog .ui-dialog-content {
420
- position: relative;
421
- border: 0;
422
- padding: .5em 1em;
423
- background: none;
424
- overflow: auto;
425
  }
 
426
  .ui-dialog .ui-dialog-buttonpane {
427
- text-align: left;
428
- border-width: 1px 0 0 0;
429
- background-image: none;
430
- margin-top: .5em;
431
- padding: .3em 1em .5em .4em;
432
  }
 
433
  .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
434
- float: right;
435
  }
 
436
  .ui-dialog .ui-dialog-buttonpane button {
437
- margin: .5em .4em .5em 0;
438
- cursor: pointer;
439
  }
 
440
  .ui-dialog .ui-resizable-se {
441
- width: 12px;
442
- height: 12px;
443
- right: -5px;
444
- bottom: -5px;
445
- background-position: 16px 16px;
446
  }
 
447
  .ui-draggable .ui-dialog-titlebar {
448
- cursor: move;
449
  }
 
450
  .ui-draggable-handle {
451
- -ms-touch-action: none;
452
- touch-action: none;
453
  }
 
454
  .ui-menu {
455
- list-style: none;
456
- padding: 0;
457
- margin: 0;
458
- display: block;
459
- outline: none;
460
  }
 
461
  .ui-menu .ui-menu {
462
- position: absolute;
463
  }
 
464
  .ui-menu .ui-menu-item {
465
- position: relative;
466
- margin: 0;
467
- padding: 3px 1em 3px .4em;
468
- cursor: pointer;
469
- min-height: 0; /* support: IE7 */
470
- /* support: IE10, see #8844 */
471
- list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
472
  }
 
473
  .ui-menu .ui-menu-divider {
474
- margin: 5px 0;
475
- height: 0;
476
- font-size: 0;
477
- line-height: 0;
478
- border-width: 1px 0 0 0;
479
  }
 
480
  .ui-menu .ui-state-focus,
481
  .ui-menu .ui-state-active {
482
- margin: -1px;
483
  }
484
 
485
  /* icon support */
486
  .ui-menu-icons {
487
- position: relative;
488
  }
 
489
  .ui-menu-icons .ui-menu-item {
490
- padding-left: 2em;
491
  }
492
 
493
  /* left-aligned */
494
  .ui-menu .ui-icon {
495
- position: absolute;
496
- top: 0;
497
- bottom: 0;
498
- left: .2em;
499
- margin: auto 0;
500
  }
501
 
502
  /* right-aligned */
503
  .ui-menu .ui-menu-icon {
504
- left: auto;
505
- right: 0;
506
  }
 
507
  .ui-progressbar {
508
- height: 2em;
509
- text-align: left;
510
- overflow: hidden;
511
  }
 
512
  .ui-progressbar .ui-progressbar-value {
513
- margin: -1px;
514
- height: 100%;
515
  }
 
516
  .ui-progressbar .ui-progressbar-overlay {
517
- background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw==");
518
- height: 100%;
519
- filter: alpha(opacity=25); /* support: IE8 */
520
- opacity: 0.25;
521
  }
 
522
  .ui-progressbar-indeterminate .ui-progressbar-value {
523
- background-image: none;
524
  }
 
525
  .ui-resizable {
526
- position: relative;
527
  }
 
528
  .ui-resizable-handle {
529
- position: absolute;
530
- font-size: 0.1px;
531
- display: block;
532
- -ms-touch-action: none;
533
- touch-action: none;
534
  }
 
535
  .ui-resizable-disabled .ui-resizable-handle,
536
  .ui-resizable-autohide .ui-resizable-handle {
537
- display: none;
538
  }
 
539
  .ui-resizable-n {
540
- cursor: n-resize;
541
- height: 7px;
542
- width: 100%;
543
- top: -5px;
544
- left: 0;
545
  }
 
546
  .ui-resizable-s {
547
- cursor: s-resize;
548
- height: 7px;
549
- width: 100%;
550
- bottom: -5px;
551
- left: 0;
552
  }
 
553
  .ui-resizable-e {
554
- cursor: e-resize;
555
- width: 7px;
556
- right: -5px;
557
- top: 0;
558
- height: 100%;
559
  }
 
560
  .ui-resizable-w {
561
- cursor: w-resize;
562
- width: 7px;
563
- left: -5px;
564
- top: 0;
565
- height: 100%;
566
  }
 
567
  .ui-resizable-se {
568
- cursor: se-resize;
569
- width: 12px;
570
- height: 12px;
571
- right: 1px;
572
- bottom: 1px;
573
  }
 
574
  .ui-resizable-sw {
575
- cursor: sw-resize;
576
- width: 9px;
577
- height: 9px;
578
- left: -5px;
579
- bottom: -5px;
580
  }
 
581
  .ui-resizable-nw {
582
- cursor: nw-resize;
583
- width: 9px;
584
- height: 9px;
585
- left: -5px;
586
- top: -5px;
587
  }
 
588
  .ui-resizable-ne {
589
- cursor: ne-resize;
590
- width: 9px;
591
- height: 9px;
592
- right: -5px;
593
- top: -5px;
594
  }
 
595
  .ui-selectable {
596
- -ms-touch-action: none;
597
- touch-action: none;
598
  }
 
599
  .ui-selectable-helper {
600
- position: absolute;
601
- z-index: 100;
602
- border: 1px dotted black;
603
  }
 
604
  .ui-selectmenu-menu {
605
- padding: 0;
606
- margin: 0;
607
- position: absolute;
608
- top: 0;
609
- left: 0;
610
- display: none;
611
  }
 
612
  .ui-selectmenu-menu .ui-menu {
613
- overflow: auto;
614
- /* Support: IE7 */
615
- overflow-x: hidden;
616
- padding-bottom: 1px;
617
  }
 
618
  .ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup {
619
- font-size: 1em;
620
- font-weight: bold;
621
- line-height: 1.5;
622
- padding: 2px 0.4em;
623
- margin: 0.5em 0 0 0;
624
- height: auto;
625
- border: 0;
626
  }
 
627
  .ui-selectmenu-open {
628
- display: block;
629
  }
 
630
  .ui-selectmenu-button {
631
- display: inline-block;
632
- overflow: hidden;
633
- position: relative;
634
- text-decoration: none;
635
- cursor: pointer;
636
  }
 
637
  .ui-selectmenu-button span.ui-icon {
638
- right: 0.5em;
639
- left: auto;
640
- margin-top: -8px;
641
- position: absolute;
642
- top: 50%;
643
  }
 
644
  .ui-selectmenu-button span.ui-selectmenu-text {
645
- text-align: left;
646
- padding: 0.4em 2.1em 0.4em 1em;
647
- display: block;
648
- line-height: 1.4;
649
- overflow: hidden;
650
- text-overflow: ellipsis;
651
- white-space: nowrap;
652
  }
 
653
  .ui-slider {
654
- position: relative;
655
- text-align: left;
656
  }
 
657
  .ui-slider .ui-slider-handle {
658
- position: absolute;
659
- z-index: 2;
660
- width: 1.2em;
661
- height: 1.2em;
662
- cursor: default;
663
- -ms-touch-action: none;
664
- touch-action: none;
665
  }
 
666
  .ui-slider .ui-slider-range {
667
- position: absolute;
668
- z-index: 1;
669
- font-size: .7em;
670
- display: block;
671
- border: 0;
672
- background-position: 0 0;
673
  }
674
 
675
  /* support: IE8 - See #6727 */
676
  .ui-slider.ui-state-disabled .ui-slider-handle,
677
  .ui-slider.ui-state-disabled .ui-slider-range {
678
- filter: inherit;
679
  }
680
 
681
  .ui-slider-horizontal {
682
- height: .8em;
683
  }
 
684
  .ui-slider-horizontal .ui-slider-handle {
685
- top: -.3em;
686
- margin-left: -.6em;
687
  }
 
688
  .ui-slider-horizontal .ui-slider-range {
689
- top: 0;
690
- height: 100%;
691
  }
 
692
  .ui-slider-horizontal .ui-slider-range-min {
693
- left: 0;
694
  }
 
695
  .ui-slider-horizontal .ui-slider-range-max {
696
- right: 0;
697
  }
698
 
699
  .ui-slider-vertical {
700
- width: .8em;
701
- height: 100px;
702
  }
 
703
  .ui-slider-vertical .ui-slider-handle {
704
- left: -.3em;
705
- margin-left: 0;
706
- margin-bottom: -.6em;
707
  }
 
708
  .ui-slider-vertical .ui-slider-range {
709
- left: 0;
710
- width: 100%;
711
  }
 
712
  .ui-slider-vertical .ui-slider-range-min {
713
- bottom: 0;
714
  }
 
715
  .ui-slider-vertical .ui-slider-range-max {
716
- top: 0;
717
  }
 
718
  .ui-sortable-handle {
719
- -ms-touch-action: none;
720
- touch-action: none;
721
  }
 
722
  .ui-spinner {
723
- position: relative;
724
- display: inline-block;
725
- overflow: hidden;
726
- padding: 0;
727
- vertical-align: middle;
728
  }
 
729
  .ui-spinner-input {
730
- border: none;
731
- background: none;
732
- color: inherit;
733
- padding: 0;
734
- margin: .2em 0;
735
- vertical-align: middle;
736
- margin-left: .4em;
737
- margin-right: 22px;
738
  }
 
739
  .ui-spinner-button {
740
- width: 16px;
741
- height: 50%;
742
- font-size: .5em;
743
- padding: 0;
744
- margin: 0;
745
- text-align: center;
746
- position: absolute;
747
- cursor: default;
748
- display: block;
749
- overflow: hidden;
750
- right: 0;
751
  }
 
752
  /* more specificity required here to override default borders */
753
  .ui-spinner a.ui-spinner-button {
754
- border-top: none;
755
- border-bottom: none;
756
- border-right: none;
757
  }
 
758
  /* vertically center icon */
759
  .ui-spinner .ui-icon {
760
- position: absolute;
761
- margin-top: -8px;
762
- top: 50%;
763
- left: 0;
764
  }
 
765
  .ui-spinner-up {
766
- top: 0;
767
  }
 
768
  .ui-spinner-down {
769
- bottom: 0;
770
  }
771
 
772
  /* TR overrides */
773
  .ui-spinner .ui-icon-triangle-1-s {
774
- /* need to fix icons sprite */
775
- background-position: -65px -16px;
776
  }
 
777
  .ui-tabs {
778
- position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
779
- padding: .2em;
780
  }
 
781
  .ui-tabs .ui-tabs-nav {
782
- margin: 0;
783
- padding: .2em .2em 0;
784
  }
 
785
  .ui-tabs .ui-tabs-nav li {
786
- list-style: none;
787
- float: left;
788
- position: relative;
789
- top: 0;
790
- margin: 1px .2em 0 0;
791
- border-bottom-width: 0;
792
- padding: 0;
793
- white-space: nowrap;
794
  }
 
795
  .ui-tabs .ui-tabs-nav .ui-tabs-anchor {
796
- float: left;
797
- padding: .5em 1em;
798
- text-decoration: none;
799
  }
 
800
  .ui-tabs .ui-tabs-nav li.ui-tabs-active {
801
- margin-bottom: -1px;
802
- padding-bottom: 1px;
803
  }
 
804
  .ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
805
  .ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
806
  .ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
807
- cursor: text;
808
  }
 
809
  .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
810
- cursor: pointer;
811
  }
 
812
  .ui-tabs .ui-tabs-panel {
813
- display: block;
814
- border-width: 0;
815
- padding: 1em 1.4em;
816
- background: none;
817
  }
 
818
  .ui-tooltip {
819
- padding: 8px;
820
- position: absolute;
821
- z-index: 9999;
822
- max-width: 300px;
823
- -webkit-box-shadow: 0 0 5px #aaa;
824
- box-shadow: 0 0 5px #aaa;
825
  }
 
826
  body .ui-tooltip {
827
- border-width: 2px;
828
  }
829
 
830
  /* Component containers
831
  ----------------------------------*/
832
  .ui-widget {
833
- font-family: Verdana,Arial,sans-serif;
834
- font-size: 1.1em;
835
  }
 
836
  .ui-widget .ui-widget {
837
- font-size: 1em;
838
  }
 
839
  .ui-widget input,
840
  .ui-widget select,
841
  .ui-widget textarea,
842
  .ui-widget button {
843
- font-family: Verdana,Arial,sans-serif;
844
- font-size: 1em;
845
  }
 
846
  .ui-widget-content {
847
- border: 1px solid #aaaaaa;
848
- background: #ffffff url("../images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x;
849
- color: #222222;
850
  }
 
851
  .ui-widget-content a {
852
- color: #222222;
853
  }
 
854
  .ui-widget-header {
855
- border: 1px solid #aaaaaa;
856
- background: #cccccc url("../images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x;
857
- color: #222222;
858
- font-weight: bold;
859
  }
 
860
  .ui-widget-header a {
861
- color: #222222;
862
  }
863
 
864
  /* Interaction states
@@ -866,28 +1002,31 @@ body .ui-tooltip {
866
  .ui-state-default,
867
  .ui-widget-content .ui-state-default,
868
  .ui-widget-header .ui-state-default {
869
- border: 1px solid #d3d3d3;
870
- background: #e6e6e6 url("../images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x;
871
- font-weight: normal;
872
- color: #555555;
873
  }
 
874
  .ui-state-default a,
875
  .ui-state-default a:link,
876
  .ui-state-default a:visited {
877
- color: #555555;
878
- text-decoration: none;
879
  }
 
880
  .ui-state-hover,
881
  .ui-widget-content .ui-state-hover,
882
  .ui-widget-header .ui-state-hover,
883
  .ui-state-focus,
884
  .ui-widget-content .ui-state-focus,
885
  .ui-widget-header .ui-state-focus {
886
- border: 1px solid #999999;
887
- background: #dadada url("../images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x;
888
- font-weight: normal;
889
- color: #212121;
890
  }
 
891
  .ui-state-hover a,
892
  .ui-state-hover a:hover,
893
  .ui-state-hover a:link,
@@ -896,22 +1035,24 @@ body .ui-tooltip {
896
  .ui-state-focus a:hover,
897
  .ui-state-focus a:link,
898
  .ui-state-focus a:visited {
899
- color: #212121;
900
- text-decoration: none;
901
  }
 
902
  .ui-state-active,
903
  .ui-widget-content .ui-state-active,
904
  .ui-widget-header .ui-state-active {
905
- border: 1px solid #aaaaaa;
906
- background: #ffffff url("../images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;
907
- font-weight: normal;
908
- color: #212121;
909
  }
 
910
  .ui-state-active a,
911
  .ui-state-active a:link,
912
  .ui-state-active a:visited {
913
- color: #212121;
914
- text-decoration: none;
915
  }
916
 
917
  /* Interaction Cues
@@ -919,53 +1060,61 @@ body .ui-tooltip {
919
  .ui-state-highlight,
920
  .ui-widget-content .ui-state-highlight,
921
  .ui-widget-header .ui-state-highlight {
922
- border: 1px solid #fcefa1;
923
- background: #fbf9ee url("../images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x;
924
- color: #363636;
925
  }
 
926
  .ui-state-highlight a,
927
  .ui-widget-content .ui-state-highlight a,
928
  .ui-widget-header .ui-state-highlight a {
929
- color: #363636;
930
  }
 
931
  .ui-state-error,
932
  .ui-widget-content .ui-state-error,
933
  .ui-widget-header .ui-state-error {
934
- border: 1px solid #cd0a0a;
935
- background: #fef1ec url("../images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x;
936
- color: #cd0a0a;
937
  }
 
938
  .ui-state-error a,
939
  .ui-widget-content .ui-state-error a,
940
  .ui-widget-header .ui-state-error a {
941
- color: #cd0a0a;
942
  }
 
943
  .ui-state-error-text,
944
  .ui-widget-content .ui-state-error-text,
945
  .ui-widget-header .ui-state-error-text {
946
- color: #cd0a0a;
947
  }
 
948
  .ui-priority-primary,
949
  .ui-widget-content .ui-priority-primary,
950
  .ui-widget-header .ui-priority-primary {
951
- font-weight: bold;
952
  }
 
953
  .ui-priority-secondary,
954
  .ui-widget-content .ui-priority-secondary,
955
  .ui-widget-header .ui-priority-secondary {
956
- opacity: .7;
957
- filter:Alpha(Opacity=70); /* support: IE8 */
958
- font-weight: normal;
959
  }
 
960
  .ui-state-disabled,
961
  .ui-widget-content .ui-state-disabled,
962
  .ui-widget-header .ui-state-disabled {
963
- opacity: .35;
964
- filter:Alpha(Opacity=35); /* support: IE8 */
965
- background-image: none;
966
  }
 
967
  .ui-state-disabled .ui-icon {
968
- filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */
969
  }
970
 
971
  /* Icons
@@ -973,253 +1122,787 @@ body .ui-tooltip {
973
 
974
  /* states and images */
975
  .ui-icon {
976
- width: 16px;
977
- height: 16px;
978
  }
 
979
  .ui-icon,
980
  .ui-widget-content .ui-icon {
981
- background-image: url("../images/ui-icons_222222_256x240.png");
982
  }
 
983
  .ui-widget-header .ui-icon {
984
- background-image: url("../images/ui-icons_222222_256x240.png");
985
  }
 
986
  .ui-state-default .ui-icon {
987
- background-image: url("../images/ui-icons_888888_256x240.png");
988
  }
 
989
  .ui-state-hover .ui-icon,
990
  .ui-state-focus .ui-icon {
991
- background-image: url("../images/ui-icons_454545_256x240.png");
992
  }
 
993
  .ui-state-active .ui-icon {
994
- background-image: url("../images/ui-icons_454545_256x240.png");
995
  }
 
996
  .ui-state-highlight .ui-icon {
997
- background-image: url("../images/ui-icons_2e83ff_256x240.png");
998
  }
 
999
  .ui-state-error .ui-icon,
1000
  .ui-state-error-text .ui-icon {
1001
- background-image: url("../images/ui-icons_cd0a0a_256x240.png");
1002
  }
1003
 
1004
  /* positioning */
1005
- .ui-icon-blank { background-position: 16px 16px; }
1006
- .ui-icon-carat-1-n { background-position: 0 0; }
1007
- .ui-icon-carat-1-ne { background-position: -16px 0; }
1008
- .ui-icon-carat-1-e { background-position: -32px 0; }
1009
- .ui-icon-carat-1-se { background-position: -48px 0; }
1010
- .ui-icon-carat-1-s { background-position: -64px 0; }
1011
- .ui-icon-carat-1-sw { background-position: -80px 0; }
1012
- .ui-icon-carat-1-w { background-position: -96px 0; }
1013
- .ui-icon-carat-1-nw { background-position: -112px 0; }
1014
- .ui-icon-carat-2-n-s { background-position: -128px 0; }
1015
- .ui-icon-carat-2-e-w { background-position: -144px 0; }
1016
- .ui-icon-triangle-1-n { background-position: 0 -16px; }
1017
- .ui-icon-triangle-1-ne { background-position: -16px -16px; }
1018
- .ui-icon-triangle-1-e { background-position: -32px -16px; }
1019
- .ui-icon-triangle-1-se { background-position: -48px -16px; }
1020
- .ui-icon-triangle-1-s { background-position: -64px -16px; }
1021
- .ui-icon-triangle-1-sw { background-position: -80px -16px; }
1022
- .ui-icon-triangle-1-w { background-position: -96px -16px; }
1023
- .ui-icon-triangle-1-nw { background-position: -112px -16px; }
1024
- .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
1025
- .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
1026
- .ui-icon-arrow-1-n { background-position: 0 -32px; }
1027
- .ui-icon-arrow-1-ne { background-position: -16px -32px; }
1028
- .ui-icon-arrow-1-e { background-position: -32px -32px; }
1029
- .ui-icon-arrow-1-se { background-position: -48px -32px; }
1030
- .ui-icon-arrow-1-s { background-position: -64px -32px; }
1031
- .ui-icon-arrow-1-sw { background-position: -80px -32px; }
1032
- .ui-icon-arrow-1-w { background-position: -96px -32px; }
1033
- .ui-icon-arrow-1-nw { background-position: -112px -32px; }
1034
- .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
1035
- .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
1036
- .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
1037
- .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
1038
- .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
1039
- .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
1040
- .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
1041
- .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
1042
- .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
1043
- .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
1044
- .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
1045
- .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
1046
- .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
1047
- .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
1048
- .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
1049
- .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
1050
- .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
1051
- .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
1052
- .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
1053
- .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
1054
- .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
1055
- .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
1056
- .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
1057
- .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
1058
- .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
1059
- .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
1060
- .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
1061
- .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
1062
- .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
1063
- .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
1064
- .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
1065
- .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
1066
- .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
1067
- .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
1068
- .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
1069
- .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
1070
- .ui-icon-arrow-4 { background-position: 0 -80px; }
1071
- .ui-icon-arrow-4-diag { background-position: -16px -80px; }
1072
- .ui-icon-extlink { background-position: -32px -80px; }
1073
- .ui-icon-newwin { background-position: -48px -80px; }
1074
- .ui-icon-refresh { background-position: -64px -80px; }
1075
- .ui-icon-shuffle { background-position: -80px -80px; }
1076
- .ui-icon-transfer-e-w { background-position: -96px -80px; }
1077
- .ui-icon-transferthick-e-w { background-position: -112px -80px; }
1078
- .ui-icon-folder-collapsed { background-position: 0 -96px; }
1079
- .ui-icon-folder-open { background-position: -16px -96px; }
1080
- .ui-icon-document { background-position: -32px -96px; }
1081
- .ui-icon-document-b { background-position: -48px -96px; }
1082
- .ui-icon-note { background-position: -64px -96px; }
1083
- .ui-icon-mail-closed { background-position: -80px -96px; }
1084
- .ui-icon-mail-open { background-position: -96px -96px; }
1085
- .ui-icon-suitcase { background-position: -112px -96px; }
1086
- .ui-icon-comment { background-position: -128px -96px; }
1087
- .ui-icon-person { background-position: -144px -96px; }
1088
- .ui-icon-print { background-position: -160px -96px; }
1089
- .ui-icon-trash { background-position: -176px -96px; }
1090
- .ui-icon-locked { background-position: -192px -96px; }
1091
- .ui-icon-unlocked { background-position: -208px -96px; }
1092
- .ui-icon-bookmark { background-position: -224px -96px; }
1093
- .ui-icon-tag { background-position: -240px -96px; }
1094
- .ui-icon-home { background-position: 0 -112px; }
1095
- .ui-icon-flag { background-position: -16px -112px; }
1096
- .ui-icon-calendar { background-position: -32px -112px; }
1097
- .ui-icon-cart { background-position: -48px -112px; }
1098
- .ui-icon-pencil { background-position: -64px -112px; }
1099
- .ui-icon-clock { background-position: -80px -112px; }
1100
- .ui-icon-disk { background-position: -96px -112px; }
1101
- .ui-icon-calculator { background-position: -112px -112px; }
1102
- .ui-icon-zoomin { background-position: -128px -112px; }
1103
- .ui-icon-zoomout { background-position: -144px -112px; }
1104
- .ui-icon-search { background-position: -160px -112px; }
1105
- .ui-icon-wrench { background-position: -176px -112px; }
1106
- .ui-icon-gear { background-position: -192px -112px; }
1107
- .ui-icon-heart { background-position: -208px -112px; }
1108
- .ui-icon-star { background-position: -224px -112px; }
1109
- .ui-icon-link { background-position: -240px -112px; }
1110
- .ui-icon-cancel { background-position: 0 -128px; }
1111
- .ui-icon-plus { background-position: -16px -128px; }
1112
- .ui-icon-plusthick { background-position: -32px -128px; }
1113
- .ui-icon-minus { background-position: -48px -128px; }
1114
- .ui-icon-minusthick { background-position: -64px -128px; }
1115
- .ui-icon-close { background-position: -80px -128px; }
1116
- .ui-icon-closethick { background-position: -96px -128px; }
1117
- .ui-icon-key { background-position: -112px -128px; }
1118
- .ui-icon-lightbulb { background-position: -128px -128px; }
1119
- .ui-icon-scissors { background-position: -144px -128px; }
1120
- .ui-icon-clipboard { background-position: -160px -128px; }
1121
- .ui-icon-copy { background-position: -176px -128px; }
1122
- .ui-icon-contact { background-position: -192px -128px; }
1123
- .ui-icon-image { background-position: -208px -128px; }
1124
- .ui-icon-video { background-position: -224px -128px; }
1125
- .ui-icon-script { background-position: -240px -128px; }
1126
- .ui-icon-alert { background-position: 0 -144px; }
1127
- .ui-icon-info { background-position: -16px -144px; }
1128
- .ui-icon-notice { background-position: -32px -144px; }
1129
- .ui-icon-help { background-position: -48px -144px; }
1130
- .ui-icon-check { background-position: -64px -144px; }
1131
- .ui-icon-bullet { background-position: -80px -144px; }
1132
- .ui-icon-radio-on { background-position: -96px -144px; }
1133
- .ui-icon-radio-off { background-position: -112px -144px; }
1134
- .ui-icon-pin-w { background-position: -128px -144px; }
1135
- .ui-icon-pin-s { background-position: -144px -144px; }
1136
- .ui-icon-play { background-position: 0 -160px; }
1137
- .ui-icon-pause { background-position: -16px -160px; }
1138
- .ui-icon-seek-next { background-position: -32px -160px; }
1139
- .ui-icon-seek-prev { background-position: -48px -160px; }
1140
- .ui-icon-seek-end { background-position: -64px -160px; }
1141
- .ui-icon-seek-start { background-position: -80px -160px; }
1142
- /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
1143
- .ui-icon-seek-first { background-position: -80px -160px; }
1144
- .ui-icon-stop { background-position: -96px -160px; }
1145
- .ui-icon-eject { background-position: -112px -160px; }
1146
- .ui-icon-volume-off { background-position: -128px -160px; }
1147
- .ui-icon-volume-on { background-position: -144px -160px; }
1148
- .ui-icon-power { background-position: 0 -176px; }
1149
- .ui-icon-signal-diag { background-position: -16px -176px; }
1150
- .ui-icon-signal { background-position: -32px -176px; }
1151
- .ui-icon-battery-0 { background-position: -48px -176px; }
1152
- .ui-icon-battery-1 { background-position: -64px -176px; }
1153
- .ui-icon-battery-2 { background-position: -80px -176px; }
1154
- .ui-icon-battery-3 { background-position: -96px -176px; }
1155
- .ui-icon-circle-plus { background-position: 0 -192px; }
1156
- .ui-icon-circle-minus { background-position: -16px -192px; }
1157
- .ui-icon-circle-close { background-position: -32px -192px; }
1158
- .ui-icon-circle-triangle-e { background-position: -48px -192px; }
1159
- .ui-icon-circle-triangle-s { background-position: -64px -192px; }
1160
- .ui-icon-circle-triangle-w { background-position: -80px -192px; }
1161
- .ui-icon-circle-triangle-n { background-position: -96px -192px; }
1162
- .ui-icon-circle-arrow-e { background-position: -112px -192px; }
1163
- .ui-icon-circle-arrow-s { background-position: -128px -192px; }
1164
- .ui-icon-circle-arrow-w { background-position: -144px -192px; }
1165
- .ui-icon-circle-arrow-n { background-position: -160px -192px; }
1166
- .ui-icon-circle-zoomin { background-position: -176px -192px; }
1167
- .ui-icon-circle-zoomout { background-position: -192px -192px; }
1168
- .ui-icon-circle-check { background-position: -208px -192px; }
1169
- .ui-icon-circlesmall-plus { background-position: 0 -208px; }
1170
- .ui-icon-circlesmall-minus { background-position: -16px -208px; }
1171
- .ui-icon-circlesmall-close { background-position: -32px -208px; }
1172
- .ui-icon-squaresmall-plus { background-position: -48px -208px; }
1173
- .ui-icon-squaresmall-minus { background-position: -64px -208px; }
1174
- .ui-icon-squaresmall-close { background-position: -80px -208px; }
1175
- .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
1176
- .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
1177
- .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
1178
- .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
1179
- .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
1180
- .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
1181
 
 
 
 
1182
 
1183
- /* Misc visuals
1184
- ----------------------------------*/
 
1185
 
1186
- /* Corner radius */
1187
- .ui-corner-all,
1188
- .ui-corner-top,
1189
- .ui-corner-left,
1190
- .ui-corner-tl {
1191
- border-top-left-radius: 4px;
1192
  }
1193
- .ui-corner-all,
1194
- .ui-corner-top,
1195
- .ui-corner-right,
1196
- .ui-corner-tr {
1197
- border-top-right-radius: 4px;
1198
  }
1199
- .ui-corner-all,
1200
- .ui-corner-bottom,
1201
- .ui-corner-left,
1202
- .ui-corner-bl {
1203
- border-bottom-left-radius: 4px;
1204
  }
1205
- .ui-corner-all,
1206
- .ui-corner-bottom,
1207
- .ui-corner-right,
1208
- .ui-corner-br {
1209
- border-bottom-right-radius: 4px;
1210
  }
1211
 
1212
- /* Overlays */
1213
- .ui-widget-overlay {
1214
- background: #aaaaaa url("../images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;
1215
- opacity: .3;
1216
- filter: Alpha(Opacity=30); /* support: IE8 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1217
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1218
  .ui-widget-shadow {
1219
- margin: -8px 0 0 -8px;
1220
- padding: 8px;
1221
- background: #aaaaaa url("../images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;
1222
- opacity: .3;
1223
- filter: Alpha(Opacity=30); /* support: IE8 */
1224
- border-radius: 8px;
1225
  }
7
  /* Layout helpers
8
  ----------------------------------*/
9
  .ui-helper-hidden {
10
+ display: none;
11
  }
12
+
13
  .ui-helper-hidden-accessible {
14
+ border: 0;
15
+ clip: rect(0 0 0 0);
16
+ height: 1px;
17
+ margin: -1px;
18
+ overflow: hidden;
19
+ padding: 0;
20
+ position: absolute;
21
+ width: 1px;
22
  }
23
+
24
  .ui-helper-reset {
25
+ margin: 0;
26
+ padding: 0;
27
+ border: 0;
28
+ outline: 0;
29
+ line-height: 1.3;
30
+ text-decoration: none;
31
+ font-size: 100%;
32
+ list-style: none;
33
  }
34
+
35
  .ui-helper-clearfix:before,
36
  .ui-helper-clearfix:after {
37
+ content: "";
38
+ display: table;
39
+ border-collapse: collapse;
40
  }
41
+
42
  .ui-helper-clearfix:after {
43
+ clear: both;
44
  }
45
+
46
  .ui-helper-clearfix {
47
+ min-height: 0; /* support: IE7 */
48
  }
49
+
50
  .ui-helper-zfix {
51
+ width: 100%;
52
+ height: 100%;
53
+ top: 0;
54
+ left: 0;
55
+ position: absolute;
56
+ opacity: 0;
57
+ filter: Alpha(Opacity=0); /* support: IE8 */
58
  }
59
 
60
  .ui-front {
61
+ z-index: 100;
62
  }
63
 
 
64
  /* Interaction Cues
65
  ----------------------------------*/
66
  .ui-state-disabled {
67
+ cursor: default !important;
68
  }
69
 
 
70
  /* Icons
71
  ----------------------------------*/
72
 
73
  /* states and images */
74
  .ui-icon {
75
+ display: block;
76
+ text-indent: -99999px;
77
+ overflow: hidden;
78
+ background-repeat: no-repeat;
79
  }
80
 
 
81
  /* Misc visuals
82
  ----------------------------------*/
83
 
84
  /* Overlays */
85
  .ui-widget-overlay {
86
+ position: fixed;
87
+ top: 0;
88
+ left: 0;
89
+ width: 100%;
90
+ height: 100%;
91
  }
92
+
93
  .ui-accordion .ui-accordion-header {
94
+ display: block;
95
+ cursor: pointer;
96
+ position: relative;
97
+ margin: 2px 0 0 0;
98
+ padding: .5em .5em .5em .7em;
99
+ min-height: 0; /* support: IE7 */
100
+ font-size: 100%;
101
  }
102
+
103
  .ui-accordion .ui-accordion-icons {
104
+ padding-left: 2.2em;
105
  }
106
+
107
  .ui-accordion .ui-accordion-icons .ui-accordion-icons {
108
+ padding-left: 2.2em;
109
  }
110
+
111
  .ui-accordion .ui-accordion-header .ui-accordion-header-icon {
112
+ position: absolute;
113
+ left: .5em;
114
+ top: 50%;
115
+ margin-top: -8px;
116
  }
117
+
118
  .ui-accordion .ui-accordion-content {
119
+ padding: 1em 2.2em;
120
+ border-top: 0;
121
+ overflow: auto;
122
  }
123
+
124
  .ui-autocomplete {
125
+ position: absolute;
126
+ top: 0;
127
+ left: 0;
128
+ cursor: default;
129
  }
130
+
131
  .ui-button {
132
+ display: inline-block;
133
+ position: relative;
134
+ padding: 0;
135
+ line-height: normal;
136
+ margin-right: .1em;
137
+ cursor: pointer;
138
+ vertical-align: middle;
139
+ text-align: center;
140
+ overflow: visible; /* removes extra width in IE */
141
  }
142
+
143
  .ui-button,
144
  .ui-button:link,
145
  .ui-button:visited,
146
  .ui-button:hover,
147
  .ui-button:active {
148
+ text-decoration: none;
149
  }
150
+
151
  /* to make room for the icon, a width needs to be set here */
152
  .ui-button-icon-only {
153
+ width: 2.2em;
154
  }
155
+
156
  /* button elements seem to need a little more width */
157
  button.ui-button-icon-only {
158
+ width: 2.4em;
159
  }
160
+
161
  .ui-button-icons-only {
162
+ width: 3.4em;
163
  }
164
+
165
  button.ui-button-icons-only {
166
+ width: 3.7em;
167
  }
168
 
169
  /* button text element */
170
  .ui-button .ui-button-text {
171
+ display: block;
172
+ line-height: normal;
173
  }
174
+
175
  .ui-button-text-only .ui-button-text {
176
+ padding: .4em 1em;
177
  }
178
+
179
  .ui-button-icon-only .ui-button-text,
180
  .ui-button-icons-only .ui-button-text {
181
+ padding: .4em;
182
+ text-indent: -9999999px;
183
  }
184
+
185
  .ui-button-text-icon-primary .ui-button-text,
186
  .ui-button-text-icons .ui-button-text {
187
+ padding: .4em 1em .4em 2.1em;
188
  }
189
+
190
  .ui-button-text-icon-secondary .ui-button-text,
191
  .ui-button-text-icons .ui-button-text {
192
+ padding: .4em 2.1em .4em 1em;
193
  }
194
+
195
  .ui-button-text-icons .ui-button-text {
196
+ padding-left: 2.1em;
197
+ padding-right: 2.1em;
198
  }
199
+
200
  /* no icon support for input elements, provide padding by default */
201
  input.ui-button {
202
+ padding: .4em 1em;
203
  }
204
 
205
  /* button icon element(s) */
208
  .ui-button-text-icon-secondary .ui-icon,
209
  .ui-button-text-icons .ui-icon,
210
  .ui-button-icons-only .ui-icon {
211
+ position: absolute;
212
+ top: 50%;
213
+ margin-top: -8px;
214
  }
215
+
216
  .ui-button-icon-only .ui-icon {
217
+ left: 50%;
218
+ margin-left: -8px;
219
  }
220
+
221
  .ui-button-text-icon-primary .ui-button-icon-primary,
222
  .ui-button-text-icons .ui-button-icon-primary,
223
  .ui-button-icons-only .ui-button-icon-primary {
224
+ left: .5em;
225
  }
226
+
227
  .ui-button-text-icon-secondary .ui-button-icon-secondary,
228
  .ui-button-text-icons .ui-button-icon-secondary,
229
  .ui-button-icons-only .ui-button-icon-secondary {
230
+ right: .5em;
231
  }
232
 
233
  /* button sets */
234
  .ui-buttonset {
235
+ margin-right: 7px;
236
  }
237
+
238
  .ui-buttonset .ui-button {
239
+ margin-left: 0;
240
+ margin-right: -.3em;
241
  }
242
 
243
  /* workarounds */
244
  /* reset extra padding in Firefox, see h5bp.com/l */
245
  input.ui-button::-moz-focus-inner,
246
  button.ui-button::-moz-focus-inner {
247
+ border: 0;
248
+ padding: 0;
249
  }
250
+
251
  .ui-datepicker {
252
+ width: 17em;
253
+ padding: .2em .2em 0;
254
+ display: none;
255
  }
256
+
257
  .ui-datepicker .ui-datepicker-header {
258
+ position: relative;
259
+ padding: .2em 0;
260
  }
261
+
262
  .ui-datepicker .ui-datepicker-prev,
263
  .ui-datepicker .ui-datepicker-next {
264
+ position: absolute;
265
+ top: 2px;
266
+ width: 1.8em;
267
+ height: 1.8em;
268
  }
269
+
270
  .ui-datepicker .ui-datepicker-prev-hover,
271
  .ui-datepicker .ui-datepicker-next-hover {
272
+ top: 1px;
273
  }
274
+
275
  .ui-datepicker .ui-datepicker-prev {
276
+ left: 2px;
277
  }
278
+
279
  .ui-datepicker .ui-datepicker-next {
280
+ right: 2px;
281
  }
282
+
283
  .ui-datepicker .ui-datepicker-prev-hover {
284
+ left: 1px;
285
  }
286
+
287
  .ui-datepicker .ui-datepicker-next-hover {
288
+ right: 1px;
289
  }
290
+
291
  .ui-datepicker .ui-datepicker-prev span,
292
  .ui-datepicker .ui-datepicker-next span {
293
+ display: block;
294
+ position: absolute;
295
+ left: 50%;
296
+ margin-left: -8px;
297
+ top: 50%;
298
+ margin-top: -8px;
299
  }
300
+
301
  .ui-datepicker .ui-datepicker-title {
302
+ margin: 0 2.3em;
303
+ line-height: 1.8em;
304
+ text-align: center;
305
  }
306
+
307
  .ui-datepicker .ui-datepicker-title select {
308
+ font-size: 1em;
309
+ margin: 1px 0;
310
  }
311
+
312
  .ui-datepicker select.ui-datepicker-month,
313
  .ui-datepicker select.ui-datepicker-year {
314
+ width: 45%;
315
  }
316
+
317
  .ui-datepicker table {
318
+ width: 100%;
319
+ font-size: .9em;
320
+ border-collapse: collapse;
321
+ margin: 0 0 .4em;
322
  }
323
+
324
  .ui-datepicker th {
325
+ padding: .7em .3em;
326
+ text-align: center;
327
+ font-weight: bold;
328
+ border: 0;
329
  }
330
+
331
  .ui-datepicker td {
332
+ border: 0;
333
+ padding: 1px;
334
  }
335
+
336
  .ui-datepicker td span,
337
  .ui-datepicker td a {
338
+ display: block;
339
+ padding: .2em;
340
+ text-align: right;
341
+ text-decoration: none;
342
  }
343
+
344
  .ui-datepicker .ui-datepicker-buttonpane {
345
+ background-image: none;
346
+ margin: .7em 0 0 0;
347
+ padding: 0 .2em;
348
+ border-left: 0;
349
+ border-right: 0;
350
+ border-bottom: 0;
351
  }
352
+
353
  .ui-datepicker .ui-datepicker-buttonpane button {
354
+ float: right;
355
+ margin: .5em .2em .4em;
356
+ cursor: pointer;
357
+ padding: .2em .6em .3em .6em;
358
+ width: auto;
359
+ overflow: visible;
360
  }
361
+
362
  .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current {
363
+ float: left;
364
  }
365
 
366
  /* with multiple calendars */
367
  .ui-datepicker.ui-datepicker-multi {
368
+ width: auto;
369
  }
370
+
371
  .ui-datepicker-multi .ui-datepicker-group {
372
+ float: left;
373
  }
374
+
375
  .ui-datepicker-multi .ui-datepicker-group table {
376
+ width: 95%;
377
+ margin: 0 auto .4em;
378
  }
379
+
380
  .ui-datepicker-multi-2 .ui-datepicker-group {
381
+ width: 50%;
382
  }
383
+
384
  .ui-datepicker-multi-3 .ui-datepicker-group {
385
+ width: 33.3%;
386
  }
387
+
388
  .ui-datepicker-multi-4 .ui-datepicker-group {
389
+ width: 25%;
390
  }
391
+
392
  .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,
393
  .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header {
394
+ border-left-width: 0;
395
  }
396
+
397
  .ui-datepicker-multi .ui-datepicker-buttonpane {
398
+ clear: left;
399
  }
400
+
401
  .ui-datepicker-row-break {
402
+ clear: both;
403
+ width: 100%;
404
+ font-size: 0;
405
  }
406
 
407
  /* RTL support */
408
  .ui-datepicker-rtl {
409
+ direction: rtl;
410
  }
411
+
412
  .ui-datepicker-rtl .ui-datepicker-prev {
413
+ right: 2px;
414
+ left: auto;
415
  }
416
+
417
  .ui-datepicker-rtl .ui-datepicker-next {
418
+ left: 2px;
419
+ right: auto;
420
  }
421
+
422
  .ui-datepicker-rtl .ui-datepicker-prev:hover {
423
+ right: 1px;
424
+ left: auto;
425
  }
426
+
427
  .ui-datepicker-rtl .ui-datepicker-next:hover {
428
+ left: 1px;
429
+ right: auto;
430
  }
431
+
432
  .ui-datepicker-rtl .ui-datepicker-buttonpane {
433
+ clear: right;
434
  }
435
+
436
  .ui-datepicker-rtl .ui-datepicker-buttonpane button {
437
+ float: left;
438
  }
439
+
440
  .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,
441
  .ui-datepicker-rtl .ui-datepicker-group {
442
+ float: right;
443
  }
444
+
445
  .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,
446
  .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header {
447
+ border-right-width: 0;
448
+ border-left-width: 1px;
449
  }
450
+
451
  .ui-dialog {
452
+ overflow: hidden;
453
+ position: absolute;
454
+ top: 0;
455
+ left: 0;
456
+ padding: .2em;
457
+ outline: 0;
458
  }
459
+
460
  .ui-dialog .ui-dialog-titlebar {
461
+ padding: .4em 1em;
462
+ position: relative;
463
  }
464
+
465
  .ui-dialog .ui-dialog-title {
466
+ float: left;
467
+ margin: .1em 0;
468
+ white-space: nowrap;
469
+ width: 90%;
470
+ overflow: hidden;
471
+ text-overflow: ellipsis;
472
  }
473
+
474
  .ui-dialog .ui-dialog-titlebar-close {
475
+ position: absolute;
476
+ right: .3em;
477
+ top: 50%;
478
+ width: 20px;
479
+ margin: -10px 0 0 0;
480
+ padding: 1px;
481
+ height: 20px;
482
  }
483
+
484
  .ui-dialog .ui-dialog-content {
485
+ position: relative;
486
+ border: 0;
487
+ padding: .5em 1em;
488
+ background: none;
489
+ overflow: auto;
490
  }
491
+
492
  .ui-dialog .ui-dialog-buttonpane {
493
+ text-align: left;
494
+ border-width: 1px 0 0 0;
495
+ background-image: none;
496
+ margin-top: .5em;
497
+ padding: .3em 1em .5em .4em;
498
  }
499
+
500
  .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
501
+ float: right;
502
  }
503
+
504
  .ui-dialog .ui-dialog-buttonpane button {
505
+ margin: .5em .4em .5em 0;
506
+ cursor: pointer;
507
  }
508
+
509
  .ui-dialog .ui-resizable-se {
510
+ width: 12px;
511
+ height: 12px;
512
+ right: -5px;
513
+ bottom: -5px;
514
+ background-position: 16px 16px;
515
  }
516
+
517
  .ui-draggable .ui-dialog-titlebar {
518
+ cursor: move;
519
  }
520
+
521
  .ui-draggable-handle {
522
+ -ms-touch-action: none;
523
+ touch-action: none;
524
  }
525
+
526
  .ui-menu {
527
+ list-style: none;
528
+ padding: 0;
529
+ margin: 0;
530
+ display: block;
531
+ outline: none;
532
  }
533
+
534
  .ui-menu .ui-menu {
535
+ position: absolute;
536
  }
537
+
538
  .ui-menu .ui-menu-item {
539
+ position: relative;
540
+ margin: 0;
541
+ padding: 3px 1em 3px .4em;
542
+ cursor: pointer;
543
+ min-height: 0; /* support: IE7 */
544
+ /* support: IE10, see #8844 */
545
+ list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
546
  }
547
+
548
  .ui-menu .ui-menu-divider {
549
+ margin: 5px 0;
550
+ height: 0;
551
+ font-size: 0;
552
+ line-height: 0;
553
+ border-width: 1px 0 0 0;
554
  }
555
+
556
  .ui-menu .ui-state-focus,
557
  .ui-menu .ui-state-active {
558
+ margin: -1px;
559
  }
560
 
561
  /* icon support */
562
  .ui-menu-icons {
563
+ position: relative;
564
  }
565
+
566
  .ui-menu-icons .ui-menu-item {
567
+ padding-left: 2em;
568
  }
569
 
570
  /* left-aligned */
571
  .ui-menu .ui-icon {
572
+ position: absolute;
573
+ top: 0;
574
+ bottom: 0;
575
+ left: .2em;
576
+ margin: auto 0;
577
  }
578
 
579
  /* right-aligned */
580
  .ui-menu .ui-menu-icon {
581
+ left: auto;
582
+ right: 0;
583
  }
584
+
585
  .ui-progressbar {
586
+ height: 2em;
587
+ text-align: left;
588
+ overflow: hidden;
589
  }
590
+
591
  .ui-progressbar .ui-progressbar-value {
592
+ margin: -1px;
593
+ height: 100%;
594
  }
595
+
596
  .ui-progressbar .ui-progressbar-overlay {
597
+ background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw==");
598
+ height: 100%;
599
+ filter: alpha(opacity=25); /* support: IE8 */
600
+ opacity: 0.25;
601
  }
602
+
603
  .ui-progressbar-indeterminate .ui-progressbar-value {
604
+ background-image: none;
605
  }
606
+
607
  .ui-resizable {
608
+ position: relative;
609
  }
610
+
611
  .ui-resizable-handle {
612
+ position: absolute;
613
+ font-size: 0.1px;
614
+ display: block;
615
+ -ms-touch-action: none;
616
+ touch-action: none;
617
  }
618
+
619
  .ui-resizable-disabled .ui-resizable-handle,
620
  .ui-resizable-autohide .ui-resizable-handle {
621
+ display: none;
622
  }
623
+
624
  .ui-resizable-n {
625
+ cursor: n-resize;
626
+ height: 7px;
627
+ width: 100%;
628
+ top: -5px;
629
+ left: 0;
630
  }
631
+
632
  .ui-resizable-s {
633
+ cursor: s-resize;
634
+ height: 7px;
635
+ width: 100%;
636
+ bottom: -5px;
637
+ left: 0;
638
  }
639
+
640
  .ui-resizable-e {
641
+ cursor: e-resize;
642
+ width: 7px;
643
+ right: -5px;
644
+ top: 0;
645
+ height: 100%;
646
  }
647
+
648
  .ui-resizable-w {
649
+ cursor: w-resize;
650
+ width: 7px;
651
+ left: -5px;
652
+ top: 0;
653
+ height: 100%;
654
  }
655
+
656
  .ui-resizable-se {
657
+ cursor: se-resize;
658
+ width: 12px;
659
+ height: 12px;
660
+ right: 1px;
661
+ bottom: 1px;
662
  }
663
+
664
  .ui-resizable-sw {
665
+ cursor: sw-resize;
666
+ width: 9px;
667
+ height: 9px;
668
+ left: -5px;
669
+ bottom: -5px;
670
  }
671
+
672
  .ui-resizable-nw {
673
+ cursor: nw-resize;
674
+ width: 9px;
675
+ height: 9px;
676
+ left: -5px;
677
+ top: -5px;
678
  }
679
+
680
  .ui-resizable-ne {
681
+ cursor: ne-resize;
682
+ width: 9px;
683
+ height: 9px;
684
+ right: -5px;
685
+ top: -5px;
686
  }
687
+
688
  .ui-selectable {
689
+ -ms-touch-action: none;
690
+ touch-action: none;
691
  }
692
+
693
  .ui-selectable-helper {
694
+ position: absolute;
695
+ z-index: 100;
696
+ border: 1px dotted black;
697
  }
698
+
699
  .ui-selectmenu-menu {
700
+ padding: 0;
701
+ margin: 0;
702
+ position: absolute;
703
+ top: 0;
704
+ left: 0;
705
+ display: none;
706
  }
707
+
708
  .ui-selectmenu-menu .ui-menu {
709
+ overflow: auto;
710
+ /* Support: IE7 */
711
+ overflow-x: hidden;
712
+ padding-bottom: 1px;
713
  }
714
+
715
  .ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup {
716
+ font-size: 1em;
717
+ font-weight: bold;
718
+ line-height: 1.5;
719
+ padding: 2px 0.4em;
720
+ margin: 0.5em 0 0 0;
721
+ height: auto;
722
+ border: 0;
723
  }
724
+
725
  .ui-selectmenu-open {
726
+ display: block;
727
  }
728
+
729
  .ui-selectmenu-button {
730
+ display: inline-block;
731
+ overflow: hidden;
732
+ position: relative;
733
+ text-decoration: none;
734
+ cursor: pointer;
735
  }
736
+
737
  .ui-selectmenu-button span.ui-icon {
738
+ right: 0.5em;
739
+ left: auto;
740
+ margin-top: -8px;
741
+ position: absolute;
742
+ top: 50%;
743
  }
744
+
745
  .ui-selectmenu-button span.ui-selectmenu-text {
746
+ text-align: left;
747
+ padding: 0.4em 2.1em 0.4em 1em;
748
+ display: block;
749
+ line-height: 1.4;
750
+ overflow: hidden;
751
+ text-overflow: ellipsis;
752
+ white-space: nowrap;
753
  }
754
+
755
  .ui-slider {
756
+ position: relative;
757
+ text-align: left;
758
  }
759
+
760
  .ui-slider .ui-slider-handle {
761
+ position: absolute;
762
+ z-index: 2;
763
+ width: 1.2em;
764
+ height: 1.2em;
765
+ cursor: default;
766
+ -ms-touch-action: none;
767
+ touch-action: none;
768
  }
769
+
770
  .ui-slider .ui-slider-range {
771
+ position: absolute;
772
+ z-index: 1;
773
+ font-size: .7em;
774
+ display: block;
775
+ border: 0;
776
+ background-position: 0 0;
777
  }
778
 
779
  /* support: IE8 - See #6727 */
780
  .ui-slider.ui-state-disabled .ui-slider-handle,
781
  .ui-slider.ui-state-disabled .ui-slider-range {
782
+ filter: inherit;
783
  }
784
 
785
  .ui-slider-horizontal {
786
+ height: .8em;
787
  }
788
+
789
  .ui-slider-horizontal .ui-slider-handle {
790
+ top: -.3em;
791
+ margin-left: -.6em;
792
  }
793
+
794
  .ui-slider-horizontal .ui-slider-range {
795
+ top: 0;
796
+ height: 100%;
797
  }
798
+
799
  .ui-slider-horizontal .ui-slider-range-min {
800
+ left: 0;
801
  }
802
+
803
  .ui-slider-horizontal .ui-slider-range-max {
804
+ right: 0;
805
  }
806
 
807
  .ui-slider-vertical {
808
+ width: .8em;
809
+ height: 100px;
810
  }
811
+
812
  .ui-slider-vertical .ui-slider-handle {
813
+ left: -.3em;
814
+ margin-left: 0;
815
+ margin-bottom: -.6em;
816
  }
817
+
818
  .ui-slider-vertical .ui-slider-range {
819
+ left: 0;
820
+ width: 100%;
821
  }
822
+
823
  .ui-slider-vertical .ui-slider-range-min {
824
+ bottom: 0;
825
  }
826
+
827
  .ui-slider-vertical .ui-slider-range-max {
828
+ top: 0;
829
  }
830
+
831
  .ui-sortable-handle {
832
+ -ms-touch-action: none;
833
+ touch-action: none;
834
  }
835
+
836
  .ui-spinner {
837
+ position: relative;
838
+ display: inline-block;
839
+ overflow: hidden;
840
+ padding: 0;
841
+ vertical-align: middle;
842
  }
843
+
844
  .ui-spinner-input {
845
+ border: none;
846
+ background: none;
847
+ color: inherit;
848
+ padding: 0;
849
+ margin: .2em 0;
850
+ vertical-align: middle;
851
+ margin-left: .4em;
852
+ margin-right: 22px;
853
  }
854
+
855
  .ui-spinner-button {
856
+ width: 16px;
857
+ height: 50%;
858
+ font-size: .5em;
859
+ padding: 0;
860
+ margin: 0;
861
+ text-align: center;
862
+ position: absolute;
863
+ cursor: default;
864
+ display: block;
865
+ overflow: hidden;
866
+ right: 0;
867
  }
868
+
869
  /* more specificity required here to override default borders */
870
  .ui-spinner a.ui-spinner-button {
871
+ border-top: none;
872
+ border-bottom: none;
873
+ border-right: none;
874
  }
875
+
876
  /* vertically center icon */
877
  .ui-spinner .ui-icon {
878
+ position: absolute;
879
+ margin-top: -8px;
880
+ top: 50%;
881
+ left: 0;
882
  }
883
+
884
  .ui-spinner-up {
885
+ top: 0;
886
  }
887
+
888
  .ui-spinner-down {
889
+ bottom: 0;
890
  }
891
 
892
  /* TR overrides */
893
  .ui-spinner .ui-icon-triangle-1-s {
894
+ /* need to fix icons sprite */
895
+ background-position: -65px -16px;
896
  }
897
+
898
  .ui-tabs {
899
+ position: relative; /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
900
+ padding: .2em;
901
  }
902
+
903
  .ui-tabs .ui-tabs-nav {
904
+ margin: 0;
905
+ padding: .2em .2em 0;
906
  }
907
+
908
  .ui-tabs .ui-tabs-nav li {
909
+ list-style: none;
910
+ float: left;
911
+ position: relative;
912
+ top: 0;
913
+ margin: 1px .2em 0 0;
914
+ border-bottom-width: 0;
915
+ padding: 0;
916
+ white-space: nowrap;
917
  }
918
+
919
  .ui-tabs .ui-tabs-nav .ui-tabs-anchor {
920
+ float: left;
921
+ padding: .5em 1em;
922
+ text-decoration: none;
923
  }
924
+
925
  .ui-tabs .ui-tabs-nav li.ui-tabs-active {
926
+ margin-bottom: -1px;
927
+ padding-bottom: 1px;
928
  }
929
+
930
  .ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,
931
  .ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,
932
  .ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor {
933
+ cursor: text;
934
  }
935
+
936
  .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor {
937
+ cursor: pointer;
938
  }
939
+
940
  .ui-tabs .ui-tabs-panel {
941
+ display: block;
942
+ border-width: 0;
943
+ padding: 1em 1.4em;
944
+ background: none;
945
  }
946
+
947
  .ui-tooltip {
948
+ padding: 8px;
949
+ position: absolute;
950
+ z-index: 9999;
951
+ max-width: 300px;
952
+ -webkit-box-shadow: 0 0 5px #aaa;
953
+ box-shadow: 0 0 5px #aaa;
954
  }
955
+
956
  body .ui-tooltip {
957
+ border-width: 2px;
958
  }
959
 
960
  /* Component containers
961
  ----------------------------------*/
962
  .ui-widget {
963
+ font-family: Verdana, Arial, sans-serif;
964
+ font-size: 1.1em;
965
  }
966
+
967
  .ui-widget .ui-widget {
968
+ font-size: 1em;
969
  }
970
+
971
  .ui-widget input,
972
  .ui-widget select,
973
  .ui-widget textarea,
974
  .ui-widget button {
975
+ font-family: Verdana, Arial, sans-serif;
976
+ font-size: 1em;
977
  }
978
+
979
  .ui-widget-content {
980
+ border: 1px solid #aaaaaa;
981
+ background: #ffffff url("../images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x;
982
+ color: #222222;
983
  }
984
+
985
  .ui-widget-content a {
986
+ color: #222222;
987
  }
988
+
989
  .ui-widget-header {
990
+ border: 1px solid #aaaaaa;
991
+ background: #cccccc url("../images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x;
992
+ color: #222222;
993
+ font-weight: bold;
994
  }
995
+
996
  .ui-widget-header a {
997
+ color: #222222;
998
  }
999
 
1000
  /* Interaction states
1002
  .ui-state-default,
1003
  .ui-widget-content .ui-state-default,
1004
  .ui-widget-header .ui-state-default {
1005
+ border: 1px solid #d3d3d3;
1006
+ background: #e6e6e6 url("../images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x;
1007
+ font-weight: normal;
1008
+ color: #555555;
1009
  }
1010
+
1011
  .ui-state-default a,
1012
  .ui-state-default a:link,
1013
  .ui-state-default a:visited {
1014
+ color: #555555;
1015
+ text-decoration: none;
1016
  }
1017
+
1018
  .ui-state-hover,
1019
  .ui-widget-content .ui-state-hover,
1020
  .ui-widget-header .ui-state-hover,
1021
  .ui-state-focus,
1022
  .ui-widget-content .ui-state-focus,
1023
  .ui-widget-header .ui-state-focus {
1024
+ border: 1px solid #999999;
1025
+ background: #dadada url("../images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x;
1026
+ font-weight: normal;
1027
+ color: #212121;
1028
  }
1029
+
1030
  .ui-state-hover a,
1031
  .ui-state-hover a:hover,
1032
  .ui-state-hover a:link,
1035
  .ui-state-focus a:hover,
1036
  .ui-state-focus a:link,
1037
  .ui-state-focus a:visited {
1038
+ color: #212121;
1039
+ text-decoration: none;
1040
  }
1041
+
1042
  .ui-state-active,
1043
  .ui-widget-content .ui-state-active,
1044
  .ui-widget-header .ui-state-active {
1045
+ border: 1px solid #aaaaaa;
1046
+ background: #ffffff url("../images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;
1047
+ font-weight: normal;
1048
+ color: #212121;
1049
  }
1050
+
1051
  .ui-state-active a,
1052
  .ui-state-active a:link,
1053
  .ui-state-active a:visited {
1054
+ color: #212121;
1055
+ text-decoration: none;
1056
  }
1057
 
1058
  /* Interaction Cues
1060
  .ui-state-highlight,
1061
  .ui-widget-content .ui-state-highlight,
1062
  .ui-widget-header .ui-state-highlight {
1063
+ border: 1px solid #fcefa1;
1064
+ background: #fbf9ee url("../images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x;
1065
+ color: #363636;
1066
  }
1067
+
1068
  .ui-state-highlight a,
1069
  .ui-widget-content .ui-state-highlight a,
1070
  .ui-widget-header .ui-state-highlight a {
1071
+ color: #363636;
1072
  }
1073
+
1074
  .ui-state-error,
1075
  .ui-widget-content .ui-state-error,
1076
  .ui-widget-header .ui-state-error {
1077
+ border: 1px solid #cd0a0a;
1078
+ background: #fef1ec url("../images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x;
1079
+ color: #cd0a0a;
1080
  }
1081
+
1082
  .ui-state-error a,
1083
  .ui-widget-content .ui-state-error a,
1084
  .ui-widget-header .ui-state-error a {
1085
+ color: #cd0a0a;
1086
  }
1087
+
1088
  .ui-state-error-text,
1089
  .ui-widget-content .ui-state-error-text,
1090
  .ui-widget-header .ui-state-error-text {
1091
+ color: #cd0a0a;
1092
  }
1093
+
1094
  .ui-priority-primary,
1095
  .ui-widget-content .ui-priority-primary,
1096
  .ui-widget-header .ui-priority-primary {
1097
+ font-weight: bold;
1098
  }
1099
+
1100
  .ui-priority-secondary,
1101
  .ui-widget-content .ui-priority-secondary,
1102
  .ui-widget-header .ui-priority-secondary {
1103
+ opacity: .7;
1104
+ filter: Alpha(Opacity=70); /* support: IE8 */
1105
+ font-weight: normal;
1106
  }
1107
+
1108
  .ui-state-disabled,
1109
  .ui-widget-content .ui-state-disabled,
1110
  .ui-widget-header .ui-state-disabled {
1111
+ opacity: .35;
1112
+ filter: Alpha(Opacity=35); /* support: IE8 */
1113
+ background-image: none;
1114
  }
1115
+
1116
  .ui-state-disabled .ui-icon {
1117
+ filter: Alpha(Opacity=35); /* support: IE8 - See #6059 */
1118
  }
1119
 
1120
  /* Icons
1122
 
1123
  /* states and images */
1124
  .ui-icon {
1125
+ width: 16px;
1126
+ height: 16px;
1127
  }
1128
+
1129
  .ui-icon,
1130
  .ui-widget-content .ui-icon {
1131
+ background-image: url("../images/ui-icons_222222_256x240.png");
1132
  }
1133
+
1134
  .ui-widget-header .ui-icon {
1135
+ background-image: url("../images/ui-icons_222222_256x240.png");
1136
  }
1137
+
1138
  .ui-state-default .ui-icon {
1139
+ background-image: url("../images/ui-icons_888888_256x240.png");
1140
  }
1141
+
1142
  .ui-state-hover .ui-icon,
1143
  .ui-state-focus .ui-icon {
1144
+ background-image: url("../images/ui-icons_454545_256x240.png");
1145
  }
1146
+
1147
  .ui-state-active .ui-icon {
1148
+ background-image: url("../images/ui-icons_454545_256x240.png");
1149
  }
1150
+
1151
  .ui-state-highlight .ui-icon {
1152
+ background-image: url("../images/ui-icons_2e83ff_256x240.png");
1153
  }
1154
+
1155
  .ui-state-error .ui-icon,
1156
  .ui-state-error-text .ui-icon {
1157
+ background-image: url("../images/ui-icons_cd0a0a_256x240.png");
1158
  }
1159
 
1160
  /* positioning */
1161
+ .ui-icon-blank {
1162
+ background-position: 16px 16px;
1163
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1164
 
1165
+ .ui-icon-carat-1-n {
1166
+ background-position: 0 0;
1167
+ }
1168
 
1169
+ .ui-icon-carat-1-ne {
1170
+ background-position: -16px 0;
1171
+ }
1172
 
1173
+ .ui-icon-carat-1-e {
1174
+ background-position: -32px 0;
 
 
 
 
1175
  }
1176
+
1177
+ .ui-icon-carat-1-se {
1178
+ background-position: -48px 0;
 
 
1179
  }
1180
+
1181
+ .ui-icon-carat-1-s {
1182
+ background-position: -64px 0;
 
 
1183
  }
1184
+
1185
+ .ui-icon-carat-1-sw {
1186
+ background-position: -80px 0;
 
 
1187
  }
1188
 
1189
+ .ui-icon-carat-1-w {
1190
+ background-position: -96px 0;
1191
+ }
1192
+
1193
+ .ui-icon-carat-1-nw {
1194
+ background-position: -112px 0;
1195
+ }
1196
+
1197
+ .ui-icon-carat-2-n-s {
1198
+ background-position: -128px 0;
1199
+ }
1200
+
1201
+ .ui-icon-carat-2-e-w {
1202
+ background-position: -144px 0;
1203
+ }
1204
+
1205
+ .ui-icon-triangle-1-n {
1206
+ background-position: 0 -16px;
1207
+ }
1208
+
1209
+ .ui-icon-triangle-1-ne {
1210
+ background-position: -16px -16px;
1211
+ }
1212
+
1213
+ .ui-icon-triangle-1-e {
1214
+ background-position: -32px -16px;
1215
+ }
1216
+
1217
+ .ui-icon-triangle-1-se {
1218
+ background-position: -48px -16px;
1219
+ }
1220
+
1221
+ .ui-icon-triangle-1-s {
1222
+ background-position: -64px -16px;
1223
+ }
1224
+
1225
+ .ui-icon-triangle-1-sw {
1226
+ background-position: -80px -16px;
1227
+ }
1228
+
1229
+ .ui-icon-triangle-1-w {
1230
+ background-position: -96px -16px;
1231
+ }
1232
+
1233
+ .ui-icon-triangle-1-nw {
1234
+ background-position: -112px -16px;
1235
+ }
1236
+
1237
+ .ui-icon-triangle-2-n-s {
1238
+ background-position: -128px -16px;
1239
+ }
1240
+
1241
+ .ui-icon-triangle-2-e-w {
1242
+ background-position: -144px -16px;
1243
+ }
1244
+
1245
+ .ui-icon-arrow-1-n {
1246
+ background-position: 0 -32px;
1247
+ }
1248
+
1249
+ .ui-icon-arrow-1-ne {
1250
+ background-position: -16px -32px;
1251
+ }
1252
+
1253
+ .ui-icon-arrow-1-e {
1254
+ background-position: -32px -32px;
1255
+ }
1256
+
1257
+ .ui-icon-arrow-1-se {
1258
+ background-position: -48px -32px;
1259
+ }
1260
+
1261
+ .ui-icon-arrow-1-s {
1262
+ background-position: -64px -32px;
1263
+ }
1264
+
1265
+ .ui-icon-arrow-1-sw {
1266
+ background-position: -80px -32px;
1267
+ }
1268
+
1269
+ .ui-icon-arrow-1-w {
1270
+ background-position: -96px -32px;
1271
+ }
1272
+
1273
+ .ui-icon-arrow-1-nw {
1274
+ background-position: -112px -32px;
1275
+ }
1276
+
1277
+ .ui-icon-arrow-2-n-s {
1278
+ background-position: -128px -32px;
1279
+ }
1280
+
1281
+ .ui-icon-arrow-2-ne-sw {
1282
+ background-position: -144px -32px;
1283
+ }
1284
+
1285
+ .ui-icon-arrow-2-e-w {
1286
+ background-position: -160px -32px;
1287
+ }
1288
+
1289
+ .ui-icon-arrow-2-se-nw {
1290
+ background-position: -176px -32px;
1291
+ }
1292
+
1293
+ .ui-icon-arrowstop-1-n {
1294
+ background-position: -192px -32px;
1295
+ }
1296
+
1297
+ .ui-icon-arrowstop-1-e {
1298
+ background-position: -208px -32px;
1299
+ }
1300
+
1301
+ .ui-icon-arrowstop-1-s {
1302
+ background-position: -224px -32px;
1303
+ }
1304
+
1305
+ .ui-icon-arrowstop-1-w {
1306
+ background-position: -240px -32px;
1307
+ }
1308
+
1309
+ .ui-icon-arrowthick-1-n {
1310
+ background-position: 0 -48px;
1311
+ }
1312
+
1313
+ .ui-icon-arrowthick-1-ne {
1314
+ background-position: -16px -48px;
1315
+ }
1316
+
1317
+ .ui-icon-arrowthick-1-e {
1318
+ background-position: -32px -48px;
1319
+ }
1320
+
1321
+ .ui-icon-arrowthick-1-se {
1322
+ background-position: -48px -48px;
1323
  }
1324
+
1325
+ .ui-icon-arrowthick-1-s {
1326
+ background-position: -64px -48px;
1327
+ }
1328
+
1329
+ .ui-icon-arrowthick-1-sw {
1330
+ background-position: -80px -48px;
1331
+ }
1332
+
1333
+ .ui-icon-arrowthick-1-w {
1334
+ background-position: -96px -48px;
1335
+ }
1336
+
1337
+ .ui-icon-arrowthick-1-nw {
1338
+ background-position: -112px -48px;
1339
+ }
1340
+
1341
+ .ui-icon-arrowthick-2-n-s {
1342
+ background-position: -128px -48px;
1343
+ }
1344
+
1345
+ .ui-icon-arrowthick-2-ne-sw {
1346
+ background-position: -144px -48px;
1347
+ }
1348
+
1349
+ .ui-icon-arrowthick-2-e-w {
1350
+ background-position: -160px -48px;
1351
+ }
1352
+
1353
+ .ui-icon-arrowthick-2-se-nw {
1354
+ background-position: -176px -48px;
1355
+ }
1356
+
1357
+ .ui-icon-arrowthickstop-1-n {
1358
+ background-position: -192px -48px;
1359
+ }
1360
+
1361
+ .ui-icon-arrowthickstop-1-e {
1362
+ background-position: -208px -48px;
1363
+ }
1364
+
1365
+ .ui-icon-arrowthickstop-1-s {
1366
+ background-position: -224px -48px;
1367
+ }
1368
+
1369
+ .ui-icon-arrowthickstop-1-w {
1370
+ background-position: -240px -48px;
1371
+ }
1372
+
1373
+ .ui-icon-arrowreturnthick-1-w {
1374
+ background-position: 0 -64px;
1375
+ }
1376
+
1377
+ .ui-icon-arrowreturnthick-1-n {
1378
+ background-position: -16px -64px;
1379
+ }
1380
+
1381
+ .ui-icon-arrowreturnthick-1-e {
1382
+ background-position: -32px -64px;
1383
+ }
1384
+
1385
+ .ui-icon-arrowreturnthick-1-s {
1386
+ background-position: -48px -64px;
1387
+ }
1388
+
1389
+ .ui-icon-arrowreturn-1-w {
1390
+ background-position: -64px -64px;
1391
+ }
1392
+
1393
+ .ui-icon-arrowreturn-1-n {
1394
+ background-position: -80px -64px;
1395
+ }
1396
+
1397
+ .ui-icon-arrowreturn-1-e {
1398
+ background-position: -96px -64px;
1399
+ }
1400
+
1401
+ .ui-icon-arrowreturn-1-s {
1402
+ background-position: -112px -64px;
1403
+ }
1404
+
1405
+ .ui-icon-arrowrefresh-1-w {
1406
+ background-position: -128px -64px;
1407
+ }
1408
+
1409
+ .ui-icon-arrowrefresh-1-n {
1410
+ background-position: -144px -64px;
1411
+ }
1412
+
1413
+ .ui-icon-arrowrefresh-1-e {
1414
+ background-position: -160px -64px;
1415
+ }
1416
+
1417
+ .ui-icon-arrowrefresh-1-s {
1418
+ background-position: -176px -64px;
1419
+ }
1420
+
1421
+ .ui-icon-arrow-4 {
1422
+ background-position: 0 -80px;
1423
+ }
1424
+
1425
+ .ui-icon-arrow-4-diag {
1426
+ background-position: -16px -80px;
1427
+ }
1428
+
1429
+ .ui-icon-extlink {
1430
+ background-position: -32px -80px;
1431
+ }
1432
+
1433
+ .ui-icon-newwin {
1434
+ background-position: -48px -80px;
1435
+ }
1436
+
1437
+ .ui-icon-refresh {
1438
+ background-position: -64px -80px;
1439
+ }
1440
+
1441
+ .ui-icon-shuffle {
1442
+ background-position: -80px -80px;
1443
+ }
1444
+
1445
+ .ui-icon-transfer-e-w {
1446
+ background-position: -96px -80px;
1447
+ }
1448
+
1449
+ .ui-icon-transferthick-e-w {
1450
+ background-position: -112px -80px;
1451
+ }
1452
+
1453
+ .ui-icon-folder-collapsed {
1454
+ background-position: 0 -96px;
1455
+ }
1456
+
1457
+ .ui-icon-folder-open {
1458
+ background-position: -16px -96px;
1459
+ }
1460
+
1461
+ .ui-icon-document {
1462
+ background-position: -32px -96px;
1463
+ }
1464
+
1465
+ .ui-icon-document-b {
1466
+ background-position: -48px -96px;
1467
+ }
1468
+
1469
+ .ui-icon-note {
1470
+ background-position: -64px -96px;
1471
+ }
1472
+
1473
+ .ui-icon-mail-closed {
1474
+ background-position: -80px -96px;
1475
+ }
1476
+
1477
+ .ui-icon-mail-open {
1478
+ background-position: -96px -96px;
1479
+ }
1480
+
1481
+ .ui-icon-suitcase {
1482
+ background-position: -112px -96px;
1483
+ }
1484
+
1485
+ .ui-icon-comment {
1486
+ background-position: -128px -96px;
1487
+ }
1488
+
1489
+ .ui-icon-person {
1490
+ background-position: -144px -96px;
1491
+ }
1492
+
1493
+ .ui-icon-print {
1494
+ background-position: -160px -96px;
1495
+ }
1496
+
1497
+ .ui-icon-trash {
1498
+ background-position: -176px -96px;
1499
+ }
1500
+
1501
+ .ui-icon-locked {
1502
+ background-position: -192px -96px;
1503
+ }
1504
+
1505
+ .ui-icon-unlocked {
1506
+ background-position: -208px -96px;
1507
+ }
1508
+
1509
+ .ui-icon-bookmark {
1510
+ background-position: -224px -96px;
1511
+ }
1512
+
1513
+ .ui-icon-tag {
1514
+ background-position: -240px -96px;
1515
+ }
1516
+
1517
+ .ui-icon-home {
1518
+ background-position: 0 -112px;
1519
+ }
1520
+
1521
+ .ui-icon-flag {
1522
+ background-position: -16px -112px;
1523
+ }
1524
+
1525
+ .ui-icon-calendar {
1526
+ background-position: -32px -112px;
1527
+ }
1528
+
1529
+ .ui-icon-cart {
1530
+ background-position: -48px -112px;
1531
+ }
1532
+
1533
+ .ui-icon-pencil {
1534
+ background-position: -64px -112px;
1535
+ }
1536
+
1537
+ .ui-icon-clock {
1538
+ background-position: -80px -112px;
1539
+ }
1540
+
1541
+ .ui-icon-disk {
1542
+ background-position: -96px -112px;
1543
+ }
1544
+
1545
+ .ui-icon-calculator {
1546
+ background-position: -112px -112px;
1547
+ }
1548
+
1549
+ .ui-icon-zoomin {
1550
+ background-position: -128px -112px;
1551
+ }
1552
+
1553
+ .ui-icon-zoomout {
1554
+ background-position: -144px -112px;
1555
+ }
1556
+
1557
+ .ui-icon-search {
1558
+ background-position: -160px -112px;
1559
+ }
1560
+
1561
+ .ui-icon-wrench {
1562
+ background-position: -176px -112px;
1563
+ }
1564
+
1565
+ .ui-icon-gear {
1566
+ background-position: -192px -112px;
1567
+ }
1568
+
1569
+ .ui-icon-heart {
1570
+ background-position: -208px -112px;
1571
+ }
1572
+
1573
+ .ui-icon-star {
1574
+ background-position: -224px -112px;
1575
+ }
1576
+
1577
+ .ui-icon-link {
1578
+ background-position: -240px -112px;
1579
+ }
1580
+
1581
+ .ui-icon-cancel {
1582
+ background-position: 0 -128px;
1583
+ }
1584
+
1585
+ .ui-icon-plus {
1586
+ background-position: -16px -128px;
1587
+ }
1588
+
1589
+ .ui-icon-plusthick {
1590
+ background-position: -32px -128px;
1591
+ }
1592
+
1593
+ .ui-icon-minus {
1594
+ background-position: -48px -128px;
1595
+ }
1596
+
1597
+ .ui-icon-minusthick {
1598
+ background-position: -64px -128px;
1599
+ }
1600
+
1601
+ .ui-icon-close {
1602
+ background-position: -80px -128px;
1603
+ }
1604
+
1605
+ .ui-icon-closethick {
1606
+ background-position: -96px -128px;
1607
+ }
1608
+
1609
+ .ui-icon-key {
1610
+ background-position: -112px -128px;
1611
+ }
1612
+
1613
+ .ui-icon-lightbulb {
1614
+ background-position: -128px -128px;
1615
+ }
1616
+
1617
+ .ui-icon-scissors {
1618
+ background-position: -144px -128px;
1619
+ }
1620
+
1621
+ .ui-icon-clipboard {
1622
+ background-position: -160px -128px;
1623
+ }
1624
+
1625
+ .ui-icon-copy {
1626
+ background-position: -176px -128px;
1627
+ }
1628
+
1629
+ .ui-icon-contact {
1630
+ background-position: -192px -128px;
1631
+ }
1632
+
1633
+ .ui-icon-image {
1634
+ background-position: -208px -128px;
1635
+ }
1636
+
1637
+ .ui-icon-video {
1638
+ background-position: -224px -128px;
1639
+ }
1640
+
1641
+ .ui-icon-script {
1642
+ background-position: -240px -128px;
1643
+ }
1644
+
1645
+ .ui-icon-alert {
1646
+ background-position: 0 -144px;
1647
+ }
1648
+
1649
+ .ui-icon-info {
1650
+ background-position: -16px -144px;
1651
+ }
1652
+
1653
+ .ui-icon-notice {
1654
+ background-position: -32px -144px;
1655
+ }
1656
+
1657
+ .ui-icon-help {
1658
+ background-position: -48px -144px;
1659
+ }
1660
+
1661
+ .ui-icon-check {
1662
+ background-position: -64px -144px;
1663
+ }
1664
+
1665
+ .ui-icon-bullet {
1666
+ background-position: -80px -144px;
1667
+ }
1668
+
1669
+ .ui-icon-radio-on {
1670
+ background-position: -96px -144px;
1671
+ }
1672
+
1673
+ .ui-icon-radio-off {
1674
+ background-position: -112px -144px;
1675
+ }
1676
+
1677
+ .ui-icon-pin-w {
1678
+ background-position: -128px -144px;
1679
+ }
1680
+
1681
+ .ui-icon-pin-s {
1682
+ background-position: -144px -144px;
1683
+ }
1684
+
1685
+ .ui-icon-play {
1686
+ background-position: 0 -160px;
1687
+ }
1688
+
1689
+ .ui-icon-pause {
1690
+ background-position: -16px -160px;
1691
+ }
1692
+
1693
+ .ui-icon-seek-next {
1694
+ background-position: -32px -160px;
1695
+ }
1696
+
1697
+ .ui-icon-seek-prev {
1698
+ background-position: -48px -160px;
1699
+ }
1700
+
1701
+ .ui-icon-seek-end {
1702
+ background-position: -64px -160px;
1703
+ }
1704
+
1705
+ .ui-icon-seek-start {
1706
+ background-position: -80px -160px;
1707
+ }
1708
+
1709
+ /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
1710
+ .ui-icon-seek-first {
1711
+ background-position: -80px -160px;
1712
+ }
1713
+
1714
+ .ui-icon-stop {
1715
+ background-position: -96px -160px;
1716
+ }
1717
+
1718
+ .ui-icon-eject {
1719
+ background-position: -112px -160px;
1720
+ }
1721
+
1722
+ .ui-icon-volume-off {
1723
+ background-position: -128px -160px;
1724
+ }
1725
+
1726
+ .ui-icon-volume-on {
1727
+ background-position: -144px -160px;
1728
+ }
1729
+
1730
+ .ui-icon-power {
1731
+ background-position: 0 -176px;
1732
+ }
1733
+
1734
+ .ui-icon-signal-diag {
1735
+ background-position: -16px -176px;
1736
+ }
1737
+
1738
+ .ui-icon-signal {
1739
+ background-position: -32px -176px;
1740
+ }
1741
+
1742
+ .ui-icon-battery-0 {
1743
+ background-position: -48px -176px;
1744
+ }
1745
+
1746
+ .ui-icon-battery-1 {
1747
+ background-position: -64px -176px;
1748
+ }
1749
+
1750
+ .ui-icon-battery-2 {
1751
+ background-position: -80px -176px;
1752
+ }
1753
+
1754
+ .ui-icon-battery-3 {
1755
+ background-position: -96px -176px;
1756
+ }
1757
+
1758
+ .ui-icon-circle-plus {
1759
+ background-position: 0 -192px;
1760
+ }
1761
+
1762
+ .ui-icon-circle-minus {
1763
+ background-position: -16px -192px;
1764
+ }
1765
+
1766
+ .ui-icon-circle-close {
1767
+ background-position: -32px -192px;
1768
+ }
1769
+
1770
+ .ui-icon-circle-triangle-e {
1771
+ background-position: -48px -192px;
1772
+ }
1773
+
1774
+ .ui-icon-circle-triangle-s {
1775
+ background-position: -64px -192px;
1776
+ }
1777
+
1778
+ .ui-icon-circle-triangle-w {
1779
+ background-position: -80px -192px;
1780
+ }
1781
+
1782
+ .ui-icon-circle-triangle-n {
1783
+ background-position: -96px -192px;
1784
+ }
1785
+
1786
+ .ui-icon-circle-arrow-e {
1787
+ background-position: -112px -192px;
1788
+ }
1789
+
1790
+ .ui-icon-circle-arrow-s {
1791
+ background-position: -128px -192px;
1792
+ }
1793
+
1794
+ .ui-icon-circle-arrow-w {
1795
+ background-position: -144px -192px;
1796
+ }
1797
+
1798
+ .ui-icon-circle-arrow-n {
1799
+ background-position: -160px -192px;
1800
+ }
1801
+
1802
+ .ui-icon-circle-zoomin {
1803
+ background-position: -176px -192px;
1804
+ }
1805
+
1806
+ .ui-icon-circle-zoomout {
1807
+ background-position: -192px -192px;
1808
+ }
1809
+
1810
+ .ui-icon-circle-check {
1811
+ background-position: -208px -192px;
1812
+ }
1813
+
1814
+ .ui-icon-circlesmall-plus {
1815
+ background-position: 0 -208px;
1816
+ }
1817
+
1818
+ .ui-icon-circlesmall-minus {
1819
+ background-position: -16px -208px;
1820
+ }
1821
+
1822
+ .ui-icon-circlesmall-close {
1823
+ background-position: -32px -208px;
1824
+ }
1825
+
1826
+ .ui-icon-squaresmall-plus {
1827
+ background-position: -48px -208px;
1828
+ }
1829
+
1830
+ .ui-icon-squaresmall-minus {
1831
+ background-position: -64px -208px;
1832
+ }
1833
+
1834
+ .ui-icon-squaresmall-close {
1835
+ background-position: -80px -208px;
1836
+ }
1837
+
1838
+ .ui-icon-grip-dotted-vertical {
1839
+ background-position: 0 -224px;
1840
+ }
1841
+
1842
+ .ui-icon-grip-dotted-horizontal {
1843
+ background-position: -16px -224px;
1844
+ }
1845
+
1846
+ .ui-icon-grip-solid-vertical {
1847
+ background-position: -32px -224px;
1848
+ }
1849
+
1850
+ .ui-icon-grip-solid-horizontal {
1851
+ background-position: -48px -224px;
1852
+ }
1853
+
1854
+ .ui-icon-gripsmall-diagonal-se {
1855
+ background-position: -64px -224px;
1856
+ }
1857
+
1858
+ .ui-icon-grip-diagonal-se {
1859
+ background-position: -80px -224px;
1860
+ }
1861
+
1862
+ /* Misc visuals
1863
+ ----------------------------------*/
1864
+
1865
+ /* Corner radius */
1866
+ .ui-corner-all,
1867
+ .ui-corner-top,
1868
+ .ui-corner-left,
1869
+ .ui-corner-tl {
1870
+ border-top-left-radius: 4px;
1871
+ }
1872
+
1873
+ .ui-corner-all,
1874
+ .ui-corner-top,
1875
+ .ui-corner-right,
1876
+ .ui-corner-tr {
1877
+ border-top-right-radius: 4px;
1878
+ }
1879
+
1880
+ .ui-corner-all,
1881
+ .ui-corner-bottom,
1882
+ .ui-corner-left,
1883
+ .ui-corner-bl {
1884
+ border-bottom-left-radius: 4px;
1885
+ }
1886
+
1887
+ .ui-corner-all,
1888
+ .ui-corner-bottom,
1889
+ .ui-corner-right,
1890
+ .ui-corner-br {
1891
+ border-bottom-right-radius: 4px;
1892
+ }
1893
+
1894
+ /* Overlays */
1895
+ .ui-widget-overlay {
1896
+ background: #aaaaaa url("../images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;
1897
+ opacity: .3;
1898
+ filter: Alpha(Opacity=30); /* support: IE8 */
1899
+ }
1900
+
1901
  .ui-widget-shadow {
1902
+ margin: -8px 0 0 -8px;
1903
+ padding: 8px;
1904
+ background: #aaaaaa url("../images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;
1905
+ opacity: .3;
1906
+ filter: Alpha(Opacity=30); /* support: IE8 */
1907
+ border-radius: 8px;
1908
  }
assets/css/log.css CHANGED
@@ -1,55 +1,58 @@
1
  @media print {
2
- #wpadminbar,
3
- #adminmenuback,
4
- #adminmenuwrap,
5
- #show-settings-link {
6
- display: none;
7
- }
8
-
9
- #wpcontent, #wpfooter {
10
- margin-left: 0px;
11
- }
12
  }
13
 
14
  #wps-postbox-container-1 {
15
  width: 30%;
16
- float: left;
17
  }
18
 
19
  #wps-postbox-container-2 {
20
  margin: 0 0 0 1%;
21
  width: 68%;
22
- float: right;
23
  }
24
 
25
  @media screen and (max-width: 960px) {
26
- #wps-postbox-container-1 {
27
- width: 35%;
28
- }
29
- #wps-postbox-container-2 {
30
- margin: 0 0 0 1%;
31
- width: 63%;
32
- }
 
33
  }
34
 
35
  @media screen and (max-width: 758px) {
36
- #wps-postbox-container-1 {
37
- width: 100%;
38
- }
39
- #wps-postbox-container-2 {
40
- margin: 0 0 0 1%;
41
- width: 100%;
42
- }
 
43
  }
44
 
45
  @media screen and (max-width: 524px) {
46
- #wps-postbox-container-1 {
47
- width: 100%;
48
- }
49
- #wps-postbox-container-2 {
50
- margin: 0 0 0 1%;
51
- width: 100%;
52
- }
 
53
  }
54
 
55
  #last-log {
@@ -73,12 +76,12 @@
73
 
74
  #summary-stats span {
75
  color: #21759B !important;
76
- font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
77
  font-size: 21px;
78
  }
79
 
80
  #post-stats {
81
- border: none;
82
  }
83
 
84
  #th-colspan {
@@ -165,7 +168,7 @@
165
  .log-item {
166
  border-bottom: 1px solid #D3CDCD;
167
  border-top: 1px solid #FFFFFF;
168
- min-height: 46px;
169
  padding: 3px 7px;
170
  }
171
 
@@ -180,17 +183,17 @@
180
  .log-referred {
181
  float: left;
182
  white-space: nowrap;
183
- overflow: hidden;
184
- text-overflow: ellipsis;
185
- width: auto;
186
  }
187
 
188
  .log-page-title {
189
  float: left;
190
  overflow: hidden;
191
  white-space: nowrap;
192
- text-overflow: ellipsis;
193
- width: 100%;
194
  }
195
 
196
  .log-ip {
@@ -199,9 +202,9 @@
199
  font-size: 10px;
200
  margin-bottom: 5px;
201
  white-space: pre;
202
- overflow: hidden;
203
- text-overflow: ellipsis;
204
- text-align: right;
205
  }
206
 
207
  .log-tools {
@@ -220,8 +223,8 @@
220
  margin: 0 0 0 2px;
221
  white-space: nowrap;
222
  width: 100%;
223
- overflow: hidden;
224
- text-overflow: ellipsis;
225
  }
226
 
227
  .log-url img {
@@ -249,9 +252,8 @@
249
  #wps_summary_postbox,
250
  #wps_browsers_postbox,
251
  #wps_referring_postbox,
252
- #wps_countries_postbox
253
- {
254
- overflow: hidden;
255
  }
256
 
257
  #time_zone a {
@@ -292,8 +294,8 @@
292
  direction: ltr;
293
  }
294
 
295
- #page-stats{
296
- direction: ltr;
297
  }
298
 
299
  #about-links {
@@ -327,9 +329,9 @@
327
  }
328
 
329
  .jqvmap-label {
330
- z-index: 10000;
331
  }
332
 
333
  .ui-sortable {
334
- min-height: 100px;
335
  }
1
  @media print {
2
+ #wpadminbar,
3
+ #adminmenuback,
4
+ #adminmenuwrap,
5
+ #show-settings-link {
6
+ display: none;
7
+ }
8
+
9
+ #wpcontent, #wpfooter {
10
+ margin-left: 0px;
11
+ }
12
  }
13
 
14
  #wps-postbox-container-1 {
15
  width: 30%;
16
+ float: left;
17
  }
18
 
19
  #wps-postbox-container-2 {
20
  margin: 0 0 0 1%;
21
  width: 68%;
22
+ float: right;
23
  }
24
 
25
  @media screen and (max-width: 960px) {
26
+ #wps-postbox-container-1 {
27
+ width: 35%;
28
+ }
29
+
30
+ #wps-postbox-container-2 {
31
+ margin: 0 0 0 1%;
32
+ width: 63%;
33
+ }
34
  }
35
 
36
  @media screen and (max-width: 758px) {
37
+ #wps-postbox-container-1 {
38
+ width: 100%;
39
+ }
40
+
41
+ #wps-postbox-container-2 {
42
+ margin: 0 0 0 1%;
43
+ width: 100%;
44
+ }
45
  }
46
 
47
  @media screen and (max-width: 524px) {
48
+ #wps-postbox-container-1 {
49
+ width: 100%;
50
+ }
51
+
52
+ #wps-postbox-container-2 {
53
+ margin: 0 0 0 1%;
54
+ width: 100%;
55
+ }
56
  }
57
 
58
  #last-log {
76
 
77
  #summary-stats span {
78
  color: #21759B !important;
79
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
80
  font-size: 21px;
81
  }
82
 
83
  #post-stats {
84
+ border: none;
85
  }
86
 
87
  #th-colspan {
168
  .log-item {
169
  border-bottom: 1px solid #D3CDCD;
170
  border-top: 1px solid #FFFFFF;
171
+ min-height: 46px;
172
  padding: 3px 7px;
173
  }
174
 
183
  .log-referred {
184
  float: left;
185
  white-space: nowrap;
186
+ overflow: hidden;
187
+ text-overflow: ellipsis;
188
+ width: auto;
189
  }
190
 
191
  .log-page-title {
192
  float: left;
193
  overflow: hidden;
194
  white-space: nowrap;
195
+ text-overflow: ellipsis;
196
+ width: 100%;
197
  }
198
 
199
  .log-ip {
202
  font-size: 10px;
203
  margin-bottom: 5px;
204
  white-space: pre;
205
+ overflow: hidden;
206
+ text-overflow: ellipsis;
207
+ text-align: right;
208
  }
209
 
210
  .log-tools {
223
  margin: 0 0 0 2px;
224
  white-space: nowrap;
225
  width: 100%;
226
+ overflow: hidden;
227
+ text-overflow: ellipsis;
228
  }
229
 
230
  .log-url img {
252
  #wps_summary_postbox,
253
  #wps_browsers_postbox,
254
  #wps_referring_postbox,
255
+ #wps_countries_postbox {
256
+ overflow: hidden;
 
257
  }
258
 
259
  #time_zone a {
294
  direction: ltr;
295
  }
296
 
297
+ #page-stats {
298
+ direction: ltr;
299
  }
300
 
301
  #about-links {
329
  }
330
 
331
  .jqvmap-label {
332
+ z-index: 10000;
333
  }
334
 
335
  .ui-sortable {
336
+ min-height: 100px;
337
  }
assets/css/pagination.css CHANGED
@@ -4,6 +4,7 @@
4
  padding: 14px 0 0;
5
  text-align: center;
6
  }
 
7
  .pageOn {
8
  background: none repeat scroll 0 0 #4dcdff;
9
  border: 1px solid #60a8ff;
@@ -13,6 +14,7 @@
13
  margin: 2px;
14
  padding: 5px 10px;
15
  }
 
16
  .pageOff {
17
  background: none repeat scroll 0 0 #ffffff;
18
  border: 1px solid #dadada;
@@ -22,16 +24,20 @@
22
  padding: 5px 9px;
23
  text-shadow: 1px 1px #ffffff;
24
  }
 
25
  .pageOff:hover {
26
  }
 
27
  .pageOff a {
28
  box-shadow: 0 1px 0 #ffffff inset;
29
  color: #aaaaaa;
30
  padding: 5px 8px;
31
  }
 
32
  .paginationSelect {
33
  background: none repeat scroll 0 0 #eeeeee;
34
  }
 
35
  .paginationErrors {
36
  background: none repeat scroll 0 0 #ffdd99;
37
  border: 2px dashed #dd9900;
@@ -42,6 +48,7 @@
42
  text-align: left;
43
  width: 70%;
44
  }
 
45
  #result-log {
46
  color: #148e00;
47
  direction: rtl;
4
  padding: 14px 0 0;
5
  text-align: center;
6
  }
7
+
8
  .pageOn {
9
  background: none repeat scroll 0 0 #4dcdff;
10
  border: 1px solid #60a8ff;
14
  margin: 2px;
15
  padding: 5px 10px;
16
  }
17
+
18
  .pageOff {
19
  background: none repeat scroll 0 0 #ffffff;
20
  border: 1px solid #dadada;
24
  padding: 5px 9px;
25
  text-shadow: 1px 1px #ffffff;
26
  }
27
+
28
  .pageOff:hover {
29
  }
30
+
31
  .pageOff a {
32
  box-shadow: 0 1px 0 #ffffff inset;
33
  color: #aaaaaa;
34
  padding: 5px 8px;
35
  }
36
+
37
  .paginationSelect {
38
  background: none repeat scroll 0 0 #eeeeee;
39
  }
40
+
41
  .paginationErrors {
42
  background: none repeat scroll 0 0 #ffdd99;
43
  border: 2px dashed #dd9900;
48
  text-align: left;
49
  width: 70%;
50
  }
51
+
52
  #result-log {
53
  color: #148e00;
54
  direction: rtl;
assets/css/rtl.css CHANGED
@@ -17,23 +17,23 @@
17
  float: left;
18
  }
19
 
20
- #last-log{
21
- direction: rtl;
22
  }
23
 
24
- .ui-widget, .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button{
25
- font-family: tahoma;
26
  }
27
 
28
- .ui-tabs .ui-tabs-nav li{
29
- float: right;
30
  }
31
 
32
- .jqvmap-label{
33
- direction: ltr;
34
  }
35
 
36
- .jqplot-table-legend, .jqplot-highlighter-tooltip{
37
  direction: rtl;
38
  font-family: tahoma;
39
  }
@@ -47,9 +47,9 @@
47
  }
48
 
49
  .left-div {
50
- float: right;
51
  }
52
 
53
  .right-div {
54
- float: left;
55
  }
17
  float: left;
18
  }
19
 
20
+ #last-log {
21
+ direction: rtl;
22
  }
23
 
24
+ .ui-widget, .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
25
+ font-family: tahoma;
26
  }
27
 
28
+ .ui-tabs .ui-tabs-nav li {
29
+ float: right;
30
  }
31
 
32
+ .jqvmap-label {
33
+ direction: ltr;
34
  }
35
 
36
+ .jqplot-table-legend, .jqplot-highlighter-tooltip {
37
  direction: rtl;
38
  font-family: tahoma;
39
  }
47
  }
48
 
49
  .left-div {
50
+ float: right;
51
  }
52
 
53
  .right-div {
54
+ float: left;
55
  }
assets/css/style.css CHANGED
@@ -3,11 +3,13 @@
3
  font-size: 11px !important;
4
  font-weight: bold;
5
  }
 
6
  .data {
7
  border-top: 1px solid #CFCDCD;
8
  font-size: 11px !important;
9
  padding: 5px 0 0;
10
  }
 
11
  .data code {
12
  border-radius: 2px 2px 2px 2px;
13
  }
3
  font-size: 11px !important;
4
  font-weight: bold;
5
  }
6
+
7
  .data {
8
  border-top: 1px solid #CFCDCD;
9
  font-size: 11px !important;
10
  padding: 5px 0 0;
11
  }
12
+
13
  .data code {
14
  border-radius: 2px 2px 2px 2px;
15
  }
assets/images/HTML.png DELETED
Binary file
assets/images/ODT.png DELETED
Binary file
assets/images/logo-250.png CHANGED
Binary file
assets/js/dashboard.js CHANGED
@@ -1,74 +1,75 @@
1
  /*
2
- Function to handle the loading of widget content
3
- */
4
-
5
- function wp_statistics_get_widget_contents( widget, container_id ) {
6
- var data = {
7
- 'action': 'wp_statistics_get_widget_contents',
8
- 'widget': widget,
9
- 'format': 'dashboard'
10
- };
11
-
12
- container = jQuery("#" + container_id);
13
-
14
- if( container.is( ':visible' ) ) {
15
- jQuery.ajax({ url: ajaxurl,
16
- type: 'post',
17
- data: data,
18
- datatype: 'json',
19
- })
20
- .always(function(result){
21
- // Take the returned result and add it to the DOM.
22
- jQuery("#" + container_id).html("").html(result);
23
- })
24
- .fail(function(result){
25
- // If we failed for some reason, like a timeout, try again.
26
- container.html(wp_statistics_loading_image);
27
- wp_statistics_get_widget_contents( widget, container_id );
28
- });
29
-
30
- }
 
31
  }
32
 
33
  function wp_statistics_refresh_widget() {
34
- var container_id = this.id.replace( '_refresh_button', '' );
35
- container_id = container_id.replace( '-widget', '-div' );
36
-
37
- var widget = container_id.replace( 'wp-statistics-', '' );
38
- widget = widget.replace( '-div', '' );
39
- widget = widget.replace( '-', '.' );
40
-
41
- container = jQuery("#" + container_id);
42
-
43
- if( container.is( ':visible' ) ) {
44
- container.html(wp_statistics_loading_image);
45
-
46
- wp_statistics_get_widget_contents( widget, container_id );
47
- }
48
-
49
- return false;
50
  }
51
 
52
  function wp_statistics_refresh_on_toggle_widget() {
53
- if( this.value.substring(0, 14) != 'wp-statistics-' ) {
54
- return;
55
- }
56
-
57
- var container_id = this.value.replace( '-widget', '-div' );
58
- var widget = container_id.replace( 'wp-statistics-', '' );
59
- widget = widget.replace( '-div', '' );
60
- widget = widget.replace( '-', '.' );
61
-
62
- wp_statistics_get_widget_contents( widget, container_id );
63
  }
64
 
65
  function wp_statistics_goto_more() {
66
- var widget = this.id;
67
-
68
- if( wp_statistics_destinations[widget] !== undefined ) {
69
- window.location.href = wp_statistics_destinations[widget];
70
- }
71
-
72
- return false;
73
  }
74
 
1
  /*
2
+ Function to handle the loading of widget content
3
+ */
4
+
5
+ function wp_statistics_get_widget_contents(widget, container_id) {
6
+ var data = {
7
+ 'action': 'wp_statistics_get_widget_contents',
8
+ 'widget': widget,
9
+ 'format': 'dashboard'
10
+ };
11
+
12
+ container = jQuery("#" + container_id);
13
+
14
+ if (container.is(':visible')) {
15
+ jQuery.ajax({
16
+ url: ajaxurl,
17
+ type: 'post',
18
+ data: data,
19
+ datatype: 'json',
20
+ })
21
+ .always(function (result) {
22
+ // Take the returned result and add it to the DOM.
23
+ jQuery("#" + container_id).html("").html(result);
24
+ })
25
+ .fail(function (result) {
26
+ // If we failed for some reason, like a timeout, try again.
27
+ container.html(wp_statistics_loading_image);
28
+ wp_statistics_get_widget_contents(widget, container_id);
29
+ });
30
+
31
+ }
32
  }
33
 
34
  function wp_statistics_refresh_widget() {
35
+ var container_id = this.id.replace('_refresh_button', '');
36
+ container_id = container_id.replace('-widget', '-div');
37
+
38
+ var widget = container_id.replace('wp-statistics-', '');
39
+ widget = widget.replace('-div', '');
40
+ widget = widget.replace('-', '.');
41
+
42
+ container = jQuery("#" + container_id);
43
+
44
+ if (container.is(':visible')) {
45
+ container.html(wp_statistics_loading_image);
46
+
47
+ wp_statistics_get_widget_contents(widget, container_id);
48
+ }
49
+
50
+ return false;
51
  }
52
 
53
  function wp_statistics_refresh_on_toggle_widget() {
54
+ if (this.value.substring(0, 14) != 'wp-statistics-') {
55
+ return;
56
+ }
57
+
58
+ var container_id = this.value.replace('-widget', '-div');
59
+ var widget = container_id.replace('wp-statistics-', '');
60
+ widget = widget.replace('-div', '');
61
+ widget = widget.replace('-', '.');
62
+
63
+ wp_statistics_get_widget_contents(widget, container_id);
64
  }
65
 
66
  function wp_statistics_goto_more() {
67
+ var widget = this.id;
68
+
69
+ if (wp_statistics_destinations[widget] !== undefined) {
70
+ window.location.href = wp_statistics_destinations[widget];
71
+ }
72
+
73
+ return false;
74
  }
75
 
assets/js/editor.js CHANGED
@@ -1,65 +1,66 @@
1
  /*
2
- Function to handle the loading of widget content
3
- */
4
 
5
- function wp_statistics_get_widget_contents( widget, container_id ) {
6
- var data = {
7
- 'action': 'wp_statistics_get_widget_contents',
8
- 'widget': widget,
9
- 'page-id': wp_statistics_current_id,
10
- };
11
-
12
- container = jQuery("#" + container_id);
13
 
14
- if( container.is( ':visible' ) ) {
15
- jQuery.ajax({ url: ajaxurl,
16
- type: 'post',
17
- data: data,
18
- datatype: 'json',
19
- })
20
- .always(function(result){
21
- // Take the returned result and add it to the DOM.
22
- jQuery("#" + container_id).html("").html(result);
23
- })
24
- .fail(function(result){
25
- // If we failed for some reason, like a timeout, try again.
26
- container.html(wp_statistics_loading_image);
27
- wp_statistics_get_widget_contents( widget, container_id );
28
- });
29
-
30
- }
 
 
 
31
  }
32
 
33
  function wp_statistics_refresh_widget() {
34
- var container_id = 'wp-statistics-page-div';
35
- var widget = 'page';
 
 
 
 
 
36
 
37
- container = jQuery("#" + container_id);
38
- container.html(wp_statistics_loading_image);
39
-
40
- wp_statistics_get_widget_contents( widget, container_id );
41
-
42
- return false;
43
  }
44
 
45
  function wp_statistics_refresh_on_toggle_widget() {
46
- if( this.value != 'wp_statistics_editor_meta_box' ) {
47
- return;
48
- }
49
-
50
- var container_id = 'wp-statistics-page-div';
51
- var widget = 'page';
52
 
53
- wp_statistics_get_widget_contents( widget, container_id );
 
 
 
54
  }
55
 
56
  function wp_statistics_goto_more() {
57
- var widget = this.id;
58
-
59
- if( wp_statistics_destinations[widget] !== undefined ) {
60
- window.location.href = wp_statistics_destinations[widget] + wp_statistics_current_id;
61
- }
62
-
63
- return false;
64
  }
65
 
1
  /*
2
+ Function to handle the loading of widget content
3
+ */
4
 
5
+ function wp_statistics_get_widget_contents(widget, container_id) {
6
+ var data = {
7
+ 'action': 'wp_statistics_get_widget_contents',
8
+ 'widget': widget,
9
+ 'page-id': wp_statistics_current_id,
10
+ };
 
 
11
 
12
+ container = jQuery("#" + container_id);
13
+
14
+ if (container.is(':visible')) {
15
+ jQuery.ajax({
16
+ url: ajaxurl,
17
+ type: 'post',
18
+ data: data,
19
+ datatype: 'json',
20
+ })
21
+ .always(function (result) {
22
+ // Take the returned result and add it to the DOM.
23
+ jQuery("#" + container_id).html("").html(result);
24
+ })
25
+ .fail(function (result) {
26
+ // If we failed for some reason, like a timeout, try again.
27
+ container.html(wp_statistics_loading_image);
28
+ wp_statistics_get_widget_contents(widget, container_id);
29
+ });
30
+
31
+ }
32
  }
33
 
34
  function wp_statistics_refresh_widget() {
35
+ var container_id = 'wp-statistics-page-div';
36
+ var widget = 'page';
37
+
38
+ container = jQuery("#" + container_id);
39
+ container.html(wp_statistics_loading_image);
40
+
41
+ wp_statistics_get_widget_contents(widget, container_id);
42
 
43
+ return false;
 
 
 
 
 
44
  }
45
 
46
  function wp_statistics_refresh_on_toggle_widget() {
47
+ if (this.value != 'wp_statistics_editor_meta_box') {
48
+ return;
49
+ }
 
 
 
50
 
51
+ var container_id = 'wp-statistics-page-div';
52
+ var widget = 'page';
53
+
54
+ wp_statistics_get_widget_contents(widget, container_id);
55
  }
56
 
57
  function wp_statistics_goto_more() {
58
+ var widget = this.id;
59
+
60
+ if (wp_statistics_destinations[widget] !== undefined) {
61
+ window.location.href = wp_statistics_destinations[widget] + wp_statistics_current_id;
62
+ }
63
+
64
+ return false;
65
  }
66
 
assets/js/log.js CHANGED
@@ -1,68 +1,69 @@
1
  /*
2
- Function to handle the loading of widget content
3
- */
4
-
5
- function wp_statistics_get_widget_contents( widget, container_id ) {
6
- var data = {
7
- 'action': 'wp_statistics_get_widget_contents',
8
- 'widget': widget,
9
- };
10
-
11
- container = jQuery("#" + container_id);
12
-
13
- if( container.is( ':visible' ) ) {
14
- jQuery.ajax({ url: ajaxurl,
15
- type: 'post',
16
- data: data,
17
- datatype: 'json',
18
- })
19
- .always(function(result){
20
- // Take the returned result and add it to the DOM.
21
- jQuery("#" + container_id).html("").html(result);
22
- })
23
- .fail(function(result){
24
- // If we failed for some reason, like a timeout, try again.
25
- container.html(wp_statistics_loading_image);
26
- wp_statistics_get_widget_contents( widget, container_id );
27
- });
28
-
29
- }
 
30
  }
31
 
32
  function wp_statistics_refresh_widget() {
33
- var widget = this.id.replace( 'wps_', '' );
34
- widget = widget.replace( '_refresh_button', '' );
35
- container_id = widget.replace( '.', '_' ) + '_postbox';
36
-
37
- container = jQuery("#" + container_id);
38
-
39
- if( container.is( ':visible' ) ) {
40
- container.html(wp_statistics_loading_image);
41
-
42
- wp_statistics_get_widget_contents( widget, container_id );
43
- }
44
-
45
- return false;
46
  }
47
 
48
  function wp_statistics_refresh_on_toggle_widget() {
49
- if( this.value.substring(0, 4) != 'wps_' ) {
50
- return;
51
- }
52
-
53
- var container_id = this.value.replace( 'wps_', '' );
54
- var widget = container_id.replace( '_postbox', '' );
55
-
56
- wp_statistics_get_widget_contents( widget, container_id );
57
  }
58
 
59
  function wp_statistics_goto_more() {
60
- var widget = this.id;
61
-
62
- if( wp_statistics_destinations[widget] !== undefined ) {
63
- window.location.href = wp_statistics_destinations[widget];
64
- }
65
-
66
- return false;
67
  }
68
 
1
  /*
2
+ Function to handle the loading of widget content
3
+ */
4
+
5
+ function wp_statistics_get_widget_contents(widget, container_id) {
6
+ var data = {
7
+ 'action': 'wp_statistics_get_widget_contents',
8
+ 'widget': widget,
9
+ };
10
+
11
+ container = jQuery("#" + container_id);
12
+
13
+ if (container.is(':visible')) {
14
+ jQuery.ajax({
15
+ url: ajaxurl,
16
+ type: 'post',
17
+ data: data,
18
+ datatype: 'json',
19
+ })
20
+ .always(function (result) {
21
+ // Take the returned result and add it to the DOM.
22
+ jQuery("#" + container_id).html("").html(result);
23
+ })
24
+ .fail(function (result) {
25
+ // If we failed for some reason, like a timeout, try again.
26
+ container.html(wp_statistics_loading_image);
27
+ wp_statistics_get_widget_contents(widget, container_id);
28
+ });
29
+
30
+ }
31
  }
32
 
33
  function wp_statistics_refresh_widget() {
34
+ var widget = this.id.replace('wps_', '');
35
+ widget = widget.replace('_refresh_button', '');
36
+ container_id = widget.replace('.', '_') + '_postbox';
37
+
38
+ container = jQuery("#" + container_id);
39
+
40
+ if (container.is(':visible')) {
41
+ container.html(wp_statistics_loading_image);
42
+
43
+ wp_statistics_get_widget_contents(widget, container_id);
44
+ }
45
+
46
+ return false;
47
  }
48
 
49
  function wp_statistics_refresh_on_toggle_widget() {
50
+ if (this.value.substring(0, 4) != 'wps_') {
51
+ return;
52
+ }
53
+
54
+ var container_id = this.value.replace('wps_', '');
55
+ var widget = container_id.replace('_postbox', '');
56
+
57
+ wp_statistics_get_widget_contents(widget, container_id);
58
  }
59
 
60
  function wp_statistics_goto_more() {
61
+ var widget = this.id;
62
+
63
+ if (wp_statistics_destinations[widget] !== undefined) {
64
+ window.location.href = wp_statistics_destinations[widget];
65
+ }
66
+
67
+ return false;
68
  }
69
 
changelog.txt CHANGED
@@ -1,105 +1,4 @@
1
  == Changelog ==
2
- = 11.0.3 =
3
- * Release Date: January 13, 2017
4
- * Added: Option to reset plugin options without deleting the data.
5
- * Fixed: If IP hashing as enabled a PHP would be generated during the hashing.
6
- * Fixed: Typo in JavaScript code that would cause some errors not to be displayed.
7
- * Fixed: Make sure the historical table exists before checking the keys on it which would cause extra output to be generated on first install.
8
- * Updated: RTL CSS styles for left/right div's in the admin dashboard, thanks sszdh.
9
-
10
- = 11.0.2 =
11
- * Release Date: December 1, 2016
12
- * Fixed: Top visitors page css for date picker.
13
- * Fixed: Incorrect url for link on recent visitors widget.
14
- * Fixed: Make sure the tick intervals are always whole numbers, otherwise the axis ticks won't match up with the data on line charts.
15
- * Fixed: Make sure when looking up a page/post ID for a URL to take the latest visited id instead of the first in case the URI has been reused.
16
- * Fixed: Duplicate display of hit statistics on hits page in some corner cases.
17
-
18
- = 11.0.1 =
19
- * Release Date: November 7, 2016
20
- * Fixed: Don't refresh a widget if it's not visible, fixes the widget being replaced by a spinner that never goes away.
21
- * Updated: Minimum PHP version is now 5.4.
22
- * Updated: Additional error checks for new IP code.
23
- * Updated: jqPlot library to version development version and added DST fix.
24
-
25
- = 11.0 =
26
- * Release Date: October 28, 2016
27
- * Added: IPv6 Support.
28
- * Added: Time attribute to searches shortcode.
29
- * Added: Basic print styles for the overview and log pages.
30
- * Fixed: Default provider for searches shortcode.
31
- * Fixed: Display of top sites list when the display port is very small would .
32
- * Fixed: CSS for date picker not loading.
33
- * Fixed: Incorrect stats on some pages for date ranges that end in the past.
34
- * Fixed: Date range selector on stats now properly displays a custom range after it has been set.
35
- * Fixed: "Empty" log widget columns could not have widgets added to them.
36
- * Updated: GeoIP library to version 1.1.1.
37
- * Updated: phpUserAgent library to 0.5.2.
38
- * Updated: Language on the front end widget to match the summary widget in the admin.
39
- * Removed: Check for bc math.
40
- * Removed: Last bits of google maps code.
41
-
42
- = 10.3 =
43
- * Release Date: August 19, 2016
44
- * Added: Support for minified css/js files and the SCRIPT_DEBUG WordPress define.
45
- * Added: <label> spans around the text for widget fields for easier styling.
46
- * Added: 'AdsBot-Google' to the robots list
47
- * Fixed: Pop up country information on the map dashboard widget will now stay on top of the WordPress dashboard menus.
48
- * Fixed: WP_DEBUG errors in front end widget.
49
- * Updated: JQVMap library to version 1.5.1.
50
- * Updated: jqPlot library to version 1.0.9.
51
- * Updated: GeoIP library to version 2.4.1.
52
-
53
- = 10.2 =
54
- * Release Date: August 2, 2016
55
- * Added: Support for use page id in Get_Historical_Data function.
56
- * Updated: jQuery CSS references.
57
- * Fixed: Various WP_DEBUG warnings.
58
- * Fixed: Incorrect URL in quick access widget for some of the totals.
59
- * Fixed: Make sure to escape the post title in the widget otherwise the graph may not be displayed correctly.
60
- * Removed: Google Maps support as Google no longer supports keyless access to the API (http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html).
61
-
62
- = 10.1 =
63
- * Release Date: April 3, 2016
64
- * Updated: Top pages page to list the stats for the selected date range in the page list.
65
- * Updated: Added check for gzopen() function to the Optimization page as some builds of PHP are broken and do not include it which causes the GeoIP download to fail causing a white screen of death in some cases.
66
- * Updated: Added check to make sure we can write to the upload directory before doing so.
67
- * Updated: User Agent Parser library updated to V0.5.1.
68
- * Updated: MaxMind Reader Library updated to V1.1.
69
- * Fixed: Only display the widgets on the overview page that have their features enabled.
70
- * Fixed: Top pages list failed when there were less than 5 pages to display.
71
- * Fixed: Manual download links did not function.
72
- * Fixed: Typo in function name for purging the database.
73
- * Fixed: Renamed the Czech and Danish translation file names to function correctly.
74
- * Fixed: Ensure we have a valid page id before record the stat to the database to avoid an error being recorded in the PHP error log.
75
-
76
- = 10.0.5 =
77
- * Release Date: February 5, 2016
78
- * Fixed: Date range selector display after entering a custom date range.
79
- * Fixed: Date ranges that ended in the past displaying the wrong visit/visitors data.
80
-
81
- = 10.0.4 =
82
- * Release Date: January 21, 2016
83
- * Fixed: Recent Visitors widget in the dashboard did not work.
84
- * Fixed: Top Visitors in Overview page would not reload.
85
- * Fixed: Links for yesterday and older visitors count went to wrong page.
86
- * Fixed: Typo in purge code that caused a fatal error.
87
-
88
- = 10.0.3 =
89
- * Release Date: January 19, 2016
90
- * Updated: Google map API now always uses https.
91
- * Fixed: Google map error that broken the overview page display of charts and the map.
92
-
93
- = 10.0.2 =
94
- * Release Date: January 19, 2016
95
- * Added: Additional error checking on widget load so they will retry if there is a failure.
96
- * Fixed: Added code to flush out invalid widget order user meta.
97
- * Fixed: Include Fatal Error if corrupt data was passed to the ajax widget code.
98
-
99
- = 10.0.1 =
100
- * Release Date: January 18, 2016
101
- * Fixed: If you re-ordered the widgets on the overview screen and then reloaded the page, all the widgets would disappear.
102
-
103
  = 10.0 =
104
  * Release Date: January 15, 2016
105
  * Added: Widgets now support reloading on overview and dashboard screen.
1
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  = 10.0 =
3
  * Release Date: January 15, 2016
4
  * Added: Widgets now support reloading on overview and dashboard screen.
dashboard.php CHANGED
@@ -1,202 +1,238 @@
1
  <?php
2
- add_action( 'wp_dashboard_setup', 'wp_statistics_dashboard_widget_load' );
3
- add_action( 'admin_footer', 'wp_statistics_dashboard_inline_javascript' );
4
-
5
- function wp_statistics_dashboard_widget_load() {
6
- GLOBAL $WP_Statistics;
7
-
8
- $WP_Statistics->load_user_options();
9
-
10
- // We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on
11
- // the first time they visit the dashboard though so check to see if we've been here before.
12
- if( !$WP_Statistics->get_user_option('dashboard_set') ) {
13
- $WP_Statistics->update_user_option('dashboard_set', WP_STATISTICS_VERSION);
14
-
15
- $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
16
- if( !is_array( $hidden_widgets ) ) { $hidden_widgets = array(); }
17
-
18
- $default_hidden = array('wp-statistics-browsers-widget','wp-statistics-countries-widget','wp-statistics-hitsmap-widget',
19
- 'wp-statistics-hits-widget','wp-statistics-pages-widget','wp-statistics-recent-widget','wp-statistics-referring-widget',
20
- 'wp-statistics-search-widget','wp-statistics-summary-widget','wp-statistics-words-widget', 'wp-statistics-top-visitors-widget' );
21
-
22
- foreach( $default_hidden as $widget ) {
23
- if( !in_array( $widget, $hidden_widgets ) ) {
24
- $hidden_widgets[] = $widget;
25
- }
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
-
28
- update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
29
  }
30
- else if( $WP_Statistics->get_user_option('dashboard_set') != WP_STATISTICS_VERSION ) {
31
- // We also have to fudge things when we add new widgets to the code base.
32
- if( version_compare( $WP_Statistics->get_user_option('dashboard_set'), '8.7', '<' ) ) {
33
-
34
- $WP_Statistics->update_user_option('dashboard_set', WP_STATISTICS_VERSION);
35
-
36
- $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
37
- if( !is_array( $hidden_widgets ) ) { $hidden_widgets = array(); }
38
-
39
- $default_hidden = array('wp-statistics-top-visitors-widget' );
40
-
41
- foreach( $default_hidden as $widget ) {
42
- if( !in_array( $widget, $hidden_widgets ) ) {
43
- $hidden_widgets[] = $widget;
44
- }
 
 
 
45
  }
46
-
47
- update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
48
  }
49
- }
50
-
51
- // If the user does not have at least read access to the status plugin, just return without adding the widgets.
52
- if (!current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_option')))) { return; }
53
-
54
- // If the admin has disabled the widgets, don't display them.
55
- if (!$WP_Statistics->get_option('disable_dashboard')) {
56
- wp_add_dashboard_widget( 'wp-statistics-quickstats-widget', __('Quick Stats', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'quickstats' ) );
57
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-browsers-widget', __('Top 10 Browsers', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'browsers' ) ); }
58
- if( $WP_Statistics->get_option('geoip') && $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-countries-widget', __('Top 10 Countries', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'countries' ) ); }
59
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-hitsmap-widget', __('Today\'s Visitor Map', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'hitsmap' ) ); }
60
- if( $WP_Statistics->get_option('visits') ) { wp_add_dashboard_widget( 'wp-statistics-hits-widget', __('Hit Statistics', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'hits' ) ); }
61
- if( $WP_Statistics->get_option('pages') ) { wp_add_dashboard_widget( 'wp-statistics-pages-widget', __('Top 10 Pages', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'pages' ) ); }
62
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-recent-widget', __('Recent Visitors', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'recent' ) ); }
63
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-referring-widget', __('Top Referring Sites', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'referring' ) ); }
64
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-search-widget', __('Search Engine Referrals', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'search' ) ); }
65
- wp_add_dashboard_widget( 'wp-statistics-summary-widget', __('Summary', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'summary' ) );
66
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-words-widget', __('Latest Search Words', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'words' ) ); }
67
- if( $WP_Statistics->get_option('visitors') ) { wp_add_dashboard_widget( 'wp-statistics-top-visitors-widget', __('Top 10 Visitors Today', 'wp_statistics'), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'top.visitors' ) ); }
68
  }
69
  }
70
 
71
- function wp_statistics_load_widget_css_and_scripts() {
72
- GLOBAL $WP_Statistics;
73
-
74
- // Load the css we use for the statistics pages.
75
- wp_enqueue_style('log-css', plugin_dir_url(__FILE__) . 'assets/css/log' . WP_STATISTICS_MIN_EXT . '.css', true, '1.1');
76
- wp_enqueue_style('jqplot-css', plugin_dir_url(__FILE__) . 'assets/jqplot/jquery.jqplot' . WP_STATISTICS_MIN_EXT . '.css', true, '1.0.9');
77
-
78
- // Don't forget the right to left support.
79
- if( is_rtl() ) {
80
- wp_enqueue_style('rtl-css', plugin_dir_url(__FILE__) . 'assets/css/rtl' . WP_STATISTICS_MIN_EXT . '.css', true, '1.1');
 
 
 
 
 
 
81
  }
82
-
83
- // Load the charts code.
84
- wp_enqueue_script('jqplot', plugin_dir_url(__FILE__) . 'assets/jqplot/jquery.jqplot' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
85
- wp_enqueue_script('jqplot-daterenderer', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.dateAxisRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
86
- wp_enqueue_script('jqplot-tickrenderer', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.canvasAxisTickRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
87
- wp_enqueue_script('jqplot-axisrenderer', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.canvasAxisLabelRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
88
- wp_enqueue_script('jqplot-textrenderer', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.canvasTextRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
89
- wp_enqueue_script('jqplot-tooltip', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.highlighter' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
90
- wp_enqueue_script('jqplot-pierenderer', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.pieRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
91
- wp_enqueue_script('jqplot-enhancedlengend', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.enhancedLegendRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
92
- wp_enqueue_script('jqplot-enhancedpielengend', plugin_dir_url(__FILE__) . 'assets/jqplot/plugins/jqplot.enhancedPieLegendRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9');
93
-
94
- wp_enqueue_style('jqvmap-css', plugin_dir_url(__FILE__) . 'assets/jqvmap/jqvmap' . WP_STATISTICS_MIN_EXT . '.css', true, '1.5.1');
95
- wp_enqueue_script('jquery-vmap', plugin_dir_url(__FILE__) . 'assets/jqvmap/jquery.vmap' . WP_STATISTICS_MIN_EXT . '.js', true, '1.5.1');
96
- wp_enqueue_script('jquery-vmap-world', plugin_dir_url(__FILE__) . 'assets/jqvmap/maps/jquery.vmap.world' . WP_STATISTICS_MIN_EXT . '.js', true, '1.5.1');
97
-
98
- $screen = get_current_screen();
99
-
100
- // Load our custom widgets handling javascript.
101
- if( 'post' == $screen->id || 'page' == $screen->id) {
102
- wp_enqueue_script('wp_statistics_editor', plugin_dir_url(__FILE__) . 'assets/js/editor' . WP_STATISTICS_MIN_EXT . '.js');
103
- } else {
104
- wp_enqueue_script('wp_statistics_dashboard', plugin_dir_url(__FILE__) . 'assets/js/dashboard' . WP_STATISTICS_MIN_EXT . '.js');
105
  }
106
  }
107
-
108
- function wp_statistics_generate_dashboard_postbox_contents( $post, $args ) {
109
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
110
- $widget = $args['args']['widget'];
111
- $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
112
-
113
- echo '<div id="' . $container_id . '">' . $loading_img .'</div>';
114
- wp_statistics_generate_widget_load_javascript( $widget, $container_id );
 
 
 
 
115
  }
116
 
117
-
118
- function wp_statistics_dashboard_inline_javascript() {
119
- $screen = get_current_screen();
 
 
 
 
 
 
 
120
 
121
- if( 'dashboard' != $screen->id ) {
122
- return;
123
- }
124
-
125
- wp_statistics_load_widget_css_and_scripts();
126
-
127
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
128
-
129
- $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
130
- $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
131
-
132
- $admin_url = get_admin_url() . "/admin.php?page=";
133
-
134
- $page_urls = array();
135
-
136
- $page_urls['wp-statistics-browsers-widget_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE;
137
- $page_urls['wp-statistics-countries-widget_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE;
138
- $page_urls['wp-statistics-exclusions-widget_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE;
139
- $page_urls['wp-statistics-hits-widget_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE;
140
- $page_urls['wp-statistics-online-widget_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE;
141
- $page_urls['wp-statistics-pages-widget_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE;
142
- $page_urls['wp-statistics-referring-widget_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE;
143
- $page_urls['wp-statistics-search-widget_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE;
144
- $page_urls['wp-statistics-words-widget_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE;
145
- $page_urls['wp-statistics-top-visitors-widget_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE;
146
- $page_urls['wp-statistics-visitors-widget_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE;
147
- $page_urls['wp-statistics-quickstats-widget_more_button'] = $admin_url . WP_STATISTICS_OVERVIEW_PAGE;
148
-
149
- ?>
150
- <script type="text/javascript">
151
- var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
152
- var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
153
-
154
- function wp_statistics_wait_for_postboxes() {
155
-
156
- if( ! jQuery('#show-settings-link').is( ':visible') ) {
157
- setTimeout( wp_statistics_wait_for_postboxes, 500 );
158
- }
159
-
160
- jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget );
161
- jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more );
162
 
163
- jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget );
 
 
 
 
164
  }
165
-
166
- jQuery(document).ready(function(){
167
-
168
- // Add the "more" and "refresh" buttons.
169
- jQuery('.postbox').each( function () {
170
- var temp = jQuery( this );
171
- var temp_id = temp.attr( 'id' );
172
-
173
- if( temp_id.substr( 0, 14 ) != 'wp-statistics-' ) {
174
- return;
175
- }
176
 
177
- var temp_html = temp.html();
178
-
179
- if( temp_id == 'wp-statistics-summary-widget' ) {
180
- new_text = '<?php echo $new_button;?>';
181
- new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' );
182
-
183
- temp_html = temp_html.replace( '</button>', new_text );
184
- } else {
185
- new_text = '<?php echo $new_buttons;?>';
186
- new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' );
187
- new_text = new_text.replace( '{{moreid}}', temp_id + '_more_button' );
188
-
189
- temp_html = temp_html.replace( '</button>', new_text );
190
- }
191
-
192
- temp.html( temp_html );
193
- });
194
-
195
- // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
196
- // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
197
- setTimeout( wp_statistics_wait_for_postboxes, 100 );
198
- });
199
- </script>
200
- <?php
201
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  ?>
1
  <?php
2
+ add_action( 'wp_dashboard_setup', 'wp_statistics_dashboard_widget_load' );
3
+ add_action( 'admin_footer', 'wp_statistics_dashboard_inline_javascript' );
4
+
5
+ function wp_statistics_dashboard_widget_load() {
6
+ GLOBAL $WP_Statistics;
7
+
8
+ $WP_Statistics->load_user_options();
9
+
10
+ // We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on
11
+ // the first time they visit the dashboard though so check to see if we've been here before.
12
+ if ( ! $WP_Statistics->get_user_option( 'dashboard_set' ) ) {
13
+ $WP_Statistics->update_user_option( 'dashboard_set', WP_STATISTICS_VERSION );
14
+
15
+ $hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', true );
16
+ if ( ! is_array( $hidden_widgets ) ) {
17
+ $hidden_widgets = array();
18
+ }
19
+
20
+ $default_hidden = array(
21
+ 'wp-statistics-browsers-widget',
22
+ 'wp-statistics-countries-widget',
23
+ 'wp-statistics-hitsmap-widget',
24
+ 'wp-statistics-hits-widget',
25
+ 'wp-statistics-pages-widget',
26
+ 'wp-statistics-recent-widget',
27
+ 'wp-statistics-referring-widget',
28
+ 'wp-statistics-search-widget',
29
+ 'wp-statistics-summary-widget',
30
+ 'wp-statistics-words-widget',
31
+ 'wp-statistics-top-visitors-widget'
32
+ );
33
+
34
+ foreach ( $default_hidden as $widget ) {
35
+ if ( ! in_array( $widget, $hidden_widgets ) ) {
36
+ $hidden_widgets[] = $widget;
37
  }
 
 
38
  }
39
+
40
+ update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
41
+ } else if ( $WP_Statistics->get_user_option( 'dashboard_set' ) != WP_STATISTICS_VERSION ) {
42
+ // We also have to fudge things when we add new widgets to the code base.
43
+ if ( version_compare( $WP_Statistics->get_user_option( 'dashboard_set' ), '8.7', '<' ) ) {
44
+
45
+ $WP_Statistics->update_user_option( 'dashboard_set', WP_STATISTICS_VERSION );
46
+
47
+ $hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', true );
48
+ if ( ! is_array( $hidden_widgets ) ) {
49
+ $hidden_widgets = array();
50
+ }
51
+
52
+ $default_hidden = array( 'wp-statistics-top-visitors-widget' );
53
+
54
+ foreach ( $default_hidden as $widget ) {
55
+ if ( ! in_array( $widget, $hidden_widgets ) ) {
56
+ $hidden_widgets[] = $widget;
57
  }
 
 
58
  }
59
+
60
+ update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
  }
63
 
64
+ // If the user does not have at least read access to the status plugin, just return without adding the widgets.
65
+ if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_option' ) ) ) ) {
66
+ return;
67
+ }
68
+
69
+ // If the admin has disabled the widgets, don't display them.
70
+ if ( ! $WP_Statistics->get_option( 'disable_dashboard' ) ) {
71
+ wp_add_dashboard_widget( 'wp-statistics-quickstats-widget', __( 'Quick Stats', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'quickstats' ) );
72
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
73
+ wp_add_dashboard_widget( 'wp-statistics-browsers-widget', __( 'Top 10 Browsers', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'browsers' ) );
74
+ }
75
+ if ( $WP_Statistics->get_option( 'geoip' ) && $WP_Statistics->get_option( 'visitors' ) ) {
76
+ wp_add_dashboard_widget( 'wp-statistics-countries-widget', __( 'Top 10 Countries', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'countries' ) );
77
+ }
78
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
79
+ wp_add_dashboard_widget( 'wp-statistics-hitsmap-widget', __( 'Today\'s Visitor Map', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'hitsmap' ) );
80
  }
81
+ if ( $WP_Statistics->get_option( 'visits' ) ) {
82
+ wp_add_dashboard_widget( 'wp-statistics-hits-widget', __( 'Hit Statistics', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'hits' ) );
83
+ }
84
+ if ( $WP_Statistics->get_option( 'pages' ) ) {
85
+ wp_add_dashboard_widget( 'wp-statistics-pages-widget', __( 'Top 10 Pages', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'pages' ) );
86
+ }
87
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
88
+ wp_add_dashboard_widget( 'wp-statistics-recent-widget', __( 'Recent Visitors', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'recent' ) );
89
+ }
90
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
91
+ wp_add_dashboard_widget( 'wp-statistics-referring-widget', __( 'Top Referring Sites', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'referring' ) );
92
+ }
93
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
94
+ wp_add_dashboard_widget( 'wp-statistics-search-widget', __( 'Search Engine Referrals', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'search' ) );
95
+ }
96
+ wp_add_dashboard_widget( 'wp-statistics-summary-widget', __( 'Summary', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'summary' ) );
97
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
98
+ wp_add_dashboard_widget( 'wp-statistics-words-widget', __( 'Latest Search Words', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'words' ) );
99
+ }
100
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
101
+ wp_add_dashboard_widget( 'wp-statistics-top-visitors-widget', __( 'Top 10 Visitors Today', 'wp_statistics' ), 'wp_statistics_generate_dashboard_postbox_contents', $control_callback = null, array( 'widget' => 'top.visitors' ) );
 
 
102
  }
103
  }
104
+ }
105
+
106
+ function wp_statistics_load_widget_css_and_scripts() {
107
+ GLOBAL $WP_Statistics;
108
+
109
+ // Load the css we use for the statistics pages.
110
+ wp_enqueue_style( 'log-css', plugin_dir_url( __FILE__ ) . 'assets/css/log' . WP_STATISTICS_MIN_EXT . '.css', true, '1.1' );
111
+ wp_enqueue_style( 'jqplot-css', plugin_dir_url( __FILE__ ) . 'assets/jqplot/jquery.jqplot' . WP_STATISTICS_MIN_EXT . '.css', true, '1.0.9' );
112
+
113
+ // Don't forget the right to left support.
114
+ if ( is_rtl() ) {
115
+ wp_enqueue_style( 'rtl-css', plugin_dir_url( __FILE__ ) . 'assets/css/rtl' . WP_STATISTICS_MIN_EXT . '.css', true, '1.1' );
116
  }
117
 
118
+ // Load the charts code.
119
+ wp_enqueue_script( 'jqplot', plugin_dir_url( __FILE__ ) . 'assets/jqplot/jquery.jqplot' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
120
+ wp_enqueue_script( 'jqplot-daterenderer', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.dateAxisRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
121
+ wp_enqueue_script( 'jqplot-tickrenderer', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.canvasAxisTickRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
122
+ wp_enqueue_script( 'jqplot-axisrenderer', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.canvasAxisLabelRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
123
+ wp_enqueue_script( 'jqplot-textrenderer', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.canvasTextRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
124
+ wp_enqueue_script( 'jqplot-tooltip', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.highlighter' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
125
+ wp_enqueue_script( 'jqplot-pierenderer', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.pieRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
126
+ wp_enqueue_script( 'jqplot-enhancedlengend', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.enhancedLegendRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
127
+ wp_enqueue_script( 'jqplot-enhancedpielengend', plugin_dir_url( __FILE__ ) . 'assets/jqplot/plugins/jqplot.enhancedPieLegendRenderer' . WP_STATISTICS_MIN_EXT . '.js', true, '1.0.9' );
128
 
129
+ wp_enqueue_style( 'jqvmap-css', plugin_dir_url( __FILE__ ) . 'assets/jqvmap/jqvmap' . WP_STATISTICS_MIN_EXT . '.css', true, '1.5.1' );
130
+ wp_enqueue_script( 'jquery-vmap', plugin_dir_url( __FILE__ ) . 'assets/jqvmap/jquery.vmap' . WP_STATISTICS_MIN_EXT . '.js', true, '1.5.1' );
131
+ wp_enqueue_script( 'jquery-vmap-world', plugin_dir_url( __FILE__ ) . 'assets/jqvmap/maps/jquery.vmap.world' . WP_STATISTICS_MIN_EXT . '.js', true, '1.5.1' );
132
+
133
+ $screen = get_current_screen();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ // Load our custom widgets handling javascript.
136
+ if ( 'post' == $screen->id || 'page' == $screen->id ) {
137
+ wp_enqueue_script( 'wp_statistics_editor', plugin_dir_url( __FILE__ ) . 'assets/js/editor' . WP_STATISTICS_MIN_EXT . '.js' );
138
+ } else {
139
+ wp_enqueue_script( 'wp_statistics_dashboard', plugin_dir_url( __FILE__ ) . 'assets/js/dashboard' . WP_STATISTICS_MIN_EXT . '.js' );
140
  }
141
+ }
 
 
 
 
 
 
 
 
 
 
142
 
143
+ function wp_statistics_generate_dashboard_postbox_contents( $post, $args ) {
144
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
145
+ $widget = $args['args']['widget'];
146
+ $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
147
+
148
+ echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
149
+ wp_statistics_generate_widget_load_javascript( $widget, $container_id );
150
+ }
151
+
152
+
153
+ function wp_statistics_dashboard_inline_javascript() {
154
+ $screen = get_current_screen();
155
+
156
+ if ( 'dashboard' != $screen->id ) {
157
+ return;
 
 
 
 
 
 
 
 
 
158
  }
159
+
160
+ wp_statistics_load_widget_css_and_scripts();
161
+
162
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
163
+
164
+ $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
165
+ $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
166
+
167
+ $admin_url = get_admin_url() . "admin.php?page=";
168
+
169
+ $page_urls = array();
170
+
171
+ $page_urls['wp-statistics-browsers-widget_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE;
172
+ $page_urls['wp-statistics-countries-widget_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE;
173
+ $page_urls['wp-statistics-exclusions-widget_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE;
174
+ $page_urls['wp-statistics-hits-widget_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE;
175
+ $page_urls['wp-statistics-online-widget_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE;
176
+ $page_urls['wp-statistics-pages-widget_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE;
177
+ $page_urls['wp-statistics-referring-widget_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE;
178
+ $page_urls['wp-statistics-search-widget_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE;
179
+ $page_urls['wp-statistics-words-widget_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE;
180
+ $page_urls['wp-statistics-top-visitors-widget_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE;
181
+ $page_urls['wp-statistics-recent-widget_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE;
182
+ $page_urls['wp-statistics-quickstats-widget_more_button'] = $admin_url . WP_STATISTICS_OVERVIEW_PAGE;
183
+
184
+ ?>
185
+ <script type="text/javascript">
186
+ var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
187
+ var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
188
+
189
+ function wp_statistics_wait_for_postboxes() {
190
+
191
+ if (!jQuery('#show-settings-link').is(':visible')) {
192
+ setTimeout(wp_statistics_wait_for_postboxes, 500);
193
+ }
194
+
195
+ jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
196
+ jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
197
+
198
+ jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
199
+ }
200
+
201
+ jQuery(document).ready(function () {
202
+
203
+ // Add the "more" and "refresh" buttons.
204
+ jQuery('.postbox').each(function () {
205
+ var temp = jQuery(this);
206
+ var temp_id = temp.attr('id');
207
+
208
+ if (temp_id.substr(0, 14) != 'wp-statistics-') {
209
+ return;
210
+ }
211
+
212
+ var temp_html = temp.html();
213
+
214
+ if (temp_id == 'wp-statistics-summary-widget') {
215
+ new_text = '<?php echo $new_button;?>';
216
+ new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
217
+
218
+ temp_html = temp_html.replace('</button>', new_text);
219
+ } else {
220
+ new_text = '<?php echo $new_buttons;?>';
221
+ new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
222
+ new_text = new_text.replace('{{moreid}}', temp_id + '_more_button');
223
+
224
+ temp_html = temp_html.replace('</button>', new_text);
225
+ }
226
+
227
+ temp.html(temp_html);
228
+ });
229
+
230
+ // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
231
+ // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
232
+ setTimeout(wp_statistics_wait_for_postboxes, 100);
233
+ });
234
+ </script>
235
+ <?php
236
+ }
237
+
238
  ?>
editor.php CHANGED
@@ -4,38 +4,46 @@
4
  */
5
  function wp_statistics_add_editor_meta_box() {
6
  GLOBAL $WP_Statistics;
7
-
8
  $WP_Statistics->load_user_options();
9
-
10
  // We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on
11
  // the first time they visit the dashboard though so check to see if we've been here before.
12
- if( !$WP_Statistics->get_user_option('editor_set') ) {
13
- $WP_Statistics->update_user_option('editor_set', WP_STATISTICS_VERSION);
14
-
15
- $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_post', true);
16
- if( !is_array( $hidden_widgets ) ) { $hidden_widgets = array(); }
17
-
18
- if( !in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
 
 
19
  $hidden_widgets[] = 'wp_statistics_editor_meta_box';
20
  }
21
-
22
  update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets );
23
 
24
- $hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_page', true);
25
- if( !is_array( $hidden_widgets ) ) { $hidden_widgets = array(); }
26
-
27
- if( !in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
 
 
28
  $hidden_widgets[] = 'wp_statistics_editor_meta_box';
29
  }
30
-
31
  update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets );
32
- }
33
 
34
  // If the user does not have at least read access to the status plugin, just return without adding the widgets.
35
- if (!current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_option')))) { return; }
 
 
36
 
37
  // If the admin has disabled the widgets don't display them.
38
- if ($WP_Statistics->get_option('disable_editor')) { return; }
 
 
39
 
40
  $screens = array( 'post', 'page' );
41
 
@@ -48,26 +56,31 @@ function wp_statistics_add_editor_meta_box() {
48
  $screen,
49
  'normal',
50
  'high'
51
- );
52
- }
53
  }
 
 
54
  add_action( 'add_meta_boxes', 'wp_statistics_add_editor_meta_box' );
55
 
56
  function wp_statistics_editor_meta_box( $post ) {
57
  // If the post isn't published yet, don't output the stats as they take too much memory and CPU to compute for no reason.
58
- if( $post->post_status != 'publish' && $post->post_status != 'private' ) { _e('This post is not yet published.', 'wp_statistics'); return; }
59
-
60
- add_action( 'admin_footer', 'wp_statistics_editor_inline_javascript' );
61
-
62
- wp_statistics_generate_editor_postbox_contents( $post->ID, array( 'args' => array( 'widget' => 'page' ) ) );
63
  }
64
 
 
 
 
 
 
65
  function wp_statistics_generate_editor_postbox_contents( $post, $args ) {
66
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
67
- $widget = $args['args']['widget'];
68
  $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
69
-
70
- echo '<div id="' . $container_id . '">' . $loading_img .'</div>';
71
  echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
72
  wp_statistics_generate_widget_load_javascript( $widget, $container_id );
73
  }
@@ -75,67 +88,67 @@ function wp_statistics_generate_editor_postbox_contents( $post, $args ) {
75
  function wp_statistics_editor_inline_javascript() {
76
  $screen = get_current_screen();
77
 
78
- if( 'post' != $screen->id && 'page' != $screen->id) {
79
  return;
80
  }
81
-
82
  wp_statistics_load_widget_css_and_scripts();
83
-
84
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
85
-
86
  $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
87
- $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
88
-
89
  $admin_url = get_admin_url() . "/admin.php?page=";
90
 
91
  $page_urls = array();
92
-
93
- $page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE . '&page-id=';
94
-
95
- ?>
96
- <script type="text/javascript">
97
- var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
98
- var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
99
-
100
- function wp_statistics_wait_for_postboxes() {
101
-
102
- if( ! jQuery('#show-settings-link').is( ':visible') ) {
103
- setTimeout( wp_statistics_wait_for_postboxes, 500 );
104
- }
105
-
106
- jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget );
107
- jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more );
108
 
109
- jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget );
110
- }
111
-
112
- jQuery(document).ready(function(){
113
-
114
- // Add the "more" and "refresh" buttons.
115
- jQuery('.postbox').each( function () {
116
- var temp = jQuery( this );
117
- var temp_id = temp.attr( 'id' );
118
-
119
- if( temp_id == 'wp_statistics_editor_meta_box' ) {
120
-
121
- var temp_html = temp.html();
122
-
123
- new_text = '<?php echo $new_buttons;?>';
124
- new_text = new_text.replace( '{{refreshid}}', temp_id + '_refresh_button' );
125
- new_text = new_text.replace( '{{moreid}}', temp_id + '_more_button' );
126
-
127
- temp_html = temp_html.replace( '</button>', new_text );
128
-
129
- temp.html( temp_html );
130
- }
131
- });
132
-
133
- // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
134
- // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
135
- setTimeout( wp_statistics_wait_for_postboxes, 100 );
136
- });
137
- </script>
138
- <?php
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  ?>
4
  */
5
  function wp_statistics_add_editor_meta_box() {
6
  GLOBAL $WP_Statistics;
7
+
8
  $WP_Statistics->load_user_options();
9
+
10
  // We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on
11
  // the first time they visit the dashboard though so check to see if we've been here before.
12
+ if ( ! $WP_Statistics->get_user_option( 'editor_set' ) ) {
13
+ $WP_Statistics->update_user_option( 'editor_set', WP_STATISTICS_VERSION );
14
+
15
+ $hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', true );
16
+ if ( ! is_array( $hidden_widgets ) ) {
17
+ $hidden_widgets = array();
18
+ }
19
+
20
+ if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
21
  $hidden_widgets[] = 'wp_statistics_editor_meta_box';
22
  }
23
+
24
  update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets );
25
 
26
+ $hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', true );
27
+ if ( ! is_array( $hidden_widgets ) ) {
28
+ $hidden_widgets = array();
29
+ }
30
+
31
+ if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
32
  $hidden_widgets[] = 'wp_statistics_editor_meta_box';
33
  }
34
+
35
  update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets );
36
+ }
37
 
38
  // If the user does not have at least read access to the status plugin, just return without adding the widgets.
39
+ if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_option' ) ) ) ) {
40
+ return;
41
+ }
42
 
43
  // If the admin has disabled the widgets don't display them.
44
+ if ( $WP_Statistics->get_option( 'disable_editor' ) ) {
45
+ return;
46
+ }
47
 
48
  $screens = array( 'post', 'page' );
49
 
56
  $screen,
57
  'normal',
58
  'high'
59
+ );
 
60
  }
61
+ }
62
+
63
  add_action( 'add_meta_boxes', 'wp_statistics_add_editor_meta_box' );
64
 
65
  function wp_statistics_editor_meta_box( $post ) {
66
  // If the post isn't published yet, don't output the stats as they take too much memory and CPU to compute for no reason.
67
+ if ( $post->post_status != 'publish' && $post->post_status != 'private' ) {
68
+ _e( 'This post is not yet published.', 'wp_statistics' );
69
+
70
+ return;
 
71
  }
72
 
73
+ add_action( 'admin_footer', 'wp_statistics_editor_inline_javascript' );
74
+
75
+ wp_statistics_generate_editor_postbox_contents( $post->ID, array( 'args' => array( 'widget' => 'page' ) ) );
76
+ }
77
+
78
  function wp_statistics_generate_editor_postbox_contents( $post, $args ) {
79
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
80
+ $widget = $args['args']['widget'];
81
  $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
82
+
83
+ echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
84
  echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
85
  wp_statistics_generate_widget_load_javascript( $widget, $container_id );
86
  }
88
  function wp_statistics_editor_inline_javascript() {
89
  $screen = get_current_screen();
90
 
91
+ if ( 'post' != $screen->id && 'page' != $screen->id ) {
92
  return;
93
  }
94
+
95
  wp_statistics_load_widget_css_and_scripts();
96
+
97
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
98
+
99
  $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
100
+ $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
101
+
102
  $admin_url = get_admin_url() . "/admin.php?page=";
103
 
104
  $page_urls = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
+ $page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE . '&page-id=';
107
+
108
+ ?>
109
+ <script type="text/javascript">
110
+ var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
111
+ var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
112
+
113
+ function wp_statistics_wait_for_postboxes() {
114
+
115
+ if (!jQuery('#show-settings-link').is(':visible')) {
116
+ setTimeout(wp_statistics_wait_for_postboxes, 500);
117
+ }
118
+
119
+ jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
120
+ jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
121
+
122
+ jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
123
+ }
124
+
125
+ jQuery(document).ready(function () {
126
+
127
+ // Add the "more" and "refresh" buttons.
128
+ jQuery('.postbox').each(function () {
129
+ var temp = jQuery(this);
130
+ var temp_id = temp.attr('id');
131
+
132
+ if (temp_id == 'wp_statistics_editor_meta_box') {
133
+
134
+ var temp_html = temp.html();
135
+
136
+ new_text = '<?php echo $new_buttons;?>';
137
+ new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
138
+ new_text = new_text.replace('{{moreid}}', temp_id + '_more_button');
139
+
140
+ temp_html = temp_html.replace('</button>', new_text);
141
+
142
+ temp.html(temp_html);
143
+ }
144
+ });
145
+
146
+ // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
147
+ // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
148
+ setTimeout(wp_statistics_wait_for_postboxes, 100);
149
+ });
150
+ </script>
151
+ <?php
152
+ }
153
 
154
  ?>
includes/classes/hits.class.php CHANGED
@@ -19,10 +19,10 @@ class Hits extends WP_Statistics {
19
  public $result = null;
20
 
21
  protected $location = '000';
22
- protected $exclusion_match = FALSE;
23
  protected $exclusion_reason = '';
24
 
25
- private $exclusion_record = FALSE;
26
  private $timestamp;
27
  private $second;
28
  private $current_page_id;
@@ -41,39 +41,37 @@ class Hits extends WP_Statistics {
41
  $this->second = 30;
42
 
43
  // Get the user set value for seconds to check for users online.
44
- if( $this->get_option('check_online') ) {
45
  $this->second = $this->get_option( 'check_online' );
46
  }
47
 
48
  // Check to see if the user wants us to record why we're excluding hits.
49
- if( $this->get_option( 'record_exclusions' ) ) {
50
- $this->exclusion_record = TRUE;
51
  }
52
 
53
  // Create a IP Tools instance from the current IP address for use later.
54
  // Fall back to the localhost if it can't be parsed.
55
  try {
56
  $ip = new IP( $this->ip );
57
- }
58
- catch( Exception $e ) {
59
  $ip = new IP( '127.0.0.1' );
60
  }
61
 
62
  // Let's check to see if our subnet matches a private IP address range, if so go ahead and set the location information now.
63
- if( $this->get_option( 'private_country_code' ) != '000' && $this->get_option( 'private_country_code' ) != '' ) {
64
  $private_subnets = array( '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.1/24', 'fc00::/7' );
65
 
66
- foreach( $private_subnets as $psub ) {
67
  $contains_ip = false;
68
 
69
  try {
70
  $contains_ip = Range::parse( $psub )->contains( $ip );
71
- }
72
- catch( Exception $e ) {
73
  $contains_ip = false;
74
  }
75
 
76
- if( $contains_ip ) {
77
  $this->location = $this->get_option( 'private_country_code' );
78
  break;
79
  }
@@ -96,27 +94,27 @@ class Hits extends WP_Statistics {
96
  * Note that we stop processing as soon as a match is made by executing a `return` from the function constructor.
97
  *
98
  */
99
-
100
  // Detect if we're running an ajax request.
101
- $page_uri = wp_statistics_get_uri();
102
  $ajax_string = 'admin-ajax.php';
103
-
104
- if( substr( $page_uri, 0, strlen( $ajax_string ) ) === $ajax_string ) {
105
- $this->exclusion_match = TRUE;
106
  $this->exclusion_reason = 'ajax';
107
-
108
  return;
109
  }
110
 
111
  // Detect if the user is a crawler.
112
- $crawler = false;
113
  $ua_string = '';
114
 
115
- if( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) {
116
  $ua_string = $_SERVER['HTTP_USER_AGENT'];
117
  }
118
 
119
- if( $this->get_option('last_browscap_dl') > 1 && $this->get_option('browscap') ) {
120
  // Get the upload directory from WordPress.
121
  $upload_dir = wp_upload_dir();
122
 
@@ -124,57 +122,54 @@ class Hits extends WP_Statistics {
124
  $BrowscapFile = $upload_dir['basedir'] . '/wp-statistics';
125
 
126
  // Get the Browser Capabilities use Browscap.
127
- $bc = new Browscap( $BrowscapFile );
128
- $bc->doAutoUpdate = false; // We don't want to auto update.
129
  try {
130
  $current_browser = $bc->getBrowser();
131
  // Make sure we got an object back and it has the Crawler property before accessing it.
132
- if( is_object( $current_browser ) && property_exists( $current_browser, 'Crawler') ) {
133
  $crawler = $current_browser->Crawler;
134
- }
135
- else {
136
  $crawler = false;
137
  }
138
- }
139
- catch( Exception $e ) {
140
  $crawler = false;
141
  }
142
- }
143
- else {
144
  $this->update_option( 'update_browscap', true );
145
  }
146
 
147
  // If we're a crawler as per browscap, exclude us, otherwise double check based on the WP Statistics robot list.
148
- if( $crawler == true ) {
149
- $this->exclusion_match = TRUE;
150
  $this->exclusion_reason = 'browscap';
151
-
152
  return;
153
  } else {
154
  // Pull the robots from the database.
155
  $robots = explode( "\n", $this->get_option( 'robotlist' ) );
156
 
157
  // Check to see if we match any of the robots.
158
- foreach($robots as $robot) {
159
  $robot = trim( $robot );
160
 
161
  // If the match case is less than 4 characters long, it might match too much so don't execute it.
162
- if( strlen( $robot ) > 3 ) {
163
- if( stripos( $ua_string, $robot ) !== FALSE ) {
164
- $this->exclusion_match = TRUE;
165
  $this->exclusion_reason = 'robot';
166
-
167
  return;
168
  }
169
  }
170
  }
171
 
172
  // Finally check to see if we have corrupt header information.
173
- if( !$this->exclusion_match && $this->get_option( 'corrupt_browser_info' ) ) {
174
- if( $ua_string == '' || $this->ip == '' ) {
175
- $this->exclusion_match = TRUE;
176
  $this->exclusion_reason = 'robot';
177
-
178
  return;
179
  }
180
  }
@@ -186,22 +181,21 @@ class Hits extends WP_Statistics {
186
  $subnets = explode( "\n", $this->get_option( 'exclude_ip' ) );
187
 
188
  // Check to see if we match any of the excluded addresses.
189
- foreach( $subnets as $subnet ) {
190
  $subnet = trim( $subnet );
191
 
192
  // The shortest ip address is 1.1.1.1, anything less must be a malformed entry.
193
- if( strlen( $subnet ) > 6 ) {
194
  $range_prased = false;
195
 
196
  try {
197
  $range_prased = Range::parse( $subnet )->contains( $ip );
198
- }
199
- catch( Exception $e ) {
200
  $range_parased = false;
201
  }
202
 
203
- if( $range_prased ) {
204
- $this->exclusion_match = TRUE;
205
  $this->exclusion_reason = 'ip match';
206
 
207
  return;
@@ -210,64 +204,64 @@ class Hits extends WP_Statistics {
210
  }
211
 
212
  // Check to see if we are being referred to ourselves.
213
- if( $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url( null, '/' ) || $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url() ) {
214
- $this->exclusion_match = TRUE;
215
  $this->exclusion_reason = 'self referral';
216
-
217
  return;
218
  }
219
 
220
  // Check to see if we're excluding the login page.
221
- if( $this->get_option( 'exclude_loginpage' ) ) {
222
- $protocol = strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 'https' ) === FALSE ? 'http' : 'https';
223
  $host = $_SERVER['HTTP_HOST'];
224
  $script = $_SERVER['SCRIPT_NAME'];
225
 
226
  $currentURL = $protocol . '://' . $host . $script;
227
- $loginURL = wp_login_url();
228
 
229
- if( $currentURL == $loginURL ) {
230
- $this->exclusion_match = TRUE;
231
  $this->exclusion_reason = 'login page';
232
-
233
  return;
234
  }
235
  }
236
 
237
  // Check to see if we're excluding the admin pages.
238
- if( $this->get_option( 'exclude_adminpage' ) ) {
239
- $protocol = strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 'https' ) === FALSE ? 'http' : 'https';
240
  $host = $_SERVER['HTTP_HOST'];
241
  $script = $_SERVER['SCRIPT_NAME'];
242
 
243
  $currentURL = $protocol . '://' . $host . $script;
244
- $adminURL = get_admin_url();
245
 
246
  $currentURL = substr( $currentURL, 0, strlen( $adminURL ) );
247
 
248
- if( $currentURL == $adminURL ) {
249
- $this->exclusion_match = TRUE;
250
  $this->exclusion_reason = 'admin page';
251
-
252
  return;
253
  }
254
  }
255
 
256
  // Check to see if we're excluding referrer spam.
257
- if( $this->get_option( 'referrerspam' ) ) {
258
  $referrer = $this->get_Referred();
259
 
260
  // Pull the referrer spam list from the database.
261
  $referrerspamlist = explode( "\n", $this->get_option( 'referrerspamlist' ) );
262
 
263
  // Check to see if we match any of the robots.
264
- foreach( $referrerspamlist as $item ) {
265
  $item = trim( $item );
266
 
267
  // If the match case is less than 4 characters long, it might match too much so don't execute it.
268
- if( strlen( $item ) > 3) {
269
- if( stripos( $referrer, $item ) !== FALSE ) {
270
- $this->exclusion_match = TRUE;
271
  $this->exclusion_reason = 'referrer_spam';
272
 
273
  return;
@@ -277,43 +271,43 @@ class Hits extends WP_Statistics {
277
  }
278
 
279
  // Check to see if we're excluding RSS feeds.
280
- if( $this->get_option( 'exclude_feeds' ) ) {
281
- if( is_object( $WP_Statistics ) ) {
282
- if( $WP_Statistics->check_feed() ) {
283
- $this->exclusion_match = TRUE;
284
  $this->exclusion_reason = 'feed';
285
-
286
  return;
287
  }
288
  }
289
  }
290
 
291
  // Check to see if we're excluding 404 pages.
292
- if( $this->get_option( 'exclude_404s' ) ) {
293
- if( is_404() ) {
294
- $this->exclusion_match = TRUE;
295
  $this->exclusion_reason = '404';
296
-
297
  return;
298
  }
299
  }
300
 
301
  // Check to see if we're excluding the current page url.
302
- if( $this->get_option( 'excluded_urls' ) ) {
303
- $script = $_SERVER['REQUEST_URI'];
304
  $delimiter = strpos( $script, '?' );
305
- if( $delimiter > 0 ) {
306
  $script = substr( $script, 0, $delimiter );
307
  }
308
 
309
  $excluded_urls = explode( "\n", $this->get_option( 'excluded_urls' ) );
310
 
311
- foreach( $excluded_urls as $url ) {
312
  $this_url = trim( $url );
313
 
314
- if( strlen( $this_url ) > 2 ) {
315
- if( stripos( $script, $this_url ) === 0 ) {
316
- $this->exclusion_match = TRUE;
317
  $this->exclusion_reason = 'excluded url';
318
 
319
  return;
@@ -323,13 +317,13 @@ class Hits extends WP_Statistics {
323
  }
324
 
325
  // Check to see if we are excluding based on the user role.
326
- if( is_user_logged_in() ) {
327
  $current_user = wp_get_current_user();
328
 
329
- foreach( $current_user->roles as $role ) {
330
  $option_name = 'exclude_' . str_replace( ' ', '_', strtolower( $role ) );
331
- if( $this->get_option( $option_name ) == TRUE ) {
332
- $this->exclusion_match = TRUE;
333
  $this->exclusion_reason = 'user role';
334
 
335
  return;
@@ -338,26 +332,26 @@ class Hits extends WP_Statistics {
338
  }
339
 
340
  // Check to see if we are excluded by the host name.
341
- if( !$this->exclusion_match ) {
342
  $excluded_host = explode( "\n", $this->get_option( 'excluded_hosts' ) );
343
 
344
  // If there's nothing in the excluded host list, don't do anything.
345
- if( count( $excluded_host ) > 0 ) {
346
  $transient_name = 'wps_excluded_hostname_to_ip_cache';
347
 
348
  // Get the transient with the hostname cache.
349
  $hostname_cache = get_transient( $transient_name );
350
 
351
  // If the transient has expired (or has never been set), create one now.
352
- if( $hostname_cache === false ) {
353
  // Flush the failed cache variable.
354
  $hostname_cache = array();
355
 
356
  // Loop through the list of hosts and look them up.
357
- foreach( $excluded_host as $host ) {
358
- if( strpos( $host, '.' ) > 0 ) {
359
  // We add the extra period to the end of the host name to make sure we don't append the local dns suffix to the resolution cycle.
360
- $hostname_cache[$host] = gethostbyname( $host . '.' );
361
  }
362
  }
363
 
@@ -366,10 +360,10 @@ class Hits extends WP_Statistics {
366
  }
367
 
368
  // Check if the current IP address matches one of the ones in the excluded hosts list.
369
- if( in_array( $this->ip, $hostname_cache ) ) {
370
- $this->exclusion_match = TRUE;
371
  $this->exclusion_reason = 'hostname';
372
-
373
  return;
374
  }
375
  }
@@ -380,13 +374,13 @@ class Hits extends WP_Statistics {
380
  public function Visits() {
381
 
382
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the visit.
383
- if( !$this->exclusion_match ) {
384
 
385
  // Check to see if we're a returning visitor.
386
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visit ORDER BY `{$this->tb_prefix}statistics_visit`.`ID` DESC" );
387
 
388
  // If we're a returning visitor, update the current record in the database, otherwise, create a new one.
389
- if( $this->result->last_counter != $this->Current_Date( 'Y-m-d' ) ) {
390
  // We'd normally use the WordPress insert function, but since we may run in to a race condition where another hit to the site has already created a new entry in the database
391
  // for this IP address we want to do an "INSERT ... ON DUPLICATE KEY" which WordPress doesn't support.
392
  $sqlstring = $this->db->prepare( 'INSERT INTO ' . $this->tb_prefix . 'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d) ON DUPLICATE KEY UPDATE visit = visit + ' . $this->coefficient, $this->Current_Date(), $this->Current_date( 'Y-m-d' ), $this->coefficient );
@@ -405,37 +399,38 @@ class Hits extends WP_Statistics {
405
  global $wp_query, $WP_Statistics;
406
 
407
  // Get the pages or posts ID if it exists.
408
- if( is_object( $wp_query ) ) {
409
  $this->current_page_id = $wp_query->get_queried_object_id();
410
  }
411
 
412
- if( $this->get_option( 'use_honeypot' ) && $this->get_option( 'honeypot_postid') > 0 && $this->get_option( 'honeypot_postid' ) == $this->current_page_id && $this->current_page_id > 0 ) {
413
- $this->exclusion_match = TRUE;
414
  $this->exclusion_reason = 'honeypot';
415
  }
416
 
417
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the visit.
418
  // The exception here is if we've matched a honey page, we want to lookup the user and flag them
419
  // as having been trapped in the honey pot for later exclusions.
420
- if( $this->exclusion_reason == 'honeypot' || ! $this->exclusion_match ) {
421
 
422
  // Check to see if we already have an entry in the database.
423
- if( $this->ip_hash != false ) {
424
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visitor WHERE `last_counter` = '{$this->Current_Date('Y-m-d')}' AND `ip` = '{$this->ip_hash}'" );
425
- }
426
- else {
427
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visitor WHERE `last_counter` = '{$this->Current_Date('Y-m-d')}' AND `ip` = '{$this->ip}' AND `agent` = '{$this->agent['browser']}' AND `platform` = '{$this->agent['platform']}' AND `version` = '{$this->agent['version']}'" );
428
  }
429
 
430
  // Check to see if this is a visit to the honey pot page, flag it when we create the new entry.
431
  $honeypot = 0;
432
- if( $this->exclusion_reason == 'honeypot' ) { $honeypot = 1; }
 
 
433
 
434
  // If we don't create a new one, otherwise update the old one.
435
- if( !$this->result ) {
436
 
437
  // If we've been told to store the entire user agent, do so.
438
- if( $this->get_option( 'store_ua' ) == true ) {
439
  $ua = $_SERVER['HTTP_USER_AGENT'];
440
  } else {
441
  $ua = '';
@@ -450,45 +445,44 @@ class Hits extends WP_Statistics {
450
 
451
  // Now parse the referrer and store the results in the search table if the database has been converted.
452
  // Also make sure we actually inserted a row on the INSERT IGNORE above or we'll create duplicate entries.
453
- if( $this->get_option( 'search_converted' ) && $this->db->insert_id ) {
454
 
455
  $search_engines = wp_statistics_searchengine_list();
456
- $referred = $this->get_Referred();
457
 
458
  // Parse the URL in to it's component parts.
459
  $parts = parse_url( $referred );
460
 
461
  // Loop through the SE list until we find which search engine matches.
462
- foreach( $search_engines as $key => $value ) {
463
  $search_regex = wp_statistics_searchengine_regex( $key );
464
 
465
- preg_match( '/' . $search_regex . '/', $parts['host'], $matches);
466
 
467
- if( isset($matches[1]) ) {
468
  $data['last_counter'] = $this->Current_date( 'Y-m-d' );
469
- $data['engine'] = $key;
470
- $data['words'] = $WP_Statistics->Search_Engine_QueryString( $referred );
471
- $data['host'] = $parts['host'];
472
- $data['visitor'] = $this->db->insert_id ;
473
 
474
- if( $data['words'] == 'No search query found!' ) { $data['words'] = ''; }
 
 
475
 
476
  $this->db->insert( $this->db->prefix . 'statistics_search', $data );
477
  }
478
  }
479
  }
480
- }
481
- else {
482
  // Normally we've done all of our exclusion matching during the class creation, however for the robot threshold is calculated here to avoid another call the database.
483
- if( $this->get_option( 'robot_threshold' ) > 0 && $this->result->hits + 1 > $this->get_option( 'robot_threshold' ) ) {
484
- $this->exclusion_match = TRUE;
485
  $this->exclusion_reason = 'robot_threshold';
486
- }
487
- else if( $this->result->honeypot ) {
488
- $this->exclusion_match = TRUE;
489
  $this->exclusion_reason = 'honeypot';
490
- }
491
- else {
492
 
493
  $sqlstring = $this->db->prepare( 'UPDATE ' . $this->tb_prefix . 'statistics_visitor SET `hits` = `hits` + %d, `honeypot` = %d WHERE `ID` = %d', 1 - $honeypot, $honeypot, $this->result->ID );
494
 
@@ -497,26 +491,26 @@ class Hits extends WP_Statistics {
497
  }
498
  }
499
 
500
- if( $this->exclusion_match ) {
501
  $this->RecordExclusion();
502
  }
503
  }
504
 
505
  private function RecordExclusion() {
506
  // If we're not storing exclusions, just return.
507
- if( $this->exclusion_record != TRUE ) {
508
  return;
509
  }
510
 
511
  $this->result = $this->db->query( "UPDATE {$this->tb_prefix}statistics_exclusions SET `count` = `count` + 1 WHERE `date` = '{$this->Current_Date( 'Y-m-d' )}' AND `reason` = '{$this->exclusion_reason}'" );
512
 
513
- if( !$this->result ) {
514
  $this->db->insert(
515
  $this->tb_prefix . 'statistics_exclusions',
516
  array(
517
- 'date' => $this->Current_date( 'Y-m-d' ),
518
- 'reason' => $this->exclusion_reason,
519
- 'count' => 1
520
  )
521
  );
522
  }
@@ -527,51 +521,51 @@ class Hits extends WP_Statistics {
527
  global $wp_query;
528
 
529
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the page hit.
530
- if( !$this->exclusion_match ) {
531
 
532
  // Don't track anything but actual pages and posts, unless we've been told to.
533
- if( $this->get_option('track_all_pages') || is_page() || is_single() || is_front_page() ) {
534
  // Get the pages or posts ID if it exists and we haven't set it in the visitors code.
535
- if( ! $this->current_page_id && is_object( $wp_query ) ) {
536
  $this->current_page_id = $wp_query->get_queried_object_id();
537
  }
538
 
539
  // If we didn't find a page id, we don't have anything else to do.
540
- if( ! $this->current_page_id ) {
541
  return;
542
  }
543
 
544
  // Get the current page URI.
545
  $page_uri = wp_statistics_get_uri();
546
 
547
- if( $this->get_option( 'strip_uri_parameters' ) ) {
548
  $temp = explode( '?', $page_uri );
549
- if( $temp !== false ) {
550
  $page_uri = $temp[0];
551
  }
552
  }
553
 
554
  // Limit the URI length to 255 characters, otherwise we may overrun the SQL field size.
555
- $page_uri = substr( $page_uri, 0, 255);
556
 
557
  // If we have already been to this page today (a likely scenario), just update the count on the record.
558
- $sql = $this->db->prepare( "UPDATE {$this->tb_prefix}statistics_pages SET `count` = `count` + 1 WHERE `date` = '{$this->Current_Date( 'Y-m-d' )}' AND `uri` = %s", $page_uri );
559
- $this->result = $this->db->query($sql);
560
 
561
  // If the update failed (aka the record doesn't exist), insert a new one. Note this may drop a page hit if a race condition
562
  // exists where two people load the same page a the roughly the same time. In that case two inserts would be attempted but
563
  // there is a unique index requirement on the database and one of them would fail.
564
- if( !$this->result ) {
565
 
566
  $this->db->insert(
567
  $this->tb_prefix . 'statistics_pages',
568
  array(
569
- 'uri' => $page_uri,
570
- 'date' => $this->Current_date( 'Y-m-d' ),
571
- 'count' => 1,
572
- 'id' => $this->current_page_id
573
- )
574
- );
575
  }
576
  }
577
  }
@@ -581,24 +575,24 @@ class Hits extends WP_Statistics {
581
  // Note we set the $this->result variable so we don't have to re-execute the query when we do the user update.
582
  public function Is_user() {
583
 
584
- if( $this->ip_hash != false ) {
585
  $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_useronline WHERE `ip` = '{$this->ip_hash}'" );
586
- }
587
- else {
588
  $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_useronline WHERE `ip` = '{$this->ip}' AND `agent` = '{$this->agent['browser']}' AND `platform` = '{$this->agent['platform']}' AND `version` = '{$this->agent['version']}'" );
589
  }
590
 
591
- if( $this->result )
592
  return true;
 
593
  }
594
 
595
  // This function add/update/delete the online users in the database.
596
  public function Check_online() {
597
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the user as online, unless we've been told to anyway.
598
- if( ! $this->exclusion_match || $this->get_option( 'all_online' ) ) {
599
 
600
  // If the current user exists in the database already, just update them, otherwise add them
601
- if( $this->Is_user() ) {
602
  $this->Update_user();
603
  } else {
604
  $this->Add_user();
@@ -611,21 +605,21 @@ class Hits extends WP_Statistics {
611
 
612
  // This function adds a user to the database.
613
  public function Add_user() {
614
- if(!$this->Is_user()) {
615
 
616
  // Insert the user in to the database.
617
  $this->db->insert(
618
  $this->tb_prefix . 'statistics_useronline',
619
  array(
620
- 'ip' => $this->ip_hash ? $this->ip_hash : $this->ip,
621
- 'timestamp' => $this->timestamp,
622
- 'created' => $this->timestamp,
623
- 'date' => $this->Current_Date(),
624
- 'referred' => $this->get_Referred(),
625
- 'agent' => $this->agent['browser'],
626
- 'platform' => $this->agent['platform'],
627
- 'version' => $this->agent['version'],
628
- 'location' => $this->location,
629
  )
630
  );
631
  }
@@ -635,22 +629,22 @@ class Hits extends WP_Statistics {
635
  // This function updates a user in the database.
636
  public function Update_user() {
637
  // Make sure we found the user earlier when we called Is_user().
638
- if( $this->result) {
639
 
640
  // Update the database with the new information.
641
  $this->db->update(
642
  $this->tb_prefix . 'statistics_useronline',
643
  array(
644
- 'timestamp' => $this->timestamp,
645
- 'date' => $this->Current_Date(),
646
- 'referred' => $this->get_Referred(),
647
  ),
648
  array(
649
- 'ip' => $this->ip_hash ? $this->ip_hash : $this->ip,
650
- 'agent' => $this->agent['browser'],
651
- 'platform' => $this->agent['platform'],
652
- 'version' => $this->agent['version'],
653
- 'location' => $this->location,
654
  )
655
  );
656
  }
19
  public $result = null;
20
 
21
  protected $location = '000';
22
+ protected $exclusion_match = false;
23
  protected $exclusion_reason = '';
24
 
25
+ private $exclusion_record = false;
26
  private $timestamp;
27
  private $second;
28
  private $current_page_id;
41
  $this->second = 30;
42
 
43
  // Get the user set value for seconds to check for users online.
44
+ if ( $this->get_option( 'check_online' ) ) {
45
  $this->second = $this->get_option( 'check_online' );
46
  }
47
 
48
  // Check to see if the user wants us to record why we're excluding hits.
49
+ if ( $this->get_option( 'record_exclusions' ) ) {
50
+ $this->exclusion_record = true;
51
  }
52
 
53
  // Create a IP Tools instance from the current IP address for use later.
54
  // Fall back to the localhost if it can't be parsed.
55
  try {
56
  $ip = new IP( $this->ip );
57
+ } catch ( Exception $e ) {
 
58
  $ip = new IP( '127.0.0.1' );
59
  }
60
 
61
  // Let's check to see if our subnet matches a private IP address range, if so go ahead and set the location information now.
62
+ if ( $this->get_option( 'private_country_code' ) != '000' && $this->get_option( 'private_country_code' ) != '' ) {
63
  $private_subnets = array( '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.1/24', 'fc00::/7' );
64
 
65
+ foreach ( $private_subnets as $psub ) {
66
  $contains_ip = false;
67
 
68
  try {
69
  $contains_ip = Range::parse( $psub )->contains( $ip );
70
+ } catch ( Exception $e ) {
 
71
  $contains_ip = false;
72
  }
73
 
74
+ if ( $contains_ip ) {
75
  $this->location = $this->get_option( 'private_country_code' );
76
  break;
77
  }
94
  * Note that we stop processing as soon as a match is made by executing a `return` from the function constructor.
95
  *
96
  */
97
+
98
  // Detect if we're running an ajax request.
99
+ $page_uri = wp_statistics_get_uri();
100
  $ajax_string = 'admin-ajax.php';
101
+
102
+ if ( substr( $page_uri, 0, strlen( $ajax_string ) ) === $ajax_string ) {
103
+ $this->exclusion_match = true;
104
  $this->exclusion_reason = 'ajax';
105
+
106
  return;
107
  }
108
 
109
  // Detect if the user is a crawler.
110
+ $crawler = false;
111
  $ua_string = '';
112
 
113
+ if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) {
114
  $ua_string = $_SERVER['HTTP_USER_AGENT'];
115
  }
116
 
117
+ if ( $this->get_option( 'last_browscap_dl' ) > 1 && $this->get_option( 'browscap' ) ) {
118
  // Get the upload directory from WordPress.
119
  $upload_dir = wp_upload_dir();
120
 
122
  $BrowscapFile = $upload_dir['basedir'] . '/wp-statistics';
123
 
124
  // Get the Browser Capabilities use Browscap.
125
+ $bc = new Browscap( $BrowscapFile );
126
+ $bc->doAutoUpdate = false; // We don't want to auto update.
127
  try {
128
  $current_browser = $bc->getBrowser();
129
  // Make sure we got an object back and it has the Crawler property before accessing it.
130
+ if ( is_object( $current_browser ) && property_exists( $current_browser, 'Crawler' ) ) {
131
  $crawler = $current_browser->Crawler;
132
+ } else {
 
133
  $crawler = false;
134
  }
135
+ } catch ( Exception $e ) {
 
136
  $crawler = false;
137
  }
138
+ } else {
 
139
  $this->update_option( 'update_browscap', true );
140
  }
141
 
142
  // If we're a crawler as per browscap, exclude us, otherwise double check based on the WP Statistics robot list.
143
+ if ( $crawler == true ) {
144
+ $this->exclusion_match = true;
145
  $this->exclusion_reason = 'browscap';
146
+
147
  return;
148
  } else {
149
  // Pull the robots from the database.
150
  $robots = explode( "\n", $this->get_option( 'robotlist' ) );
151
 
152
  // Check to see if we match any of the robots.
153
+ foreach ( $robots as $robot ) {
154
  $robot = trim( $robot );
155
 
156
  // If the match case is less than 4 characters long, it might match too much so don't execute it.
157
+ if ( strlen( $robot ) > 3 ) {
158
+ if ( stripos( $ua_string, $robot ) !== false ) {
159
+ $this->exclusion_match = true;
160
  $this->exclusion_reason = 'robot';
161
+
162
  return;
163
  }
164
  }
165
  }
166
 
167
  // Finally check to see if we have corrupt header information.
168
+ if ( ! $this->exclusion_match && $this->get_option( 'corrupt_browser_info' ) ) {
169
+ if ( $ua_string == '' || $this->ip == '' ) {
170
+ $this->exclusion_match = true;
171
  $this->exclusion_reason = 'robot';
172
+
173
  return;
174
  }
175
  }
181
  $subnets = explode( "\n", $this->get_option( 'exclude_ip' ) );
182
 
183
  // Check to see if we match any of the excluded addresses.
184
+ foreach ( $subnets as $subnet ) {
185
  $subnet = trim( $subnet );
186
 
187
  // The shortest ip address is 1.1.1.1, anything less must be a malformed entry.
188
+ if ( strlen( $subnet ) > 6 ) {
189
  $range_prased = false;
190
 
191
  try {
192
  $range_prased = Range::parse( $subnet )->contains( $ip );
193
+ } catch ( Exception $e ) {
 
194
  $range_parased = false;
195
  }
196
 
197
+ if ( $range_prased ) {
198
+ $this->exclusion_match = true;
199
  $this->exclusion_reason = 'ip match';
200
 
201
  return;
204
  }
205
 
206
  // Check to see if we are being referred to ourselves.
207
+ if ( $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url( null, '/' ) || $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url() ) {
208
+ $this->exclusion_match = true;
209
  $this->exclusion_reason = 'self referral';
210
+
211
  return;
212
  }
213
 
214
  // Check to see if we're excluding the login page.
215
+ if ( $this->get_option( 'exclude_loginpage' ) ) {
216
+ $protocol = strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 'https' ) === false ? 'http' : 'https';
217
  $host = $_SERVER['HTTP_HOST'];
218
  $script = $_SERVER['SCRIPT_NAME'];
219
 
220
  $currentURL = $protocol . '://' . $host . $script;
221
+ $loginURL = wp_login_url();
222
 
223
+ if ( $currentURL == $loginURL ) {
224
+ $this->exclusion_match = true;
225
  $this->exclusion_reason = 'login page';
226
+
227
  return;
228
  }
229
  }
230
 
231
  // Check to see if we're excluding the admin pages.
232
+ if ( $this->get_option( 'exclude_adminpage' ) ) {
233
+ $protocol = strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 'https' ) === false ? 'http' : 'https';
234
  $host = $_SERVER['HTTP_HOST'];
235
  $script = $_SERVER['SCRIPT_NAME'];
236
 
237
  $currentURL = $protocol . '://' . $host . $script;
238
+ $adminURL = get_admin_url();
239
 
240
  $currentURL = substr( $currentURL, 0, strlen( $adminURL ) );
241
 
242
+ if ( $currentURL == $adminURL ) {
243
+ $this->exclusion_match = true;
244
  $this->exclusion_reason = 'admin page';
245
+
246
  return;
247
  }
248
  }
249
 
250
  // Check to see if we're excluding referrer spam.
251
+ if ( $this->get_option( 'referrerspam' ) ) {
252
  $referrer = $this->get_Referred();
253
 
254
  // Pull the referrer spam list from the database.
255
  $referrerspamlist = explode( "\n", $this->get_option( 'referrerspamlist' ) );
256
 
257
  // Check to see if we match any of the robots.
258
+ foreach ( $referrerspamlist as $item ) {
259
  $item = trim( $item );
260
 
261
  // If the match case is less than 4 characters long, it might match too much so don't execute it.
262
+ if ( strlen( $item ) > 3 ) {
263
+ if ( stripos( $referrer, $item ) !== false ) {
264
+ $this->exclusion_match = true;
265
  $this->exclusion_reason = 'referrer_spam';
266
 
267
  return;
271
  }
272
 
273
  // Check to see if we're excluding RSS feeds.
274
+ if ( $this->get_option( 'exclude_feeds' ) ) {
275
+ if ( is_object( $WP_Statistics ) ) {
276
+ if ( $WP_Statistics->check_feed() ) {
277
+ $this->exclusion_match = true;
278
  $this->exclusion_reason = 'feed';
279
+
280
  return;
281
  }
282
  }
283
  }
284
 
285
  // Check to see if we're excluding 404 pages.
286
+ if ( $this->get_option( 'exclude_404s' ) ) {
287
+ if ( is_404() ) {
288
+ $this->exclusion_match = true;
289
  $this->exclusion_reason = '404';
290
+
291
  return;
292
  }
293
  }
294
 
295
  // Check to see if we're excluding the current page url.
296
+ if ( $this->get_option( 'excluded_urls' ) ) {
297
+ $script = $_SERVER['REQUEST_URI'];
298
  $delimiter = strpos( $script, '?' );
299
+ if ( $delimiter > 0 ) {
300
  $script = substr( $script, 0, $delimiter );
301
  }
302
 
303
  $excluded_urls = explode( "\n", $this->get_option( 'excluded_urls' ) );
304
 
305
+ foreach ( $excluded_urls as $url ) {
306
  $this_url = trim( $url );
307
 
308
+ if ( strlen( $this_url ) > 2 ) {
309
+ if ( stripos( $script, $this_url ) === 0 ) {
310
+ $this->exclusion_match = true;
311
  $this->exclusion_reason = 'excluded url';
312
 
313
  return;
317
  }
318
 
319
  // Check to see if we are excluding based on the user role.
320
+ if ( is_user_logged_in() ) {
321
  $current_user = wp_get_current_user();
322
 
323
+ foreach ( $current_user->roles as $role ) {
324
  $option_name = 'exclude_' . str_replace( ' ', '_', strtolower( $role ) );
325
+ if ( $this->get_option( $option_name ) == true ) {
326
+ $this->exclusion_match = true;
327
  $this->exclusion_reason = 'user role';
328
 
329
  return;
332
  }
333
 
334
  // Check to see if we are excluded by the host name.
335
+ if ( ! $this->exclusion_match ) {
336
  $excluded_host = explode( "\n", $this->get_option( 'excluded_hosts' ) );
337
 
338
  // If there's nothing in the excluded host list, don't do anything.
339
+ if ( count( $excluded_host ) > 0 ) {
340
  $transient_name = 'wps_excluded_hostname_to_ip_cache';
341
 
342
  // Get the transient with the hostname cache.
343
  $hostname_cache = get_transient( $transient_name );
344
 
345
  // If the transient has expired (or has never been set), create one now.
346
+ if ( $hostname_cache === false ) {
347
  // Flush the failed cache variable.
348
  $hostname_cache = array();
349
 
350
  // Loop through the list of hosts and look them up.
351
+ foreach ( $excluded_host as $host ) {
352
+ if ( strpos( $host, '.' ) > 0 ) {
353
  // We add the extra period to the end of the host name to make sure we don't append the local dns suffix to the resolution cycle.
354
+ $hostname_cache[ $host ] = gethostbyname( $host . '.' );
355
  }
356
  }
357
 
360
  }
361
 
362
  // Check if the current IP address matches one of the ones in the excluded hosts list.
363
+ if ( in_array( $this->ip, $hostname_cache ) ) {
364
+ $this->exclusion_match = true;
365
  $this->exclusion_reason = 'hostname';
366
+
367
  return;
368
  }
369
  }
374
  public function Visits() {
375
 
376
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the visit.
377
+ if ( ! $this->exclusion_match ) {
378
 
379
  // Check to see if we're a returning visitor.
380
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visit ORDER BY `{$this->tb_prefix}statistics_visit`.`ID` DESC" );
381
 
382
  // If we're a returning visitor, update the current record in the database, otherwise, create a new one.
383
+ if ( $this->result->last_counter != $this->Current_Date( 'Y-m-d' ) ) {
384
  // We'd normally use the WordPress insert function, but since we may run in to a race condition where another hit to the site has already created a new entry in the database
385
  // for this IP address we want to do an "INSERT ... ON DUPLICATE KEY" which WordPress doesn't support.
386
  $sqlstring = $this->db->prepare( 'INSERT INTO ' . $this->tb_prefix . 'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d) ON DUPLICATE KEY UPDATE visit = visit + ' . $this->coefficient, $this->Current_Date(), $this->Current_date( 'Y-m-d' ), $this->coefficient );
399
  global $wp_query, $WP_Statistics;
400
 
401
  // Get the pages or posts ID if it exists.
402
+ if ( is_object( $wp_query ) ) {
403
  $this->current_page_id = $wp_query->get_queried_object_id();
404
  }
405
 
406
+ if ( $this->get_option( 'use_honeypot' ) && $this->get_option( 'honeypot_postid' ) > 0 && $this->get_option( 'honeypot_postid' ) == $this->current_page_id && $this->current_page_id > 0 ) {
407
+ $this->exclusion_match = true;
408
  $this->exclusion_reason = 'honeypot';
409
  }
410
 
411
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the visit.
412
  // The exception here is if we've matched a honey page, we want to lookup the user and flag them
413
  // as having been trapped in the honey pot for later exclusions.
414
+ if ( $this->exclusion_reason == 'honeypot' || ! $this->exclusion_match ) {
415
 
416
  // Check to see if we already have an entry in the database.
417
+ if ( $this->ip_hash != false ) {
418
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visitor WHERE `last_counter` = '{$this->Current_Date('Y-m-d')}' AND `ip` = '{$this->ip_hash}'" );
419
+ } else {
 
420
  $this->result = $this->db->get_row( "SELECT * FROM {$this->tb_prefix}statistics_visitor WHERE `last_counter` = '{$this->Current_Date('Y-m-d')}' AND `ip` = '{$this->ip}' AND `agent` = '{$this->agent['browser']}' AND `platform` = '{$this->agent['platform']}' AND `version` = '{$this->agent['version']}'" );
421
  }
422
 
423
  // Check to see if this is a visit to the honey pot page, flag it when we create the new entry.
424
  $honeypot = 0;
425
+ if ( $this->exclusion_reason == 'honeypot' ) {
426
+ $honeypot = 1;
427
+ }
428
 
429
  // If we don't create a new one, otherwise update the old one.
430
+ if ( ! $this->result ) {
431
 
432
  // If we've been told to store the entire user agent, do so.
433
+ if ( $this->get_option( 'store_ua' ) == true ) {
434
  $ua = $_SERVER['HTTP_USER_AGENT'];
435
  } else {
436
  $ua = '';
445
 
446
  // Now parse the referrer and store the results in the search table if the database has been converted.
447
  // Also make sure we actually inserted a row on the INSERT IGNORE above or we'll create duplicate entries.
448
+ if ( $this->get_option( 'search_converted' ) && $this->db->insert_id ) {
449
 
450
  $search_engines = wp_statistics_searchengine_list();
451
+ $referred = $this->get_Referred();
452
 
453
  // Parse the URL in to it's component parts.
454
  $parts = parse_url( $referred );
455
 
456
  // Loop through the SE list until we find which search engine matches.
457
+ foreach ( $search_engines as $key => $value ) {
458
  $search_regex = wp_statistics_searchengine_regex( $key );
459
 
460
+ preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
461
 
462
+ if ( isset( $matches[1] ) ) {
463
  $data['last_counter'] = $this->Current_date( 'Y-m-d' );
464
+ $data['engine'] = $key;
465
+ $data['words'] = $WP_Statistics->Search_Engine_QueryString( $referred );
466
+ $data['host'] = $parts['host'];
467
+ $data['visitor'] = $this->db->insert_id;
468
 
469
+ if ( $data['words'] == 'No search query found!' ) {
470
+ $data['words'] = '';
471
+ }
472
 
473
  $this->db->insert( $this->db->prefix . 'statistics_search', $data );
474
  }
475
  }
476
  }
477
+ } else {
 
478
  // Normally we've done all of our exclusion matching during the class creation, however for the robot threshold is calculated here to avoid another call the database.
479
+ if ( $this->get_option( 'robot_threshold' ) > 0 && $this->result->hits + 1 > $this->get_option( 'robot_threshold' ) ) {
480
+ $this->exclusion_match = true;
481
  $this->exclusion_reason = 'robot_threshold';
482
+ } else if ( $this->result->honeypot ) {
483
+ $this->exclusion_match = true;
 
484
  $this->exclusion_reason = 'honeypot';
485
+ } else {
 
486
 
487
  $sqlstring = $this->db->prepare( 'UPDATE ' . $this->tb_prefix . 'statistics_visitor SET `hits` = `hits` + %d, `honeypot` = %d WHERE `ID` = %d', 1 - $honeypot, $honeypot, $this->result->ID );
488
 
491
  }
492
  }
493
 
494
+ if ( $this->exclusion_match ) {
495
  $this->RecordExclusion();
496
  }
497
  }
498
 
499
  private function RecordExclusion() {
500
  // If we're not storing exclusions, just return.
501
+ if ( $this->exclusion_record != true ) {
502
  return;
503
  }
504
 
505
  $this->result = $this->db->query( "UPDATE {$this->tb_prefix}statistics_exclusions SET `count` = `count` + 1 WHERE `date` = '{$this->Current_Date( 'Y-m-d' )}' AND `reason` = '{$this->exclusion_reason}'" );
506
 
507
+ if ( ! $this->result ) {
508
  $this->db->insert(
509
  $this->tb_prefix . 'statistics_exclusions',
510
  array(
511
+ 'date' => $this->Current_date( 'Y-m-d' ),
512
+ 'reason' => $this->exclusion_reason,
513
+ 'count' => 1
514
  )
515
  );
516
  }
521
  global $wp_query;
522
 
523
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the page hit.
524
+ if ( ! $this->exclusion_match ) {
525
 
526
  // Don't track anything but actual pages and posts, unless we've been told to.
527
+ if ( $this->get_option( 'track_all_pages' ) || is_page() || is_single() || is_front_page() ) {
528
  // Get the pages or posts ID if it exists and we haven't set it in the visitors code.
529
+ if ( ! $this->current_page_id && is_object( $wp_query ) ) {
530
  $this->current_page_id = $wp_query->get_queried_object_id();
531
  }
532
 
533
  // If we didn't find a page id, we don't have anything else to do.
534
+ if ( ! $this->current_page_id ) {
535
  return;
536
  }
537
 
538
  // Get the current page URI.
539
  $page_uri = wp_statistics_get_uri();
540
 
541
+ if ( $this->get_option( 'strip_uri_parameters' ) ) {
542
  $temp = explode( '?', $page_uri );
543
+ if ( $temp !== false ) {
544
  $page_uri = $temp[0];
545
  }
546
  }
547
 
548
  // Limit the URI length to 255 characters, otherwise we may overrun the SQL field size.
549
+ $page_uri = substr( $page_uri, 0, 255 );
550
 
551
  // If we have already been to this page today (a likely scenario), just update the count on the record.
552
+ $sql = $this->db->prepare( "UPDATE {$this->tb_prefix}statistics_pages SET `count` = `count` + 1 WHERE `date` = '{$this->Current_Date( 'Y-m-d' )}' AND `uri` = %s", $page_uri );
553
+ $this->result = $this->db->query( $sql );
554
 
555
  // If the update failed (aka the record doesn't exist), insert a new one. Note this may drop a page hit if a race condition
556
  // exists where two people load the same page a the roughly the same time. In that case two inserts would be attempted but
557
  // there is a unique index requirement on the database and one of them would fail.
558
+ if ( ! $this->result ) {
559
 
560
  $this->db->insert(
561
  $this->tb_prefix . 'statistics_pages',
562
  array(
563
+ 'uri' => $page_uri,
564
+ 'date' => $this->Current_date( 'Y-m-d' ),
565
+ 'count' => 1,
566
+ 'id' => $this->current_page_id
567
+ )
568
+ );
569
  }
570
  }
571
  }
575
  // Note we set the $this->result variable so we don't have to re-execute the query when we do the user update.
576
  public function Is_user() {
577
 
578
+ if ( $this->ip_hash != false ) {
579
  $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_useronline WHERE `ip` = '{$this->ip_hash}'" );
580
+ } else {
 
581
  $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_useronline WHERE `ip` = '{$this->ip}' AND `agent` = '{$this->agent['browser']}' AND `platform` = '{$this->agent['platform']}' AND `version` = '{$this->agent['version']}'" );
582
  }
583
 
584
+ if ( $this->result ) {
585
  return true;
586
+ }
587
  }
588
 
589
  // This function add/update/delete the online users in the database.
590
  public function Check_online() {
591
  // If we're a webcrawler or referral from ourselves or an excluded address don't record the user as online, unless we've been told to anyway.
592
+ if ( ! $this->exclusion_match || $this->get_option( 'all_online' ) ) {
593
 
594
  // If the current user exists in the database already, just update them, otherwise add them
595
+ if ( $this->Is_user() ) {
596
  $this->Update_user();
597
  } else {
598
  $this->Add_user();
605
 
606
  // This function adds a user to the database.
607
  public function Add_user() {
608
+ if ( ! $this->Is_user() ) {
609
 
610
  // Insert the user in to the database.
611
  $this->db->insert(
612
  $this->tb_prefix . 'statistics_useronline',
613
  array(
614
+ 'ip' => $this->ip_hash ? $this->ip_hash : $this->ip,
615
+ 'timestamp' => $this->timestamp,
616
+ 'created' => $this->timestamp,
617
+ 'date' => $this->Current_Date(),
618
+ 'referred' => $this->get_Referred(),
619
+ 'agent' => $this->agent['browser'],
620
+ 'platform' => $this->agent['platform'],
621
+ 'version' => $this->agent['version'],
622
+ 'location' => $this->location,
623
  )
624
  );
625
  }
629
  // This function updates a user in the database.
630
  public function Update_user() {
631
  // Make sure we found the user earlier when we called Is_user().
632
+ if ( $this->result ) {
633
 
634
  // Update the database with the new information.
635
  $this->db->update(
636
  $this->tb_prefix . 'statistics_useronline',
637
  array(
638
+ 'timestamp' => $this->timestamp,
639
+ 'date' => $this->Current_Date(),
640
+ 'referred' => $this->get_Referred(),
641
  ),
642
  array(
643
+ 'ip' => $this->ip_hash ? $this->ip_hash : $this->ip,
644
+ 'agent' => $this->agent['browser'],
645
+ 'platform' => $this->agent['platform'],
646
+ 'version' => $this->agent['version'],
647
+ 'location' => $this->location,
648
  )
649
  );
650
  }
includes/classes/hits.geoip.class.php CHANGED
@@ -13,13 +13,12 @@ class GeoIPHits extends Hits {
13
  parent::__construct();
14
 
15
  // We may have set the location based on a private IP address in the hits class, if so, don't bother looking it up again.
16
- if( $this->location == '000' ) {
17
 
18
  // Now get the location information from the MaxMind database.
19
- try
20
- {
21
  // Get the WordPress upload directory information, which is where we have stored the MaxMind database.
22
- $upload_dir = wp_upload_dir();
23
 
24
  // Create a new Reader and point it to the database.
25
  $reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
@@ -31,33 +30,37 @@ class GeoIPHits extends Hits {
31
  $location = $record->country->isoCode;
32
 
33
  // MaxMind returns a blank for location if it can't find it, but we want to use 000 so replace it.
34
- if( $location == "" ) { $location = "000"; }
 
35
  }
36
- catch( Exception $e )
37
- {
38
  $location = "000";
39
- }
40
 
41
  // Store the location in the protected $location variable from the parent class.
42
  $this->location = $location;
43
  }
44
 
45
  // Check to see if we are excluded by the GeoIP rules.
46
- if( !$this->exclusion_match ) {
47
  // Grab the excluded/included countries lists, force the country codes to be in upper case to match what the GeoIP code uses.
48
- $excluded_countries = explode( "\n", strtoupper( str_replace( "\r\n", "\n", $this->get_option('excluded_countries') ) ) );
49
- $included_countries_string = trim( strtoupper( str_replace( "\r\n", "\n", $this->get_option('included_countries') ) ) );
50
 
51
  // We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none.
52
- if( $included_countries_string == '' ) { $included_countries = array(); } else { $included_countries = explode( "\n", $included_countries_string ); }
 
 
 
 
53
 
54
  // Check to see if the current location is in the excluded countries list.
55
- if( in_array( $this->location, $excluded_countries ) ) {
56
- $this->exclusion_match = TRUE;
57
  $this->exclusion_reason = "geoip";
58
  } // Check to see if the current location is not the included countries list.
59
- else if( !in_array( $this->location, $included_countries ) && count( $included_countries ) > 0 ) {
60
- $this->exclusion_match = TRUE;
61
  $this->exclusion_reason = "geoip";
62
  }
63
  }
13
  parent::__construct();
14
 
15
  // We may have set the location based on a private IP address in the hits class, if so, don't bother looking it up again.
16
+ if ( $this->location == '000' ) {
17
 
18
  // Now get the location information from the MaxMind database.
19
+ try {
 
20
  // Get the WordPress upload directory information, which is where we have stored the MaxMind database.
21
+ $upload_dir = wp_upload_dir();
22
 
23
  // Create a new Reader and point it to the database.
24
  $reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
30
  $location = $record->country->isoCode;
31
 
32
  // MaxMind returns a blank for location if it can't find it, but we want to use 000 so replace it.
33
+ if ( $location == "" ) {
34
+ $location = "000";
35
  }
36
+ } catch ( Exception $e ) {
 
37
  $location = "000";
38
+ }
39
 
40
  // Store the location in the protected $location variable from the parent class.
41
  $this->location = $location;
42
  }
43
 
44
  // Check to see if we are excluded by the GeoIP rules.
45
+ if ( ! $this->exclusion_match ) {
46
  // Grab the excluded/included countries lists, force the country codes to be in upper case to match what the GeoIP code uses.
47
+ $excluded_countries = explode( "\n", strtoupper( str_replace( "\r\n", "\n", $this->get_option( 'excluded_countries' ) ) ) );
48
+ $included_countries_string = trim( strtoupper( str_replace( "\r\n", "\n", $this->get_option( 'included_countries' ) ) ) );
49
 
50
  // We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none.
51
+ if ( $included_countries_string == '' ) {
52
+ $included_countries = array();
53
+ } else {
54
+ $included_countries = explode( "\n", $included_countries_string );
55
+ }
56
 
57
  // Check to see if the current location is in the excluded countries list.
58
+ if ( in_array( $this->location, $excluded_countries ) ) {
59
+ $this->exclusion_match = true;
60
  $this->exclusion_reason = "geoip";
61
  } // Check to see if the current location is not the included countries list.
62
+ else if ( ! in_array( $this->location, $included_countries ) && count( $included_countries ) > 0 ) {
63
+ $this->exclusion_match = true;
64
  $this->exclusion_reason = "geoip";
65
  }
66
  }
includes/classes/pagination.class.php CHANGED
@@ -1,550 +1,598 @@
1
  <?php
2
  /**
3
- * Pagination Class
4
- *
5
- * This class displays a pagination navigation bar complete with links to first, last,
6
- * previous, next, and all pages. This class handles cookie setting, page bounds checking/
7
- * redirection, appropriate error reporting, CSS styling, and POST/GET retrieval all
8
- * internally.
9
- *
10
- * PHP version 5
11
- *
12
- * @author Dane Gardow <dane.g87@gmail.com>
13
- * @copyright 2013 Dane Gardow
14
- * @date 01 January 2013
15
- * @version 1.0
16
- * @license Free
17
- *
18
- ******************************************************************************************/
19
-
20
- if(!class_exists("WP_Statistics_Pagination")): // Prevent multiple class definitions
21
-
22
- class WP_Statistics_Pagination
23
- {
24
- /*******************************************************
25
- PROPERTIES / DATA MEMBERS
26
- *******************************************************/
27
-
28
- // Edit these as you desire
29
- const DEFAULT_ENTRIES_DISPLAY = 10; // Default number of entries to display per page
30
- const PAGE_GETVAR_NAME = "page"; // Name of GET variable name for page values (i.e., example.php?page=1)
31
-
32
- private $_paginationID = "pagination"; // ID Name of pagination object "pagination" is default
33
- // used also for form name for select options
34
-
35
- // Do not edit these values; they are simply null initializations
36
- private $_totalEntries = null; // Total number of entries (usually supplied by MySQL query)
37
- private $_pagesPerSection = null; // Total number of pages displayed per section (supplied by admin)
38
- private $_entriesPerPage = null; // Total number of entries displayed per page (supplied by user)
39
- private $_currentPage = null; // Current page viewed by user
40
- private $_displayOptions = array(); // Array of options for viewing how many entries per page (supplied by user)
41
- private $_errors = array(); // Array of encountered error messages
42
- private $_styles = array(); // Array of CSS styles for pagination navigation display
43
-
44
-
45
-
46
-
47
- /*******************************************************
48
- CONSTRUCTOR
49
- *******************************************************/
50
-
51
- function __construct($totalEntries, $pagesPerSection, $options = "", $paginationID = "", $stylePageOff = "",
52
- $stylePageOn = "", $styleErrors = "", $styleSelect = "")
53
- {
54
- $this->setPaginationID($paginationID); // Set ID name of pagination object
55
- $this->setTotalEntries($totalEntries); // Set total entries
56
- $this->setPagesPerSection($pagesPerSection); // Set pages per section
57
- $this->setDisplayOptions($options); // Set viewing display options
58
- $this->setEntriesPerPage(); // Set entries per page (input from POST or cookies)
59
- $this->setCurrentPage(); // Set current page (input from GET)
60
- // ! This function must follow after setEntriesPerPage()
61
- $this->setStyles($stylePageOff, $stylePageOn,
62
- $styleSelect, $styleErrors); // Set CSS styles for pagination navigation display
63
- }
64
 
65
 
 
 
 
66
 
67
- /*******************************************************
68
- UTILITY FUNCTIONS
69
- *******************************************************/
70
-
71
- public function deleteCookie() // deletes the cookie if it exists
72
- {
73
- $cookieVar = $this->_getPOSTVarName();
74
-
75
- if(isset($_COOKIE[$cookieVar])) // If cookie is set
76
  {
77
- $_COOKIE[$cookieVar] = ""; // Clear cookie
78
- setcookie($cookieVar, "", time()-3600, "/"); // Delete cookie
79
- }
80
- }
81
-
82
- private function _getURL($input = 1) // returns appropriate URL with all GET variables intact
83
- { // updates only the particular GET variable in question
84
- $getVars = $_GET; // Get all GET variables
85
-
86
- /* Uncomment this if you need to exclude any GET variables (due to HTACCESS issues, for example) from being
87
- * processed in the ensuing URL. Simply enter in the GET variable name in the unset(...) function below.
88
- unset($getVars["foo"], $getVars["bar"], ... ); // Remove any so they do not appear in URL
89
- */
90
-
91
- $output = '?'.http_build_query(array_merge($getVars, array($this->_getIDGETVarName()=>$input)));
92
- $output .= '#'. $this->getPaginationID(); // Add #xxx at the end of URL for auto-scrolling
93
-
94
- return $output;
95
- }
96
-
97
- private function _isError() // determines if an error exists and registers any errors
98
- {
99
- if($this->_errors) // If error already exists, return
100
- return true;
101
-
102
- if(!$this->_totalEntries) // If total entries not set
103
- $this->_errors[] = "The value for <strong>total entries</strong> has not been specified.";
104
-
105
- if(!$this->_displayOptions) // If display options not set
106
- $this->_errors[] = "The values for <strong>display options</strong> have not been specified.";
107
-
108
- if(!$this->_entriesPerPage) // If entries per page not set
109
- $this->_errors[] = "The value for <strong>entries per page</strong> has not been specified.";
110
-
111
- if(!$this->_currentPage) // If current page not set
112
- $this->_errors[] = "The value for <strong>current page</strong> has not been specified.";
113
-
114
- return ($this->_errors) ? true : false;
115
- }
116
 
117
- private function _validEntry($input) // determines if input is valid
118
- {
119
- if(is_array($input)) // If array
120
- {
121
- foreach($input as $element)
122
- { // Recursion: evaluate each array element
123
- if(!$this->_validEntry($element)) // If invalid
124
- return false;
125
  }
 
 
 
 
 
126
 
127
- return true; // If function makes it to this point, it is valid
 
 
 
 
 
 
 
 
128
  }
129
- else // If not array
 
130
  {
131
- if( (preg_match("/^\d+$/",$input) && $input > 0) || strtolower($input) == "all") // If positive digit or "all"
 
132
  return true;
133
- else
134
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
- }
137
-
138
- private function _navBox($text, $destinationPage, $end = 0) // returns span-encased link for pagination bar
139
- {
140
- switch($end)
141
  {
142
- case 1:
143
- $title = "First page";
144
- break;
145
- case 2:
146
- $title = "Previous page";
147
- break;
148
- case 3:
149
- $title = "Next page";
150
- break;
151
- case 4:
152
- $title = "Last page (". $this->getTotalPages() .")";
153
- break;
154
- default:
155
- $title = "";
156
- break;
 
 
 
 
157
  }
158
 
159
- $title = ($end > 0 && $title != "") ? 'title="' . $title . '"' : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- $style = $this->_styles["pageOff"];
 
162
 
163
- // Determine Style
164
- $style = ($this->_currentPage == $destinationPage && !$end) ? $this->_styles["pageOn"] : $this->_styles["pageOff"];
165
 
166
- // Determine Link URL/Text
167
- $url = "";
168
-
169
- if($this->_currentPage != $destinationPage // If current page is not same as destination page
170
- && $destinationPage <= $this->getTotalPages() // and destination page does not exceed last page
171
- && $destinationPage >= 1) // and destination page is not less than first page
172
  {
173
- $text = '<a href="'. $this->_getURL($destinationPage) .'">'. $text .'</a>'; // then make $text a link
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
 
176
- if($style)
177
- $style = 'class="'. $style .'"';
178
-
179
- $onClick = ($url) ? "onclick=\"location.href='". $url ."'\"" : ""; // Determine if span element is clickable
180
-
181
- return '<span '. $style . $title .' '. $onClick .'>'. $text .'</span>';
182
- }
183
-
184
-
185
-
186
- /*******************************************************
187
- DISPLAY FUNCTIONS
188
- *******************************************************/
189
-
190
- public function display() // displays the pagination bar
191
- {
192
- if($this->_isError()) // If error encountered, do not display, but display errors
193
- return $this->displayErrors();
194
-
195
- $firstPage = 1;
196
- $previousPage = $this->_currentPage - 1;
197
- $nextPage = $this->_currentPage + 1;
198
- $lastPage = $this->getTotalPages();
199
-
200
- $totalpages = $this->getTotalPages();
201
-
202
- $pagesPerSection = $this->getPagesPerSection();
203
-
204
- $sectionStart = $this->_currentPage - floor($pagesPerSection / 2); // Section start is current page # minus half the # of pages per section
205
-
206
- if($sectionStart <= 0) // Adjust section start to 1 (first page) if # pages between 1st page
207
- $sectionStart = 1; // and current page is less than half the # of pages per section
208
-
209
- $sectionEnd = $sectionStart + $pagesPerSection - 1; // Section end is # pages per section after section start,
210
- // minus 1 (otherwise # of pages per section will exceed given amount by 1)
211
-
212
- if($sectionEnd > $lastPage) // Adjust section end to last page if section end exceeds last page
213
- $sectionEnd = $lastPage;
214
-
215
- $sectionStart = $sectionEnd - $pagesPerSection + 1; // Adjust section start to # of pages behind section end
216
-
217
- $output = $this->_navBox("&lt;&lt;", $firstPage, 1); // First page
218
- $output .= $this->_navBox("&lt;", $previousPage, 2); // Previous page
219
-
220
- for($i = $sectionStart; $i <= $sectionEnd; ++$i)
221
- $output .= $this->_navBox($i, $i); // Pagination
222
-
223
- $output .= $this->_navBox("&gt;", $nextPage, 3); // Next Page
224
- $output .= $this->_navBox("&gt;&gt;", $lastPage, 4); // Last Page
225
-
226
- return $output;
227
- }
228
-
229
- public function displayErrors() // displays the errors encountered
230
- {
231
- if(!$this->_errors)
232
- return "No errors were encountered.";
233
-
234
- $words = (count($this->_errors) > 1) ? "errors were" : "error was";
235
-
236
- // Determine CSS styling for error reporting
237
- if($this->_styles["errors"])
238
- $css = 'class="'. $this->_styles["errors"] .'"';
239
- else
240
- $css = '';
241
-
242
- $output = '
243
- <div '. $css .'>
244
- The following '. $words .' encountered while using the '. get_class($this) .' class:<br/><br/>
245
  <ul>';
246
 
247
- foreach($this->_errors as $error)
248
- $output .= '<li>'. $error .'</li>';
 
249
 
250
- $output .= '
251
  </ul>
252
  </div>';
253
 
254
- return $output;
255
- }
256
-
257
- public function displaySelectInterface() // displays the <select> interface for choosing display amount
258
- {
259
- if(count($this->_displayOptions) < 2) // If only 1 or fewer options, do not display
260
- return;
261
-
262
- if($this->_isError()) // If error encountered, do not display
263
- return;
264
-
265
- static $count = 0; // This counts how many times function is run.
266
- // This variable value is tacked on the end of the form name which
267
- // will enable multiple instances of the display interface form
268
-
269
- $paginationID = $this->getPaginationID();
270
-
271
- $formName = $paginationID. '_select_form';
272
-
273
- // Determine CSS styling for <select>
274
- if($this->_styles["select"])
275
- $css = 'class="'. $this->_styles["select"] .'"';
276
- else
277
- $css = "";
278
-
279
- $formNumber = ($count) ? $count : "";
280
-
281
- $output = '
282
- <form name="'. $formName . $formNumber .'" method="post" style="display:inline-block;" action="'. $this->_getURL($this->_currentPage) .'">
283
- Show:
284
- <select '. $css .' name="'. $this->_getPOSTVarName() .'" OnChange ="'. $formName . $formNumber .'.submit()">';
285
-
286
- foreach($this->_displayOptions as $line)
287
- {
288
- if($this->_entriesPerPage == $line || $this->_entriesPerPage == $this->_totalEntries) // If option equals entries per page
289
- $selected = "selected"; // or entries per page equals total entries
290
- else // then select option, otherwise
291
- $selected = ""; // leave unselected
292
-
293
- $output .= '<option value="'. $line .'" '. $selected .'>'. $line .'</option>';
294
  }
295
-
296
- $output .= '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  </select>
298
  <noscript><input type="submit" name="paginationDisplaySubmit" value="Display"/></noscript>
299
  </form>';
300
-
301
- ++$count; // Increase # of times this function has run
302
-
303
- return $output;
304
- }
305
-
306
-
307
-
308
- /*******************************************************
309
- SET FUNCTIONS
310
- *******************************************************/
311
-
312
- public function setCurrentPage() // sets the currently accessed page from GET value
313
- {
314
- $idVar = $this->_getIDGETVarName();
315
-
316
- if(isset($_GET[$idVar])) // If GET set
317
- $page = $_GET[$idVar]; // Retrieve page from GET
318
- else
319
- $page = 1; // Otherwise use first page
320
-
321
- if($page < 1 || !preg_match("/^\d+$/", $page)) // If page is less than 1 or page value not a digit
322
- {
323
- header("Location: ". $this->_getURL()); // No argument for _getURL() sets it to 1 (first page)
324
- exit;
325
- }
326
 
327
- if($page > $this->getTotalPages() && $this->getTotalPages() != 0) // If page exceeds last page
328
- { // 2nd condition prevents infinite loop should it equal 0
329
- header("Location: ". $this->_getURL($this->getTotalPages()));
330
- exit;
331
  }
332
 
333
- $this->_currentPage = $page;
334
- }
335
 
336
- public function setDisplayOptions($input) // sets the user-specified display amount
337
- {
338
- if(!$this->_validEntry($input)) // If invalid entry encountered, register error and exit function
 
 
339
  {
340
- if(is_array($input)) // If array
 
 
341
  {
342
- $argument = "";
343
-
344
- foreach($input as $key=>$element)
345
- {
346
- if($key > 0)
347
- $argument .= ", ";
348
 
349
- $argument .= $element; // Save all elements in string
350
- }
351
- }
352
- else // If not array
353
  {
354
- $argument = $input;
 
355
  }
356
 
357
- $this->_errors[] = "The value(s) set for <strong>display options</strong> is/are invalid: ". $argument;
 
 
 
 
358
 
359
- return;
360
  }
361
 
362
- if(!is_array($input) && strtolower($input) == "all") // If Not Array and "All" selected
363
- $input = $this->_totalEntries; // Set total entries value
364
-
365
- $this->_displayOptions = $input;
366
- }
367
-
368
- public function setEntriesPerPage() // sets entries per page amount from POST or COOKIE values
369
- {
370
- if($this->_errors) // If an error, quit
371
- return;
372
-
373
- $varName = $this->_getPOSTVarName();
374
-
375
- if(count($this->_displayOptions) > 1) // If more than 1 display option
376
  {
377
- $value = $this->_displayOptions[0]; // Default is first selection
378
-
379
- if(isset($_POST[$varName])) // If POST is set
380
  {
381
- if(in_array($_POST[$varName], $this->_displayOptions)) // Check for valid post value
382
  {
383
- $value = $_POST[$varName];
384
- setcookie($varName, $value, 604800 + time(), "/"); // Set cookie
385
- $_COOKIE[$varName] = $value;
386
- }
387
- else // If invalid post value
388
- {
389
- $value = self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
 
 
 
 
 
390
  }
 
 
 
 
391
  }
392
- elseif(isset($_COOKIE[$varName])) // If POST not set, but COOKIE set
 
393
  {
394
- // Check for valid cookie value
395
- if(in_array($_COOKIE[$varName], $this->_displayOptions)) // Check for valid cookie value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  {
397
- $value = $_COOKIE[$varName]; // Set to value if valid
398
- }
399
- else
 
 
 
 
 
 
 
400
  {
401
- $value = self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
402
- $this->deleteCookie(); // Delete invalid cookie
 
 
 
 
 
 
403
  }
 
 
 
404
  }
 
 
 
 
 
 
 
405
  }
406
- else // If only one option, set either to default or displayOptions value
 
407
  {
408
- $value = ($this->_displayOptions) ? $this->_displayOptions : self::DEFAULT_ENTRIES_DISPLAY;
 
 
 
 
 
 
409
  }
410
 
411
- if(strtolower($value) == "all") // If set to "All", use total entries
412
- $value = $this->_totalEntries;
413
-
414
- $this->_entriesPerPage = $value;
415
- }
416
-
417
- public function setPagesPerSection($input) // sets # of pages per section
418
- {
419
- if(!$this->_validEntry($input))
 
 
 
 
 
420
  {
421
- $this->_errors[] = "The value set for <strong>pages per section</strong> is invalid: ". $input;
422
- return;
 
 
 
 
423
  }
424
-
425
- $this->_pagesPerSection = $input;
426
- }
427
-
428
- public function setPaginationID($input)
429
- {
430
- if($input)
431
  {
432
- if(preg_match("/^\d+$/",$input[0])) // Check if first character is a digit
433
- {
434
- $this->_errors[] = "The first character of the <strong>pagination ID</strong> cannot be a number: ". $input;
435
- return; // cannot be a digit because variable names cannot start with digits,
436
- } // and this value will be used as a variable name
437
 
438
- $this->_paginationID = $input;
 
 
 
439
  }
440
- }
441
-
442
- public function setStyles($pageOff = "", $pageOn = "", $select = "", $errors = "") // sets CSS style class names
443
- {
444
- $this->_styles = array(
445
- "pageOff" => $pageOff,
446
- "pageOn" => $pageOn,
447
- "select" => $select,
448
- "errors" => $errors
449
- );
450
- }
451
 
452
- public function setTotalEntries($input) // sets total number of entries
453
- {
454
- if(!$this->_validEntry($input))
 
 
 
455
  {
456
- $this->_errors[] = "The value set for <strong>total entries</strong> is invalid: ". $input;
457
- return;
458
  }
459
-
460
- $this->_totalEntries = $input;
461
- }
462
 
 
 
 
 
463
 
 
 
 
 
 
 
 
 
 
464
 
 
 
 
 
 
465
 
466
- /*******************************************************
467
- GET FUNCTIONS
468
- *******************************************************/
469
 
470
- private function _getIDGETVarName() // returns GET variable name for pagination pages
471
- {
472
- return $this->getPaginationID() .'-'. self::PAGE_GETVAR_NAME;
473
- }
474
-
475
- private function _getPOSTVarName() // returns POST variable name for select/cookie entities
476
- {
477
- return $this->getPaginationID().'Display';
478
- }
479
-
480
- public function getCurrentPage() // returns the currently accessed page number
481
- {
482
- if(!$this->_currentPage) // If not set, return first page
483
- return 1;
484
- else
485
- return $this->_currentPage;
486
- }
487
 
488
- public function getPagesPerSection() // returns the # of pages per section
489
- {
490
- if(!$this->_pagesPerSection) // If not set, set error and return 0
491
  {
492
- $this->_errors[] = "The value for <strong>pages per section</strong> has not been set.";
493
- return 0;
494
  }
495
-
496
- if($this->_pagesPerSection > $this->getTotalPages()) // If per section is greater than total pages
497
- return $this->getTotalPages(); // Return total pages
498
- else
499
- return $this->_pagesPerSection; // Otherwise return per section
500
- }
501
 
502
- public function getPaginationID() // returns ID name for pagination object
503
- {
504
- return $this->_paginationID;
505
- }
506
-
507
- public function getTotalPages() // returns total pages
508
- {
509
- if($this->_errors) // If there is an error, return 0
510
- return 0;
511
-
512
- if($this->_entriesPerPage == 0) // Prevent division by zero
513
- return 0;
514
-
515
- return ceil($this->_totalEntries / $this->_entriesPerPage); // Total pages: total # of entries divided by total entries per page
516
- }
517
 
518
- public function getEntryStart() // returns the start entry for the page
519
- {
520
- if($this->_isError()) // If error encountered
521
- return 0;
522
-
523
- return ($this->_currentPage - 1) * $this->_entriesPerPage; // Entry start: 1 less than current page multiplied by total entries per page
524
- }
525
 
526
- public function getEntryEnd() // returns the last entry for the page
527
- {
528
- if($this->_isError()) // If error encountered
529
- return 0;
530
 
531
- if($this->_currentPage == $this->getTotalPages()) // If current page is last page
532
- return $this->_totalEntries - $this->getEntryStart(); // then entry end is total entries minus start entry
533
- else
534
- return $this->_entriesPerPage; // otherwise entry end is # of entries per page
535
- }
536
-
537
- public function getEntryEndFF() // Flat-file version of the above getEntryEnd() function
538
- {
539
- if($this->_isError()) // If error encountered
540
- return 0;
541
-
542
- if($this->_currentPage == $this->getTotalPages()) // If current page is last page
543
- return $this->_totalEntries; // then entry end is total entries minus start entry
544
- else
545
- return $this->getEntryStart() + $this->_entriesPerPage; // otherwise entry end is # of entries per page after start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  }
547
- }
548
 
549
- endif; // Prevent multiple class definitions
550
  ?>
1
  <?php
2
  /**
3
+ * Pagination Class
4
+ *
5
+ * This class displays a pagination navigation bar complete with links to first, last,
6
+ * previous, next, and all pages. This class handles cookie setting, page bounds checking/
7
+ * redirection, appropriate error reporting, CSS styling, and POST/GET retrieval all
8
+ * internally.
9
+ *
10
+ * PHP version 5
11
+ *
12
+ * @author Dane Gardow <dane.g87@gmail.com>
13
+ * @copyright 2013 Dane Gardow
14
+ * @date 01 January 2013
15
+ * @version 1.0
16
+ * @license Free
17
+ *
18
+ ******************************************************************************************/
19
+
20
+ if ( ! class_exists( "WP_Statistics_Pagination" ) ): // Prevent multiple class definitions
21
+
22
+ class WP_Statistics_Pagination {
23
+ /*******************************************************
24
+ * PROPERTIES / DATA MEMBERS
25
+ *******************************************************/
26
+
27
+ // Edit these as you desire
28
+ const DEFAULT_ENTRIES_DISPLAY = 10; // Default number of entries to display per page
29
+ const PAGE_GETVAR_NAME = "page"; // Name of GET variable name for page values (i.e., example.php?page=1)
30
+
31
+ private $_paginationID = "pagination"; // ID Name of pagination object "pagination" is default
32
+ // used also for form name for select options
33
+
34
+ // Do not edit these values; they are simply null initializations
35
+ private $_totalEntries = null; // Total number of entries (usually supplied by MySQL query)
36
+ private $_pagesPerSection = null; // Total number of pages displayed per section (supplied by admin)
37
+ private $_entriesPerPage = null; // Total number of entries displayed per page (supplied by user)
38
+ private $_currentPage = null; // Current page viewed by user
39
+ private $_displayOptions = array(); // Array of options for viewing how many entries per page (supplied by user)
40
+ private $_errors = array(); // Array of encountered error messages
41
+ private $_styles = array(); // Array of CSS styles for pagination navigation display
42
+
43
+
44
+ /*******************************************************
45
+ * CONSTRUCTOR
46
+ *******************************************************/
47
+
48
+ function __construct(
49
+ $totalEntries, $pagesPerSection, $options = "", $paginationID = "", $stylePageOff = "",
50
+ $stylePageOn = "", $styleErrors = "", $styleSelect = ""
51
+ ) {
52
+ $this->setPaginationID( $paginationID ); // Set ID name of pagination object
53
+ $this->setTotalEntries( $totalEntries ); // Set total entries
54
+ $this->setPagesPerSection( $pagesPerSection ); // Set pages per section
55
+ $this->setDisplayOptions( $options ); // Set viewing display options
56
+ $this->setEntriesPerPage(); // Set entries per page (input from POST or cookies)
57
+ $this->setCurrentPage(); // Set current page (input from GET)
58
+ // ! This function must follow after setEntriesPerPage()
59
+ $this->setStyles( $stylePageOff, $stylePageOn,
60
+ $styleSelect, $styleErrors ); // Set CSS styles for pagination navigation display
61
+ }
 
 
62
 
63
 
64
+ /*******************************************************
65
+ * UTILITY FUNCTIONS
66
+ *******************************************************/
67
 
68
+ public function deleteCookie() // deletes the cookie if it exists
 
 
 
 
 
 
 
 
69
  {
70
+ $cookieVar = $this->_getPOSTVarName();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ if ( isset( $_COOKIE[ $cookieVar ] ) ) // If cookie is set
73
+ {
74
+ $_COOKIE[ $cookieVar ] = ""; // Clear cookie
75
+ setcookie( $cookieVar, "", time() - 3600, "/" ); // Delete cookie
 
 
 
 
76
  }
77
+ }
78
+
79
+ private function _getURL( $input = 1 ) // returns appropriate URL with all GET variables intact
80
+ { // updates only the particular GET variable in question
81
+ $getVars = $_GET; // Get all GET variables
82
 
83
+ /* Uncomment this if you need to exclude any GET variables (due to HTACCESS issues, for example) from being
84
+ * processed in the ensuing URL. Simply enter in the GET variable name in the unset(...) function below.
85
+ unset($getVars["foo"], $getVars["bar"], ... ); // Remove any so they do not appear in URL
86
+ */
87
+
88
+ $output = '?' . http_build_query( array_merge( $getVars, array( $this->_getIDGETVarName() => $input ) ) );
89
+ $output .= '#' . $this->getPaginationID(); // Add #xxx at the end of URL for auto-scrolling
90
+
91
+ return $output;
92
  }
93
+
94
+ private function _isError() // determines if an error exists and registers any errors
95
  {
96
+ if ( $this->_errors ) // If error already exists, return
97
+ {
98
  return true;
99
+ }
100
+
101
+ if ( ! $this->_totalEntries ) // If total entries not set
102
+ {
103
+ $this->_errors[] = "The value for <strong>total entries</strong> has not been specified.";
104
+ }
105
+
106
+ if ( ! $this->_displayOptions ) // If display options not set
107
+ {
108
+ $this->_errors[] = "The values for <strong>display options</strong> have not been specified.";
109
+ }
110
+
111
+ if ( ! $this->_entriesPerPage ) // If entries per page not set
112
+ {
113
+ $this->_errors[] = "The value for <strong>entries per page</strong> has not been specified.";
114
+ }
115
+
116
+ if ( ! $this->_currentPage ) // If current page not set
117
+ {
118
+ $this->_errors[] = "The value for <strong>current page</strong> has not been specified.";
119
+ }
120
+
121
+ return ( $this->_errors ) ? true : false;
122
  }
123
+
124
+ private function _validEntry( $input ) // determines if input is valid
 
 
 
125
  {
126
+ if ( is_array( $input ) ) // If array
127
+ {
128
+ foreach ( $input as $element ) { // Recursion: evaluate each array element
129
+ if ( ! $this->_validEntry( $element ) ) // If invalid
130
+ {
131
+ return false;
132
+ }
133
+ }
134
+
135
+ return true; // If function makes it to this point, it is valid
136
+ } else // If not array
137
+ {
138
+ if ( ( preg_match( "/^\d+$/", $input ) && $input > 0 ) || strtolower( $input ) == "all" ) // If positive digit or "all"
139
+ {
140
+ return true;
141
+ } else {
142
+ return false;
143
+ }
144
+ }
145
  }
146
 
147
+ private function _navBox( $text, $destinationPage, $end = 0 ) // returns span-encased link for pagination bar
148
+ {
149
+ switch ( $end ) {
150
+ case 1:
151
+ $title = "First page";
152
+ break;
153
+ case 2:
154
+ $title = "Previous page";
155
+ break;
156
+ case 3:
157
+ $title = "Next page";
158
+ break;
159
+ case 4:
160
+ $title = "Last page (" . $this->getTotalPages() . ")";
161
+ break;
162
+ default:
163
+ $title = "";
164
+ break;
165
+ }
166
+
167
+ $title = ( $end > 0 && $title != "" ) ? 'title="' . $title . '"' : '';
168
+
169
+ $style = $this->_styles["pageOff"];
170
+
171
+ // Determine Style
172
+ $style = ( $this->_currentPage == $destinationPage && ! $end ) ? $this->_styles["pageOn"] : $this->_styles["pageOff"];
173
+
174
+ // Determine Link URL/Text
175
+ $url = "";
176
+
177
+ if ( $this->_currentPage != $destinationPage // If current page is not same as destination page
178
+ && $destinationPage <= $this->getTotalPages() // and destination page does not exceed last page
179
+ && $destinationPage >= 1
180
+ ) // and destination page is not less than first page
181
+ {
182
+ $text = '<a href="' . $this->_getURL( $destinationPage ) . '">' . $text . '</a>'; // then make $text a link
183
+ }
184
+
185
+ if ( $style ) {
186
+ $style = 'class="' . $style . '"';
187
+ }
188
+
189
+ $onClick = ( $url ) ? "onclick=\"location.href='" . $url . "'\"" : ""; // Determine if span element is clickable
190
 
191
+ return '<span ' . $style . $title . ' ' . $onClick . '>' . $text . '</span>';
192
+ }
193
 
 
 
194
 
195
+ /*******************************************************
196
+ * DISPLAY FUNCTIONS
197
+ *******************************************************/
198
+
199
+ public function display() // displays the pagination bar
 
200
  {
201
+ if ( $this->_isError() ) // If error encountered, do not display, but display errors
202
+ {
203
+ return $this->displayErrors();
204
+ }
205
+
206
+ $firstPage = 1;
207
+ $previousPage = $this->_currentPage - 1;
208
+ $nextPage = $this->_currentPage + 1;
209
+ $lastPage = $this->getTotalPages();
210
+
211
+ $totalpages = $this->getTotalPages();
212
+
213
+ $pagesPerSection = $this->getPagesPerSection();
214
+
215
+ $sectionStart = $this->_currentPage - floor( $pagesPerSection / 2 ); // Section start is current page # minus half the # of pages per section
216
+
217
+ if ( $sectionStart <= 0 ) // Adjust section start to 1 (first page) if # pages between 1st page
218
+ {
219
+ $sectionStart = 1;
220
+ } // and current page is less than half the # of pages per section
221
+
222
+ $sectionEnd = $sectionStart + $pagesPerSection - 1; // Section end is # pages per section after section start,
223
+ // minus 1 (otherwise # of pages per section will exceed given amount by 1)
224
+
225
+ if ( $sectionEnd > $lastPage ) // Adjust section end to last page if section end exceeds last page
226
+ {
227
+ $sectionEnd = $lastPage;
228
+ }
229
+
230
+ $sectionStart = $sectionEnd - $pagesPerSection + 1; // Adjust section start to # of pages behind section end
231
+
232
+ $output = $this->_navBox( "&lt;&lt;", $firstPage, 1 ); // First page
233
+ $output .= $this->_navBox( "&lt;", $previousPage, 2 ); // Previous page
234
+
235
+ for ( $i = $sectionStart; $i <= $sectionEnd; ++ $i ) {
236
+ $output .= $this->_navBox( $i, $i );
237
+ } // Pagination
238
+
239
+ $output .= $this->_navBox( "&gt;", $nextPage, 3 ); // Next Page
240
+ $output .= $this->_navBox( "&gt;&gt;", $lastPage, 4 ); // Last Page
241
+
242
+ return $output;
243
  }
244
 
245
+ public function displayErrors() // displays the errors encountered
246
+ {
247
+ if ( ! $this->_errors ) {
248
+ return "No errors were encountered.";
249
+ }
250
+
251
+ $words = ( count( $this->_errors ) > 1 ) ? "errors were" : "error was";
252
+
253
+ // Determine CSS styling for error reporting
254
+ if ( $this->_styles["errors"] ) {
255
+ $css = 'class="' . $this->_styles["errors"] . '"';
256
+ } else {
257
+ $css = '';
258
+ }
259
+
260
+ $output = '
261
+ <div ' . $css . '>
262
+ The following ' . $words . ' encountered while using the ' . get_class( $this ) . ' class:<br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  <ul>';
264
 
265
+ foreach ( $this->_errors as $error ) {
266
+ $output .= '<li>' . $error . '</li>';
267
+ }
268
 
269
+ $output .= '
270
  </ul>
271
  </div>';
272
 
273
+ return $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  }
275
+
276
+ public function displaySelectInterface() // displays the <select> interface for choosing display amount
277
+ {
278
+ if ( count( $this->_displayOptions ) < 2 ) // If only 1 or fewer options, do not display
279
+ {
280
+ return;
281
+ }
282
+
283
+ if ( $this->_isError() ) // If error encountered, do not display
284
+ {
285
+ return;
286
+ }
287
+
288
+ static $count = 0; // This counts how many times function is run.
289
+ // This variable value is tacked on the end of the form name which
290
+ // will enable multiple instances of the display interface form
291
+
292
+ $paginationID = $this->getPaginationID();
293
+
294
+ $formName = $paginationID . '_select_form';
295
+
296
+ // Determine CSS styling for <select>
297
+ if ( $this->_styles["select"] ) {
298
+ $css = 'class="' . $this->_styles["select"] . '"';
299
+ } else {
300
+ $css = "";
301
+ }
302
+
303
+ $formNumber = ( $count ) ? $count : "";
304
+
305
+ $output = '
306
+ <form name="' . $formName . $formNumber . '" method="post" style="display:inline-block;" action="' . $this->_getURL( $this->_currentPage ) . '">
307
+ Show:
308
+ <select ' . $css . ' name="' . $this->_getPOSTVarName() . '" OnChange ="' . $formName . $formNumber . '.submit()">';
309
+
310
+ foreach ( $this->_displayOptions as $line ) {
311
+ if ( $this->_entriesPerPage == $line || $this->_entriesPerPage == $this->_totalEntries ) // If option equals entries per page
312
+ {
313
+ $selected = "selected";
314
+ } // or entries per page equals total entries
315
+ else // then select option, otherwise
316
+ {
317
+ $selected = "";
318
+ } // leave unselected
319
+
320
+ $output .= '<option value="' . $line . '" ' . $selected . '>' . $line . '</option>';
321
+ }
322
+
323
+ $output .= '
324
  </select>
325
  <noscript><input type="submit" name="paginationDisplaySubmit" value="Display"/></noscript>
326
  </form>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
 
328
+ ++ $count; // Increase # of times this function has run
329
+
330
+ return $output;
 
331
  }
332
 
 
 
333
 
334
+ /*******************************************************
335
+ * SET FUNCTIONS
336
+ *******************************************************/
337
+
338
+ public function setCurrentPage() // sets the currently accessed page from GET value
339
  {
340
+ $idVar = $this->_getIDGETVarName();
341
+
342
+ if ( isset( $_GET[ $idVar ] ) ) // If GET set
343
  {
344
+ $page = $_GET[ $idVar ];
345
+ } // Retrieve page from GET
346
+ else {
347
+ $page = 1;
348
+ } // Otherwise use first page
 
349
 
350
+ if ( $page < 1 || ! preg_match( "/^\d+$/", $page ) ) // If page is less than 1 or page value not a digit
 
 
 
351
  {
352
+ header( "Location: " . $this->_getURL() ); // No argument for _getURL() sets it to 1 (first page)
353
+ exit;
354
  }
355
 
356
+ if ( $page > $this->getTotalPages() && $this->getTotalPages() != 0 ) // If page exceeds last page
357
+ { // 2nd condition prevents infinite loop should it equal 0
358
+ header( "Location: " . $this->_getURL( $this->getTotalPages() ) );
359
+ exit;
360
+ }
361
 
362
+ $this->_currentPage = $page;
363
  }
364
 
365
+ public function setDisplayOptions( $input ) // sets the user-specified display amount
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  {
367
+ if ( ! $this->_validEntry( $input ) ) // If invalid entry encountered, register error and exit function
 
 
368
  {
369
+ if ( is_array( $input ) ) // If array
370
  {
371
+ $argument = "";
372
+
373
+ foreach ( $input as $key => $element ) {
374
+ if ( $key > 0 ) {
375
+ $argument .= ", ";
376
+ }
377
+
378
+ $argument .= $element; // Save all elements in string
379
+ }
380
+ } else // If not array
381
+ {
382
+ $argument = $input;
383
  }
384
+
385
+ $this->_errors[] = "The value(s) set for <strong>display options</strong> is/are invalid: " . $argument;
386
+
387
+ return;
388
  }
389
+
390
+ if ( ! is_array( $input ) && strtolower( $input ) == "all" ) // If Not Array and "All" selected
391
  {
392
+ $input = $this->_totalEntries;
393
+ } // Set total entries value
394
+
395
+ $this->_displayOptions = $input;
396
+ }
397
+
398
+ public function setEntriesPerPage() // sets entries per page amount from POST or COOKIE values
399
+ {
400
+ if ( $this->_errors ) // If an error, quit
401
+ {
402
+ return;
403
+ }
404
+
405
+ $varName = $this->_getPOSTVarName();
406
+
407
+ if ( count( $this->_displayOptions ) > 1 ) // If more than 1 display option
408
+ {
409
+ $value = $this->_displayOptions[0]; // Default is first selection
410
+
411
+ if ( isset( $_POST[ $varName ] ) ) // If POST is set
412
  {
413
+ if ( in_array( $_POST[ $varName ], $this->_displayOptions ) ) // Check for valid post value
414
+ {
415
+ $value = $_POST[ $varName ];
416
+ setcookie( $varName, $value, 604800 + time(), "/" ); // Set cookie
417
+ $_COOKIE[ $varName ] = $value;
418
+ } else // If invalid post value
419
+ {
420
+ $value = self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
421
+ }
422
+ } elseif ( isset( $_COOKIE[ $varName ] ) ) // If POST not set, but COOKIE set
423
  {
424
+ // Check for valid cookie value
425
+ if ( in_array( $_COOKIE[ $varName ], $this->_displayOptions ) ) // Check for valid cookie value
426
+ {
427
+ $value = $_COOKIE[ $varName ]; // Set to value if valid
428
+ } else {
429
+ $value = self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
430
+ $this->deleteCookie(); // Delete invalid cookie
431
+ }
432
  }
433
+ } else // If only one option, set either to default or displayOptions value
434
+ {
435
+ $value = ( $this->_displayOptions ) ? $this->_displayOptions : self::DEFAULT_ENTRIES_DISPLAY;
436
  }
437
+
438
+ if ( strtolower( $value ) == "all" ) // If set to "All", use total entries
439
+ {
440
+ $value = $this->_totalEntries;
441
+ }
442
+
443
+ $this->_entriesPerPage = $value;
444
  }
445
+
446
+ public function setPagesPerSection( $input ) // sets # of pages per section
447
  {
448
+ if ( ! $this->_validEntry( $input ) ) {
449
+ $this->_errors[] = "The value set for <strong>pages per section</strong> is invalid: " . $input;
450
+
451
+ return;
452
+ }
453
+
454
+ $this->_pagesPerSection = $input;
455
  }
456
 
457
+ public function setPaginationID( $input ) {
458
+ if ( $input ) {
459
+ if ( preg_match( "/^\d+$/", $input[0] ) ) // Check if first character is a digit
460
+ {
461
+ $this->_errors[] = "The first character of the <strong>pagination ID</strong> cannot be a number: " . $input;
462
+
463
+ return; // cannot be a digit because variable names cannot start with digits,
464
+ } // and this value will be used as a variable name
465
+
466
+ $this->_paginationID = $input;
467
+ }
468
+ }
469
+
470
+ public function setStyles( $pageOff = "", $pageOn = "", $select = "", $errors = "" ) // sets CSS style class names
471
  {
472
+ $this->_styles = array(
473
+ "pageOff" => $pageOff,
474
+ "pageOn" => $pageOn,
475
+ "select" => $select,
476
+ "errors" => $errors
477
+ );
478
  }
479
+
480
+ public function setTotalEntries( $input ) // sets total number of entries
 
 
 
 
 
481
  {
482
+ if ( ! $this->_validEntry( $input ) ) {
483
+ $this->_errors[] = "The value set for <strong>total entries</strong> is invalid: " . $input;
 
 
 
484
 
485
+ return;
486
+ }
487
+
488
+ $this->_totalEntries = $input;
489
  }
 
 
 
 
 
 
 
 
 
 
 
490
 
491
+
492
+ /*******************************************************
493
+ * GET FUNCTIONS
494
+ *******************************************************/
495
+
496
+ private function _getIDGETVarName() // returns GET variable name for pagination pages
497
  {
498
+ return $this->getPaginationID() . '-' . self::PAGE_GETVAR_NAME;
 
499
  }
 
 
 
500
 
501
+ private function _getPOSTVarName() // returns POST variable name for select/cookie entities
502
+ {
503
+ return $this->getPaginationID() . 'Display';
504
+ }
505
 
506
+ public function getCurrentPage() // returns the currently accessed page number
507
+ {
508
+ if ( ! $this->_currentPage ) // If not set, return first page
509
+ {
510
+ return 1;
511
+ } else {
512
+ return $this->_currentPage;
513
+ }
514
+ }
515
 
516
+ public function getPagesPerSection() // returns the # of pages per section
517
+ {
518
+ if ( ! $this->_pagesPerSection ) // If not set, set error and return 0
519
+ {
520
+ $this->_errors[] = "The value for <strong>pages per section</strong> has not been set.";
521
 
522
+ return 0;
523
+ }
 
524
 
525
+ if ( $this->_pagesPerSection > $this->getTotalPages() ) // If per section is greater than total pages
526
+ {
527
+ return $this->getTotalPages();
528
+ } // Return total pages
529
+ else {
530
+ return $this->_pagesPerSection;
531
+ } // Otherwise return per section
532
+ }
 
 
 
 
 
 
 
 
 
533
 
534
+ public function getPaginationID() // returns ID name for pagination object
 
 
535
  {
536
+ return $this->_paginationID;
 
537
  }
 
 
 
 
 
 
538
 
539
+ public function getTotalPages() // returns total pages
540
+ {
541
+ if ( $this->_errors ) // If there is an error, return 0
542
+ {
543
+ return 0;
544
+ }
 
 
 
 
 
 
 
 
 
545
 
546
+ if ( $this->_entriesPerPage == 0 ) // Prevent division by zero
547
+ {
548
+ return 0;
549
+ }
 
 
 
550
 
551
+ return ceil( $this->_totalEntries / $this->_entriesPerPage ); // Total pages: total # of entries divided by total entries per page
552
+ }
 
 
553
 
554
+ public function getEntryStart() // returns the start entry for the page
555
+ {
556
+ if ( $this->_isError() ) // If error encountered
557
+ {
558
+ return 0;
559
+ }
560
+
561
+ return ( $this->_currentPage - 1 ) * $this->_entriesPerPage; // Entry start: 1 less than current page multiplied by total entries per page
562
+ }
563
+
564
+ public function getEntryEnd() // returns the last entry for the page
565
+ {
566
+ if ( $this->_isError() ) // If error encountered
567
+ {
568
+ return 0;
569
+ }
570
+
571
+ if ( $this->_currentPage == $this->getTotalPages() ) // If current page is last page
572
+ {
573
+ return $this->_totalEntries - $this->getEntryStart();
574
+ } // then entry end is total entries minus start entry
575
+ else {
576
+ return $this->_entriesPerPage;
577
+ } // otherwise entry end is # of entries per page
578
+ }
579
+
580
+ public function getEntryEndFF() // Flat-file version of the above getEntryEnd() function
581
+ {
582
+ if ( $this->_isError() ) // If error encountered
583
+ {
584
+ return 0;
585
+ }
586
+
587
+ if ( $this->_currentPage == $this->getTotalPages() ) // If current page is last page
588
+ {
589
+ return $this->_totalEntries;
590
+ } // then entry end is total entries minus start entry
591
+ else {
592
+ return $this->getEntryStart() + $this->_entriesPerPage;
593
+ } // otherwise entry end is # of entries per page after start
594
+ }
595
  }
 
596
 
597
+ endif; // Prevent multiple class definitions
598
  ?>
includes/classes/php-export-data.class.php CHANGED
@@ -13,17 +13,17 @@ abstract class ExportData {
13
 
14
  public $filename; // file mode: the output file name; browser mode: file name for download; string mode: not used
15
 
16
- public function __construct($exportTo = "browser", $filename = "exportdata") {
17
- if(!in_array($exportTo, array('browser','file','string') )) {
18
- throw new Exception("$exportTo is not a valid ExportData export type");
19
  }
20
  $this->exportTo = $exportTo;
21
  $this->filename = $filename;
22
  }
23
-
24
  public function initialize() {
25
-
26
- switch($this->exportTo) {
27
  case 'browser':
28
  $this->sendHttpHeaders();
29
  break;
@@ -31,23 +31,23 @@ abstract class ExportData {
31
  $this->stringData = '';
32
  break;
33
  case 'file':
34
- $this->tempFilename = tempnam(sys_get_temp_dir(), 'exportdata');
35
- $this->tempFile = fopen($this->tempFilename, "w");
36
  break;
37
  }
38
-
39
- $this->write($this->generateHeader());
40
  }
41
-
42
- public function addRow($row) {
43
- $this->write($this->generateRow($row));
44
  }
45
-
46
  public function finalize() {
47
-
48
- $this->write($this->generateFooter());
49
-
50
- switch($this->exportTo) {
51
  case 'browser':
52
  flush();
53
  break;
@@ -56,20 +56,20 @@ abstract class ExportData {
56
  break;
57
  case 'file':
58
  // close temp file and move it to correct location
59
- fclose($this->tempFile);
60
- rename($this->tempFilename, $this->filename);
61
  break;
62
  }
63
  }
64
-
65
  public function getString() {
66
  return $this->stringData;
67
  }
68
-
69
  abstract public function sendHttpHeaders();
70
-
71
- protected function write($data) {
72
- switch($this->exportTo) {
73
  case 'browser':
74
  echo $data;
75
  break;
@@ -77,41 +77,42 @@ abstract class ExportData {
77
  $this->stringData .= $data;
78
  break;
79
  case 'file':
80
- fwrite($this->tempFile, $data);
81
  break;
82
  }
83
  }
84
-
85
  protected function generateHeader() {
86
  // can be overridden by subclass to return any data that goes at the top of the exported file
87
  }
88
-
89
  protected function generateFooter() {
90
  // can be overridden by subclass to return any data that goes at the bottom of the exported file
91
  }
92
-
93
  // In subclasses generateRow will take $row array and return string of it formatted for export type
94
- abstract protected function generateRow($row);
95
-
96
  }
97
 
98
  /**
99
  * ExportDataTSV - Exports to TSV (tab separated value) format.
100
  */
101
  class ExportDataTSV extends ExportData {
102
-
103
- function generateRow($row) {
104
- foreach ($row as $key => $value) {
105
  // Escape inner quotes and wrap all contents in new quotes.
106
  // Note that we are using \" to escape double quote not ""
107
- $row[$key] = '"'. str_replace('"', '\"', $value) .'"';
108
  }
109
- return implode("\t", $row) . "\n";
 
110
  }
111
-
112
  function sendHttpHeaders() {
113
- header("Content-type: text/tab-separated-values");
114
- header("Content-Disposition: attachment; filename=".basename($this->filename));
115
  }
116
  }
117
 
@@ -119,92 +120,94 @@ class ExportDataTSV extends ExportData {
119
  * ExportDataCSV - Exports to CSV (comma separated value) format.
120
  */
121
  class ExportDataCSV extends ExportData {
122
-
123
- function generateRow($row) {
124
- foreach ($row as $key => $value) {
125
  // Escape inner quotes and wrap all contents in new quotes.
126
  // Note that we are using \" to escape double quote not ""
127
- $row[$key] = '"'. str_replace('"', '\"', $value) .'"';
128
  }
129
- return implode(",", $row) . "\n";
 
130
  }
131
-
132
  function sendHttpHeaders() {
133
- header("Content-type: text/csv");
134
- header("Content-Disposition: attachment; filename=".basename($this->filename));
135
  }
136
  }
137
 
138
 
139
  /**
140
- * ExportDataExcel exports data into an XML format (spreadsheetML) that can be
141
  * read by MS Excel 2003 and newer as well as OpenOffice
142
- *
143
  * Creates a workbook with a single worksheet (title specified by
144
  * $title).
145
- *
146
  * Note that using .XML is the "correct" file extension for these files, but it
147
  * generally isn't associated with Excel. Using .XLS is tempting, but Excel 2007 will
148
  * throw a scary warning that the extension doesn't match the file type.
149
- *
150
  * Based on Excel XML code from Excel_XML (http://github.com/oliverschwarz/php-excel)
151
  * by Oliver Schwarz
152
  */
153
  class ExportDataExcel extends ExportData {
154
-
155
  const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
156
  const XmlFooter = "</Workbook>";
157
-
158
  public $encoding = 'UTF-8'; // encoding type to specify in file.
159
  // Note that you're on your own for making sure your data is actually encoded to this encoding
160
-
161
  public $title = 'Sheet1'; // title for Worksheet
162
-
163
  function generateHeader() {
164
-
165
  // workbook header
166
- $output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
167
-
168
  // Set up styles
169
  $output .= "<Styles>\n";
170
  $output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
171
  $output .= "</Styles>\n";
172
-
173
  // worksheet header
174
- $output .= sprintf("<Worksheet ss:Name=\"%s\">\n <Table>\n", htmlentities($this->title));
175
-
176
  return $output;
177
  }
178
-
179
  function generateFooter() {
180
  $output = '';
181
-
182
  // worksheet footer
183
  $output .= " </Table>\n</Worksheet>\n";
184
-
185
  // workbook footer
186
  $output .= self::XmlFooter;
187
-
188
  return $output;
189
  }
190
-
191
- function generateRow($row) {
192
  $output = '';
193
  $output .= " <Row>\n";
194
- foreach ($row as $k => $v) {
195
- $output .= $this->generateCell($v);
196
  }
197
  $output .= " </Row>\n";
 
198
  return $output;
199
  }
200
-
201
- private function generateCell($item) {
202
  $output = '';
203
- $style = '';
204
-
205
  // Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
206
  // as text if number is longer than that.
207
- if(preg_match("/^-?\d+(?:[.,]\d+)?$/",$item) && (strlen($item) < 15)) {
208
  $type = 'Number';
209
  }
210
  // Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
@@ -213,30 +216,30 @@ class ExportDataExcel extends ExportData {
213
  // Note we want to be very strict in what we consider a date. There is the possibility
214
  // of really screwing up the data if we try to reformat a string that was not actually
215
  // intended to represent a date.
216
- elseif(preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/",$item) &&
217
- ($timestamp = strtotime($item)) &&
218
- ($timestamp > 0) &&
219
- ($timestamp < strtotime('+500 years'))) {
220
- $type = 'DateTime';
221
- $item = strftime("%Y-%m-%dT%H:%M:%S",$timestamp);
 
222
  $style = 'sDT'; // defined in header; tells excel to format date for display
223
- }
224
- else {
225
  $type = 'String';
226
  }
227
-
228
- $item = str_replace('&#039;', '&apos;', htmlspecialchars($item, ENT_QUOTES));
229
  $output .= " ";
230
  $output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
231
- $output .= sprintf("<Data ss:Type=\"%s\">%s</Data>", $type, $item);
232
  $output .= "</Cell>\n";
233
-
234
  return $output;
235
  }
236
-
237
  function sendHttpHeaders() {
238
- header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding);
239
- header("Content-Disposition: inline; filename=\"" . basename($this->filename) . "\"");
240
  }
241
-
242
  }
13
 
14
  public $filename; // file mode: the output file name; browser mode: file name for download; string mode: not used
15
 
16
+ public function __construct( $exportTo = "browser", $filename = "exportdata" ) {
17
+ if ( ! in_array( $exportTo, array( 'browser', 'file', 'string' ) ) ) {
18
+ throw new Exception( "$exportTo is not a valid ExportData export type" );
19
  }
20
  $this->exportTo = $exportTo;
21
  $this->filename = $filename;
22
  }
23
+
24
  public function initialize() {
25
+
26
+ switch ( $this->exportTo ) {
27
  case 'browser':
28
  $this->sendHttpHeaders();
29
  break;
31
  $this->stringData = '';
32
  break;
33
  case 'file':
34
+ $this->tempFilename = tempnam( sys_get_temp_dir(), 'exportdata' );
35
+ $this->tempFile = fopen( $this->tempFilename, "w" );
36
  break;
37
  }
38
+
39
+ $this->write( $this->generateHeader() );
40
  }
41
+
42
+ public function addRow( $row ) {
43
+ $this->write( $this->generateRow( $row ) );
44
  }
45
+
46
  public function finalize() {
47
+
48
+ $this->write( $this->generateFooter() );
49
+
50
+ switch ( $this->exportTo ) {
51
  case 'browser':
52
  flush();
53
  break;
56
  break;
57
  case 'file':
58
  // close temp file and move it to correct location
59
+ fclose( $this->tempFile );
60
+ rename( $this->tempFilename, $this->filename );
61
  break;
62
  }
63
  }
64
+
65
  public function getString() {
66
  return $this->stringData;
67
  }
68
+
69
  abstract public function sendHttpHeaders();
70
+
71
+ protected function write( $data ) {
72
+ switch ( $this->exportTo ) {
73
  case 'browser':
74
  echo $data;
75
  break;
77
  $this->stringData .= $data;
78
  break;
79
  case 'file':
80
+ fwrite( $this->tempFile, $data );
81
  break;
82
  }
83
  }
84
+
85
  protected function generateHeader() {
86
  // can be overridden by subclass to return any data that goes at the top of the exported file
87
  }
88
+
89
  protected function generateFooter() {
90
  // can be overridden by subclass to return any data that goes at the bottom of the exported file
91
  }
92
+
93
  // In subclasses generateRow will take $row array and return string of it formatted for export type
94
+ abstract protected function generateRow( $row );
95
+
96
  }
97
 
98
  /**
99
  * ExportDataTSV - Exports to TSV (tab separated value) format.
100
  */
101
  class ExportDataTSV extends ExportData {
102
+
103
+ function generateRow( $row ) {
104
+ foreach ( $row as $key => $value ) {
105
  // Escape inner quotes and wrap all contents in new quotes.
106
  // Note that we are using \" to escape double quote not ""
107
+ $row[ $key ] = '"' . str_replace( '"', '\"', $value ) . '"';
108
  }
109
+
110
+ return implode( "\t", $row ) . "\n";
111
  }
112
+
113
  function sendHttpHeaders() {
114
+ header( "Content-type: text/tab-separated-values" );
115
+ header( "Content-Disposition: attachment; filename=" . basename( $this->filename ) );
116
  }
117
  }
118
 
120
  * ExportDataCSV - Exports to CSV (comma separated value) format.
121
  */
122
  class ExportDataCSV extends ExportData {
123
+
124
+ function generateRow( $row ) {
125
+ foreach ( $row as $key => $value ) {
126
  // Escape inner quotes and wrap all contents in new quotes.
127
  // Note that we are using \" to escape double quote not ""
128
+ $row[ $key ] = '"' . str_replace( '"', '\"', $value ) . '"';
129
  }
130
+
131
+ return implode( ",", $row ) . "\n";
132
  }
133
+
134
  function sendHttpHeaders() {
135
+ header( "Content-type: text/csv" );
136
+ header( "Content-Disposition: attachment; filename=" . basename( $this->filename ) );
137
  }
138
  }
139
 
140
 
141
  /**
142
+ * ExportDataExcel exports data into an XML format (spreadsheetML) that can be
143
  * read by MS Excel 2003 and newer as well as OpenOffice
144
+ *
145
  * Creates a workbook with a single worksheet (title specified by
146
  * $title).
147
+ *
148
  * Note that using .XML is the "correct" file extension for these files, but it
149
  * generally isn't associated with Excel. Using .XLS is tempting, but Excel 2007 will
150
  * throw a scary warning that the extension doesn't match the file type.
151
+ *
152
  * Based on Excel XML code from Excel_XML (http://github.com/oliverschwarz/php-excel)
153
  * by Oliver Schwarz
154
  */
155
  class ExportDataExcel extends ExportData {
156
+
157
  const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
158
  const XmlFooter = "</Workbook>";
159
+
160
  public $encoding = 'UTF-8'; // encoding type to specify in file.
161
  // Note that you're on your own for making sure your data is actually encoded to this encoding
162
+
163
  public $title = 'Sheet1'; // title for Worksheet
164
+
165
  function generateHeader() {
166
+
167
  // workbook header
168
+ $output = stripslashes( sprintf( self::XmlHeader, $this->encoding ) ) . "\n";
169
+
170
  // Set up styles
171
  $output .= "<Styles>\n";
172
  $output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
173
  $output .= "</Styles>\n";
174
+
175
  // worksheet header
176
+ $output .= sprintf( "<Worksheet ss:Name=\"%s\">\n <Table>\n", htmlentities( $this->title ) );
177
+
178
  return $output;
179
  }
180
+
181
  function generateFooter() {
182
  $output = '';
183
+
184
  // worksheet footer
185
  $output .= " </Table>\n</Worksheet>\n";
186
+
187
  // workbook footer
188
  $output .= self::XmlFooter;
189
+
190
  return $output;
191
  }
192
+
193
+ function generateRow( $row ) {
194
  $output = '';
195
  $output .= " <Row>\n";
196
+ foreach ( $row as $k => $v ) {
197
+ $output .= $this->generateCell( $v );
198
  }
199
  $output .= " </Row>\n";
200
+
201
  return $output;
202
  }
203
+
204
+ private function generateCell( $item ) {
205
  $output = '';
206
+ $style = '';
207
+
208
  // Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
209
  // as text if number is longer than that.
210
+ if ( preg_match( "/^-?\d+(?:[.,]\d+)?$/", $item ) && ( strlen( $item ) < 15 ) ) {
211
  $type = 'Number';
212
  }
213
  // Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
216
  // Note we want to be very strict in what we consider a date. There is the possibility
217
  // of really screwing up the data if we try to reformat a string that was not actually
218
  // intended to represent a date.
219
+ elseif ( preg_match( "/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item ) &&
220
+ ( $timestamp = strtotime( $item ) ) &&
221
+ ( $timestamp > 0 ) &&
222
+ ( $timestamp < strtotime( '+500 years' ) )
223
+ ) {
224
+ $type = 'DateTime';
225
+ $item = strftime( "%Y-%m-%dT%H:%M:%S", $timestamp );
226
  $style = 'sDT'; // defined in header; tells excel to format date for display
227
+ } else {
 
228
  $type = 'String';
229
  }
230
+
231
+ $item = str_replace( '&#039;', '&apos;', htmlspecialchars( $item, ENT_QUOTES ) );
232
  $output .= " ";
233
  $output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
234
+ $output .= sprintf( "<Data ss:Type=\"%s\">%s</Data>", $type, $item );
235
  $output .= "</Cell>\n";
236
+
237
  return $output;
238
  }
239
+
240
  function sendHttpHeaders() {
241
+ header( "Content-Type: application/vnd.ms-excel; charset=" . $this->encoding );
242
+ header( "Content-Disposition: inline; filename=\"" . basename( $this->filename ) . "\"" );
243
  }
244
+
245
  }
includes/classes/statistics.class.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /*
3
  This is the primary class for WP Statistics recording hits on the WordPress site. It is extended by the Hits class and the GeoIPHits class.
4
 
@@ -35,21 +36,21 @@ class WP_Statistics {
35
 
36
  global $wpdb;
37
 
38
- if( get_option( 'timezone_string' ) ) {
39
  $this->tz_offset = timezone_offset_get( timezone_open( get_option( 'timezone_string' ) ), new DateTime() );
40
- } else if( get_option( 'gmt_offset' ) ) {
41
  $this->tz_offset = get_option( 'gmt_offset' ) * 60 * 60;
42
  }
43
 
44
- $this->db = $wpdb;
45
- $this->tb_prefix = $wpdb->prefix;
46
- $this->agent = $this->get_UserAgent();
47
  $this->historical = array();
48
 
49
  // Load the options from the database
50
  $this->options = get_option( 'wp_statistics' );
51
 
52
- if( ! is_array( $this->options ) ) {
53
  $this->user_options = array();
54
  }
55
 
@@ -57,21 +58,25 @@ class WP_Statistics {
57
  $this->coefficient = $this->get_option( 'coefficient', 1 );
58
 
59
  // Double check the co-efficient setting to make sure it's not been set to 0.
60
- if( $this->coefficient <= 0 ) { $this->coefficient = 1; }
 
 
61
 
62
  // This is a bit of a hack, we strip off the "includes/classes" at the end of the current class file's path.
63
- $this->plugin_dir = substr( dirname( __FILE__ ), 0, -17 );
64
- $this->plugin_url = substr( plugin_dir_url( __FILE__ ), 0, -17 );
65
 
66
  $this->get_IP();
67
 
68
- if( $this->get_option( 'hash_ips' ) == true ) { $this->ip_hash = '#hash#' . sha1( $this->ip . $_SERVER['HTTP_USER_AGENT'] ); }
 
 
69
 
70
  }
71
 
72
  // This function sets the current WordPress user id for the class.
73
  public function set_user_id() {
74
- if( $this->user_id == 0 ) {
75
  $this->user_id = get_current_user_id();
76
  }
77
  }
@@ -80,68 +85,76 @@ class WP_Statistics {
80
  public function load_options() {
81
  $this->options = get_option( 'wp_statistics' );
82
 
83
- if( ! is_array( $this->options ) ) {
84
  $this->user_options = array();
85
  }
86
  }
87
 
88
  // This function loads the user options from WordPress. It is NOT called during the class constructor.
89
  public function load_user_options( $force = false ) {
90
- if( $this->user_options_loaded == true && $force != true ) { return; }
 
 
91
 
92
  $this->set_user_id();
93
 
94
  // Not sure why, but get_user_meta() is returning an array or array's unless $single is set to true.
95
  $this->user_options = get_user_meta( $this->user_id, 'wp_statistics', true );
96
 
97
- if( ! is_array( $this->user_options ) ) {
98
  $this->user_options = array();
99
  }
100
-
101
  $this->user_options_loaded = true;
102
  }
103
 
104
  // The function mimics WordPress's get_option() function but uses the array instead of individual options.
105
  public function get_option( $option, $default = null ) {
106
  // If no options array exists, return FALSE.
107
- if( !is_array($this->options) ) { return FALSE; }
 
 
108
 
109
  // if the option isn't set yet, return the $default if it exists, otherwise FALSE.
110
- if( !array_key_exists( $option, $this->options ) ) {
111
- if( isset( $default ) ) {
112
  return $default;
113
  } else {
114
- return FALSE;
115
  }
116
  }
117
 
118
  // Return the option.
119
- return $this->options[$option];
120
  }
121
 
122
  // This function mimics WordPress's get_user_meta() function but uses the array instead of individual options.
123
  public function get_user_option( $option, $default = null ) {
124
  // If the user id has not been set or no options array exists, return FALSE.
125
- if( $this->user_id == 0 ) {return FALSE; }
126
- if( !is_array($this->user_options) ) { return FALSE; }
 
 
 
 
127
 
128
  // if the option isn't set yet, return the $default if it exists, otherwise FALSE.
129
- if( !array_key_exists( $option, $this->user_options ) ) {
130
- if( isset( $default ) ) {
131
  return $default;
132
  } else {
133
- return FALSE;
134
  }
135
  }
136
 
137
  // Return the option.
138
- return $this->user_options[$option];
139
  }
140
 
141
  // The function mimics WordPress's update_option() function but uses the array instead of individual options.
142
  public function update_option( $option, $value ) {
143
  // Store the value in the array.
144
- $this->options[$option] = $value;
145
 
146
  // Write the array to the database.
147
  update_option( 'wp_statistics', $this->options );
@@ -150,10 +163,12 @@ class WP_Statistics {
150
  // The function mimics WordPress's update_user_meta() function but uses the array instead of individual options.
151
  public function update_user_option( $option, $value ) {
152
  // If the user id has not been set return FALSE.
153
- if( $this->user_id == 0 ) { return FALSE; }
 
 
154
 
155
  // Store the value in the array.
156
- $this->user_options[$option] = $value;
157
 
158
  // Write the array to the database.
159
  update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
@@ -161,40 +176,50 @@ class WP_Statistics {
161
 
162
  // This function is similar to update_option, but it only stores the option in the array. This save some writing to the database if you have multiple values to update.
163
  public function store_option( $option, $value ) {
164
- $this->options[$option] = $value;
165
  }
166
 
167
  // This function is similar to update_user_option, but it only stores the option in the array. This save some writing to the database if you have multiple values to update.
168
  public function store_user_option( $option, $value ) {
169
  // If the user id has not been set return FALSE.
170
- if( $this->user_id == 0 ) { return FALSE; }
 
 
171
 
172
- $this->user_options[$option] = $value;
173
  }
174
 
175
  // This function saves the current options array to the database.
176
  public function save_options() {
177
  update_option( 'wp_statistics', $this->options );
178
- }
179
 
180
  // This function saves the current user options array to the database.
181
  public function save_user_options() {
182
- if( $this->user_id == 0 ) { return FALSE; }
 
 
183
 
184
  update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
185
  }
186
 
187
  // This function check to see if an option is currently set or not.
188
  public function isset_option( $option ) {
189
- if( !is_array($this->options) ) { return FALSE; }
 
 
190
 
191
  return array_key_exists( $option, $this->options );
192
  }
193
 
194
  // This function check to see if a user option is currently set or not.
195
  public function isset_user_option( $option ) {
196
- if( $this->user_id == 0 ) { return FALSE; }
197
- if( !is_array($this->user_options) ) { return FALSE; }
 
 
 
 
198
 
199
  return array_key_exists( $option, $this->user_options );
200
  }
@@ -203,52 +228,52 @@ class WP_Statistics {
203
  // This function will add some initial data if the tables are empty.
204
  public function Primary_Values() {
205
 
206
- $this->result = $this->db->query("SELECT * FROM {$this->tb_prefix}statistics_useronline");
207
 
208
- if( !$this->result ) {
209
 
210
  $this->db->insert(
211
  $this->tb_prefix . "statistics_useronline",
212
  array(
213
- 'ip' => $this->get_IP(),
214
- 'timestamp' => $this->Current_Date('U'),
215
- 'date' => $this->Current_Date(),
216
- 'referred' => $this->get_Referred(),
217
- 'agent' => $this->agent['browser'],
218
- 'platform' => $this->agent['platform'],
219
- 'version' => $this->agent['version']
220
  )
221
  );
222
  }
223
 
224
- $this->result = $this->db->query("SELECT * FROM {$this->tb_prefix}statistics_visit");
225
 
226
- if( !$this->result ) {
227
 
228
  $this->db->insert(
229
  $this->tb_prefix . "statistics_visit",
230
  array(
231
- 'last_visit' => $this->Current_Date(),
232
- 'last_counter' => $this->Current_date('Y-m-d'),
233
- 'visit' => 1
234
  )
235
  );
236
  }
237
 
238
- $this->result = $this->db->query("SELECT * FROM {$this->tb_prefix}statistics_visitor");
239
 
240
- if( !$this->result ) {
241
 
242
  $this->db->insert(
243
  $this->tb_prefix . "statistics_visitor",
244
  array(
245
- 'last_counter' => $this->Current_date('Y-m-d'),
246
- 'referred' => $this->get_Referred(),
247
- 'agent' => $this->agent['browser'],
248
- 'platform' => $this->agent['platform'],
249
- 'version' => $this->agent['version'],
250
- 'ip' => $this->get_IP(),
251
- 'location' => '000'
252
  )
253
  );
254
  }
@@ -258,46 +283,46 @@ class WP_Statistics {
258
  // This function will save a set of default options for the plugin.
259
  public function Default_Options() {
260
  $options = array();
261
-
262
  // Get the robots list, we'll use this for both upgrades and new installs.
263
  include_once( $this->plugin_dir . '/robotslist.php' );
264
 
265
  $options['robotlist'] = trim( $wps_robotslist );
266
 
267
  // By default, on new installs, use the new search table.
268
- $options['search_converted'] = 1;
269
 
270
  // If this is a first time install or an upgrade and we've added options, set some intelligent defaults.
271
- $options['geoip'] = FALSE;
272
- $options['browscap'] = FALSE;
273
- $options['useronline'] = TRUE;
274
- $options['visits'] = TRUE;
275
- $options['visitors'] = TRUE;
276
- $options['pages'] = TRUE;
277
- $options['check_online'] = '30';
278
- $options['menu_bar'] = FALSE;
279
- $options['coefficient'] = '1';
280
- $options['stats_report'] = FALSE;
281
- $options['time_report'] = 'daily';
282
- $options['send_report'] = 'mail';
283
- $options['content_report'] = '';
284
- $options['update_geoip'] = TRUE;
285
- $options['store_ua'] = FALSE;
286
- $options['robotlist'] = $wps_robotslist;
287
- $options['exclude_administrator'] = TRUE;
288
- $options['disable_se_clearch'] = TRUE;
289
- $options['disable_se_ask'] = TRUE;
290
- $options['map_type'] = 'jqvmap';
291
-
292
- $options['force_robot_update'] = TRUE;
293
-
294
  return $options;
295
  }
296
-
297
  // This function processes a string that represents an IP address and returns either FALSE if it's invalid or a valid IP4 address.
298
  private function get_ip_value( $ip ) {
299
  // Reject anything that's not a string.
300
- if( ! is_string( $ip ) ) {
301
  return false;
302
  }
303
 
@@ -305,29 +330,29 @@ class WP_Statistics {
305
  $ip = trim( $ip );
306
 
307
  // Process IPv4 and v6 addresses separately.
308
- if( $this->isValidIPv6( $ip ) ) {
309
  // Reject any IPv6 addresses if IPv6 is not compiled in to this version of PHP.
310
- if( ! defined( 'AF_INET6' ) ) {
311
  return false;
312
  }
313
  } else {
314
  // Trim off any port values that exist.
315
- if( strstr( $ip, ':' ) !== FALSE ) {
316
  $temp = explode( ':', $ip );
317
- $ip = $temp[0];
318
  }
319
 
320
  // Check to make sure the http header is actually an IP address and not some kind of SQL injection attack.
321
  $long = ip2long( $ip );
322
 
323
  // ip2long returns either -1 or FALSE if it is not a valid IP address depending on the PHP version, so check for both.
324
- if( $long == -1 || $long === FALSE ) {
325
  return false;
326
  }
327
  }
328
 
329
  // If the ip address is blank, reject it.
330
- if( $ip == '' ) {
331
  return false;
332
  }
333
 
@@ -340,18 +365,18 @@ class WP_Statistics {
340
  public function get_IP() {
341
 
342
  // Check to see if we've already retrieved the IP address and if so return the last result.
343
- if( $this->ip !== FALSE ) {
344
  return $this->ip;
345
  }
346
 
347
  // By default we use the remote address the server has.
348
- if( array_key_exists( 'REMOTE_ADDR', $_SERVER ) ) {
349
  $temp_ip = $this->get_ip_value( $_SERVER['REMOTE_ADDR'] );
350
  } else {
351
  $temp_ip = '127.0.0.1';
352
  }
353
 
354
- if( FALSE !== $temp_ip ) {
355
  $this->ip = $temp_ip;
356
  }
357
 
@@ -363,12 +388,18 @@ class WP_Statistics {
363
  * one.
364
  *
365
  */
366
- $envs = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED' );
367
-
368
- foreach( $envs as $env ) {
 
 
 
 
 
 
369
  $temp_ip = $this->get_ip_value( getenv( $env ) );
370
 
371
- if( FALSE !== $temp_ip ) {
372
  $this->ip = $temp_ip;
373
 
374
  break;
@@ -376,7 +407,7 @@ class WP_Statistics {
376
  }
377
 
378
  // If no valid ip address has been found, use 127.0.0.1 (aka localhost).
379
- if( FALSE === $this->ip ) {
380
  $this->ip = '127.0.0.1';
381
  }
382
 
@@ -387,38 +418,42 @@ class WP_Statistics {
387
  * Validate an IPv6 IP address
388
  *
389
  * @param string $ip
 
390
  * @return boolean - true/false
391
  */
392
  private function isValidIPv6( $ip ) {
393
- if( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
394
- return false;
395
- } else {
396
- return true;
397
- }
398
  }
399
 
400
  // This function calls the user agent parsing code.
401
  public function get_UserAgent() {
402
 
403
  // Parse the agent stirng.
404
- try
405
- {
406
  $agent = parse_user_agent();
407
- }
408
- catch( Exception $e )
409
- {
410
  $agent = array( 'browser' => 'Unknown', 'platform' => 'Unknown', 'version' => 'Unknown' );
411
- }
412
 
413
  // null isn't a very good default, so set it to Unknown instead.
414
- if( $agent['browser'] == null ) { $agent['browser'] = "Unknown"; }
415
- if( $agent['platform'] == null ) { $agent['platform'] = "Unknown"; }
416
- if( $agent['version'] == null ) { $agent['version'] = "Unknown"; }
 
 
 
 
 
 
417
 
418
  // Uncommon browsers often have some extra cruft, like brackets, http:// and other strings that we can strip out.
419
- $strip_strings = array('"', "'", '(', ')', ';', ':', '/', '[', ']', '{', '}', 'http' );
420
- foreach( $agent as $key => $value ) {
421
- $agent[$key] = str_replace( $strip_strings, '', $agent[$key] );
422
  }
423
 
424
  return $agent;
@@ -427,30 +462,38 @@ class WP_Statistics {
427
  // This function will return the referrer link for the current user.
428
  public function get_Referred( $default_referrer = false ) {
429
 
430
- if( $this->referrer !== false ) { return $this->referrer; }
 
 
431
 
432
  $this->referrer = '';
433
 
434
- if( isset($_SERVER['HTTP_REFERER']) ) { $this->referrer = $_SERVER['HTTP_REFERER']; }
435
- if( $default_referrer ) { $this->referrer = $default_referrer; }
 
 
 
 
436
 
437
  $this->referrer = esc_sql( strip_tags( $this->referrer ) );
438
 
439
- if( !$this->referrer ) { $this->referrer = get_bloginfo('url'); }
 
 
440
 
441
- if( $this->get_option( 'addsearchwords', false ) ) {
442
  // Check to see if this is a search engine referrer
443
  $SEInfo = $this->Search_Engine_Info( $this->referrer );
444
 
445
- if( is_array( $SEInfo ) ) {
446
  // If we're a known SE, check the query string
447
- if( $SEInfo['tag'] != '' ) {
448
  $result = $this->Search_Engine_QueryString( $this->referrer );
449
 
450
  // If there were no search words, let's add the page title
451
- if( $result == '' || $result == 'No search query found!' ) {
452
- $result = wp_title('', false);
453
- if( $result != '' ) {
454
  $this->referrer = esc_url( add_query_arg( $SEInfo['querykey'], urlencode( '~"' . $result . '"' ), $this->referrer ) );
455
  }
456
  }
@@ -469,26 +512,24 @@ class WP_Statistics {
469
  // This function returns a date string in the desired format.
470
  public function Current_Date( $format = 'Y-m-d H:i:s', $strtotime = null, $relative = null ) {
471
 
472
- if( $strtotime ) {
473
- if( $relative ) {
474
- return date($format, strtotime("{$strtotime} day", $relative) + $this->tz_offset );
475
- }
476
- else {
477
- return date($format, strtotime("{$strtotime} day") + $this->tz_offset );
478
  }
479
  } else {
480
- return date($format, time() + $this->tz_offset);
481
  }
482
  }
483
 
484
  // This function returns a date string in the desired format.
485
  public function Real_Current_Date( $format = 'Y-m-d H:i:s', $strtotime = null, $relative = null ) {
486
 
487
- if( $strtotime ) {
488
- if( $relative ) {
489
  return date( $format, strtotime( "{$strtotime} day", $relative ) );
490
- }
491
- else {
492
  return date( $format, strtotime( "{$strtotime} day" ) );
493
  }
494
  } else {
@@ -497,9 +538,9 @@ class WP_Statistics {
497
  }
498
 
499
  // This function returns an internationalized date string in the desired format.
500
- public function Current_Date_i18n( $format = 'Y-m-d H:i:s', $strtotime = null, $day=' day' ) {
501
 
502
- if( $strtotime ) {
503
  return date_i18n( $format, strtotime( "{$strtotime}{$day}" ) + $this->tz_offset );
504
  } else {
505
  return date_i18n( $format, time() + $this->tz_offset );
@@ -517,7 +558,7 @@ class WP_Statistics {
517
  // This function checks to see if a search engine exists in the current list of search engines.
518
  public function Check_Search_Engines( $search_engine_name, $search_engine = null ) {
519
 
520
- if( strstr( $search_engine, $search_engine_name ) ) {
521
  return 1;
522
  }
523
  }
@@ -527,36 +568,42 @@ class WP_Statistics {
527
  public function Search_Engine_Info( $url = false ) {
528
 
529
  // If no URL was passed in, get the current referrer for the session.
530
- if(!$url) {
531
- $url = isset($_SERVER['HTTP_REFERER']) ? $this->get_Referred() : false;
532
  }
533
 
534
  // If there is no URL and no referrer, always return false.
535
- if($url == false) {
536
  return false;
537
  }
538
 
539
  // Parse the URL in to it's component parts.
540
- $parts = parse_url($url);
541
 
542
  // Get the list of search engines we currently support.
543
  $search_engines = wp_statistics_searchengine_list();
544
 
545
  // Loop through the SE list until we find which search engine matches.
546
- foreach( $search_engines as $key => $value ) {
547
- $search_regex = wp_statistics_searchengine_regex($key);
548
 
549
- preg_match( '/' . $search_regex . '/', $parts['host'], $matches);
550
 
551
- if( isset($matches[1]) )
552
- {
553
  // Return the first matched SE.
554
  return $value;
555
- }
556
  }
557
 
558
  // If no SE matched, return some defaults.
559
- return array('name' => 'Unknown', 'tag' => '', 'sqlpattern' => '', 'regexpattern' => '', 'querykey' => 'q', 'image' => 'unknown.png' );
 
 
 
 
 
 
 
560
  }
561
 
562
  // This function returns an array of information about a given search engine based on the url passed in.
@@ -564,31 +611,38 @@ class WP_Statistics {
564
  public function Search_Engine_Info_By_Engine( $engine = false ) {
565
 
566
  // If there is no URL and no referrer, always return false.
567
- if($engine == false) {
568
  return false;
569
  }
570
 
571
  // Get the list of search engines we currently support.
572
  $search_engines = wp_statistics_searchengine_list();
573
 
574
- if( array_key_exists( $engine, $search_engines ) ) {
575
- return $search_engines[$engine];
576
  }
577
 
578
  // If no SE matched, return some defaults.
579
- return array('name' => 'Unknown', 'tag' => '', 'sqlpattern' => '', 'regexpattern' => '', 'querykey' => 'q', 'image' => 'unknown.png' );
 
 
 
 
 
 
 
580
  }
581
 
582
  // This function will parse a URL from a referrer and return the search query words used.
583
  public function Search_Engine_QueryString( $url = false ) {
584
 
585
  // If no URL was passed in, get the current referrer for the session.
586
- if(!$url) {
587
  $url = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : false;
588
  }
589
 
590
  // If there is no URL and no referrer, always return false.
591
- if($url == false) {
592
  return false;
593
  }
594
 
@@ -597,31 +651,36 @@ class WP_Statistics {
597
 
598
  // Check to see if there is a query component in the URL (everything after the ?). If there isn't one
599
  // set an empty array so we don't get errors later.
600
- if( array_key_exists( 'query', $parts ) ) { parse_str( $parts['query'], $query ); } else { $query = array(); }
 
 
 
 
601
 
602
  // Get the list of search engines we currently support.
603
  $search_engines = wp_statistics_searchengine_list();
604
 
605
  // Loop through the SE list until we find which search engine matches.
606
- foreach( $search_engines as $key => $value ) {
607
  $search_regex = wp_statistics_searchengine_regex( $key );
608
 
609
  preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
610
 
611
- if( isset($matches[1]) )
612
- {
613
  // Check to see if the query key the SE uses exists in the query part of the URL.
614
- if( array_key_exists( $search_engines[$key]['querykey'], $query ) ) {
615
- $words = strip_tags( $query[$search_engines[$key]['querykey']] );
616
- }
617
- else {
618
  $words = '';
619
  }
620
 
621
  // If no words were found, return a pleasant default.
622
- if( $words == '' ) { $words = 'No search query found!'; }
623
- return $words;
624
  }
 
 
 
625
  }
626
 
627
  // We should never actually get to this point, but let's make sure we return something
@@ -633,52 +692,56 @@ class WP_Statistics {
633
 
634
  $count = 0;
635
 
636
- switch( $type ) {
637
  case 'visitors':
638
- if( array_key_exists( 'visitors', $this->historical ) ) {
639
  return $this->historical['visitors'];
640
- }
641
- else {
642
  $result = $this->db->get_var( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'visitors'" );
643
- if( $result > $count ) { $count = $result; }
 
 
644
  $this->historical['visitors'] = $count;
645
  }
646
 
647
  break;
648
  case 'visits':
649
- if( array_key_exists( 'visits', $this->historical ) ) {
650
  return $this->historical['visits'];
651
- }
652
- else {
653
  $result = $this->db->get_var( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'visits'" );
654
- if( $result > $count ) { $count = $result; }
 
 
655
  $this->historical['visits'] = $count;
656
  }
657
 
658
  break;
659
  case 'uri':
660
- if( array_key_exists( $id, $this->historical ) ) {
661
- return $this->historical[$id];
662
- }
663
- else {
664
  $result = $this->db->get_var( $this->db->prepare( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'uri' AND uri = %s", $id ) );
665
- if( $result > $count ) { $count = $result; }
666
- $this->historical[$id] = $count;
 
 
667
  }
668
 
669
  break;
670
  case 'page':
671
- if( array_key_exists( $id, $this->historical ) ) {
672
- return $this->historical[$id];
673
- }
674
- else {
675
  $result = $this->db->get_var( $this->db->prepare( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'uri' AND page_id = %d", $id ) );
676
- if( $result > $count ) { $count = $result; }
677
- $this->historical[$id] = $count;
 
 
678
  }
679
 
680
  break;
681
- }
682
 
683
  return $count;
684
  }
@@ -692,68 +755,68 @@ class WP_Statistics {
692
  }
693
 
694
  public function get_country_codes() {
695
- if( $this->country_codes == false ) {
696
  $ISOCountryCode = array();
697
- include( $this->plugin_dir . "/includes/functions/country-codes.php");
698
  $this->country_codes = $ISOCountryCode;
699
  }
700
 
701
  return $this->country_codes;
702
  }
703
-
704
  // Returns an array of site id's
705
  public function get_wp_sites_list() {
706
  GLOBAL $wp_version;
707
-
708
  $site_list = array();
709
-
710
  // wp_get_sites() is deprecated in 4.6 or above and replaced with get_sites().
711
- if( version_compare( $wp_version, '4.6', '>=' ) ) {
712
  $sites = get_sites();
713
-
714
- foreach( $sites as $site ) {
715
  $site_list[] = $site->blog_id;
716
  }
717
  } else {
718
  $sites = wp_get_sites();
719
 
720
- foreach( $sites as $site ) {
721
  $site_list[] = $site['blog_id'];
722
  }
723
  }
724
-
725
  return $site_list;
726
  }
727
-
728
- public function html_sanitize_referrer( $referrer, $length = -1 ) {
729
  $referrer = trim( $referrer );
730
-
731
- if( 'data:' == strtolower( substr( $referrer, 0, 5 ) ) ) {
732
  $referrer = 'http://127.0.0.1';
733
  }
734
-
735
- if( 'javascript:' == strtolower( substr( $referrer, 0, 11 ) ) ) {
736
  $referrer = 'http://127.0.0.1';
737
  }
738
 
739
- if( $length > 0 ) {
740
  $referrer = substr( $referrer, 0, $length );
741
  }
742
-
743
  return htmlentities( $referrer, ENT_QUOTES );
744
  }
745
-
746
- public function get_referrer_link( $referrer, $length = -1 ) {
747
  $html_referrer = $this->html_sanitize_referrer( $referrer );
748
-
749
- if( $length > 0 && strlen( $referrer ) > $length ) {
750
  $html_referrer_limited = $this->html_sanitize_referrer( $item->referred, $length );
751
- $eplises = '[...]';
752
  } else {
753
  $html_referrer_limited = $html_referrer;
754
- $eplises = '';
755
- }
756
-
757
- return "<a href='{$html_referrer}'><div class='dashicons dashicons-admin-links'></div>{$html_referrer_limited}{$eplises}</a></div>";
758
  }
759
  }
1
  <?php
2
+
3
  /*
4
  This is the primary class for WP Statistics recording hits on the WordPress site. It is extended by the Hits class and the GeoIPHits class.
5
 
36
 
37
  global $wpdb;
38
 
39
+ if ( get_option( 'timezone_string' ) ) {
40
  $this->tz_offset = timezone_offset_get( timezone_open( get_option( 'timezone_string' ) ), new DateTime() );
41
+ } else if ( get_option( 'gmt_offset' ) ) {
42
  $this->tz_offset = get_option( 'gmt_offset' ) * 60 * 60;
43
  }
44
 
45
+ $this->db = $wpdb;
46
+ $this->tb_prefix = $wpdb->prefix;
47
+ $this->agent = $this->get_UserAgent();
48
  $this->historical = array();
49
 
50
  // Load the options from the database
51
  $this->options = get_option( 'wp_statistics' );
52
 
53
+ if ( ! is_array( $this->options ) ) {
54
  $this->user_options = array();
55
  }
56
 
58
  $this->coefficient = $this->get_option( 'coefficient', 1 );
59
 
60
  // Double check the co-efficient setting to make sure it's not been set to 0.
61
+ if ( $this->coefficient <= 0 ) {
62
+ $this->coefficient = 1;
63
+ }
64
 
65
  // This is a bit of a hack, we strip off the "includes/classes" at the end of the current class file's path.
66
+ $this->plugin_dir = substr( dirname( __FILE__ ), 0, - 17 );
67
+ $this->plugin_url = substr( plugin_dir_url( __FILE__ ), 0, - 17 );
68
 
69
  $this->get_IP();
70
 
71
+ if ( $this->get_option( 'hash_ips' ) == true ) {
72
+ $this->ip_hash = '#hash#' . sha1( $this->ip . $_SERVER['HTTP_USER_AGENT'] );
73
+ }
74
 
75
  }
76
 
77
  // This function sets the current WordPress user id for the class.
78
  public function set_user_id() {
79
+ if ( $this->user_id == 0 ) {
80
  $this->user_id = get_current_user_id();
81
  }
82
  }
85
  public function load_options() {
86
  $this->options = get_option( 'wp_statistics' );
87
 
88
+ if ( ! is_array( $this->options ) ) {
89
  $this->user_options = array();
90
  }
91
  }
92
 
93
  // This function loads the user options from WordPress. It is NOT called during the class constructor.
94
  public function load_user_options( $force = false ) {
95
+ if ( $this->user_options_loaded == true && $force != true ) {
96
+ return;
97
+ }
98
 
99
  $this->set_user_id();
100
 
101
  // Not sure why, but get_user_meta() is returning an array or array's unless $single is set to true.
102
  $this->user_options = get_user_meta( $this->user_id, 'wp_statistics', true );
103
 
104
+ if ( ! is_array( $this->user_options ) ) {
105
  $this->user_options = array();
106
  }
107
+
108
  $this->user_options_loaded = true;
109
  }
110
 
111
  // The function mimics WordPress's get_option() function but uses the array instead of individual options.
112
  public function get_option( $option, $default = null ) {
113
  // If no options array exists, return FALSE.
114
+ if ( ! is_array( $this->options ) ) {
115
+ return false;
116
+ }
117
 
118
  // if the option isn't set yet, return the $default if it exists, otherwise FALSE.
119
+ if ( ! array_key_exists( $option, $this->options ) ) {
120
+ if ( isset( $default ) ) {
121
  return $default;
122
  } else {
123
+ return false;
124
  }
125
  }
126
 
127
  // Return the option.
128
+ return $this->options[ $option ];
129
  }
130
 
131
  // This function mimics WordPress's get_user_meta() function but uses the array instead of individual options.
132
  public function get_user_option( $option, $default = null ) {
133
  // If the user id has not been set or no options array exists, return FALSE.
134
+ if ( $this->user_id == 0 ) {
135
+ return false;
136
+ }
137
+ if ( ! is_array( $this->user_options ) ) {
138
+ return false;
139
+ }
140
 
141
  // if the option isn't set yet, return the $default if it exists, otherwise FALSE.
142
+ if ( ! array_key_exists( $option, $this->user_options ) ) {
143
+ if ( isset( $default ) ) {
144
  return $default;
145
  } else {
146
+ return false;
147
  }
148
  }
149
 
150
  // Return the option.
151
+ return $this->user_options[ $option ];
152
  }
153
 
154
  // The function mimics WordPress's update_option() function but uses the array instead of individual options.
155
  public function update_option( $option, $value ) {
156
  // Store the value in the array.
157
+ $this->options[ $option ] = $value;
158
 
159
  // Write the array to the database.
160
  update_option( 'wp_statistics', $this->options );
163
  // The function mimics WordPress's update_user_meta() function but uses the array instead of individual options.
164
  public function update_user_option( $option, $value ) {
165
  // If the user id has not been set return FALSE.
166
+ if ( $this->user_id == 0 ) {
167
+ return false;
168
+ }
169
 
170
  // Store the value in the array.
171
+ $this->user_options[ $option ] = $value;
172
 
173
  // Write the array to the database.
174
  update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
176
 
177
  // This function is similar to update_option, but it only stores the option in the array. This save some writing to the database if you have multiple values to update.
178
  public function store_option( $option, $value ) {
179
+ $this->options[ $option ] = $value;
180
  }
181
 
182
  // This function is similar to update_user_option, but it only stores the option in the array. This save some writing to the database if you have multiple values to update.
183
  public function store_user_option( $option, $value ) {
184
  // If the user id has not been set return FALSE.
185
+ if ( $this->user_id == 0 ) {
186
+ return false;
187
+ }
188
 
189
+ $this->user_options[ $option ] = $value;
190
  }
191
 
192
  // This function saves the current options array to the database.
193
  public function save_options() {
194
  update_option( 'wp_statistics', $this->options );
195
+ }
196
 
197
  // This function saves the current user options array to the database.
198
  public function save_user_options() {
199
+ if ( $this->user_id == 0 ) {
200
+ return false;
201
+ }
202
 
203
  update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
204
  }
205
 
206
  // This function check to see if an option is currently set or not.
207
  public function isset_option( $option ) {
208
+ if ( ! is_array( $this->options ) ) {
209
+ return false;
210
+ }
211
 
212
  return array_key_exists( $option, $this->options );
213
  }
214
 
215
  // This function check to see if a user option is currently set or not.
216
  public function isset_user_option( $option ) {
217
+ if ( $this->user_id == 0 ) {
218
+ return false;
219
+ }
220
+ if ( ! is_array( $this->user_options ) ) {
221
+ return false;
222
+ }
223
 
224
  return array_key_exists( $option, $this->user_options );
225
  }
228
  // This function will add some initial data if the tables are empty.
229
  public function Primary_Values() {
230
 
231
+ $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_useronline" );
232
 
233
+ if ( ! $this->result ) {
234
 
235
  $this->db->insert(
236
  $this->tb_prefix . "statistics_useronline",
237
  array(
238
+ 'ip' => $this->get_IP(),
239
+ 'timestamp' => $this->Current_Date( 'U' ),
240
+ 'date' => $this->Current_Date(),
241
+ 'referred' => $this->get_Referred(),
242
+ 'agent' => $this->agent['browser'],
243
+ 'platform' => $this->agent['platform'],
244
+ 'version' => $this->agent['version']
245
  )
246
  );
247
  }
248
 
249
+ $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_visit" );
250
 
251
+ if ( ! $this->result ) {
252
 
253
  $this->db->insert(
254
  $this->tb_prefix . "statistics_visit",
255
  array(
256
+ 'last_visit' => $this->Current_Date(),
257
+ 'last_counter' => $this->Current_date( 'Y-m-d' ),
258
+ 'visit' => 1
259
  )
260
  );
261
  }
262
 
263
+ $this->result = $this->db->query( "SELECT * FROM {$this->tb_prefix}statistics_visitor" );
264
 
265
+ if ( ! $this->result ) {
266
 
267
  $this->db->insert(
268
  $this->tb_prefix . "statistics_visitor",
269
  array(
270
+ 'last_counter' => $this->Current_date( 'Y-m-d' ),
271
+ 'referred' => $this->get_Referred(),
272
+ 'agent' => $this->agent['browser'],
273
+ 'platform' => $this->agent['platform'],
274
+ 'version' => $this->agent['version'],
275
+ 'ip' => $this->get_IP(),
276
+ 'location' => '000'
277
  )
278
  );
279
  }
283
  // This function will save a set of default options for the plugin.
284
  public function Default_Options() {
285
  $options = array();
286
+
287
  // Get the robots list, we'll use this for both upgrades and new installs.
288
  include_once( $this->plugin_dir . '/robotslist.php' );
289
 
290
  $options['robotlist'] = trim( $wps_robotslist );
291
 
292
  // By default, on new installs, use the new search table.
293
+ $options['search_converted'] = 1;
294
 
295
  // If this is a first time install or an upgrade and we've added options, set some intelligent defaults.
296
+ $options['geoip'] = false;
297
+ $options['browscap'] = false;
298
+ $options['useronline'] = true;
299
+ $options['visits'] = true;
300
+ $options['visitors'] = true;
301
+ $options['pages'] = true;
302
+ $options['check_online'] = '30';
303
+ $options['menu_bar'] = false;
304
+ $options['coefficient'] = '1';
305
+ $options['stats_report'] = false;
306
+ $options['time_report'] = 'daily';
307
+ $options['send_report'] = 'mail';
308
+ $options['content_report'] = '';
309
+ $options['update_geoip'] = true;
310
+ $options['store_ua'] = false;
311
+ $options['robotlist'] = $wps_robotslist;
312
+ $options['exclude_administrator'] = true;
313
+ $options['disable_se_clearch'] = true;
314
+ $options['disable_se_ask'] = true;
315
+ $options['map_type'] = 'jqvmap';
316
+
317
+ $options['force_robot_update'] = true;
318
+
319
  return $options;
320
  }
321
+
322
  // This function processes a string that represents an IP address and returns either FALSE if it's invalid or a valid IP4 address.
323
  private function get_ip_value( $ip ) {
324
  // Reject anything that's not a string.
325
+ if ( ! is_string( $ip ) ) {
326
  return false;
327
  }
328
 
330
  $ip = trim( $ip );
331
 
332
  // Process IPv4 and v6 addresses separately.
333
+ if ( $this->isValidIPv6( $ip ) ) {
334
  // Reject any IPv6 addresses if IPv6 is not compiled in to this version of PHP.
335
+ if ( ! defined( 'AF_INET6' ) ) {
336
  return false;
337
  }
338
  } else {
339
  // Trim off any port values that exist.
340
+ if ( strstr( $ip, ':' ) !== false ) {
341
  $temp = explode( ':', $ip );
342
+ $ip = $temp[0];
343
  }
344
 
345
  // Check to make sure the http header is actually an IP address and not some kind of SQL injection attack.
346
  $long = ip2long( $ip );
347
 
348
  // ip2long returns either -1 or FALSE if it is not a valid IP address depending on the PHP version, so check for both.
349
+ if ( $long == - 1 || $long === false ) {
350
  return false;
351
  }
352
  }
353
 
354
  // If the ip address is blank, reject it.
355
+ if ( $ip == '' ) {
356
  return false;
357
  }
358
 
365
  public function get_IP() {
366
 
367
  // Check to see if we've already retrieved the IP address and if so return the last result.
368
+ if ( $this->ip !== false ) {
369
  return $this->ip;
370
  }
371
 
372
  // By default we use the remote address the server has.
373
+ if ( array_key_exists( 'REMOTE_ADDR', $_SERVER ) ) {
374
  $temp_ip = $this->get_ip_value( $_SERVER['REMOTE_ADDR'] );
375
  } else {
376
  $temp_ip = '127.0.0.1';
377
  }
378
 
379
+ if ( false !== $temp_ip ) {
380
  $this->ip = $temp_ip;
381
  }
382
 
388
  * one.
389
  *
390
  */
391
+ $envs = array(
392
+ 'HTTP_CLIENT_IP',
393
+ 'HTTP_X_FORWARDED_FOR',
394
+ 'HTTP_X_FORWARDED',
395
+ 'HTTP_FORWARDED_FOR',
396
+ 'HTTP_FORWARDED'
397
+ );
398
+
399
+ foreach ( $envs as $env ) {
400
  $temp_ip = $this->get_ip_value( getenv( $env ) );
401
 
402
+ if ( false !== $temp_ip ) {
403
  $this->ip = $temp_ip;
404
 
405
  break;
407
  }
408
 
409
  // If no valid ip address has been found, use 127.0.0.1 (aka localhost).
410
+ if ( false === $this->ip ) {
411
  $this->ip = '127.0.0.1';
412
  }
413
 
418
  * Validate an IPv6 IP address
419
  *
420
  * @param string $ip
421
+ *
422
  * @return boolean - true/false
423
  */
424
  private function isValidIPv6( $ip ) {
425
+ if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
426
+ return false;
427
+ } else {
428
+ return true;
429
+ }
430
  }
431
 
432
  // This function calls the user agent parsing code.
433
  public function get_UserAgent() {
434
 
435
  // Parse the agent stirng.
436
+ try {
 
437
  $agent = parse_user_agent();
438
+ } catch ( Exception $e ) {
 
 
439
  $agent = array( 'browser' => 'Unknown', 'platform' => 'Unknown', 'version' => 'Unknown' );
440
+ }
441
 
442
  // null isn't a very good default, so set it to Unknown instead.
443
+ if ( $agent['browser'] == null ) {
444
+ $agent['browser'] = "Unknown";
445
+ }
446
+ if ( $agent['platform'] == null ) {
447
+ $agent['platform'] = "Unknown";
448
+ }
449
+ if ( $agent['version'] == null ) {
450
+ $agent['version'] = "Unknown";
451
+ }
452
 
453
  // Uncommon browsers often have some extra cruft, like brackets, http:// and other strings that we can strip out.
454
+ $strip_strings = array( '"', "'", '(', ')', ';', ':', '/', '[', ']', '{', '}', 'http' );
455
+ foreach ( $agent as $key => $value ) {
456
+ $agent[ $key ] = str_replace( $strip_strings, '', $agent[ $key ] );
457
  }
458
 
459
  return $agent;
462
  // This function will return the referrer link for the current user.
463
  public function get_Referred( $default_referrer = false ) {
464
 
465
+ if ( $this->referrer !== false ) {
466
+ return $this->referrer;
467
+ }
468
 
469
  $this->referrer = '';
470
 
471
+ if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
472
+ $this->referrer = $_SERVER['HTTP_REFERER'];
473
+ }
474
+ if ( $default_referrer ) {
475
+ $this->referrer = $default_referrer;
476
+ }
477
 
478
  $this->referrer = esc_sql( strip_tags( $this->referrer ) );
479
 
480
+ if ( ! $this->referrer ) {
481
+ $this->referrer = get_bloginfo( 'url' );
482
+ }
483
 
484
+ if ( $this->get_option( 'addsearchwords', false ) ) {
485
  // Check to see if this is a search engine referrer
486
  $SEInfo = $this->Search_Engine_Info( $this->referrer );
487
 
488
+ if ( is_array( $SEInfo ) ) {
489
  // If we're a known SE, check the query string
490
+ if ( $SEInfo['tag'] != '' ) {
491
  $result = $this->Search_Engine_QueryString( $this->referrer );
492
 
493
  // If there were no search words, let's add the page title
494
+ if ( $result == '' || $result == 'No search query found!' ) {
495
+ $result = wp_title( '', false );
496
+ if ( $result != '' ) {
497
  $this->referrer = esc_url( add_query_arg( $SEInfo['querykey'], urlencode( '~"' . $result . '"' ), $this->referrer ) );
498
  }
499
  }
512
  // This function returns a date string in the desired format.
513
  public function Current_Date( $format = 'Y-m-d H:i:s', $strtotime = null, $relative = null ) {
514
 
515
+ if ( $strtotime ) {
516
+ if ( $relative ) {
517
+ return date( $format, strtotime( "{$strtotime} day", $relative ) + $this->tz_offset );
518
+ } else {
519
+ return date( $format, strtotime( "{$strtotime} day" ) + $this->tz_offset );
 
520
  }
521
  } else {
522
+ return date( $format, time() + $this->tz_offset );
523
  }
524
  }
525
 
526
  // This function returns a date string in the desired format.
527
  public function Real_Current_Date( $format = 'Y-m-d H:i:s', $strtotime = null, $relative = null ) {
528
 
529
+ if ( $strtotime ) {
530
+ if ( $relative ) {
531
  return date( $format, strtotime( "{$strtotime} day", $relative ) );
532
+ } else {
 
533
  return date( $format, strtotime( "{$strtotime} day" ) );
534
  }
535
  } else {
538
  }
539
 
540
  // This function returns an internationalized date string in the desired format.
541
+ public function Current_Date_i18n( $format = 'Y-m-d H:i:s', $strtotime = null, $day = ' day' ) {
542
 
543
+ if ( $strtotime ) {
544
  return date_i18n( $format, strtotime( "{$strtotime}{$day}" ) + $this->tz_offset );
545
  } else {
546
  return date_i18n( $format, time() + $this->tz_offset );
558
  // This function checks to see if a search engine exists in the current list of search engines.
559
  public function Check_Search_Engines( $search_engine_name, $search_engine = null ) {
560
 
561
+ if ( strstr( $search_engine, $search_engine_name ) ) {
562
  return 1;
563
  }
564
  }
568
  public function Search_Engine_Info( $url = false ) {
569
 
570
  // If no URL was passed in, get the current referrer for the session.
571
+ if ( ! $url ) {
572
+ $url = isset( $_SERVER['HTTP_REFERER'] ) ? $this->get_Referred() : false;
573
  }
574
 
575
  // If there is no URL and no referrer, always return false.
576
+ if ( $url == false ) {
577
  return false;
578
  }
579
 
580
  // Parse the URL in to it's component parts.
581
+ $parts = parse_url( $url );
582
 
583
  // Get the list of search engines we currently support.
584
  $search_engines = wp_statistics_searchengine_list();
585
 
586
  // Loop through the SE list until we find which search engine matches.
587
+ foreach ( $search_engines as $key => $value ) {
588
+ $search_regex = wp_statistics_searchengine_regex( $key );
589
 
590
+ preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
591
 
592
+ if ( isset( $matches[1] ) ) {
 
593
  // Return the first matched SE.
594
  return $value;
595
+ }
596
  }
597
 
598
  // If no SE matched, return some defaults.
599
+ return array(
600
+ 'name' => 'Unknown',
601
+ 'tag' => '',
602
+ 'sqlpattern' => '',
603
+ 'regexpattern' => '',
604
+ 'querykey' => 'q',
605
+ 'image' => 'unknown.png'
606
+ );
607
  }
608
 
609
  // This function returns an array of information about a given search engine based on the url passed in.
611
  public function Search_Engine_Info_By_Engine( $engine = false ) {
612
 
613
  // If there is no URL and no referrer, always return false.
614
+ if ( $engine == false ) {
615
  return false;
616
  }
617
 
618
  // Get the list of search engines we currently support.
619
  $search_engines = wp_statistics_searchengine_list();
620
 
621
+ if ( array_key_exists( $engine, $search_engines ) ) {
622
+ return $search_engines[ $engine ];
623
  }
624
 
625
  // If no SE matched, return some defaults.
626
+ return array(
627
+ 'name' => 'Unknown',
628
+ 'tag' => '',
629
+ 'sqlpattern' => '',
630
+ 'regexpattern' => '',
631
+ 'querykey' => 'q',
632
+ 'image' => 'unknown.png'
633
+ );
634
  }
635
 
636
  // This function will parse a URL from a referrer and return the search query words used.
637
  public function Search_Engine_QueryString( $url = false ) {
638
 
639
  // If no URL was passed in, get the current referrer for the session.
640
+ if ( ! $url ) {
641
  $url = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : false;
642
  }
643
 
644
  // If there is no URL and no referrer, always return false.
645
+ if ( $url == false ) {
646
  return false;
647
  }
648
 
651
 
652
  // Check to see if there is a query component in the URL (everything after the ?). If there isn't one
653
  // set an empty array so we don't get errors later.
654
+ if ( array_key_exists( 'query', $parts ) ) {
655
+ parse_str( $parts['query'], $query );
656
+ } else {
657
+ $query = array();
658
+ }
659
 
660
  // Get the list of search engines we currently support.
661
  $search_engines = wp_statistics_searchengine_list();
662
 
663
  // Loop through the SE list until we find which search engine matches.
664
+ foreach ( $search_engines as $key => $value ) {
665
  $search_regex = wp_statistics_searchengine_regex( $key );
666
 
667
  preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
668
 
669
+ if ( isset( $matches[1] ) ) {
 
670
  // Check to see if the query key the SE uses exists in the query part of the URL.
671
+ if ( array_key_exists( $search_engines[ $key ]['querykey'], $query ) ) {
672
+ $words = strip_tags( $query[ $search_engines[ $key ]['querykey'] ] );
673
+ } else {
 
674
  $words = '';
675
  }
676
 
677
  // If no words were found, return a pleasant default.
678
+ if ( $words == '' ) {
679
+ $words = 'No search query found!';
680
  }
681
+
682
+ return $words;
683
+ }
684
  }
685
 
686
  // We should never actually get to this point, but let's make sure we return something
692
 
693
  $count = 0;
694
 
695
+ switch ( $type ) {
696
  case 'visitors':
697
+ if ( array_key_exists( 'visitors', $this->historical ) ) {
698
  return $this->historical['visitors'];
699
+ } else {
 
700
  $result = $this->db->get_var( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'visitors'" );
701
+ if ( $result > $count ) {
702
+ $count = $result;
703
+ }
704
  $this->historical['visitors'] = $count;
705
  }
706
 
707
  break;
708
  case 'visits':
709
+ if ( array_key_exists( 'visits', $this->historical ) ) {
710
  return $this->historical['visits'];
711
+ } else {
 
712
  $result = $this->db->get_var( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'visits'" );
713
+ if ( $result > $count ) {
714
+ $count = $result;
715
+ }
716
  $this->historical['visits'] = $count;
717
  }
718
 
719
  break;
720
  case 'uri':
721
+ if ( array_key_exists( $id, $this->historical ) ) {
722
+ return $this->historical[ $id ];
723
+ } else {
 
724
  $result = $this->db->get_var( $this->db->prepare( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'uri' AND uri = %s", $id ) );
725
+ if ( $result > $count ) {
726
+ $count = $result;
727
+ }
728
+ $this->historical[ $id ] = $count;
729
  }
730
 
731
  break;
732
  case 'page':
733
+ if ( array_key_exists( $id, $this->historical ) ) {
734
+ return $this->historical[ $id ];
735
+ } else {
 
736
  $result = $this->db->get_var( $this->db->prepare( "SELECT value FROM {$this->tb_prefix}statistics_historical WHERE category = 'uri' AND page_id = %d", $id ) );
737
+ if ( $result > $count ) {
738
+ $count = $result;
739
+ }
740
+ $this->historical[ $id ] = $count;
741
  }
742
 
743
  break;
744
+ }
745
 
746
  return $count;
747
  }
755
  }
756
 
757
  public function get_country_codes() {
758
+ if ( $this->country_codes == false ) {
759
  $ISOCountryCode = array();
760
+ include( $this->plugin_dir . "/includes/functions/country-codes.php" );
761
  $this->country_codes = $ISOCountryCode;
762
  }
763
 
764
  return $this->country_codes;
765
  }
766
+
767
  // Returns an array of site id's
768
  public function get_wp_sites_list() {
769
  GLOBAL $wp_version;
770
+
771
  $site_list = array();
772
+
773
  // wp_get_sites() is deprecated in 4.6 or above and replaced with get_sites().
774
+ if ( version_compare( $wp_version, '4.6', '>=' ) ) {
775
  $sites = get_sites();
776
+
777
+ foreach ( $sites as $site ) {
778
  $site_list[] = $site->blog_id;
779
  }
780
  } else {
781
  $sites = wp_get_sites();
782
 
783
+ foreach ( $sites as $site ) {
784
  $site_list[] = $site['blog_id'];
785
  }
786
  }
787
+
788
  return $site_list;
789
  }
790
+
791
+ public function html_sanitize_referrer( $referrer, $length = - 1 ) {
792
  $referrer = trim( $referrer );
793
+
794
+ if ( 'data:' == strtolower( substr( $referrer, 0, 5 ) ) ) {
795
  $referrer = 'http://127.0.0.1';
796
  }
797
+
798
+ if ( 'javascript:' == strtolower( substr( $referrer, 0, 11 ) ) ) {
799
  $referrer = 'http://127.0.0.1';
800
  }
801
 
802
+ if ( $length > 0 ) {
803
  $referrer = substr( $referrer, 0, $length );
804
  }
805
+
806
  return htmlentities( $referrer, ENT_QUOTES );
807
  }
808
+
809
+ public function get_referrer_link( $referrer, $length = - 1 ) {
810
  $html_referrer = $this->html_sanitize_referrer( $referrer );
811
+
812
+ if ( $length > 0 && strlen( $referrer ) > $length ) {
813
  $html_referrer_limited = $this->html_sanitize_referrer( $item->referred, $length );
814
+ $eplises = '[...]';
815
  } else {
816
  $html_referrer_limited = $html_referrer;
817
+ $eplises = '';
818
+ }
819
+
820
+ return "<a href='http://{$html_referrer}'><div class='dashicons dashicons-admin-links'></div>{$html_referrer_limited}{$eplises}</a>";
821
  }
822
  }
includes/functions/country-codes.php CHANGED
@@ -5,283 +5,283 @@
5
  It is used in several places in the plugin and is therefore centralized here for ease of update.
6
  */
7
  $ISOCountryCode['000'] = "Unknown";
8
- $ISOCountryCode['AF'] = "Afghanistan";
9
- $ISOCountryCode['AX'] = "�land Islands";
10
- $ISOCountryCode['AL'] = "Albania";
11
- $ISOCountryCode['DZ'] = "Algeria";
12
- $ISOCountryCode['AS'] = "American Samoa";
13
- $ISOCountryCode['AD'] = "Andorra";
14
- $ISOCountryCode['AO'] = "Angola";
15
- $ISOCountryCode['AI'] = "Anguilla";
16
- $ISOCountryCode['AQ'] = "Antarctica";
17
- $ISOCountryCode['AG'] = "Antigua and Barbuda";
18
- $ISOCountryCode['AR'] = "Argentina";
19
- $ISOCountryCode['AM'] = "Armenia";
20
- $ISOCountryCode['AW'] = "Aruba";
21
- $ISOCountryCode['AU'] = "Australia";
22
- $ISOCountryCode['AT'] = "Austria";
23
- $ISOCountryCode['AZ'] = "Azerbaijan";
24
- $ISOCountryCode['BS'] = "Bahamas";
25
- $ISOCountryCode['BH'] = "Bahrain";
26
- $ISOCountryCode['BD'] = "Bangladesh";
27
- $ISOCountryCode['BB'] = "Barbados";
28
- $ISOCountryCode['BY'] = "Belarus";
29
- $ISOCountryCode['BE'] = "Belgium";
30
- $ISOCountryCode['BZ'] = "Belize";
31
- $ISOCountryCode['BJ'] = "Benin";
32
- $ISOCountryCode['BM'] = "Bermuda";
33
- $ISOCountryCode['BT'] = "Bhutan";
34
- $ISOCountryCode['BO'] = "Bolivia, Plurinational State of";
35
- $ISOCountryCode['BQ'] = "Bonaire, Sint Eustatius and Saba";
36
- $ISOCountryCode['BA'] = "Bosnia and Herzegovina";
37
- $ISOCountryCode['BW'] = "Botswana";
38
- $ISOCountryCode['BV'] = "Bouvet Island";
39
- $ISOCountryCode['BR'] = "Brazil";
40
- $ISOCountryCode['BQ'] = "British Antarctic Territory";
41
- $ISOCountryCode['IO'] = "British Indian Ocean Territory";
42
- $ISOCountryCode['BN'] = "Brunei Darussalam";
43
- $ISOCountryCode['BG'] = "Bulgaria";
44
- $ISOCountryCode['BF'] = "Burkina Faso";
45
- $ISOCountryCode['BU'] = "Burma";
46
- $ISOCountryCode['BI'] = "Burundi";
47
- $ISOCountryCode['BY'] = "Byelorussian SSR";
48
- $ISOCountryCode['KH'] = "Cambodia";
49
- $ISOCountryCode['CM'] = "Cameroon";
50
- $ISOCountryCode['CA'] = "Canada";
51
- $ISOCountryCode['CT'] = "Canton and Enderbury Islands";
52
- $ISOCountryCode['CV'] = "Cape Verde";
53
- $ISOCountryCode['KY'] = "Cayman Islands";
54
- $ISOCountryCode['CF'] = "Central African Republic";
55
- $ISOCountryCode['TD'] = "Chad";
56
- $ISOCountryCode['CL'] = "Chile";
57
- $ISOCountryCode['CN'] = "China";
58
- $ISOCountryCode['CX'] = "Christmas Island";
59
- $ISOCountryCode['CC'] = "Cocos (Keeling) Islands";
60
- $ISOCountryCode['CO'] = "Colombia";
61
- $ISOCountryCode['KM'] = "Comoros";
62
- $ISOCountryCode['CG'] = "Congo";
63
- $ISOCountryCode['CD'] = "Congo (the Democratic Republic of the)";
64
- $ISOCountryCode['CK'] = "Cook Islands";
65
- $ISOCountryCode['CR'] = "Costa Rica";
66
- $ISOCountryCode['CI'] = "C�te d'Ivoire";
67
- $ISOCountryCode['HR'] = "Croatia";
68
- $ISOCountryCode['CU'] = "Cuba";
69
- $ISOCountryCode['CW'] = "Cura�ao";
70
- $ISOCountryCode['CY'] = "Cyprus";
71
- $ISOCountryCode['CZ'] = "Czech Republic";
72
- $ISOCountryCode['CS'] = "Czechoslovakia";
73
- $ISOCountryCode['DY'] = "Dahomey";
74
- $ISOCountryCode['DK'] = "Denmark";
75
- $ISOCountryCode['DJ'] = "Djibouti";
76
- $ISOCountryCode['DM'] = "Dominica";
77
- $ISOCountryCode['DO'] = "Dominican Republic";
78
- $ISOCountryCode['NQ'] = "Dronning Maud Land";
79
- $ISOCountryCode['TP'] = "East Timor";
80
- $ISOCountryCode['EC'] = "Ecuador";
81
- $ISOCountryCode['EG'] = "Egypt";
82
- $ISOCountryCode['SV'] = "El Salvador";
83
- $ISOCountryCode['GQ'] = "Equatorial Guinea";
84
- $ISOCountryCode['ER'] = "Eritrea";
85
- $ISOCountryCode['EE'] = "Estonia";
86
- $ISOCountryCode['ET'] = "Ethiopia";
87
- $ISOCountryCode['FK'] = "Falkland Islands [Malvinas]";
88
- $ISOCountryCode['FO'] = "Faroe Islands";
89
- $ISOCountryCode['FJ'] = "Fiji";
90
- $ISOCountryCode['FI'] = "Finland";
91
- $ISOCountryCode['FR'] = "France";
92
- $ISOCountryCode['FX'] = "France, Metropolitan";
93
- $ISOCountryCode['AI'] = "French Afars and Issas";
94
- $ISOCountryCode['GF'] = "French Guiana";
95
- $ISOCountryCode['PF'] = "French Polynesia";
96
- $ISOCountryCode['FQ'] = "French Southern and Antarctic Territories";
97
- $ISOCountryCode['TF'] = "French Southern Territories";
98
- $ISOCountryCode['GA'] = "Gabon";
99
- $ISOCountryCode['GM'] = "Gambia";
100
- $ISOCountryCode['GE'] = "Georgia";
101
- $ISOCountryCode['DD'] = "German Democratic Republic";
102
- $ISOCountryCode['DE'] = "Germany";
103
- $ISOCountryCode['GH'] = "Ghana";
104
- $ISOCountryCode['GI'] = "Gibraltar";
105
- $ISOCountryCode['GR'] = "Greece";
106
- $ISOCountryCode['GL'] = "Greenland";
107
- $ISOCountryCode['GD'] = "Grenada";
108
- $ISOCountryCode['GP'] = "Guadeloupe";
109
- $ISOCountryCode['GU'] = "Guam";
110
- $ISOCountryCode['GT'] = "Guatemala";
111
- $ISOCountryCode['GG'] = "Guernsey";
112
- $ISOCountryCode['GN'] = "Guinea";
113
- $ISOCountryCode['GW'] = "Guinea-Bissau";
114
- $ISOCountryCode['GY'] = "Guyana";
115
- $ISOCountryCode['HT'] = "Haiti";
116
- $ISOCountryCode['HM'] = "Heard Island and McDonald Islands";
117
- $ISOCountryCode['VA'] = "Holy See [Vatican City State]";
118
- $ISOCountryCode['HN'] = "Honduras";
119
- $ISOCountryCode['HK'] = "Hong Kong";
120
- $ISOCountryCode['HU'] = "Hungary";
121
- $ISOCountryCode['IS'] = "Iceland";
122
- $ISOCountryCode['IN'] = "India";
123
- $ISOCountryCode['ID'] = "Indonesia";
124
- $ISOCountryCode['IR'] = "Iran (the Islamic Republic of)";
125
- $ISOCountryCode['IQ'] = "Iraq";
126
- $ISOCountryCode['IE'] = "Ireland";
127
- $ISOCountryCode['IM'] = "Isle of Man";
128
- $ISOCountryCode['IL'] = "Israel";
129
- $ISOCountryCode['IT'] = "Italy";
130
- $ISOCountryCode['JM'] = "Jamaica";
131
- $ISOCountryCode['JP'] = "Japan";
132
- $ISOCountryCode['JE'] = "Jersey";
133
- $ISOCountryCode['JT'] = "Johnston Island";
134
- $ISOCountryCode['JO'] = "Jordan";
135
- $ISOCountryCode['KZ'] = "Kazakhstan";
136
- $ISOCountryCode['KE'] = "Kenya";
137
- $ISOCountryCode['KI'] = "Kiribati";
138
- $ISOCountryCode['KP'] = "Korea (the Democratic People's Republic of)";
139
- $ISOCountryCode['KR'] = "Korea (the Republic of)";
140
- $ISOCountryCode['KW'] = "Kuwait";
141
- $ISOCountryCode['KG'] = "Kyrgyzstan";
142
- $ISOCountryCode['LA'] = "Lao People's Democratic Republic";
143
- $ISOCountryCode['LV'] = "Latvia";
144
- $ISOCountryCode['LB'] = "Lebanon";
145
- $ISOCountryCode['LS'] = "Lesotho";
146
- $ISOCountryCode['LR'] = "Liberia";
147
- $ISOCountryCode['LY'] = "Libya";
148
- $ISOCountryCode['LI'] = "Liechtenstein";
149
- $ISOCountryCode['LT'] = "Lithuania";
150
- $ISOCountryCode['LU'] = "Luxembourg";
151
- $ISOCountryCode['MO'] = "Macao";
152
- $ISOCountryCode['MK'] = "Macedonia (the former Yugoslav Republic of)";
153
- $ISOCountryCode['MG'] = "Madagascar";
154
- $ISOCountryCode['MW'] = "Malawi";
155
- $ISOCountryCode['MY'] = "Malaysia";
156
- $ISOCountryCode['MV'] = "Maldives";
157
- $ISOCountryCode['ML'] = "Mali";
158
- $ISOCountryCode['MT'] = "Malta";
159
- $ISOCountryCode['MH'] = "Marshall Islands";
160
- $ISOCountryCode['MQ'] = "Martinique";
161
- $ISOCountryCode['MR'] = "Mauritania";
162
- $ISOCountryCode['MU'] = "Mauritius";
163
- $ISOCountryCode['YT'] = "Mayotte";
164
- $ISOCountryCode['MX'] = "Mexico";
165
- $ISOCountryCode['FM'] = "Micronesia (the Federated States of)";
166
- $ISOCountryCode['MI'] = "Midway Islands";
167
- $ISOCountryCode['MD'] = "Moldova (the Republic of)";
168
- $ISOCountryCode['MC'] = "Monaco";
169
- $ISOCountryCode['MN'] = "Mongolia";
170
- $ISOCountryCode['ME'] = "Montenegro";
171
- $ISOCountryCode['MS'] = "Montserrat";
172
- $ISOCountryCode['MA'] = "Morocco";
173
- $ISOCountryCode['MZ'] = "Mozambique";
174
- $ISOCountryCode['MM'] = "Myanmar";
175
- $ISOCountryCode['NA'] = "Namibia";
176
- $ISOCountryCode['NR'] = "Nauru";
177
- $ISOCountryCode['NP'] = "Nepal";
178
- $ISOCountryCode['NL'] = "Netherlands";
179
- $ISOCountryCode['AN'] = "Netherlands Antilles";
180
- $ISOCountryCode['NT'] = "Neutral Zone";
181
- $ISOCountryCode['NC'] = "New Caledonia";
182
- $ISOCountryCode['NH'] = "New Hebrides";
183
- $ISOCountryCode['NZ'] = "New Zealand";
184
- $ISOCountryCode['NI'] = "Nicaragua";
185
- $ISOCountryCode['NE'] = "Niger";
186
- $ISOCountryCode['NG'] = "Nigeria";
187
- $ISOCountryCode['NU'] = "Niue";
188
- $ISOCountryCode['NF'] = "Norfolk Island";
189
- $ISOCountryCode['MP'] = "Northern Mariana Islands";
190
- $ISOCountryCode['NO'] = "Norway";
191
- $ISOCountryCode['OM'] = "Oman";
192
- $ISOCountryCode['PC'] = "Pacific Islands (Trust Territory)";
193
- $ISOCountryCode['PK'] = "Pakistan";
194
- $ISOCountryCode['PW'] = "Palau";
195
- $ISOCountryCode['PS'] = "Palestine, State of";
196
- $ISOCountryCode['PA'] = "Panama";
197
- $ISOCountryCode['PZ'] = "Panama Canal Zone";
198
- $ISOCountryCode['PG'] = "Papua New Guinea";
199
- $ISOCountryCode['PY'] = "Paraguay";
200
- $ISOCountryCode['PE'] = "Peru";
201
- $ISOCountryCode['PH'] = "Philippines";
202
- $ISOCountryCode['PN'] = "Pitcairn";
203
- $ISOCountryCode['PL'] = "Poland";
204
- $ISOCountryCode['PT'] = "Portugal";
205
- $ISOCountryCode['PR'] = "Puerto Rico";
206
- $ISOCountryCode['QA'] = "Qatar";
207
- $ISOCountryCode['RE'] = "R�union";
208
- $ISOCountryCode['RO'] = "Romania";
209
- $ISOCountryCode['RU'] = "Russian Federation";
210
- $ISOCountryCode['RW'] = "Rwanda";
211
- $ISOCountryCode['BL'] = "Saint Barth�lemy";
212
- $ISOCountryCode['SH'] = "Saint Helena, Ascension and Tristan da Cunha";
213
- $ISOCountryCode['KN'] = "Saint Kitts and Nevis";
214
- $ISOCountryCode['LC'] = "Saint Lucia";
215
- $ISOCountryCode['MF'] = "Saint Martin (French part)";
216
- $ISOCountryCode['PM'] = "Saint Pierre and Miquelon";
217
- $ISOCountryCode['VC'] = "Saint Vincent and the Grenadines";
218
- $ISOCountryCode['WS'] = "Samoa";
219
- $ISOCountryCode['SM'] = "San Marino";
220
- $ISOCountryCode['ST'] = "Sao Tome and Principe";
221
- $ISOCountryCode['SA'] = "Saudi Arabia";
222
- $ISOCountryCode['SN'] = "Senegal";
223
- $ISOCountryCode['RS'] = "Serbia";
224
- $ISOCountryCode['CS'] = "Serbia and Montenegro";
225
- $ISOCountryCode['SC'] = "Seychelles";
226
- $ISOCountryCode['SL'] = "Sierra Leone";
227
- $ISOCountryCode['SK'] = "Sikkim";
228
- $ISOCountryCode['SG'] = "Singapore";
229
- $ISOCountryCode['SX'] = "Sint Maarten (Dutch part)";
230
- $ISOCountryCode['SK'] = "Slovakia";
231
- $ISOCountryCode['SI'] = "Slovenia";
232
- $ISOCountryCode['SB'] = "Solomon Islands";
233
- $ISOCountryCode['SO'] = "Somalia";
234
- $ISOCountryCode['ZA'] = "South Africa";
235
- $ISOCountryCode['GS'] = "South Georgia and the South Sandwich Islands";
236
- $ISOCountryCode['SS'] = "South Sudan ";
237
- $ISOCountryCode['RH'] = "Southern Rhodesia";
238
- $ISOCountryCode['ES'] = "Spain";
239
- $ISOCountryCode['LK'] = "Sri Lanka";
240
- $ISOCountryCode['SD'] = "Sudan";
241
- $ISOCountryCode['SR'] = "Suriname";
242
- $ISOCountryCode['SJ'] = "Svalbard and Jan Mayen";
243
- $ISOCountryCode['SZ'] = "Swaziland";
244
- $ISOCountryCode['SE'] = "Sweden";
245
- $ISOCountryCode['CH'] = "Switzerland";
246
- $ISOCountryCode['SY'] = "Syrian Arab Republic";
247
- $ISOCountryCode['TW'] = "Taiwan (Province of China)";
248
- $ISOCountryCode['TJ'] = "Tajikistan";
249
- $ISOCountryCode['TZ'] = "Tanzania, United Republic of";
250
- $ISOCountryCode['TH'] = "Thailand";
251
- $ISOCountryCode['TL'] = "Timor-Leste";
252
- $ISOCountryCode['TG'] = "Togo";
253
- $ISOCountryCode['TK'] = "Tokelau";
254
- $ISOCountryCode['TO'] = "Tonga";
255
- $ISOCountryCode['TT'] = "Trinidad and Tobago";
256
- $ISOCountryCode['TN'] = "Tunisia";
257
- $ISOCountryCode['TR'] = "Turkey";
258
- $ISOCountryCode['TM'] = "Turkmenistan";
259
- $ISOCountryCode['TC'] = "Turks and Caicos Islands";
260
- $ISOCountryCode['TV'] = "Tuvalu";
261
- $ISOCountryCode['UG'] = "Uganda";
262
- $ISOCountryCode['UA'] = "Ukraine";
263
- $ISOCountryCode['AE'] = "United Arab Emirates";
264
- $ISOCountryCode['GB'] = "United Kingdom";
265
- $ISOCountryCode['US'] = "United States";
266
- $ISOCountryCode['UM'] = "United States Minor Outlying Islands";
267
- $ISOCountryCode['PU'] = "United States Miscellaneous Pacific Islands";
268
- $ISOCountryCode['HV'] = "Upper Volta";
269
- $ISOCountryCode['UY'] = "Uruguay";
270
- $ISOCountryCode['SU'] = "USSR";
271
- $ISOCountryCode['UZ'] = "Uzbekistan";
272
- $ISOCountryCode['VU'] = "Vanuatu";
273
- $ISOCountryCode['VE'] = "Venezuela, Bolivarian Republic of ";
274
- $ISOCountryCode['VN'] = "Viet Nam";
275
- $ISOCountryCode['VD'] = "Viet-Nam, Democratic Republic of";
276
- $ISOCountryCode['VG'] = "Virgin Islands (British)";
277
- $ISOCountryCode['VI'] = "Virgin Islands (U.S.)";
278
- $ISOCountryCode['WK'] = "Wake Island";
279
- $ISOCountryCode['WF'] = "Wallis and Futuna";
280
- $ISOCountryCode['EH'] = "Western Sahara";
281
- $ISOCountryCode['YE'] = "Yemen";
282
- $ISOCountryCode['YD'] = "Yemen, Democratic";
283
- $ISOCountryCode['YU'] = "Yugoslavia";
284
- $ISOCountryCode['ZR'] = "Zaire";
285
- $ISOCountryCode['ZM'] = "Zambia";
286
- $ISOCountryCode['ZW'] = "Zimbabwe";
287
  ?>
5
  It is used in several places in the plugin and is therefore centralized here for ease of update.
6
  */
7
  $ISOCountryCode['000'] = "Unknown";
8
+ $ISOCountryCode['AF'] = "Afghanistan";
9
+ $ISOCountryCode['AX'] = "�land Islands";
10
+ $ISOCountryCode['AL'] = "Albania";
11
+ $ISOCountryCode['DZ'] = "Algeria";
12
+ $ISOCountryCode['AS'] = "American Samoa";
13
+ $ISOCountryCode['AD'] = "Andorra";
14
+ $ISOCountryCode['AO'] = "Angola";
15
+ $ISOCountryCode['AI'] = "Anguilla";
16
+ $ISOCountryCode['AQ'] = "Antarctica";
17
+ $ISOCountryCode['AG'] = "Antigua and Barbuda";
18
+ $ISOCountryCode['AR'] = "Argentina";
19
+ $ISOCountryCode['AM'] = "Armenia";
20
+ $ISOCountryCode['AW'] = "Aruba";
21
+ $ISOCountryCode['AU'] = "Australia";
22
+ $ISOCountryCode['AT'] = "Austria";
23
+ $ISOCountryCode['AZ'] = "Azerbaijan";
24
+ $ISOCountryCode['BS'] = "Bahamas";
25
+ $ISOCountryCode['BH'] = "Bahrain";
26
+ $ISOCountryCode['BD'] = "Bangladesh";
27
+ $ISOCountryCode['BB'] = "Barbados";
28
+ $ISOCountryCode['BY'] = "Belarus";
29
+ $ISOCountryCode['BE'] = "Belgium";
30
+ $ISOCountryCode['BZ'] = "Belize";
31
+ $ISOCountryCode['BJ'] = "Benin";
32
+ $ISOCountryCode['BM'] = "Bermuda";
33
+ $ISOCountryCode['BT'] = "Bhutan";
34
+ $ISOCountryCode['BO'] = "Bolivia, Plurinational State of";
35
+ $ISOCountryCode['BQ'] = "Bonaire, Sint Eustatius and Saba";
36
+ $ISOCountryCode['BA'] = "Bosnia and Herzegovina";
37
+ $ISOCountryCode['BW'] = "Botswana";
38
+ $ISOCountryCode['BV'] = "Bouvet Island";
39
+ $ISOCountryCode['BR'] = "Brazil";
40
+ $ISOCountryCode['BQ'] = "British Antarctic Territory";
41
+ $ISOCountryCode['IO'] = "British Indian Ocean Territory";
42
+ $ISOCountryCode['BN'] = "Brunei Darussalam";
43
+ $ISOCountryCode['BG'] = "Bulgaria";
44
+ $ISOCountryCode['BF'] = "Burkina Faso";
45
+ $ISOCountryCode['BU'] = "Burma";
46
+ $ISOCountryCode['BI'] = "Burundi";
47
+ $ISOCountryCode['BY'] = "Byelorussian SSR";
48
+ $ISOCountryCode['KH'] = "Cambodia";
49
+ $ISOCountryCode['CM'] = "Cameroon";
50
+ $ISOCountryCode['CA'] = "Canada";
51
+ $ISOCountryCode['CT'] = "Canton and Enderbury Islands";
52
+ $ISOCountryCode['CV'] = "Cape Verde";
53
+ $ISOCountryCode['KY'] = "Cayman Islands";
54
+ $ISOCountryCode['CF'] = "Central African Republic";
55
+ $ISOCountryCode['TD'] = "Chad";
56
+ $ISOCountryCode['CL'] = "Chile";
57
+ $ISOCountryCode['CN'] = "China";
58
+ $ISOCountryCode['CX'] = "Christmas Island";
59
+ $ISOCountryCode['CC'] = "Cocos (Keeling) Islands";
60
+ $ISOCountryCode['CO'] = "Colombia";
61
+ $ISOCountryCode['KM'] = "Comoros";
62
+ $ISOCountryCode['CG'] = "Congo";
63
+ $ISOCountryCode['CD'] = "Congo (the Democratic Republic of the)";
64
+ $ISOCountryCode['CK'] = "Cook Islands";
65
+ $ISOCountryCode['CR'] = "Costa Rica";
66
+ $ISOCountryCode['CI'] = "C�te d'Ivoire";
67
+ $ISOCountryCode['HR'] = "Croatia";
68
+ $ISOCountryCode['CU'] = "Cuba";
69
+ $ISOCountryCode['CW'] = "Cura�ao";
70
+ $ISOCountryCode['CY'] = "Cyprus";
71
+ $ISOCountryCode['CZ'] = "Czech Republic";
72
+ $ISOCountryCode['CS'] = "Czechoslovakia";
73
+ $ISOCountryCode['DY'] = "Dahomey";
74
+ $ISOCountryCode['DK'] = "Denmark";
75
+ $ISOCountryCode['DJ'] = "Djibouti";
76
+ $ISOCountryCode['DM'] = "Dominica";
77
+ $ISOCountryCode['DO'] = "Dominican Republic";
78
+ $ISOCountryCode['NQ'] = "Dronning Maud Land";
79
+ $ISOCountryCode['TP'] = "East Timor";
80
+ $ISOCountryCode['EC'] = "Ecuador";
81
+ $ISOCountryCode['EG'] = "Egypt";
82
+ $ISOCountryCode['SV'] = "El Salvador";
83
+ $ISOCountryCode['GQ'] = "Equatorial Guinea";
84
+ $ISOCountryCode['ER'] = "Eritrea";
85
+ $ISOCountryCode['EE'] = "Estonia";
86
+ $ISOCountryCode['ET'] = "Ethiopia";
87
+ $ISOCountryCode['FK'] = "Falkland Islands [Malvinas]";
88
+ $ISOCountryCode['FO'] = "Faroe Islands";
89
+ $ISOCountryCode['FJ'] = "Fiji";
90
+ $ISOCountryCode['FI'] = "Finland";
91
+ $ISOCountryCode['FR'] = "France";
92
+ $ISOCountryCode['FX'] = "France, Metropolitan";
93
+ $ISOCountryCode['AI'] = "French Afars and Issas";
94
+ $ISOCountryCode['GF'] = "French Guiana";
95
+ $ISOCountryCode['PF'] = "French Polynesia";
96
+ $ISOCountryCode['FQ'] = "French Southern and Antarctic Territories";
97
+ $ISOCountryCode['TF'] = "French Southern Territories";
98
+ $ISOCountryCode['GA'] = "Gabon";
99
+ $ISOCountryCode['GM'] = "Gambia";
100
+ $ISOCountryCode['GE'] = "Georgia";
101
+ $ISOCountryCode['DD'] = "German Democratic Republic";
102
+ $ISOCountryCode['DE'] = "Germany";
103
+ $ISOCountryCode['GH'] = "Ghana";
104
+ $ISOCountryCode['GI'] = "Gibraltar";
105
+ $ISOCountryCode['GR'] = "Greece";
106
+ $ISOCountryCode['GL'] = "Greenland";
107
+ $ISOCountryCode['GD'] = "Grenada";
108
+ $ISOCountryCode['GP'] = "Guadeloupe";
109
+ $ISOCountryCode['GU'] = "Guam";
110
+ $ISOCountryCode['GT'] = "Guatemala";
111
+ $ISOCountryCode['GG'] = "Guernsey";
112
+ $ISOCountryCode['GN'] = "Guinea";
113
+ $ISOCountryCode['GW'] = "Guinea-Bissau";
114
+ $ISOCountryCode['GY'] = "Guyana";
115
+ $ISOCountryCode['HT'] = "Haiti";
116
+ $ISOCountryCode['HM'] = "Heard Island and McDonald Islands";
117
+ $ISOCountryCode['VA'] = "Holy See [Vatican City State]";
118
+ $ISOCountryCode['HN'] = "Honduras";
119
+ $ISOCountryCode['HK'] = "Hong Kong";
120
+ $ISOCountryCode['HU'] = "Hungary";
121
+ $ISOCountryCode['IS'] = "Iceland";
122
+ $ISOCountryCode['IN'] = "India";
123
+ $ISOCountryCode['ID'] = "Indonesia";
124
+ $ISOCountryCode['IR'] = "Iran (the Islamic Republic of)";
125
+ $ISOCountryCode['IQ'] = "Iraq";
126
+ $ISOCountryCode['IE'] = "Ireland";
127
+ $ISOCountryCode['IM'] = "Isle of Man";
128
+ $ISOCountryCode['IL'] = "Israel";
129
+ $ISOCountryCode['IT'] = "Italy";
130
+ $ISOCountryCode['JM'] = "Jamaica";
131
+ $ISOCountryCode['JP'] = "Japan";
132
+ $ISOCountryCode['JE'] = "Jersey";
133
+ $ISOCountryCode['JT'] = "Johnston Island";
134
+ $ISOCountryCode['JO'] = "Jordan";
135
+ $ISOCountryCode['KZ'] = "Kazakhstan";
136
+ $ISOCountryCode['KE'] = "Kenya";
137
+ $ISOCountryCode['KI'] = "Kiribati";
138
+ $ISOCountryCode['KP'] = "Korea (the Democratic People's Republic of)";
139
+ $ISOCountryCode['KR'] = "Korea (the Republic of)";
140
+ $ISOCountryCode['KW'] = "Kuwait";
141
+ $ISOCountryCode['KG'] = "Kyrgyzstan";
142
+ $ISOCountryCode['LA'] = "Lao People's Democratic Republic";
143
+ $ISOCountryCode['LV'] = "Latvia";
144
+ $ISOCountryCode['LB'] = "Lebanon";
145
+ $ISOCountryCode['LS'] = "Lesotho";
146
+ $ISOCountryCode['LR'] = "Liberia";
147
+ $ISOCountryCode['LY'] = "Libya";
148
+ $ISOCountryCode['LI'] = "Liechtenstein";
149
+ $ISOCountryCode['LT'] = "Lithuania";
150
+ $ISOCountryCode['LU'] = "Luxembourg";
151
+ $ISOCountryCode['MO'] = "Macao";
152
+ $ISOCountryCode['MK'] = "Macedonia (the former Yugoslav Republic of)";
153
+ $ISOCountryCode['MG'] = "Madagascar";
154
+ $ISOCountryCode['MW'] = "Malawi";
155
+ $ISOCountryCode['MY'] = "Malaysia";
156
+ $ISOCountryCode['MV'] = "Maldives";
157
+ $ISOCountryCode['ML'] = "Mali";
158
+ $ISOCountryCode['MT'] = "Malta";
159
+ $ISOCountryCode['MH'] = "Marshall Islands";
160
+ $ISOCountryCode['MQ'] = "Martinique";
161
+ $ISOCountryCode['MR'] = "Mauritania";
162
+ $ISOCountryCode['MU'] = "Mauritius";
163
+ $ISOCountryCode['YT'] = "Mayotte";
164
+ $ISOCountryCode['MX'] = "Mexico";
165
+ $ISOCountryCode['FM'] = "Micronesia (the Federated States of)";
166
+ $ISOCountryCode['MI'] = "Midway Islands";
167
+ $ISOCountryCode['MD'] = "Moldova (the Republic of)";
168
+ $ISOCountryCode['MC'] = "Monaco";
169
+ $ISOCountryCode['MN'] = "Mongolia";
170
+ $ISOCountryCode['ME'] = "Montenegro";
171
+ $ISOCountryCode['MS'] = "Montserrat";
172
+ $ISOCountryCode['MA'] = "Morocco";
173
+ $ISOCountryCode['MZ'] = "Mozambique";
174
+ $ISOCountryCode['MM'] = "Myanmar";
175
+ $ISOCountryCode['NA'] = "Namibia";
176
+ $ISOCountryCode['NR'] = "Nauru";
177
+ $ISOCountryCode['NP'] = "Nepal";
178
+ $ISOCountryCode['NL'] = "Netherlands";
179
+ $ISOCountryCode['AN'] = "Netherlands Antilles";
180
+ $ISOCountryCode['NT'] = "Neutral Zone";
181
+ $ISOCountryCode['NC'] = "New Caledonia";
182
+ $ISOCountryCode['NH'] = "New Hebrides";
183
+ $ISOCountryCode['NZ'] = "New Zealand";
184
+ $ISOCountryCode['NI'] = "Nicaragua";
185
+ $ISOCountryCode['NE'] = "Niger";
186
+ $ISOCountryCode['NG'] = "Nigeria";
187
+ $ISOCountryCode['NU'] = "Niue";
188
+ $ISOCountryCode['NF'] = "Norfolk Island";
189
+ $ISOCountryCode['MP'] = "Northern Mariana Islands";
190
+ $ISOCountryCode['NO'] = "Norway";
191
+ $ISOCountryCode['OM'] = "Oman";
192
+ $ISOCountryCode['PC'] = "Pacific Islands (Trust Territory)";
193
+ $ISOCountryCode['PK'] = "Pakistan";
194
+ $ISOCountryCode['PW'] = "Palau";
195
+ $ISOCountryCode['PS'] = "Palestine, State of";
196
+ $ISOCountryCode['PA'] = "Panama";
197
+ $ISOCountryCode['PZ'] = "Panama Canal Zone";
198
+ $ISOCountryCode['PG'] = "Papua New Guinea";
199
+ $ISOCountryCode['PY'] = "Paraguay";
200
+ $ISOCountryCode['PE'] = "Peru";
201
+ $ISOCountryCode['PH'] = "Philippines";
202
+ $ISOCountryCode['PN'] = "Pitcairn";
203
+ $ISOCountryCode['PL'] = "Poland";
204
+ $ISOCountryCode['PT'] = "Portugal";
205
+ $ISOCountryCode['PR'] = "Puerto Rico";
206
+ $ISOCountryCode['QA'] = "Qatar";
207
+ $ISOCountryCode['RE'] = "R�union";
208
+ $ISOCountryCode['RO'] = "Romania";
209
+ $ISOCountryCode['RU'] = "Russian Federation";
210
+ $ISOCountryCode['RW'] = "Rwanda";
211
+ $ISOCountryCode['BL'] = "Saint Barth�lemy";
212
+ $ISOCountryCode['SH'] = "Saint Helena, Ascension and Tristan da Cunha";
213
+ $ISOCountryCode['KN'] = "Saint Kitts and Nevis";
214
+ $ISOCountryCode['LC'] = "Saint Lucia";
215
+ $ISOCountryCode['MF'] = "Saint Martin (French part)";
216
+ $ISOCountryCode['PM'] = "Saint Pierre and Miquelon";
217
+ $ISOCountryCode['VC'] = "Saint Vincent and the Grenadines";
218
+ $ISOCountryCode['WS'] = "Samoa";
219
+ $ISOCountryCode['SM'] = "San Marino";
220
+ $ISOCountryCode['ST'] = "Sao Tome and Principe";
221
+ $ISOCountryCode['SA'] = "Saudi Arabia";
222
+ $ISOCountryCode['SN'] = "Senegal";
223
+ $ISOCountryCode['RS'] = "Serbia";
224
+ $ISOCountryCode['CS'] = "Serbia and Montenegro";
225
+ $ISOCountryCode['SC'] = "Seychelles";
226
+ $ISOCountryCode['SL'] = "Sierra Leone";
227
+ $ISOCountryCode['SK'] = "Sikkim";
228
+ $ISOCountryCode['SG'] = "Singapore";
229
+ $ISOCountryCode['SX'] = "Sint Maarten (Dutch part)";
230
+ $ISOCountryCode['SK'] = "Slovakia";
231
+ $ISOCountryCode['SI'] = "Slovenia";
232
+ $ISOCountryCode['SB'] = "Solomon Islands";
233
+ $ISOCountryCode['SO'] = "Somalia";
234
+ $ISOCountryCode['ZA'] = "South Africa";
235
+ $ISOCountryCode['GS'] = "South Georgia and the South Sandwich Islands";
236
+ $ISOCountryCode['SS'] = "South Sudan ";
237
+ $ISOCountryCode['RH'] = "Southern Rhodesia";
238
+ $ISOCountryCode['ES'] = "Spain";
239
+ $ISOCountryCode['LK'] = "Sri Lanka";
240
+ $ISOCountryCode['SD'] = "Sudan";
241
+ $ISOCountryCode['SR'] = "Suriname";
242
+ $ISOCountryCode['SJ'] = "Svalbard and Jan Mayen";
243
+ $ISOCountryCode['SZ'] = "Swaziland";
244
+ $ISOCountryCode['SE'] = "Sweden";
245
+ $ISOCountryCode['CH'] = "Switzerland";
246
+ $ISOCountryCode['SY'] = "Syrian Arab Republic";
247
+ $ISOCountryCode['TW'] = "Taiwan (Province of China)";
248
+ $ISOCountryCode['TJ'] = "Tajikistan";
249
+ $ISOCountryCode['TZ'] = "Tanzania, United Republic of";
250
+ $ISOCountryCode['TH'] = "Thailand";
251
+ $ISOCountryCode['TL'] = "Timor-Leste";
252
+ $ISOCountryCode['TG'] = "Togo";
253
+ $ISOCountryCode['TK'] = "Tokelau";
254
+ $ISOCountryCode['TO'] = "Tonga";
255
+ $ISOCountryCode['TT'] = "Trinidad and Tobago";
256
+ $ISOCountryCode['TN'] = "Tunisia";
257
+ $ISOCountryCode['TR'] = "Turkey";
258
+ $ISOCountryCode['TM'] = "Turkmenistan";
259
+ $ISOCountryCode['TC'] = "Turks and Caicos Islands";
260
+ $ISOCountryCode['TV'] = "Tuvalu";
261
+ $ISOCountryCode['UG'] = "Uganda";
262
+ $ISOCountryCode['UA'] = "Ukraine";
263
+ $ISOCountryCode['AE'] = "United Arab Emirates";
264
+ $ISOCountryCode['GB'] = "United Kingdom";
265
+ $ISOCountryCode['US'] = "United States";
266
+ $ISOCountryCode['UM'] = "United States Minor Outlying Islands";
267
+ $ISOCountryCode['PU'] = "United States Miscellaneous Pacific Islands";
268
+ $ISOCountryCode['HV'] = "Upper Volta";
269
+ $ISOCountryCode['UY'] = "Uruguay";
270
+ $ISOCountryCode['SU'] = "USSR";
271
+ $ISOCountryCode['UZ'] = "Uzbekistan";
272
+ $ISOCountryCode['VU'] = "Vanuatu";
273
+ $ISOCountryCode['VE'] = "Venezuela, Bolivarian Republic of ";
274
+ $ISOCountryCode['VN'] = "Viet Nam";
275
+ $ISOCountryCode['VD'] = "Viet-Nam, Democratic Republic of";
276
+ $ISOCountryCode['VG'] = "Virgin Islands (British)";
277
+ $ISOCountryCode['VI'] = "Virgin Islands (U.S.)";
278
+ $ISOCountryCode['WK'] = "Wake Island";
279
+ $ISOCountryCode['WF'] = "Wallis and Futuna";
280
+ $ISOCountryCode['EH'] = "Western Sahara";
281
+ $ISOCountryCode['YE'] = "Yemen";
282
+ $ISOCountryCode['YD'] = "Yemen, Democratic";
283
+ $ISOCountryCode['YU'] = "Yugoslavia";
284
+ $ISOCountryCode['ZR'] = "Zaire";
285
+ $ISOCountryCode['ZM'] = "Zambia";
286
+ $ISOCountryCode['ZW'] = "Zimbabwe";
287
  ?>
includes/functions/country-coordinates.php CHANGED
@@ -4,247 +4,247 @@
4
 
5
  It is used for the map in the overview page.
6
  */
7
- $CountryCoordinates["AF"] = array("lat" => "33", "lng" => "65");
8
- $CountryCoordinates["AL"] = array("lat" => "41", "lng" => "20");
9
- $CountryCoordinates["DZ"] = array("lat" => "28", "lng" => "3");
10
- $CountryCoordinates["AS"] = array("lat" => "-14.3333", "lng" => "-170");
11
- $CountryCoordinates["AD"] = array("lat" => "42.5", "lng" => "1.6");
12
- $CountryCoordinates["AO"] = array("lat" => "-12.5", "lng" => "18.5");
13
- $CountryCoordinates["AI"] = array("lat" => "18.25", "lng" => "-63.1667");
14
- $CountryCoordinates["AQ"] = array("lat" => "-90", "lng" => "0");
15
- $CountryCoordinates["AG"] = array("lat" => "17.05", "lng" => "-61.8");
16
- $CountryCoordinates["AR"] = array("lat" => "-34", "lng" => "-64");
17
- $CountryCoordinates["AM"] = array("lat" => "40", "lng" => "45");
18
- $CountryCoordinates["AW"] = array("lat" => "12.5", "lng" => "-69.9667");
19
- $CountryCoordinates["AU"] = array("lat" => "-27", "lng" => "133");
20
- $CountryCoordinates["AT"] = array("lat" => "47.3333", "lng" => "13.3333");
21
- $CountryCoordinates["AZ"] = array("lat" => "40.5", "lng" => "47.5");
22
- $CountryCoordinates["BS"] = array("lat" => "24.25", "lng" => "-76");
23
- $CountryCoordinates["BH"] = array("lat" => "26", "lng" => "50.55");
24
- $CountryCoordinates["BD"] = array("lat" => "24", "lng" => "90");
25
- $CountryCoordinates["BB"] = array("lat" => "13.1667", "lng" => "-59.5333");
26
- $CountryCoordinates["BY"] = array("lat" => "53", "lng" => "28");
27
- $CountryCoordinates["BE"] = array("lat" => "50.8333", "lng" => "4");
28
- $CountryCoordinates["BZ"] = array("lat" => "17.25", "lng" => "-88.75");
29
- $CountryCoordinates["BJ"] = array("lat" => "9.5", "lng" => "2.25");
30
- $CountryCoordinates["BM"] = array("lat" => "32.3333", "lng" => "-64.75");
31
- $CountryCoordinates["BT"] = array("lat" => "27.5", "lng" => "90.5");
32
- $CountryCoordinates["BO"] = array("lat" => "-17", "lng" => "-65");
33
- $CountryCoordinates["BA"] = array("lat" => "44", "lng" => "18");
34
- $CountryCoordinates["BW"] = array("lat" => "-22", "lng" => "24");
35
- $CountryCoordinates["BV"] = array("lat" => "-54.4333", "lng" => "3.4");
36
- $CountryCoordinates["BR"] = array("lat" => "-10", "lng" => "-55");
37
- $CountryCoordinates["IO"] = array("lat" => "-6", "lng" => "71.5");
38
- $CountryCoordinates["BN"] = array("lat" => "4.5", "lng" => "114.6667");
39
- $CountryCoordinates["BG"] = array("lat" => "43", "lng" => "25");
40
- $CountryCoordinates["BF"] = array("lat" => "13", "lng" => "-2");
41
- $CountryCoordinates["BI"] = array("lat" => "-3.5", "lng" => "30");
42
- $CountryCoordinates["KH"] = array("lat" => "13", "lng" => "105");
43
- $CountryCoordinates["CM"] = array("lat" => "6", "lng" => "12");
44
- $CountryCoordinates["CA"] = array("lat" => "60", "lng" => "-95");
45
- $CountryCoordinates["CV"] = array("lat" => "16", "lng" => "-24");
46
- $CountryCoordinates["KY"] = array("lat" => "19.5", "lng" => "-80.5");
47
- $CountryCoordinates["CF"] = array("lat" => "7", "lng" => "21");
48
- $CountryCoordinates["TD"] = array("lat" => "15", "lng" => "19");
49
- $CountryCoordinates["CL"] = array("lat" => "-30", "lng" => "-71");
50
- $CountryCoordinates["CN"] = array("lat" => "35", "lng" => "105");
51
- $CountryCoordinates["CX"] = array("lat" => "-10.5", "lng" => "105.6667");
52
- $CountryCoordinates["CC"] = array("lat" => "-12.5", "lng" => "96.8333");
53
- $CountryCoordinates["CO"] = array("lat" => "4", "lng" => "-72");
54
- $CountryCoordinates["KM"] = array("lat" => "-12.1667", "lng" => "44.25");
55
- $CountryCoordinates["CG"] = array("lat" => "-1", "lng" => "15");
56
- $CountryCoordinates["CD"] = array("lat" => "0", "lng" => "25");
57
- $CountryCoordinates["CK"] = array("lat" => "-21.2333", "lng" => "-159.7667");
58
- $CountryCoordinates["CR"] = array("lat" => "10", "lng" => "-84");
59
- $CountryCoordinates["CI"] = array("lat" => "8", "lng" => "-5");
60
- $CountryCoordinates["HR"] = array("lat" => "45.1667", "lng" => "15.5");
61
- $CountryCoordinates["CU"] = array("lat" => "21.5", "lng" => "-80");
62
- $CountryCoordinates["CY"] = array("lat" => "35", "lng" => "33");
63
- $CountryCoordinates["CZ"] = array("lat" => "49.75", "lng" => "15.5");
64
- $CountryCoordinates["DK"] = array("lat" => "56", "lng" => "10");
65
- $CountryCoordinates["DJ"] = array("lat" => "11.5", "lng" => "43");
66
- $CountryCoordinates["DM"] = array("lat" => "15.4167", "lng" => "-61.3333");
67
- $CountryCoordinates["DO"] = array("lat" => "19", "lng" => "-70.6667");
68
- $CountryCoordinates["EC"] = array("lat" => "-2", "lng" => "-77.5");
69
- $CountryCoordinates["EG"] = array("lat" => "27", "lng" => "30");
70
- $CountryCoordinates["SV"] = array("lat" => "13.8333", "lng" => "-88.9167");
71
- $CountryCoordinates["GQ"] = array("lat" => "2", "lng" => "10");
72
- $CountryCoordinates["ER"] = array("lat" => "15", "lng" => "39");
73
- $CountryCoordinates["EE"] = array("lat" => "59", "lng" => "26");
74
- $CountryCoordinates["ET"] = array("lat" => "8", "lng" => "38");
75
- $CountryCoordinates["FK"] = array("lat" => "-51.75", "lng" => "-59");
76
- $CountryCoordinates["FO"] = array("lat" => "62", "lng" => "-7");
77
- $CountryCoordinates["FJ"] = array("lat" => "-18", "lng" => "175");
78
- $CountryCoordinates["FI"] = array("lat" => "64", "lng" => "26");
79
- $CountryCoordinates["FR"] = array("lat" => "46", "lng" => "2");
80
- $CountryCoordinates["GF"] = array("lat" => "4", "lng" => "-53");
81
- $CountryCoordinates["PF"] = array("lat" => "-15", "lng" => "-140");
82
- $CountryCoordinates["TF"] = array("lat" => "-43", "lng" => "67");
83
- $CountryCoordinates["GA"] = array("lat" => "-1", "lng" => "11.75");
84
- $CountryCoordinates["GM"] = array("lat" => "13.4667", "lng" => "-16.5667");
85
- $CountryCoordinates["GE"] = array("lat" => "42", "lng" => "43.5");
86
- $CountryCoordinates["DE"] = array("lat" => "51", "lng" => "9");
87
- $CountryCoordinates["GH"] = array("lat" => "8", "lng" => "-2");
88
- $CountryCoordinates["GI"] = array("lat" => "36.1833", "lng" => "-5.3667");
89
- $CountryCoordinates["GR"] = array("lat" => "39", "lng" => "22");
90
- $CountryCoordinates["GL"] = array("lat" => "72", "lng" => "-40");
91
- $CountryCoordinates["GD"] = array("lat" => "12.1167", "lng" => "-61.6667");
92
- $CountryCoordinates["GP"] = array("lat" => "16.25", "lng" => "-61.5833");
93
- $CountryCoordinates["GU"] = array("lat" => "13.4667", "lng" => "144.7833");
94
- $CountryCoordinates["GT"] = array("lat" => "15.5", "lng" => "-90.25");
95
- $CountryCoordinates["GG"] = array("lat" => "49.5", "lng" => "-2.56");
96
- $CountryCoordinates["GN"] = array("lat" => "11", "lng" => "-10");
97
- $CountryCoordinates["GW"] = array("lat" => "12", "lng" => "-15");
98
- $CountryCoordinates["GY"] = array("lat" => "5", "lng" => "-59");
99
- $CountryCoordinates["HT"] = array("lat" => "19", "lng" => "-72.4167");
100
- $CountryCoordinates["HM"] = array("lat" => "-53.1", "lng" => "72.5167");
101
- $CountryCoordinates["VA"] = array("lat" => "41.9", "lng" => "12.45");
102
- $CountryCoordinates["HN"] = array("lat" => "15", "lng" => "-86.5");
103
- $CountryCoordinates["HK"] = array("lat" => "22.25", "lng" => "114.1667");
104
- $CountryCoordinates["HU"] = array("lat" => "47", "lng" => "20");
105
- $CountryCoordinates["IS"] = array("lat" => "65", "lng" => "-18");
106
- $CountryCoordinates["IN"] = array("lat" => "20", "lng" => "77");
107
- $CountryCoordinates["ID"] = array("lat" => "-5", "lng" => "120");
108
- $CountryCoordinates["IR"] = array("lat" => "32", "lng" => "53");
109
- $CountryCoordinates["IQ"] = array("lat" => "33", "lng" => "44");
110
- $CountryCoordinates["IE"] = array("lat" => "53", "lng" => "-8");
111
- $CountryCoordinates["IM"] = array("lat" => "54.23", "lng" => "-4.55");
112
- $CountryCoordinates["IL"] = array("lat" => "31.5", "lng" => "34.75");
113
- $CountryCoordinates["IT"] = array("lat" => "42.8333", "lng" => "12.8333");
114
- $CountryCoordinates["JM"] = array("lat" => "18.25", "lng" => "-77.5");
115
- $CountryCoordinates["JP"] = array("lat" => "36", "lng" => "138");
116
- $CountryCoordinates["JE"] = array("lat" => "49.21", "lng" => "-2.13");
117
- $CountryCoordinates["JO"] = array("lat" => "31", "lng" => "36");
118
- $CountryCoordinates["KZ"] = array("lat" => "48", "lng" => "68");
119
- $CountryCoordinates["KE"] = array("lat" => "1", "lng" => "38");
120
- $CountryCoordinates["KI"] = array("lat" => "1.4167", "lng" => "173");
121
- $CountryCoordinates["KP"] = array("lat" => "40", "lng" => "127");
122
- $CountryCoordinates["KR"] = array("lat" => "37", "lng" => "127.5");
123
- $CountryCoordinates["KW"] = array("lat" => "29.3375", "lng" => "47.6581");
124
- $CountryCoordinates["KG"] = array("lat" => "41", "lng" => "75");
125
- $CountryCoordinates["LA"] = array("lat" => "18", "lng" => "105");
126
- $CountryCoordinates["LV"] = array("lat" => "57", "lng" => "25");
127
- $CountryCoordinates["LB"] = array("lat" => "33.8333", "lng" => "35.8333");
128
- $CountryCoordinates["LS"] = array("lat" => "-29.5", "lng" => "28.5");
129
- $CountryCoordinates["LR"] = array("lat" => "6.5", "lng" => "-9.5");
130
- $CountryCoordinates["LY"] = array("lat" => "25", "lng" => "17");
131
- $CountryCoordinates["LI"] = array("lat" => "47.1667", "lng" => "9.5333");
132
- $CountryCoordinates["LT"] = array("lat" => "56", "lng" => "24");
133
- $CountryCoordinates["LU"] = array("lat" => "49.75", "lng" => "6.1667");
134
- $CountryCoordinates["MO"] = array("lat" => "22.1667", "lng" => "113.55");
135
- $CountryCoordinates["MK"] = array("lat" => "41.8333", "lng" => "22");
136
- $CountryCoordinates["MG"] = array("lat" => "-20", "lng" => "47");
137
- $CountryCoordinates["MW"] = array("lat" => "-13.5", "lng" => "34");
138
- $CountryCoordinates["MY"] = array("lat" => "2.5", "lng" => "112.5");
139
- $CountryCoordinates["MV"] = array("lat" => "3.25", "lng" => "73");
140
- $CountryCoordinates["ML"] = array("lat" => "17", "lng" => "-4");
141
- $CountryCoordinates["MT"] = array("lat" => "35.8333", "lng" => "14.5833");
142
- $CountryCoordinates["MH"] = array("lat" => "9", "lng" => "168");
143
- $CountryCoordinates["MQ"] = array("lat" => "14.6667", "lng" => "-61");
144
- $CountryCoordinates["MR"] = array("lat" => "20", "lng" => "-12");
145
- $CountryCoordinates["MU"] = array("lat" => "-20.2833", "lng" => "57.55");
146
- $CountryCoordinates["YT"] = array("lat" => "-12.8333", "lng" => "45.1667");
147
- $CountryCoordinates["MX"] = array("lat" => "23", "lng" => "-102");
148
- $CountryCoordinates["FM"] = array("lat" => "6.9167", "lng" => "158.25");
149
- $CountryCoordinates["MD"] = array("lat" => "47", "lng" => "29");
150
- $CountryCoordinates["MC"] = array("lat" => "43.7333", "lng" => "7.4");
151
- $CountryCoordinates["MN"] = array("lat" => "46", "lng" => "105");
152
- $CountryCoordinates["ME"] = array("lat" => "42", "lng" => "19");
153
- $CountryCoordinates["MS"] = array("lat" => "16.75", "lng" => "-62.2");
154
- $CountryCoordinates["MA"] = array("lat" => "32", "lng" => "-5");
155
- $CountryCoordinates["MZ"] = array("lat" => "-18.25", "lng" => "35");
156
- $CountryCoordinates["MM"] = array("lat" => "22", "lng" => "98");
157
- $CountryCoordinates["NA"] = array("lat" => "-22", "lng" => "17");
158
- $CountryCoordinates["NR"] = array("lat" => "-0.5333", "lng" => "166.9167");
159
- $CountryCoordinates["NP"] = array("lat" => "28", "lng" => "84");
160
- $CountryCoordinates["NL"] = array("lat" => "52.5", "lng" => "5.75");
161
- $CountryCoordinates["AN"] = array("lat" => "12.25", "lng" => "-68.75");
162
- $CountryCoordinates["NC"] = array("lat" => "-21.5", "lng" => "165.5");
163
- $CountryCoordinates["NZ"] = array("lat" => "-41", "lng" => "174");
164
- $CountryCoordinates["NI"] = array("lat" => "13", "lng" => "-85");
165
- $CountryCoordinates["NE"] = array("lat" => "16", "lng" => "8");
166
- $CountryCoordinates["NG"] = array("lat" => "10", "lng" => "8");
167
- $CountryCoordinates["NU"] = array("lat" => "-19.0333", "lng" => "-169.8667");
168
- $CountryCoordinates["NF"] = array("lat" => "-29.0333", "lng" => "167.95");
169
- $CountryCoordinates["MP"] = array("lat" => "15.2", "lng" => "145.75");
170
- $CountryCoordinates["NO"] = array("lat" => "62", "lng" => "10");
171
- $CountryCoordinates["OM"] = array("lat" => "21", "lng" => "57");
172
- $CountryCoordinates["PK"] = array("lat" => "30", "lng" => "70");
173
- $CountryCoordinates["PW"] = array("lat" => "7.5", "lng" => "134.5");
174
- $CountryCoordinates["PS"] = array("lat" => "32", "lng" => "35.25");
175
- $CountryCoordinates["PA"] = array("lat" => "9", "lng" => "-80");
176
- $CountryCoordinates["PG"] = array("lat" => "-6", "lng" => "147");
177
- $CountryCoordinates["PY"] = array("lat" => "-23", "lng" => "-58");
178
- $CountryCoordinates["PE"] = array("lat" => "-10", "lng" => "-76");
179
- $CountryCoordinates["PH"] = array("lat" => "13", "lng" => "122");
180
- $CountryCoordinates["PN"] = array("lat" => "-24.7", "lng" => "-127.4");
181
- $CountryCoordinates["PL"] = array("lat" => "52", "lng" => "20");
182
- $CountryCoordinates["PT"] = array("lat" => "39.5", "lng" => "-8");
183
- $CountryCoordinates["PR"] = array("lat" => "18.25", "lng" => "-66.5");
184
- $CountryCoordinates["QA"] = array("lat" => "25.5", "lng" => "51.25");
185
- $CountryCoordinates["RE"] = array("lat" => "-21.1", "lng" => "55.6");
186
- $CountryCoordinates["RO"] = array("lat" => "46", "lng" => "25");
187
- $CountryCoordinates["RU"] = array("lat" => "60", "lng" => "100");
188
- $CountryCoordinates["RW"] = array("lat" => "-2", "lng" => "30");
189
- $CountryCoordinates["SH"] = array("lat" => "-15.9333", "lng" => "-5.7");
190
- $CountryCoordinates["KN"] = array("lat" => "17.3333", "lng" => "-62.75");
191
- $CountryCoordinates["LC"] = array("lat" => "13.8833", "lng" => "-61.1333");
192
- $CountryCoordinates["PM"] = array("lat" => "46.8333", "lng" => "-56.3333");
193
- $CountryCoordinates["VC"] = array("lat" => "13.25", "lng" => "-61.2");
194
- $CountryCoordinates["WS"] = array("lat" => "-13.5833", "lng" => "-172.3333");
195
- $CountryCoordinates["SM"] = array("lat" => "43.7667", "lng" => "12.4167");
196
- $CountryCoordinates["ST"] = array("lat" => "1", "lng" => "7");
197
- $CountryCoordinates["SA"] = array("lat" => "25", "lng" => "45");
198
- $CountryCoordinates["SN"] = array("lat" => "14", "lng" => "-14");
199
- $CountryCoordinates["RS"] = array("lat" => "44", "lng" => "21");
200
- $CountryCoordinates["SC"] = array("lat" => "-4.5833", "lng" => "55.6667");
201
- $CountryCoordinates["SL"] = array("lat" => "8.5", "lng" => "-11.5");
202
- $CountryCoordinates["SG"] = array("lat" => "1.3667", "lng" => "103.8");
203
- $CountryCoordinates["SK"] = array("lat" => "48.6667", "lng" => "19.5");
204
- $CountryCoordinates["SI"] = array("lat" => "46", "lng" => "15");
205
- $CountryCoordinates["SB"] = array("lat" => "-8", "lng" => "159");
206
- $CountryCoordinates["SO"] = array("lat" => "10", "lng" => "49");
207
- $CountryCoordinates["ZA"] = array("lat" => "-29", "lng" => "24");
208
- $CountryCoordinates["GS"] = array("lat" => "-54.5", "lng" => "-37");
209
- $CountryCoordinates["ES"] = array("lat" => "40", "lng" => "-4");
210
- $CountryCoordinates["LK"] = array("lat" => "7", "lng" => "81");
211
- $CountryCoordinates["SD"] = array("lat" => "15", "lng" => "30");
212
- $CountryCoordinates["SR"] = array("lat" => "4", "lng" => "-56");
213
- $CountryCoordinates["SJ"] = array("lat" => "78", "lng" => "20");
214
- $CountryCoordinates["SZ"] = array("lat" => "-26.5", "lng" => "31.5");
215
- $CountryCoordinates["SE"] = array("lat" => "62", "lng" => "15");
216
- $CountryCoordinates["CH"] = array("lat" => "47", "lng" => "8");
217
- $CountryCoordinates["SY"] = array("lat" => "35", "lng" => "38");
218
- $CountryCoordinates["TW"] = array("lat" => "23.5", "lng" => "121");
219
- $CountryCoordinates["TJ"] = array("lat" => "39", "lng" => "71");
220
- $CountryCoordinates["TZ"] = array("lat" => "-6", "lng" => "35");
221
- $CountryCoordinates["TH"] = array("lat" => "15", "lng" => "100");
222
- $CountryCoordinates["TL"] = array("lat" => "-8.55", "lng" => "125.5167");
223
- $CountryCoordinates["TG"] = array("lat" => "8", "lng" => "1.1667");
224
- $CountryCoordinates["TK"] = array("lat" => "-9", "lng" => "-172");
225
- $CountryCoordinates["TO"] = array("lat" => "-20", "lng" => "-175");
226
- $CountryCoordinates["TT"] = array("lat" => "11", "lng" => "-61");
227
- $CountryCoordinates["TN"] = array("lat" => "34", "lng" => "9");
228
- $CountryCoordinates["TR"] = array("lat" => "39", "lng" => "35");
229
- $CountryCoordinates["TM"] = array("lat" => "40", "lng" => "60");
230
- $CountryCoordinates["TC"] = array("lat" => "21.75", "lng" => "-71.5833");
231
- $CountryCoordinates["TV"] = array("lat" => "-8", "lng" => "178");
232
- $CountryCoordinates["UG"] = array("lat" => "1", "lng" => "32");
233
- $CountryCoordinates["UA"] = array("lat" => "49", "lng" => "32");
234
- $CountryCoordinates["AE"] = array("lat" => "24", "lng" => "54");
235
- $CountryCoordinates["GB"] = array("lat" => "54", "lng" => "-2");
236
- $CountryCoordinates["US"] = array("lat" => "38", "lng" => "-97");
237
- $CountryCoordinates["UM"] = array("lat" => "19.2833", "lng" => "166.6");
238
- $CountryCoordinates["UY"] = array("lat" => "-33", "lng" => "-56");
239
- $CountryCoordinates["UZ"] = array("lat" => "41", "lng" => "64");
240
- $CountryCoordinates["VU"] = array("lat" => "-16", "lng" => "167");
241
- $CountryCoordinates["VE"] = array("lat" => "8", "lng" => "-66");
242
- $CountryCoordinates["VN"] = array("lat" => "16", "lng" => "106");
243
- $CountryCoordinates["VG"] = array("lat" => "18.5", "lng" => "-64.5");
244
- $CountryCoordinates["VI"] = array("lat" => "18.3333", "lng" => "-64.8333");
245
- $CountryCoordinates["WF"] = array("lat" => "-13.3", "lng" => "-176.2");
246
- $CountryCoordinates["EH"] = array("lat" => "24.5", "lng" => "-13");
247
- $CountryCoordinates["YE"] = array("lat" => "15", "lng" => "48");
248
- $CountryCoordinates["ZM"] = array("lat" => "-15", "lng" => "30");
249
- $CountryCoordinates["ZW"] = array("lat" => "-20", "lng" => "30");
250
  ?>
4
 
5
  It is used for the map in the overview page.
6
  */
7
+ $CountryCoordinates["AF"] = array( "lat" => "33", "lng" => "65" );
8
+ $CountryCoordinates["AL"] = array( "lat" => "41", "lng" => "20" );
9
+ $CountryCoordinates["DZ"] = array( "lat" => "28", "lng" => "3" );
10
+ $CountryCoordinates["AS"] = array( "lat" => "-14.3333", "lng" => "-170" );
11
+ $CountryCoordinates["AD"] = array( "lat" => "42.5", "lng" => "1.6" );
12
+ $CountryCoordinates["AO"] = array( "lat" => "-12.5", "lng" => "18.5" );
13
+ $CountryCoordinates["AI"] = array( "lat" => "18.25", "lng" => "-63.1667" );
14
+ $CountryCoordinates["AQ"] = array( "lat" => "-90", "lng" => "0" );
15
+ $CountryCoordinates["AG"] = array( "lat" => "17.05", "lng" => "-61.8" );
16
+ $CountryCoordinates["AR"] = array( "lat" => "-34", "lng" => "-64" );
17
+ $CountryCoordinates["AM"] = array( "lat" => "40", "lng" => "45" );
18
+ $CountryCoordinates["AW"] = array( "lat" => "12.5", "lng" => "-69.9667" );
19
+ $CountryCoordinates["AU"] = array( "lat" => "-27", "lng" => "133" );
20
+ $CountryCoordinates["AT"] = array( "lat" => "47.3333", "lng" => "13.3333" );
21
+ $CountryCoordinates["AZ"] = array( "lat" => "40.5", "lng" => "47.5" );
22
+ $CountryCoordinates["BS"] = array( "lat" => "24.25", "lng" => "-76" );
23
+ $CountryCoordinates["BH"] = array( "lat" => "26", "lng" => "50.55" );
24
+ $CountryCoordinates["BD"] = array( "lat" => "24", "lng" => "90" );
25
+ $CountryCoordinates["BB"] = array( "lat" => "13.1667", "lng" => "-59.5333" );
26
+ $CountryCoordinates["BY"] = array( "lat" => "53", "lng" => "28" );
27
+ $CountryCoordinates["BE"] = array( "lat" => "50.8333", "lng" => "4" );
28
+ $CountryCoordinates["BZ"] = array( "lat" => "17.25", "lng" => "-88.75" );
29
+ $CountryCoordinates["BJ"] = array( "lat" => "9.5", "lng" => "2.25" );
30
+ $CountryCoordinates["BM"] = array( "lat" => "32.3333", "lng" => "-64.75" );
31
+ $CountryCoordinates["BT"] = array( "lat" => "27.5", "lng" => "90.5" );
32
+ $CountryCoordinates["BO"] = array( "lat" => "-17", "lng" => "-65" );
33
+ $CountryCoordinates["BA"] = array( "lat" => "44", "lng" => "18" );
34
+ $CountryCoordinates["BW"] = array( "lat" => "-22", "lng" => "24" );
35
+ $CountryCoordinates["BV"] = array( "lat" => "-54.4333", "lng" => "3.4" );
36
+ $CountryCoordinates["BR"] = array( "lat" => "-10", "lng" => "-55" );
37
+ $CountryCoordinates["IO"] = array( "lat" => "-6", "lng" => "71.5" );
38
+ $CountryCoordinates["BN"] = array( "lat" => "4.5", "lng" => "114.6667" );
39
+ $CountryCoordinates["BG"] = array( "lat" => "43", "lng" => "25" );
40
+ $CountryCoordinates["BF"] = array( "lat" => "13", "lng" => "-2" );
41
+ $CountryCoordinates["BI"] = array( "lat" => "-3.5", "lng" => "30" );
42
+ $CountryCoordinates["KH"] = array( "lat" => "13", "lng" => "105" );
43
+ $CountryCoordinates["CM"] = array( "lat" => "6", "lng" => "12" );
44
+ $CountryCoordinates["CA"] = array( "lat" => "60", "lng" => "-95" );
45
+ $CountryCoordinates["CV"] = array( "lat" => "16", "lng" => "-24" );
46
+ $CountryCoordinates["KY"] = array( "lat" => "19.5", "lng" => "-80.5" );
47
+ $CountryCoordinates["CF"] = array( "lat" => "7", "lng" => "21" );
48
+ $CountryCoordinates["TD"] = array( "lat" => "15", "lng" => "19" );
49
+ $CountryCoordinates["CL"] = array( "lat" => "-30", "lng" => "-71" );
50
+ $CountryCoordinates["CN"] = array( "lat" => "35", "lng" => "105" );
51
+ $CountryCoordinates["CX"] = array( "lat" => "-10.5", "lng" => "105.6667" );
52
+ $CountryCoordinates["CC"] = array( "lat" => "-12.5", "lng" => "96.8333" );
53
+ $CountryCoordinates["CO"] = array( "lat" => "4", "lng" => "-72" );
54
+ $CountryCoordinates["KM"] = array( "lat" => "-12.1667", "lng" => "44.25" );
55
+ $CountryCoordinates["CG"] = array( "lat" => "-1", "lng" => "15" );
56
+ $CountryCoordinates["CD"] = array( "lat" => "0", "lng" => "25" );
57
+ $CountryCoordinates["CK"] = array( "lat" => "-21.2333", "lng" => "-159.7667" );
58
+ $CountryCoordinates["CR"] = array( "lat" => "10", "lng" => "-84" );
59
+ $CountryCoordinates["CI"] = array( "lat" => "8", "lng" => "-5" );
60
+ $CountryCoordinates["HR"] = array( "lat" => "45.1667", "lng" => "15.5" );
61
+ $CountryCoordinates["CU"] = array( "lat" => "21.5", "lng" => "-80" );
62
+ $CountryCoordinates["CY"] = array( "lat" => "35", "lng" => "33" );
63
+ $CountryCoordinates["CZ"] = array( "lat" => "49.75", "lng" => "15.5" );
64
+ $CountryCoordinates["DK"] = array( "lat" => "56", "lng" => "10" );
65
+ $CountryCoordinates["DJ"] = array( "lat" => "11.5", "lng" => "43" );
66
+ $CountryCoordinates["DM"] = array( "lat" => "15.4167", "lng" => "-61.3333" );
67
+ $CountryCoordinates["DO"] = array( "lat" => "19", "lng" => "-70.6667" );
68
+ $CountryCoordinates["EC"] = array( "lat" => "-2", "lng" => "-77.5" );
69
+ $CountryCoordinates["EG"] = array( "lat" => "27", "lng" => "30" );
70
+ $CountryCoordinates["SV"] = array( "lat" => "13.8333", "lng" => "-88.9167" );
71
+ $CountryCoordinates["GQ"] = array( "lat" => "2", "lng" => "10" );
72
+ $CountryCoordinates["ER"] = array( "lat" => "15", "lng" => "39" );
73
+ $CountryCoordinates["EE"] = array( "lat" => "59", "lng" => "26" );
74
+ $CountryCoordinates["ET"] = array( "lat" => "8", "lng" => "38" );
75
+ $CountryCoordinates["FK"] = array( "lat" => "-51.75", "lng" => "-59" );
76
+ $CountryCoordinates["FO"] = array( "lat" => "62", "lng" => "-7" );
77
+ $CountryCoordinates["FJ"] = array( "lat" => "-18", "lng" => "175" );
78
+ $CountryCoordinates["FI"] = array( "lat" => "64", "lng" => "26" );
79
+ $CountryCoordinates["FR"] = array( "lat" => "46", "lng" => "2" );
80
+ $CountryCoordinates["GF"] = array( "lat" => "4", "lng" => "-53" );
81
+ $CountryCoordinates["PF"] = array( "lat" => "-15", "lng" => "-140" );
82
+ $CountryCoordinates["TF"] = array( "lat" => "-43", "lng" => "67" );
83
+ $CountryCoordinates["GA"] = array( "lat" => "-1", "lng" => "11.75" );
84
+ $CountryCoordinates["GM"] = array( "lat" => "13.4667", "lng" => "-16.5667" );
85
+ $CountryCoordinates["GE"] = array( "lat" => "42", "lng" => "43.5" );
86
+ $CountryCoordinates["DE"] = array( "lat" => "51", "lng" => "9" );
87
+ $CountryCoordinates["GH"] = array( "lat" => "8", "lng" => "-2" );
88
+ $CountryCoordinates["GI"] = array( "lat" => "36.1833", "lng" => "-5.3667" );
89
+ $CountryCoordinates["GR"] = array( "lat" => "39", "lng" => "22" );
90
+ $CountryCoordinates["GL"] = array( "lat" => "72", "lng" => "-40" );
91
+ $CountryCoordinates["GD"] = array( "lat" => "12.1167", "lng" => "-61.6667" );
92
+ $CountryCoordinates["GP"] = array( "lat" => "16.25", "lng" => "-61.5833" );
93
+ $CountryCoordinates["GU"] = array( "lat" => "13.4667", "lng" => "144.7833" );
94
+ $CountryCoordinates["GT"] = array( "lat" => "15.5", "lng" => "-90.25" );
95
+ $CountryCoordinates["GG"] = array( "lat" => "49.5", "lng" => "-2.56" );
96
+ $CountryCoordinates["GN"] = array( "lat" => "11", "lng" => "-10" );
97
+ $CountryCoordinates["GW"] = array( "lat" => "12", "lng" => "-15" );
98
+ $CountryCoordinates["GY"] = array( "lat" => "5", "lng" => "-59" );
99
+ $CountryCoordinates["HT"] = array( "lat" => "19", "lng" => "-72.4167" );
100
+ $CountryCoordinates["HM"] = array( "lat" => "-53.1", "lng" => "72.5167" );
101
+ $CountryCoordinates["VA"] = array( "lat" => "41.9", "lng" => "12.45" );
102
+ $CountryCoordinates["HN"] = array( "lat" => "15", "lng" => "-86.5" );
103
+ $CountryCoordinates["HK"] = array( "lat" => "22.25", "lng" => "114.1667" );
104
+ $CountryCoordinates["HU"] = array( "lat" => "47", "lng" => "20" );
105
+ $CountryCoordinates["IS"] = array( "lat" => "65", "lng" => "-18" );
106
+ $CountryCoordinates["IN"] = array( "lat" => "20", "lng" => "77" );
107
+ $CountryCoordinates["ID"] = array( "lat" => "-5", "lng" => "120" );
108
+ $CountryCoordinates["IR"] = array( "lat" => "32", "lng" => "53" );
109
+ $CountryCoordinates["IQ"] = array( "lat" => "33", "lng" => "44" );
110
+ $CountryCoordinates["IE"] = array( "lat" => "53", "lng" => "-8" );
111
+ $CountryCoordinates["IM"] = array( "lat" => "54.23", "lng" => "-4.55" );
112
+ $CountryCoordinates["IL"] = array( "lat" => "31.5", "lng" => "34.75" );
113
+ $CountryCoordinates["IT"] = array( "lat" => "42.8333", "lng" => "12.8333" );
114
+ $CountryCoordinates["JM"] = array( "lat" => "18.25", "lng" => "-77.5" );
115
+ $CountryCoordinates["JP"] = array( "lat" => "36", "lng" => "138" );
116
+ $CountryCoordinates["JE"] = array( "lat" => "49.21", "lng" => "-2.13" );
117
+ $CountryCoordinates["JO"] = array( "lat" => "31", "lng" => "36" );
118
+ $CountryCoordinates["KZ"] = array( "lat" => "48", "lng" => "68" );
119
+ $CountryCoordinates["KE"] = array( "lat" => "1", "lng" => "38" );
120
+ $CountryCoordinates["KI"] = array( "lat" => "1.4167", "lng" => "173" );
121
+ $CountryCoordinates["KP"] = array( "lat" => "40", "lng" => "127" );
122
+ $CountryCoordinates["KR"] = array( "lat" => "37", "lng" => "127.5" );
123
+ $CountryCoordinates["KW"] = array( "lat" => "29.3375", "lng" => "47.6581" );
124
+ $CountryCoordinates["KG"] = array( "lat" => "41", "lng" => "75" );
125
+ $CountryCoordinates["LA"] = array( "lat" => "18", "lng" => "105" );
126
+ $CountryCoordinates["LV"] = array( "lat" => "57", "lng" => "25" );
127
+ $CountryCoordinates["LB"] = array( "lat" => "33.8333", "lng" => "35.8333" );
128
+ $CountryCoordinates["LS"] = array( "lat" => "-29.5", "lng" => "28.5" );
129
+ $CountryCoordinates["LR"] = array( "lat" => "6.5", "lng" => "-9.5" );
130
+ $CountryCoordinates["LY"] = array( "lat" => "25", "lng" => "17" );
131
+ $CountryCoordinates["LI"] = array( "lat" => "47.1667", "lng" => "9.5333" );
132
+ $CountryCoordinates["LT"] = array( "lat" => "56", "lng" => "24" );
133
+ $CountryCoordinates["LU"] = array( "lat" => "49.75", "lng" => "6.1667" );
134
+ $CountryCoordinates["MO"] = array( "lat" => "22.1667", "lng" => "113.55" );
135
+ $CountryCoordinates["MK"] = array( "lat" => "41.8333", "lng" => "22" );
136
+ $CountryCoordinates["MG"] = array( "lat" => "-20", "lng" => "47" );
137
+ $CountryCoordinates["MW"] = array( "lat" => "-13.5", "lng" => "34" );
138
+ $CountryCoordinates["MY"] = array( "lat" => "2.5", "lng" => "112.5" );
139
+ $CountryCoordinates["MV"] = array( "lat" => "3.25", "lng" => "73" );
140
+ $CountryCoordinates["ML"] = array( "lat" => "17", "lng" => "-4" );
141
+ $CountryCoordinates["MT"] = array( "lat" => "35.8333", "lng" => "14.5833" );
142
+ $CountryCoordinates["MH"] = array( "lat" => "9", "lng" => "168" );
143
+ $CountryCoordinates["MQ"] = array( "lat" => "14.6667", "lng" => "-61" );
144
+ $CountryCoordinates["MR"] = array( "lat" => "20", "lng" => "-12" );
145
+ $CountryCoordinates["MU"] = array( "lat" => "-20.2833", "lng" => "57.55" );
146
+ $CountryCoordinates["YT"] = array( "lat" => "-12.8333", "lng" => "45.1667" );
147
+ $CountryCoordinates["MX"] = array( "lat" => "23", "lng" => "-102" );
148
+ $CountryCoordinates["FM"] = array( "lat" => "6.9167", "lng" => "158.25" );
149
+ $CountryCoordinates["MD"] = array( "lat" => "47", "lng" => "29" );
150
+ $CountryCoordinates["MC"] = array( "lat" => "43.7333", "lng" => "7.4" );
151
+ $CountryCoordinates["MN"] = array( "lat" => "46", "lng" => "105" );
152
+ $CountryCoordinates["ME"] = array( "lat" => "42", "lng" => "19" );
153
+ $CountryCoordinates["MS"] = array( "lat" => "16.75", "lng" => "-62.2" );
154
+ $CountryCoordinates["MA"] = array( "lat" => "32", "lng" => "-5" );
155
+ $CountryCoordinates["MZ"] = array( "lat" => "-18.25", "lng" => "35" );
156
+ $CountryCoordinates["MM"] = array( "lat" => "22", "lng" => "98" );
157
+ $CountryCoordinates["NA"] = array( "lat" => "-22", "lng" => "17" );
158
+ $CountryCoordinates["NR"] = array( "lat" => "-0.5333", "lng" => "166.9167" );
159
+ $CountryCoordinates["NP"] = array( "lat" => "28", "lng" => "84" );
160
+ $CountryCoordinates["NL"] = array( "lat" => "52.5", "lng" => "5.75" );
161
+ $CountryCoordinates["AN"] = array( "lat" => "12.25", "lng" => "-68.75" );
162
+ $CountryCoordinates["NC"] = array( "lat" => "-21.5", "lng" => "165.5" );
163
+ $CountryCoordinates["NZ"] = array( "lat" => "-41", "lng" => "174" );
164
+ $CountryCoordinates["NI"] = array( "lat" => "13", "lng" => "-85" );
165
+ $CountryCoordinates["NE"] = array( "lat" => "16", "lng" => "8" );
166
+ $CountryCoordinates["NG"] = array( "lat" => "10", "lng" => "8" );
167
+ $CountryCoordinates["NU"] = array( "lat" => "-19.0333", "lng" => "-169.8667" );
168
+ $CountryCoordinates["NF"] = array( "lat" => "-29.0333", "lng" => "167.95" );
169
+ $CountryCoordinates["MP"] = array( "lat" => "15.2", "lng" => "145.75" );
170
+ $CountryCoordinates["NO"] = array( "lat" => "62", "lng" => "10" );
171
+ $CountryCoordinates["OM"] = array( "lat" => "21", "lng" => "57" );
172
+ $CountryCoordinates["PK"] = array( "lat" => "30", "lng" => "70" );
173
+ $CountryCoordinates["PW"] = array( "lat" => "7.5", "lng" => "134.5" );
174
+ $CountryCoordinates["PS"] = array( "lat" => "32", "lng" => "35.25" );
175
+ $CountryCoordinates["PA"] = array( "lat" => "9", "lng" => "-80" );
176
+ $CountryCoordinates["PG"] = array( "lat" => "-6", "lng" => "147" );
177
+ $CountryCoordinates["PY"] = array( "lat" => "-23", "lng" => "-58" );
178
+ $CountryCoordinates["PE"] = array( "lat" => "-10", "lng" => "-76" );
179
+ $CountryCoordinates["PH"] = array( "lat" => "13", "lng" => "122" );
180
+ $CountryCoordinates["PN"] = array( "lat" => "-24.7", "lng" => "-127.4" );
181
+ $CountryCoordinates["PL"] = array( "lat" => "52", "lng" => "20" );
182
+ $CountryCoordinates["PT"] = array( "lat" => "39.5", "lng" => "-8" );
183
+ $CountryCoordinates["PR"] = array( "lat" => "18.25", "lng" => "-66.5" );
184
+ $CountryCoordinates["QA"] = array( "lat" => "25.5", "lng" => "51.25" );
185
+ $CountryCoordinates["RE"] = array( "lat" => "-21.1", "lng" => "55.6" );
186
+ $CountryCoordinates["RO"] = array( "lat" => "46", "lng" => "25" );
187
+ $CountryCoordinates["RU"] = array( "lat" => "60", "lng" => "100" );
188
+ $CountryCoordinates["RW"] = array( "lat" => "-2", "lng" => "30" );
189
+ $CountryCoordinates["SH"] = array( "lat" => "-15.9333", "lng" => "-5.7" );
190
+ $CountryCoordinates["KN"] = array( "lat" => "17.3333", "lng" => "-62.75" );
191
+ $CountryCoordinates["LC"] = array( "lat" => "13.8833", "lng" => "-61.1333" );
192
+ $CountryCoordinates["PM"] = array( "lat" => "46.8333", "lng" => "-56.3333" );
193
+ $CountryCoordinates["VC"] = array( "lat" => "13.25", "lng" => "-61.2" );
194
+ $CountryCoordinates["WS"] = array( "lat" => "-13.5833", "lng" => "-172.3333" );
195
+ $CountryCoordinates["SM"] = array( "lat" => "43.7667", "lng" => "12.4167" );
196
+ $CountryCoordinates["ST"] = array( "lat" => "1", "lng" => "7" );
197
+ $CountryCoordinates["SA"] = array( "lat" => "25", "lng" => "45" );
198
+ $CountryCoordinates["SN"] = array( "lat" => "14", "lng" => "-14" );
199
+ $CountryCoordinates["RS"] = array( "lat" => "44", "lng" => "21" );
200
+ $CountryCoordinates["SC"] = array( "lat" => "-4.5833", "lng" => "55.6667" );
201
+ $CountryCoordinates["SL"] = array( "lat" => "8.5", "lng" => "-11.5" );
202
+ $CountryCoordinates["SG"] = array( "lat" => "1.3667", "lng" => "103.8" );
203
+ $CountryCoordinates["SK"] = array( "lat" => "48.6667", "lng" => "19.5" );
204
+ $CountryCoordinates["SI"] = array( "lat" => "46", "lng" => "15" );
205
+ $CountryCoordinates["SB"] = array( "lat" => "-8", "lng" => "159" );
206
+ $CountryCoordinates["SO"] = array( "lat" => "10", "lng" => "49" );
207
+ $CountryCoordinates["ZA"] = array( "lat" => "-29", "lng" => "24" );
208
+ $CountryCoordinates["GS"] = array( "lat" => "-54.5", "lng" => "-37" );
209
+ $CountryCoordinates["ES"] = array( "lat" => "40", "lng" => "-4" );
210
+ $CountryCoordinates["LK"] = array( "lat" => "7", "lng" => "81" );
211
+ $CountryCoordinates["SD"] = array( "lat" => "15", "lng" => "30" );
212
+ $CountryCoordinates["SR"] = array( "lat" => "4", "lng" => "-56" );
213
+ $CountryCoordinates["SJ"] = array( "lat" => "78", "lng" => "20" );
214
+ $CountryCoordinates["SZ"] = array( "lat" => "-26.5", "lng" => "31.5" );
215
+ $CountryCoordinates["SE"] = array( "lat" => "62", "lng" => "15" );
216
+ $CountryCoordinates["CH"] = array( "lat" => "47", "lng" => "8" );
217
+ $CountryCoordinates["SY"] = array( "lat" => "35", "lng" => "38" );
218
+ $CountryCoordinates["TW"] = array( "lat" => "23.5", "lng" => "121" );
219
+ $CountryCoordinates["TJ"] = array( "lat" => "39", "lng" => "71" );
220
+ $CountryCoordinates["TZ"] = array( "lat" => "-6", "lng" => "35" );
221
+ $CountryCoordinates["TH"] = array( "lat" => "15", "lng" => "100" );
222
+ $CountryCoordinates["TL"] = array( "lat" => "-8.55", "lng" => "125.5167" );
223
+ $CountryCoordinates["TG"] = array( "lat" => "8", "lng" => "1.1667" );
224
+ $CountryCoordinates["TK"] = array( "lat" => "-9", "lng" => "-172" );
225
+ $CountryCoordinates["TO"] = array( "lat" => "-20", "lng" => "-175" );
226
+ $CountryCoordinates["TT"] = array( "lat" => "11", "lng" => "-61" );
227
+ $CountryCoordinates["TN"] = array( "lat" => "34", "lng" => "9" );
228
+ $CountryCoordinates["TR"] = array( "lat" => "39", "lng" => "35" );
229
+ $CountryCoordinates["TM"] = array( "lat" => "40", "lng" => "60" );
230
+ $CountryCoordinates["TC"] = array( "lat" => "21.75", "lng" => "-71.5833" );
231
+ $CountryCoordinates["TV"] = array( "lat" => "-8", "lng" => "178" );
232
+ $CountryCoordinates["UG"] = array( "lat" => "1", "lng" => "32" );
233
+ $CountryCoordinates["UA"] = array( "lat" => "49", "lng" => "32" );
234
+ $CountryCoordinates["AE"] = array( "lat" => "24", "lng" => "54" );
235
+ $CountryCoordinates["GB"] = array( "lat" => "54", "lng" => "-2" );
236
+ $CountryCoordinates["US"] = array( "lat" => "38", "lng" => "-97" );
237
+ $CountryCoordinates["UM"] = array( "lat" => "19.2833", "lng" => "166.6" );
238
+ $CountryCoordinates["UY"] = array( "lat" => "-33", "lng" => "-56" );
239
+ $CountryCoordinates["UZ"] = array( "lat" => "41", "lng" => "64" );
240
+ $CountryCoordinates["VU"] = array( "lat" => "-16", "lng" => "167" );
241
+ $CountryCoordinates["VE"] = array( "lat" => "8", "lng" => "-66" );
242
+ $CountryCoordinates["VN"] = array( "lat" => "16", "lng" => "106" );
243
+ $CountryCoordinates["VG"] = array( "lat" => "18.5", "lng" => "-64.5" );
244
+ $CountryCoordinates["VI"] = array( "lat" => "18.3333", "lng" => "-64.8333" );
245
+ $CountryCoordinates["WF"] = array( "lat" => "-13.3", "lng" => "-176.2" );
246
+ $CountryCoordinates["EH"] = array( "lat" => "24.5", "lng" => "-13" );
247
+ $CountryCoordinates["YE"] = array( "lat" => "15", "lng" => "48" );
248
+ $CountryCoordinates["ZM"] = array( "lat" => "-15", "lng" => "30" );
249
+ $CountryCoordinates["ZW"] = array( "lat" => "-20", "lng" => "30" );
250
  ?>
includes/functions/export.php CHANGED
@@ -1,84 +1,96 @@
1
  <?php
2
- function wp_statistics_export_data() {
3
- GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
4
-
5
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option('manage_capability', 'manage_options') );
6
-
7
- if( current_user_can( $manage_cap ) ) {
8
- $table = $_POST['table-to-export'];
9
- $type = $_POST['export-file-type'];
10
- $headers = $_POST['export-headers'];
11
-
12
- // Validate the table name the user passed to us.
13
- if( !( $table == "useronline" || $table == "visit" || $table == "visitor" || $table == "exclusions" || $table == "pages" || $table == "search" ) ) { $table = FALSE; }
14
-
15
- // Validate the file type the user passed to us.
16
- if( !( $type == "xml" || $type == "csv" || $type == "tsv" ) ) { $table = FALSE; }
17
-
18
- if($table && $type) {
19
-
20
- require($WP_Statistics->plugin_dir . '/includes/classes/php-export-data.class.php');
21
-
22
- $file_name = WPS_EXPORT_FILE_NAME . '-' . $WP_Statistics->Current_Date('Y-m-d-H-i');
23
-
24
- switch($type) {
25
- case 'xml':
26
- $exporter = new ExportDataExcel('browser', "{$file_name}.xml");
27
-
28
- break;
29
- case 'csv':
30
- $exporter = new ExportDataCSV('browser', "{$file_name}.csv");
31
-
32
- break;
33
- case 'tsv':
34
- $exporter = new ExportDataTSV('browser', "{$file_name}.tsv");
35
-
36
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
 
 
 
 
 
 
 
38
 
39
- $exporter->initialize();
40
-
41
- // We need to limit the number of results we retrieve to ensure we don't run out of memory
42
- $query_base = "SELECT * FROM {$wpdb->prefix}statistics_{$table}";
43
- $query = $query_base . ' LIMIT 0,1000';
44
-
45
- $i = 1;
46
- $more_results = true;
47
- $result = $wpdb->get_results($query, ARRAY_A);
48
-
49
- // If we didn't get any rows, don't output anything.
50
- if( count( $result ) < 1 ) { echo "No data in table!"; exit; }
51
-
52
- if( $headers ) {
53
- foreach( $result[0] as $key => $col ) { $columns[] = $key; }
54
- $exporter->addRow($columns);
55
  }
56
-
57
-
58
- while( $more_results ) {
59
- foreach($result as $row) {
60
- $exporter->addRow($row);
61
-
62
- // Make sure we've flushed the output buffer so we don't run out of memory on large exports.
63
- ob_flush();
64
- flush();
65
- }
66
-
67
- unset( $result );
68
- $wpdb->flush();
69
-
70
- $query = $query_base . ' LIMIT ' . ($i * 1000) . ',1000';
71
- $result = $wpdb->get_results($query, ARRAY_A);
72
-
73
- if( count( $result ) == 0 ) { $more_results = false; }
74
-
75
- $i++;
76
  }
77
-
78
- $exporter->finalize();
79
-
80
- exit;
81
  }
 
 
 
 
82
  }
83
  }
 
 
84
  ?>
1
  <?php
2
+ function wp_statistics_export_data() {
3
+ GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
4
+
5
+ $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) );
6
+
7
+ if ( current_user_can( $manage_cap ) ) {
8
+ $table = $_POST['table-to-export'];
9
+ $type = $_POST['export-file-type'];
10
+ $headers = $_POST['export-headers'];
11
+
12
+ // Validate the table name the user passed to us.
13
+ if ( ! ( $table == "useronline" || $table == "visit" || $table == "visitor" || $table == "exclusions" || $table == "pages" || $table == "search" ) ) {
14
+ $table = false;
15
+ }
16
+
17
+ // Validate the file type the user passed to us.
18
+ if ( ! ( $type == "xml" || $type == "csv" || $type == "tsv" ) ) {
19
+ $table = false;
20
+ }
21
+
22
+ if ( $table && $type ) {
23
+
24
+ require( $WP_Statistics->plugin_dir . '/includes/classes/php-export-data.class.php' );
25
+
26
+ $file_name = WPS_EXPORT_FILE_NAME . '-' . $WP_Statistics->Current_Date( 'Y-m-d-H-i' );
27
+
28
+ switch ( $type ) {
29
+ case 'xml':
30
+ $exporter = new ExportDataExcel( 'browser', "{$file_name}.xml" );
31
+
32
+ break;
33
+ case 'csv':
34
+ $exporter = new ExportDataCSV( 'browser', "{$file_name}.csv" );
35
+
36
+ break;
37
+ case 'tsv':
38
+ $exporter = new ExportDataTSV( 'browser', "{$file_name}.tsv" );
39
+
40
+ break;
41
+ }
42
+
43
+ $exporter->initialize();
44
+
45
+ // We need to limit the number of results we retrieve to ensure we don't run out of memory
46
+ $query_base = "SELECT * FROM {$wpdb->prefix}statistics_{$table}";
47
+ $query = $query_base . ' LIMIT 0,1000';
48
+
49
+ $i = 1;
50
+ $more_results = true;
51
+ $result = $wpdb->get_results( $query, ARRAY_A );
52
+
53
+ // If we didn't get any rows, don't output anything.
54
+ if ( count( $result ) < 1 ) {
55
+ echo "No data in table!";
56
+ exit;
57
+ }
58
+
59
+ if ( $headers ) {
60
+ foreach ( $result[0] as $key => $col ) {
61
+ $columns[] = $key;
62
  }
63
+ $exporter->addRow( $columns );
64
+ }
65
+
66
+
67
+ while ( $more_results ) {
68
+ foreach ( $result as $row ) {
69
+ $exporter->addRow( $row );
70
 
71
+ // Make sure we've flushed the output buffer so we don't run out of memory on large exports.
72
+ ob_flush();
73
+ flush();
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
+
76
+ unset( $result );
77
+ $wpdb->flush();
78
+
79
+ $query = $query_base . ' LIMIT ' . ( $i * 1000 ) . ',1000';
80
+ $result = $wpdb->get_results( $query, ARRAY_A );
81
+
82
+ if ( count( $result ) == 0 ) {
83
+ $more_results = false;
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
+
86
+ $i ++;
 
 
87
  }
88
+
89
+ $exporter->finalize();
90
+
91
+ exit;
92
  }
93
  }
94
+ }
95
+
96
  ?>
includes/functions/functions.php CHANGED
@@ -6,1059 +6,1187 @@
6
  the number of rows returned, but you can also use it an a foreach loop to to get the details of the rows.
7
  */
8
 
9
- // This function returns the current users online.
10
- function wp_statistics_useronline() {
11
-
12
- global $wpdb;
13
-
14
- return $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_useronline");
15
- }
16
-
17
- // This function get the visit statistics for a given time frame.
18
- function wp_statistics_visit( $time, $daily = null ) {
19
-
20
- // We need database and the global $WP_Statistics object access.
21
- global $wpdb, $WP_Statistics;
22
-
23
- // If we've been asked to do a daily count, it's a slightly different SQL query, so handle it separately.
24
- if( $daily == true ) {
25
-
26
- // Fetch the results from the database.
27
- $result = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}'" );
28
-
29
- // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case.
30
- if( $result) {
31
- return $result->visit;
32
- } else {
33
- return 0;
34
- }
35
-
36
- } else {
37
-
38
- // This function accepts several options for time parameter, each one has a unique SQL query string.
39
- // They're pretty self explanatory.
40
-
41
- switch( $time ) {
42
- case 'today':
43
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
44
- break;
45
-
46
- case 'yesterday':
47
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'" );
48
- break;
49
-
50
- case 'week':
51
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
52
- break;
53
-
54
- case 'month':
55
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
56
- break;
57
-
58
- case 'year':
59
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
60
- break;
61
-
62
- case 'total':
63
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit" );
64
- $result += $WP_Statistics->Get_Historical_Data( 'visits' );
65
- break;
66
-
67
- default:
68
- $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
69
- break;
70
- }
71
- }
72
 
73
  // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case.
74
- if( $result == null ) { $result = 0; }
75
-
76
- return $result;
77
- }
78
-
79
- // This function gets the visitor statistics for a given time frame.
80
- function wp_statistics_visitor( $time, $daily = null, $countonly = false ) {
81
-
82
- // We need database and the global $WP_Statistics object access.
83
- global $wpdb, $WP_Statistics;
84
-
85
- $history = 0;
86
- $select = '*';
87
- $sqlstatement = '';
88
-
89
- // We often don't need the complete results but just the count of rows, if that's the case, let's have MySQL just count the results for us.
90
- if( $countonly == true ) { $select = 'count(last_counter)'; }
91
-
92
- // If we've been asked to do a daily count, it's a slightly different SQL query, so handle it seperatly.
93
- if( $daily == true ) {
94
-
95
- // Fetch the results from the database.
96
- $result = $wpdb->query( "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}'");
97
-
98
- return $result;
99
-
100
  } else {
101
-
102
- // This function accepts several options for time parameter, each one has a unique SQL query string.
103
- // They're pretty self explanatory.
104
- switch( $time ) {
105
- case 'today':
106
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
107
- break;
108
-
109
- case 'yesterday':
110
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'";
111
- break;
112
-
113
- case 'week':
114
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
115
- break;
116
-
117
- case 'month':
118
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
119
- break;
120
-
121
- case 'year':
122
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
123
- break;
124
-
125
- case 'total':
126
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor";
127
- $history = $WP_Statistics->Get_Historical_Data( 'visitors' );
128
- break;
129
-
130
- default:
131
- $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
132
- break;
133
- }
134
  }
135
 
136
- // Execute the SQL call, if we're only counting we can use get_var(), otherwise we use query().
137
- if( $countonly == true ) {
138
- $result = $wpdb->get_var( $sqlstatement );
139
- $result += $history;
140
- }
141
- else {
142
- $result = $wpdb->query( $sqlstatement );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
-
145
- return $result;
146
  }
147
 
148
- // This function returns the statistics for a given page.
149
- function wp_statistics_pages( $time, $page_uri = '', $id = -1, $rangestartdate = null, $rangeenddate = null ) {
150
-
151
- // We need database and the global $WP_Statistics object access.
152
- global $wpdb, $WP_Statistics;
153
-
154
- $history = 0;
155
- $sqlstatement = '';
156
-
157
- // If no page URI has been passed in, get the current page URI.
158
- if( $page_uri == '' ) { $page_uri = wp_statistics_get_uri(); }
159
-
160
- $page_uri_sql = esc_sql( $page_uri );
161
-
162
- // If a page/post ID has been passed, use it to select the rows, otherwise use the URI.
163
- // Note that a single page/post ID can have multiple URI's associated with it.
164
- if( $id != -1 ) {
165
- $page_sql = '`id` = ' . $id;
166
- $history_key = 'page';
167
- $history_id = $id;
168
- } else {
169
- $page_sql = "`URI` = '{$page_uri_sql}'";
170
- $history_key = 'uri';
171
- $history_id = $page_uri;
172
- }
 
 
 
 
 
 
 
173
 
174
  // This function accepts several options for time parameter, each one has a unique SQL query string.
175
  // They're pretty self explanatory.
176
- switch($time) {
177
  case 'today':
178
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
179
  break;
180
-
181
  case 'yesterday':
182
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$page_sql}";
183
  break;
184
-
185
  case 'week':
186
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
187
  break;
188
-
189
  case 'month':
190
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
191
  break;
192
-
193
  case 'year':
194
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
195
  break;
196
-
197
  case 'total':
198
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE {$page_sql}";
199
- $history = $WP_Statistics->Get_Historical_Data( $history_key, $history_id );
200
- break;
201
- case 'range':
202
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '" . $WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangestartdate ) ) . "' AND '" . $WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangeenddate ) ) . "' AND {$page_sql}";
203
-
204
  break;
 
205
  default:
206
- $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$page_sql}";
207
  break;
208
  }
 
209
 
210
- // Since this function only every returns a count, just use get_var().
 
211
  $result = $wpdb->get_var( $sqlstatement );
212
  $result += $history;
213
-
214
- // If we have an empty result, return 0 instead of a blank.
215
- if( $result == '' ) { $result = 0; }
216
-
217
- return $result;
218
  }
219
-
220
- // This function converts a page URI to a page/post ID. It does this by looking up in the pages database
221
- // the URI and getting the associated ID. This will only work if the page has been visited at least once.
222
- function wp_statistics_uri_to_id( $uri ) {
223
- global $wpdb;
224
-
225
- // Create the SQL query to use.
226
- $sqlstatement = $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}statistics_pages WHERE `URI` = %s AND id > 0 ORDER BY date DESC", $uri );
227
-
228
- // Execute the query.
229
- $result = $wpdb->get_var( $sqlstatement );
230
-
231
- // If we returned a false or some other 0 equivalent value, make sure $result is set to an integer 0.
232
- if( $result == 0 ) { $result = 0; }
233
-
234
- return $result;
235
  }
236
-
237
- // We need a quick function to pass to usort to properly sort the most popular pages.
238
- function wp_stats_compare_uri_hits( $a, $b ) {
239
- return $a[1] < $b[1];
 
 
 
 
 
 
 
 
 
240
  }
241
-
242
- // This function returns a multi-dimensional array, with the total number of pages and an array or URI's sorted in order with their URI, count, id and title.
243
- function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = null ) {
244
- global $wpdb;
245
-
246
- // Get every unique URI from the pages database.
247
- if( $rangestartdate != null && $rangeenddate != null ) {
248
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N);
249
- } else {
250
- $result = $wpdb->get_results( "SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N );
251
- }
252
 
253
- $total = 0;
254
- $uris = array();
255
-
256
- // Now get the total page visit count for each unique URI.
257
- foreach( $result as $out ) {
258
- // Increment the total number of results.
259
- $total ++;
260
-
261
- // Retreive the post ID for the URI.
262
- $id = wp_statistics_uri_to_id( $out[0] );
263
-
264
- // Lookup the post title.
265
- $post = get_post($id);
266
-
267
- if( is_object( $post ) ) {
268
- $title = $post->post_title;
269
- }
270
- else {
271
- if( $out[0] == '/' ) {
272
- $title = get_bloginfo();
273
- }
274
- else {
275
- $title = '';
276
- }
277
- }
278
 
279
- // Add the current post to the array.
280
- if( $rangestartdate != null && $rangeenddate != null ) {
281
- $uris[] = array( $out[0], wp_statistics_pages( 'range', $out[0], -1, $rangestartdate, $rangeenddate ), $id, $title );
282
- } else {
283
- $uris[] = array( $out[0], wp_statistics_pages( 'total', $out[0] ), $id, $title );
284
- }
285
- }
 
 
 
 
286
 
287
- // If we have more than one result, let's sort them using usort.
288
- if( count( $uris ) > 1 ) {
289
- // Sort the URI's based on their hit count.
290
- usort( $uris, 'wp_stats_compare_uri_hits');
291
- }
292
-
293
- return array( $total, $uris );
 
 
 
 
 
 
 
 
294
  }
295
-
296
- // This function gets the current page URI.
297
- function wp_statistics_get_uri() {
298
- // Get the site's path from the URL.
299
- $site_uri = parse_url( site_url(), PHP_URL_PATH );
300
- $site_uri_len = strlen( $site_uri );
301
-
302
- // Get the site's path from the URL.
303
- $home_uri = parse_url( home_url(), PHP_URL_PATH );
304
- $home_uri_len = strlen( $home_uri );
305
-
306
- // Get the current page URI.
307
- $page_uri = $_SERVER["REQUEST_URI"];
308
-
309
- /*
310
- * We need to check which URI is longer in case one contains the other.
311
- *
312
- * For example home_uri might be "/site/wp" and site_uri might be "/site".
313
- *
314
- * In that case we want to check to see if the page_uri starts with "/site/wp" before
315
- * we check for "/site", but in the reverse case, we need to swap the order of the check.
316
- */
317
- if( $site_uri_len > $home_uri_len ) {
318
- if( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
319
- $page_uri = substr( $page_uri, $site_uri_len );
320
- }
321
-
322
- if( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
323
- $page_uri = substr( $page_uri, $home_uri_len );
324
- }
325
- } else {
326
- if( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
327
- $page_uri = substr( $page_uri, $home_uri_len );
328
- }
329
 
330
- if( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
331
- $page_uri = substr( $page_uri, $site_uri_len );
332
- }
333
- }
334
-
335
- // If we're at the root (aka the URI is blank), let's make sure to indicate it.
336
- if( $page_uri == '' ) { $page_uri = '/'; }
337
-
338
- return $page_uri;
339
  }
340
-
341
- // This function returns all unique user agents in the database.
342
- function wp_statistics_ua_list( $rangestartdate = null, $rangeenddate = null ) {
343
-
344
- global $wpdb;
345
-
346
- if( $rangestartdate != null && $rangeenddate != null ) {
347
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor AND `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N);
348
- } else {
349
- $result = $wpdb->get_results( "SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor", ARRAY_N);
350
- }
351
 
352
- $Browers = array();
353
-
354
- foreach( $result as $out )
355
- {
356
- $Browsers[] = $out[0];
357
- }
358
-
359
- return $Browsers;
 
 
 
 
 
 
 
 
 
360
  }
361
-
362
- // This function returns the count of a given user agent in the database.
363
- function wp_statistics_useragent( $agent, $rangestartdate = null, $rangeenddate = null ) {
364
-
365
- global $wpdb;
366
-
367
- if( $rangestartdate != null && $rangeenddate != null ) {
368
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate ) );
369
- } else {
370
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent ) );
371
- }
372
-
373
- return $result;
 
 
 
 
 
374
  }
375
 
376
- // This function returns all unique platform types from the database.
377
- function wp_statistics_platform_list( $rangestartdate = null, $rangeenddate = null ) {
378
-
379
- global $wpdb;
380
-
381
- if( $rangestartdate != null && $rangeenddate != null ) {
382
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N);
 
 
 
 
 
 
 
 
 
383
  } else {
384
- $result = $wpdb->get_results("SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor", ARRAY_N);
385
- }
386
-
387
- $Platforms = array();
388
-
389
- foreach( $result as $out )
390
- {
391
- $Platforms[] = $out[0];
392
  }
393
-
394
- return $Platforms;
395
- }
396
 
397
- // This function returns the count of a given platform in the database.
398
- function wp_statistics_platform( $platform, $rangestartdate = null, $rangeenddate = null ) {
399
-
400
- global $wpdb;
401
-
402
- if( $rangestartdate != null && $rangeenddate != null ) {
403
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(platform) FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s AND `last_counter` BETWEEN %s AND %s", $platform, $rangestartdate, $rangeenddate ) );
 
404
  } else {
405
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(platform) FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform ) );
406
  }
407
-
408
- return $result;
409
  }
410
-
411
- // This function returns all unique versions for a given agent from the database.
412
- function wp_statistics_agent_version_list( $agent, $rangestartdate = null, $rangeenddate = null ) {
413
-
414
- global $wpdb;
415
-
416
- if( $rangestartdate != null && $rangeenddate != null ) {
417
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate ), ARRAY_N );
418
- } else {
419
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s", $agent ), ARRAY_N );
420
- }
421
-
422
- $Versions = array();
423
-
424
- foreach( $result as $out )
425
- {
426
- $Versions[] = $out[0];
427
- }
428
-
429
- return $Versions;
430
  }
431
 
432
- // This function returns the statistcs for a given agent/version pair from the database.
433
- function wp_statistics_agent_version( $agent, $version, $rangestartdate = null, $rangeenddate = null ) {
434
-
435
- global $wpdb;
436
-
437
- if( $rangestartdate != null && $rangeenddate != null ) {
438
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(version) FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND version = %s AND `last_counter` BETWEEN %s AND %s", $agent, $version, $rangestartdate, $rangeenddate ) );
439
- } else {
440
- $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(version) FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND version = %s", $agent, $version ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  }
442
-
443
- return $result;
444
  }
445
 
446
- // This function returns an array or array's which define what search engines we should look for.
447
- //
448
- // By default will only return ones that have not been disabled by the user, this can be overridden by the $all parameter.
449
- //
450
- // Each sub array is made up of the following items:
451
- // name = The proper name of the search engine
452
- // translated = The proper name translated to the local language
453
- // tag = a short one word, all lower case, representation of the search engine
454
- // sqlpattern = either a single SQL style search pattern OR an array or search patterns to match the hostname in a URL against
455
- // regexpattern = either a single regex style search pattern OR an array or search patterns to match the hostname in a URL against
456
- // querykey = the URL key that contains the search string for the search engine
457
- // image = the name of the image file to associate with this search engine (just the filename, no path info)
458
- //
459
- function wp_statistics_searchengine_list( $all = false ) {
460
- GLOBAL $WP_Statistics;
461
-
462
- $default = $engines = array (
463
- 'ask' => array( 'name' => 'Ask.com', 'translated' => __( 'Ask.com', 'wp_statistics' ), 'tag' => 'ask', 'sqlpattern' => '%ask.com%', 'regexpattern' => 'ask\.com', 'querykey' => 'q', 'image' => 'ask.png' ),
464
- 'baidu' => array( 'name' => 'Baidu', 'translated' => __( 'Baidu', 'wp_statistics' ), 'tag' => 'baidu', 'sqlpattern' => '%baidu.com%', 'regexpattern' => 'baidu\.com', 'querykey' => 'wd', 'image' => 'baidu.png' ),
465
- 'bing' => array( 'name' => 'Bing', 'translated' => __( 'Bing', 'wp_statistics' ), 'tag' => 'bing', 'sqlpattern' => '%bing.com%', 'regexpattern' => 'bing\.com', 'querykey' => 'q', 'image' => 'bing.png' ),
466
- 'clearch' => array( 'name' => 'clearch.org', 'translated' => __( 'clearch.org', 'wp_statistics' ), 'tag' => 'clearch', 'sqlpattern' => '%clearch.org%', 'regexpattern' => 'clearch\.org', 'querykey' => 'q', 'image' => 'clearch.png' ),
467
- 'duckduckgo' => array( 'name' => 'DuckDuckGo', 'translated' => __( 'DuckDuckGo', 'wp_statistics' ), 'tag' => 'duckduckgo', 'sqlpattern' => array('%duckduckgo.com%', '%ddg.gg%' ), 'regexpattern' => array('duckduckgo\.com','ddg\.gg' ), 'querykey' => 'q', 'image' => 'duckduckgo.png' ),
468
- 'google' => array( 'name' => 'Google', 'translated' => __( 'Google', 'wp_statistics' ), 'tag' => 'google', 'sqlpattern' => '%google.%', 'regexpattern' => 'google\.', 'querykey' => 'q', 'image' => 'google.png' ),
469
- 'yahoo' => array( 'name' => 'Yahoo!', 'translated' => __( 'Yahoo!', 'wp_statistics' ), 'tag' => 'yahoo', 'sqlpattern' => '%yahoo.com%', 'regexpattern' => 'yahoo\.com', 'querykey' => 'p', 'image' => 'yahoo.png' ),
470
- 'yandex' => array( 'name' => 'Yandex', 'translated' => __( 'Yandex', 'wp_statistics' ), 'tag' => 'yandex', 'sqlpattern' => '%yandex.ru%', 'regexpattern' => 'yandex\.ru', 'querykey' => 'text', 'image' => 'yandex.png' )
471
- );
472
-
473
- if( $all == false ) {
474
- foreach( $engines as $key => $engine ) {
475
- if( $WP_Statistics->get_option( 'disable_se_' . $engine['tag'] ) ) { unset( $engines[$key] ); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  }
 
477
 
478
- // If we've disabled all the search engines, reset the list back to default.
479
- if( count( $engines ) == 0 ) { $engines = $default; }
 
480
  }
481
-
482
- return $engines;
483
  }
484
 
485
- // This function will return the SQL WHERE clause for getting the search words for a given search engine.
486
- function wp_statistics_searchword_query( $search_engine = 'all' ) {
487
- GLOBAL $WP_Statistics;
488
-
489
- // Get a complete list of search engines
490
- $searchengine_list = wp_statistics_searchengine_list();
491
- $search_query = '';
492
-
493
- if( $WP_Statistics->get_option( 'search_converted' ) ) {
494
- // Are we getting results for all search engines or a specific one?
495
- if( strtolower( $search_engine ) == 'all' ) {
496
- // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
497
- foreach( $searchengine_list as $key => $se ) {
498
- $search_query .= "( `engine` = '{$key}' AND `words` <> '' ) OR ";
499
- }
500
-
501
- // Trim off the last ' OR ' for the loop above.
502
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
503
- } else {
504
- $search_query .= "`engine` = '{$search_engine}' AND `words` <> ''";
505
  }
 
 
 
506
  } else {
507
- // Are we getting results for all search engines or a specific one?
508
- if( strtolower( $search_engine ) == 'all' ) {
509
- // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
510
- // NOTE: This SQL query can be *VERY* long.
511
- foreach( $searchengine_list as $se ) {
512
- // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
513
- if( is_array( $se['sqlpattern'] ) ) {
514
- foreach( $se['sqlpattern'] as $subse ) {
515
- $search_query .= "(`referred` LIKE '{$subse}{$se['querykey']}=%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=') OR ";
516
- }
517
- } else {
518
- $search_query .= "(`referred` LIKE '{$se['sqlpattern']}{$se['querykey']}=%' AND `referred` NOT LIKE '{$se['sqlpattern']}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$se['sqlpattern']}{$se['querykey']}=') OR ";
519
- }
520
- }
521
-
522
- // Trim off the last ' OR ' for the loop above.
523
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
524
- } else {
525
- // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
526
- if( is_array( $searchengine_list[$search_engine]['sqlpattern'] ) ) {
527
- foreach( $searchengine_list[$search_engine]['sqlpattern'] as $se ) {
528
- $search_query .= "(`referred` LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=%' AND `referred` NOT LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=&%' AND `referred` NOT LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=') OR ";
529
  }
530
-
531
- // Trim off the last ' OR ' for the loop above.
532
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
533
  } else {
534
- $search_query .= "(`referred` LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=%' AND `referred` NOT LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=&%' AND `referred` NOT LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=')";
535
  }
536
  }
537
- }
538
-
539
- return $search_query;
540
- }
541
 
542
- // This function will return the SQL WHERE clause for getting the search engine.
543
- function wp_statistics_searchengine_query( $search_engine = 'all' ) {
544
- GLOBAL $WP_Statistics;
545
-
546
- // Get a complete list of search engines
547
- $searchengine_list = wp_statistics_searchengine_list();
548
- $search_query = '';
549
-
550
- if( $WP_Statistics->get_option( 'search_converted' ) ) {
551
- // Are we getting results for all search engines or a specific one?
552
- if( strtolower( $search_engine ) == 'all' ) {
553
- // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
554
- foreach( $searchengine_list as $key => $se ) {
555
- $search_query .= "`engine` = '{$key}' OR ";
556
- }
557
-
558
- // Trim off the last ' OR ' for the loop above.
559
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
560
- } else {
561
- $search_query .= "`engine` = '{$search_engine}'";
562
- }
563
  } else {
564
- // Are we getting results for all search engines or a specific one?
565
- if( strtolower( $search_engine ) == 'all' ) {
566
- // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
567
- // NOTE: This SQL query can be long.
568
- foreach( $searchengine_list as $se ) {
569
- // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
570
- if( is_array( $se['sqlpattern'] ) ) {
571
- foreach( $se['sqlpattern'] as $subse ) {
572
- $search_query .= "`referred` LIKE '{$subse}' OR ";
573
- }
574
- } else {
575
- $search_query .= "`referred` LIKE '{$se['sqlpattern']}' OR ";
576
- }
577
  }
578
-
579
  // Trim off the last ' OR ' for the loop above.
580
  $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
581
  } else {
582
- // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
583
- if( is_array( $searchengine_list[$search_engine]['sqlpattern'] ) ) {
584
- foreach( $searchengine_list[$search_engine]['sqlpattern'] as $se ) {
585
- $search_query .= "`referred` LIKE '{$se}' OR ";
586
- }
587
-
588
- // Trim off the last ' OR ' for the loop above.
589
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
590
- }
591
- else {
592
- $search_query .= "`referred` LIKE '{$searchengine_list[$search_engine]['sqlpattern']}'";
593
- }
594
  }
595
  }
596
-
597
- return $search_query;
598
  }
599
 
600
- // This function will return a regular expression clause for matching one or more search engines.
601
- function wp_statistics_searchengine_regex( $search_engine = 'all' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
 
603
- // Get a complete list of search engines
604
- $searchengine_list = wp_statistics_searchengine_list();
605
- $search_query = '';
606
-
 
 
607
  // Are we getting results for all search engines or a specific one?
608
- if( strtolower( $search_engine ) == 'all' ) {
609
- foreach( $searchengine_list as $se ) {
 
 
610
  // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
611
- if( is_array( $se['regexpattern'] ) ) {
612
- foreach( $se['regexpattern'] as $subse ) {
613
- $search_query .= "{$subse}|";
614
  }
615
  } else {
616
- $search_query .= "{$se['regexpattern']}|";
617
  }
618
  }
619
-
620
- // Trim off the last '|' for the loop above.
621
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
622
  } else {
623
  // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
624
- if( is_array( $searchengine_list[$search_engine]['regexpattern'] ) ) {
625
- foreach( $searchengine_list[$search_engine]['regexpattern'] as $se ) {
626
- $search_query .= "{$se}|";
627
  }
628
 
629
- // Trim off the last '|' for the loop above.
630
- $search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
631
  } else {
632
- $search_query .= $searchengine_list[$search_engine]['regexpattern'];
633
  }
634
  }
635
-
636
- // Add the brackets and return
637
- return "({$search_query})";
638
  }
639
 
640
- // This function will return the statistics for a given search engine.
641
- function wp_statistics_searchengine( $search_engine = 'all', $time = 'total' ) {
642
-
643
- global $wpdb, $WP_Statistics;
644
 
645
- // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
646
- $tablename = $wpdb->prefix . 'statistics_';
647
-
648
- if( $WP_Statistics->get_option('search_converted') ) {
649
- $tablename .= 'search';
650
- } else {
651
- $tablename .= 'visitor';
652
- }
653
 
654
- // Get a complete list of search engines
655
- $search_query = wp_statistics_searchengine_query( $search_engine );
 
656
 
657
- // This function accepts several options for time parameter, each one has a unique SQL query string.
658
- // They're pretty self explanatory.
659
- switch( $time ) {
660
- case 'today':
661
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}");
662
- break;
663
-
664
- case 'yesterday':
665
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}");
666
-
667
- break;
668
-
669
- case 'week':
670
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}");
671
-
672
- break;
673
-
674
- case 'month':
675
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}");
676
-
677
- break;
678
-
679
- case 'year':
680
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}");
681
-
682
- break;
683
-
684
- case 'total':
685
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}");
686
-
687
- break;
688
-
689
- default:
690
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time)}' AND {$search_query}");
691
-
692
- break;
693
  }
694
-
695
- return $result;
696
- }
697
 
698
- // This function will return the statistics for a given search engine for a given time frame.
699
- function wp_statistics_searchword( $search_engine = 'all', $time = 'total' ) {
700
-
701
- global $wpdb, $WP_Statistics;
 
 
 
 
702
 
703
- // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
704
- $tablename = $wpdb->prefix . 'statistics_';
705
-
706
- if( $WP_Statistics->get_option( 'search_converted' ) ) {
707
- $tablename .= 'search';
708
  } else {
709
- $tablename .= 'visitor';
710
  }
 
711
 
712
- // Get a complete list of search engines
713
- $search_query = wp_statistics_searchword_query( $search_engine );
 
714
 
715
- // This function accepts several options for time parameter, each one has a unique SQL query string.
716
- // They're pretty self explanatory.
717
- switch( $time ) {
718
- case 'today':
719
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}");
720
- break;
721
-
722
- case 'yesterday':
723
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}");
724
-
725
- break;
726
-
727
- case 'week':
728
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}");
729
-
730
- break;
731
-
732
- case 'month':
733
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}");
734
-
735
- break;
736
-
737
- case 'year':
738
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}");
739
-
740
- break;
741
-
742
- case 'total':
743
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}");
744
-
745
- break;
746
-
747
- default:
748
- $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$search_query}");
749
-
750
- break;
751
- }
752
-
753
- return $result;
754
  }
755
 
756
- // This function will return the total number of posts in WordPress.
757
- function wp_statistics_countposts() {
758
-
759
- $count_posts = wp_count_posts( 'post' );
760
-
761
- $ret = 0;
762
-
763
- if( is_object( $count_posts ) ) { $ret = $count_posts->publish; }
764
-
765
- return $ret;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  }
767
 
768
- // This function will return the total number of pages in WordPress.
769
- function wp_statistics_countpages() {
770
-
771
- $count_pages = wp_count_posts( 'page' );
772
-
773
- $ret = 0;
774
-
775
- if( is_object( $count_pages ) ) { $ret = $count_pages->publish; }
776
-
777
- return $ret;
 
 
 
 
 
778
  }
779
 
780
- // This function will return the total number of comments in WordPress.
781
- function wp_statistics_countcomment() {
782
-
783
- global $wpdb;
784
-
785
- $countcomms = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
786
-
787
- return $countcomms;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
788
  }
789
 
790
- // This function will return the total number of spam comments *IF* akismet is installed.
791
- function wp_statistics_countspam() {
792
-
793
- return number_format_i18n( get_option( 'akismet_spam_count' ) );
 
 
 
 
 
 
 
 
794
  }
795
 
796
- // This function will return the total number of users in WordPress.
797
- function wp_statistics_countusers() {
798
-
799
- $result = count_users();
800
- return $result['total_users'];
 
 
 
 
 
 
 
801
  }
802
 
803
- // This function will return the last date a post was published on your site.
804
- function wp_statistics_lastpostdate() {
805
-
806
- global $wpdb, $WP_Statistics;
807
-
808
- $db_date = $wpdb->get_var( "SELECT post_date FROM {$wpdb->posts} WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1" );
809
-
810
- $date_format = get_option( 'date_format' );
811
-
812
- return $WP_Statistics->Current_Date_i18n( $date_format, $db_date, false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  }
814
-
815
- // This function will return the average number of posts per day that are published on your site.
816
- // Alternatively if $days is set to true it returns the average number of days between posts on your site.
817
- function wp_statistics_average_post( $days = false ) {
818
-
819
- global $wpdb;
820
-
821
- $get_first_post = $wpdb->get_var( "SELECT post_date FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date LIMIT 1" );
822
- $get_total_post = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post'" );
823
-
824
- $days_spend = intval( ( time() - strtotime( $get_first_post ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
825
-
826
- if( $days == true ) {
827
- if( $get_total_post == 0 ) { $get_total_post = 1; } // Avoid divide by zero errors.
828
- return round( $days_spend / $get_total_post, 0 );
829
- }
830
- else {
831
- if( $days_spend == 0 ) { $days_spend = 1; } // Avoid divide by zero errors.
832
- return round( $get_total_post / $days_spend, 2 );
833
- }
 
 
 
 
 
834
  }
 
835
 
836
- // This function will return the average number of comments per day that are published on your site.
837
- // Alternatively if $days is set to true it returns the average number of days between comments on your site.
838
- function wp_statistics_average_comment( $days = false ) {
839
-
840
- global $wpdb;
841
-
842
- $get_first_comment = $wpdb->get_var( "SELECT comment_date FROM {$wpdb->comments} ORDER BY comment_date LIMIT 1" );
843
- $get_total_comment = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
844
-
845
- $days_spend = intval( ( time() - strtotime( $get_first_comment ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
846
-
847
- if( $days == true ) {
848
- if( $get_total_comment == 0 ) { $get_total_comment = 1; } // Avoid divide by zero errors.
849
- return round( $days_spend / $get_total_comment, 0 );
850
- }
851
- else {
852
- if( $days_spend == 0 ) { $days_spend = 1; } // Avoid divide by zero errors.
853
- return round( $get_total_comment / $days_spend, 2 );
854
- }
 
 
 
 
855
  }
 
856
 
857
- // This function will return the average number of users per day that are registered on your site.
858
- // Alternatively if $days is set to true it returns the average number of days between user registrations on your site.
859
- function wp_statistics_average_registeruser( $days = false ) {
860
-
861
- global $wpdb;
862
-
863
- $get_first_user = $wpdb->get_var( "SELECT user_registered FROM {$wpdb->users} ORDER BY user_registered LIMIT 1" );
864
- $get_total_user = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}" );
865
-
866
- $days_spend = intval( ( time() - strtotime( $get_first_user ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
867
-
868
- if( $days == true ) {
869
- if( $get_total_user == 0 ) { $get_total_user = 1; } // Avoid divide by zero errors.
870
- return round( $days_spend / $get_total_user, 0 );
871
- }
872
- else {
873
- if( $days_spend == 0 ) { $days_spend = 1; } // Avoid divide by zero errors.
874
- return round( $get_total_user / $days_spend, 2 );
875
- }
876
  }
877
-
878
- // This function handle's the dashicons in the overview page.
879
- function wp_statistics_icons( $dashicons, $icon_name = null ) {
880
-
881
- global $wp_version;
882
-
883
- if( null == $icon_name ) { $icon_name = $dashicons; }
884
-
885
- // Since versions of WordPress before 3.8 didn't have dashicons, don't use them in those versions.
886
- if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) {
887
- return '<span class="dashicons ' . $dashicons . '"></span>';
888
- } else {
889
- return '<img src="' . plugins_url('wp-statistics/assets/images/') . $icon_name . '.png"/>';
890
- }
891
  }
892
-
893
- // This function checks to see if all the PHP modules we need for GeoIP exists.
894
- function wp_statistics_geoip_supported() {
895
- // Check to see if we can support the GeoIP code, requirements are:
896
- $enabled = true;
897
-
898
- // PHP 5.3
899
- if( ! version_compare( phpversion(), WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION, '>' ) ) { $enabled = false; }
900
-
901
- // PHP's cURL extension installed
902
- if( ! function_exists( 'curl_init' ) ) { $enabled = false; }
903
-
904
- // PHP NOT running in safe mode
905
- if( ini_get('safe_mode') ) {
906
- // Double check php version, 5.4 and above don't support safe mode but the ini value may still be set after an upgrade.
907
- if( ! version_compare( phpversion(), '5.4', '<' ) ) { $enabled = false; }
908
- }
909
-
910
- return $enabled;
911
  }
912
-
913
- // This function creates the date range selector 'widget' used in the various statistics pages.
914
- function wp_statistics_date_range_selector( $page, $current, $range = array(), $desc = array(), $extrafields = '', $pre_extra = '', $post_extra = '' ) {
915
- GLOBAL $WP_Statistics;
916
-
917
- wp_enqueue_script( 'jquery-ui-datepicker' );
918
- wp_register_style( 'jquery-ui-smoothness-css', $WP_Statistics->plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' );
919
- wp_enqueue_style( 'jquery-ui-smoothness-css' );
920
-
921
- if( count( $range ) == 0 ) {
922
- $range = array( 10, 20, 30, 60, 90, 180, 270, 365 );
923
- $desc = array( __( '10 Days', 'wp_statistics' ), __( '20 Days', 'wp_statistics' ), __( '30 Days', 'wp_statistics' ), __( '2 Months', 'wp_statistics' ), __( '3 Months', 'wp_statistics' ), __( '6 Months', 'wp_statistics' ), __( '9 Months', 'wp_statistics' ), __( '1 Year', 'wp_statistics' ) );
924
- }
925
-
926
- if( count( $desc ) == 0 ) {
927
- $desc = $range;
928
- }
929
-
930
- $rcount = count( $range );
931
-
932
- $bold = true;
933
 
934
- // Check to see if there's a range in the URL, if so set it, otherwise use the default.
935
- if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current ); }
936
- if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = $WP_Statistics->Current_Date( 'm/d/Y' ); }
 
937
 
938
- // Convert the text dates to unix timestamps and do some basic sanity checking.
939
- $rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
940
- if( false === $rangestart_utime ) { $rangestart_utime = time(); }
941
- $rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
942
- if( false === $rangeend_utime || $rangeend_utime < $rangestart_utime ) { $rangeend_utime = time(); }
943
-
944
- // Now get the number of days in the range.
945
- $daysToDisplay = (int)( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
946
- $today = $WP_Statistics->Current_Date( 'm/d/Y' );
947
-
948
- // Re-create the range start/end strings from our utime's to make sure we get ride of any cruft and have them in the format we want.
949
- $rangestart = $WP_Statistics->Local_Date( 'm/d/Y', $rangestart_utime );
950
- $rangeend = $WP_Statistics->Local_Date( 'm/d/Y', $rangeend_utime );
951
-
952
- // If the rangeend isn't today OR it is but not one of the standard range values, then it's a custom selected value and we need to flag it as such.
953
- if( $rangeend != $today || ( $rangeend == $today && ! in_array( $current, $range ) ) ) {
954
- $current = -1;
955
- } else {
956
- // If on the other hand we are a standard range, let's reset the custom range selector to match it.
957
- $rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
958
- $rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
959
- }
960
-
961
- echo '<form method="get"><ul class="subsubsub">' . "\r\n";
962
-
963
- // Output any extra HTML we've been passed after the form element but before the date selector.
964
- echo $pre_extra;
965
-
966
- for( $i = 0; $i < $rcount; $i ++ ) {
967
- echo ' <li class="all"><a ';
968
-
969
- if( $current == $range[$i] ) { echo 'class="current" '; $bold = false;}
970
-
971
- // Don't bother adding he date range to the standard links as they're not needed any may confuse the custom range selector.
972
- echo 'href="?page=' . $page . '&hitdays=' . $range[$i] . esc_url($extrafields) . '">' . $desc[$i] . '</a></li>';
973
-
974
- if( $i < $rcount - 1 ) {
975
- echo ' | ';
976
- }
977
-
978
- echo "\r\n";
979
- }
980
-
981
- echo ' | ';
982
-
983
- echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $page . '">';
984
-
985
- parse_str( $extrafields, $parse );
986
-
987
- foreach( $parse as $key => $value ) {
988
- echo '<input type="hidden" name="' . $key . '" value="' . esc_url($value) . '">';
989
  }
990
-
991
- if( $bold ) {
992
- echo ' <b>' . __( 'Range', 'wp_statistics' ) . ':</b> ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
993
  }
994
- else {
995
- echo ' ' . __( 'Range', 'wp_statistics' ) . ': ';
 
 
 
 
996
  }
997
-
998
- 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";
999
-
1000
- // Output any extra HTML we've been passed after the date selector but before the submit button.
1001
- echo $post_extra;
1002
-
1003
- echo '</form>' . "\r\n";
1004
-
1005
- echo '<script>jQuery(function() { jQuery( "#datestartpicker" ).datepicker(); jQuery( "#dateendpicker" ).datepicker(); });</script>' . "\r\n";
1006
  }
1007
-
1008
- // This function is used to calculate the number of days and thier respective unix timestamps.
1009
- function wp_statistics_date_range_calculator( $days, $start, $end ) {
1010
- GLOBAL $WP_Statistics;
1011
-
1012
- $daysToDisplay = $days;
1013
- $rangestart = $start;
1014
- $rangeend = $end;
1015
-
1016
- if( $daysToDisplay == -1 ) {
1017
- $rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
1018
- $rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
1019
- $daysToDisplay = (int)( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
1020
-
1021
- if( $rangestart_utime == FALSE || $rangeend_utime == FALSE ) {
1022
- $daysToDisplay = 20;
1023
- $rangeend_utime = $WP_Statistics->timetz();
1024
- $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1025
- }
1026
- }
1027
- else {
1028
- $rangeend_utime = $WP_Statistics->timetz();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1029
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1030
  }
1031
-
1032
- return array( $daysToDisplay, $rangestart_utime, $rangeend_utime );
 
1033
  }
1034
-
1035
- // This function will empty a table based on the table name.
1036
- function wp_statitiscs_empty_table( $table_name = FALSE ) {
1037
- global $wpdb;
1038
-
1039
- if( $table_name ) {
1040
- $result = $wpdb->query( 'DELETE FROM ' . $table_name );
1041
-
1042
- if($result) {
1043
- return sprintf( __( '%s table data deleted successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
1044
- }
1045
- }
1046
 
1047
- return sprintf( __( 'Error, %s not emptied!', 'wp_statistics' ), $table_name );
1048
- }
 
 
 
 
1049
 
1050
- // This function creates a small JavaScript snipit that will load the contents of a overview or dashboard widget.
1051
- function wp_statistics_generate_widget_load_javascript( $widget, $container_id = null ) {
1052
- if( null == $container_id ) {
1053
- $container_id = str_replace( '.', '_', $widget . '_postbox' );
 
1054
  }
1055
- ?>
1056
- <script type="text/javascript">
1057
- jQuery(document).ready(function() {
1058
- wp_statistics_get_widget_contents( '<?php echo $widget; ?>', '<?php echo $container_id; ?>' );
1059
- });
1060
- </script>
1061
- <?php
1062
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1063
 
1064
 
6
  the number of rows returned, but you can also use it an a foreach loop to to get the details of the rows.
7
  */
8
 
9
+ // This function returns the current users online.
10
+ function wp_statistics_useronline() {
11
+
12
+ global $wpdb;
13
+
14
+ return $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_useronline" );
15
+ }
16
+
17
+ // This function get the visit statistics for a given time frame.
18
+ function wp_statistics_visit( $time, $daily = null ) {
19
+
20
+ // We need database and the global $WP_Statistics object access.
21
+ global $wpdb, $WP_Statistics;
22
+
23
+ // If we've been asked to do a daily count, it's a slightly different SQL query, so handle it separately.
24
+ if ( $daily == true ) {
25
+
26
+ // Fetch the results from the database.
27
+ $result = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}'" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case.
30
+ if ( $result ) {
31
+ return $result->visit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  } else {
33
+ return 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
+ } else {
37
+
38
+ // This function accepts several options for time parameter, each one has a unique SQL query string.
39
+ // They're pretty self explanatory.
40
+
41
+ switch ( $time ) {
42
+ case 'today':
43
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
44
+ break;
45
+
46
+ case 'yesterday':
47
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'" );
48
+ break;
49
+
50
+ case 'week':
51
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
52
+ break;
53
+
54
+ case 'month':
55
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
56
+ break;
57
+
58
+ case 'year':
59
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
60
+ break;
61
+
62
+ case 'total':
63
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit" );
64
+ $result += $WP_Statistics->Get_Historical_Data( 'visits' );
65
+ break;
66
+
67
+ default:
68
+ $result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
69
+ break;
70
  }
 
 
71
  }
72
 
73
+ // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case.
74
+ if ( $result == null ) {
75
+ $result = 0;
76
+ }
77
+
78
+ return $result;
79
+ }
80
+
81
+ // This function gets the visitor statistics for a given time frame.
82
+ function wp_statistics_visitor( $time, $daily = null, $countonly = false ) {
83
+
84
+ // We need database and the global $WP_Statistics object access.
85
+ global $wpdb, $WP_Statistics;
86
+
87
+ $history = 0;
88
+ $select = '*';
89
+ $sqlstatement = '';
90
+
91
+ // We often don't need the complete results but just the count of rows, if that's the case, let's have MySQL just count the results for us.
92
+ if ( $countonly == true ) {
93
+ $select = 'count(last_counter)';
94
+ }
95
+
96
+ // If we've been asked to do a daily count, it's a slightly different SQL query, so handle it seperatly.
97
+ if ( $daily == true ) {
98
+
99
+ // Fetch the results from the database.
100
+ $result = $wpdb->query( "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}'" );
101
+
102
+ return $result;
103
+
104
+ } else {
105
 
106
  // This function accepts several options for time parameter, each one has a unique SQL query string.
107
  // They're pretty self explanatory.
108
+ switch ( $time ) {
109
  case 'today':
110
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
111
  break;
112
+
113
  case 'yesterday':
114
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'";
115
  break;
116
+
117
  case 'week':
118
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
119
  break;
120
+
121
  case 'month':
122
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
123
  break;
124
+
125
  case 'year':
126
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
127
  break;
128
+
129
  case 'total':
130
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor";
131
+ $history = $WP_Statistics->Get_Historical_Data( 'visitors' );
 
 
 
 
132
  break;
133
+
134
  default:
135
+ $sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
136
  break;
137
  }
138
+ }
139
 
140
+ // Execute the SQL call, if we're only counting we can use get_var(), otherwise we use query().
141
+ if ( $countonly == true ) {
142
  $result = $wpdb->get_var( $sqlstatement );
143
  $result += $history;
144
+ } else {
145
+ $result = $wpdb->query( $sqlstatement );
 
 
 
146
  }
147
+
148
+ return $result;
149
+ }
150
+
151
+ // This function returns the statistics for a given page.
152
+ function wp_statistics_pages( $time, $page_uri = '', $id = - 1, $rangestartdate = null, $rangeenddate = null ) {
153
+
154
+ // We need database and the global $WP_Statistics object access.
155
+ global $wpdb, $WP_Statistics;
156
+
157
+ $history = 0;
158
+ $sqlstatement = '';
159
+
160
+ // If no page URI has been passed in, get the current page URI.
161
+ if ( $page_uri == '' ) {
162
+ $page_uri = wp_statistics_get_uri();
163
  }
164
+
165
+ $page_uri_sql = esc_sql( $page_uri );
166
+
167
+ // If a page/post ID has been passed, use it to select the rows, otherwise use the URI.
168
+ // Note that a single page/post ID can have multiple URI's associated with it.
169
+ if ( $id != - 1 ) {
170
+ $page_sql = '`id` = ' . $id;
171
+ $history_key = 'page';
172
+ $history_id = $id;
173
+ } else {
174
+ $page_sql = "`URI` = '{$page_uri_sql}'";
175
+ $history_key = 'uri';
176
+ $history_id = $page_uri;
177
  }
 
 
 
 
 
 
 
 
 
 
 
178
 
179
+ // This function accepts several options for time parameter, each one has a unique SQL query string.
180
+ // They're pretty self explanatory.
181
+ switch ( $time ) {
182
+ case 'today':
183
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
184
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+ case 'yesterday':
187
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$page_sql}";
188
+ break;
189
+
190
+ case 'week':
191
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
192
+ break;
193
+
194
+ case 'month':
195
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
196
+ break;
197
 
198
+ case 'year':
199
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
200
+ break;
201
+
202
+ case 'total':
203
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE {$page_sql}";
204
+ $history = $WP_Statistics->Get_Historical_Data( $history_key, $history_id );
205
+ break;
206
+ case 'range':
207
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '" . $WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangestartdate ) ) . "' AND '" . $WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangeenddate ) ) . "' AND {$page_sql}";
208
+
209
+ break;
210
+ default:
211
+ $sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$page_sql}";
212
+ break;
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
+ // Since this function only every returns a count, just use get_var().
216
+ $result = $wpdb->get_var( $sqlstatement );
217
+ $result += $history;
218
+
219
+ // If we have an empty result, return 0 instead of a blank.
220
+ if ( $result == '' ) {
221
+ $result = 0;
 
 
222
  }
 
 
 
 
 
 
 
 
 
 
 
223
 
224
+ return $result;
225
+ }
226
+
227
+ // This function converts a page URI to a page/post ID. It does this by looking up in the pages database
228
+ // the URI and getting the associated ID. This will only work if the page has been visited at least once.
229
+ function wp_statistics_uri_to_id( $uri ) {
230
+ global $wpdb;
231
+
232
+ // Create the SQL query to use.
233
+ $sqlstatement = $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}statistics_pages WHERE `URI` = %s AND id > 0 ORDER BY date DESC", $uri );
234
+
235
+ // Execute the query.
236
+ $result = $wpdb->get_var( $sqlstatement );
237
+
238
+ // If we returned a false or some other 0 equivalent value, make sure $result is set to an integer 0.
239
+ if ( $result == 0 ) {
240
+ $result = 0;
241
  }
242
+
243
+ return $result;
244
+ }
245
+
246
+ // We need a quick function to pass to usort to properly sort the most popular pages.
247
+ function wp_stats_compare_uri_hits( $a, $b ) {
248
+ return $a[1] < $b[1];
249
+ }
250
+
251
+ // This function returns a multi-dimensional array, with the total number of pages and an array or URI's sorted in order with their URI, count, id and title.
252
+ function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = null ) {
253
+ global $wpdb;
254
+
255
+ // Get every unique URI from the pages database.
256
+ if ( $rangestartdate != null && $rangeenddate != null ) {
257
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N );
258
+ } else {
259
+ $result = $wpdb->get_results( "SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N );
260
  }
261
 
262
+ $total = 0;
263
+ $uris = array();
264
+
265
+ // Now get the total page visit count for each unique URI.
266
+ foreach ( $result as $out ) {
267
+ // Increment the total number of results.
268
+ $total ++;
269
+
270
+ // Retreive the post ID for the URI.
271
+ $id = wp_statistics_uri_to_id( $out[0] );
272
+
273
+ // Lookup the post title.
274
+ $post = get_post( $id );
275
+
276
+ if ( is_object( $post ) ) {
277
+ $title = $post->post_title;
278
  } else {
279
+ if ( $out[0] == '/' ) {
280
+ $title = get_bloginfo();
281
+ } else {
282
+ $title = '';
 
 
 
 
283
  }
284
+ }
 
 
285
 
286
+ // Add the current post to the array.
287
+ if ( $rangestartdate != null && $rangeenddate != null ) {
288
+ $uris[] = array(
289
+ $out[0],
290
+ wp_statistics_pages( 'range', $out[0], - 1, $rangestartdate, $rangeenddate ),
291
+ $id,
292
+ $title
293
+ );
294
  } else {
295
+ $uris[] = array( $out[0], wp_statistics_pages( 'total', $out[0] ), $id, $title );
296
  }
 
 
297
  }
298
+
299
+ // If we have more than one result, let's sort them using usort.
300
+ if ( count( $uris ) > 1 ) {
301
+ // Sort the URI's based on their hit count.
302
+ usort( $uris, 'wp_stats_compare_uri_hits' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
 
305
+ return array( $total, $uris );
306
+ }
307
+
308
+ // This function gets the current page URI.
309
+ function wp_statistics_get_uri() {
310
+ // Get the site's path from the URL.
311
+ $site_uri = parse_url( site_url(), PHP_URL_PATH );
312
+ $site_uri_len = strlen( $site_uri );
313
+
314
+ // Get the site's path from the URL.
315
+ $home_uri = parse_url( home_url(), PHP_URL_PATH );
316
+ $home_uri_len = strlen( $home_uri );
317
+
318
+ // Get the current page URI.
319
+ $page_uri = $_SERVER["REQUEST_URI"];
320
+
321
+ /*
322
+ * We need to check which URI is longer in case one contains the other.
323
+ *
324
+ * For example home_uri might be "/site/wp" and site_uri might be "/site".
325
+ *
326
+ * In that case we want to check to see if the page_uri starts with "/site/wp" before
327
+ * we check for "/site", but in the reverse case, we need to swap the order of the check.
328
+ */
329
+ if ( $site_uri_len > $home_uri_len ) {
330
+ if ( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
331
+ $page_uri = substr( $page_uri, $site_uri_len );
332
+ }
333
+
334
+ if ( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
335
+ $page_uri = substr( $page_uri, $home_uri_len );
336
+ }
337
+ } else {
338
+ if ( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
339
+ $page_uri = substr( $page_uri, $home_uri_len );
340
+ }
341
+
342
+ if ( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
343
+ $page_uri = substr( $page_uri, $site_uri_len );
344
  }
 
 
345
  }
346
 
347
+ // If we're at the root (aka the URI is blank), let's make sure to indicate it.
348
+ if ( $page_uri == '' ) {
349
+ $page_uri = '/';
350
+ }
351
+
352
+ return $page_uri;
353
+ }
354
+
355
+ // This function returns all unique user agents in the database.
356
+ function wp_statistics_ua_list( $rangestartdate = null, $rangeenddate = null ) {
357
+
358
+ global $wpdb;
359
+
360
+ if ( $rangestartdate != null && $rangeenddate != null ) {
361
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor AND `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N );
362
+ } else {
363
+ $result = $wpdb->get_results( "SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor", ARRAY_N );
364
+ }
365
+
366
+ $Browers = array();
367
+
368
+ foreach ( $result as $out ) {
369
+ $Browsers[] = $out[0];
370
+ }
371
+
372
+ return $Browsers;
373
+ }
374
+
375
+ // This function returns the count of a given user agent in the database.
376
+ function wp_statistics_useragent( $agent, $rangestartdate = null, $rangeenddate = null ) {
377
+
378
+ global $wpdb;
379
+
380
+ if ( $rangestartdate != null && $rangeenddate != null ) {
381
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate ) );
382
+ } else {
383
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent ) );
384
+ }
385
+
386
+ return $result;
387
+ }
388
+
389
+ // This function returns all unique platform types from the database.
390
+ function wp_statistics_platform_list( $rangestartdate = null, $rangeenddate = null ) {
391
+
392
+ global $wpdb;
393
+
394
+ if ( $rangestartdate != null && $rangeenddate != null ) {
395
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ), ARRAY_N );
396
+ } else {
397
+ $result = $wpdb->get_results( "SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor", ARRAY_N );
398
+ }
399
+
400
+ $Platforms = array();
401
+
402
+ foreach ( $result as $out ) {
403
+ $Platforms[] = $out[0];
404
+ }
405
+
406
+ return $Platforms;
407
+ }
408
+
409
+ // This function returns the count of a given platform in the database.
410
+ function wp_statistics_platform( $platform, $rangestartdate = null, $rangeenddate = null ) {
411
+
412
+ global $wpdb;
413
+
414
+ if ( $rangestartdate != null && $rangeenddate != null ) {
415
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(platform) FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s AND `last_counter` BETWEEN %s AND %s", $platform, $rangestartdate, $rangeenddate ) );
416
+ } else {
417
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(platform) FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform ) );
418
+ }
419
+
420
+ return $result;
421
+ }
422
+
423
+ // This function returns all unique versions for a given agent from the database.
424
+ function wp_statistics_agent_version_list( $agent, $rangestartdate = null, $rangeenddate = null ) {
425
+
426
+ global $wpdb;
427
+
428
+ if ( $rangestartdate != null && $rangeenddate != null ) {
429
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND `last_counter` BETWEEN %s AND %s", $agent, $rangestartdate, $rangeenddate ), ARRAY_N );
430
+ } else {
431
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s", $agent ), ARRAY_N );
432
+ }
433
+
434
+ $Versions = array();
435
+
436
+ foreach ( $result as $out ) {
437
+ $Versions[] = $out[0];
438
+ }
439
+
440
+ return $Versions;
441
+ }
442
+
443
+ // This function returns the statistcs for a given agent/version pair from the database.
444
+ function wp_statistics_agent_version( $agent, $version, $rangestartdate = null, $rangeenddate = null ) {
445
+
446
+ global $wpdb;
447
+
448
+ if ( $rangestartdate != null && $rangeenddate != null ) {
449
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(version) FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND version = %s AND `last_counter` BETWEEN %s AND %s", $agent, $version, $rangestartdate, $rangeenddate ) );
450
+ } else {
451
+ $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(version) FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s AND version = %s", $agent, $version ) );
452
+ }
453
+
454
+ return $result;
455
+ }
456
+
457
+ // This function returns an array or array's which define what search engines we should look for.
458
+ //
459
+ // By default will only return ones that have not been disabled by the user, this can be overridden by the $all parameter.
460
+ //
461
+ // Each sub array is made up of the following items:
462
+ // name = The proper name of the search engine
463
+ // translated = The proper name translated to the local language
464
+ // tag = a short one word, all lower case, representation of the search engine
465
+ // sqlpattern = either a single SQL style search pattern OR an array or search patterns to match the hostname in a URL against
466
+ // regexpattern = either a single regex style search pattern OR an array or search patterns to match the hostname in a URL against
467
+ // querykey = the URL key that contains the search string for the search engine
468
+ // image = the name of the image file to associate with this search engine (just the filename, no path info)
469
+ //
470
+ function wp_statistics_searchengine_list( $all = false ) {
471
+ GLOBAL $WP_Statistics;
472
+
473
+ $default = $engines = array(
474
+ 'ask' => array(
475
+ 'name' => 'Ask.com',
476
+ 'translated' => __( 'Ask.com', 'wp_statistics' ),
477
+ 'tag' => 'ask',
478
+ 'sqlpattern' => '%ask.com%',
479
+ 'regexpattern' => 'ask\.com',
480
+ 'querykey' => 'q',
481
+ 'image' => 'ask.png'
482
+ ),
483
+ 'baidu' => array(
484
+ 'name' => 'Baidu',
485
+ 'translated' => __( 'Baidu', 'wp_statistics' ),
486
+ 'tag' => 'baidu',
487
+ 'sqlpattern' => '%baidu.com%',
488
+ 'regexpattern' => 'baidu\.com',
489
+ 'querykey' => 'wd',
490
+ 'image' => 'baidu.png'
491
+ ),
492
+ 'bing' => array(
493
+ 'name' => 'Bing',
494
+ 'translated' => __( 'Bing', 'wp_statistics' ),
495
+ 'tag' => 'bing',
496
+ 'sqlpattern' => '%bing.com%',
497
+ 'regexpattern' => 'bing\.com',
498
+ 'querykey' => 'q',
499
+ 'image' => 'bing.png'
500
+ ),
501
+ 'clearch' => array(
502
+ 'name' => 'clearch.org',
503
+ 'translated' => __( 'clearch.org', 'wp_statistics' ),
504
+ 'tag' => 'clearch',
505
+ 'sqlpattern' => '%clearch.org%',
506
+ 'regexpattern' => 'clearch\.org',
507
+ 'querykey' => 'q',
508
+ 'image' => 'clearch.png'
509
+ ),
510
+ 'duckduckgo' => array(
511
+ 'name' => 'DuckDuckGo',
512
+ 'translated' => __( 'DuckDuckGo', 'wp_statistics' ),
513
+ 'tag' => 'duckduckgo',
514
+ 'sqlpattern' => array( '%duckduckgo.com%', '%ddg.gg%' ),
515
+ 'regexpattern' => array( 'duckduckgo\.com', 'ddg\.gg' ),
516
+ 'querykey' => 'q',
517
+ 'image' => 'duckduckgo.png'
518
+ ),
519
+ 'google' => array(
520
+ 'name' => 'Google',
521
+ 'translated' => __( 'Google', 'wp_statistics' ),
522
+ 'tag' => 'google',
523
+ 'sqlpattern' => '%google.%',
524
+ 'regexpattern' => 'google\.',
525
+ 'querykey' => 'q',
526
+ 'image' => 'google.png'
527
+ ),
528
+ 'yahoo' => array(
529
+ 'name' => 'Yahoo!',
530
+ 'translated' => __( 'Yahoo!', 'wp_statistics' ),
531
+ 'tag' => 'yahoo',
532
+ 'sqlpattern' => '%yahoo.com%',
533
+ 'regexpattern' => 'yahoo\.com',
534
+ 'querykey' => 'p',
535
+ 'image' => 'yahoo.png'
536
+ ),
537
+ 'yandex' => array(
538
+ 'name' => 'Yandex',
539
+ 'translated' => __( 'Yandex', 'wp_statistics' ),
540
+ 'tag' => 'yandex',
541
+ 'sqlpattern' => '%yandex.ru%',
542
+ 'regexpattern' => 'yandex\.ru',
543
+ 'querykey' => 'text',
544
+ 'image' => 'yandex.png'
545
+ )
546
+ );
547
+
548
+ if ( $all == false ) {
549
+ foreach ( $engines as $key => $engine ) {
550
+ if ( $WP_Statistics->get_option( 'disable_se_' . $engine['tag'] ) ) {
551
+ unset( $engines[ $key ] );
552
  }
553
+ }
554
 
555
+ // If we've disabled all the search engines, reset the list back to default.
556
+ if ( count( $engines ) == 0 ) {
557
+ $engines = $default;
558
  }
 
 
559
  }
560
 
561
+ return $engines;
562
+ }
563
+
564
+ // This function will return the SQL WHERE clause for getting the search words for a given search engine.
565
+ function wp_statistics_searchword_query( $search_engine = 'all' ) {
566
+ GLOBAL $WP_Statistics;
567
+
568
+ // Get a complete list of search engines
569
+ $searchengine_list = wp_statistics_searchengine_list();
570
+ $search_query = '';
571
+
572
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
573
+ // Are we getting results for all search engines or a specific one?
574
+ if ( strtolower( $search_engine ) == 'all' ) {
575
+ // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
576
+ foreach ( $searchengine_list as $key => $se ) {
577
+ $search_query .= "( `engine` = '{$key}' AND `words` <> '' ) OR ";
 
 
 
578
  }
579
+
580
+ // Trim off the last ' OR ' for the loop above.
581
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
582
  } else {
583
+ $search_query .= "`engine` = '{$search_engine}' AND `words` <> ''";
584
+ }
585
+ } else {
586
+ // Are we getting results for all search engines or a specific one?
587
+ if ( strtolower( $search_engine ) == 'all' ) {
588
+ // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
589
+ // NOTE: This SQL query can be *VERY* long.
590
+ foreach ( $searchengine_list as $se ) {
591
+ // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
592
+ if ( is_array( $se['sqlpattern'] ) ) {
593
+ foreach ( $se['sqlpattern'] as $subse ) {
594
+ $search_query .= "(`referred` LIKE '{$subse}{$se['querykey']}=%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=') OR ";
 
 
 
 
 
 
 
 
 
 
595
  }
 
 
 
596
  } else {
597
+ $search_query .= "(`referred` LIKE '{$se['sqlpattern']}{$se['querykey']}=%' AND `referred` NOT LIKE '{$se['sqlpattern']}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$se['sqlpattern']}{$se['querykey']}=') OR ";
598
  }
599
  }
 
 
 
 
600
 
601
+ // Trim off the last ' OR ' for the loop above.
602
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  } else {
604
+ // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
605
+ if ( is_array( $searchengine_list[ $search_engine ]['sqlpattern'] ) ) {
606
+ foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
607
+ $search_query .= "(`referred` LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=%' AND `referred` NOT LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=&%' AND `referred` NOT LIKE '{$se}{$searchengine_list[$search_engine]['querykey']}=') OR ";
 
 
 
 
 
 
 
 
 
608
  }
609
+
610
  // Trim off the last ' OR ' for the loop above.
611
  $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
612
  } else {
613
+ $search_query .= "(`referred` LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=%' AND `referred` NOT LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=&%' AND `referred` NOT LIKE '{$searchengine_list[$search_engine]['sqlpattern']}{$searchengine_list[$search_engine]['querykey']}=')";
 
 
 
 
 
 
 
 
 
 
 
614
  }
615
  }
 
 
616
  }
617
 
618
+ return $search_query;
619
+ }
620
+
621
+ // This function will return the SQL WHERE clause for getting the search engine.
622
+ function wp_statistics_searchengine_query( $search_engine = 'all' ) {
623
+ GLOBAL $WP_Statistics;
624
+
625
+ // Get a complete list of search engines
626
+ $searchengine_list = wp_statistics_searchengine_list();
627
+ $search_query = '';
628
+
629
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
630
+ // Are we getting results for all search engines or a specific one?
631
+ if ( strtolower( $search_engine ) == 'all' ) {
632
+ // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
633
+ foreach ( $searchengine_list as $key => $se ) {
634
+ $search_query .= "`engine` = '{$key}' OR ";
635
+ }
636
 
637
+ // Trim off the last ' OR ' for the loop above.
638
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
639
+ } else {
640
+ $search_query .= "`engine` = '{$search_engine}'";
641
+ }
642
+ } else {
643
  // Are we getting results for all search engines or a specific one?
644
+ if ( strtolower( $search_engine ) == 'all' ) {
645
+ // For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
646
+ // NOTE: This SQL query can be long.
647
+ foreach ( $searchengine_list as $se ) {
648
  // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
649
+ if ( is_array( $se['sqlpattern'] ) ) {
650
+ foreach ( $se['sqlpattern'] as $subse ) {
651
+ $search_query .= "`referred` LIKE '{$subse}' OR ";
652
  }
653
  } else {
654
+ $search_query .= "`referred` LIKE '{$se['sqlpattern']}' OR ";
655
  }
656
  }
657
+
658
+ // Trim off the last ' OR ' for the loop above.
659
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
660
  } else {
661
  // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
662
+ if ( is_array( $searchengine_list[ $search_engine ]['sqlpattern'] ) ) {
663
+ foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
664
+ $search_query .= "`referred` LIKE '{$se}' OR ";
665
  }
666
 
667
+ // Trim off the last ' OR ' for the loop above.
668
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
669
  } else {
670
+ $search_query .= "`referred` LIKE '{$searchengine_list[$search_engine]['sqlpattern']}'";
671
  }
672
  }
 
 
 
673
  }
674
 
675
+ return $search_query;
676
+ }
 
 
677
 
678
+ // This function will return a regular expression clause for matching one or more search engines.
679
+ function wp_statistics_searchengine_regex( $search_engine = 'all' ) {
 
 
 
 
 
 
680
 
681
+ // Get a complete list of search engines
682
+ $searchengine_list = wp_statistics_searchengine_list();
683
+ $search_query = '';
684
 
685
+ // Are we getting results for all search engines or a specific one?
686
+ if ( strtolower( $search_engine ) == 'all' ) {
687
+ foreach ( $searchengine_list as $se ) {
688
+ // The SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
689
+ if ( is_array( $se['regexpattern'] ) ) {
690
+ foreach ( $se['regexpattern'] as $subse ) {
691
+ $search_query .= "{$subse}|";
692
+ }
693
+ } else {
694
+ $search_query .= "{$se['regexpattern']}|";
695
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  }
 
 
 
697
 
698
+ // Trim off the last '|' for the loop above.
699
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
700
+ } else {
701
+ // For just one? Ok, the SQL pattern for a search engine may be an array if it has to handle multiple domains (like google.com and google.ca) or other factors.
702
+ if ( is_array( $searchengine_list[ $search_engine ]['regexpattern'] ) ) {
703
+ foreach ( $searchengine_list[ $search_engine ]['regexpattern'] as $se ) {
704
+ $search_query .= "{$se}|";
705
+ }
706
 
707
+ // Trim off the last '|' for the loop above.
708
+ $search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
 
 
 
709
  } else {
710
+ $search_query .= $searchengine_list[ $search_engine ]['regexpattern'];
711
  }
712
+ }
713
 
714
+ // Add the brackets and return
715
+ return "({$search_query})";
716
+ }
717
 
718
+ // This function will return the statistics for a given search engine.
719
+ function wp_statistics_searchengine( $search_engine = 'all', $time = 'total' ) {
720
+
721
+ global $wpdb, $WP_Statistics;
722
+
723
+ // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
724
+ $tablename = $wpdb->prefix . 'statistics_';
725
+
726
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
727
+ $tablename .= 'search';
728
+ } else {
729
+ $tablename .= 'visitor';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  }
731
 
732
+ // Get a complete list of search engines
733
+ $search_query = wp_statistics_searchengine_query( $search_engine );
734
+
735
+ // This function accepts several options for time parameter, each one has a unique SQL query string.
736
+ // They're pretty self explanatory.
737
+ switch ( $time ) {
738
+ case 'today':
739
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}" );
740
+ break;
741
+
742
+ case 'yesterday':
743
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}" );
744
+
745
+ break;
746
+
747
+ case 'week':
748
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}" );
749
+
750
+ break;
751
+
752
+ case 'month':
753
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}" );
754
+
755
+ break;
756
+
757
+ case 'year':
758
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}" );
759
+
760
+ break;
761
+
762
+ case 'total':
763
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}" );
764
+
765
+ break;
766
+
767
+ default:
768
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time)}' AND {$search_query}" );
769
+
770
+ break;
771
  }
772
 
773
+ return $result;
774
+ }
775
+
776
+ // This function will return the statistics for a given search engine for a given time frame.
777
+ function wp_statistics_searchword( $search_engine = 'all', $time = 'total' ) {
778
+
779
+ global $wpdb, $WP_Statistics;
780
+
781
+ // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
782
+ $tablename = $wpdb->prefix . 'statistics_';
783
+
784
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
785
+ $tablename .= 'search';
786
+ } else {
787
+ $tablename .= 'visitor';
788
  }
789
 
790
+ // Get a complete list of search engines
791
+ $search_query = wp_statistics_searchword_query( $search_engine );
792
+
793
+ // This function accepts several options for time parameter, each one has a unique SQL query string.
794
+ // They're pretty self explanatory.
795
+ switch ( $time ) {
796
+ case 'today':
797
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}" );
798
+ break;
799
+
800
+ case 'yesterday':
801
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}" );
802
+
803
+ break;
804
+
805
+ case 'week':
806
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}" );
807
+
808
+ break;
809
+
810
+ case 'month':
811
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}" );
812
+
813
+ break;
814
+
815
+ case 'year':
816
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}" );
817
+
818
+ break;
819
+
820
+ case 'total':
821
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}" );
822
+
823
+ break;
824
+
825
+ default:
826
+ $result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$search_query}" );
827
+
828
+ break;
829
  }
830
 
831
+ return $result;
832
+ }
833
+
834
+ // This function will return the total number of posts in WordPress.
835
+ function wp_statistics_countposts() {
836
+
837
+ $count_posts = wp_count_posts( 'post' );
838
+
839
+ $ret = 0;
840
+
841
+ if ( is_object( $count_posts ) ) {
842
+ $ret = $count_posts->publish;
843
  }
844
 
845
+ return $ret;
846
+ }
847
+
848
+ // This function will return the total number of pages in WordPress.
849
+ function wp_statistics_countpages() {
850
+
851
+ $count_pages = wp_count_posts( 'page' );
852
+
853
+ $ret = 0;
854
+
855
+ if ( is_object( $count_pages ) ) {
856
+ $ret = $count_pages->publish;
857
  }
858
 
859
+ return $ret;
860
+ }
861
+
862
+ // This function will return the total number of comments in WordPress.
863
+ function wp_statistics_countcomment() {
864
+
865
+ global $wpdb;
866
+
867
+ $countcomms = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
868
+
869
+ return $countcomms;
870
+ }
871
+
872
+ // This function will return the total number of spam comments *IF* akismet is installed.
873
+ function wp_statistics_countspam() {
874
+
875
+ return number_format_i18n( get_option( 'akismet_spam_count' ) );
876
+ }
877
+
878
+ // This function will return the total number of users in WordPress.
879
+ function wp_statistics_countusers() {
880
+
881
+ $result = count_users();
882
+
883
+ return $result['total_users'];
884
+ }
885
+
886
+ // This function will return the last date a post was published on your site.
887
+ function wp_statistics_lastpostdate() {
888
+
889
+ global $wpdb, $WP_Statistics;
890
+
891
+ $db_date = $wpdb->get_var( "SELECT post_date FROM {$wpdb->posts} WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1" );
892
+
893
+ $date_format = get_option( 'date_format' );
894
+
895
+ return $WP_Statistics->Current_Date_i18n( $date_format, $db_date, false );
896
+ }
897
+
898
+ // This function will return the average number of posts per day that are published on your site.
899
+ // Alternatively if $days is set to true it returns the average number of days between posts on your site.
900
+ function wp_statistics_average_post( $days = false ) {
901
+
902
+ global $wpdb;
903
+
904
+ $get_first_post = $wpdb->get_var( "SELECT post_date FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date LIMIT 1" );
905
+ $get_total_post = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post'" );
906
+
907
+ $days_spend = intval( ( time() - strtotime( $get_first_post ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
908
+
909
+ if ( $days == true ) {
910
+ if ( $get_total_post == 0 ) {
911
+ $get_total_post = 1;
912
+ } // Avoid divide by zero errors.
913
+
914
+ return round( $days_spend / $get_total_post, 0 );
915
+ } else {
916
+ if ( $days_spend == 0 ) {
917
+ $days_spend = 1;
918
+ } // Avoid divide by zero errors.
919
+
920
+ return round( $get_total_post / $days_spend, 2 );
921
  }
922
+ }
923
+
924
+ // This function will return the average number of comments per day that are published on your site.
925
+ // Alternatively if $days is set to true it returns the average number of days between comments on your site.
926
+ function wp_statistics_average_comment( $days = false ) {
927
+
928
+ global $wpdb;
929
+
930
+ $get_first_comment = $wpdb->get_var( "SELECT comment_date FROM {$wpdb->comments} ORDER BY comment_date LIMIT 1" );
931
+ $get_total_comment = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
932
+
933
+ $days_spend = intval( ( time() - strtotime( $get_first_comment ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
934
+
935
+ if ( $days == true ) {
936
+ if ( $get_total_comment == 0 ) {
937
+ $get_total_comment = 1;
938
+ } // Avoid divide by zero errors.
939
+
940
+ return round( $days_spend / $get_total_comment, 0 );
941
+ } else {
942
+ if ( $days_spend == 0 ) {
943
+ $days_spend = 1;
944
+ } // Avoid divide by zero errors.
945
+
946
+ return round( $get_total_comment / $days_spend, 2 );
947
  }
948
+ }
949
 
950
+ // This function will return the average number of users per day that are registered on your site.
951
+ // Alternatively if $days is set to true it returns the average number of days between user registrations on your site.
952
+ function wp_statistics_average_registeruser( $days = false ) {
953
+
954
+ global $wpdb;
955
+
956
+ $get_first_user = $wpdb->get_var( "SELECT user_registered FROM {$wpdb->users} ORDER BY user_registered LIMIT 1" );
957
+ $get_total_user = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}" );
958
+
959
+ $days_spend = intval( ( time() - strtotime( $get_first_user ) ) / 86400 ); // 86400 = 60 * 60 * 24 = number of seconds in a day
960
+
961
+ if ( $days == true ) {
962
+ if ( $get_total_user == 0 ) {
963
+ $get_total_user = 1;
964
+ } // Avoid divide by zero errors.
965
+
966
+ return round( $days_spend / $get_total_user, 0 );
967
+ } else {
968
+ if ( $days_spend == 0 ) {
969
+ $days_spend = 1;
970
+ } // Avoid divide by zero errors.
971
+
972
+ return round( $get_total_user / $days_spend, 2 );
973
  }
974
+ }
975
 
976
+ // This function handle's the dashicons in the overview page.
977
+ function wp_statistics_icons( $dashicons, $icon_name = null ) {
978
+
979
+ global $wp_version;
980
+
981
+ if ( null == $icon_name ) {
982
+ $icon_name = $dashicons;
 
 
 
 
 
 
 
 
 
 
 
 
983
  }
984
+
985
+ // Since versions of WordPress before 3.8 didn't have dashicons, don't use them in those versions.
986
+ if ( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) {
987
+ return '<span class="dashicons ' . $dashicons . '"></span>';
988
+ } else {
989
+ return '<img src="' . plugins_url( 'wp-statistics/assets/images/' ) . $icon_name . '.png"/>';
 
 
 
 
 
 
 
 
990
  }
991
+ }
992
+
993
+ // This function checks to see if all the PHP modules we need for GeoIP exists.
994
+ function wp_statistics_geoip_supported() {
995
+ // Check to see if we can support the GeoIP code, requirements are:
996
+ $enabled = true;
997
+
998
+ // PHP 5.3
999
+ if ( ! version_compare( phpversion(), WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION, '>' ) ) {
1000
+ $enabled = false;
 
 
 
 
 
 
 
 
 
1001
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
 
1003
+ // PHP's cURL extension installed
1004
+ if ( ! function_exists( 'curl_init' ) ) {
1005
+ $enabled = false;
1006
+ }
1007
 
1008
+ // PHP NOT running in safe mode
1009
+ if ( ini_get( 'safe_mode' ) ) {
1010
+ // Double check php version, 5.4 and above don't support safe mode but the ini value may still be set after an upgrade.
1011
+ if ( ! version_compare( phpversion(), '5.4', '<' ) ) {
1012
+ $enabled = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
  }
1014
+ }
1015
+
1016
+ return $enabled;
1017
+ }
1018
+
1019
+ // This function creates the date range selector 'widget' used in the various statistics pages.
1020
+ function wp_statistics_date_range_selector( $page, $current, $range = array(), $desc = array(), $extrafields = '', $pre_extra = '', $post_extra = '' ) {
1021
+ GLOBAL $WP_Statistics;
1022
+
1023
+ wp_enqueue_script( 'jquery-ui-datepicker' );
1024
+ wp_register_style( 'jquery-ui-smoothness-css', $WP_Statistics->plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' );
1025
+ wp_enqueue_style( 'jquery-ui-smoothness-css' );
1026
+
1027
+ if ( count( $range ) == 0 ) {
1028
+ $range = array( 10, 20, 30, 60, 90, 180, 270, 365 );
1029
+ $desc = array(
1030
+ __( '10 Days', 'wp_statistics' ),
1031
+ __( '20 Days', 'wp_statistics' ),
1032
+ __( '30 Days', 'wp_statistics' ),
1033
+ __( '2 Months', 'wp_statistics' ),
1034
+ __( '3 Months', 'wp_statistics' ),
1035
+ __( '6 Months', 'wp_statistics' ),
1036
+ __( '9 Months', 'wp_statistics' ),
1037
+ __( '1 Year', 'wp_statistics' )
1038
+ );
1039
+ }
1040
+
1041
+ if ( count( $desc ) == 0 ) {
1042
+ $desc = $range;
1043
+ }
1044
+
1045
+ $rcount = count( $range );
1046
+
1047
+ $bold = true;
1048
+
1049
+ // Check to see if there's a range in the URL, if so set it, otherwise use the default.
1050
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
1051
+ $rangestart = $_GET['rangestart'];
1052
+ } else {
1053
+ $rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
1054
+ }
1055
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
1056
+ $rangeend = $_GET['rangeend'];
1057
+ } else {
1058
+ $rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
1059
+ }
1060
+
1061
+ // Convert the text dates to unix timestamps and do some basic sanity checking.
1062
+ $rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
1063
+ if ( false === $rangestart_utime ) {
1064
+ $rangestart_utime = time();
1065
+ }
1066
+ $rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
1067
+ if ( false === $rangeend_utime || $rangeend_utime < $rangestart_utime ) {
1068
+ $rangeend_utime = time();
1069
+ }
1070
+
1071
+ // Now get the number of days in the range.
1072
+ $daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
1073
+ $today = $WP_Statistics->Current_Date( 'm/d/Y' );
1074
+
1075
+ // Re-create the range start/end strings from our utime's to make sure we get ride of any cruft and have them in the format we want.
1076
+ $rangestart = $WP_Statistics->Local_Date( 'm/d/Y', $rangestart_utime );
1077
+ $rangeend = $WP_Statistics->Local_Date( 'm/d/Y', $rangeend_utime );
1078
+
1079
+ // If the rangeend isn't today OR it is but not one of the standard range values, then it's a custom selected value and we need to flag it as such.
1080
+ if ( $rangeend != $today || ( $rangeend == $today && ! in_array( $current, $range ) ) ) {
1081
+ $current = - 1;
1082
+ } else {
1083
+ // If on the other hand we are a standard range, let's reset the custom range selector to match it.
1084
+ $rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
1085
+ $rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
1086
+ }
1087
+
1088
+ echo '<form method="get"><ul class="subsubsub">' . "\r\n";
1089
+
1090
+ // Output any extra HTML we've been passed after the form element but before the date selector.
1091
+ echo $pre_extra;
1092
+
1093
+ for ( $i = 0; $i < $rcount; $i ++ ) {
1094
+ echo ' <li class="all"><a ';
1095
+
1096
+ if ( $current == $range[ $i ] ) {
1097
+ echo 'class="current" ';
1098
+ $bold = false;
1099
  }
1100
+
1101
+ // Don't bother adding he date range to the standard links as they're not needed any may confuse the custom range selector.
1102
+ echo 'href="?page=' . $page . '&hitdays=' . $range[ $i ] . esc_url( $extrafields ) . '">' . $desc[ $i ] . '</a></li>';
1103
+
1104
+ if ( $i < $rcount - 1 ) {
1105
+ echo ' | ';
1106
  }
1107
+
1108
+ echo "\r\n";
 
 
 
 
 
 
 
1109
  }
1110
+
1111
+ echo ' | ';
1112
+
1113
+ echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $page . '">';
1114
+
1115
+ parse_str( $extrafields, $parse );
1116
+
1117
+ foreach ( $parse as $key => $value ) {
1118
+ echo '<input type="hidden" name="' . $key . '" value="' . esc_url( $value ) . '">';
1119
+ }
1120
+
1121
+ if ( $bold ) {
1122
+ echo ' <b>' . __( 'Range', 'wp_statistics' ) . ':</b> ';
1123
+ } else {
1124
+ echo ' ' . __( 'Range', 'wp_statistics' ) . ': ';
1125
+ }
1126
+
1127
+ 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";
1128
+
1129
+ // Output any extra HTML we've been passed after the date selector but before the submit button.
1130
+ echo $post_extra;
1131
+
1132
+ echo '</form>' . "\r\n";
1133
+
1134
+ echo '<script>jQuery(function() { jQuery( "#datestartpicker" ).datepicker(); jQuery( "#dateendpicker" ).datepicker(); });</script>' . "\r\n";
1135
+ }
1136
+
1137
+ // This function is used to calculate the number of days and thier respective unix timestamps.
1138
+ function wp_statistics_date_range_calculator( $days, $start, $end ) {
1139
+ GLOBAL $WP_Statistics;
1140
+
1141
+ $daysToDisplay = $days;
1142
+ $rangestart = $start;
1143
+ $rangeend = $end;
1144
+
1145
+ if ( $daysToDisplay == - 1 ) {
1146
+ $rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
1147
+ $rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
1148
+ $daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
1149
+
1150
+ if ( $rangestart_utime == false || $rangeend_utime == false ) {
1151
+ $daysToDisplay = 20;
1152
+ $rangeend_utime = $WP_Statistics->timetz();
1153
  $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1154
  }
1155
+ } else {
1156
+ $rangeend_utime = $WP_Statistics->timetz();
1157
+ $rangestart_utime = $rangeend_utime - ( $daysToDisplay * 24 * 60 * 60 );
1158
  }
 
 
 
 
 
 
 
 
 
 
 
 
1159
 
1160
+ return array( $daysToDisplay, $rangestart_utime, $rangeend_utime );
1161
+ }
1162
+
1163
+ // This function will empty a table based on the table name.
1164
+ function wp_statitiscs_empty_table( $table_name = false ) {
1165
+ global $wpdb;
1166
 
1167
+ if ( $table_name ) {
1168
+ $result = $wpdb->query( 'DELETE FROM ' . $table_name );
1169
+
1170
+ if ( $result ) {
1171
+ return sprintf( __( '%s table data deleted successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
1172
  }
 
 
 
 
 
 
 
1173
  }
1174
+
1175
+ return sprintf( __( 'Error, %s not emptied!', 'wp_statistics' ), $table_name );
1176
+ }
1177
+
1178
+ // This function creates a small JavaScript snipit that will load the contents of a overview or dashboard widget.
1179
+ function wp_statistics_generate_widget_load_javascript( $widget, $container_id = null ) {
1180
+ if ( null == $container_id ) {
1181
+ $container_id = str_replace( '.', '_', $widget . '_postbox' );
1182
+ }
1183
+ ?>
1184
+ <script type="text/javascript">
1185
+ jQuery(document).ready(function () {
1186
+ wp_statistics_get_widget_contents('<?php echo $widget; ?>', '<?php echo $container_id; ?>');
1187
+ });
1188
+ </script>
1189
+ <?php
1190
+ }
1191
 
1192
 
includes/functions/geoip-populate.php CHANGED
@@ -5,46 +5,49 @@
5
  It is used in two different parts of the plugin; when a user manual requests the update to happen and after a new GeoIP database has been download (if the option is selected).
6
  */
7
 
8
- // Include the MaxMind library and use it.
9
- include_once( plugin_dir_path( __FILE__ ) . '../../vendor/autoload.php' );
10
- use GeoIp2\Database\Reader;
11
-
12
- // This function does all the work.
13
- function wp_statistics_populate_geoip_info() {
14
- global $wpdb;
15
-
16
- // Find all rows in the table that currently don't have GeoIP info or have an unknown ('000') location.
17
- $result = $wpdb->get_results("SELECT id,ip FROM `{$wpdb->prefix}statistics_visitor` WHERE location = '' or location = '000' or location IS NULL");
18
-
19
- // Try create a new reader instance.
20
- try {
21
- $upload_dir = wp_upload_dir();
22
- $reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
23
- } catch( Exception $e ) {
24
- return "<div class='updated settings-error'><p><strong>" . __('Unable to load the GeoIP database, make sure you have downloaded it in the settings page.', 'wp_statistics') . "</strong></p></div>";
25
- }
26
-
27
- $count = 0;
28
-
29
- // Loop through all the missing rows and update them if we find a locaiton for them.
30
- foreach( $result as $item ) {
31
- $count++;
32
-
33
- // If the IP address is only a hash, don't bother updating the record.
34
- if( substr( $item->ip, 0, 6 ) != '#hash#' ) {
35
- try {
36
- $record = $reader->country( $item->ip );
37
- $location = $record->country->isoCode;
38
- if( $location == "" ) { $location = "000"; }
39
- } catch( Exception $e ) {
40
  $location = "000";
41
  }
42
-
43
- // Update the row in the database.
44
- $wpdb->update( $wpdb->prefix . "statistics_visitor", array( 'location' => $location ), array( 'id' => $item->id) );
45
  }
 
 
 
46
  }
47
-
48
- return "<div class='updated settings-error'><p><strong>" . sprintf(__('Updated %s GeoIP records in the visitors database.', 'wp_statistics'), $count) . "</strong></p></div>";
49
  }
 
 
 
 
50
  ?>
5
  It is used in two different parts of the plugin; when a user manual requests the update to happen and after a new GeoIP database has been download (if the option is selected).
6
  */
7
 
8
+ // Include the MaxMind library and use it.
9
+ include_once( plugin_dir_path( __FILE__ ) . '../../vendor/autoload.php' );
10
+ use GeoIp2\Database\Reader;
11
+
12
+ // This function does all the work.
13
+ function wp_statistics_populate_geoip_info() {
14
+ global $wpdb;
15
+
16
+ // Find all rows in the table that currently don't have GeoIP info or have an unknown ('000') location.
17
+ $result = $wpdb->get_results( "SELECT id,ip FROM `{$wpdb->prefix}statistics_visitor` WHERE location = '' or location = '000' or location IS NULL" );
18
+
19
+ // Try create a new reader instance.
20
+ try {
21
+ $upload_dir = wp_upload_dir();
22
+ $reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
23
+ } catch ( Exception $e ) {
24
+ return "<div class='updated settings-error'><p><strong>" . __( 'Unable to load the GeoIP database, make sure you have downloaded it in the settings page.', 'wp_statistics' ) . "</strong></p></div>";
25
+ }
26
+
27
+ $count = 0;
28
+
29
+ // Loop through all the missing rows and update them if we find a locaiton for them.
30
+ foreach ( $result as $item ) {
31
+ $count ++;
32
+
33
+ // If the IP address is only a hash, don't bother updating the record.
34
+ if ( substr( $item->ip, 0, 6 ) != '#hash#' ) {
35
+ try {
36
+ $record = $reader->country( $item->ip );
37
+ $location = $record->country->isoCode;
38
+ if ( $location == "" ) {
 
39
  $location = "000";
40
  }
41
+ } catch ( Exception $e ) {
42
+ $location = "000";
 
43
  }
44
+
45
+ // Update the row in the database.
46
+ $wpdb->update( $wpdb->prefix . "statistics_visitor", array( 'location' => $location ), array( 'id' => $item->id ) );
47
  }
 
 
48
  }
49
+
50
+ return "<div class='updated settings-error'><p><strong>" . sprintf( __( 'Updated %s GeoIP records in the visitors database.', 'wp_statistics' ), $count ) . "</strong></p></div>";
51
+ }
52
+
53
  ?>
includes/functions/manual.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- function wp_statistics_download_manual() {
3
- GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
4
-
5
- $manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options') );
6
-
7
- if( current_user_can( $manage_cap ) ) {
8
-
9
- $type = $_GET['type'];
10
-
11
- if( $type == 'odt' || $type == 'html' ) {
12
-
13
- $filepath = $WP_Statistics->plugin_dir . '/manual';
14
- $filename = '';
15
- $ext = '.' . $type;
16
-
17
- // open this directory
18
- $dir = opendir( $filepath );
19
-
20
- // get each entry
21
- while( $entry = readdir( $dir ) ) {
22
- if( substr( $entry, -strlen( $ext ) ) == $ext ) {
23
- $filename = $entry;
24
- }
25
- }
26
-
27
- // close directory
28
- closedir( $dir );
29
-
30
- if( $filename != '' ) {
31
- header('Content-Type: application/octet-stream;');
32
- header('Content-Disposition: attachment; filename="' . $filename . '"');
33
-
34
- readfile( $filepath . '/' . $filename );
35
- }
36
- }
37
- }
38
- }
39
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions/purge-hits.php CHANGED
@@ -1,50 +1,51 @@
1
  <?php
2
- function wp_statistics_purge_visitor_hits( $purge_hits ) {
3
- GLOBAL $wpdb, $WP_Statistics;
4
-
5
- // If it's less than 10 hits, don't do anything.
6
- if( $purge_hits > 9 ) {
7
- // Purge the visitor's with more than the defined hits.
8
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}statistics_visitor WHERE `hits` > %s", $purge_hits ) );
9
-
10
- $to_delete = array();
11
-
12
- // Loop through the results and store the requried information in an array. We don't just process it now as deleting
13
- // the rows from the visitor table will mess up the results from our first query.
14
- foreach( $result as $row ) {
15
- $to_delete[] = array( $row->ID, $row->last_counter, $row->hits );
16
- }
17
- if( count( $to_delete ) > 0 ) {
18
- foreach( $to_delete as $item ) {
19
- // First update the daily hit count.
20
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_visit SET `visit` = `visit` - %d WHERE `last_counter` = %s;", $item[2], $item[1] ) );
21
- // Next remove the visitor. Note we can't do both in a single query, looks like $wpdb doesn't like executing them together.
22
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `id` = %s;", $item[0] ) );
23
- }
24
-
25
- $result_string = sprintf(__('%s records purged successfully.', 'wp_statistics'), '<code>' . count( $to_delete ) . '</code>');
26
- }
27
- else {
28
- $result_string = __('No visitors found to purge.', 'wp_statistics' );
29
- }
30
  }
31
- else {
32
- $result_string = __('Number of hits must be greater than or equal to 10!', 'wp_statistics');
 
 
 
 
 
 
 
 
 
33
  }
 
 
 
 
 
 
 
34
 
35
- if( $WP_Statistics->get_option('prune_report') == true ) {
36
- $blogname = get_bloginfo('name');
37
- $blogemail = get_bloginfo('admin_email');
38
-
39
- $headers[] = "From: $blogname <$blogemail>";
40
- $headers[] = "MIME-Version: 1.0";
41
- $headers[] = "Content-type: text/html; charset=utf-8";
42
-
43
- if( $WP_Statistics->get_option('email_list') == '' ) { $WP_Statistics->update_option( 'email_list', $blogemail ); }
44
-
45
- wp_mail( $WP_Statistics->get_option('email_list'), __('Database pruned on', 'wp_statistics') . ' ' . $blogname, $result_string, $headers );
46
  }
47
 
48
- return $result_string;
49
  }
 
 
 
 
50
  ?>
1
  <?php
2
+ function wp_statistics_purge_visitor_hits( $purge_hits ) {
3
+ GLOBAL $wpdb, $WP_Statistics;
4
+
5
+ // If it's less than 10 hits, don't do anything.
6
+ if ( $purge_hits > 9 ) {
7
+ // Purge the visitor's with more than the defined hits.
8
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}statistics_visitor WHERE `hits` > %s", $purge_hits ) );
9
+
10
+ $to_delete = array();
11
+
12
+ // Loop through the results and store the requried information in an array. We don't just process it now as deleting
13
+ // the rows from the visitor table will mess up the results from our first query.
14
+ foreach ( $result as $row ) {
15
+ $to_delete[] = array( $row->ID, $row->last_counter, $row->hits );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
+ if ( count( $to_delete ) > 0 ) {
18
+ foreach ( $to_delete as $item ) {
19
+ // First update the daily hit count.
20
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_visit SET `visit` = `visit` - %d WHERE `last_counter` = %s;", $item[2], $item[1] ) );
21
+ // Next remove the visitor. Note we can't do both in a single query, looks like $wpdb doesn't like executing them together.
22
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `id` = %s;", $item[0] ) );
23
+ }
24
+
25
+ $result_string = sprintf( __( '%s records purged successfully.', 'wp_statistics' ), '<code>' . count( $to_delete ) . '</code>' );
26
+ } else {
27
+ $result_string = __( 'No visitors found to purge.', 'wp_statistics' );
28
  }
29
+ } else {
30
+ $result_string = __( 'Number of hits must be greater than or equal to 10!', 'wp_statistics' );
31
+ }
32
+
33
+ if ( $WP_Statistics->get_option( 'prune_report' ) == true ) {
34
+ $blogname = get_bloginfo( 'name' );
35
+ $blogemail = get_bloginfo( 'admin_email' );
36
 
37
+ $headers[] = "From: $blogname <$blogemail>";
38
+ $headers[] = "MIME-Version: 1.0";
39
+ $headers[] = "Content-type: text/html; charset=utf-8";
40
+
41
+ if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
42
+ $WP_Statistics->update_option( 'email_list', $blogemail );
 
 
 
 
 
43
  }
44
 
45
+ wp_mail( $WP_Statistics->get_option( 'email_list' ), __( 'Database pruned on', 'wp_statistics' ) . ' ' . $blogname, $result_string, $headers );
46
  }
47
+
48
+ return $result_string;
49
+ }
50
+
51
  ?>
includes/functions/purge.php CHANGED
@@ -1,117 +1,132 @@
1
  <?php
2
- function wp_statistics_purge_data( $purge_days ) {
3
- GLOBAL $wpdb, $WP_Statistics;
4
-
5
- // If it's less than 30 days, don't do anything.
6
- if($purge_days > 30) {
7
- // Purge the visit data.
8
- $table_name = $wpdb->prefix . 'statistics_visit';
9
- $date_string = $WP_Statistics->current_date( 'Y-m-d', '-' . $purge_days);
10
-
11
- $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
12
-
13
- if($result) {
14
- // Update the historical count with what we purged.
15
- $historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visits'", $result ) );
16
-
17
- if( $historical_result == 0 ) {
18
- $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result, 'category' => 'visits', 'page_id' => -2, 'uri' => '-2' ) );
19
- }
20
-
21
- $result_string = sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
22
- } else {
23
- $result_string = sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' );
24
- }
25
 
26
- // Purge the visitors data.
27
- $table_name = $wpdb->prefix . 'statistics_visitor';
28
-
29
- $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
30
-
31
- if($result) {
32
- // Update the historical count with what we purged.
33
- $historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visitors'", $result ) );
34
-
35
- if( $historical_result == 0 ) {
36
- $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result, 'category' => 'visitors', 'page_id' => -1, 'uri' => '-1' ) );
37
- }
38
-
39
- $result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
40
- } else {
41
- $result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' );
42
- }
43
 
44
- // Purge the exclusions data.
45
- $table_name = $wpdb->prefix . 'statistics_exclusions';
 
46
 
47
- $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
48
-
49
- if($result) {
50
- $result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
51
- } else {
52
- $result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' );
53
  }
54
 
55
- // Purge the search data.
56
- $table_name = $wpdb->prefix . 'statistics_search';
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
59
-
60
- if($result) {
61
- $result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
62
- } else {
63
- $result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' );
64
  }
65
 
66
- // Purge the pages data, this is more complex as we want to save the historical data per page.
67
- $table_name = $wpdb->prefix . 'statistics_pages';
68
- $historical = 0;
69
-
70
- // The first thing we need to do is update the historical data by finding all the unique pages.
71
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string ) );
72
-
73
- // If we have a result, let's store the historical data.
74
- if( $result ) {
75
- // Loop through all the unique rows that were returned.
76
- foreach( $result as $row ) {
77
- // Use the unique rows to get a total count from the database of all the data from the given URIs/Pageids that we're going to delete later.
78
- $historical = $wpdb->get_var( $wpdb->prepare( "SELECT sum(count) FROM {$table_name} WHERE `uri` = %s AND `date` < %s", $row->uri, $date_string));
79
-
80
- // Do an update of the historical data.
81
- $uresult = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET `value` = value + %d WHERE `uri` = %s AND `category` = 'uri'", $historical, $row->uri, $date_string ) );
82
-
83
- // If we failed it's because this is the first time we've seen this URI/pageid so let's create a historical row for it.
84
- if( $uresult == 0 ) {
85
- $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $historical, 'category' => 'uri', 'uri' => $row->uri, 'page_id' => wp_statistics_uri_to_id($row->uri) ) );
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
  }
89
-
90
- // Now that we've done all of the required historical data storage, we can actually delete the data from the database.
91
- $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
92
-
93
- if($result) {
94
- $result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
95
- } else {
96
- $result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' );
97
- }
98
-
99
- if( $WP_Statistics->get_option('prune_report') == true ) {
100
- $blogname = get_bloginfo('name');
101
- $blogemail = get_bloginfo('admin_email');
102
-
103
- $headers[] = "From: $blogname <$blogemail>";
104
- $headers[] = "MIME-Version: 1.0";
105
- $headers[] = "Content-type: text/html; charset=utf-8";
106
-
107
- if( $WP_Statistics->get_option('email_list') == '' ) { $WP_Statistics->update_option( 'email_list', $blogemail ); }
108
-
109
- wp_mail( $WP_Statistics->get_option('email_list'), __('Database pruned on', 'wp_statistics') . ' ' . $blogname, $result_string, $headers );
110
- }
111
 
112
- return $result_string;
 
 
 
 
113
  } else {
114
- return __('Please select a value over 30 days.', 'wp_statistics');
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
 
 
117
  ?>
1
  <?php
2
+ function wp_statistics_purge_data( $purge_days ) {
3
+ GLOBAL $wpdb, $WP_Statistics;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ // If it's less than 30 days, don't do anything.
6
+ if ( $purge_days > 30 ) {
7
+ // Purge the visit data.
8
+ $table_name = $wpdb->prefix . 'statistics_visit';
9
+ $date_string = $WP_Statistics->current_date( 'Y-m-d', '-' . $purge_days );
10
+
11
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
 
 
 
 
 
 
 
 
 
 
12
 
13
+ if ( $result ) {
14
+ // Update the historical count with what we purged.
15
+ $historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visits'", $result ) );
16
 
17
+ if ( $historical_result == 0 ) {
18
+ $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result,
19
+ 'category' => 'visits',
20
+ 'page_id' => - 2,
21
+ 'uri' => '-2'
22
+ ) );
23
  }
24
 
25
+ $result_string = sprintf( __( '%s data older than %s days purged successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' );
26
+ } else {
27
+ $result_string = sprintf( __( 'No records found to purge from %s!', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
28
+ }
29
+
30
+ // Purge the visitors data.
31
+ $table_name = $wpdb->prefix . 'statistics_visitor';
32
+
33
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
34
+
35
+ if ( $result ) {
36
+ // Update the historical count with what we purged.
37
+ $historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visitors'", $result ) );
38
 
39
+ if ( $historical_result == 0 ) {
40
+ $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result,
41
+ 'category' => 'visitors',
42
+ 'page_id' => - 1,
43
+ 'uri' => '-1'
44
+ ) );
45
  }
46
 
47
+ $result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' );
48
+ } else {
49
+ $result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
50
+ }
51
+
52
+ // Purge the exclusions data.
53
+ $table_name = $wpdb->prefix . 'statistics_exclusions';
54
+
55
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
56
+
57
+ if ( $result ) {
58
+ $result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' );
59
+ } else {
60
+ $result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
61
+ }
62
+
63
+ // Purge the search data.
64
+ $table_name = $wpdb->prefix . 'statistics_search';
65
+
66
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
67
+
68
+ if ( $result ) {
69
+ $result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' );
70
+ } else {
71
+ $result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
72
+ }
73
+
74
+ // Purge the pages data, this is more complex as we want to save the historical data per page.
75
+ $table_name = $wpdb->prefix . 'statistics_pages';
76
+ $historical = 0;
77
+
78
+ // The first thing we need to do is update the historical data by finding all the unique pages.
79
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string ) );
80
+
81
+ // If we have a result, let's store the historical data.
82
+ if ( $result ) {
83
+ // Loop through all the unique rows that were returned.
84
+ foreach ( $result as $row ) {
85
+ // Use the unique rows to get a total count from the database of all the data from the given URIs/Pageids that we're going to delete later.
86
+ $historical = $wpdb->get_var( $wpdb->prepare( "SELECT sum(count) FROM {$table_name} WHERE `uri` = %s AND `date` < %s", $row->uri, $date_string ) );
87
+
88
+ // Do an update of the historical data.
89
+ $uresult = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET `value` = value + %d WHERE `uri` = %s AND `category` = 'uri'", $historical, $row->uri, $date_string ) );
90
+
91
+ // If we failed it's because this is the first time we've seen this URI/pageid so let's create a historical row for it.
92
+ if ( $uresult == 0 ) {
93
+ $wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $historical,
94
+ 'category' => 'uri',
95
+ 'uri' => $row->uri,
96
+ 'page_id' => wp_statistics_uri_to_id( $row->uri )
97
+ ) );
98
  }
99
  }
100
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ // Now that we've done all of the required historical data storage, we can actually delete the data from the database.
103
+ $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
104
+
105
+ if ( $result ) {
106
+ $result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp_statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' );
107
  } else {
108
+ $result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp_statistics' ), '<code>' . $table_name . '</code>' );
109
  }
110
+
111
+ if ( $WP_Statistics->get_option( 'prune_report' ) == true ) {
112
+ $blogname = get_bloginfo( 'name' );
113
+ $blogemail = get_bloginfo( 'admin_email' );
114
+
115
+ $headers[] = "From: $blogname <$blogemail>";
116
+ $headers[] = "MIME-Version: 1.0";
117
+ $headers[] = "Content-type: text/html; charset=utf-8";
118
+
119
+ if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
120
+ $WP_Statistics->update_option( 'email_list', $blogemail );
121
+ }
122
+
123
+ wp_mail( $WP_Statistics->get_option( 'email_list' ), __( 'Database pruned on', 'wp_statistics' ) . ' ' . $blogname, $result_string, $headers );
124
+ }
125
+
126
+ return $result_string;
127
+ } else {
128
+ return __( 'Please select a value over 30 days.', 'wp_statistics' );
129
  }
130
+ }
131
+
132
  ?>
includes/log/all-browsers.php CHANGED
@@ -1,321 +1,339 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $daysToDisplay = 20;
8
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval($_GET['hitdays']); }
 
 
9
 
10
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
11
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
 
 
 
 
 
 
 
 
12
 
13
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
14
 
15
- $rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime );
16
- $rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime );
17
 
18
  ?>
19
  <div class="wrap">
20
- <?php screen_icon('options-general'); ?>
21
- <h2><?php _e('Browser Statistics', 'wp_statistics'); ?></h2>
22
-
23
- <div><?php wp_statistics_date_range_selector( WP_STATISTICS_BROWSERS_PAGE, $daysToDisplay ); ?></div>
24
-
25
- <div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
26
- <div class="metabox-holder">
27
- <div class="meta-box-sortables">
28
- <div class="postbox">
29
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
30
- <h3 class="hndle"><span><?php _e('Browsers', 'wp_statistics'); ?></span></h3>
31
- <div class="inside">
32
- <script type="text/javascript">
33
- jQuery(function () {
34
- var browser_chart;
35
- jQuery(document).ready(function() {
36
- <?php
37
- $Browsers = wp_statistics_ua_list();
38
- if( !is_array( $Browsers ) ) { $Browsers = array(); }
39
-
40
- natcasesort( $Browsers );
41
-
42
- echo "var browser_data = [";
43
-
44
- foreach( $Browsers as $Browser )
45
- {
46
- $count = wp_statistics_useragent( $Browser, $rangestartdate, $rangeenddate );
47
- echo "['" . substr( $Browser, 0, 15 ) . " (" . number_format_i18n($count) . ")'," . $count . "], ";
48
  }
49
 
50
- echo "];\n";
51
 
52
-
53
- ?>
54
 
55
- browser_chart = jQuery.jqplot('browsers-log', [browser_data], {
56
- title: {
57
- text: '<b>' + <?php echo json_encode(__('Browsers by type', 'wp_statistics')); ?> + '</b>',
58
- fontSize: '12px',
59
- fontFamily: 'Tahoma',
60
- textColor: '#000000',
61
- },
62
- seriesDefaults: {
63
- // Make this a pie chart.
64
- renderer: jQuery.jqplot.PieRenderer,
65
- rendererOptions: {
66
- // Put data labels on the pie slices.
67
- // By default, labels show the percentage of the slice.
68
- dataLabels: 'percent',
69
- showDataLabels: true,
70
- shadowOffset: 0,
71
- }
72
- },
73
- legend: {
74
- show:true,
75
- location: 's',
76
- renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
77
- rendererOptions:
78
- {
79
- numberColumns: 3,
80
- disableIEFading: false,
81
- border: 'none',
82
- },
83
- },
84
- grid: { background: 'transparent', borderWidth: 0, shadow: false },
85
- highlighter: {
86
- show: true,
87
- formatString:'%s',
88
- tooltipLocation:'n',
89
- useAxesFormatters:false,
90
- },
91
- } );
92
- });
93
-
94
- jQuery(window).resize(function() {
95
- browser_chart.replot( {resetAxes: true } );
96
- });
97
-
98
- });
99
-
100
- </script>
101
-
102
- <div id="browsers-log" style="height: <?php $height = ( ceil( count($Browsers) / 3) * 27 ) + 400; if( $height < 400 ) { $height = 400; } echo $height; ?>px;"></div>
103
- </div>
104
- </div>
105
- </div>
106
- </div>
107
- </div>
108
-
109
- <div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
110
- <div class="metabox-holder">
111
- <div class="meta-box-sortables">
112
- <div class="postbox">
113
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
114
- <h3 class="hndle"><span><?php _e('Platform', 'wp_statistics'); ?></span></h3>
115
- <div class="inside">
116
- <script type="text/javascript">
117
- jQuery(function () {
118
- var platform_chart;
119
- jQuery(document).ready(function() {
120
- <?php
121
- $Platforms = wp_statistics_platform_list( null, $rangestartdate, $rangeenddate );
122
- if( !is_array( $Platforms ) ) { $Platforms = array(); }
123
-
124
- natcasesort( $Platforms );
125
-
126
- echo "var platform_data = [";
127
-
128
- foreach( $Platforms as $Platform )
129
- {
130
- $count = wp_statistics_platform( $Platform );
131
- echo "['" . substr( $Platform, 0, 15) . " (" . number_format_i18n($count) . ")'," . $count . "], ";
132
  }
133
 
134
- echo "];\n";
135
 
136
-
137
- ?>
138
 
139
- platform_chart = jQuery.jqplot('platform-log', [platform_data], {
140
- title: {
141
- text: '<b>' + <?php echo json_encode(__('Browsers by platform', 'wp_statistics')); ?> + '</b>',
142
- fontSize: '12px',
143
- fontFamily: 'Tahoma',
144
- textColor: '#000000',
145
- },
146
- seriesDefaults: {
147
- // Make this a pie chart.
148
- renderer: jQuery.jqplot.PieRenderer,
149
- rendererOptions: {
150
- // Put data labels on the pie slices.
151
- // By default, labels show the percentage of the slice.
152
- dataLabels: 'percent',
153
- showDataLabels: true,
154
- shadowOffset: 0,
155
- }
156
- },
157
- legend: {
158
- show:true,
159
- location: 's',
160
- renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
161
- rendererOptions: {
162
- numberColumns: 3,
163
- disableIEFading: false,
164
- border: 'none',
165
- },
166
- },
167
- grid: { background: 'transparent', borderWidth: 0, shadow: false },
168
- highlighter: {
169
- show: true,
170
- formatString:'%s',
171
- tooltipLocation:'n',
172
- useAxesFormatters:false,
173
- },
174
- } );
175
- });
176
-
177
- jQuery(window).resize(function() {
178
- platform_chart.replot( {resetAxes: true } );
179
- });
180
-
181
- });
182
-
183
- </script>
184
-
185
- <div id="platform-log" style="height: <?php $height = ( ceil( count($Platforms) / 3 ) * 27 ) + 400; if( $height < 400 ) { $height = 400; } echo $height; ?>px;"></div>
186
-
187
- </div>
188
- </div>
189
- </div>
190
- </div>
191
- </div>
192
-
193
- <div style="width: 100%; clear: both;">
194
- <hr />
195
- </div>
196
-
197
- <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
198
- <div class="metabox-holder">
199
- <div class="meta-box-sortables">
200
- <?php
201
- for( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount++ )
202
- {
203
- if( $BrowserCount % 3 == 0 )
204
- {
205
- BrowserVersionStats($Browsers[$BrowserCount]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
 
208
  ?>
209
- </div>
210
- </div>
211
- </div>
212
-
213
- <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
214
- <div class="metabox-holder">
215
- <div class="meta-box-sortables">
216
  <?php
217
- for( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount++ )
218
- {
219
- if( $BrowserCount % 3 == 1 )
220
- {
221
- BrowserVersionStats($Browsers[$BrowserCount]);
222
- }
223
  }
 
224
  ?>
225
- </div>
226
- </div>
227
- </div>
228
 
229
- <div class="postbox-container" style="width: 30%; float: left">
230
- <div class="metabox-holder">
231
- <div class="meta-box-sortables">
232
  <?php
233
- for( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount++ )
234
- {
235
- if( $BrowserCount % 3 == 2 )
236
- {
237
- BrowserVersionStats($Browsers[$BrowserCount]);
238
- }
239
  }
 
240
  ?>
241
- </div>
242
- </div>
243
- </div>
244
  </div>
245
 
246
- <?php function BrowserVersionStats( $Browser, $rangestartdate = null, $rangeenddate = null ) { $Browser_tag = strtolower(preg_replace('/[^a-zA-Z]/', '', $Browser)); ?>
247
- <div class="postbox">
248
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
249
- <h3 class="hndle"><span><?php echo sprintf(__('%s Version', 'wp_statistics'), $Browser); ?></span></h3>
250
- <div class="inside">
251
- <script type="text/javascript">
252
- jQuery(function () {
253
- var <?php echo $Browser_tag;?>_chart;
254
- jQuery(document).ready(function() {
255
- <?php
256
- $Versions = wp_statistics_agent_version_list( $Browser, $rangestartdate, $rangeenddate );
257
- if( !is_array( $Versions ) ) { $Versions = array(); }
258
-
259
- natcasesort( $Versions );
260
-
261
- echo "var " . $Browser_tag . "_version_data = [";
262
-
263
- foreach( $Versions as $Version )
264
- {
265
- $count = wp_statistics_agent_version( $Browser, $Version, $rangestartdate, $rangeenddate );
266
- echo "['" . $Version . " (" . number_format_i18n($count) . ")'," . $count . "], ";
267
  }
268
 
269
- echo "];\n";
270
 
271
-
272
- ?>
273
- <?php echo $Browser_tag;?>_chart = jQuery.jqplot('version-<?php echo $Browser_tag;?>-log', [<?php echo $Browser_tag;?>_version_data], {
274
- title: {
275
- text: '<b><?php echo $Browser; ?></b>',
276
- fontSize: '12px',
277
- fontFamily: 'Tahoma',
278
- textColor: '#000000',
279
- },
280
- seriesDefaults: {
281
- // Make this a pie chart.
282
- renderer: jQuery.jqplot.PieRenderer,
283
- rendererOptions: {
284
- // Put data labels on the pie slices.
285
- // By default, labels show the percentage of the slice.
286
- dataLabels: 'percent',
287
- showDataLabels: true,
288
- shadowOffset: 0,
289
- }
290
- },
291
- legend: {
292
- show:true,
293
- location: 's',
294
- renderer: jQuery.jqplot.EnhancedLegendPieRenderer,
295
- rendererOptions:
296
- {
297
- numberColumns: 2,
298
- disableIEFading: false,
299
- border: 'none',
300
- },
301
- },
302
- grid: { background: 'transparent', borderWidth: 0, shadow: false },
303
- highlighter: {
304
- show: true,
305
- formatString:'%s',
306
- tooltipLocation:'n',
307
- useAxesFormatters:false,
308
- },
309
- } );
310
- });
311
-
312
- jQuery(window).resize(function() {
313
- <?php echo $Browser_tag;?>_chart.replot( {resetAxes: true } );
314
- });
315
-
316
- });
317
- </script>
318
- <div class="ltr" id="version-<?php echo $Browser_tag;?>-log" style="height: <?php $height = ( ceil( count($Versions) / 2 ) * 27 ) + 237; if( $height < 300 ) { $height = 300; } echo $height; ?>px;"></div>
319
- </div>
320
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
321
  <?php } ?>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $daysToDisplay = 20;
8
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
9
+ $daysToDisplay = intval( $_GET['hitdays'] );
10
+ }
11
 
12
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
13
+ $rangestart = $_GET['rangestart'];
14
+ } else {
15
+ $rangestart = '';
16
+ }
17
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
18
+ $rangeend = $_GET['rangeend'];
19
+ } else {
20
+ $rangeend = '';
21
+ }
22
 
23
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
24
 
25
+ $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
26
+ $rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
27
 
28
  ?>
29
  <div class="wrap">
30
+ <?php screen_icon( 'options-general' ); ?>
31
+ <h2><?php _e( 'Browser Statistics', 'wp_statistics' ); ?></h2>
32
+
33
+ <div><?php wp_statistics_date_range_selector( WP_STATISTICS_BROWSERS_PAGE, $daysToDisplay ); ?></div>
34
+
35
+ <div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
36
+ <div class="metabox-holder">
37
+ <div class="meta-box-sortables">
38
+ <div class="postbox">
39
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
40
+ <h3 class="hndle"><span><?php _e( 'Browsers', 'wp_statistics' ); ?></span></h3>
41
+ <div class="inside">
42
+ <script type="text/javascript">
43
+ jQuery(function () {
44
+ var browser_chart;
45
+ jQuery(document).ready(function () {
46
+ <?php
47
+ $Browsers = wp_statistics_ua_list();
48
+ if ( ! is_array( $Browsers ) ) {
49
+ $Browsers = array();
 
 
 
 
 
 
 
 
50
  }
51
 
52
+ natcasesort( $Browsers );
53
 
54
+ echo "var browser_data = [";
 
55
 
56
+ foreach ( $Browsers as $Browser ) {
57
+ $count = wp_statistics_useragent( $Browser, $rangestartdate, $rangeenddate );
58
+ echo "['" . substr( $Browser, 0, 15 ) . " (" . number_format_i18n( $count ) . ")'," . $count . "], ";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
 
61
+ echo "];\n";
62
 
 
 
63
 
64
+ ?>
65
+
66
+ browser_chart = jQuery.jqplot('browsers-log', [browser_data], {
67
+ title: {
68
+ text: '<b>' + <?php echo json_encode( __( 'Browsers by type', 'wp_statistics' ) ); ?> +'</b>',
69
+ fontSize: '12px',
70
+ fontFamily: 'Tahoma',
71
+ textColor: '#000000',
72
+ },
73
+ seriesDefaults: {
74
+ // Make this a pie chart.
75
+ renderer: jQuery.jqplot.PieRenderer,
76
+ rendererOptions: {
77
+ // Put data labels on the pie slices.
78
+ // By default, labels show the percentage of the slice.
79
+ dataLabels: 'percent',
80
+ showDataLabels: true,
81
+ shadowOffset: 0,
82
+ }
83
+ },
84
+ legend: {
85
+ show: true,
86
+ location: 's',
87
+ renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
88
+ rendererOptions: {
89
+ numberColumns: 3,
90
+ disableIEFading: false,
91
+ border: 'none',
92
+ },
93
+ },
94
+ grid: {background: 'transparent', borderWidth: 0, shadow: false},
95
+ highlighter: {
96
+ show: true,
97
+ formatString: '%s',
98
+ tooltipLocation: 'n',
99
+ useAxesFormatters: false,
100
+ },
101
+ });
102
+ });
103
+
104
+ jQuery(window).resize(function () {
105
+ browser_chart.replot({resetAxes: true});
106
+ });
107
+
108
+ });
109
+
110
+ </script>
111
+
112
+ <div id="browsers-log" style="height: <?php $height = ( ceil( count( $Browsers ) / 3 ) * 27 ) + 400;
113
+ if ( $height < 400 ) {
114
+ $height = 400;
115
+ }
116
+ echo $height; ?>px;"></div>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
122
+
123
+ <div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
124
+ <div class="metabox-holder">
125
+ <div class="meta-box-sortables">
126
+ <div class="postbox">
127
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
128
+ <h3 class="hndle"><span><?php _e( 'Platform', 'wp_statistics' ); ?></span></h3>
129
+ <div class="inside">
130
+ <script type="text/javascript">
131
+ jQuery(function () {
132
+ var platform_chart;
133
+ jQuery(document).ready(function () {
134
+ <?php
135
+ $Platforms = wp_statistics_platform_list( null, $rangestartdate, $rangeenddate );
136
+ if ( ! is_array( $Platforms ) ) {
137
+ $Platforms = array();
138
+ }
139
+
140
+ natcasesort( $Platforms );
141
+
142
+ echo "var platform_data = [";
143
+
144
+ foreach ( $Platforms as $Platform ) {
145
+ $count = wp_statistics_platform( $Platform );
146
+ echo "['" . substr( $Platform, 0, 15 ) . " (" . number_format_i18n( $count ) . ")'," . $count . "], ";
147
+ }
148
+
149
+ echo "];\n";
150
+
151
+
152
+ ?>
153
+
154
+ platform_chart = jQuery.jqplot('platform-log', [platform_data], {
155
+ title: {
156
+ text: '<b>' + <?php echo json_encode( __( 'Browsers by platform', 'wp_statistics' ) ); ?> +'</b>',
157
+ fontSize: '12px',
158
+ fontFamily: 'Tahoma',
159
+ textColor: '#000000',
160
+ },
161
+ seriesDefaults: {
162
+ // Make this a pie chart.
163
+ renderer: jQuery.jqplot.PieRenderer,
164
+ rendererOptions: {
165
+ // Put data labels on the pie slices.
166
+ // By default, labels show the percentage of the slice.
167
+ dataLabels: 'percent',
168
+ showDataLabels: true,
169
+ shadowOffset: 0,
170
+ }
171
+ },
172
+ legend: {
173
+ show: true,
174
+ location: 's',
175
+ renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
176
+ rendererOptions: {
177
+ numberColumns: 3,
178
+ disableIEFading: false,
179
+ border: 'none',
180
+ },
181
+ },
182
+ grid: {background: 'transparent', borderWidth: 0, shadow: false},
183
+ highlighter: {
184
+ show: true,
185
+ formatString: '%s',
186
+ tooltipLocation: 'n',
187
+ useAxesFormatters: false,
188
+ },
189
+ });
190
+ });
191
+
192
+ jQuery(window).resize(function () {
193
+ platform_chart.replot({resetAxes: true});
194
+ });
195
+
196
+ });
197
+
198
+ </script>
199
+
200
+ <div id="platform-log" style="height: <?php $height = ( ceil( count( $Platforms ) / 3 ) * 27 ) + 400;
201
+ if ( $height < 400 ) {
202
+ $height = 400;
203
  }
204
+ echo $height; ?>px;"></div>
205
+
206
+ </div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+ </div>
211
+
212
+ <div style="width: 100%; clear: both;">
213
+ <hr/>
214
+ </div>
215
+
216
+ <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
217
+ <div class="metabox-holder">
218
+ <div class="meta-box-sortables">
219
+ <?php
220
+ for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
221
+ if ( $BrowserCount % 3 == 0 ) {
222
+ BrowserVersionStats( $Browsers[ $BrowserCount ] );
223
  }
224
+ }
225
  ?>
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
231
+ <div class="metabox-holder">
232
+ <div class="meta-box-sortables">
233
  <?php
234
+ for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
235
+ if ( $BrowserCount % 3 == 1 ) {
236
+ BrowserVersionStats( $Browsers[ $BrowserCount ] );
 
 
 
237
  }
238
+ }
239
  ?>
240
+ </div>
241
+ </div>
242
+ </div>
243
 
244
+ <div class="postbox-container" style="width: 30%; float: left">
245
+ <div class="metabox-holder">
246
+ <div class="meta-box-sortables">
247
  <?php
248
+ for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
249
+ if ( $BrowserCount % 3 == 2 ) {
250
+ BrowserVersionStats( $Browsers[ $BrowserCount ] );
 
 
 
251
  }
252
+ }
253
  ?>
254
+ </div>
255
+ </div>
256
+ </div>
257
  </div>
258
 
259
+ <?php function BrowserVersionStats( $Browser, $rangestartdate = null, $rangeenddate = null ) {
260
+ $Browser_tag = strtolower( preg_replace( '/[^a-zA-Z]/', '', $Browser ) ); ?>
261
+ <div class="postbox">
262
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
263
+ <h3 class="hndle"><span><?php echo sprintf( __( '%s Version', 'wp_statistics' ), $Browser ); ?></span></h3>
264
+ <div class="inside">
265
+ <script type="text/javascript">
266
+ jQuery(function () {
267
+ var <?php echo $Browser_tag;?>_chart;
268
+ jQuery(document).ready(function () {
269
+ <?php
270
+ $Versions = wp_statistics_agent_version_list( $Browser, $rangestartdate, $rangeenddate );
271
+ if ( ! is_array( $Versions ) ) {
272
+ $Versions = array();
 
 
 
 
 
 
 
273
  }
274
 
275
+ natcasesort( $Versions );
276
 
277
+ echo "var " . $Browser_tag . "_version_data = [";
278
+
279
+ foreach ( $Versions as $Version ) {
280
+ $count = wp_statistics_agent_version( $Browser, $Version, $rangestartdate, $rangeenddate );
281
+ echo "['" . $Version . " (" . number_format_i18n( $count ) . ")'," . $count . "], ";
282
+ }
283
+
284
+ echo "];\n";
285
+
286
+
287
+ ?>
288
+ <?php echo $Browser_tag;?>_chart = jQuery.jqplot('version-<?php echo $Browser_tag;?>-log', [<?php echo $Browser_tag;?>_version_data], {
289
+ title: {
290
+ text: '<b><?php echo $Browser; ?></b>',
291
+ fontSize: '12px',
292
+ fontFamily: 'Tahoma',
293
+ textColor: '#000000',
294
+ },
295
+ seriesDefaults: {
296
+ // Make this a pie chart.
297
+ renderer: jQuery.jqplot.PieRenderer,
298
+ rendererOptions: {
299
+ // Put data labels on the pie slices.
300
+ // By default, labels show the percentage of the slice.
301
+ dataLabels: 'percent',
302
+ showDataLabels: true,
303
+ shadowOffset: 0,
304
+ }
305
+ },
306
+ legend: {
307
+ show: true,
308
+ location: 's',
309
+ renderer: jQuery.jqplot.EnhancedLegendPieRenderer,
310
+ rendererOptions: {
311
+ numberColumns: 2,
312
+ disableIEFading: false,
313
+ border: 'none',
314
+ },
315
+ },
316
+ grid: {background: 'transparent', borderWidth: 0, shadow: false},
317
+ highlighter: {
318
+ show: true,
319
+ formatString: '%s',
320
+ tooltipLocation: 'n',
321
+ useAxesFormatters: false,
322
+ },
323
+ });
324
+ });
325
+
326
+ jQuery(window).resize(function () {
327
+ <?php echo $Browser_tag;?>_chart.replot({resetAxes: true});
328
+ });
329
+
330
+ });
331
+ </script>
332
+ <div class="ltr" id="version-<?php echo $Browser_tag; ?>-log" style="height: <?php $height = ( ceil( count( $Versions ) / 2 ) * 27 ) + 237;
333
+ if ( $height < 300 ) {
334
+ $height = 300;
335
+ }
336
+ echo $height; ?>px;"></div>
337
+ </div>
338
+ </div>
339
  <?php } ?>
includes/log/authors.php CHANGED
@@ -4,95 +4,109 @@
4
  ?>
5
 
6
  <script type="text/javascript">
7
- jQuery( document ).ready( function() {
8
- postboxes.add_postbox_toggles( pagenow );
9
- } );
10
  </script>
11
  <div class="wrap">
12
- <?php screen_icon('options-general'); ?>
13
- <h2><?php _e( 'Author Statistics', 'wp_statistics' ); ?></h2>
14
-
15
- <?php
16
- $daysToDisplay = 20;
17
- if( array_key_exists( 'hitdays',$_GET ) ) { $daysToDisplay = intval( $_GET['hitdays'] ); }
18
-
19
- if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
20
- if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
21
- if( array_key_exists( 'author', $_GET ) ) {
22
- $author = intval( $_GET['author'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  } else {
24
- if( array_key_exists( 'preauthor', $_GET ) ) {
25
- $author = intval( $_GET['preauthor'] );
26
- } else {
27
- $author = 0;
28
- }
29
  }
 
30
 
31
- $html = __( 'Select Author', 'wp_statistics' ) . ': ';
32
- $html .= '<select name="author" id="author">';
33
 
34
- $authors_list = wp_list_authors( 'html=0&style=none&echo=0&exclude_admin=0&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC' );
35
 
36
- $authors_array = explode( ',', $authors_list );
37
 
38
- foreach( $authors_array as $value ) {
39
- $author_obj = get_user_by( 'slug', $value );
40
 
41
- if( $author_obj !== false ) {
42
- // Check to see if this tag is the one that is currently selected.
43
- if( $author_obj->ID === $author ) { $selected = ' SELECTED'; } else { $selected = ''; }
44
-
45
- $html .= '<option value="' . $author_obj->ID . '"{$selected}>' . $value . '</option>';
 
46
  }
 
 
47
  }
48
-
49
- $html .= '</select>';
50
 
51
- $html .= ' <input type="submit" value="' . __( 'Select', 'wp_statistics' ).'" class="button-primary">';
52
- $html .= '<br>';
53
 
54
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
 
55
 
56
- wp_statistics_date_range_selector( WP_STATISTICS_AUTHORS_PAGE, $daysToDisplay, NULL, NULL, '&preauthor=' . $author, $html );
57
 
58
- $args = array(
59
- 'author' => $author,
60
- );
61
 
62
- $posts = get_posts( $args );
 
 
 
 
63
 
64
  ?>
65
 
66
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
67
- <div class="metabox-holder">
68
- <div class="meta-box-sortables">
69
- <div class="postbox">
70
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
71
- <h3 class="hndle"><span><?php _e( 'Author Statistics Chart', 'wp_statistics' ); ?></span></h3>
72
- <div class="inside">
73
- <script type="text/javascript">
74
- var visit_chart;
75
- jQuery( document ).ready( function() {
76
- <?php
77
  $visit_total = 0;
78
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
79
  $posts_stats = array();
80
 
81
  // Setup the array, otherwise PHP may throw an error.
82
- foreach( $posts as $post ){
83
- $posts_stats[$post->ID] = 0;
84
  }
85
 
86
  echo "var visit_data_line = [";
87
 
88
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
89
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
90
 
91
  $stat = 0;
92
- foreach( $posts as $post ){
93
- $temp_stat = wp_statistics_pages( '-' . (int)( $i + $daysInThePast ), NULL, $post->ID );
94
- $posts_stats[$post->ID] += $temp_stat;
95
- $stat = $temp_stat;
96
  }
97
 
98
  $visit_total += $stat;
@@ -103,186 +117,193 @@
103
  echo "];\n";
104
 
105
  $tickInterval = round( $daysToDisplay / 20, 0 );
106
- if( $tickInterval < 1 ) { $tickInterval = 1; }
107
- ?>
108
- visit_chart = jQuery.jqplot( 'visits-stats', [visit_data_line], {
109
- title: {
110
- text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
111
- fontSize: '12px',
112
- fontFamily: 'Tahoma',
113
- textColor: '#000000',
114
- },
115
- axes: {
116
- xaxis: {
117
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-'.$daysToDisplay, $rangeend_utime ); ?>',
118
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
119
- tickInterval: '<?php echo $tickInterval; ?> day',
120
- renderer:jQuery.jqplot.DateAxisRenderer,
121
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
122
- tickOptions: {
123
- angle: -45,
124
- formatString:'%b %#d',
125
- showGridline: false,
126
- },
127
- },
128
- yaxis: {
129
- min: 0,
130
- padMin: 1.0,
131
- label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
132
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
133
- labelOptions: {
134
- angle: -90,
135
- fontSize: '12px',
136
- fontFamily: 'Tahoma',
137
- fontWeight: 'bold',
138
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
- },
141
- legend: {
142
- show: true,
143
- location: 's',
144
- placement: 'outsideGrid',
145
- labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
146
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
147
- rendererOptions:
148
- {
149
- numberColumns: 2,
150
- disableIEFading: false,
151
- border: 'none',
152
- },
153
- },
154
- highlighter: {
155
- show: true,
156
- bringSeriesToFront: true,
157
- tooltipAxes: 'xy',
158
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
159
- tooltipContentEditor: tooltipContentEditor,
160
- },
161
- grid: {
162
- drawGridlines: true,
163
- borderColor: 'transparent',
164
- shadow: false,
165
- drawBorder: false,
166
- shadowColor: 'transparent'
167
- },
168
- } );
169
-
170
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
171
- // display series_label, x-axis_tick, y-axis value
172
- return plot.legend.labels[seriesIndex] + ", " + str;;
173
- }
174
-
175
- jQuery(window).resize(function() {
176
- JQPlotVisitChartLengendClickRedraw()
177
- });
178
 
179
- function JQPlotVisitChartLengendClickRedraw() {
180
- visit_chart.replot( {resetAxes: ['yaxis'] } );
181
-
182
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
183
- JQPlotVisitChartLengendClickRedraw();
184
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
 
187
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
188
- JQPlotVisitChartLengendClickRedraw()
189
- });
190
-
191
- });
192
-
193
- </script>
194
-
195
- <div id="visits-stats" style="height:500px;"></div>
196
-
197
- </div>
198
- </div>
199
- </div>
200
- </div>
201
- </div>
202
-
203
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
204
- <div class="metabox-holder">
205
- <div class="meta-box-sortables">
206
- <div class="postbox">
207
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
208
- <h3 class="hndle"><span><?php _e( 'Author Statistics Summary', 'wp_statistics' ); ?></span></h3>
209
- <div class="inside">
210
- <table width="auto" class="widefat table-stats" id="summary-stats">
211
- <tbody>
212
- <tr>
213
- <th></th>
214
- <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
215
- </tr>
216
-
217
- <tr>
218
- <th><?php _e('Number of posts by author', 'wp_statistics'); ?>:</th>
219
- <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span></th>
220
- </tr>
221
-
222
- <tr>
223
- <th><?php _e('Chart Visits Total', 'wp_statistics'); ?>:</th>
224
- <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span></th>
225
- </tr>
226
-
227
- <tr>
228
- <th><?php _e('All Time Visits Total', 'wp_statistics'); ?>:</th>
229
- <th class="th-center"><span><?php
230
-
231
- $stat = 0;
232
- foreach( $posts as $post ){
233
- $stat += wp_statistics_pages( 'total', NULL, $post->ID );
234
- }
235
-
236
- echo number_format_i18n( $stat ); ?></span></th>
237
- </tr>
238
- </tbody>
239
- </table>
240
- </div>
241
- </div>
242
- </div>
243
- </div>
244
- </div>
245
-
246
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
247
- <div class="metabox-holder">
248
- <div class="meta-box-sortables">
249
- <div class="postbox">
250
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
251
- <h3 class="hndle"><span><?php _e( 'Author Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
252
- <div class="inside">
253
- <table width="auto" class="widefat table-stats" id="post-stats">
254
- <tbody>
255
- <tr>
256
- <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
257
- <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
258
- </tr>
259
-
260
- <?php
261
- arsort( $posts_stats );
262
-
263
- $posts_by_id = array();
264
-
265
- foreach( $posts as $post ) {
266
- $posts_by_id[$post->ID] = $post;
267
- }
268
-
269
- foreach( $posts_stats as $post_id => $post_stat ) {
270
- $post_obj = $posts_by_id[$post_id];
271
-
272
- ?>
273
- <tr>
274
- <th><a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a></th>
275
- <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span></th>
276
- </tr>
277
- <?php
278
- }
279
- ?>
280
- </tbody>
281
- </table>
282
- </div>
283
- </div>
284
- </div>
285
- </div>
286
- </div>
287
 
288
  </div>
4
  ?>
5
 
6
  <script type="text/javascript">
7
+ jQuery(document).ready(function () {
8
+ postboxes.add_postbox_toggles(pagenow);
9
+ });
10
  </script>
11
  <div class="wrap">
12
+ <?php screen_icon( 'options-general' ); ?>
13
+ <h2><?php _e( 'Author Statistics', 'wp_statistics' ); ?></h2>
14
+
15
+ <?php
16
+ $daysToDisplay = 20;
17
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
18
+ $daysToDisplay = intval( $_GET['hitdays'] );
19
+ }
20
+
21
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
22
+ $rangestart = $_GET['rangestart'];
23
+ } else {
24
+ $rangestart = '';
25
+ }
26
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
27
+ $rangeend = $_GET['rangeend'];
28
+ } else {
29
+ $rangeend = '';
30
+ }
31
+ if ( array_key_exists( 'author', $_GET ) ) {
32
+ $author = intval( $_GET['author'] );
33
+ } else {
34
+ if ( array_key_exists( 'preauthor', $_GET ) ) {
35
+ $author = intval( $_GET['preauthor'] );
36
  } else {
37
+ $author = 0;
 
 
 
 
38
  }
39
+ }
40
 
41
+ $html = __( 'Select Author', 'wp_statistics' ) . ': ';
42
+ $html .= '<select name="author" id="author">';
43
 
44
+ $authors_list = wp_list_authors( 'html=0&style=none&echo=0&exclude_admin=0&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC' );
45
 
46
+ $authors_array = explode( ',', $authors_list );
47
 
48
+ foreach ( $authors_array as $value ) {
49
+ $author_obj = get_user_by( 'slug', $value );
50
 
51
+ if ( $author_obj !== false ) {
52
+ // Check to see if this tag is the one that is currently selected.
53
+ if ( $author_obj->ID === $author ) {
54
+ $selected = ' SELECTED';
55
+ } else {
56
+ $selected = '';
57
  }
58
+
59
+ $html .= '<option value="' . $author_obj->ID . '"{$selected}>' . $value . '</option>';
60
  }
61
+ }
 
62
 
63
+ $html .= '</select>';
 
64
 
65
+ $html .= ' <input type="submit" value="' . __( 'Select', 'wp_statistics' ) . '" class="button-primary">';
66
+ $html .= '<br>';
67
 
68
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
69
 
70
+ wp_statistics_date_range_selector( WP_STATISTICS_AUTHORS_PAGE, $daysToDisplay, null, null, '&preauthor=' . $author, $html );
 
 
71
 
72
+ $args = array(
73
+ 'author' => $author,
74
+ );
75
+
76
+ $posts = get_posts( $args );
77
 
78
  ?>
79
 
80
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
81
+ <div class="metabox-holder">
82
+ <div class="meta-box-sortables">
83
+ <div class="postbox">
84
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
85
+ <h3 class="hndle"><span><?php _e( 'Author Statistics Chart', 'wp_statistics' ); ?></span></h3>
86
+ <div class="inside">
87
+ <script type="text/javascript">
88
+ var visit_chart;
89
+ jQuery(document).ready(function () {
90
+ <?php
91
  $visit_total = 0;
92
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
93
  $posts_stats = array();
94
 
95
  // Setup the array, otherwise PHP may throw an error.
96
+ foreach ( $posts as $post ) {
97
+ $posts_stats[ $post->ID ] = 0;
98
  }
99
 
100
  echo "var visit_data_line = [";
101
 
102
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
103
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
104
 
105
  $stat = 0;
106
+ foreach ( $posts as $post ) {
107
+ $temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
108
+ $posts_stats[ $post->ID ] += $temp_stat;
109
+ $stat = $temp_stat;
110
  }
111
 
112
  $visit_total += $stat;
117
  echo "];\n";
118
 
119
  $tickInterval = round( $daysToDisplay / 20, 0 );
120
+ if ( $tickInterval < 1 ) {
121
+ $tickInterval = 1;
122
+ }
123
+ ?>
124
+ visit_chart = jQuery.jqplot('visits-stats', [visit_data_line], {
125
+ title: {
126
+ text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
127
+ fontSize: '12px',
128
+ fontFamily: 'Tahoma',
129
+ textColor: '#000000',
130
+ },
131
+ axes: {
132
+ xaxis: {
133
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
134
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
135
+ tickInterval: '<?php echo $tickInterval; ?> day',
136
+ renderer: jQuery.jqplot.DateAxisRenderer,
137
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
138
+ tickOptions: {
139
+ angle: -45,
140
+ formatString: '%b %#d',
141
+ showGridline: false,
142
+ },
143
+ },
144
+ yaxis: {
145
+ min: 0,
146
+ padMin: 1.0,
147
+ label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
148
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
149
+ labelOptions: {
150
+ angle: -90,
151
+ fontSize: '12px',
152
+ fontFamily: 'Tahoma',
153
+ fontWeight: 'bold',
154
+ },
155
+ }
156
+ },
157
+ legend: {
158
+ show: true,
159
+ location: 's',
160
+ placement: 'outsideGrid',
161
+ labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
162
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
163
+ rendererOptions: {
164
+ numberColumns: 2,
165
+ disableIEFading: false,
166
+ border: 'none',
167
+ },
168
+ },
169
+ highlighter: {
170
+ show: true,
171
+ bringSeriesToFront: true,
172
+ tooltipAxes: 'xy',
173
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
174
+ tooltipContentEditor: tooltipContentEditor,
175
+ },
176
+ grid: {
177
+ drawGridlines: true,
178
+ borderColor: 'transparent',
179
+ shadow: false,
180
+ drawBorder: false,
181
+ shadowColor: 'transparent'
182
+ },
183
+ });
184
+
185
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
186
+ // display series_label, x-axis_tick, y-axis value
187
+ return plot.legend.labels[seriesIndex] + ", " + str;
188
+ ;
189
+ }
190
+
191
+ jQuery(window).resize(function () {
192
+ JQPlotVisitChartLengendClickRedraw()
193
+ });
194
+
195
+ function JQPlotVisitChartLengendClickRedraw() {
196
+ visit_chart.replot({resetAxes: ['yaxis']});
197
+
198
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
199
+ JQPlotVisitChartLengendClickRedraw();
200
+ });
201
+ }
202
+
203
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
204
+ JQPlotVisitChartLengendClickRedraw()
205
+ });
206
+
207
+ });
208
+
209
+ </script>
210
+
211
+ <div id="visits-stats" style="height:500px;"></div>
212
+
213
+ </div>
214
+ </div>
215
+ </div>
216
+ </div>
217
+ </div>
218
+
219
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
220
+ <div class="metabox-holder">
221
+ <div class="meta-box-sortables">
222
+ <div class="postbox">
223
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
224
+ <h3 class="hndle"><span><?php _e( 'Author Statistics Summary', 'wp_statistics' ); ?></span></h3>
225
+ <div class="inside">
226
+ <table width="auto" class="widefat table-stats" id="summary-stats">
227
+ <tbody>
228
+ <tr>
229
+ <th></th>
230
+ <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
231
+ </tr>
232
+
233
+ <tr>
234
+ <th><?php _e( 'Number of posts by author', 'wp_statistics' ); ?>:</th>
235
+ <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
236
+ </th>
237
+ </tr>
238
+
239
+ <tr>
240
+ <th><?php _e( 'Chart Visits Total', 'wp_statistics' ); ?>:</th>
241
+ <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
242
+ </th>
243
+ </tr>
244
+
245
+ <tr>
246
+ <th><?php _e( 'All Time Visits Total', 'wp_statistics' ); ?>:</th>
247
+ <th class="th-center"><span><?php
248
+
249
+ $stat = 0;
250
+ foreach ( $posts as $post ) {
251
+ $stat += wp_statistics_pages( 'total', null, $post->ID );
252
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
+ echo number_format_i18n( $stat ); ?></span></th>
255
+ </tr>
256
+ </tbody>
257
+ </table>
258
+ </div>
259
+ </div>
260
+ </div>
261
+ </div>
262
+ </div>
263
+
264
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
265
+ <div class="metabox-holder">
266
+ <div class="meta-box-sortables">
267
+ <div class="postbox">
268
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
269
+ <h3 class="hndle"><span><?php _e( 'Author Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
270
+ <div class="inside">
271
+ <table width="auto" class="widefat table-stats" id="post-stats">
272
+ <tbody>
273
+ <tr>
274
+ <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
275
+ <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
276
+ </tr>
277
+
278
+ <?php
279
+ arsort( $posts_stats );
280
+
281
+ $posts_by_id = array();
282
+
283
+ foreach ( $posts as $post ) {
284
+ $posts_by_id[ $post->ID ] = $post;
285
  }
286
 
287
+ foreach ( $posts_stats as $post_id => $post_stat ) {
288
+ $post_obj = $posts_by_id[ $post_id ];
289
+
290
+ ?>
291
+ <tr>
292
+ <th>
293
+ <a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a>
294
+ </th>
295
+ <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
296
+ </th>
297
+ </tr>
298
+ <?php
299
+ }
300
+ ?>
301
+ </tbody>
302
+ </table>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  </div>
includes/log/categories.php CHANGED
@@ -4,83 +4,93 @@
4
  ?>
5
 
6
  <script type="text/javascript">
7
- jQuery( document ).ready( function() {
8
- postboxes.add_postbox_toggles( pagenow );
9
- } );
10
  </script>
11
  <div class="wrap">
12
- <?php screen_icon('options-general'); ?>
13
- <h2><?php _e( 'Category Statistics', 'wp_statistics' ); ?></h2>
14
-
15
- <?php
16
- $daysToDisplay = 20;
17
- if( array_key_exists( 'hitdays',$_GET ) ) { $daysToDisplay = intval( $_GET['hitdays'] ); }
18
-
19
- if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
20
- if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
21
- if( array_key_exists( 'cat', $_GET ) ) {
22
- $category = intval( $_GET['cat'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  } else {
24
- if( array_key_exists( 'precat', $_GET ) ) {
25
- $category = intval( $_GET['precat'] );
26
- } else {
27
- $category = 0;
28
- }
29
  }
 
30
 
31
- $html = __( 'Select Category', 'wp_statistics' ) . ': ';
32
 
33
- $args = array(
34
- 'selected' => $category,
35
- 'echo' => 0,
36
- );
37
 
38
- $html .= wp_dropdown_categories( $args );
39
- $html .= '<input type="submit" value="' . __( 'Select', 'wp_statistics' ).'" class="button-primary">';
40
- $html .= '<br>';
41
 
42
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
43
 
44
- wp_statistics_date_range_selector( WP_STATISTICS_CATEGORIES_PAGE, $daysToDisplay, NULL, NULL, '&precat=' . $category, $html );
45
 
46
- $args = array(
47
- 'category' => $category,
48
- );
49
 
50
- $posts = get_posts( $args );
51
 
52
  ?>
53
 
54
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
55
- <div class="metabox-holder">
56
- <div class="meta-box-sortables">
57
- <div class="postbox">
58
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
59
- <h3 class="hndle"><span><?php _e( 'Category Statistics Chart', 'wp_statistics' ); ?></span></h3>
60
- <div class="inside">
61
- <script type="text/javascript">
62
- var visit_chart;
63
- jQuery( document ).ready( function() {
64
- <?php
65
  $visit_total = 0;
66
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
67
  $posts_stats = array();
68
 
69
  // Setup the array, otherwise PHP may throw an error.
70
- foreach( $posts as $post ){
71
- $posts_stats[$post->ID] = 0;
72
  }
73
 
74
  echo "var visit_data_line = [";
75
 
76
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
77
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
78
 
79
  $stat = 0;
80
- foreach( $posts as $post ){
81
- $temp_stat = wp_statistics_pages( '-' . (int)( $i + $daysInThePast ), NULL, $post->ID );
82
- $posts_stats[$post->ID] += $temp_stat;
83
- $stat = $temp_stat;
84
  }
85
 
86
  $visit_total += $stat;
@@ -91,186 +101,193 @@
91
  echo "];\n";
92
 
93
  $tickInterval = round( $daysToDisplay / 20, 0 );
94
- if( $tickInterval < 1 ) { $tickInterval = 1; }
95
- ?>
96
- visit_chart = jQuery.jqplot( 'visits-stats', [visit_data_line], {
97
- title: {
98
- text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
99
- fontSize: '12px',
100
- fontFamily: 'Tahoma',
101
- textColor: '#000000',
102
- },
103
- axes: {
104
- xaxis: {
105
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-'.$daysToDisplay, $rangeend_utime ); ?>',
106
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
107
- tickInterval: '<?php echo $tickInterval; ?> day',
108
- renderer:jQuery.jqplot.DateAxisRenderer,
109
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
110
- tickOptions: {
111
- angle: -45,
112
- formatString:'%b %#d',
113
- showGridline: false,
114
- },
115
- },
116
- yaxis: {
117
- min: 0,
118
- padMin: 1.0,
119
- label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
120
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
121
- labelOptions: {
122
- angle: -90,
123
- fontSize: '12px',
124
- fontFamily: 'Tahoma',
125
- fontWeight: 'bold',
126
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
- },
129
- legend: {
130
- show: true,
131
- location: 's',
132
- placement: 'outsideGrid',
133
- labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
134
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
135
- rendererOptions:
136
- {
137
- numberColumns: 2,
138
- disableIEFading: false,
139
- border: 'none',
140
- },
141
- },
142
- highlighter: {
143
- show: true,
144
- bringSeriesToFront: true,
145
- tooltipAxes: 'xy',
146
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
147
- tooltipContentEditor: tooltipContentEditor,
148
- },
149
- grid: {
150
- drawGridlines: true,
151
- borderColor: 'transparent',
152
- shadow: false,
153
- drawBorder: false,
154
- shadowColor: 'transparent'
155
- },
156
- } );
157
-
158
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
159
- // display series_label, x-axis_tick, y-axis value
160
- return plot.legend.labels[seriesIndex] + ", " + str;;
161
- }
162
-
163
- jQuery(window).resize(function() {
164
- JQPlotVisitChartLengendClickRedraw()
165
- });
166
 
167
- function JQPlotVisitChartLengendClickRedraw() {
168
- visit_chart.replot( {resetAxes: ['yaxis'] } );
169
-
170
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
171
- JQPlotVisitChartLengendClickRedraw();
172
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
174
 
175
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
176
- JQPlotVisitChartLengendClickRedraw()
177
- });
178
-
179
- });
180
-
181
- </script>
182
-
183
- <div id="visits-stats" style="height:500px;"></div>
184
-
185
- </div>
186
- </div>
187
- </div>
188
- </div>
189
- </div>
190
-
191
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
192
- <div class="metabox-holder">
193
- <div class="meta-box-sortables">
194
- <div class="postbox">
195
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
196
- <h3 class="hndle"><span><?php _e( 'Category Statistics Summary', 'wp_statistics' ); ?></span></h3>
197
- <div class="inside">
198
- <table width="auto" class="widefat table-stats" id="summary-stats">
199
- <tbody>
200
- <tr>
201
- <th></th>
202
- <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
203
- </tr>
204
-
205
- <tr>
206
- <th><?php _e('Number of posts in category', 'wp_statistics'); ?>:</th>
207
- <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span></th>
208
- </tr>
209
-
210
- <tr>
211
- <th><?php _e('Chart Visits Total', 'wp_statistics'); ?>:</th>
212
- <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span></th>
213
- </tr>
214
-
215
- <tr>
216
- <th><?php _e('All Time Visits Total', 'wp_statistics'); ?>:</th>
217
- <th class="th-center"><span><?php
218
-
219
- $stat = 0;
220
- foreach( $posts as $post ){
221
- $stat += wp_statistics_pages( 'total', NULL, $post->ID );
222
- }
223
-
224
- echo number_format_i18n( $stat ); ?></span></th>
225
- </tr>
226
- </tbody>
227
- </table>
228
- </div>
229
- </div>
230
- </div>
231
- </div>
232
- </div>
233
-
234
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
235
- <div class="metabox-holder">
236
- <div class="meta-box-sortables">
237
- <div class="postbox">
238
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
239
- <h3 class="hndle"><span><?php _e( 'Category Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
240
- <div class="inside">
241
- <table width="auto" class="widefat table-stats" id="post-stats">
242
- <tbody>
243
- <tr>
244
- <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
245
- <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
246
- </tr>
247
-
248
- <?php
249
- arsort( $posts_stats );
250
-
251
- $posts_by_id = array();
252
-
253
- foreach( $posts as $post ) {
254
- $posts_by_id[$post->ID] = $post;
255
- }
256
-
257
- foreach( $posts_stats as $post_id => $post_stat ) {
258
- $post_obj = $posts_by_id[$post_id];
259
-
260
- ?>
261
- <tr>
262
- <th><a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a></th>
263
- <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span></th>
264
- </tr>
265
- <?php
266
- }
267
- ?>
268
- </tbody>
269
- </table>
270
- </div>
271
- </div>
272
- </div>
273
- </div>
274
- </div>
275
 
276
  </div>
4
  ?>
5
 
6
  <script type="text/javascript">
7
+ jQuery(document).ready(function () {
8
+ postboxes.add_postbox_toggles(pagenow);
9
+ });
10
  </script>
11
  <div class="wrap">
12
+ <?php screen_icon( 'options-general' ); ?>
13
+ <h2><?php _e( 'Category Statistics', 'wp_statistics' ); ?></h2>
14
+
15
+ <?php
16
+ $daysToDisplay = 20;
17
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
18
+ $daysToDisplay = intval( $_GET['hitdays'] );
19
+ }
20
+
21
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
22
+ $rangestart = $_GET['rangestart'];
23
+ } else {
24
+ $rangestart = '';
25
+ }
26
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
27
+ $rangeend = $_GET['rangeend'];
28
+ } else {
29
+ $rangeend = '';
30
+ }
31
+ if ( array_key_exists( 'cat', $_GET ) ) {
32
+ $category = intval( $_GET['cat'] );
33
+ } else {
34
+ if ( array_key_exists( 'precat', $_GET ) ) {
35
+ $category = intval( $_GET['precat'] );
36
  } else {
37
+ $category = 0;
 
 
 
 
38
  }
39
+ }
40
 
41
+ $html = __( 'Select Category', 'wp_statistics' ) . ': ';
42
 
43
+ $args = array(
44
+ 'selected' => $category,
45
+ 'echo' => 0,
46
+ );
47
 
48
+ $html .= wp_dropdown_categories( $args );
49
+ $html .= '<input type="submit" value="' . __( 'Select', 'wp_statistics' ) . '" class="button-primary">';
50
+ $html .= '<br>';
51
 
52
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
53
 
54
+ wp_statistics_date_range_selector( WP_STATISTICS_CATEGORIES_PAGE, $daysToDisplay, null, null, '&precat=' . $category, $html );
55
 
56
+ $args = array(
57
+ 'category' => $category,
58
+ );
59
 
60
+ $posts = get_posts( $args );
61
 
62
  ?>
63
 
64
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
65
+ <div class="metabox-holder">
66
+ <div class="meta-box-sortables">
67
+ <div class="postbox">
68
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
69
+ <h3 class="hndle"><span><?php _e( 'Category Statistics Chart', 'wp_statistics' ); ?></span></h3>
70
+ <div class="inside">
71
+ <script type="text/javascript">
72
+ var visit_chart;
73
+ jQuery(document).ready(function () {
74
+ <?php
75
  $visit_total = 0;
76
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
77
  $posts_stats = array();
78
 
79
  // Setup the array, otherwise PHP may throw an error.
80
+ foreach ( $posts as $post ) {
81
+ $posts_stats[ $post->ID ] = 0;
82
  }
83
 
84
  echo "var visit_data_line = [";
85
 
86
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
87
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
88
 
89
  $stat = 0;
90
+ foreach ( $posts as $post ) {
91
+ $temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
92
+ $posts_stats[ $post->ID ] += $temp_stat;
93
+ $stat = $temp_stat;
94
  }
95
 
96
  $visit_total += $stat;
101
  echo "];\n";
102
 
103
  $tickInterval = round( $daysToDisplay / 20, 0 );
104
+ if ( $tickInterval < 1 ) {
105
+ $tickInterval = 1;
106
+ }
107
+ ?>
108
+ visit_chart = jQuery.jqplot('visits-stats', [visit_data_line], {
109
+ title: {
110
+ text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
111
+ fontSize: '12px',
112
+ fontFamily: 'Tahoma',
113
+ textColor: '#000000',
114
+ },
115
+ axes: {
116
+ xaxis: {
117
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
118
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
119
+ tickInterval: '<?php echo $tickInterval; ?> day',
120
+ renderer: jQuery.jqplot.DateAxisRenderer,
121
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
122
+ tickOptions: {
123
+ angle: -45,
124
+ formatString: '%b %#d',
125
+ showGridline: false,
126
+ },
127
+ },
128
+ yaxis: {
129
+ min: 0,
130
+ padMin: 1.0,
131
+ label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
132
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
133
+ labelOptions: {
134
+ angle: -90,
135
+ fontSize: '12px',
136
+ fontFamily: 'Tahoma',
137
+ fontWeight: 'bold',
138
+ },
139
+ }
140
+ },
141
+ legend: {
142
+ show: true,
143
+ location: 's',
144
+ placement: 'outsideGrid',
145
+ labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
146
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
147
+ rendererOptions: {
148
+ numberColumns: 2,
149
+ disableIEFading: false,
150
+ border: 'none',
151
+ },
152
+ },
153
+ highlighter: {
154
+ show: true,
155
+ bringSeriesToFront: true,
156
+ tooltipAxes: 'xy',
157
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
158
+ tooltipContentEditor: tooltipContentEditor,
159
+ },
160
+ grid: {
161
+ drawGridlines: true,
162
+ borderColor: 'transparent',
163
+ shadow: false,
164
+ drawBorder: false,
165
+ shadowColor: 'transparent'
166
+ },
167
+ });
168
+
169
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
170
+ // display series_label, x-axis_tick, y-axis value
171
+ return plot.legend.labels[seriesIndex] + ", " + str;
172
+ ;
173
+ }
174
+
175
+ jQuery(window).resize(function () {
176
+ JQPlotVisitChartLengendClickRedraw()
177
+ });
178
+
179
+ function JQPlotVisitChartLengendClickRedraw() {
180
+ visit_chart.replot({resetAxes: ['yaxis']});
181
+
182
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
183
+ JQPlotVisitChartLengendClickRedraw();
184
+ });
185
+ }
186
+
187
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
188
+ JQPlotVisitChartLengendClickRedraw()
189
+ });
190
+
191
+ });
192
+
193
+ </script>
194
+
195
+ <div id="visits-stats" style="height:500px;"></div>
196
+
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ </div>
202
+
203
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
204
+ <div class="metabox-holder">
205
+ <div class="meta-box-sortables">
206
+ <div class="postbox">
207
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
208
+ <h3 class="hndle"><span><?php _e( 'Category Statistics Summary', 'wp_statistics' ); ?></span></h3>
209
+ <div class="inside">
210
+ <table width="auto" class="widefat table-stats" id="summary-stats">
211
+ <tbody>
212
+ <tr>
213
+ <th></th>
214
+ <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
215
+ </tr>
216
+
217
+ <tr>
218
+ <th><?php _e( 'Number of posts in category', 'wp_statistics' ); ?>:</th>
219
+ <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
220
+ </th>
221
+ </tr>
222
+
223
+ <tr>
224
+ <th><?php _e( 'Chart Visits Total', 'wp_statistics' ); ?>:</th>
225
+ <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
226
+ </th>
227
+ </tr>
228
+
229
+ <tr>
230
+ <th><?php _e( 'All Time Visits Total', 'wp_statistics' ); ?>:</th>
231
+ <th class="th-center"><span><?php
232
+
233
+ $stat = 0;
234
+ foreach ( $posts as $post ) {
235
+ $stat += wp_statistics_pages( 'total', null, $post->ID );
236
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
+ echo number_format_i18n( $stat ); ?></span></th>
239
+ </tr>
240
+ </tbody>
241
+ </table>
242
+ </div>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </div>
247
+
248
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
249
+ <div class="metabox-holder">
250
+ <div class="meta-box-sortables">
251
+ <div class="postbox">
252
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
253
+ <h3 class="hndle"><span><?php _e( 'Category Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
254
+ <div class="inside">
255
+ <table width="auto" class="widefat table-stats" id="post-stats">
256
+ <tbody>
257
+ <tr>
258
+ <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
259
+ <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
260
+ </tr>
261
+
262
+ <?php
263
+ arsort( $posts_stats );
264
+
265
+ $posts_by_id = array();
266
+
267
+ foreach ( $posts as $post ) {
268
+ $posts_by_id[ $post->ID ] = $post;
269
  }
270
 
271
+ foreach ( $posts_stats as $post_id => $post_stat ) {
272
+ $post_obj = $posts_by_id[ $post_id ];
273
+
274
+ ?>
275
+ <tr>
276
+ <th>
277
+ <a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a>
278
+ </th>
279
+ <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
280
+ </th>
281
+ </tr>
282
+ <?php
283
+ }
284
+ ?>
285
+ </tbody>
286
+ </table>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ </div>
291
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
  </div>
includes/log/exclusions.php CHANGED
@@ -1,217 +1,312 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- if( $WP_Statistics->get_option( 'record_exclusions' ) != 1 ) {
8
- echo "<div class='updated settings-error'><p><strong>" . __('Attention: Exclusion are not currently set to be recorded, the results below may not reflect current statistics!', 'wp_statistics') . "</strong></p></div>";
9
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- $daysToDisplay = 20;
12
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval($_GET['hitdays']); }
13
-
14
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
15
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
16
-
17
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
18
-
19
- $total_stats = $WP_Statistics->get_option( 'chart_totals' );
20
-
21
- $excluded_reasons = array( 'Robot','Browscap','IP Match','Self Referral','Login Page','Admin Page','User Role','GeoIP','Hostname', 'Robot Threshold','Honey Pot','Feeds', 'Excluded URL', '404 Pages', 'Referrer Spam', 'AJAX Request' );
22
- $excluded_reason_tags = array( 'Robot' => 'robot','Browscap' => 'browscap','IP Match' => 'ipmatch','Self Referral' => 'selfreferral','Login Page' => 'loginpage','Admin Page' => 'adminpage','User Role' => 'userrole','Total' => 'total','GeoIP' => 'geoip','Hostname' => 'hostname','Robot Threshold' => 'robot_threshold','Honey Pot' => 'honeypot','Feeds' => 'feed', 'Excluded URL' => 'excluded_url', '404 Pages' => 'excluded_404s', 'Referrer Spam' => 'referrer_spam', 'AJAX Request' => 'ajax' );
23
- $excluded_reason_db = array( 'Robot' => 'robot','Browscap' => 'browscap','IP Match' => 'ip match','Self Referral' => 'self referral','Login Page' => 'login page','Admin Page' => 'admin page','User Role' => 'user role','Total' => 'total','GeoIP' => 'geoip','Hostname' => 'hostname','Robot Threshold' => 'robot_threshold','Honey Pot' => 'honeypot','Feeds' => 'feed', 'Excluded URL' => 'excluded url', '404 Pages' => '404', 'Referrer Spam' => 'referrer_spam', 'AJAX Request' => 'ajax' );
24
- $excluded_reason_translate = array( 'Robot' => json_encode( __( 'Robot', 'wp_statistics' ) ), 'Browscap' => json_encode( __( 'Browscap', 'wp_statistics' ) ), 'IP Match' => json_encode( __( 'IP Match', 'wp_statistics' ) ), 'Self Referral' => json_encode( __( 'Self Referral', 'wp_statistics' ) ), 'Login Page' => json_encode( __( 'Login Page', 'wp_statistics' ) ), 'Admin Page' => json_encode( __( 'Admin Page', 'wp_statistics' ) ), 'User Role' => json_encode( __( 'User Role', 'wp_statistics' ) ), 'Total' => json_encode( __( 'Total', 'wp_statistics' ) ), 'GeoIP' => json_encode( __( 'GeoIP', 'wp_statistics' ) ), 'Hostname' => json_encode( __( 'Hostname', 'wp_statistics' ) ), 'Robot Threshold' => json_encode( __( 'Robot Threshold', 'wp_statistics' ) ), 'Honey Pot' => json_encode( __( 'Honey Pot', 'wp_statistics' ) ), 'Feeds' => json_encode( __( 'Feeds', 'wp_statistics') ), 'Excluded URL' => json_encode( __( 'Excluded URL', 'wp_statistics') ),'404 Pages' => json_encode( __( '404 Pages', 'wp_statistics') ), 'Referrer Spam' => json_encode( __( 'Referrer Spam', 'wp_statistics') ), 'AJAX Request' => json_encode( __( 'AJAX Request', 'wp_statistics') ) );
25
- $excluded_results = array('Total' => array() );
26
- $excluded_total = 0;
27
-
28
- foreach( $excluded_reasons as $reason ) {
29
-
30
- // The reasons array above is used both for display and internal purposes. Internally the values are all lower case but the array
31
- // is created with mixed case so it looks nice to the user. Therefore we have to convert it to lower case here.
32
- $thisreason = $excluded_reason_db[$reason];
33
-
34
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
35
-
36
- // We're looping through the days backwards, so let's fine out what date we want to look at.
37
- $thisdate = $WP_Statistics->real_current_date( 'Y-m-d', '-' . $i, $rangeend_utime );
38
-
39
- // Create the SQL query string to get the data.
40
- $query = $wpdb->prepare( "SELECT count FROM {$wpdb->prefix}statistics_exclusions WHERE reason = %s AND date = %s", $thisreason, $thisdate );
41
-
42
- // Execute the query.
43
- $excluded_results[$reason][$i] = $wpdb->get_var( $query );
44
-
45
- // If we're returned an error or a FALSE value, then let's make sure it's set to a numerical 0.
46
- if( $excluded_results[$reason][$i] < 1 ) { $excluded_results[$reason][$i] = 0; }
47
-
48
- // Make sure to initialize the results so we don't get warnings when WP_DEBUG is enabled.
49
- if( !array_key_exists( $i, $excluded_results['Total'] ) ) { $excluded_results['Total'][$i] = 0; }
50
-
51
- // We're totalling things up here for use later.
52
- $excluded_results['Total'][$i] += $excluded_results[$reason][$i];
53
- $excluded_total += $excluded_results[$reason][$i];
54
  }
 
 
 
 
 
 
 
 
 
55
  }
56
-
57
- $excuded_all_time = $wpdb->get_var( "SELECT SUM(count) FROM {$wpdb->prefix}statistics_exclusions" );
58
-
59
- // If the chart totals is enabled, cheat a little and just add another reason category to the list so it gets generated later.
60
- if( $total_stats == 1 ) { $excluded_reasons[] = 'Total'; }
 
 
 
61
  ?>
62
  <div class="wrap">
63
- <?php screen_icon('options-general'); ?>
64
- <h2><?php _e('Exclusions Statistics', 'wp_statistics'); ?></h2>
65
 
66
  <?php wp_statistics_date_range_selector( WP_STATISTICS_EXCLUSIONS_PAGE, $daysToDisplay ); ?>
67
 
68
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
69
- <div class="metabox-holder">
70
- <div class="meta-box-sortables">
71
- <div class="postbox">
72
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
73
- <h3 class="hndle"><span><?php _e('Exclusions Statistical Chart', 'wp_statistics'); ?></span></h3>
74
- <div class="inside">
75
- <script type="text/javascript">
76
- var visit_chart;
77
- jQuery(document).ready(function() {
78
- <?php
79
- foreach( $excluded_reasons as $reason ) {
80
-
81
- echo "var excluded_data_line_" . $excluded_reason_tags[$reason] . " = [";
82
-
83
- for( $i=$daysToDisplay; $i>=0; $i--) {
84
- echo "['" . $WP_Statistics->Real_Current_Date('Y-m-d', '-'.$i, $rangeend_utime) . "'," . $excluded_results[$reason][$i] . "], ";
85
- }
86
 
87
  echo "];\n";
88
  }
89
-
90
  $tickInterval = round( $daysToDisplay / 20, 0 );
91
- if( $tickInterval < 1 ) { $tickInterval = 1; }
92
- ?>
93
- visit_chart = jQuery.jqplot('exclusion-stats', [<?php foreach( $excluded_reasons as $reason ) { echo "excluded_data_line_" . $excluded_reason_tags[$reason] . ", "; } ?>], {
94
- title: {
95
- text: '<b>' + <?php echo json_encode( __( 'Excluded hits in the last', 'wp_statistics') . ' ' . $daysToDisplay . ' ' . __('days', 'wp_statistics' ) ); ?> + '</b>',
96
- fontSize: '12px',
97
- fontFamily: 'Tahoma',
98
- textColor: '#000000',
99
- },
100
- axes: {
101
- xaxis: {
102
- min: '<?php echo $WP_Statistics->Real_Current_Date('Y-m-d', '-'.$daysToDisplay, $rangeend_utime);?>',
103
- max: '<?php echo $WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangeend_utime);?>',
104
- tickInterval: '<?php echo $tickInterval?> day',
105
- renderer:jQuery.jqplot.DateAxisRenderer,
106
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
107
- tickOptions: {
108
- angle: -45,
109
- formatString:'%b %#d',
110
- showGridline: false,
111
- },
112
- },
113
- yaxis: {
114
- min: 0,
115
- padMin: 1.0,
116
- label: <?php echo json_encode( __( 'Number of excluded hits', 'wp_statistics' ) ); ?>,
117
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
118
- labelOptions: {
119
- angle: -90,
120
- fontSize: '12px',
121
- fontFamily: 'Tahoma',
122
- fontWeight: 'bold',
123
- },
124
- }
125
- },
126
- legend: {
127
- show: true,
128
- location: 's',
129
- placement: 'outsideGrid',
130
- labels: [<?php foreach( $excluded_reasons as $reason ) { echo $excluded_reason_translate[$reason] . ", "; } ?>],
131
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
132
- rendererOptions:
133
- {
134
- numberColumns: <?php echo count($excluded_reasons) + 1; ?>,
135
- disableIEFading: false,
136
- border: 'none',
137
- },
138
- },
139
- highlighter: {
140
- show: true,
141
- bringSeriesToFront: true,
142
- tooltipAxes: 'xy',
143
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
144
- tooltipContentEditor: tooltipContentEditor,
145
- },
146
- grid: {
147
- drawGridlines: true,
148
- borderColor: 'transparent',
149
- shadow: false,
150
- drawBorder: false,
151
- shadowColor: 'transparent'
152
- },
153
- } );
154
-
155
- function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
156
- // display series_label, x-axis_tick, y-axis value
157
- return plot.legend.labels[seriesIndex] + ", " + str;;
158
- }
159
-
160
- jQuery(window).resize(function() {
161
- JQPlotExclusionChartLengendClickRedraw()
162
- });
163
-
164
- function JQPlotExclusionChartLengendClickRedraw() {
165
- visit_chart.replot( {resetAxes: ['yaxis'] } );
166
- jQuery('div[id="exclusion-stats"] .jqplot-table-legend').click(function() {
167
- JQPlotExclusionChartLengendClickRedraw();
168
- });
169
- }
170
-
171
- jQuery('div[id="exclusion-stats"] .jqplot-table-legend').click(function() {
172
- JQPlotExclusionChartLengendClickRedraw()
173
- });
174
-
175
- });
176
- </script>
177
-
178
- <div id="exclusion-stats" style="height:500px;"></div>
179
-
180
- </div>
181
- </div>
182
- </div>
183
- </div>
184
- </div>
185
-
186
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
187
- <div class="metabox-holder">
188
- <div class="meta-box-sortables">
189
- <div class="postbox">
190
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
191
- <h3 class="hndle"><span><?php _e('Hits Statistics Summary', 'wp_statistics'); ?></span></h3>
192
- <div class="inside">
193
- <table width="auto" class="widefat table-stats" id="summary-stats">
194
- <tbody>
195
- <tr>
196
- <th></th>
197
- <th class="th-center"><?php _e('Exclusions', 'wp_statistics'); ?></th>
198
- </tr>
199
-
200
- <tr>
201
- <th><?php _e('Chart Total', 'wp_statistics'); ?>:</th>
202
- <th class="th-center"><span><?php echo number_format_i18n($excluded_total); ?></span></th>
203
- </tr>
204
-
205
- <tr>
206
- <th><?php _e('All Time Total', 'wp_statistics'); ?>:</th>
207
- <th class="th-center"><span><?php echo number_format_i18n($excuded_all_time); ?></span></th>
208
- </tr>
209
- </tbody>
210
- </table>
211
- </div>
212
- </div>
213
- </div>
214
- </div>
215
- </div>
 
 
 
 
 
 
 
 
 
216
 
217
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ if ( $WP_Statistics->get_option( 'record_exclusions' ) != 1 ) {
8
+ echo "<div class='updated settings-error'><p><strong>" . __( 'Attention: Exclusion are not currently set to be recorded, the results below may not reflect current statistics!', 'wp_statistics' ) . "</strong></p></div>";
9
+ }
10
+
11
+ $daysToDisplay = 20;
12
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
13
+ $daysToDisplay = intval( $_GET['hitdays'] );
14
+ }
15
+
16
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
17
+ $rangestart = $_GET['rangestart'];
18
+ } else {
19
+ $rangestart = '';
20
+ }
21
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
22
+ $rangeend = $_GET['rangeend'];
23
+ } else {
24
+ $rangeend = '';
25
+ }
26
+
27
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
28
+
29
+ $total_stats = $WP_Statistics->get_option( 'chart_totals' );
30
+
31
+ $excluded_reasons = array(
32
+ 'Robot',
33
+ 'Browscap',
34
+ 'IP Match',
35
+ 'Self Referral',
36
+ 'Login Page',
37
+ 'Admin Page',
38
+ 'User Role',
39
+ 'GeoIP',
40
+ 'Hostname',
41
+ 'Robot Threshold',
42
+ 'Honey Pot',
43
+ 'Feeds',
44
+ 'Excluded URL',
45
+ '404 Pages',
46
+ 'Referrer Spam',
47
+ 'AJAX Request'
48
+ );
49
+ $excluded_reason_tags = array(
50
+ 'Robot' => 'robot',
51
+ 'Browscap' => 'browscap',
52
+ 'IP Match' => 'ipmatch',
53
+ 'Self Referral' => 'selfreferral',
54
+ 'Login Page' => 'loginpage',
55
+ 'Admin Page' => 'adminpage',
56
+ 'User Role' => 'userrole',
57
+ 'Total' => 'total',
58
+ 'GeoIP' => 'geoip',
59
+ 'Hostname' => 'hostname',
60
+ 'Robot Threshold' => 'robot_threshold',
61
+ 'Honey Pot' => 'honeypot',
62
+ 'Feeds' => 'feed',
63
+ 'Excluded URL' => 'excluded_url',
64
+ '404 Pages' => 'excluded_404s',
65
+ 'Referrer Spam' => 'referrer_spam',
66
+ 'AJAX Request' => 'ajax'
67
+ );
68
+ $excluded_reason_db = array(
69
+ 'Robot' => 'robot',
70
+ 'Browscap' => 'browscap',
71
+ 'IP Match' => 'ip match',
72
+ 'Self Referral' => 'self referral',
73
+ 'Login Page' => 'login page',
74
+ 'Admin Page' => 'admin page',
75
+ 'User Role' => 'user role',
76
+ 'Total' => 'total',
77
+ 'GeoIP' => 'geoip',
78
+ 'Hostname' => 'hostname',
79
+ 'Robot Threshold' => 'robot_threshold',
80
+ 'Honey Pot' => 'honeypot',
81
+ 'Feeds' => 'feed',
82
+ 'Excluded URL' => 'excluded url',
83
+ '404 Pages' => '404',
84
+ 'Referrer Spam' => 'referrer_spam',
85
+ 'AJAX Request' => 'ajax'
86
+ );
87
+ $excluded_reason_translate = array( 'Robot' => json_encode( __( 'Robot', 'wp_statistics' ) ),
88
+ 'Browscap' => json_encode( __( 'Browscap', 'wp_statistics' ) ),
89
+ 'IP Match' => json_encode( __( 'IP Match', 'wp_statistics' ) ),
90
+ 'Self Referral' => json_encode( __( 'Self Referral', 'wp_statistics' ) ),
91
+ 'Login Page' => json_encode( __( 'Login Page', 'wp_statistics' ) ),
92
+ 'Admin Page' => json_encode( __( 'Admin Page', 'wp_statistics' ) ),
93
+ 'User Role' => json_encode( __( 'User Role', 'wp_statistics' ) ),
94
+ 'Total' => json_encode( __( 'Total', 'wp_statistics' ) ),
95
+ 'GeoIP' => json_encode( __( 'GeoIP', 'wp_statistics' ) ),
96
+ 'Hostname' => json_encode( __( 'Hostname', 'wp_statistics' ) ),
97
+ 'Robot Threshold' => json_encode( __( 'Robot Threshold', 'wp_statistics' ) ),
98
+ 'Honey Pot' => json_encode( __( 'Honey Pot', 'wp_statistics' ) ),
99
+ 'Feeds' => json_encode( __( 'Feeds', 'wp_statistics' ) ),
100
+ 'Excluded URL' => json_encode( __( 'Excluded URL', 'wp_statistics' ) ),
101
+ '404 Pages' => json_encode( __( '404 Pages', 'wp_statistics' ) ),
102
+ 'Referrer Spam' => json_encode( __( 'Referrer Spam', 'wp_statistics' ) ),
103
+ 'AJAX Request' => json_encode( __( 'AJAX Request', 'wp_statistics' ) )
104
+ );
105
+ $excluded_results = array( 'Total' => array() );
106
+ $excluded_total = 0;
107
+
108
+ foreach ( $excluded_reasons as $reason ) {
109
+
110
+ // The reasons array above is used both for display and internal purposes. Internally the values are all lower case but the array
111
+ // is created with mixed case so it looks nice to the user. Therefore we have to convert it to lower case here.
112
+ $thisreason = $excluded_reason_db[ $reason ];
113
 
114
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
115
+
116
+ // We're looping through the days backwards, so let's fine out what date we want to look at.
117
+ $thisdate = $WP_Statistics->real_current_date( 'Y-m-d', '-' . $i, $rangeend_utime );
118
+
119
+ // Create the SQL query string to get the data.
120
+ $query = $wpdb->prepare( "SELECT count FROM {$wpdb->prefix}statistics_exclusions WHERE reason = %s AND date = %s", $thisreason, $thisdate );
121
+
122
+ // Execute the query.
123
+ $excluded_results[ $reason ][ $i ] = $wpdb->get_var( $query );
124
+
125
+ // If we're returned an error or a FALSE value, then let's make sure it's set to a numerical 0.
126
+ if ( $excluded_results[ $reason ][ $i ] < 1 ) {
127
+ $excluded_results[ $reason ][ $i ] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
+
130
+ // Make sure to initialize the results so we don't get warnings when WP_DEBUG is enabled.
131
+ if ( ! array_key_exists( $i, $excluded_results['Total'] ) ) {
132
+ $excluded_results['Total'][ $i ] = 0;
133
+ }
134
+
135
+ // We're totalling things up here for use later.
136
+ $excluded_results['Total'][ $i ] += $excluded_results[ $reason ][ $i ];
137
+ $excluded_total += $excluded_results[ $reason ][ $i ];
138
  }
139
+ }
140
+
141
+ $excuded_all_time = $wpdb->get_var( "SELECT SUM(count) FROM {$wpdb->prefix}statistics_exclusions" );
142
+
143
+ // If the chart totals is enabled, cheat a little and just add another reason category to the list so it gets generated later.
144
+ if ( $total_stats == 1 ) {
145
+ $excluded_reasons[] = 'Total';
146
+ }
147
  ?>
148
  <div class="wrap">
149
+ <?php screen_icon( 'options-general' ); ?>
150
+ <h2><?php _e( 'Exclusions Statistics', 'wp_statistics' ); ?></h2>
151
 
152
  <?php wp_statistics_date_range_selector( WP_STATISTICS_EXCLUSIONS_PAGE, $daysToDisplay ); ?>
153
 
154
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
155
+ <div class="metabox-holder">
156
+ <div class="meta-box-sortables">
157
+ <div class="postbox">
158
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
159
+ <h3 class="hndle"><span><?php _e( 'Exclusions Statistical Chart', 'wp_statistics' ); ?></span></h3>
160
+ <div class="inside">
161
+ <script type="text/javascript">
162
+ var visit_chart;
163
+ jQuery(document).ready(function () {
164
+ <?php
165
+ foreach ( $excluded_reasons as $reason ) {
166
+
167
+ echo "var excluded_data_line_" . $excluded_reason_tags[ $reason ] . " = [";
168
+
169
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
170
+ echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $excluded_results[ $reason ][ $i ] . "], ";
171
+ }
172
 
173
  echo "];\n";
174
  }
175
+
176
  $tickInterval = round( $daysToDisplay / 20, 0 );
177
+ if ( $tickInterval < 1 ) {
178
+ $tickInterval = 1;
179
+ }
180
+ ?>
181
+ visit_chart = jQuery.jqplot('exclusion-stats', [<?php foreach ( $excluded_reasons as $reason ) {
182
+ echo "excluded_data_line_" . $excluded_reason_tags[ $reason ] . ", ";
183
+ } ?>], {
184
+ title: {
185
+ text: '<b>' + <?php echo json_encode( __( 'Excluded hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
186
+ fontSize: '12px',
187
+ fontFamily: 'Tahoma',
188
+ textColor: '#000000',
189
+ },
190
+ axes: {
191
+ xaxis: {
192
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime );?>',
193
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime );?>',
194
+ tickInterval: '<?php echo $tickInterval?> day',
195
+ renderer: jQuery.jqplot.DateAxisRenderer,
196
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
197
+ tickOptions: {
198
+ angle: -45,
199
+ formatString: '%b %#d',
200
+ showGridline: false,
201
+ },
202
+ },
203
+ yaxis: {
204
+ min: 0,
205
+ padMin: 1.0,
206
+ label: <?php echo json_encode( __( 'Number of excluded hits', 'wp_statistics' ) ); ?>,
207
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
208
+ labelOptions: {
209
+ angle: -90,
210
+ fontSize: '12px',
211
+ fontFamily: 'Tahoma',
212
+ fontWeight: 'bold',
213
+ },
214
+ }
215
+ },
216
+ legend: {
217
+ show: true,
218
+ location: 's',
219
+ placement: 'outsideGrid',
220
+ labels: [<?php foreach ( $excluded_reasons as $reason ) {
221
+ echo $excluded_reason_translate[ $reason ] . ", ";
222
+ } ?>],
223
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
224
+ rendererOptions: {
225
+ numberColumns: <?php echo count( $excluded_reasons ) + 1; ?>,
226
+ disableIEFading: false,
227
+ border: 'none',
228
+ },
229
+ },
230
+ highlighter: {
231
+ show: true,
232
+ bringSeriesToFront: true,
233
+ tooltipAxes: 'xy',
234
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
235
+ tooltipContentEditor: tooltipContentEditor,
236
+ },
237
+ grid: {
238
+ drawGridlines: true,
239
+ borderColor: 'transparent',
240
+ shadow: false,
241
+ drawBorder: false,
242
+ shadowColor: 'transparent'
243
+ },
244
+ });
245
+
246
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
247
+ // display series_label, x-axis_tick, y-axis value
248
+ return plot.legend.labels[seriesIndex] + ", " + str;
249
+ ;
250
+ }
251
+
252
+ jQuery(window).resize(function () {
253
+ JQPlotExclusionChartLengendClickRedraw()
254
+ });
255
+
256
+ function JQPlotExclusionChartLengendClickRedraw() {
257
+ visit_chart.replot({resetAxes: ['yaxis']});
258
+ jQuery('div[id="exclusion-stats"] .jqplot-table-legend').click(function () {
259
+ JQPlotExclusionChartLengendClickRedraw();
260
+ });
261
+ }
262
+
263
+ jQuery('div[id="exclusion-stats"] .jqplot-table-legend').click(function () {
264
+ JQPlotExclusionChartLengendClickRedraw()
265
+ });
266
+
267
+ });
268
+ </script>
269
+
270
+ <div id="exclusion-stats" style="height:500px;"></div>
271
+
272
+ </div>
273
+ </div>
274
+ </div>
275
+ </div>
276
+ </div>
277
+
278
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
279
+ <div class="metabox-holder">
280
+ <div class="meta-box-sortables">
281
+ <div class="postbox">
282
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
283
+ <h3 class="hndle"><span><?php _e( 'Hits Statistics Summary', 'wp_statistics' ); ?></span></h3>
284
+ <div class="inside">
285
+ <table width="auto" class="widefat table-stats" id="summary-stats">
286
+ <tbody>
287
+ <tr>
288
+ <th></th>
289
+ <th class="th-center"><?php _e( 'Exclusions', 'wp_statistics' ); ?></th>
290
+ </tr>
291
+
292
+ <tr>
293
+ <th><?php _e( 'Chart Total', 'wp_statistics' ); ?>:</th>
294
+ <th class="th-center"><span><?php echo number_format_i18n( $excluded_total ); ?></span>
295
+ </th>
296
+ </tr>
297
+
298
+ <tr>
299
+ <th><?php _e( 'All Time Total', 'wp_statistics' ); ?>:</th>
300
+ <th class="th-center">
301
+ <span><?php echo number_format_i18n( $excuded_all_time ); ?></span>
302
+ </th>
303
+ </tr>
304
+ </tbody>
305
+ </table>
306
+ </div>
307
+ </div>
308
+ </div>
309
+ </div>
310
+ </div>
311
 
312
  </div>
includes/log/hit-statistics.php CHANGED
@@ -1,45 +1,55 @@
1
  <script type="text/javascript">
2
- jQuery( document ).ready( function() {
3
- postboxes.add_postbox_toggles( pagenow );
4
- } );
5
  </script>
6
  <div class="wrap">
7
- <?php screen_icon('options-general'); ?>
8
- <h2><?php _e( 'Hit Statistics', 'wp_statistics' ); ?></h2>
9
 
10
  <?php
11
- $daysToDisplay = 20;
12
- if( array_key_exists( 'hitdays',$_GET ) ) { $daysToDisplay = intval( $_GET['hitdays'] ); }
13
-
14
- if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
15
- if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
16
-
17
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
18
-
19
- wp_statistics_date_range_selector( WP_STATISTICS_HITS_PAGE, $daysToDisplay );
 
 
 
 
 
 
 
 
 
 
20
  ?>
21
 
22
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
23
- <div class="metabox-holder">
24
- <div class="meta-box-sortables">
25
- <div class="postbox">
26
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
27
- <h3 class="hndle"><span><?php _e( 'Hits Statistics Chart', 'wp_statistics' ); ?></span></h3>
28
- <div class="inside">
29
- <script type="text/javascript">
30
- var visit_chart;
31
- jQuery( document ).ready( function() {
32
- <?php
33
  $visit_total = 0;
34
  $visitor_total = 0;
35
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
36
 
37
  echo "var visit_data_line = [";
38
 
39
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
40
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
41
- $stat = wp_statistics_visit( '-' . (int)( $i + $daysInThePast ), true );
42
- $visit_total += $stat;
43
 
44
  echo "['" . $working_date . "'," . $stat . "], ";
45
  }
@@ -48,9 +58,9 @@
48
 
49
  echo "var visitor_data_line = [";
50
 
51
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
52
- $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
53
- $stat = wp_statistics_visitor( '-' . (int)( $i + $daysInThePast ), true );
54
  $visitor_total += $stat;
55
 
56
  echo "['" . $working_date . "'," . $stat . "], ";
@@ -59,135 +69,143 @@
59
  echo "];\n";
60
 
61
  $tickInterval = round( $daysToDisplay / 20, 0 );
62
- if( $tickInterval < 1 ) { $tickInterval = 1; }
63
- ?>
64
- visit_chart = jQuery.jqplot( 'visits-stats', [visit_data_line, visitor_data_line], {
65
- title: {
66
- text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
67
- fontSize: '12px',
68
- fontFamily: 'Tahoma',
69
- textColor: '#000000',
70
- },
71
- axes: {
72
- xaxis: {
73
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-'.$daysToDisplay, $rangeend_utime ); ?>',
74
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
75
- tickInterval: '<?php echo $tickInterval; ?> day',
76
- renderer:jQuery.jqplot.DateAxisRenderer,
77
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
78
- tickOptions: {
79
- angle: -45,
80
- formatString:'%b %#d',
81
- showGridline: false,
82
- },
83
- },
84
- yaxis: {
85
- min: 0,
86
- padMin: 1.0,
87
- label: <?php echo json_encode( __( 'Number of visits and visitors', 'wp_statistics' ) ); ?>,
88
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
89
- labelOptions: {
90
- angle: -90,
91
- fontSize: '12px',
92
- fontFamily: 'Tahoma',
93
- fontWeight: 'bold',
94
- },
95
- }
96
- },
97
- legend: {
98
- show: true,
99
- location: 's',
100
- placement: 'outsideGrid',
101
- labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Visitor', 'wp_statistics' ) ); ?>],
102
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
103
- rendererOptions:
104
- {
105
- numberColumns: 2,
106
- disableIEFading: false,
107
- border: 'none',
108
- },
109
- },
110
- highlighter: {
111
- show: true,
112
- bringSeriesToFront: true,
113
- tooltipAxes: 'xy',
114
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
115
- tooltipContentEditor: tooltipContentEditor,
116
- },
117
- grid: {
118
- drawGridlines: true,
119
- borderColor: 'transparent',
120
- shadow: false,
121
- drawBorder: false,
122
- shadowColor: 'transparent'
123
- },
124
- } );
125
-
126
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
127
- // display series_label, x-axis_tick, y-axis value
128
- return plot.legend.labels[seriesIndex] + ", " + str;;
129
- }
130
-
131
- jQuery(window).resize(function() {
132
- JQPlotVisitChartLengendClickRedraw()
133
- });
134
-
135
- function JQPlotVisitChartLengendClickRedraw() {
136
- visit_chart.replot( {resetAxes: ['yaxis'] } );
137
-
138
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
139
- JQPlotVisitChartLengendClickRedraw();
140
- });
141
- }
142
-
143
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
144
- JQPlotVisitChartLengendClickRedraw()
145
- });
146
-
147
- });
148
-
149
- </script>
150
-
151
- <div id="visits-stats" style="height:500px;"></div>
152
-
153
- </div>
154
- </div>
155
- </div>
156
- </div>
157
- </div>
158
-
159
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
160
- <div class="metabox-holder">
161
- <div class="meta-box-sortables">
162
- <div class="postbox">
163
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
164
- <h3 class="hndle"><span><?php _e( 'Hits Statistics Summary', 'wp_statistics' ); ?></span></h3>
165
- <div class="inside">
166
- <table width="auto" class="widefat table-stats" id="summary-stats">
167
- <tbody>
168
- <tr>
169
- <th></th>
170
- <th class="th-center"><?php _e( 'Visit', 'wp_statistics' ); ?></th>
171
- <th class="th-center"><?php _e( 'Visitor', 'wp_statistics' ); ?></th>
172
- </tr>
173
-
174
- <tr>
175
- <th><?php _e('Chart Total', 'wp_statistics'); ?>:</th>
176
- <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span></th>
177
- <th class="th-center"><span><?php echo number_format_i18n( $visitor_total ); ?></span></th>
178
- </tr>
179
-
180
- <tr>
181
- <th><?php _e('All Time Total', 'wp_statistics'); ?>:</th>
182
- <th class="th-center"><span><?php echo number_format_i18n( wp_statistics_visit( 'total' ) ); ?></span></th>
183
- <th class="th-center"><span><?php echo number_format_i18n( wp_statistics_visitor( 'total', null, true ) ); ?></span></th>
184
- </tr>
185
- </tbody>
186
- </table>
187
- </div>
188
- </div>
189
- </div>
190
- </div>
191
- </div>
 
 
 
 
 
 
 
 
192
 
193
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <div class="wrap">
7
+ <?php screen_icon( 'options-general' ); ?>
8
+ <h2><?php _e( 'Hit Statistics', 'wp_statistics' ); ?></h2>
9
 
10
  <?php
11
+ $daysToDisplay = 20;
12
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
13
+ $daysToDisplay = intval( $_GET['hitdays'] );
14
+ }
15
+
16
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
17
+ $rangestart = $_GET['rangestart'];
18
+ } else {
19
+ $rangestart = '';
20
+ }
21
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
22
+ $rangeend = $_GET['rangeend'];
23
+ } else {
24
+ $rangeend = '';
25
+ }
26
+
27
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
28
+
29
+ wp_statistics_date_range_selector( WP_STATISTICS_HITS_PAGE, $daysToDisplay );
30
  ?>
31
 
32
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
33
+ <div class="metabox-holder">
34
+ <div class="meta-box-sortables">
35
+ <div class="postbox">
36
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
37
+ <h3 class="hndle"><span><?php _e( 'Hits Statistics Chart', 'wp_statistics' ); ?></span></h3>
38
+ <div class="inside">
39
+ <script type="text/javascript">
40
+ var visit_chart;
41
+ jQuery(document).ready(function () {
42
+ <?php
43
  $visit_total = 0;
44
  $visitor_total = 0;
45
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
46
 
47
  echo "var visit_data_line = [";
48
 
49
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
50
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
51
+ $stat = wp_statistics_visit( '-' . (int) ( $i + $daysInThePast ), true );
52
+ $visit_total += $stat;
53
 
54
  echo "['" . $working_date . "'," . $stat . "], ";
55
  }
58
 
59
  echo "var visitor_data_line = [";
60
 
61
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
62
+ $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
63
+ $stat = wp_statistics_visitor( '-' . (int) ( $i + $daysInThePast ), true );
64
  $visitor_total += $stat;
65
 
66
  echo "['" . $working_date . "'," . $stat . "], ";
69
  echo "];\n";
70
 
71
  $tickInterval = round( $daysToDisplay / 20, 0 );
72
+ if ( $tickInterval < 1 ) {
73
+ $tickInterval = 1;
74
+ }
75
+ ?>
76
+ visit_chart = jQuery.jqplot('visits-stats', [visit_data_line, visitor_data_line], {
77
+ title: {
78
+ text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
79
+ fontSize: '12px',
80
+ fontFamily: 'Tahoma',
81
+ textColor: '#000000',
82
+ },
83
+ axes: {
84
+ xaxis: {
85
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
86
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
87
+ tickInterval: '<?php echo $tickInterval; ?> day',
88
+ renderer: jQuery.jqplot.DateAxisRenderer,
89
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
90
+ tickOptions: {
91
+ angle: -45,
92
+ formatString: '%b %#d',
93
+ showGridline: false,
94
+ },
95
+ },
96
+ yaxis: {
97
+ min: 0,
98
+ padMin: 1.0,
99
+ label: <?php echo json_encode( __( 'Number of visits and visitors', 'wp_statistics' ) ); ?>,
100
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
101
+ labelOptions: {
102
+ angle: -90,
103
+ fontSize: '12px',
104
+ fontFamily: 'Tahoma',
105
+ fontWeight: 'bold',
106
+ },
107
+ }
108
+ },
109
+ legend: {
110
+ show: true,
111
+ location: 's',
112
+ placement: 'outsideGrid',
113
+ labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Visitor', 'wp_statistics' ) ); ?>],
114
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
115
+ rendererOptions: {
116
+ numberColumns: 2,
117
+ disableIEFading: false,
118
+ border: 'none',
119
+ },
120
+ },
121
+ highlighter: {
122
+ show: true,
123
+ bringSeriesToFront: true,
124
+ tooltipAxes: 'xy',
125
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
126
+ tooltipContentEditor: tooltipContentEditor,
127
+ },
128
+ grid: {
129
+ drawGridlines: true,
130
+ borderColor: 'transparent',
131
+ shadow: false,
132
+ drawBorder: false,
133
+ shadowColor: 'transparent'
134
+ },
135
+ });
136
+
137
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
138
+ // display series_label, x-axis_tick, y-axis value
139
+ return plot.legend.labels[seriesIndex] + ", " + str;
140
+ ;
141
+ }
142
+
143
+ jQuery(window).resize(function () {
144
+ JQPlotVisitChartLengendClickRedraw()
145
+ });
146
+
147
+ function JQPlotVisitChartLengendClickRedraw() {
148
+ visit_chart.replot({resetAxes: ['yaxis']});
149
+
150
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
151
+ JQPlotVisitChartLengendClickRedraw();
152
+ });
153
+ }
154
+
155
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
156
+ JQPlotVisitChartLengendClickRedraw()
157
+ });
158
+
159
+ });
160
+
161
+ </script>
162
+
163
+ <div id="visits-stats" style="height:500px;"></div>
164
+
165
+ </div>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
172
+ <div class="metabox-holder">
173
+ <div class="meta-box-sortables">
174
+ <div class="postbox">
175
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
176
+ <h3 class="hndle"><span><?php _e( 'Hits Statistics Summary', 'wp_statistics' ); ?></span></h3>
177
+ <div class="inside">
178
+ <table width="auto" class="widefat table-stats" id="summary-stats">
179
+ <tbody>
180
+ <tr>
181
+ <th></th>
182
+ <th class="th-center"><?php _e( 'Visit', 'wp_statistics' ); ?></th>
183
+ <th class="th-center"><?php _e( 'Visitor', 'wp_statistics' ); ?></th>
184
+ </tr>
185
+
186
+ <tr>
187
+ <th><?php _e( 'Chart Total', 'wp_statistics' ); ?>:</th>
188
+ <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
189
+ </th>
190
+ <th class="th-center"><span><?php echo number_format_i18n( $visitor_total ); ?></span>
191
+ </th>
192
+ </tr>
193
+
194
+ <tr>
195
+ <th><?php _e( 'All Time Total', 'wp_statistics' ); ?>:</th>
196
+ <th class="th-center">
197
+ <span><?php echo number_format_i18n( wp_statistics_visit( 'total' ) ); ?></span>
198
+ </th>
199
+ <th class="th-center">
200
+ <span><?php echo number_format_i18n( wp_statistics_visitor( 'total', null, true ) ); ?></span>
201
+ </th>
202
+ </tr>
203
+ </tbody>
204
+ </table>
205
+ </div>
206
+ </div>
207
+ </div>
208
+ </div>
209
+ </div>
210
 
211
  </div>
includes/log/last-search.php CHANGED
@@ -1,166 +1,173 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $search_engines = wp_statistics_searchengine_list();
8
-
9
- $search_result['All'] = wp_statistics_searchword('all','total');
10
 
11
- foreach( $search_engines as $key => $se ) {
12
- $search_result[$key] = wp_statistics_searchword($key,'total');
13
- }
14
-
15
- if( array_key_exists('referred',$_GET) ) {
16
- if( $_GET['referred'] != '' ) {
17
- $referred = $_GET['referred'];
18
- }
19
- else {
20
- $referred = 'All';
21
- }
22
- }
23
- else {
24
  $referred = 'All';
25
  }
26
-
27
- $total = $search_result[$referred];
 
 
 
28
  ?>
29
  <div class="wrap">
30
- <?php screen_icon('options-general'); ?>
31
- <h2><?php _e('Latest Search Words', 'wp_statistics'); ?></h2>
32
- <ul class="subsubsub">
33
- <?php
34
  $search_result_count = count( $search_result );
35
- $i = 0;
36
- $separator = ' | ';
37
-
38
- foreach( $search_result as $key => $value ) {
39
- $i++;
40
-
41
- if( $i == $search_result_count ) { $separator = ''; }
42
-
43
- if( $key == 'All' )
44
- {
45
- $tag = '';
46
- $name = 'All';
47
- $translate = __('All', 'wp_statistics');
48
- }
49
- else
50
- {
51
- $tag = $search_engines[$key]['tag'];
52
- $name = $search_engines[$key]['name'];
53
- $translate = $search_engines[$key]['translated'];
54
- }
55
-
56
  echo "<li><a href='?page=" . WP_STATISTICS_WORDS_PAGE . "&referred={$tag}'>" . $translate . " <span class='count'>({$value})</span></a></li>{$separator}";
57
  }
58
- ?>
59
- </ul>
60
- <div class="postbox-container" id="last-log">
61
- <div class="metabox-holder">
62
- <div class="meta-box-sortables">
63
- <div class="postbox">
64
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
65
- <h3 class="hndle"><span><?php _e('Latest Search Word Statistics', 'wp_statistics'); ?></span></h3>
66
- <div class="inside">
67
- <div class='log-latest'>
68
  <?php
69
- if( $total > 0 ) {
70
- // Instantiate pagination object with appropriate arguments
71
- $pagesPerSection = 10;
72
- $options = array(25, "All");
73
- $stylePageOff = "pageOff";
74
- $stylePageOn = "pageOn";
75
- $styleErrors = "paginationErrors";
76
- $styleSelect = "paginationSelect";
77
-
78
- $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect);
79
-
80
- $start = $Pagination->getEntryStart();
81
- $end = $Pagination->getEntryEnd();
82
-
83
- // Retrieve MySQL data
84
- if( $referred && $referred != '') {
85
- $search_query = wp_statistics_searchword_query($referred);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  } else {
87
- $search_query = wp_statistics_searchword_query('all');
 
88
  }
89
 
90
- // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
91
- $tablename = $wpdb->prefix . 'statistics_';
92
-
93
- if( $WP_Statistics->get_option('search_converted') ) {
94
- $tabletwo = $tablename . 'visitor';
95
- $tablename .= 'search';
96
- $result = $wpdb->get_results("SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}");
97
  } else {
98
- $tablename .= 'visitor';
99
- $result = $wpdb->get_results("SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}");
100
  }
101
-
102
- $ISOCountryCode = $WP_Statistics->get_country_codes();
103
-
104
- $dash_icon = wp_statistics_icons('dashicons-location-alt', 'map');
105
-
106
- foreach($result as $items) {
107
- if( !$WP_Statistics->Search_Engine_QueryString($items->referred) ) continue;
108
-
109
- if( substr( $items->ip, 0, 6 ) == '#hash#' ) {
110
- $ip_string = __('#hash#', 'wp_statistics');
111
- $map_string = "";
112
- }
113
- else {
114
- $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
115
- $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='".__('Map', 'wp_statistics')."'>{$dash_icon}</a>";
116
- }
117
-
118
- if( $WP_Statistics->get_option('search_converted') ) {
119
- $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine($items->engine);
120
- $words = $items->words;
121
- } else {
122
- $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
123
- $words = $WP_Statistics->Search_Engine_QueryString($items->referred);
124
- }
125
-
126
- echo "<div class='log-item'>";
127
- echo "<div class='log-referred'>".$words."</div>";
128
- echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . " - {$ip_string}</div>";
129
- echo "<div class='clear'></div>";
130
- echo "<div class='log-url'>";
131
- echo $map_string;
132
-
133
- if($WP_Statistics->get_option('geoip')) {
134
- echo "<img src='".plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png')."' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
135
- }
136
-
137
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='".plugins_url('wp-statistics/assets/images/' . $this_search_engine['image'])."' class='log-tools' title='".__($this_search_engine['name'], 'wp_statistics')."'/></a>";
138
-
139
- if( array_search( strtolower( $items->agent ), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
140
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$items->agent.".png' class='log-tools' title='{$items->agent}'/>";
141
- } else {
142
- $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
143
- }
144
-
145
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
146
-
147
- echo $WP_Statistics->get_referrer_link( $items->referred );
148
-
149
- echo "</div>";
150
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
 
152
 
153
- echo "</div>";
154
  ?>
155
- </div>
156
- </div>
157
-
158
- <div class="pagination-log">
159
- <?php if( $total > 0 ) { echo $Pagination->display(); ?>
160
- <p id="result-log"><?php echo ' ' . __('Page', 'wp_statistics') . ' ' . $Pagination->getCurrentPage() . ' ' . __('From', 'wp_statistics') . ' ' . $Pagination->getTotalPages(); ?></p>
161
- <?php }?>
162
- </div>
163
- </div>
164
- </div>
165
- </div>
166
- </div>
 
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $search_engines = wp_statistics_searchengine_list();
 
 
8
 
9
+ $search_result['All'] = wp_statistics_searchword( 'all', 'total' );
10
+
11
+ foreach ( $search_engines as $key => $se ) {
12
+ $search_result[ $key ] = wp_statistics_searchword( $key, 'total' );
13
+ }
14
+
15
+ if ( array_key_exists( 'referred', $_GET ) ) {
16
+ if ( $_GET['referred'] != '' ) {
17
+ $referred = $_GET['referred'];
18
+ } else {
 
 
 
19
  $referred = 'All';
20
  }
21
+ } else {
22
+ $referred = 'All';
23
+ }
24
+
25
+ $total = $search_result[ $referred ];
26
  ?>
27
  <div class="wrap">
28
+ <?php screen_icon( 'options-general' ); ?>
29
+ <h2><?php _e( 'Latest Search Words', 'wp_statistics' ); ?></h2>
30
+ <ul class="subsubsub">
31
+ <?php
32
  $search_result_count = count( $search_result );
33
+ $i = 0;
34
+ $separator = ' | ';
35
+
36
+ foreach ( $search_result as $key => $value ) {
37
+ $i ++;
38
+
39
+ if ( $i == $search_result_count ) {
40
+ $separator = '';
41
+ }
42
+
43
+ if ( $key == 'All' ) {
44
+ $tag = '';
45
+ $name = 'All';
46
+ $translate = __( 'All', 'wp_statistics' );
47
+ } else {
48
+ $tag = $search_engines[ $key ]['tag'];
49
+ $name = $search_engines[ $key ]['name'];
50
+ $translate = $search_engines[ $key ]['translated'];
51
+ }
52
+
 
53
  echo "<li><a href='?page=" . WP_STATISTICS_WORDS_PAGE . "&referred={$tag}'>" . $translate . " <span class='count'>({$value})</span></a></li>{$separator}";
54
  }
55
+ ?>
56
+ </ul>
57
+ <div class="postbox-container" id="last-log">
58
+ <div class="metabox-holder">
59
+ <div class="meta-box-sortables">
60
+ <div class="postbox">
61
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
62
+ <h3 class="hndle"><span><?php _e( 'Latest Search Word Statistics', 'wp_statistics' ); ?></span></h3>
63
+ <div class="inside">
64
+ <div class='log-latest'>
65
  <?php
66
+ if ( $total > 0 ) {
67
+ // Instantiate pagination object with appropriate arguments
68
+ $pagesPerSection = 10;
69
+ $options = array( 25, "All" );
70
+ $stylePageOff = "pageOff";
71
+ $stylePageOn = "pageOn";
72
+ $styleErrors = "paginationErrors";
73
+ $styleSelect = "paginationSelect";
74
+
75
+ $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
76
+
77
+ $start = $Pagination->getEntryStart();
78
+ $end = $Pagination->getEntryEnd();
79
+
80
+ // Retrieve MySQL data
81
+ if ( $referred && $referred != '' ) {
82
+ $search_query = wp_statistics_searchword_query( $referred );
83
+ } else {
84
+ $search_query = wp_statistics_searchword_query( 'all' );
85
+ }
86
+
87
+ // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
88
+ $tablename = $wpdb->prefix . 'statistics_';
89
+
90
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
91
+ $tabletwo = $tablename . 'visitor';
92
+ $tablename .= 'search';
93
+ $result = $wpdb->get_results( "SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}" );
94
+ } else {
95
+ $tablename .= 'visitor';
96
+ $result = $wpdb->get_results( "SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}" );
97
+ }
98
+
99
+ $ISOCountryCode = $WP_Statistics->get_country_codes();
100
+
101
+ $dash_icon = wp_statistics_icons( 'dashicons-location-alt', 'map' );
102
+
103
+ foreach ( $result as $items ) {
104
+ if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) {
105
+ continue;
106
+ }
107
+
108
+ if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
109
+ $ip_string = __( '#hash#', 'wp_statistics' );
110
+ $map_string = "";
111
  } else {
112
+ $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
113
+ $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp_statistics' ) . "'>{$dash_icon}</a>";
114
  }
115
 
116
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
117
+ $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine( $items->engine );
118
+ $words = $items->words;
 
 
 
 
119
  } else {
120
+ $this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
121
+ $words = $WP_Statistics->Search_Engine_QueryString( $items->referred );
122
  }
123
+
124
+ echo "<div class='log-item'>";
125
+ echo "<div class='log-referred'>" . $words . "</div>";
126
+ echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . " - {$ip_string}</div>";
127
+ echo "<div class='clear'></div>";
128
+ echo "<div class='log-url'>";
129
+ echo $map_string;
130
+
131
+ if ( $WP_Statistics->get_option( 'geoip' ) ) {
132
+ echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
+
135
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" . plugins_url( 'wp-statistics/assets/images/' . $this_search_engine['image'] ) . "' class='log-tools' title='" . __( $this_search_engine['name'], 'wp_statistics' ) . "'/></a>";
136
+
137
+ if ( array_search( strtolower( $items->agent ), array(
138
+ "chrome",
139
+ "firefox",
140
+ "msie",
141
+ "opera",
142
+ "safari"
143
+ ) ) !== false
144
+ ) {
145
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
146
+ } else {
147
+ $agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
148
+ }
149
+
150
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
151
+
152
+ echo $WP_Statistics->get_referrer_link( $items->referred );
153
+
154
+ echo "</div>";
155
+ echo "</div>";
156
  }
157
+ }
158
 
159
+ echo "</div>";
160
  ?>
161
+ </div>
162
+ </div>
163
+
164
+ <div class="pagination-log">
165
+ <?php if ( $total > 0 ) {
166
+ echo $Pagination->display(); ?>
167
+ <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
168
+ <?php } ?>
169
+ </div>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ </div>
includes/log/last-visitor.php CHANGED
@@ -1,145 +1,170 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $ISOCountryCode = $WP_Statistics->get_country_codes();
8
-
9
- $_var = 'agent';
10
- $_get = '%';
11
- $title = 'All';
12
-
13
- if( array_key_exists( 'agent', $_GET ) ) {
14
- $_var = 'agent';
15
- $_get = '%' . $_GET['agent'] . '%';
16
- $title = htmlentities( $_GET['agent'], ENT_QUOTES );
17
- }
18
-
19
- if( array_key_exists( 'ip', $_GET ) ) {
20
- $_var = 'ip';
21
- $_get = '%' . $_GET['ip'] . '%';
22
- $title = htmlentities( $_GET['ip'], ENT_QUOTES );
23
- }
24
-
25
- $total_visitor = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor`");
26
-
27
- if( $_get != '%' ) {
28
- $total = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get));
29
- } else {
30
- $total = $total_visitor;
31
- }
32
-
33
  ?>
34
  <div class="wrap">
35
- <?php screen_icon('options-general'); ?>
36
- <h2><?php _e('Recent Visitors', 'wp_statistics'); ?></h2>
37
- <ul class="subsubsub">
38
- <li class="all"><a <?php if($_get == '%') { echo 'class="current"'; } ?>href="?page=<?php echo WP_STATISTICS_VISITORS_PAGE; ?>"><?php _e('All', 'wp_statistics'); ?> <span class="count">(<?php echo $total_visitor; ?>)</span></a></li>
 
 
 
39
  <?php
40
- if( isset( $_var ) ) {
41
- $spacer = " | ";
42
-
43
- if($_var == 'agent') {
44
- $Browsers = wp_statistics_ua_list();
45
- $i = 0;
46
- $Total = count( $Browsers );
47
-
48
- foreach( $Browsers as $Browser ) {
49
- if($Browser == null) continue;
50
-
51
- $i++;
52
- if($title == $Browser) { $current = 'class="current" '; } else { $current = ""; }
53
- if( $i == $Total ) { $spacer = ""; }
54
- echo $spacer . "<li><a " . $current . "href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&agent=" . $Browser . "'> " . __($Browser, 'wp_statistics') ." <span class='count'>(" . number_format_i18n(wp_statistics_useragent($Browser)) .")</span></a></li>";
 
 
 
 
 
 
55
  }
 
 
 
 
 
56
  } else {
57
- if($_get != '%') { $current = 'class="current" '; } else { $current = ""; }
58
- echo $spacer . "<li><a {$current} href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&{$_var}={$_get}'>{$title} <span class='count'>({$total})</span></a></li>";
59
  }
 
60
  }
 
61
  ?>
62
- </ul>
63
- <div class="postbox-container" id="last-log">
64
- <div class="metabox-holder">
65
- <div class="meta-box-sortables">
66
- <div class="postbox">
67
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
68
- <h3 class="hndle"><span><?php _e('Recent Visitor Statistics', 'wp_statistics'); if($_get != '%') { echo ' [' . __('Filtered by', 'wp_statistics') . ': ' . $title . ']'; } ?></span></h3>
69
-
70
- <div class="inside">
71
- <?php
72
- // Instantiate pagination object with appropriate arguments
73
- $pagesPerSection = 10;
74
- $options = array(25, "All");
75
- $stylePageOff = "pageOff";
76
- $stylePageOn = "pageOn";
77
- $styleErrors = "paginationErrors";
78
- $styleSelect = "paginationSelect";
79
-
80
- $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect);
81
-
82
- $start = $Pagination->getEntryStart();
83
- $end = $Pagination->getEntryEnd();
84
-
85
- // Retrieve MySQL data
86
- if( $_get != '%' ) {
87
- $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$start}, {$end}", $_get));
88
- } else {
89
- $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$start}, {$end}");
90
- }
91
-
92
- // Check to see if User Agent logging is enabled.
93
- $DisplayUA = $WP_Statistics->get_option( "store_ua" );
94
-
95
- echo "<div class='log-latest'>";
96
-
97
- $dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
98
-
99
- foreach($result as $items) {
100
- if( substr( $items->ip, 0, 6 ) == '#hash#' ) {
101
- $ip_string = __('#hash#', 'wp_statistics');
102
- $map_string = "";
103
- }
104
- else {
105
- $ip_string = "<a href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
106
- $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='".__('Map', 'wp_statistics')."'>".wp_statistics_icons('dashicons-location-alt', 'map')."</a>";
107
- }
108
-
109
- echo "<div class='log-item'>";
110
- echo "<div class='log-referred'>{$ip_string}</div>";
111
- echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . "</div>";
112
- echo "<div class='clear'></div>";
113
- echo "<div class='log-url'>";
114
- echo $map_string;
115
-
116
- if($WP_Statistics->get_option('geoip')) {
117
- echo "<img src='".plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png')."' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
118
- }
119
-
120
- if( array_search( strtolower( $items->agent ), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
121
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$items->agent.".png' class='log-tools' title='{$items->agent}'/>";
122
- } else {
123
- $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
124
- }
125
-
126
- echo "<a href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&agent={$items->agent}'>{$agent}</a>";
127
-
128
- echo $WP_Statistics->get_referrer_link( $items->referred );
129
-
130
- echo "</div>";
131
- }
132
-
133
- echo "</div>";
134
- ?>
135
- </div>
136
- </div>
137
-
138
- <div class="pagination-log">
 
 
 
 
 
 
 
 
 
 
139
  <?php echo $Pagination->display(); ?>
140
- <p id="result-log"><?php echo ' ' . __('Page', 'wp_statistics') . ' ' . $Pagination->getCurrentPage() . ' ' . __('From', 'wp_statistics') . ' ' . $Pagination->getTotalPages(); ?></p>
141
- </div>
142
- </div>
143
- </div>
144
- </div>
145
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $ISOCountryCode = $WP_Statistics->get_country_codes();
8
+
9
+ $_var = 'agent';
10
+ $_get = '%';
11
+ $title = 'All';
12
+
13
+ if ( array_key_exists( 'agent', $_GET ) ) {
14
+ $_var = 'agent';
15
+ $_get = '%' . $_GET['agent'] . '%';
16
+ $title = htmlentities( $_GET['agent'], ENT_QUOTES );
17
+ }
18
+
19
+ if ( array_key_exists( 'ip', $_GET ) ) {
20
+ $_var = 'ip';
21
+ $_get = '%' . $_GET['ip'] . '%';
22
+ $title = htmlentities( $_GET['ip'], ENT_QUOTES );
23
+ }
24
+
25
+ $total_visitor = $wpdb->get_var( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor`" );
26
+
27
+ if ( $_get != '%' ) {
28
+ $total = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get ) );
29
+ } else {
30
+ $total = $total_visitor;
31
+ }
32
+
33
  ?>
34
  <div class="wrap">
35
+ <?php screen_icon( 'options-general' ); ?>
36
+ <h2><?php _e( 'Recent Visitors', 'wp_statistics' ); ?></h2>
37
+ <ul class="subsubsub">
38
+ <li class="all"><a <?php if ( $_get == '%' ) {
39
+ echo 'class="current"';
40
+ } ?>href="?page=<?php echo WP_STATISTICS_VISITORS_PAGE; ?>"><?php _e( 'All', 'wp_statistics' ); ?>
41
+ <span class="count">(<?php echo $total_visitor; ?>)</span></a></li>
42
  <?php
43
+ if ( isset( $_var ) ) {
44
+ $spacer = " | ";
45
+
46
+ if ( $_var == 'agent' ) {
47
+ $Browsers = wp_statistics_ua_list();
48
+ $i = 0;
49
+ $Total = count( $Browsers );
50
+
51
+ foreach ( $Browsers as $Browser ) {
52
+ if ( $Browser == null ) {
53
+ continue;
54
+ }
55
+
56
+ $i ++;
57
+ if ( $title == $Browser ) {
58
+ $current = 'class="current" ';
59
+ } else {
60
+ $current = "";
61
+ }
62
+ if ( $i == $Total ) {
63
+ $spacer = "";
64
  }
65
+ echo $spacer . "<li><a " . $current . "href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&agent=" . $Browser . "'> " . __( $Browser, 'wp_statistics' ) . " <span class='count'>(" . number_format_i18n( wp_statistics_useragent( $Browser ) ) . ")</span></a></li>";
66
+ }
67
+ } else {
68
+ if ( $_get != '%' ) {
69
+ $current = 'class="current" ';
70
  } else {
71
+ $current = "";
 
72
  }
73
+ echo $spacer . "<li><a {$current} href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&{$_var}={$_get}'>{$title} <span class='count'>({$total})</span></a></li>";
74
  }
75
+ }
76
  ?>
77
+ </ul>
78
+ <div class="postbox-container" id="last-log">
79
+ <div class="metabox-holder">
80
+ <div class="meta-box-sortables">
81
+ <div class="postbox">
82
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
83
+ <h3 class="hndle"><span><?php _e( 'Recent Visitor Statistics', 'wp_statistics' );
84
+ if ( $_get != '%' ) {
85
+ echo ' [' . __( 'Filtered by', 'wp_statistics' ) . ': ' . $title . ']';
86
+ } ?></span></h3>
87
+
88
+ <div class="inside">
89
+ <?php
90
+ // Instantiate pagination object with appropriate arguments
91
+ $pagesPerSection = 10;
92
+ $options = array( 25, "All" );
93
+ $stylePageOff = "pageOff";
94
+ $stylePageOn = "pageOn";
95
+ $styleErrors = "paginationErrors";
96
+ $styleSelect = "paginationSelect";
97
+
98
+ $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
99
+
100
+ $start = $Pagination->getEntryStart();
101
+ $end = $Pagination->getEntryEnd();
102
+
103
+ // Retrieve MySQL data
104
+ if ( $_get != '%' ) {
105
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$start}, {$end}", $_get ) );
106
+ } else {
107
+ $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$start}, {$end}" );
108
+ }
109
+
110
+ // Check to see if User Agent logging is enabled.
111
+ $DisplayUA = $WP_Statistics->get_option( "store_ua" );
112
+
113
+ echo "<div class='log-latest'>";
114
+
115
+ $dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
116
+
117
+ foreach ( $result as $items ) {
118
+ if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
119
+ $ip_string = __( '#hash#', 'wp_statistics' );
120
+ $map_string = "";
121
+ } else {
122
+ $ip_string = "<a href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
123
+ $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp_statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>";
124
+ }
125
+
126
+ echo "<div class='log-item'>";
127
+ echo "<div class='log-referred'>{$ip_string}</div>";
128
+ echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . "</div>";
129
+ echo "<div class='clear'></div>";
130
+ echo "<div class='log-url'>";
131
+ echo $map_string;
132
+
133
+ if ( $WP_Statistics->get_option( 'geoip' ) ) {
134
+ echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
135
+ }
136
+
137
+ if ( array_search( strtolower( $items->agent ), array(
138
+ "chrome",
139
+ "firefox",
140
+ "msie",
141
+ "opera",
142
+ "safari"
143
+ ) ) !== false
144
+ ) {
145
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
146
+ } else {
147
+ $agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
148
+ }
149
+
150
+ echo "<a href='?page=" . WP_STATISTICS_VISITORS_PAGE . "&agent={$items->agent}'>{$agent}</a>";
151
+
152
+ echo $WP_Statistics->get_referrer_link( $items->referred );
153
+
154
+ echo "</div>";
155
+ echo "</div>";
156
+ }
157
+
158
+ echo "</div>";
159
+ ?>
160
+ </div>
161
+ </div>
162
+
163
+ <div class="pagination-log">
164
  <?php echo $Pagination->display(); ?>
165
+ <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ </div>
170
  </div>
includes/log/log.php CHANGED
@@ -1,122 +1,124 @@
1
- <?php
2
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
3
-
4
- $nag_html = '';
5
- if( ! $WP_Statistics->get_option( 'disable_donation_nag', false ) ) {
6
- $nag_html = '<div id="wps_nag" class="update-nag" style="width: 90%;"><div id="donate-text"><p>' . __('Have you thought about donating to WP Statistics?', 'wp_statistics') . ' <a href="http://wp-statistics.com/donate/" target="_blank">'.__('Donate Now!', 'wp_statistics').'</a></p></div><div id="donate-button"><a class="button-primary" id="wps_close_nag">' . __('Close', 'wp_statistics') . '</a></div></div>';
7
- }
8
-
9
- // WP Statistics 10.0 had a bug which could corrupt the metabox display if the user re-ordered the widgets. Check to see if the meta data is corrupt and if so delete it.
10
- $widget_order = get_user_meta($WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page', true);
11
-
12
- if( is_array( $widget_order ) && count( $widget_order ) > 2 ) {
13
- delete_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page');
14
- }
15
-
16
- // Add the about box here as metaboxes added on the actual page load cannot be closed.
17
- add_meta_box( 'wps_about_postbox', sprintf(__('About WP Statistics Version %s', 'wp_statistics'), WP_STATISTICS_VERSION), 'wp_statistics_generate_overview_postbox_contents', $WP_Statistics->menu_slugs['overview'], 'side', null, array( 'widget' =>'about' ) );
18
-
19
- function wp_statistics_generate_overview_postbox_contents( $post, $args ) {
20
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url('wp-statistics/assets/images/') . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
21
- $widget = $args['args']['widget'];
22
- $container_id = str_replace( '.', '_', $widget . '_postbox' );
23
-
24
- echo '<div id="' . $container_id . '">' . $loading_img .'</div>';
25
- wp_statistics_generate_widget_load_javascript( $widget, $container_id );
26
- }
 
27
  ?>
28
  <div class="wrap">
29
  <?php echo $nag_html; ?>
30
- <?php screen_icon('options-general'); ?>
31
- <h2><?php echo get_admin_page_title(); ?></h2>
32
- <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
33
- <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
34
-
35
- <div class="metabox-holder" id="overview-widgets">
36
- <div class="postbox-container" id="wps-postbox-container-1">
37
- <?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'side', '' ); ?>
38
- </div>
39
-
40
- <div class="postbox-container" id="wps-postbox-container-2">
41
- <?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'normal', '' ); ?>
42
- </div>
43
- </div>
44
  </div>
45
  <?php
46
- $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
47
- $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
48
-
49
- $admin_url = get_admin_url() . "/admin.php?page=";
50
-
51
- $page_urls = array();
52
-
53
- $page_urls['wps_browsers_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE;
54
- $page_urls['wps_countries_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE;
55
- $page_urls['wps_exclusions_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE;
56
- $page_urls['wps_hits_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE;
57
- $page_urls['wps_online_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE;
58
- $page_urls['wps_pages_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE;
59
- $page_urls['wps_referring_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE;
60
- $page_urls['wps_search_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE;
61
- $page_urls['wps_words_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE;
62
- $page_urls['wps_top_visitors_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE;
63
- $page_urls['wps_recent_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE;
64
-
65
  ?>
66
  <script type="text/javascript">
67
- var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
68
- var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
69
-
70
- jQuery(document).ready(function(){
71
-
72
- // Add the "more" and "refresh" buttons.
73
- jQuery('.postbox').each( function () {
74
- var temp = jQuery( this );
75
- var temp_id = temp.attr( 'id' );
76
- var temp_html = temp.html();
77
- if( temp_id == 'wps_summary_postbox' || temp_id == 'wps_map_postbox' || temp_id == 'wps_about_postbox' ) {
78
- if( temp_id != 'wps_about_postbox' ) {
79
- new_text = '<?php echo $new_button;?>';
80
- new_text = new_text.replace( '{{refreshid}}', temp_id.replace( '_postbox', '_refresh_button' ) );
81
-
82
- temp_html = temp_html.replace( '</button>', new_text );
83
- }
84
- } else {
85
- new_text = '<?php echo $new_buttons;?>';
86
- new_text = new_text.replace( '{{refreshid}}', temp_id.replace( '_postbox', '_refresh_button' ) );
87
- new_text = new_text.replace( '{{moreid}}', temp_id.replace( '_postbox', '_more_button' ) );
88
-
89
- temp_html = temp_html.replace( '</button>', new_text );
90
- }
91
-
92
- temp.html( temp_html );
93
- });
94
-
95
- // close postboxes that should be closed
96
- jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
97
-
98
- // postboxes setup
99
- postboxes.add_postbox_toggles('<?php echo $WP_Statistics->menu_slugs['overview']; ?>');
100
-
101
- jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget );
102
- jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more );
103
-
104
- jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget );
105
-
106
- jQuery('#wps_close_nag').click( function(){
107
- var data = {
108
- 'action': 'wp_statistics_close_donation_nag',
109
- 'query': '',
110
- };
111
-
112
- jQuery.ajax({ url: ajaxurl,
113
- type: 'get',
114
- data: data,
115
- datatype: 'json',
116
- });
117
-
118
- jQuery('#wps_nag').hide();
119
- });
120
-
121
- });
 
122
  </script>
1
+ <?php
2
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp_statistics' ) . '"></div>';
3
+
4
+ $nag_html = '';
5
+ if ( ! $WP_Statistics->get_option( 'disable_donation_nag', false ) ) {
6
+ $nag_html = '<div id="wps_nag" class="update-nag" style="width: 90%;"><div id="donate-text"><p>' . __( 'Have you thought about donating to WP Statistics?', 'wp_statistics' ) . ' <a href="http://wp-statistics.com/donate/" target="_blank">' . __( 'Donate Now!', 'wp_statistics' ) . '</a></p></div><div id="donate-button"><a class="button-primary" id="wps_close_nag">' . __( 'Close', 'wp_statistics' ) . '</a></div></div>';
7
+ }
8
+
9
+ // WP Statistics 10.0 had a bug which could corrupt the metabox display if the user re-ordered the widgets. Check to see if the meta data is corrupt and if so delete it.
10
+ $widget_order = get_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page', true );
11
+
12
+ if ( is_array( $widget_order ) && count( $widget_order ) > 2 ) {
13
+ delete_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page' );
14
+ }
15
+
16
+ // Add the about box here as metaboxes added on the actual page load cannot be closed.
17
+ add_meta_box( 'wps_about_postbox', sprintf( __( 'About WP Statistics Version %s', 'wp_statistics' ), WP_STATISTICS_VERSION ), 'wp_statistics_generate_overview_postbox_contents', $WP_Statistics->menu_slugs['overview'], 'side', null, array( 'widget' => 'about' ) );
18
+
19
+ function wp_statistics_generate_overview_postbox_contents( $post, $args ) {
20
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp_statistics' ) . '"></div>';
21
+ $widget = $args['args']['widget'];
22
+ $container_id = str_replace( '.', '_', $widget . '_postbox' );
23
+
24
+ echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
25
+ wp_statistics_generate_widget_load_javascript( $widget, $container_id );
26
+ }
27
+
28
  ?>
29
  <div class="wrap">
30
  <?php echo $nag_html; ?>
31
+ <?php screen_icon( 'options-general' ); ?>
32
+ <h2><?php echo get_admin_page_title(); ?></h2>
33
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
34
+ <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
35
+
36
+ <div class="metabox-holder" id="overview-widgets">
37
+ <div class="postbox-container" id="wps-postbox-container-1">
38
+ <?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'side', '' ); ?>
39
+ </div>
40
+
41
+ <div class="postbox-container" id="wps-postbox-container-2">
42
+ <?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'normal', '' ); ?>
43
+ </div>
44
+ </div>
45
  </div>
46
  <?php
47
+ $new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '</button>';
48
+ $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '</button>';
49
+
50
+ $admin_url = get_admin_url() . "admin.php?page=";
51
+
52
+ $page_urls = array();
53
+
54
+ $page_urls['wps_browsers_more_button'] = $admin_url . WP_STATISTICS_BROWSERS_PAGE;
55
+ $page_urls['wps_countries_more_button'] = $admin_url . WP_STATISTICS_COUNTRIES_PAGE;
56
+ $page_urls['wps_exclusions_more_button'] = $admin_url . WP_STATISTICS_EXCLUSIONS_PAGE;
57
+ $page_urls['wps_hits_more_button'] = $admin_url . WP_STATISTICS_HITS_PAGE;
58
+ $page_urls['wps_online_more_button'] = $admin_url . WP_STATISTICS_ONLINE_PAGE;
59
+ $page_urls['wps_pages_more_button'] = $admin_url . WP_STATISTICS_PAGES_PAGE;
60
+ $page_urls['wps_referring_more_button'] = $admin_url . WP_STATISTICS_REFERRERS_PAGE;
61
+ $page_urls['wps_search_more_button'] = $admin_url . WP_STATISTICS_SEARCHES_PAGE;
62
+ $page_urls['wps_words_more_button'] = $admin_url . WP_STATISTICS_WORDS_PAGE;
63
+ $page_urls['wps_top_visitors_more_button'] = $admin_url . WP_STATISTICS_TOP_VISITORS_PAGE;
64
+ $page_urls['wps_recent_more_button'] = $admin_url . WP_STATISTICS_VISITORS_PAGE;
65
+
66
  ?>
67
  <script type="text/javascript">
68
+ var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
69
+ var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
70
+
71
+ jQuery(document).ready(function () {
72
+
73
+ // Add the "more" and "refresh" buttons.
74
+ jQuery('.postbox').each(function () {
75
+ var temp = jQuery(this);
76
+ var temp_id = temp.attr('id');
77
+ var temp_html = temp.html();
78
+ if (temp_id == 'wps_summary_postbox' || temp_id == 'wps_map_postbox' || temp_id == 'wps_about_postbox') {
79
+ if (temp_id != 'wps_about_postbox') {
80
+ new_text = '<?php echo $new_button;?>';
81
+ new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button'));
82
+
83
+ temp_html = temp_html.replace('</button>', new_text);
84
+ }
85
+ } else {
86
+ new_text = '<?php echo $new_buttons;?>';
87
+ new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button'));
88
+ new_text = new_text.replace('{{moreid}}', temp_id.replace('_postbox', '_more_button'));
89
+
90
+ temp_html = temp_html.replace('</button>', new_text);
91
+ }
92
+
93
+ temp.html(temp_html);
94
+ });
95
+
96
+ // close postboxes that should be closed
97
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
98
+
99
+ // postboxes setup
100
+ postboxes.add_postbox_toggles('<?php echo $WP_Statistics->menu_slugs['overview']; ?>');
101
+
102
+ jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
103
+ jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
104
+
105
+ jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
106
+
107
+ jQuery('#wps_close_nag').click(function () {
108
+ var data = {
109
+ 'action': 'wp_statistics_close_donation_nag',
110
+ 'query': '',
111
+ };
112
+
113
+ jQuery.ajax({
114
+ url: ajaxurl,
115
+ type: 'get',
116
+ data: data,
117
+ datatype: 'json',
118
+ });
119
+
120
+ jQuery('#wps_nag').hide();
121
+ });
122
+
123
+ });
124
  </script>
includes/log/online.php CHANGED
@@ -1,115 +1,121 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
 
8
  ?>
9
  <div class="wrap">
10
- <?php screen_icon('options-general'); ?>
11
- <h2><?php _e('Online Users', 'wp_statistics'); ?></h2>
12
- <div class="postbox-container" id="last-log">
13
- <div class="metabox-holder">
14
- <div class="meta-box-sortables">
15
-
16
- <div class="postbox">
17
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
18
- <h3 class="hndle"><span><?php _e('Online Users', 'wp_statistics'); ?></span></h3>
19
- <div class="inside">
20
- <?php
21
- $ISOCountryCode = $WP_Statistics->get_country_codes();
22
-
23
- $result = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}statistics_useronline;" );
24
- $total = count( $result );
25
-
26
- if( $total > 0 ) {
27
- // Instantiate pagination object with appropriate arguments
28
- $pagesPerSection = 10;
29
- $options = 10;
30
- $stylePageOff = "pageOff";
31
- $stylePageOn = "pageOn";
32
- $styleErrors = "paginationErrors";
33
- $styleSelect = "paginationSelect";
34
-
35
- $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect);
36
-
37
- $start = $Pagination->getEntryStart();
38
- $end = $Pagination->getEntryEnd();
39
-
40
- echo "<div class='log-latest'>";
41
- $count = 0;
42
-
43
- $dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
44
-
45
- foreach($result as $items) {
46
- $count++;
47
-
48
- if( $count >= $start ) {
49
- if( substr( $items->ip, 0, 6 ) == '#hash#' ) {
50
- $ip_string = __('#hash#', 'wp_statistics');
51
- $map_string = "";
52
- }
53
- else {
54
- $ip_string = "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
55
- $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='".__('Map', 'wp_statistics')."'>".wp_statistics_icons('dashicons-location-alt', 'map')."</a>";
56
- }
57
-
58
- echo "<div class='log-item'>";
59
- echo "<div class='log-url'>";
60
- echo $map_string;
61
-
62
- if($WP_Statistics->get_option('geoip')) {
63
- echo "<img src='".plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png')."' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
64
- }
65
-
66
- if( array_search( strtolower( $items->agent ), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
67
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$items->agent.".png' class='log-tools' title='{$items->agent}'/>";
68
- } else {
69
- $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
70
- }
71
-
72
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a> {$items->ip}";
73
- echo "<br>";
74
-
75
- echo __('Online for ', 'wp_statistics');
76
- $timediff = ($items->timestamp - $items->created);
77
-
78
- if( $timediff > 3600 ) {
79
- echo date( "H:i:s", ($items->timestamp - $items->created) );
80
- }
81
- else if( $timediff > 60 ) {
82
- echo "00:" . date( "i:s", ($items->timestamp - $items->created) );
83
- }
84
- else {
85
- echo "00:00:" . date( "s", ($items->timestamp - $items->created) );
86
- }
87
-
88
- echo " (HH:MM:SS)";
89
-
90
- echo "</div>";
91
- echo "</div>";
92
- }
93
-
94
- if( $count == $start + 10 ) { break; }
95
-
96
  }
97
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  echo "</div>";
99
- } else {
100
- echo "<div class='wps-center'>".__('Currently there are no users online in the site.', 'wp_statistics')."</div>";
 
 
 
101
  }
102
- ?>
103
- </div>
104
- </div>
105
-
106
- <?php if( $total > 0 ) {?>
107
- <div class="pagination-log">
108
- <?php echo $Pagination->display(); ?>
109
- <p id="result-log"><?php echo ' ' . __('Page', 'wp_statistics') . ' ' . $Pagination->getCurrentPage() . ' ' . __('From', 'wp_statistics') . ' ' . $Pagination->getTotalPages(); ?></p>
110
- </div>
111
- <?php } ?>
112
- </div>
113
- </div>
114
- </div>
 
 
 
 
 
 
 
115
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
 
8
  ?>
9
  <div class="wrap">
10
+ <?php screen_icon( 'options-general' ); ?>
11
+ <h2><?php _e( 'Online Users', 'wp_statistics' ); ?></h2>
12
+ <div class="postbox-container" id="last-log">
13
+ <div class="metabox-holder">
14
+ <div class="meta-box-sortables">
15
+
16
+ <div class="postbox">
17
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
18
+ <h3 class="hndle"><span><?php _e( 'Online Users', 'wp_statistics' ); ?></span></h3>
19
+ <div class="inside">
20
+ <?php
21
+ $ISOCountryCode = $WP_Statistics->get_country_codes();
22
+
23
+ $result = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}statistics_useronline;" );
24
+ $total = count( $result );
25
+
26
+ if ( $total > 0 ) {
27
+ // Instantiate pagination object with appropriate arguments
28
+ $pagesPerSection = 10;
29
+ $options = 10;
30
+ $stylePageOff = "pageOff";
31
+ $stylePageOn = "pageOn";
32
+ $styleErrors = "paginationErrors";
33
+ $styleSelect = "paginationSelect";
34
+
35
+ $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
36
+
37
+ $start = $Pagination->getEntryStart();
38
+ $end = $Pagination->getEntryEnd();
39
+
40
+ echo "<div class='log-latest'>";
41
+ $count = 0;
42
+
43
+ $dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
44
+
45
+ foreach ( $result as $items ) {
46
+ $count ++;
47
+
48
+ if ( $count >= $start ) {
49
+ if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
50
+ $ip_string = __( '#hash#', 'wp_statistics' );
51
+ $map_string = "";
52
+ } else {
53
+ $ip_string = "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
54
+ $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp_statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>";
55
+ }
56
+
57
+ echo "<div class='log-item'>";
58
+ echo "<div class='log-url'>";
59
+ echo $map_string;
60
+
61
+ if ( $WP_Statistics->get_option( 'geoip' ) ) {
62
+ echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
63
+ }
64
+
65
+ if ( array_search( strtolower( $items->agent ), array(
66
+ "chrome",
67
+ "firefox",
68
+ "msie",
69
+ "opera",
70
+ "safari"
71
+ ) ) !== false
72
+ ) {
73
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
74
+ } else {
75
+ $agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
+
78
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a> {$items->ip}";
79
+ echo "<br>";
80
+
81
+ echo __( 'Online for ', 'wp_statistics' );
82
+ $timediff = ( $items->timestamp - $items->created );
83
+
84
+ if ( $timediff > 3600 ) {
85
+ echo date( "H:i:s", ( $items->timestamp - $items->created ) );
86
+ } else if ( $timediff > 60 ) {
87
+ echo "00:" . date( "i:s", ( $items->timestamp - $items->created ) );
88
+ } else {
89
+ echo "00:00:" . date( "s", ( $items->timestamp - $items->created ) );
90
+ }
91
+
92
+ echo " (HH:MM:SS)";
93
+
94
  echo "</div>";
95
+ echo "</div>";
96
+ }
97
+
98
+ if ( $count == $start + 10 ) {
99
+ break;
100
  }
101
+
102
+ }
103
+
104
+ echo "</div>";
105
+ } else {
106
+ echo "<div class='wps-center'>" . __( 'Currently there are no users online in the site.', 'wp_statistics' ) . "</div>";
107
+ }
108
+ ?>
109
+ </div>
110
+ </div>
111
+
112
+ <?php if ( $total > 0 ) { ?>
113
+ <div class="pagination-log">
114
+ <?php echo $Pagination->display(); ?>
115
+ <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
116
+ </div>
117
+ <?php } ?>
118
+ </div>
119
+ </div>
120
+ </div>
121
  </div>
includes/log/page-statistics.php CHANGED
@@ -1,43 +1,70 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
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
-
12
- $post = get_post($pageid);
13
- if( is_object($post) ) { $title = $post->post_title; } else { $title = ""; }
14
-
15
- $urlfields = "&page-id={$pageid}";
16
- if( $pageuri ) { $urlfields .= "&page-uri={$pageuri}"; }
17
-
18
- $daysToDisplay = 20;
19
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval($_GET['hitdays']); }
20
-
21
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
22
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ?>
24
  <div class="wrap">
25
- <?php screen_icon('options-general'); ?>
26
- <h2><?php echo __('Page Trend for Post ID', 'wp_statistics') . ' ' . $pageid . ' - ' . $title; ?></h2>
27
 
28
  <?php wp_statistics_date_range_selector( WP_STATISTICS_PAGES_PAGE, $daysToDisplay, null, null, $urlfields ); ?>
29
 
30
- <div class="postbox-container" id="last-log">
31
- <div class="metabox-holder">
32
- <div class="meta-box-sortables">
33
- <div class="postbox">
34
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
35
- <h3 class="hndle"><span><?php _e('Page Trend', 'wp_statistics'); ?></span></h3>
36
- <div class="inside">
37
- <?php include_once( dirname( __FILE__ ) . '/widgets/page.php'); wp_statistics_generate_page_postbox_content( $pageuri, $pageid, $daysToDisplay, null, $rangestart, $rangeend ); ?>
38
- </div>
39
- </div>
40
- </div>
41
- </div>
42
- </div>
 
43
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ if ( array_key_exists( 'page-uri', $_GET ) ) {
8
+ $pageuri = $_GET['page-uri'];
9
+ } else {
10
+ $pageuri = null;
11
+ }
12
+ if ( array_key_exists( 'page-id', $_GET ) ) {
13
+ $pageid = (int) $_GET['page-id'];
14
+ } else {
15
+ $pageid = null;
16
+ }
17
 
18
+ if ( $pageuri && ! $pageid ) {
19
+ $pageid = wp_statistics_uri_to_id( $pageuri );
20
+ }
21
+
22
+ $post = get_post( $pageid );
23
+ if ( is_object( $post ) ) {
24
+ $title = $post->post_title;
25
+ } else {
26
+ $title = "";
27
+ }
28
+
29
+ $urlfields = "&page-id={$pageid}";
30
+ if ( $pageuri ) {
31
+ $urlfields .= "&page-uri={$pageuri}";
32
+ }
33
+
34
+ $daysToDisplay = 20;
35
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
36
+ $daysToDisplay = intval( $_GET['hitdays'] );
37
+ }
38
+
39
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
40
+ $rangestart = $_GET['rangestart'];
41
+ } else {
42
+ $rangestart = '';
43
+ }
44
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
45
+ $rangeend = $_GET['rangeend'];
46
+ } else {
47
+ $rangeend = '';
48
+ }
49
  ?>
50
  <div class="wrap">
51
+ <?php screen_icon( 'options-general' ); ?>
52
+ <h2><?php echo __( 'Page Trend for Post ID', 'wp_statistics' ) . ' ' . $pageid . ' - ' . $title; ?></h2>
53
 
54
  <?php wp_statistics_date_range_selector( WP_STATISTICS_PAGES_PAGE, $daysToDisplay, null, null, $urlfields ); ?>
55
 
56
+ <div class="postbox-container" id="last-log">
57
+ <div class="metabox-holder">
58
+ <div class="meta-box-sortables">
59
+ <div class="postbox">
60
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
61
+ <h3 class="hndle"><span><?php _e( 'Page Trend', 'wp_statistics' ); ?></span></h3>
62
+ <div class="inside">
63
+ <?php include_once( dirname( __FILE__ ) . '/widgets/page.php' );
64
+ wp_statistics_generate_page_postbox_content( $pageuri, $pageid, $daysToDisplay, null, $rangestart, $rangeend ); ?>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
  </div>
includes/log/search-statistics.php CHANGED
@@ -1,161 +1,184 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $search_engines = wp_statistics_searchengine_list();
8
 
9
- $daysToDisplay = 20;
10
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval($_GET['hitdays']); }
 
 
11
 
12
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
13
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
 
 
 
 
 
 
 
 
14
 
15
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
16
- $daysInThePast = round( ( time() - $rangeend_utime ) / 86400 ,0 );
17
  ?>
18
  <div class="wrap">
19
- <?php screen_icon('options-general'); ?>
20
- <h2><?php _e('Search Engine Referral Statistics', 'wp_statistics'); ?></h2>
21
 
22
  <?php wp_statistics_date_range_selector( WP_STATISTICS_SEARCHES_PAGE, $daysToDisplay ); ?>
23
 
24
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
25
- <div class="metabox-holder">
26
- <div class="meta-box-sortables">
27
- <div class="postbox">
28
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
29
- <h3 class="hndle"><span><?php _e('Search Engine Referral Statistics', 'wp_statistics'); ?></span></h3>
30
- <div class="inside">
31
- <script type="text/javascript">
32
- var visit_chart;
33
- jQuery( document ).ready( function() {
34
- <?php
 
35
  $total_stats = $WP_Statistics->get_option( 'chart_totals' );
36
  $total_daily = array();
37
 
38
- foreach( $search_engines as $se ) {
39
-
40
  echo "var searches_data_line_" . $se['tag'] . " = [";
41
-
42
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
43
- if( !array_key_exists( $i, $total_daily ) ) { $total_daily[$i] = 0; }
44
-
45
- $stat = wp_statistics_searchengine( $se['tag'], '-' . ( $i + $daysInThePast ) );
46
- $total_daily[$i] += $stat;
47
-
 
 
48
  echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
49
-
50
  }
51
 
52
  echo "];\n";
53
  }
54
 
55
- if( $total_stats == 1 ) {
56
  echo "var searches_data_line_total = [";
57
 
58
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
59
- echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $total_daily[$i] . "], ";
60
  }
61
-
62
  echo "];\n";
63
  }
64
-
65
  $tickInterval = round( $daysToDisplay / 20, 0 );
66
- if( $tickInterval < 1 ) { $tickInterval = 1; }
67
- ?>
68
- visit_chart = jQuery.jqplot( 'search-stats', [<?php foreach( $search_engines as $se ) { echo "searches_data_line_" . $se['tag'] . ", "; } if( $total_stats == 1 ) { echo 'searches_data_line_total'; }?>], {
69
- title: {
70
- text: '<b>' + <?php echo json_encode( __( 'Search engine referrals in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
71
- fontSize: '12px',
72
- fontFamily: 'Tahoma',
73
- textColor: '#000000',
74
- },
75
- axes: {
76
- xaxis: {
77
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
78
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
79
- tickInterval: '<?php echo $tickInterval; ?> day',
80
- renderer:jQuery.jqplot.DateAxisRenderer,
81
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
82
- tickOptions: {
83
- angle: -45,
84
- formatString:'%b %#d',
85
- showGridline: false,
86
- },
87
- },
88
- yaxis: {
89
- min: 0,
90
- padMin: 1.0,
91
- label: '<?php echo addslashes( __( 'Number of referrals', 'wp_statistics' ) ); ?>',
92
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
93
- labelOptions: {
94
- angle: -90,
95
- fontSize: '12px',
96
- fontFamily: 'Tahoma',
97
- fontWeight: 'bold',
98
- },
99
- }
100
- },
101
- legend: {
102
- show: true,
103
- location: 's',
104
- placement: 'outsideGrid',
105
- labels: [<?php foreach( $search_engines as $se ) { echo "'" . addslashes( $se['translated']) . "', "; } if( $total_stats == 1 ) { echo "'" . addslashes( __( 'Total', 'wp_statistics' ) ) . "'"; } ?>],
106
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
107
- rendererOptions:
108
- {
109
- numberColumns: <?php echo count( $search_engines ) + 1; ?>,
110
- disableIEFading: false,
111
- border: 'none',
112
- },
113
- },
114
- highlighter: {
115
- show: true,
116
- bringSeriesToFront: true,
117
- tooltipAxes: 'xy',
118
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
119
- tooltipContentEditor: tooltipContentEditor,
120
- },
121
- grid: {
122
- drawGridlines: true,
123
- borderColor: 'transparent',
124
- shadow: false,
125
- drawBorder: false,
126
- shadowColor: 'transparent'
127
- },
128
- } );
129
-
130
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
131
- // display series_label, x-axis_tick, y-axis value
132
- return plot.legend.labels[seriesIndex] + ", " + str;;
133
- }
134
-
135
- jQuery(window).resize( function() {
136
- JQPlotSearchChartLengendClickRedraw()
137
- });
138
-
139
- function JQPlotSearchChartLengendClickRedraw() {
140
- visit_chart.replot( {resetAxes: ['yaxis'] } );
141
- jQuery('div[id="search-stats"] .jqplot-table-legend').click( function() {
142
- JQPlotSearchChartLengendClickRedraw();
143
- });
144
- }
145
-
146
- jQuery('div[id="search-stats"] .jqplot-table-legend').click( function() {
147
- JQPlotSearchChartLengendClickRedraw()
148
- });
149
-
150
- });
151
-
152
- </script>
153
-
154
- <div id="search-stats" style="height:500px;"></div>
155
-
156
- </div>
157
- </div>
158
- </div>
159
- </div>
160
- </div>
 
 
 
 
 
 
 
 
 
 
161
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $search_engines = wp_statistics_searchengine_list();
8
 
9
+ $daysToDisplay = 20;
10
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
11
+ $daysToDisplay = intval( $_GET['hitdays'] );
12
+ }
13
 
14
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
15
+ $rangestart = $_GET['rangestart'];
16
+ } else {
17
+ $rangestart = '';
18
+ }
19
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
20
+ $rangeend = $_GET['rangeend'];
21
+ } else {
22
+ $rangeend = '';
23
+ }
24
 
25
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
26
+ $daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
27
  ?>
28
  <div class="wrap">
29
+ <?php screen_icon( 'options-general' ); ?>
30
+ <h2><?php _e( 'Search Engine Referral Statistics', 'wp_statistics' ); ?></h2>
31
 
32
  <?php wp_statistics_date_range_selector( WP_STATISTICS_SEARCHES_PAGE, $daysToDisplay ); ?>
33
 
34
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
35
+ <div class="metabox-holder">
36
+ <div class="meta-box-sortables">
37
+ <div class="postbox">
38
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
39
+ <h3 class="hndle"><span><?php _e( 'Search Engine Referral Statistics', 'wp_statistics' ); ?></span>
40
+ </h3>
41
+ <div class="inside">
42
+ <script type="text/javascript">
43
+ var visit_chart;
44
+ jQuery(document).ready(function () {
45
+ <?php
46
  $total_stats = $WP_Statistics->get_option( 'chart_totals' );
47
  $total_daily = array();
48
 
49
+ foreach ( $search_engines as $se ) {
50
+
51
  echo "var searches_data_line_" . $se['tag'] . " = [";
52
+
53
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
54
+ if ( ! array_key_exists( $i, $total_daily ) ) {
55
+ $total_daily[ $i ] = 0;
56
+ }
57
+
58
+ $stat = wp_statistics_searchengine( $se['tag'], '-' . ( $i + $daysInThePast ) );
59
+ $total_daily[ $i ] += $stat;
60
+
61
  echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
62
+
63
  }
64
 
65
  echo "];\n";
66
  }
67
 
68
+ if ( $total_stats == 1 ) {
69
  echo "var searches_data_line_total = [";
70
 
71
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
72
+ echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $total_daily[ $i ] . "], ";
73
  }
74
+
75
  echo "];\n";
76
  }
77
+
78
  $tickInterval = round( $daysToDisplay / 20, 0 );
79
+ if ( $tickInterval < 1 ) {
80
+ $tickInterval = 1;
81
+ }
82
+ ?>
83
+ visit_chart = jQuery.jqplot('search-stats', [<?php foreach ( $search_engines as $se ) {
84
+ echo "searches_data_line_" . $se['tag'] . ", ";
85
+ } if ( $total_stats == 1 ) {
86
+ echo 'searches_data_line_total';
87
+ }?>], {
88
+ title: {
89
+ text: '<b>' + <?php echo json_encode( __( 'Search engine referrals in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
90
+ fontSize: '12px',
91
+ fontFamily: 'Tahoma',
92
+ textColor: '#000000',
93
+ },
94
+ axes: {
95
+ xaxis: {
96
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
97
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
98
+ tickInterval: '<?php echo $tickInterval; ?> day',
99
+ renderer: jQuery.jqplot.DateAxisRenderer,
100
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
101
+ tickOptions: {
102
+ angle: -45,
103
+ formatString: '%b %#d',
104
+ showGridline: false,
105
+ },
106
+ },
107
+ yaxis: {
108
+ min: 0,
109
+ padMin: 1.0,
110
+ label: '<?php echo addslashes( __( 'Number of referrals', 'wp_statistics' ) ); ?>',
111
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
112
+ labelOptions: {
113
+ angle: -90,
114
+ fontSize: '12px',
115
+ fontFamily: 'Tahoma',
116
+ fontWeight: 'bold',
117
+ },
118
+ }
119
+ },
120
+ legend: {
121
+ show: true,
122
+ location: 's',
123
+ placement: 'outsideGrid',
124
+ labels: [<?php foreach ( $search_engines as $se ) {
125
+ echo "'" . addslashes( $se['translated'] ) . "', ";
126
+ } if ( $total_stats == 1 ) {
127
+ echo "'" . addslashes( __( 'Total', 'wp_statistics' ) ) . "'";
128
+ } ?>],
129
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
130
+ rendererOptions: {
131
+ numberColumns: <?php echo count( $search_engines ) + 1; ?>,
132
+ disableIEFading: false,
133
+ border: 'none',
134
+ },
135
+ },
136
+ highlighter: {
137
+ show: true,
138
+ bringSeriesToFront: true,
139
+ tooltipAxes: 'xy',
140
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
141
+ tooltipContentEditor: tooltipContentEditor,
142
+ },
143
+ grid: {
144
+ drawGridlines: true,
145
+ borderColor: 'transparent',
146
+ shadow: false,
147
+ drawBorder: false,
148
+ shadowColor: 'transparent'
149
+ },
150
+ });
151
+
152
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
153
+ // display series_label, x-axis_tick, y-axis value
154
+ return plot.legend.labels[seriesIndex] + ", " + str;
155
+ ;
156
+ }
157
+
158
+ jQuery(window).resize(function () {
159
+ JQPlotSearchChartLengendClickRedraw()
160
+ });
161
+
162
+ function JQPlotSearchChartLengendClickRedraw() {
163
+ visit_chart.replot({resetAxes: ['yaxis']});
164
+ jQuery('div[id="search-stats"] .jqplot-table-legend').click(function () {
165
+ JQPlotSearchChartLengendClickRedraw();
166
+ });
167
+ }
168
+
169
+ jQuery('div[id="search-stats"] .jqplot-table-legend').click(function () {
170
+ JQPlotSearchChartLengendClickRedraw()
171
+ });
172
+
173
+ });
174
+
175
+ </script>
176
+
177
+ <div id="search-stats" style="height:500px;"></div>
178
+
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ </div>
184
  </div>
includes/log/tags.php CHANGED
@@ -1,101 +1,117 @@
1
  <?php
2
 
3
-
4
  ?>
5
 
6
  <script type="text/javascript">
7
- jQuery( document ).ready( function() {
8
- postboxes.add_postbox_toggles( pagenow );
9
- } );
10
  </script>
11
  <div class="wrap">
12
- <?php screen_icon('options-general'); ?>
13
- <h2><?php _e( 'Tag Statistics', 'wp_statistics' ); ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- <?php
16
- $daysToDisplay = 20;
17
- if( array_key_exists( 'hitdays',$_GET ) ) { $daysToDisplay = intval( $_GET['hitdays'] ); }
 
 
 
 
 
 
18
 
19
- if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
20
- if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
21
- if( array_key_exists( 'tag', $_GET ) ) {
22
- $tag = $_GET['tag'];
23
  } else {
24
- if( array_key_exists( 'pretag', $_GET ) ) {
25
- $tag = $_GET['pretag'];
26
- } else {
27
- $tag = '';
28
- }
29
  }
30
 
31
- $html = __( 'Select Tag', 'wp_statistics' ) . ': ';
32
-
33
- $tags = get_tags();
34
 
35
- $html .= '<select name="tag" id="tag">';
 
 
36
 
37
- foreach ( $tags as $tag_obj ) {
38
- // If a tag hasn't been selected yet, use the first one in the tag list.
39
- if( '' === $tag ) { $tag = $tag_obj->slug; }
40
-
41
- // Check to see if this tag is the one that is currently selected.
42
- if( $tag_obj->slug === $tag ) { $selected = ' SELECTED'; } else { $selected = ''; }
43
-
44
- $html .= "<option value=\"{$tag_obj->slug}\"{$selected}>{$tag_obj->name}</option>";
45
- }
 
 
 
 
 
 
46
 
47
- $html .= '</select>';
48
- $html .= ' <input type="submit" value="' . __( 'Select', 'wp_statistics' ).'" class="button-primary">';
49
- $html .= '<br>';
50
-
51
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
52
-
53
- wp_statistics_date_range_selector( WP_STATISTICS_TAGS_PAGE, $daysToDisplay, NULL, NULL, '&pretag=' . $tag, $html );
54
-
55
- $args = array(
56
- 'tax_query' => array(
57
- array(
58
- 'taxonomy' => 'post_tag',
59
- 'field' => 'slug',
60
- 'terms' => sanitize_title( $tag ),
61
- )
62
- ),
63
- );
64
-
65
- $posts = get_posts( $args );
66
-
67
  ?>
68
 
69
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
70
- <div class="metabox-holder">
71
- <div class="meta-box-sortables">
72
- <div class="postbox">
73
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
74
- <h3 class="hndle"><span><?php _e( 'Tag Statistics Chart', 'wp_statistics' ); ?></span></h3>
75
- <div class="inside">
76
- <script type="text/javascript">
77
- var visit_chart;
78
- jQuery( document ).ready( function() {
79
- <?php
80
  $visit_total = 0;
81
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
82
  $posts_stats = array();
83
 
84
  // Setup the array, otherwise PHP may throw an error.
85
- foreach( $posts as $post ){
86
- $posts_stats[$post->ID] = 0;
87
  }
88
 
89
  echo "var visit_data_line = [";
90
 
91
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
92
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
93
 
94
  $stat = 0;
95
- foreach( $posts as $post ){
96
- $temp_stat = wp_statistics_pages( '-' . (int)( $i + $daysInThePast ), NULL, $post->ID );
97
- $posts_stats[$post->ID] += $temp_stat;
98
- $stat = $temp_stat;
99
  }
100
 
101
  $visit_total += $stat;
@@ -106,186 +122,193 @@
106
  echo "];\n";
107
 
108
  $tickInterval = round( $daysToDisplay / 20, 0 );
109
- if( $tickInterval < 1 ) { $tickInterval = 1; }
110
- ?>
111
- visit_chart = jQuery.jqplot( 'visits-stats', [visit_data_line], {
112
- title: {
113
- text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
114
- fontSize: '12px',
115
- fontFamily: 'Tahoma',
116
- textColor: '#000000',
117
- },
118
- axes: {
119
- xaxis: {
120
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-'.$daysToDisplay, $rangeend_utime ); ?>',
121
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
122
- tickInterval: '<?php echo $tickInterval; ?> day',
123
- renderer:jQuery.jqplot.DateAxisRenderer,
124
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
125
- tickOptions: {
126
- angle: -45,
127
- formatString:'%b %#d',
128
- showGridline: false,
129
- },
130
- },
131
- yaxis: {
132
- min: 0,
133
- padMin: 1.0,
134
- label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
135
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
136
- labelOptions: {
137
- angle: -90,
138
- fontSize: '12px',
139
- fontFamily: 'Tahoma',
140
- fontWeight: 'bold',
141
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
- },
144
- legend: {
145
- show: true,
146
- location: 's',
147
- placement: 'outsideGrid',
148
- labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
149
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
150
- rendererOptions:
151
- {
152
- numberColumns: 2,
153
- disableIEFading: false,
154
- border: 'none',
155
- },
156
- },
157
- highlighter: {
158
- show: true,
159
- bringSeriesToFront: true,
160
- tooltipAxes: 'xy',
161
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
162
- tooltipContentEditor: tooltipContentEditor,
163
- },
164
- grid: {
165
- drawGridlines: true,
166
- borderColor: 'transparent',
167
- shadow: false,
168
- drawBorder: false,
169
- shadowColor: 'transparent'
170
- },
171
- } );
172
-
173
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
174
- // display series_label, x-axis_tick, y-axis value
175
- return plot.legend.labels[seriesIndex] + ", " + str;;
176
- }
177
-
178
- jQuery(window).resize(function() {
179
- JQPlotVisitChartLengendClickRedraw()
180
- });
181
 
182
- function JQPlotVisitChartLengendClickRedraw() {
183
- visit_chart.replot( {resetAxes: ['yaxis'] } );
184
-
185
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
186
- JQPlotVisitChartLengendClickRedraw();
187
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  }
189
 
190
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click( function() {
191
- JQPlotVisitChartLengendClickRedraw()
192
- });
193
-
194
- });
195
-
196
- </script>
197
-
198
- <div id="visits-stats" style="height:500px;"></div>
199
-
200
- </div>
201
- </div>
202
- </div>
203
- </div>
204
- </div>
205
-
206
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
207
- <div class="metabox-holder">
208
- <div class="meta-box-sortables">
209
- <div class="postbox">
210
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
211
- <h3 class="hndle"><span><?php _e( 'Tag Statistics Summary', 'wp_statistics' ); ?></span></h3>
212
- <div class="inside">
213
- <table width="auto" class="widefat table-stats" id="summary-stats">
214
- <tbody>
215
- <tr>
216
- <th></th>
217
- <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
218
- </tr>
219
-
220
- <tr>
221
- <th><?php _e('Number of posts in tag', 'wp_statistics'); ?>:</th>
222
- <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span></th>
223
- </tr>
224
-
225
- <tr>
226
- <th><?php _e('Chart Visits Total', 'wp_statistics'); ?>:</th>
227
- <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span></th>
228
- </tr>
229
-
230
- <tr>
231
- <th><?php _e('All Time Visits Total', 'wp_statistics'); ?>:</th>
232
- <th class="th-center"><span><?php
233
-
234
- $stat = 0;
235
- foreach( $posts as $post ){
236
- $stat += wp_statistics_pages( 'total', NULL, $post->ID );
237
- }
238
-
239
- echo number_format_i18n( $stat ); ?></span></th>
240
- </tr>
241
- </tbody>
242
- </table>
243
- </div>
244
- </div>
245
- </div>
246
- </div>
247
- </div>
248
-
249
- <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
250
- <div class="metabox-holder">
251
- <div class="meta-box-sortables">
252
- <div class="postbox">
253
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
254
- <h3 class="hndle"><span><?php _e( 'Tag Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
255
- <div class="inside">
256
- <table width="auto" class="widefat table-stats" id="post-stats">
257
- <tbody>
258
- <tr>
259
- <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
260
- <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
261
- </tr>
262
-
263
- <?php
264
- arsort( $posts_stats );
265
-
266
- $posts_by_id = array();
267
-
268
- foreach( $posts as $post ) {
269
- $posts_by_id[$post->ID] = $post;
270
- }
271
-
272
- foreach( $posts_stats as $post_id => $post_stat ) {
273
- $post_obj = $posts_by_id[$post_id];
274
-
275
- ?>
276
- <tr>
277
- <th><a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a></th>
278
- <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span></th>
279
- </tr>
280
- <?php
281
- }
282
- ?>
283
- </tbody>
284
- </table>
285
- </div>
286
- </div>
287
- </div>
288
- </div>
289
- </div>
290
 
291
  </div>
1
  <?php
2
 
3
+
4
  ?>
5
 
6
  <script type="text/javascript">
7
+ jQuery(document).ready(function () {
8
+ postboxes.add_postbox_toggles(pagenow);
9
+ });
10
  </script>
11
  <div class="wrap">
12
+ <?php screen_icon( 'options-general' ); ?>
13
+ <h2><?php _e( 'Tag Statistics', 'wp_statistics' ); ?></h2>
14
+
15
+ <?php
16
+ $daysToDisplay = 20;
17
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
18
+ $daysToDisplay = intval( $_GET['hitdays'] );
19
+ }
20
+
21
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
22
+ $rangestart = $_GET['rangestart'];
23
+ } else {
24
+ $rangestart = '';
25
+ }
26
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
27
+ $rangeend = $_GET['rangeend'];
28
+ } else {
29
+ $rangeend = '';
30
+ }
31
+ if ( array_key_exists( 'tag', $_GET ) ) {
32
+ $tag = $_GET['tag'];
33
+ } else {
34
+ if ( array_key_exists( 'pretag', $_GET ) ) {
35
+ $tag = $_GET['pretag'];
36
+ } else {
37
+ $tag = '';
38
+ }
39
+ }
40
+
41
+ $html = __( 'Select Tag', 'wp_statistics' ) . ': ';
42
 
43
+ $tags = get_tags();
44
+
45
+ $html .= '<select name="tag" id="tag">';
46
+
47
+ foreach ( $tags as $tag_obj ) {
48
+ // If a tag hasn't been selected yet, use the first one in the tag list.
49
+ if ( '' === $tag ) {
50
+ $tag = $tag_obj->slug;
51
+ }
52
 
53
+ // Check to see if this tag is the one that is currently selected.
54
+ if ( $tag_obj->slug === $tag ) {
55
+ $selected = ' SELECTED';
 
56
  } else {
57
+ $selected = '';
 
 
 
 
58
  }
59
 
60
+ $html .= "<option value=\"{$tag_obj->slug}\"{$selected}>{$tag_obj->name}</option>";
61
+ }
 
62
 
63
+ $html .= '</select>';
64
+ $html .= ' <input type="submit" value="' . __( 'Select', 'wp_statistics' ) . '" class="button-primary">';
65
+ $html .= '<br>';
66
 
67
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
68
+
69
+ wp_statistics_date_range_selector( WP_STATISTICS_TAGS_PAGE, $daysToDisplay, null, null, '&pretag=' . $tag, $html );
70
+
71
+ $args = array(
72
+ 'tax_query' => array(
73
+ array(
74
+ 'taxonomy' => 'post_tag',
75
+ 'field' => 'slug',
76
+ 'terms' => sanitize_title( $tag ),
77
+ )
78
+ ),
79
+ );
80
+
81
+ $posts = get_posts( $args );
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  ?>
84
 
85
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
86
+ <div class="metabox-holder">
87
+ <div class="meta-box-sortables">
88
+ <div class="postbox">
89
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
90
+ <h3 class="hndle"><span><?php _e( 'Tag Statistics Chart', 'wp_statistics' ); ?></span></h3>
91
+ <div class="inside">
92
+ <script type="text/javascript">
93
+ var visit_chart;
94
+ jQuery(document).ready(function () {
95
+ <?php
96
  $visit_total = 0;
97
  $daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
98
  $posts_stats = array();
99
 
100
  // Setup the array, otherwise PHP may throw an error.
101
+ foreach ( $posts as $post ) {
102
+ $posts_stats[ $post->ID ] = 0;
103
  }
104
 
105
  echo "var visit_data_line = [";
106
 
107
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
108
  $working_date = $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . ( $i + $daysInThePast ), $rangeend_utime );
109
 
110
  $stat = 0;
111
+ foreach ( $posts as $post ) {
112
+ $temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
113
+ $posts_stats[ $post->ID ] += $temp_stat;
114
+ $stat = $temp_stat;
115
  }
116
 
117
  $visit_total += $stat;
122
  echo "];\n";
123
 
124
  $tickInterval = round( $daysToDisplay / 20, 0 );
125
+ if ( $tickInterval < 1 ) {
126
+ $tickInterval = 1;
127
+ }
128
+ ?>
129
+ visit_chart = jQuery.jqplot('visits-stats', [visit_data_line], {
130
+ title: {
131
+ text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $daysToDisplay . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
132
+ fontSize: '12px',
133
+ fontFamily: 'Tahoma',
134
+ textColor: '#000000',
135
+ },
136
+ axes: {
137
+ xaxis: {
138
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
139
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
140
+ tickInterval: '<?php echo $tickInterval; ?> day',
141
+ renderer: jQuery.jqplot.DateAxisRenderer,
142
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
143
+ tickOptions: {
144
+ angle: -45,
145
+ formatString: '%b %#d',
146
+ showGridline: false,
147
+ },
148
+ },
149
+ yaxis: {
150
+ min: 0,
151
+ padMin: 1.0,
152
+ label: <?php echo json_encode( __( 'Number of visits', 'wp_statistics' ) ); ?>,
153
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
154
+ labelOptions: {
155
+ angle: -90,
156
+ fontSize: '12px',
157
+ fontFamily: 'Tahoma',
158
+ fontWeight: 'bold',
159
+ },
160
+ }
161
+ },
162
+ legend: {
163
+ show: true,
164
+ location: 's',
165
+ placement: 'outsideGrid',
166
+ labels: [<?php echo json_encode( __( 'Visit', 'wp_statistics' ) ); ?>],
167
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
168
+ rendererOptions: {
169
+ numberColumns: 2,
170
+ disableIEFading: false,
171
+ border: 'none',
172
+ },
173
+ },
174
+ highlighter: {
175
+ show: true,
176
+ bringSeriesToFront: true,
177
+ tooltipAxes: 'xy',
178
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
179
+ tooltipContentEditor: tooltipContentEditor,
180
+ },
181
+ grid: {
182
+ drawGridlines: true,
183
+ borderColor: 'transparent',
184
+ shadow: false,
185
+ drawBorder: false,
186
+ shadowColor: 'transparent'
187
+ },
188
+ });
189
+
190
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
191
+ // display series_label, x-axis_tick, y-axis value
192
+ return plot.legend.labels[seriesIndex] + ", " + str;
193
+ ;
194
+ }
195
+
196
+ jQuery(window).resize(function () {
197
+ JQPlotVisitChartLengendClickRedraw()
198
+ });
199
+
200
+ function JQPlotVisitChartLengendClickRedraw() {
201
+ visit_chart.replot({resetAxes: ['yaxis']});
202
+
203
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
204
+ JQPlotVisitChartLengendClickRedraw();
205
+ });
206
+ }
207
+
208
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
209
+ JQPlotVisitChartLengendClickRedraw()
210
+ });
211
+
212
+ });
213
+
214
+ </script>
215
+
216
+ <div id="visits-stats" style="height:500px;"></div>
217
+
218
+ </div>
219
+ </div>
220
+ </div>
221
+ </div>
222
+ </div>
223
+
224
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
225
+ <div class="metabox-holder">
226
+ <div class="meta-box-sortables">
227
+ <div class="postbox">
228
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
229
+ <h3 class="hndle"><span><?php _e( 'Tag Statistics Summary', 'wp_statistics' ); ?></span></h3>
230
+ <div class="inside">
231
+ <table width="auto" class="widefat table-stats" id="summary-stats">
232
+ <tbody>
233
+ <tr>
234
+ <th></th>
235
+ <th class="th-center"><?php _e( 'Count', 'wp_statistics' ); ?></th>
236
+ </tr>
237
+
238
+ <tr>
239
+ <th><?php _e( 'Number of posts in tag', 'wp_statistics' ); ?>:</th>
240
+ <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
241
+ </th>
242
+ </tr>
243
+
244
+ <tr>
245
+ <th><?php _e( 'Chart Visits Total', 'wp_statistics' ); ?>:</th>
246
+ <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
247
+ </th>
248
+ </tr>
249
+
250
+ <tr>
251
+ <th><?php _e( 'All Time Visits Total', 'wp_statistics' ); ?>:</th>
252
+ <th class="th-center"><span><?php
253
+
254
+ $stat = 0;
255
+ foreach ( $posts as $post ) {
256
+ $stat += wp_statistics_pages( 'total', null, $post->ID );
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
+ echo number_format_i18n( $stat ); ?></span></th>
260
+ </tr>
261
+ </tbody>
262
+ </table>
263
+ </div>
264
+ </div>
265
+ </div>
266
+ </div>
267
+ </div>
268
+
269
+ <div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
270
+ <div class="metabox-holder">
271
+ <div class="meta-box-sortables">
272
+ <div class="postbox">
273
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
274
+ <h3 class="hndle"><span><?php _e( 'Tag Posts Sorted by Hits', 'wp_statistics' ); ?></span></h3>
275
+ <div class="inside">
276
+ <table width="auto" class="widefat table-stats" id="post-stats">
277
+ <tbody>
278
+ <tr>
279
+ <th><?php _e( 'Post Title', 'wp_statistics' ); ?></th>
280
+ <th class="th-center"><?php _e( 'Hits', 'wp_statistics' ); ?></th>
281
+ </tr>
282
+
283
+ <?php
284
+ arsort( $posts_stats );
285
+
286
+ $posts_by_id = array();
287
+
288
+ foreach ( $posts as $post ) {
289
+ $posts_by_id[ $post->ID ] = $post;
290
  }
291
 
292
+ foreach ( $posts_stats as $post_id => $post_stat ) {
293
+ $post_obj = $posts_by_id[ $post_id ];
294
+
295
+ ?>
296
+ <tr>
297
+ <th>
298
+ <a href="<?php echo get_permalink( $post_obj ); ?>"><?php echo $post_obj->post_title; ?></a>
299
+ </th>
300
+ <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
301
+ </th>
302
+ </tr>
303
+ <?php
304
+ }
305
+ ?>
306
+ </tbody>
307
+ </table>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ </div>
312
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
  </div>
includes/log/top-countries.php CHANGED
@@ -1,72 +1,81 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $daysToDisplay = 20;
8
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval($_GET['hitdays']); }
 
 
9
 
10
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
11
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
 
 
 
 
 
 
 
 
12
 
13
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
14
 
15
  ?>
16
  <div class="wrap">
17
- <?php screen_icon('options-general'); ?>
18
- <h2><?php _e('Top Countries', 'wp_statistics'); ?></h2>
19
 
20
  <?php wp_statistics_date_range_selector( WP_STATISTICS_COUNTRIES_PAGE, $daysToDisplay ); ?>
21
 
22
- <div class="postbox-container" id="last-log" style="width: 100%;">
23
- <div class="metabox-holder">
24
- <div class="meta-box-sortables">
25
- <div class="postbox">
26
- <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?>"><br /></div>
27
- <h3 class="hndle"><span><?php _e('Top Countries', 'wp_statistics'); ?></span></h3>
28
- <div class="inside">
29
- <table class="widefat table-stats" id="last-referrer" style="width: 100%;">
30
- <tr>
31
- <td><?php _e('Rank', 'wp_statistics'); ?></td>
32
- <td><?php _e('Flag', 'wp_statistics'); ?></td>
33
- <td><?php _e('Country', 'wp_statistics'); ?></td>
34
- <td><?php _e('Visitor Count', 'wp_statistics'); ?></td>
35
- </tr>
36
-
37
  <?php
38
- $ISOCountryCode = $WP_Statistics->get_country_codes();
39
-
40
- $result = $wpdb->get_results("SELECT DISTINCT `location` FROM `{$wpdb->prefix}statistics_visitor`");
41
-
42
- $rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime );
43
- $rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime );
44
-
45
- foreach( $result as $item )
46
- {
47
- $Countries[$item->location] = $wpdb->get_var( $wpdb->prepare( "SELECT count(location) FROM `{$wpdb->prefix}statistics_visitor` WHERE location=%s AND `last_counter` BETWEEN %s AND %s", $item->location, $rangestartdate, $rangeenddate ) );
48
- }
49
-
50
- arsort($Countries);
51
- $i = 0;
52
-
53
- foreach( $Countries as $item => $value) {
54
- $i++;
 
55
 
56
- $item = strtoupper($item);
57
-
58
- echo "<tr>";
59
- echo "<td style='text-align: center;'>$i</td>";
60
- echo "<td style='text-align: center;'><img src='".plugins_url('wp-statistics/assets/images/flags/' . $item . '.png')."' title='{$ISOCountryCode[$item]}'/></td>";
61
- echo "<td style='text-align: left; direction: ltr;'>{$ISOCountryCode[$item]}</td>";
62
- echo "<td style='text-align: center;'>" . number_format_i18n($value) . "</td>";
63
- echo "</tr>";
64
- }
65
  ?>
66
- </table>
67
- </div>
68
- </div>
69
- </div>
70
- </div>
71
- </div>
72
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $daysToDisplay = 20;
8
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
9
+ $daysToDisplay = intval( $_GET['hitdays'] );
10
+ }
11
 
12
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
13
+ $rangestart = $_GET['rangestart'];
14
+ } else {
15
+ $rangestart = '';
16
+ }
17
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
18
+ $rangeend = $_GET['rangeend'];
19
+ } else {
20
+ $rangeend = '';
21
+ }
22
 
23
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
24
 
25
  ?>
26
  <div class="wrap">
27
+ <?php screen_icon( 'options-general' ); ?>
28
+ <h2><?php _e( 'Top Countries', 'wp_statistics' ); ?></h2>
29
 
30
  <?php wp_statistics_date_range_selector( WP_STATISTICS_COUNTRIES_PAGE, $daysToDisplay ); ?>
31
 
32
+ <div class="postbox-container" id="last-log" style="width: 100%;">
33
+ <div class="metabox-holder">
34
+ <div class="meta-box-sortables">
35
+ <div class="postbox">
36
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
37
+ <h3 class="hndle"><span><?php _e( 'Top Countries', 'wp_statistics' ); ?></span></h3>
38
+ <div class="inside">
39
+ <table class="widefat table-stats" id="last-referrer" style="width: 100%;">
40
+ <tr>
41
+ <td><?php _e( 'Rank', 'wp_statistics' ); ?></td>
42
+ <td><?php _e( 'Flag', 'wp_statistics' ); ?></td>
43
+ <td><?php _e( 'Country', 'wp_statistics' ); ?></td>
44
+ <td><?php _e( 'Visitor Count', 'wp_statistics' ); ?></td>
45
+ </tr>
46
+
47
  <?php
48
+ $ISOCountryCode = $WP_Statistics->get_country_codes();
49
+
50
+ $result = $wpdb->get_results( "SELECT DISTINCT `location` FROM `{$wpdb->prefix}statistics_visitor`" );
51
+
52
+ $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
53
+ $rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
54
+
55
+ foreach ( $result as $item ) {
56
+ $Countries[ $item->location ] = $wpdb->get_var( $wpdb->prepare( "SELECT count(location) FROM `{$wpdb->prefix}statistics_visitor` WHERE location=%s AND `last_counter` BETWEEN %s AND %s", $item->location, $rangestartdate, $rangeenddate ) );
57
+ }
58
+
59
+ arsort( $Countries );
60
+ $i = 0;
61
+
62
+ foreach ( $Countries as $item => $value ) {
63
+ $i ++;
64
+
65
+ $item = strtoupper( $item );
66
 
67
+ echo "<tr>";
68
+ echo "<td style='text-align: center;'>$i</td>";
69
+ echo "<td style='text-align: center;'><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item . '.png' ) . "' title='{$ISOCountryCode[$item]}'/></td>";
70
+ echo "<td style='text-align: left; direction: ltr;'>{$ISOCountryCode[$item]}</td>";
71
+ echo "<td style='text-align: center;'>" . number_format_i18n( $value ) . "</td>";
72
+ echo "</tr>";
73
+ }
 
 
74
  ?>
75
+ </table>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
  </div>
includes/log/top-pages.php CHANGED
@@ -1,212 +1,230 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
  <?php
7
- $daysToDisplay = 20;
8
- if( array_key_exists('hitdays',$_GET) ) { $daysToDisplay = intval( $_GET['hitdays'] ); }
9
-
10
- if( array_key_exists('rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = ''; }
11
- if( array_key_exists('rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = ''; }
12
-
13
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
14
- $daysInThePast = round( ( time() - $rangeend_utime ) / 86400 , 0 );
15
-
16
- list( $total, $uris ) = wp_statistics_get_top_pages( $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangestart_utime ), $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ) );
 
 
 
 
 
 
 
 
 
 
17
 
18
  ?>
19
  <div class="wrap">
20
- <?php screen_icon('options-general'); ?>
21
- <h2><?php _e('Top Pages', 'wp_statistics'); ?></h2>
22
 
23
  <?php wp_statistics_date_range_selector( WP_STATISTICS_PAGES_PAGE, $daysToDisplay ); ?>
24
 
25
- <div class="postbox-container" id="last-log">
26
- <div class="metabox-holder">
27
- <div class="meta-box-sortables">
28
-
29
- <div class="postbox">
30
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
31
- <h3 class="hndle"><span><?php _e( 'Top 5 Pages Trends', 'wp_statistics' ); ?></span></h3>
32
- <div class="inside">
33
- <script type="text/javascript">
34
- var pages_jqchart;
35
- jQuery(document).ready( function() {
36
- <?php
37
  $count = 0;
38
-
39
- foreach( $uris as $uri ) {
40
-
41
- $count++;
42
-
43
  echo "var pages_data_line" . $count . " = [";
44
-
45
- for( $i = $daysToDisplay; $i >= 0; $i--) {
46
  $stat = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $uri[0] );
47
-
48
  echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
49
-
50
  }
51
 
52
  echo "];\n";
53
- if( $count > 4 ) { break; }
 
 
54
  }
55
 
56
- if( $count < 6 ) {
57
- for( $i = $count + 1 ; $i < 6; $i++ ) {
58
  echo "var pages_data_line" . $i . " = [];\n";
59
  }
60
  }
61
-
62
- $tickInterval = round( $daysToDisplay / 20, 0 );
63
- if( $tickInterval < 1 ) { $tickInterval = 1; }
64
- ?>
65
 
66
- pages_jqchart = jQuery.jqplot('jqpage-stats', [pages_data_line1, pages_data_line2, pages_data_line3, pages_data_line4, pages_data_line5], {
67
- title: {
68
- text: '<b><?php echo htmlentities( __( 'Top 5 Page Trending Stats', 'wp_statistics' ), ENT_QUOTES ); ?></b>',
69
- fontSize: '12px',
70
- fontFamily: 'Tahoma',
71
- textColor: '#000000',
72
- },
73
- axes: {
74
- xaxis: {
75
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
76
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
77
- tickInterval: '<?php echo $tickInterval; ?> day',
78
- renderer:jQuery.jqplot.DateAxisRenderer,
79
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
80
- tickOptions: {
81
- angle: -45,
82
- formatString:'%b %#d',
83
- showGridline: false,
84
- },
85
- },
86
- yaxis: {
87
- min: 0,
88
- padMin: 1.0,
89
- label: <?php echo json_encode( __( 'Number of Hits', 'wp_statistics' ) ); ?>,
90
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
91
- labelOptions: {
92
- angle: -90,
93
- fontSize: '12px',
94
- fontFamily: 'Tahoma',
95
- fontWeight: 'bold',
96
- },
97
- }
98
- },
99
- legend: {
100
- show: true,
101
- location: 's',
102
- placement: 'outsideGrid',
103
- labels: [ <?php echo json_encode( __('Rank #1', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #2', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #3', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #4', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #5', 'wp_statistics' ) ); ?> ],
104
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
105
- rendererOptions:
106
- {
107
- numberColumns: 5,
108
- disableIEFading: false,
109
- border: 'none',
110
- },
111
- },
112
- highlighter: {
113
- show: true,
114
- bringSeriesToFront: true,
115
- tooltipAxes: 'xy',
116
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
117
- tooltipContentEditor: tooltipContentEditor,
118
- },
119
- grid: {
120
- drawGridlines: true,
121
- borderColor: 'transparent',
122
- shadow: false,
123
- drawBorder: false,
124
- shadowColor: 'transparent'
125
- },
126
- } );
127
-
128
- function tooltipContentEditor( str, seriesIndex, pointIndex, plot ) {
129
- // display series_label, x-axis_tick, y-axis value
130
- return plot.legend.labels[seriesIndex] + ", " + str;;
131
- }
132
-
133
- jQuery(window).resize( function() {
134
- JQPlotPagesChartLengendClickRedraw()
135
- });
136
-
137
- function JQPlotPagesChartLengendClickRedraw() {
138
- pages_jqchart.replot( {resetAxes: ['yaxis'] } );
139
- jQuery('div[id="jqpage-stats"] .jqplot-table-legend').click( function() {
140
- JQPlotPagesChartLengendClickRedraw();
141
- });
142
- }
143
-
144
- jQuery('div[id="jqpage-stats"] .jqplot-table-legend').click( function() {
145
- JQPlotPagesChartLengendClickRedraw()
146
- });
147
- });
148
- </script>
149
-
150
- <div id="jqpage-stats" style="height:500px;"></div>
151
-
152
- </div>
153
- </div>
154
-
155
- <div class="postbox">
156
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
157
- <h3 class="hndle"><span><?php _e( 'Top Pages', 'wp_statistics' ); ?></span></h3>
158
- <div class="inside">
159
- <?php
160
- if( $total > 0 ) {
161
- // Instantiate pagination object with appropriate arguments
162
- $pagesPerSection = 10;
163
- $options = 10;
164
- $stylePageOff = "pageOff";
165
- $stylePageOn = "pageOn";
166
- $styleErrors = "paginationErrors";
167
- $styleSelect = "paginationSelect";
168
-
169
- $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
170
-
171
- $start = $Pagination->getEntryStart();
172
- $end = $Pagination->getEntryEnd();
173
-
174
- $site_url = site_url();
175
-
176
- echo "<div class='log-latest'>";
177
- $count = 0;
178
-
179
- foreach( $uris as $uri ) {
180
- $count++;
181
-
182
- if( $count >= $start ) {
183
- echo "<div class='log-item'>";
184
-
185
- if( $uri[3] == '' ) { $uri[3] = '[' . htmlentities( __( 'No page title found', 'wp_statistics' ), ENT_QUOTES ) . ']'; }
186
-
187
- echo "<div class='log-page-title'>{$count} - {$uri[3]}</div>";
188
- echo "<div class='right-div'>".__('Visits', 'wp_statistics').": <a href='?page=" . WP_STATISTICS_PAGES_PAGE . '&page-uri=' . htmlentities( $uri[0], ENT_QUOTES ) . "'>" . number_format_i18n( $uri[1] ) . "</a></div>";
189
- echo "<div class='left-div'><a dir='ltr' href='" . htmlentities( $site_url . $uri[0], ENT_QUOTES ) . "'>" . htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) . "</a></div>";
190
- echo "</div>";
191
- }
192
-
193
- if( $count == $start + 10 ) { break; }
194
-
195
  }
196
-
 
 
 
197
  echo "</div>";
198
  }
199
- ?>
200
- </div>
201
- </div>
202
-
203
- <?php if( $total > 0 ) {?>
204
- <div class="pagination-log">
205
- <?php echo $Pagination->display(); ?>
206
- <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
207
- </div>
208
- <?php } ?>
209
- </div>
210
- </div>
211
- </div>
 
 
 
 
 
 
 
 
 
212
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
  <?php
7
+ $daysToDisplay = 20;
8
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
9
+ $daysToDisplay = intval( $_GET['hitdays'] );
10
+ }
11
+
12
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
13
+ $rangestart = $_GET['rangestart'];
14
+ } else {
15
+ $rangestart = '';
16
+ }
17
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
18
+ $rangeend = $_GET['rangeend'];
19
+ } else {
20
+ $rangeend = '';
21
+ }
22
+
23
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
24
+ $daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
25
+
26
+ list( $total, $uris ) = wp_statistics_get_top_pages( $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangestart_utime ), $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ) );
27
 
28
  ?>
29
  <div class="wrap">
30
+ <?php screen_icon( 'options-general' ); ?>
31
+ <h2><?php _e( 'Top Pages', 'wp_statistics' ); ?></h2>
32
 
33
  <?php wp_statistics_date_range_selector( WP_STATISTICS_PAGES_PAGE, $daysToDisplay ); ?>
34
 
35
+ <div class="postbox-container" id="last-log">
36
+ <div class="metabox-holder">
37
+ <div class="meta-box-sortables">
38
+
39
+ <div class="postbox">
40
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
41
+ <h3 class="hndle"><span><?php _e( 'Top 5 Pages Trends', 'wp_statistics' ); ?></span></h3>
42
+ <div class="inside">
43
+ <script type="text/javascript">
44
+ var pages_jqchart;
45
+ jQuery(document).ready(function () {
46
+ <?php
47
  $count = 0;
48
+
49
+ foreach ( $uris as $uri ) {
50
+
51
+ $count ++;
52
+
53
  echo "var pages_data_line" . $count . " = [";
54
+
55
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
56
  $stat = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $uri[0] );
57
+
58
  echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
59
+
60
  }
61
 
62
  echo "];\n";
63
+ if ( $count > 4 ) {
64
+ break;
65
+ }
66
  }
67
 
68
+ if ( $count < 6 ) {
69
+ for ( $i = $count + 1; $i < 6; $i ++ ) {
70
  echo "var pages_data_line" . $i . " = [];\n";
71
  }
72
  }
 
 
 
 
73
 
74
+ $tickInterval = round( $daysToDisplay / 20, 0 );
75
+ if ( $tickInterval < 1 ) {
76
+ $tickInterval = 1;
77
+ }
78
+ ?>
79
+
80
+ pages_jqchart = jQuery.jqplot('jqpage-stats', [pages_data_line1, pages_data_line2, pages_data_line3, pages_data_line4, pages_data_line5], {
81
+ title: {
82
+ text: '<b><?php echo htmlentities( __( 'Top 5 Page Trending Stats', 'wp_statistics' ), ENT_QUOTES ); ?></b>',
83
+ fontSize: '12px',
84
+ fontFamily: 'Tahoma',
85
+ textColor: '#000000',
86
+ },
87
+ axes: {
88
+ xaxis: {
89
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime ); ?>',
90
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ); ?>',
91
+ tickInterval: '<?php echo $tickInterval; ?> day',
92
+ renderer: jQuery.jqplot.DateAxisRenderer,
93
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
94
+ tickOptions: {
95
+ angle: -45,
96
+ formatString: '%b %#d',
97
+ showGridline: false,
98
+ },
99
+ },
100
+ yaxis: {
101
+ min: 0,
102
+ padMin: 1.0,
103
+ label: <?php echo json_encode( __( 'Number of Hits', 'wp_statistics' ) ); ?>,
104
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
105
+ labelOptions: {
106
+ angle: -90,
107
+ fontSize: '12px',
108
+ fontFamily: 'Tahoma',
109
+ fontWeight: 'bold',
110
+ },
111
+ }
112
+ },
113
+ legend: {
114
+ show: true,
115
+ location: 's',
116
+ placement: 'outsideGrid',
117
+ labels: [ <?php echo json_encode( __( 'Rank #1', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #2', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #3', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #4', 'wp_statistics' ) ); ?>, <?php echo json_encode( __( 'Rank #5', 'wp_statistics' ) ); ?> ],
118
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
119
+ rendererOptions: {
120
+ numberColumns: 5,
121
+ disableIEFading: false,
122
+ border: 'none',
123
+ },
124
+ },
125
+ highlighter: {
126
+ show: true,
127
+ bringSeriesToFront: true,
128
+ tooltipAxes: 'xy',
129
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
130
+ tooltipContentEditor: tooltipContentEditor,
131
+ },
132
+ grid: {
133
+ drawGridlines: true,
134
+ borderColor: 'transparent',
135
+ shadow: false,
136
+ drawBorder: false,
137
+ shadowColor: 'transparent'
138
+ },
139
+ });
140
+
141
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
142
+ // display series_label, x-axis_tick, y-axis value
143
+ return plot.legend.labels[seriesIndex] + ", " + str;
144
+ ;
145
+ }
146
+
147
+ jQuery(window).resize(function () {
148
+ JQPlotPagesChartLengendClickRedraw()
149
+ });
150
+
151
+ function JQPlotPagesChartLengendClickRedraw() {
152
+ pages_jqchart.replot({resetAxes: ['yaxis']});
153
+ jQuery('div[id="jqpage-stats"] .jqplot-table-legend').click(function () {
154
+ JQPlotPagesChartLengendClickRedraw();
155
+ });
156
+ }
157
+
158
+ jQuery('div[id="jqpage-stats"] .jqplot-table-legend').click(function () {
159
+ JQPlotPagesChartLengendClickRedraw()
160
+ });
161
+ });
162
+ </script>
163
+
164
+ <div id="jqpage-stats" style="height:500px;"></div>
165
+
166
+ </div>
167
+ </div>
168
+
169
+ <div class="postbox">
170
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
171
+ <h3 class="hndle"><span><?php _e( 'Top Pages', 'wp_statistics' ); ?></span></h3>
172
+ <div class="inside">
173
+ <?php
174
+ if ( $total > 0 ) {
175
+ // Instantiate pagination object with appropriate arguments
176
+ $pagesPerSection = 10;
177
+ $options = 10;
178
+ $stylePageOff = "pageOff";
179
+ $stylePageOn = "pageOn";
180
+ $styleErrors = "paginationErrors";
181
+ $styleSelect = "paginationSelect";
182
+
183
+ $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
184
+
185
+ $start = $Pagination->getEntryStart();
186
+ $end = $Pagination->getEntryEnd();
187
+
188
+ $site_url = site_url();
189
+
190
+ echo "<div class='log-latest'>";
191
+ $count = 0;
192
+
193
+ foreach ( $uris as $uri ) {
194
+ $count ++;
195
+
196
+ if ( $count >= $start ) {
197
+ echo "<div class='log-item'>";
198
+
199
+ if ( $uri[3] == '' ) {
200
+ $uri[3] = '[' . htmlentities( __( 'No page title found', 'wp_statistics' ), ENT_QUOTES ) . ']';
 
 
201
  }
202
+
203
+ echo "<div class='log-page-title'>{$count} - {$uri[3]}</div>";
204
+ echo "<div class='right-div'>" . __( 'Visits', 'wp_statistics' ) . ": <a href='?page=" . WP_STATISTICS_PAGES_PAGE . '&page-uri=' . htmlentities( $uri[0], ENT_QUOTES ) . "'>" . number_format_i18n( $uri[1] ) . "</a></div>";
205
+ echo "<div class='left-div'><a dir='ltr' href='" . htmlentities( $site_url . $uri[0], ENT_QUOTES ) . "'>" . htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) . "</a></div>";
206
  echo "</div>";
207
  }
208
+
209
+ if ( $count == $start + 10 ) {
210
+ break;
211
+ }
212
+
213
+ }
214
+
215
+ echo "</div>";
216
+ }
217
+ ?>
218
+ </div>
219
+ </div>
220
+
221
+ <?php if ( $total > 0 ) { ?>
222
+ <div class="pagination-log">
223
+ <?php echo $Pagination->display(); ?>
224
+ <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
225
+ </div>
226
+ <?php } ?>
227
+ </div>
228
+ </div>
229
+ </div>
230
  </div>
includes/log/top-referring.php CHANGED
@@ -1,178 +1,190 @@
1
  <script type="text/javascript">
2
- jQuery( document ).ready( function() {
3
- jQuery( '.show-map' ).click( function() {
4
- alert( '<?php _e( 'To be added soon', 'wp_statistics' ); ?>' );
5
- } );
6
 
7
- postboxes.add_postbox_toggles( pagenow );
8
- } );
9
  </script>
10
  <?php
11
- $date_args = '';
12
- $daysToDisplay = 20;
13
- if( array_key_exists( 'hitdays', $_GET ) ) {
14
- $daysToDisplay = intval( $_GET['hitdays'] );
15
- $date_args .= '&hitdays=' . $daysToDisplay;
16
- }
17
 
18
- if( array_key_exists( 'rangestart', $_GET ) ) {
19
- $rangestart = $_GET['rangestart'];
20
- $date_args .= '&rangestart=' . $rangestart;
21
- } else {
22
- $rangestart = '';
23
- }
24
-
25
- if( array_key_exists( 'rangeend', $_GET ) ) {
26
- $rangeend = $_GET['rangeend'];
27
- $date_args .= '&rangeend=' . $rangeend;
28
- } else {
29
- $rangeend = '';
30
- }
31
 
32
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
 
 
 
 
 
33
 
34
- $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
35
- $rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
36
 
37
- if( array_key_exists( 'referr', $_GET ) ) {
38
- $referr = $_GET['referr'];
39
- $title = $_GET['referr'];
40
- $referr_field = '&referr=' . $referr;
41
- }
42
- else {
43
- $referr = '';
44
- $referr_field = null;
45
- }
46
-
47
- $get_urls = array();
48
- $total = 0;
49
-
50
- if( $referr ) {
51
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `referred` LIKE %s AND referred <> '' AND `last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC", '%' . $referr . '%', $rangestartdate, $rangeenddate ) );
52
-
53
- $total = count( $result );
54
- } else {
55
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> '' AND `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ) );
56
-
57
- $urls = array();
58
- foreach( $result as $item ) {
59
-
60
- $url = parse_url($item->referred);
61
-
62
- if( empty( $url['host'] ) || stristr( get_bloginfo( 'url' ), $url['host'] ) ) {
63
- continue;
64
- }
65
-
66
- $urls[] = $url['host'];
67
  }
68
-
69
- $get_urls = array_count_values( $urls );
70
 
71
- $total = count( $get_urls );
72
  }
73
 
 
 
 
 
 
74
  ?>
75
  <div class="wrap">
76
  <?php screen_icon( 'options-general' ); ?>
77
- <h2><?php _e( 'Top Referring Sites', 'wp_statistics' ); ?></h2>
78
-
79
- <div><?php wp_statistics_date_range_selector( WP_STATISTICS_REFERRERS_PAGE, $daysToDisplay, null, null, $referr_field ); ?></div>
80
-
81
- <div class="clear"/>
82
-
83
- <ul class="subsubsub">
84
- <?php if( $referr ) { ?>
85
- <li class="all"><a <?php if( !$referr ) { echo 'class="current"'; } ?>href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE . $date_args; ?>"><?php _e( 'All', 'wp_statistics' ); ?></a></li>
86
- | <li><a class="current" href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE; ?>&referr=<?php echo $WP_Statistics->html_sanitize_referrer( $referr ) . $date_args; ?>"> <?php echo htmlentities( $title, ENT_QUOTES ); ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
 
 
 
 
 
 
87
  <?php } else { ?>
88
- <li class="all"><a <?php if( !$referr ) { echo 'class="current"'; } ?>href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE . $date_args; ?>"><?php _e( 'All', 'wp_statistics' ); ?> <span class="count">(<?php echo $total; ?>)</span></a></li>
89
- <?php }?>
90
- </ul>
91
- <div class="postbox-container" id="last-log">
92
- <div class="metabox-holder">
93
- <div class="meta-box-sortables">
94
- <div class="postbox">
95
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
96
- <?php if( $referr ) { ?>
97
- <h3 class="hndle"><span><?php _e( 'Referring sites from', 'wp_statistics' ); ?>: <?php echo $WP_Statistics->html_sanitize_referrer( $referr ); ?></span></h3>
 
 
 
 
98
  <?php } else { ?>
99
- <h3 class="hndle"><span><?php _e( 'Top Referring Sites', 'wp_statistics' ); ?></span></h3>
100
  <?php } ?>
101
- <div class="inside">
102
- <?php
103
- echo "<div class='log-latest'>";
104
-
105
- if( $total > 0 ) {
106
- // Initiate pagination object with appropriate arguments
107
- $pagesPerSection = 10;
108
- $options = array( 25, "All" );
109
- $stylePageOff = "pageOff";
110
- $stylePageOn = "pageOn";
111
- $styleErrors = "paginationErrors";
112
- $styleSelect = "paginationSelect";
113
-
114
- $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
115
-
116
- $start = $Pagination->getEntryStart();
117
- $end = $Pagination->getEntryEnd();
118
-
119
- if( $WP_Statistics->get_option( 'search_converted' ) ) {
120
- $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}statistics_search` INNER JOIN `{$wpdb->prefix}statistics_visitor` on {$wpdb->prefix}statistics_search.`visitor` = {$wpdb->prefix}statistics_visitor.`ID` WHERE `host` = %s AND {$wpdb->prefix}statistics_visitor.`last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_search`.`ID` DESC LIMIT %d, %d", $referr, $rangestartdate, $rangeenddate, $start, $end ) );
121
- }
122
 
123
- if( $referr ) {
124
- foreach( $result as $item ) {
125
-
126
- echo "<div class='log-item'>";
127
- echo "<div class='log-referred'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&ip={$item->ip}'>".wp_statistics_icons('dashicons-visibility', 'visibility')."{$item->ip}</a></div>";
128
- echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $item->last_counter ) ) . " - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>";
129
- echo "<div class='clear'></div>";
130
- echo "<a class='show-map' title='" . __( 'Map', 'wp_statistics' ) . "'><div class='dashicons dashicons-location-alt'></div></a>";
131
-
132
- if( array_search( strtolower( $item->agent ), array( 'chrome', 'firefox', 'msie', 'opera', 'safari' ) ) !== FALSE ){
133
- $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $item->agent . ".png' class='log-tools' title='{$item->agent}'/>";
134
- } else {
135
- $agent = "<div class='dashicons dashicons-editor-help'></div>";
136
- }
137
-
138
- echo "<div class='log-agent'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>";
139
-
140
- echo $WP_Statistics->get_referrer_link( $item->referred, 100 );
141
- echo "</div>";
142
-
143
- }
144
  } else {
145
- arsort( $get_urls );
146
- $get_urls = array_slice( $get_urls, $start, $end );
147
-
148
- $i = 0;
149
- foreach( $get_urls as $items => $value) {
150
-
151
- $i++;
152
- $referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
153
-
154
- echo "<div class='log-item'>";
155
- echo "<div class='log-referred'>{$i} - <a href='?page=" . WP_STATISTICS_REFERRERS_PAGE . "&referr=" . $referrer_html . $date_args . "'>" . $referrer_html . "</a></div>";
156
- echo "<div class='log-ip'>" . __( 'References', 'wp_statistics' ) . ': ' . number_format_i18n( $value ) . '</div>';
157
- echo "<div class='clear'></div>";
158
- echo "<div class='log-url'>" . $WP_Statistics->get_referrer_link( $items, 100 ) . '</div>';
159
- echo "</div>";
160
-
161
- }
162
  }
 
 
 
 
163
  }
164
-
165
- echo '</div>';
166
- ?>
167
- </div>
168
- </div>
169
-
170
- <div class="pagination-log">
171
- <?php if( $total > 0 ) { echo $Pagination->display(); ?>
172
- <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  <?php } ?>
174
- </div>
175
- </div>
176
- </div>
177
- </div>
178
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ jQuery('.show-map').click(function () {
4
+ alert('<?php _e( 'To be added soon', 'wp_statistics' ); ?>');
5
+ });
6
 
7
+ postboxes.add_postbox_toggles(pagenow);
8
+ });
9
  </script>
10
  <?php
11
+ $date_args = '';
12
+ $daysToDisplay = 20;
13
+ if ( array_key_exists( 'hitdays', $_GET ) ) {
14
+ $daysToDisplay = intval( $_GET['hitdays'] );
15
+ $date_args .= '&hitdays=' . $daysToDisplay;
16
+ }
17
 
18
+ if ( array_key_exists( 'rangestart', $_GET ) ) {
19
+ $rangestart = $_GET['rangestart'];
20
+ $date_args .= '&rangestart=' . $rangestart;
21
+ } else {
22
+ $rangestart = '';
23
+ }
 
 
 
 
 
 
 
24
 
25
+ if ( array_key_exists( 'rangeend', $_GET ) ) {
26
+ $rangeend = $_GET['rangeend'];
27
+ $date_args .= '&rangeend=' . $rangeend;
28
+ } else {
29
+ $rangeend = '';
30
+ }
31
 
32
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $daysToDisplay, $rangestart, $rangeend );
 
33
 
34
+ $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
35
+ $rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
36
+
37
+ if ( array_key_exists( 'referr', $_GET ) ) {
38
+ $referr = $_GET['referr'];
39
+ $title = $_GET['referr'];
40
+ $referr_field = '&referr=' . $referr;
41
+ } else {
42
+ $referr = '';
43
+ $referr_field = null;
44
+ }
45
+
46
+ $get_urls = array();
47
+ $total = 0;
48
+
49
+ if ( $referr ) {
50
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `referred` LIKE %s AND referred <> '' AND `last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC", '%' . $referr . '%', $rangestartdate, $rangeenddate ) );
51
+
52
+ $total = count( $result );
53
+ } else {
54
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> '' AND `last_counter` BETWEEN %s AND %s", $rangestartdate, $rangeenddate ) );
55
+
56
+ $urls = array();
57
+ foreach ( $result as $item ) {
58
+
59
+ $url = parse_url( $item->referred );
60
+
61
+ if ( empty( $url['host'] ) || stristr( get_bloginfo( 'url' ), $url['host'] ) ) {
62
+ continue;
 
63
  }
 
 
64
 
65
+ $urls[] = $url['host'];
66
  }
67
 
68
+ $get_urls = array_count_values( $urls );
69
+
70
+ $total = count( $get_urls );
71
+ }
72
+
73
  ?>
74
  <div class="wrap">
75
  <?php screen_icon( 'options-general' ); ?>
76
+ <h2><?php _e( 'Top Referring Sites', 'wp_statistics' ); ?></h2>
77
+
78
+ <div><?php wp_statistics_date_range_selector( WP_STATISTICS_REFERRERS_PAGE, $daysToDisplay, null, null, $referr_field ); ?></div>
79
+
80
+ <div class="clear"/>
81
+
82
+ <ul class="subsubsub">
83
+ <?php if ( $referr ) { ?>
84
+ <li class="all"><a <?php if ( ! $referr ) {
85
+ echo 'class="current"';
86
+ } ?>href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE . $date_args; ?>"><?php _e( 'All', 'wp_statistics' ); ?></a>
87
+ </li>
88
+ |
89
+ <li>
90
+ <a class="current" href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE; ?>&referr=<?php echo $WP_Statistics->html_sanitize_referrer( $referr ) . $date_args; ?>"> <?php echo htmlentities( $title, ENT_QUOTES ); ?>
91
+ <span class="count">(<?php echo $total; ?>)</span></a></li>
92
  <?php } else { ?>
93
+ <li class="all"><a <?php if ( ! $referr ) {
94
+ echo 'class="current"';
95
+ } ?>href="?page=<?php echo WP_STATISTICS_REFERRERS_PAGE . $date_args; ?>"><?php _e( 'All', 'wp_statistics' ); ?>
96
+ <span class="count">(<?php echo $total; ?>)</span></a></li>
97
+ <?php } ?>
98
+ </ul>
99
+ <div class="postbox-container" id="last-log">
100
+ <div class="metabox-holder">
101
+ <div class="meta-box-sortables">
102
+ <div class="postbox">
103
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
104
+ <?php if ( $referr ) { ?>
105
+ <h3 class="hndle"><span><?php _e( 'Referring sites from', 'wp_statistics' ); ?>
106
+ : <?php echo $WP_Statistics->html_sanitize_referrer( $referr ); ?></span></h3>
107
  <?php } else { ?>
108
+ <h3 class="hndle"><span><?php _e( 'Top Referring Sites', 'wp_statistics' ); ?></span></h3>
109
  <?php } ?>
110
+ <div class="inside">
111
+ <?php
112
+ echo "<div class='log-latest'>";
113
+
114
+ if ( $total > 0 ) {
115
+ // Initiate pagination object with appropriate arguments
116
+ $pagesPerSection = 10;
117
+ $options = array( 25, "All" );
118
+ $stylePageOff = "pageOff";
119
+ $stylePageOn = "pageOn";
120
+ $styleErrors = "paginationErrors";
121
+ $styleSelect = "paginationSelect";
122
+
123
+ $Pagination = new WP_Statistics_Pagination( $total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect );
124
+
125
+ $start = $Pagination->getEntryStart();
126
+ $end = $Pagination->getEntryEnd();
127
+
128
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
129
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}statistics_search` INNER JOIN `{$wpdb->prefix}statistics_visitor` on {$wpdb->prefix}statistics_search.`visitor` = {$wpdb->prefix}statistics_visitor.`ID` WHERE `host` = %s AND {$wpdb->prefix}statistics_visitor.`last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_search`.`ID` DESC LIMIT %d, %d", $referr, $rangestartdate, $rangeenddate, $start, $end ) );
130
+ }
131
 
132
+ if ( $referr ) {
133
+ foreach ( $result as $item ) {
134
+ echo "<div class='log-item'>";
135
+ echo "<div class='log-referred'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&ip={$item->ip}'>" . wp_statistics_icons( 'dashicons-visibility', 'visibility' ) . "{$item->ip}</a></div>";
136
+ echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $item->last_counter ) ) . " - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>";
137
+ echo "<div class='clear'></div>";
138
+ echo "<a class='show-map' title='" . __( 'Map', 'wp_statistics' ) . "'><div class='dashicons dashicons-location-alt'></div></a>";
139
+
140
+ if ( array_search( strtolower( $item->agent ), array(
141
+ 'chrome',
142
+ 'firefox',
143
+ 'msie',
144
+ 'opera',
145
+ 'safari'
146
+ ) ) !== false
147
+ ) {
148
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $item->agent . ".png' class='log-tools' title='{$item->agent}'/>";
 
 
 
 
149
  } else {
150
+ $agent = "<div class='dashicons dashicons-editor-help'></div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
+
153
+ echo "<div class='log-agent'><a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>";
154
+ echo $WP_Statistics->get_referrer_link( $item->referred, 100 );
155
+ echo "</div>";
156
  }
157
+ } else {
158
+ arsort( $get_urls );
159
+ $get_urls = array_slice( $get_urls, $start, $end );
160
+
161
+ $i = 0;
162
+ foreach ( $get_urls as $items => $value ) {
163
+ $i ++;
164
+ $referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
165
+
166
+ echo "<div class='log-item'>";
167
+ echo "<div class='log-referred'>{$i} - <a href='?page=" . WP_STATISTICS_REFERRERS_PAGE . "&referr=" . $referrer_html . $date_args . "'>" . $referrer_html . "</a></div>";
168
+ echo "<div class='log-ip'>" . __( 'References', 'wp_statistics' ) . ': ' . number_format_i18n( $value ) . '</div>';
169
+ echo "<div class='clear'></div>";
170
+ echo "<div class='log-url'>" . $WP_Statistics->get_referrer_link( $items, 100 ) . '</div>';
171
+ echo "</div>";
172
+ }
173
+ }
174
+ }
175
+
176
+ echo '</div>';
177
+ ?>
178
+ </div>
179
+ </div>
180
+
181
+ <div class="pagination-log">
182
+ <?php if ( $total > 0 ) {
183
+ echo $Pagination->display(); ?>
184
+ <p id="result-log"><?php echo ' ' . __( 'Page', 'wp_statistics' ) . ' ' . $Pagination->getCurrentPage() . ' ' . __( 'From', 'wp_statistics' ) . ' ' . $Pagination->getTotalPages(); ?></p>
185
  <?php } ?>
186
+ </div>
187
+ </div>
188
+ </div>
189
+ </div>
190
  </div>
includes/log/top-visitors.php CHANGED
@@ -1,51 +1,53 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function(){
3
- postboxes.add_postbox_toggles(pagenow);
4
- });
5
  </script>
6
- <?php
7
- $ISOCountryCode = $WP_Statistics->get_country_codes();
8
- include_once( dirname( __FILE__ ) . '/widgets/top.visitors.php' );
9
  ?>
10
  <div class="wrap">
11
- <?php screen_icon('options-general'); ?>
12
- <h2><?php _e('Top 100 Visitors Today', 'wp_statistics'); ?></h2>
13
- <?php
14
  wp_enqueue_script( 'jquery-ui-datepicker' );
15
  wp_register_style( 'jquery-ui-smoothness-css', $WP_Statistics->plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' );
16
  wp_enqueue_style( 'jquery-ui-smoothness-css' );
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
 
24
  echo '<br><form method="get">' . "\r\n";
25
-
26
  echo ' ' . __( 'Date', 'wp_statistics' ) . ': ';
27
 
28
  echo '<input type="hidden" name="page" value="' . WP_STATISTICS_TOP_VISITORS_PAGE . '">' . "\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
-
33
  echo '<script>jQuery(function() { jQuery( "#statsdate" ).datepicker(); } );</script>' . "\r\n";
34
-
35
- ?>
36
- <div class="postbox-container" id="last-log" style="width: 100%;">
37
- <div class="metabox-holder">
38
- <div class="meta-box-sortables">
39
- <div class="postbox">
40
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br /></div>
41
- <h3 class="hndle"><span><?php _e( 'Top Visitors', 'wp_statistics' ); ?></span></h3>
42
- <div class="inside">
43
-
44
  <?php wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, $statsdate, 100, false ); ?>
45
-
46
- </div>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ postboxes.add_postbox_toggles(pagenow);
4
+ });
5
  </script>
6
+ <?php
7
+ $ISOCountryCode = $WP_Statistics->get_country_codes();
8
+ include_once( dirname( __FILE__ ) . '/widgets/top.visitors.php' );
9
  ?>
10
  <div class="wrap">
11
+ <?php screen_icon( 'options-general' ); ?>
12
+ <h2><?php _e( 'Top 100 Visitors Today', 'wp_statistics' ); ?></h2>
13
+ <?php
14
  wp_enqueue_script( 'jquery-ui-datepicker' );
15
  wp_register_style( 'jquery-ui-smoothness-css', $WP_Statistics->plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' );
16
  wp_enqueue_style( 'jquery-ui-smoothness-css' );
17
+
18
  $current = 0;
19
 
20
  $statsdate = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
21
+
22
+ if ( array_key_exists( 'statsdate', $_GET ) ) {
23
+ $statsdate = $_GET['statsdate'];
24
+ }
25
 
26
  echo '<br><form method="get">' . "\r\n";
27
+
28
  echo ' ' . __( 'Date', 'wp_statistics' ) . ': ';
29
 
30
  echo '<input type="hidden" name="page" value="' . WP_STATISTICS_TOP_VISITORS_PAGE . '">' . "\r\n";
31
  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";
32
 
33
  echo '</form>' . "\r\n";
34
+
35
  echo '<script>jQuery(function() { jQuery( "#statsdate" ).datepicker(); } );</script>' . "\r\n";
36
+
37
+ ?>
38
+ <div class="postbox-container" id="last-log" style="width: 100%;">
39
+ <div class="metabox-holder">
40
+ <div class="meta-box-sortables">
41
+ <div class="postbox">
42
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'wp_statistics' ); ?>"><br/></div>
43
+ <h3 class="hndle"><span><?php _e( 'Top Visitors', 'wp_statistics' ); ?></span></h3>
44
+ <div class="inside">
45
+
46
  <?php wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, $statsdate, 100, false ); ?>
47
+
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
  </div>
includes/log/widgets/about.php CHANGED
@@ -1,29 +1,33 @@
1
  <?php
2
- function wp_statistics_generate_about_postbox_content() {
3
-
4
- global $wpdb, $WP_Statistics;
5
- ?>
6
- <div style="text-align: center;">
7
- <a href="http://wp-statistics.com" target="_blank"><img src="<?php echo plugins_url('wp-statistics/assets/images/logo-250.png'); ?>"></a>
8
- </div>
9
 
10
- <div id="about-links" style="text-align: center;">
11
- <p><a href="http://wp-statistics.com" target="_blank"><?php _e('Website', 'wp_statistics'); ?></a></p>
12
- | <p><a href="http://wordpress.org/support/view/plugin-reviews/wp-statistics" target="_blank"><?php _e('Rate and Review', 'wp_statistics'); ?></a></p>
13
- <?php
14
- if(current_user_can(wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options')))) {
15
- ?>
16
- | <p><a href="?page=<?php echo WP_STATISTICS_SETTINGS_PAGE; ?>&tab=about"><?php _e('More Information', 'wp_statistics'); ?></a></p>
17
- <?php
18
- }
19
- ?>
20
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- <hr />
23
-
24
- <div>
25
- <?php echo sprintf(__('This product includes GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics'), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>'); ?>
26
- </div>
27
- <?php
28
- }
29
 
1
  <?php
2
+ function wp_statistics_generate_about_postbox_content() {
 
 
 
 
 
 
3
 
4
+ global $wpdb, $WP_Statistics;
5
+ ?>
6
+ <div style="text-align: center;">
7
+ <a href="http://wp-statistics.com" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/logo-250.png' ); ?>"></a>
8
+ </div>
9
+
10
+ <div id="about-links" style="text-align: center;">
11
+ <p><a href="http://wp-statistics.com" target="_blank"><?php _e( 'Website', 'wp_statistics' ); ?></a></p>
12
+ | <p>
13
+ <a href="http://wordpress.org/support/view/plugin-reviews/wp-statistics" target="_blank"><?php _e( 'Rate and Review', 'wp_statistics' ); ?></a>
14
+ </p>
15
+ <?php
16
+ if ( current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ) ) ) {
17
+ ?>
18
+ | <p>
19
+ <a href="?page=<?php echo WP_STATISTICS_SETTINGS_PAGE; ?>&tab=about"><?php _e( 'More Information', 'wp_statistics' ); ?></a>
20
+ </p>
21
+ <?php
22
+ }
23
+ ?>
24
+ </div>
25
+
26
+ <hr/>
27
 
28
+ <div>
29
+ <?php echo sprintf( __( 'This product includes GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics' ), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>' ); ?>
30
+ </div>
31
+ <?php
32
+ }
 
 
33
 
includes/log/widgets/browsers.php CHANGED
@@ -1,88 +1,93 @@
1
  <?php
2
- function wp_statistics_generate_browsers_postbox_content() {
3
-
4
- global $wpdb, $WP_Statistics;
5
- ?>
6
- <script type="text/javascript">
7
- jQuery(function () {
8
- var browser_chart;
9
- jQuery(document).ready(function() {
10
- <?php
11
- $Browsers = wp_statistics_ua_list();
12
- $BrowserVisits = array();
13
- $total = 0;
14
-
15
- foreach( $Browsers as $Browser ) {
16
- $BrowserVisits[$Browser] = wp_statistics_useragent( $Browser );
17
- $total += $BrowserVisits[$Browser];
18
- }
19
-
20
- arsort( $BrowserVisits );
21
-
22
- echo "var browser_data = [";
23
- $count = 0;
24
- $topten = 0;
25
-
26
- foreach( $BrowserVisits as $key => $value ) {
27
- echo "['" . substr( $key, 0, 15 ) . " (" . number_format_i18n($value) . ")'," . $value . "], ";
28
 
29
- $topten += $value;
30
- $count++;
31
- if( $count > 9 ) { break; }
32
- }
 
 
 
 
 
 
33
 
34
- echo "['" . json_encode(__('Other', 'wp_statistics')) . " (" . number_format_i18n($total - $topten) . ")'," . ( $total - $topten ) . "], ";
 
 
 
35
 
36
- echo "];\n";
37
- ?>
38
 
39
- browser_chart = jQuery.jqplot('browsers-log', [browser_data], {
40
- title: {
41
- text: '<b>' + <?php echo json_encode(__('Top 10 Browsers', 'wp_statistics')); ?> + '</b>',
42
- fontSize: '12px',
43
- fontFamily: 'Tahoma',
44
- textColor: '#000000',
45
- },
46
- seriesDefaults: {
47
- // Make this a pie chart.
48
- renderer: jQuery.jqplot.PieRenderer,
49
- rendererOptions: {
50
- // Put data labels on the pie slices.
51
- // By default, labels show the percentage of the slice.
52
- dataLabels: 'percent',
53
- showDataLabels: true,
54
- shadowOffset: 0,
55
- }
56
- },
57
- legend: {
58
- show: true,
59
- location: 's',
60
- renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
61
- rendererOptions:
62
- {
63
- numberColumns: 2,
64
- disableIEFading: false,
65
- border: 'none',
66
- },
67
- },
68
- grid: { background: 'transparent', borderWidth: 0, shadow: false },
69
- highlighter: {
70
- show: true,
71
- formatString:'%s',
72
- tooltipLocation:'n',
73
- useAxesFormatters:false,
74
- },
75
- } );
76
- });
77
 
78
- jQuery(window).resize(function() {
79
- browser_chart.replot( {resetAxes: true } );
80
- });
81
- });
82
-
83
- </script>
84
-
85
- <div id="browsers-log" style="height: <?php $height = ( count($Browsers) / 2 * 27 ) + 300; if( $height > 462 ) { $height = 462; } echo $height; ?>px;"></div>
86
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
 
 
 
88
 
1
  <?php
2
+ function wp_statistics_generate_browsers_postbox_content() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ global $wpdb, $WP_Statistics;
5
+ ?>
6
+ <script type="text/javascript">
7
+ jQuery(function () {
8
+ var browser_chart;
9
+ jQuery(document).ready(function () {
10
+ <?php
11
+ $Browsers = wp_statistics_ua_list();
12
+ $BrowserVisits = array();
13
+ $total = 0;
14
 
15
+ foreach ( $Browsers as $Browser ) {
16
+ $BrowserVisits[ $Browser ] = wp_statistics_useragent( $Browser );
17
+ $total += $BrowserVisits[ $Browser ];
18
+ }
19
 
20
+ arsort( $BrowserVisits );
 
21
 
22
+ echo "var browser_data = [";
23
+ $count = 0;
24
+ $topten = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ foreach ( $BrowserVisits as $key => $value ) {
27
+ echo "['" . substr( $key, 0, 15 ) . " (" . number_format_i18n( $value ) . ")'," . $value . "], ";
28
+
29
+ $topten += $value;
30
+ $count ++;
31
+ if ( $count > 9 ) {
32
+ break;
33
+ }
34
+ }
35
+
36
+ echo "['" . json_encode( __( 'Other', 'wp_statistics' ) ) . " (" . number_format_i18n( $total - $topten ) . ")'," . ( $total - $topten ) . "], ";
37
+
38
+ echo "];\n";
39
+ ?>
40
+
41
+ browser_chart = jQuery.jqplot('browsers-log', [browser_data], {
42
+ title: {
43
+ text: '<b>' + <?php echo json_encode( __( 'Top 10 Browsers', 'wp_statistics' ) ); ?> +'</b>',
44
+ fontSize: '12px',
45
+ fontFamily: 'Tahoma',
46
+ textColor: '#000000',
47
+ },
48
+ seriesDefaults: {
49
+ // Make this a pie chart.
50
+ renderer: jQuery.jqplot.PieRenderer,
51
+ rendererOptions: {
52
+ // Put data labels on the pie slices.
53
+ // By default, labels show the percentage of the slice.
54
+ dataLabels: 'percent',
55
+ showDataLabels: true,
56
+ shadowOffset: 0,
57
+ }
58
+ },
59
+ legend: {
60
+ show: true,
61
+ location: 's',
62
+ renderer: jQuery.jqplot.EnhancedPieLegendRenderer,
63
+ rendererOptions: {
64
+ numberColumns: 2,
65
+ disableIEFading: false,
66
+ border: 'none',
67
+ },
68
+ },
69
+ grid: {background: 'transparent', borderWidth: 0, shadow: false},
70
+ highlighter: {
71
+ show: true,
72
+ formatString: '%s',
73
+ tooltipLocation: 'n',
74
+ useAxesFormatters: false,
75
+ },
76
+ });
77
+ });
78
+
79
+ jQuery(window).resize(function () {
80
+ browser_chart.replot({resetAxes: true});
81
+ });
82
+ });
83
+
84
+ </script>
85
+
86
+ <div id="browsers-log" style="height: <?php $height = ( count( $Browsers ) / 2 * 27 ) + 300;
87
+ if ( $height > 462 ) {
88
+ $height = 462;
89
  }
90
+ echo $height; ?>px;"></div>
91
+ <?php
92
+ }
93
 
includes/log/widgets/countries.php CHANGED
@@ -1,46 +1,47 @@
1
  <?php
2
- function wp_statistics_generate_countries_postbox_content($ISOCountryCode, $count = 10) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- ?>
7
- <table width="100%" class="widefat table-stats" id="last-referrer">
8
- <tr>
9
- <td width="10%" style='text-align: left'><?php _e('Rank', 'wp_statistics'); ?></td>
10
- <td width="10%" style='text-align: left'><?php _e('Flag', 'wp_statistics'); ?></td>
11
- <td width="40%" style='text-align: left'><?php _e('Country', 'wp_statistics'); ?></td>
12
- <td width="40%" style='text-align: left'><?php _e('Visitor Count', 'wp_statistics'); ?></td>
13
- </tr>
14
-
15
- <?php
16
- $Countries = array();
17
-
18
- $result = $wpdb->get_results("SELECT DISTINCT `location` FROM `{$wpdb->prefix}statistics_visitor`");
19
-
20
- foreach( $result as $item )
21
- {
22
- $Countries[$item->location] = $wpdb->get_var( $wpdb->prepare( "SELECT count(location) FROM `{$wpdb->prefix}statistics_visitor` WHERE location=%s", $item->location ) );
23
- }
24
-
25
- arsort($Countries);
26
- $i = 0;
27
-
28
- foreach( $Countries as $item => $value) {
29
- $i++;
30
-
31
- $item = strtoupper($item);
32
-
33
- echo "<tr>";
34
- echo "<td style='text-align: left'>$i</td>";
35
- echo "<td style='text-align: left'><img src='".plugins_url('wp-statistics/assets/images/flags/' . $item . '.png')."' title='{$ISOCountryCode[$item]}'/></td>";
36
- echo "<td style='text-align: left'>{$ISOCountryCode[$item]}</td>";
37
- echo "<td style='text-align: left'>" . number_format_i18n($value) . "</td>";
38
- echo "</tr>";
39
-
40
- if( $i == $count ) { break; }
41
- }
42
- ?>
43
- </table>
44
- <?php
45
- }
 
46
 
1
  <?php
2
+ function wp_statistics_generate_countries_postbox_content( $ISOCountryCode, $count = 10 ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ ?>
7
+ <table width="100%" class="widefat table-stats" id="last-referrer">
8
+ <tr>
9
+ <td width="10%" style='text-align: left'><?php _e( 'Rank', 'wp_statistics' ); ?></td>
10
+ <td width="10%" style='text-align: left'><?php _e( 'Flag', 'wp_statistics' ); ?></td>
11
+ <td width="40%" style='text-align: left'><?php _e( 'Country', 'wp_statistics' ); ?></td>
12
+ <td width="40%" style='text-align: left'><?php _e( 'Visitor Count', 'wp_statistics' ); ?></td>
13
+ </tr>
14
+
15
+ <?php
16
+ $Countries = array();
17
+
18
+ $result = $wpdb->get_results( "SELECT DISTINCT `location` FROM `{$wpdb->prefix}statistics_visitor`" );
19
+
20
+ foreach ( $result as $item ) {
21
+ $Countries[ $item->location ] = $wpdb->get_var( $wpdb->prepare( "SELECT count(location) FROM `{$wpdb->prefix}statistics_visitor` WHERE location=%s", $item->location ) );
22
+ }
23
+
24
+ arsort( $Countries );
25
+ $i = 0;
26
+
27
+ foreach ( $Countries as $item => $value ) {
28
+ $i ++;
29
+
30
+ $item = strtoupper( $item );
31
+
32
+ echo "<tr>";
33
+ echo "<td style='text-align: left'>$i</td>";
34
+ echo "<td style='text-align: left'><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item . '.png' ) . "' title='{$ISOCountryCode[$item]}'/></td>";
35
+ echo "<td style='text-align: left'>{$ISOCountryCode[$item]}</td>";
36
+ echo "<td style='text-align: left'>" . number_format_i18n( $value ) . "</td>";
37
+ echo "</tr>";
38
+
39
+ if ( $i == $count ) {
40
+ break;
41
+ }
42
+ }
43
+ ?>
44
+ </table>
45
+ <?php
46
+ }
47
 
includes/log/widgets/hits.php CHANGED
@@ -1,129 +1,132 @@
1
  <?php
2
- function wp_statistics_generate_hits_postbox_content( $size = '300px', $days = 20 ) {
3
-
4
- global $wpdb, $WP_Statistics;
5
- ?>
6
- <script type="text/javascript">
7
- var visit_chart;
8
- jQuery( document ).ready (function() {
9
- <?php
10
- $data_lines = array();
11
-
12
- if( $WP_Statistics->get_option( 'visits' ) ) {
13
- echo "var visit_data_line = [";
14
-
15
- for( $i=$days; $i>=0; $i--) {
16
- $stat = wp_statistics_visit( '-' . $i, true );
17
-
18
- echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $stat . "], ";
19
-
20
- }
21
-
22
- echo "];\n";
23
-
24
- $data_lines[] = 'visit_data_line';
25
- }
26
-
27
- if( $WP_Statistics->get_option( 'visitors' ) ) {
28
- echo "var visitor_data_line = [";
29
-
30
- for( $i = $days; $i >= 0; $i-- ) {
31
- $stat = wp_statistics_visitor( '-' . $i, true );
32
-
33
- echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $stat . "], ";
34
-
35
- }
36
-
37
- echo "];\n";
38
-
39
- $data_lines[] = 'visitor_data_line';
40
- }
41
- ?>
42
- visit_chart = jQuery.jqplot( 'visits-stats', [<?php echo implode( ',', $data_lines); ?>], {
43
- title: {
44
- text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $days . ' ' . __( 'days', 'wp_statistics' ) ); ?> + '</b>',
45
- fontSize: '12px',
46
- fontFamily: 'Tahoma',
47
- textColor: '#000000',
48
- },
49
- axes: {
50
- xaxis: {
51
- min: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '-' . $days ); ?>',
52
- max: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '' );?>',
53
- tickInterval: '1 day',
54
- renderer:jQuery.jqplot.DateAxisRenderer,
55
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
56
- tickOptions: {
57
- angle: -45,
58
- formatString:'%b %#d',
59
- showGridline: false,
60
- },
61
- },
62
- yaxis: {
63
- min: 0,
64
- padMin: 1.0,
65
- label: <?php echo json_encode( __( 'Number of visits and visitors', 'wp_statistics' ) ); ?>,
66
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
67
- labelOptions: {
68
- angle: -90,
69
- fontSize: '12px',
70
- fontFamily: 'Tahoma',
71
- fontWeight: 'bold',
72
- },
73
- }
74
- },
75
- legend: {
76
- show: true,
77
- location: 's',
78
- placement: 'outsideGrid',
79
- labels: [<?php echo implode( ',', array( json_encode( __( 'Visit', 'wp_statistics' ) ), json_encode( __('Visitor', 'wp_statistics') ) ) ); ?>],
80
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
81
- rendererOptions:
82
- {
83
- numberColumns: 2,
84
- disableIEFading: false,
85
- border: 'none',
86
- },
87
- },
88
- highlighter: {
89
- show: true,
90
- bringSeriesToFront: true,
91
- tooltipAxes: 'xy',
92
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
93
- tooltipContentEditor: tooltipContentEditor,
94
- },
95
- grid: {
96
- drawGridlines: true,
97
- borderColor: 'transparent',
98
- shadow: false,
99
- drawBorder: false,
100
- shadowColor: 'transparent'
101
- },
102
- } );
103
-
104
- function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
105
- // display series_label, x-axis_tick, y-axis value
106
- return plot.legend.labels[seriesIndex] + ", " + str;;
107
- }
108
-
109
- jQuery(window).resize(function() {
110
- JQPlotVisitChartLengendClickRedraw()
111
- });
112
-
113
- function JQPlotVisitChartLengendClickRedraw() {
114
- visit_chart.replot( {resetAxes: ['yaxis'] } );
115
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function() {
116
- JQPlotVisitChartLengendClickRedraw();
117
- });
118
- }
119
-
120
- jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function() {
121
- JQPlotVisitChartLengendClickRedraw()
122
- });
123
- });
124
- </script>
125
-
126
- <div id="visits-stats" style="height:<?php echo $size; ?>;"></div>
127
-
128
- <?php
129
- }
 
 
 
1
  <?php
2
+ function wp_statistics_generate_hits_postbox_content( $size = '300px', $days = 20 ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+ ?>
6
+ <script type="text/javascript">
7
+ var visit_chart;
8
+ jQuery(document).ready(function () {
9
+ <?php
10
+ $data_lines = array();
11
+
12
+ if ( $WP_Statistics->get_option( 'visits' ) ) {
13
+ echo "var visit_data_line = [";
14
+
15
+ for ( $i = $days; $i >= 0; $i -- ) {
16
+ $stat = wp_statistics_visit( '-' . $i, true );
17
+
18
+ echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $stat . "], ";
19
+
20
+ }
21
+
22
+ echo "];\n";
23
+
24
+ $data_lines[] = 'visit_data_line';
25
+ }
26
+
27
+ if ( $WP_Statistics->get_option( 'visitors' ) ) {
28
+ echo "var visitor_data_line = [";
29
+
30
+ for ( $i = $days; $i >= 0; $i -- ) {
31
+ $stat = wp_statistics_visitor( '-' . $i, true );
32
+
33
+ echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $stat . "], ";
34
+
35
+ }
36
+
37
+ echo "];\n";
38
+
39
+ $data_lines[] = 'visitor_data_line';
40
+ }
41
+ ?>
42
+ visit_chart = jQuery.jqplot('visits-stats', [<?php echo implode( ',', $data_lines ); ?>], {
43
+ title: {
44
+ text: '<b>' + <?php echo json_encode( __( 'Hits in the last', 'wp_statistics' ) . ' ' . $days . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
45
+ fontSize: '12px',
46
+ fontFamily: 'Tahoma',
47
+ textColor: '#000000',
48
+ },
49
+ axes: {
50
+ xaxis: {
51
+ min: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '-' . $days ); ?>',
52
+ max: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '' );?>',
53
+ tickInterval: '1 day',
54
+ renderer: jQuery.jqplot.DateAxisRenderer,
55
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
56
+ tickOptions: {
57
+ angle: -45,
58
+ formatString: '%b %#d',
59
+ showGridline: false,
60
+ },
61
+ },
62
+ yaxis: {
63
+ min: 0,
64
+ padMin: 1.0,
65
+ label: <?php echo json_encode( __( 'Number of visits and visitors', 'wp_statistics' ) ); ?>,
66
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
67
+ labelOptions: {
68
+ angle: -90,
69
+ fontSize: '12px',
70
+ fontFamily: 'Tahoma',
71
+ fontWeight: 'bold',
72
+ },
73
+ }
74
+ },
75
+ legend: {
76
+ show: true,
77
+ location: 's',
78
+ placement: 'outsideGrid',
79
+ labels: [<?php echo implode( ',', array(
80
+ json_encode( __( 'Visit', 'wp_statistics' ) ),
81
+ json_encode( __( 'Visitor', 'wp_statistics' ) )
82
+ ) ); ?>],
83
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
84
+ rendererOptions: {
85
+ numberColumns: 2,
86
+ disableIEFading: false,
87
+ border: 'none',
88
+ },
89
+ },
90
+ highlighter: {
91
+ show: true,
92
+ bringSeriesToFront: true,
93
+ tooltipAxes: 'xy',
94
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
95
+ tooltipContentEditor: tooltipContentEditor,
96
+ },
97
+ grid: {
98
+ drawGridlines: true,
99
+ borderColor: 'transparent',
100
+ shadow: false,
101
+ drawBorder: false,
102
+ shadowColor: 'transparent'
103
+ },
104
+ });
105
+
106
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
107
+ // display series_label, x-axis_tick, y-axis value
108
+ return plot.legend.labels[seriesIndex] + ", " + str;
109
+ ;
110
+ }
111
+
112
+ jQuery(window).resize(function () {
113
+ JQPlotVisitChartLengendClickRedraw()
114
+ });
115
+
116
+ function JQPlotVisitChartLengendClickRedraw() {
117
+ visit_chart.replot({resetAxes: ['yaxis']});
118
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
119
+ JQPlotVisitChartLengendClickRedraw();
120
+ });
121
+ }
122
+
123
+ jQuery('div[id="visits-stats"] .jqplot-table-legend').click(function () {
124
+ JQPlotVisitChartLengendClickRedraw()
125
+ });
126
+ });
127
+ </script>
128
+
129
+ <div id="visits-stats" style="height:<?php echo $size; ?>;"></div>
130
+
131
+ <?php
132
+ }
includes/log/widgets/jqv.map.php CHANGED
@@ -1,102 +1,110 @@
1
  <?php
2
- function wp_statistics_generate_map_postbox_content($ISOCountryCode) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- if($WP_Statistics->get_option('geoip') && !$WP_Statistics->get_option('disable_map') ) { ?>
7
- <div id="map_canvas"></div>
8
-
9
- <?php $result = $wpdb->get_row("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'"); ?>
10
- <script type="text/javascript">
11
- var country_pin = Array();
12
- var country_color = Array();
13
-
14
- jQuery(document).ready(function(){
15
-
16
- <?php
17
- $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'");
18
- $final_result = array();
19
- $final_result['000'] = array();
20
-
21
- if( $result ) {
22
- foreach($result as $new_r) {
23
- $new_r->location = strtolower( $new_r->location );
24
-
25
- $final_result[$new_r->location][] = array
26
- (
27
- 'location' => $new_r->location,
28
- 'agent' => $new_r->agent,
29
- 'ip' => $new_r->ip
30
- );
31
- }
32
- }
33
-
34
- $final_total = count( $result ) - count( $final_result['000'] );
35
-
36
- unset($final_result['000']);
37
-
38
- $startColor = array(200, 238, 255);
39
- $endColor = array(0, 100, 145);
40
-
41
- foreach($final_result as $items) {
42
-
43
- foreach($items as $markets) {
44
-
45
- if($markets['location'] == '000') continue;
46
-
47
- $flag = "<img src='".plugins_url('wp-statistics/assets/images/flags/' . strtoupper($markets['location']) . '.png')."' title='{$ISOCountryCode[strtoupper($markets['location'])]}' class='log-tools'/> {$ISOCountryCode[strtoupper($markets['location'])]}";
48
-
49
- if( array_search( strtolower($markets['agent']), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
50
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$markets['agent'].".png' class='log-tools' title='{$markets['agent']}'/>";
51
- } else {
52
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/unknown.png')."' class='log-tools' title='{$markets['agent']}'/>";
53
- }
54
-
55
- if( substr( $markets['ip'], 0, 6 ) == '#hash#' ) { $markets['ip'] = __('#hash#', 'wp_statistics'); }
56
-
57
- $get_ipp[$markets['location']][] = "<p>{$agent} {$markets['ip']}</p>";
58
- }
59
-
60
- $market_total = count($get_ipp[$markets['location']]);
61
- $last_five = "";
62
-
63
- // Only show the last five visitors, more just makes the map a mess.
64
- for( $i = $market_total; $i > $market_total - 6; $i-- ) {
65
- if( array_key_exists( $i, $get_ipp[$markets['location']]) ) {
66
- $last_five .= $get_ipp[$markets['location']][$i];
67
- }
68
- }
69
-
70
- $summary = ' [' . $market_total . ']';
71
-
72
- $color = sprintf( "#%02X%02X%02X", round($startColor[0] + ($endColor[0] - $startColor[0]) * $market_total / $final_total), round($startColor[1] + ($endColor[1] - $startColor[1]) * $market_total / $final_total), round($startColor[2] + ($endColor[2] - $startColor[2]) * $market_total / $final_total));
73
- ?>
74
- country_pin['<?php echo $markets['location'];?>'] = "<div class='map-html-marker'><?php echo $flag . $summary . '<hr />' . $last_five; ?></div>";
75
- country_color['<?php echo $markets['location'];?>'] = "<?php echo $color;?>";
76
- <?php
77
- }
78
- ?>
79
- var data_total = <?php echo $final_total;?>;
80
-
81
- jQuery('#map_canvas').vectorMap({
82
- map: 'world_en',
83
- colors: country_color,
84
- onLabelShow: function(element, label, code)
85
- {
86
- if( country_pin[code] !== undefined )
87
- {
88
- label.html( country_pin[code] );
89
- }
90
- else
91
- {
92
- label.html( label.html() + ' [0]<hr />');
93
- }
94
- },
95
- });
96
-
97
-
98
- });
99
- </script>
100
- <?php
101
- }
102
- }
 
 
 
 
 
 
 
 
1
  <?php
2
+ function wp_statistics_generate_map_postbox_content( $ISOCountryCode ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ if ( $WP_Statistics->get_option( 'geoip' ) && ! $WP_Statistics->get_option( 'disable_map' ) ) { ?>
7
+ <div id="map_canvas"></div>
8
+
9
+ <?php $result = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" ); ?>
10
+ <script type="text/javascript">
11
+ var country_pin = Array();
12
+ var country_color = Array();
13
+
14
+ jQuery(document).ready(function () {
15
+
16
+ <?php
17
+ $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" );
18
+ $final_result = array();
19
+ $final_result['000'] = array();
20
+
21
+ if ( $result ) {
22
+ foreach ( $result as $new_r ) {
23
+ $new_r->location = strtolower( $new_r->location );
24
+
25
+ $final_result[ $new_r->location ][] = array
26
+ (
27
+ 'location' => $new_r->location,
28
+ 'agent' => $new_r->agent,
29
+ 'ip' => $new_r->ip
30
+ );
31
+ }
32
+ }
33
+
34
+ $final_total = count( $result ) - count( $final_result['000'] );
35
+
36
+ unset( $final_result['000'] );
37
+
38
+ $startColor = array( 200, 238, 255 );
39
+ $endColor = array( 0, 100, 145 );
40
+
41
+ foreach($final_result as $items) {
42
+
43
+ foreach ( $items as $markets ) {
44
+
45
+ if ( $markets['location'] == '000' ) {
46
+ continue;
47
+ }
48
+
49
+ $flag = "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . strtoupper( $markets['location'] ) . '.png' ) . "' title='{$ISOCountryCode[strtoupper($markets['location'])]}' class='log-tools'/> {$ISOCountryCode[strtoupper($markets['location'])]}";
50
+
51
+ if ( array_search( strtolower( $markets['agent'] ), array(
52
+ "chrome",
53
+ "firefox",
54
+ "msie",
55
+ "opera",
56
+ "safari"
57
+ ) ) !== false
58
+ ) {
59
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $markets['agent'] . ".png' class='log-tools' title='{$markets['agent']}'/>";
60
+ } else {
61
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/unknown.png' ) . "' class='log-tools' title='{$markets['agent']}'/>";
62
+ }
63
+
64
+ if ( substr( $markets['ip'], 0, 6 ) == '#hash#' ) {
65
+ $markets['ip'] = __( '#hash#', 'wp_statistics' );
66
+ }
67
+
68
+ $get_ipp[ $markets['location'] ][] = "<p>{$agent} {$markets['ip']}</p>";
69
+ }
70
+
71
+ $market_total = count( $get_ipp[ $markets['location'] ] );
72
+ $last_five = "";
73
+
74
+ // Only show the last five visitors, more just makes the map a mess.
75
+ for ( $i = $market_total; $i > $market_total - 6; $i -- ) {
76
+ if ( array_key_exists( $i, $get_ipp[ $markets['location'] ] ) ) {
77
+ $last_five .= $get_ipp[ $markets['location'] ][ $i ];
78
+ }
79
+ }
80
+
81
+ $summary = ' [' . $market_total . ']';
82
+
83
+ $color = sprintf( "#%02X%02X%02X", round( $startColor[0] + ( $endColor[0] - $startColor[0] ) * $market_total / $final_total ), round( $startColor[1] + ( $endColor[1] - $startColor[1] ) * $market_total / $final_total ), round( $startColor[2] + ( $endColor[2] - $startColor[2] ) * $market_total / $final_total ) );
84
+ ?>
85
+ country_pin['<?php echo $markets['location'];?>'] = "<div class='map-html-marker'><?php echo $flag . $summary . '<hr />' . $last_five; ?></div>";
86
+ country_color['<?php echo $markets['location'];?>'] = "<?php echo $color;?>";
87
+ <?php
88
+ }
89
+ ?>
90
+ var data_total = <?php echo $final_total;?>;
91
+
92
+ jQuery('#map_canvas').vectorMap({
93
+ map: 'world_en',
94
+ colors: country_color,
95
+ onLabelShow: function (element, label, code) {
96
+ if (country_pin[code] !== undefined) {
97
+ label.html(country_pin[code]);
98
+ }
99
+ else {
100
+ label.html(label.html() + ' [0]<hr />');
101
+ }
102
+ },
103
+ });
104
+
105
+
106
+ });
107
+ </script>
108
+ <?php
109
+ }
110
+ }
includes/log/widgets/page.php CHANGED
@@ -1,127 +1,141 @@
1
  <?php
2
 
3
- function wp_statistics_generate_page_postbox_content($pageuri, $pageid, $days = 20, $chart_title = null, $rangestart = '', $rangeend = '' ) {
4
- GLOBAL $WP_Statistics;
5
-
6
- if( ! $WP_Statistics->get_option('pages') ) { return; }
7
-
8
- if( $chart_title == null ) { $chart_title = __('Page Trending Stats', 'wp_statistics'); }
9
-
10
- if( $pageuri && !$pageid ) { $pageid = wp_statistics_uri_to_id( $pageuri ); }
11
-
12
- $post = get_post($pageid);
13
- if( is_object($post) ) { $title = esc_html( $post->post_title ); } else { $title = ""; }
14
-
15
- $urlfields = "&page-id={$pageid}";
16
- if( $pageuri ) { $urlfields .= "&page-uri={$pageuri}"; }
17
-
18
- list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $days, $rangestart, $rangeend );
19
- $daysInThePast = round( ( time() - $rangeend_utime ) / 86400 , 0 );
20
-
21
- ?>
22
- <script type="text/javascript">
23
- var pages_chart;
24
- jQuery(document).ready( function() {
25
- <?php
26
- echo 'var page_data_line = [';
27
-
28
- for( $i = $daysToDisplay; $i >= 0; $i-- ) {
29
- $stat = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $pageuri, $pageid );
30
-
31
- echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
32
- }
33
-
34
- echo "];\n";
35
-
36
- $tickInterval = round( $daysToDisplay / 20, 0 );
37
- if( $tickInterval < 1 ) { $tickInterval = 1; }
38
-
39
- ?>
40
- pages_jqchart = jQuery.jqplot( 'page-stats', [page_data_line], {
41
- title: {
42
- text: '<b>' + <?php echo json_encode( __( $chart_title, 'wp_statistics' ) ); ?> + '</b>',
43
- fontSize: '12px',
44
- fontFamily: 'Tahoma',
45
- textColor: '#000000',
46
- },
47
- axes: {
48
- xaxis: {
49
- min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime );?>',
50
- max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime );?>',
51
- tickInterval: '<?php echo $tickInterval; ?> day',
52
- renderer:jQuery.jqplot.DateAxisRenderer,
53
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
54
- tickOptions: {
55
- angle: -45,
56
- formatString:'%b %#d',
57
- showGridline: false,
58
- },
59
- },
60
- yaxis: {
61
- min: 0,
62
- padMin: 1.0,
63
- label: <?php echo json_encode( __('Number of Hits', 'wp_statistics' ) ); ?>,
64
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
65
- labelOptions: {
66
- angle: -90,
67
- fontSize: '12px',
68
- fontFamily: 'Tahoma',
69
- fontWeight: 'bold',
70
- },
71
- }
72
- },
73
- legend: {
74
- show: true,
75
- location: 's',
76
- placement: 'outsideGrid',
77
- labels: [ '<?php echo (int) $pageid . ' - ' . $title; ?>' ],
78
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
79
- rendererOptions:
80
- {
81
- numberColumns: 5,
82
- disableIEFading: false,
83
- border: 'none',
84
- },
85
- },
86
- highlighter: {
87
- show: true,
88
- bringSeriesToFront: true,
89
- tooltipAxes: 'xy',
90
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
91
- tooltipContentEditor: tooltipContentEditor,
92
- },
93
- grid: {
94
- drawGridlines: true,
95
- borderColor: 'transparent',
96
- shadow: false,
97
- drawBorder: false,
98
- shadowColor: 'transparent'
99
- },
100
- } );
101
-
102
- function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
103
- // display series_label, x-axis_tick, y-axis value
104
- return plot.legend.labels[seriesIndex] + ", " + str;;
105
- }
106
-
107
- jQuery(window).resize(function() {
108
- JQPlotPagesChartLengendClickRedraw()
109
- });
110
-
111
- function JQPlotPagesChartLengendClickRedraw() {
112
- pages_jqchart.replot( {resetAxes: ['yaxis'] } );
113
- jQuery('div[id="page-stats"] .jqplot-table-legend').click( function() {
114
- JQPlotPagesChartLengendClickRedraw();
115
- });
116
- }
117
-
118
- jQuery('div[id="page-stats"] .jqplot-table-legend').click( function() {
119
- JQPlotPagesChartLengendClickRedraw()
120
- });
121
- });
122
- </script>
123
-
124
- <div id="page-stats" style="height:500px;"></div>
125
-
126
- <?php
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ function wp_statistics_generate_page_postbox_content( $pageuri, $pageid, $days = 20, $chart_title = null, $rangestart = '', $rangeend = '' ) {
4
+ GLOBAL $WP_Statistics;
5
+
6
+ if ( ! $WP_Statistics->get_option( 'pages' ) ) {
7
+ return;
8
+ }
9
+
10
+ if ( $chart_title == null ) {
11
+ $chart_title = __( 'Page Trending Stats', 'wp_statistics' );
12
+ }
13
+
14
+ if ( $pageuri && ! $pageid ) {
15
+ $pageid = wp_statistics_uri_to_id( $pageuri );
16
+ }
17
+
18
+ $post = get_post( $pageid );
19
+ if ( is_object( $post ) ) {
20
+ $title = esc_html( $post->post_title );
21
+ } else {
22
+ $title = "";
23
+ }
24
+
25
+ $urlfields = "&page-id={$pageid}";
26
+ if ( $pageuri ) {
27
+ $urlfields .= "&page-uri={$pageuri}";
28
+ }
29
+
30
+ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( $days, $rangestart, $rangeend );
31
+ $daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
32
+
33
+ ?>
34
+ <script type="text/javascript">
35
+ var pages_chart;
36
+ jQuery(document).ready(function () {
37
+ <?php
38
+ echo 'var page_data_line = [';
39
+
40
+ for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
41
+ $stat = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $pageuri, $pageid );
42
+
43
+ echo "['" . $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $i, $rangeend_utime ) . "'," . $stat . "], ";
44
+ }
45
+
46
+ echo "];\n";
47
+
48
+ $tickInterval = round( $daysToDisplay / 20, 0 );
49
+ if ( $tickInterval < 1 ) {
50
+ $tickInterval = 1;
51
+ }
52
+
53
+ ?>
54
+ pages_jqchart = jQuery.jqplot('page-stats', [page_data_line], {
55
+ title: {
56
+ text: '<b>' + <?php echo json_encode( __( $chart_title, 'wp_statistics' ) ); ?> +'</b>',
57
+ fontSize: '12px',
58
+ fontFamily: 'Tahoma',
59
+ textColor: '#000000',
60
+ },
61
+ axes: {
62
+ xaxis: {
63
+ min: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-' . $daysToDisplay, $rangeend_utime );?>',
64
+ max: '<?php echo $WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime );?>',
65
+ tickInterval: '<?php echo $tickInterval; ?> day',
66
+ renderer: jQuery.jqplot.DateAxisRenderer,
67
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
68
+ tickOptions: {
69
+ angle: -45,
70
+ formatString: '%b %#d',
71
+ showGridline: false,
72
+ },
73
+ },
74
+ yaxis: {
75
+ min: 0,
76
+ padMin: 1.0,
77
+ label: <?php echo json_encode( __( 'Number of Hits', 'wp_statistics' ) ); ?>,
78
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
79
+ labelOptions: {
80
+ angle: -90,
81
+ fontSize: '12px',
82
+ fontFamily: 'Tahoma',
83
+ fontWeight: 'bold',
84
+ },
85
+ }
86
+ },
87
+ legend: {
88
+ show: true,
89
+ location: 's',
90
+ placement: 'outsideGrid',
91
+ labels: ['<?php echo (int) $pageid . ' - ' . $title; ?>'],
92
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
93
+ rendererOptions: {
94
+ numberColumns: 5,
95
+ disableIEFading: false,
96
+ border: 'none',
97
+ },
98
+ },
99
+ highlighter: {
100
+ show: true,
101
+ bringSeriesToFront: true,
102
+ tooltipAxes: 'xy',
103
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
104
+ tooltipContentEditor: tooltipContentEditor,
105
+ },
106
+ grid: {
107
+ drawGridlines: true,
108
+ borderColor: 'transparent',
109
+ shadow: false,
110
+ drawBorder: false,
111
+ shadowColor: 'transparent'
112
+ },
113
+ });
114
+
115
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
116
+ // display series_label, x-axis_tick, y-axis value
117
+ return plot.legend.labels[seriesIndex] + ", " + str;
118
+ ;
119
+ }
120
+
121
+ jQuery(window).resize(function () {
122
+ JQPlotPagesChartLengendClickRedraw()
123
+ });
124
+
125
+ function JQPlotPagesChartLengendClickRedraw() {
126
+ pages_jqchart.replot({resetAxes: ['yaxis']});
127
+ jQuery('div[id="page-stats"] .jqplot-table-legend').click(function () {
128
+ JQPlotPagesChartLengendClickRedraw();
129
+ });
130
+ }
131
+
132
+ jQuery('div[id="page-stats"] .jqplot-table-legend').click(function () {
133
+ JQPlotPagesChartLengendClickRedraw()
134
+ });
135
+ });
136
+ </script>
137
+
138
+ <div id="page-stats" style="height:500px;"></div>
139
+
140
+ <?php
141
+ }
includes/log/widgets/pages.php CHANGED
@@ -1,24 +1,28 @@
1
  <?php
2
- function wp_statistics_generate_pages_postbox_content( $total, $uris ) {
3
-
4
- echo '<div class="log-latest">';
5
-
6
- $i = 0;
7
- $site_url = site_url();
8
-
9
- foreach( $uris as $uri ) {
10
- $i++;
11
- echo '<div class="log-item">';
12
 
13
- if( empty( $uri[3] ) ) { $uri[3] = '[' . __( 'No page title found', 'wp_statistics' ) . ']'; }
14
-
15
- echo "<div class=\"log-page-title\">{$i} - {$uri[3]}</div>";
16
- echo '<div class="right-div">' . __( 'Visits', 'wp_statistics' ) . ': <a href="?page=' . WP_STATISTICS_PAGES_PAGE . '&page-uri=' . htmlentities( $uri[0], ENT_QUOTES ) . '">' . number_format_i18n( $uri[1] ) . '</a></div>';
17
- echo '<div><a href="' . htmlentities( $site_url . $uri[0], ENT_QUOTES ) . '">' . htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) . '</a></div>';
18
- echo '</div>';
19
-
20
- if( $i > 9 ) { break; }
 
 
 
21
  }
22
-
 
 
 
23
  echo '</div>';
 
 
 
 
24
  }
 
 
 
1
  <?php
2
+ function wp_statistics_generate_pages_postbox_content( $total, $uris ) {
 
 
 
 
 
 
 
 
 
3
 
4
+ echo '<div class="log-latest">';
5
+
6
+ $i = 0;
7
+ $site_url = site_url();
8
+
9
+ foreach ( $uris as $uri ) {
10
+ $i ++;
11
+ echo '<div class="log-item">';
12
+
13
+ if ( empty( $uri[3] ) ) {
14
+ $uri[3] = '[' . __( 'No page title found', 'wp_statistics' ) . ']';
15
  }
16
+
17
+ echo "<div class=\"log-page-title\">{$i} - {$uri[3]}</div>";
18
+ echo '<div class="right-div">' . __( 'Visits', 'wp_statistics' ) . ': <a href="?page=' . WP_STATISTICS_PAGES_PAGE . '&page-uri=' . htmlentities( $uri[0], ENT_QUOTES ) . '">' . number_format_i18n( $uri[1] ) . '</a></div>';
19
+ echo '<div><a href="' . htmlentities( $site_url . $uri[0], ENT_QUOTES ) . '">' . htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) . '</a></div>';
20
  echo '</div>';
21
+
22
+ if ( $i > 9 ) {
23
+ break;
24
+ }
25
  }
26
+
27
+ echo '</div>';
28
+ }
includes/log/widgets/quickstats.php CHANGED
@@ -1,142 +1,214 @@
1
  <?php
2
- function wp_statistics_generate_quickstats_postbox_content($search_engines, $search = false, $time = false) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- $show_visitors = $WP_Statistics->get_option('visitor');
7
- ?>
8
- <table width="100%" class="widefat table-stats" id="summary-stats">
9
- <tbody>
10
- <?php if( $WP_Statistics->get_option('useronline') ) {?>
11
- <tr>
12
- <th><?php _e('User(s) Online', 'wp_statistics'); ?>:</th>
13
- <th colspan="2" id="th-colspan">
14
- <span><a href="admin.php?page=<?php echo WP_STATISTICS_ONLINE_PAGE; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
15
- </th>
16
- </tr>
17
- <?php }
18
-
19
- if( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') ) {
20
- ?>
21
- <tr>
22
- <th width="60%"></th>
23
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { _e('Visitor', 'wp_statistics'); } else { echo ''; }?></th>
24
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { _e('Visit', 'wp_statistics'); } else { echo ''; }?></th>
25
- </tr>
26
-
27
- <tr>
28
- <th><?php _e('Today', 'wp_statistics'); ?>:</th>
29
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('today',null,true)) . '</span></a>'; } else { echo ''; }?></th>
30
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page='. WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('today')) . '</span></a>'; } else { echo ''; }?></th>
31
- </tr>
32
-
33
- <tr>
34
- <th><?php _e('Yesterday', 'wp_statistics'); ?>:</th>
35
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('yesterday',null,true)) . '</span></a>'; } else { echo ''; }?></th>
36
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('yesterday')) . '</span></a>'; } else { echo ''; }?></th>
37
- </tr>
38
-
39
- <tr>
40
- <th><?php _e('Last 7 Days (Week)', 'wp_statistics'); ?>:</th>
41
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=7"><span>' . number_format_i18n(wp_statistics_visitor('week',null,true)) . '</span></a>'; } else { echo ''; }?></th>
42
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE .'&hitdays=7"><span>' . number_format_i18n(wp_statistics_visit('week')) . '</span></a>'; } else { echo ''; }?></th>
43
- </tr>
44
-
45
- <tr>
46
- <th><?php _e('Last 30 Days (Month)', 'wp_statistics'); ?>:</th>
47
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=30"><span>' . number_format_i18n(wp_statistics_visitor('month',null,true)) . '</span></a>'; } else { echo ''; }?></th>
48
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=30"><span>' . number_format_i18n(wp_statistics_visit('month')) . '</span></a>'; } else { echo ''; }?></th>
49
- </tr>
50
-
51
- <tr>
52
- <th><?php _e('Last 365 Days (Year)', 'wp_statistics'); ?>:</th>
53
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('year',null,true)) . '</span></a>'; } else { echo ''; }?></th>
54
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('year')) . '</span></a>'; } else { echo ''; }?></th>
55
- </tr>
56
-
57
- <tr>
58
- <th><?php _e('Total', 'wp_statistics'); ?>:</th>
59
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('total',null,true)) . '</span></a>'; } else { echo ''; }?></th>
60
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('total')) . '</span></a>'; } else { echo ''; }?></th>
61
- </tr>
62
-
63
- <?php
64
- }
65
-
66
- if( $search == true && $WP_Statistics->get_option('visitors' )) {
67
-
68
- if( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') || $WP_Statistics->get_option('useronline') ) {
69
- ?>
70
- <tr>
71
- <th colspan="3"><br><hr></th>
72
- </tr>
73
- <?php }?>
74
- <tr>
75
- <th colspan="3" style="text-align: center;"><?php _e('Search Engine Referrals', 'wp_statistics'); ?></th>
76
- </tr>
77
-
78
- <tr>
79
- <th width="60%"></th>
80
- <th class="th-center"><?php _e('Today', 'wp_statistics'); ?></th>
81
- <th class="th-center"><?php _e('Yesterday', 'wp_statistics'); ?></th>
82
- </tr>
83
-
84
- <?php
85
- $se_today_total = 0;
86
- $se_yesterday_total = 0;
87
- foreach( $search_engines as $se ) {
88
- ?>
89
- <tr>
90
- <th><img src='<?php echo plugins_url('wp-statistics/assets/images/' . $se['image'] );?>'> <?php _e($se['name'], 'wp_statistics'); ?>:</th>
91
- <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'today'); $se_today_total += $se_temp; echo number_format_i18n($se_temp);?></span></th>
92
- <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'yesterday'); $se_yesterday_total += $se_temp; echo number_format_i18n($se_temp);?></span></th>
93
- </tr>
94
-
95
- <?php
96
- }
97
- ?>
98
- <tr>
99
- <th><?php _e('Daily Total', 'wp_statistics'); ?>:</th>
100
- <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_today_total); ?></span></td>
101
- <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_yesterday_total); ?></span></td>
102
- </tr>
103
-
104
- <tr>
105
- <th><?php _e('Total', 'wp_statistics'); ?>:</th>
106
- <th colspan="2" id="th-colspan"><span><?php echo number_format_i18n(wp_statistics_searchengine('all')); ?></span></th>
107
- </tr>
108
- <?php
109
- }
110
-
111
- if( $time == true ) {
112
- ?>
113
- <tr>
114
- <th colspan="3"><br><hr></th>
115
- </tr>
116
-
117
- <tr>
118
- <th colspan="3" style="text-align: center;"><?php _e('Current Time and Date', 'wp_statistics'); ?> <span id="time_zone"><a href="<?php echo admin_url('options-general.php'); ?>"><?php _e('(Adjustment)', 'wp_statistics'); ?></a></span></th>
119
- </tr>
120
-
121
- <tr>
122
- <th colspan="3"><?php echo sprintf(__('Date: %s', 'wp_statistics'), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n(get_option('date_format')) . '</code>'); ?></th>
123
- </tr>
124
-
125
- <tr>
126
- <th colspan="3"><?php echo sprintf(__('Time: %s', 'wp_statistics'), '<code dir="ltr">' .$WP_Statistics->Current_Date_i18n(get_option('time_format')) . '</code>'); ?></th>
127
- </tr>
128
- <?php }?>
129
- </tbody>
130
- </table>
131
-
132
- <br>
133
- <hr width="80%"/>
134
- <br>
135
- <?php
136
-
137
- // Include the hits chart widget, we're going to display the last 10 days only as the WordPress columns are kind of small to do much else.
138
- include_once( dirname( __FILE__ ) . "/hits.php");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- wp_statistics_generate_hits_postbox_content("300px", 10);
141
- }
142
 
1
  <?php
2
+ function wp_statistics_generate_quickstats_postbox_content( $search_engines, $search = false, $time = false ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ $show_visitors = $WP_Statistics->get_option( 'visitor' );
7
+ ?>
8
+ <table width="100%" class="widefat table-stats" id="summary-stats">
9
+ <tbody>
10
+ <?php if ( $WP_Statistics->get_option( 'useronline' ) ) { ?>
11
+ <tr>
12
+ <th><?php _e( 'User(s) Online', 'wp_statistics' ); ?>:</th>
13
+ <th colspan="2" id="th-colspan">
14
+ <span><a href="admin.php?page=<?php echo WP_STATISTICS_ONLINE_PAGE; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
15
+ </th>
16
+ </tr>
17
+ <?php }
18
+
19
+ if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) {
20
+ ?>
21
+ <tr>
22
+ <th width="60%"></th>
23
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
24
+ _e( 'Visitor', 'wp_statistics' );
25
+ } else {
26
+ echo '';
27
+ } ?></th>
28
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
29
+ _e( 'Visit', 'wp_statistics' );
30
+ } else {
31
+ echo '';
32
+ } ?></th>
33
+ </tr>
34
+
35
+ <tr>
36
+ <th><?php _e( 'Today', 'wp_statistics' ); ?>:</th>
37
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
38
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) . '</span></a>';
39
+ } else {
40
+ echo '';
41
+ } ?></th>
42
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
43
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visit( 'today' ) ) . '</span></a>';
44
+ } else {
45
+ echo '';
46
+ } ?></th>
47
+ </tr>
48
+
49
+ <tr>
50
+ <th><?php _e( 'Yesterday', 'wp_statistics' ); ?>:</th>
51
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
52
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) . '</span></a>';
53
+ } else {
54
+ echo '';
55
+ } ?></th>
56
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
57
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visit( 'yesterday' ) ) . '</span></a>';
58
+ } else {
59
+ echo '';
60
+ } ?></th>
61
+ </tr>
62
+
63
+ <tr>
64
+ <th><?php _e( 'Last 7 Days (Week)', 'wp_statistics' ); ?>:</th>
65
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
66
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=7"><span>' . number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) . '</span></a>';
67
+ } else {
68
+ echo '';
69
+ } ?></th>
70
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
71
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=7"><span>' . number_format_i18n( wp_statistics_visit( 'week' ) ) . '</span></a>';
72
+ } else {
73
+ echo '';
74
+ } ?></th>
75
+ </tr>
76
+
77
+ <tr>
78
+ <th><?php _e( 'Last 30 Days (Month)', 'wp_statistics' ); ?>:</th>
79
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
80
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=30"><span>' . number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) . '</span></a>';
81
+ } else {
82
+ echo '';
83
+ } ?></th>
84
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
85
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=30"><span>' . number_format_i18n( wp_statistics_visit( 'month' ) ) . '</span></a>';
86
+ } else {
87
+ echo '';
88
+ } ?></th>
89
+ </tr>
90
+
91
+ <tr>
92
+ <th><?php _e( 'Last 365 Days (Year)', 'wp_statistics' ); ?>:</th>
93
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
94
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) . '</span></a>';
95
+ } else {
96
+ echo '';
97
+ } ?></th>
98
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
99
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visit( 'year' ) ) . '</span></a>';
100
+ } else {
101
+ echo '';
102
+ } ?></th>
103
+ </tr>
104
+
105
+ <tr>
106
+ <th><?php _e( 'Total', 'wp_statistics' ); ?>:</th>
107
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
108
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) . '</span></a>';
109
+ } else {
110
+ echo '';
111
+ } ?></th>
112
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
113
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visit( 'total' ) ) . '</span></a>';
114
+ } else {
115
+ echo '';
116
+ } ?></th>
117
+ </tr>
118
+
119
+ <?php
120
+ }
121
+
122
+ if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) {
123
+
124
+ if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) || $WP_Statistics->get_option( 'useronline' ) ) {
125
+ ?>
126
+ <tr>
127
+ <th colspan="3"><br>
128
+ <hr>
129
+ </th>
130
+ </tr>
131
+ <?php } ?>
132
+ <tr>
133
+ <th colspan="3" style="text-align: center;"><?php _e( 'Search Engine Referrals', 'wp_statistics' ); ?></th>
134
+ </tr>
135
+
136
+ <tr>
137
+ <th width="60%"></th>
138
+ <th class="th-center"><?php _e( 'Today', 'wp_statistics' ); ?></th>
139
+ <th class="th-center"><?php _e( 'Yesterday', 'wp_statistics' ); ?></th>
140
+ </tr>
141
+
142
+ <?php
143
+ $se_today_total = 0;
144
+ $se_yesterday_total = 0;
145
+ foreach ( $search_engines as $se ) {
146
+ ?>
147
+ <tr>
148
+ <th>
149
+ <img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e( $se['name'], 'wp_statistics' ); ?>
150
+ :
151
+ </th>
152
+ <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' );
153
+ $se_today_total += $se_temp;
154
+ echo number_format_i18n( $se_temp ); ?></span></th>
155
+ <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' );
156
+ $se_yesterday_total += $se_temp;
157
+ echo number_format_i18n( $se_temp ); ?></span></th>
158
+ </tr>
159
+
160
+ <?php
161
+ }
162
+ ?>
163
+ <tr>
164
+ <th><?php _e( 'Daily Total', 'wp_statistics' ); ?>:</th>
165
+ <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span>
166
+ </td>
167
+ <td id="th-colspan" class="th-center">
168
+ <span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td>
169
+ </tr>
170
+
171
+ <tr>
172
+ <th><?php _e( 'Total', 'wp_statistics' ); ?>:</th>
173
+ <th colspan="2" id="th-colspan">
174
+ <span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th>
175
+ </tr>
176
+ <?php
177
+ }
178
+
179
+ if ( $time == true ) {
180
+ ?>
181
+ <tr>
182
+ <th colspan="3"><br>
183
+ <hr>
184
+ </th>
185
+ </tr>
186
+
187
+ <tr>
188
+ <th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp_statistics' ); ?>
189
+ <span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e( '(Adjustment)', 'wp_statistics' ); ?></a></span>
190
+ </th>
191
+ </tr>
192
+
193
+ <tr>
194
+ <th colspan="3"><?php echo sprintf( __( 'Date: %s', 'wp_statistics' ), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) . '</code>' ); ?></th>
195
+ </tr>
196
+
197
+ <tr>
198
+ <th colspan="3"><?php echo sprintf( __( 'Time: %s', 'wp_statistics' ), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) . '</code>' ); ?></th>
199
+ </tr>
200
+ <?php } ?>
201
+ </tbody>
202
+ </table>
203
+
204
+ <br>
205
+ <hr width="80%"/>
206
+ <br>
207
+ <?php
208
+
209
+ // Include the hits chart widget, we're going to display the last 10 days only as the WordPress columns are kind of small to do much else.
210
+ include_once( dirname( __FILE__ ) . "/hits.php" );
211
 
212
+ wp_statistics_generate_hits_postbox_content( "300px", 10 );
213
+ }
214
 
includes/log/widgets/recent.php CHANGED
@@ -1,47 +1,53 @@
1
  <?php
2
- function wp_statistics_generate_recent_postbox_content($ISOCountryCode, $count = 10) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT 0, {$count}");
7
-
8
- echo "<div class='log-latest'>";
9
-
10
- $dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
11
-
12
- foreach($result as $items) {
13
- if( substr( $items->ip, 0, 6 ) == '#hash#' ) {
14
- $ip_string = __('#hash#', 'wp_statistics');
15
- $map_string = "";
16
- }
17
- else {
18
- $ip_string = "<a href='admin.php?page=" . WP_STATISTICS_VISITORS_PAGE . "&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
19
- $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='".__('Map', 'wp_statistics')."'>".wp_statistics_icons('dashicons-location-alt', 'map')."</a>";
20
- }
21
-
22
- echo "<div class='log-item'>";
23
- echo "<div class='log-referred'>{$ip_string}</div>";
24
- echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . "</div>";
25
- echo "<div class='clear'></div>";
26
- echo "<div class='log-url'>";
27
- echo $map_string;
28
-
29
- if($WP_Statistics->get_option('geoip')) {
30
- echo "<img src='".plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png')."' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
31
- }
32
-
33
- if( array_search( strtolower( $items->agent ), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
34
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$items->agent.".png' class='log-tools' title='{$items->agent}'/>";
35
- } else {
36
- $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
37
- }
38
-
39
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
40
-
41
- echo $WP_Statistics->get_referrer_link( $items->referred );
42
-
43
- echo "</div>";
44
  }
45
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  echo "</div>";
47
  }
 
 
 
1
  <?php
2
+ function wp_statistics_generate_recent_postbox_content( $ISOCountryCode, $count = 10 ) {
3
+ global $wpdb, $WP_Statistics;
4
+
5
+ $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT 0, {$count}" );
6
+
7
+ echo "<div class='log-latest'>";
8
+
9
+ $dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
10
+
11
+ foreach ( $result as $items ) {
12
+ if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
13
+ $ip_string = __( '#hash#', 'wp_statistics' );
14
+ $map_string = "";
15
+ } else {
16
+ $ip_string = "<a href='admin.php?page=" . WP_STATISTICS_VISITORS_PAGE . "&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
17
+ $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp_statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>";
18
+ }
19
+
20
+ echo "<div class='log-item'>";
21
+ echo "<div class='log-referred'>{$ip_string}</div>";
22
+ echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . "</div>";
23
+ echo "<div class='clear'></div>";
24
+ echo "<div class='log-url'>";
25
+ echo $map_string;
26
+
27
+ if ( $WP_Statistics->get_option( 'geoip' ) ) {
28
+ echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
+
31
+ if ( array_search( strtolower( $items->agent ), array(
32
+ "chrome",
33
+ "firefox",
34
+ "msie",
35
+ "opera",
36
+ "safari"
37
+ ) ) !== false
38
+ ) {
39
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
40
+ } else {
41
+ $agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
42
+ }
43
+
44
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
45
+
46
+ echo $WP_Statistics->get_referrer_link( $items->referred );
47
+
48
+ echo "</div>";
49
  echo "</div>";
50
  }
51
+
52
+ echo "</div>";
53
+ }
includes/log/widgets/referring.php CHANGED
@@ -1,54 +1,54 @@
1
  <?php
2
- function wp_statistics_generate_referring_postbox_content( $count = 10 ) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- $get_urls = array();
7
- $urls = array();
8
- $start = 0;
9
-
10
- do {
11
- $result = $wpdb->get_results( "SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> '' LIMIT {$start}, 10000" );
12
-
13
- $start += count( $result );
14
-
15
- foreach( $result as $item ) {
16
-
17
- $url = parse_url( $item->referred );
18
-
19
- if( empty( $url['host'] ) || stristr( get_bloginfo( 'url' ), $url['host'] ) ) {
20
- continue;
21
- }
22
-
23
- $urls[] = $url['host'];
24
  }
25
-
26
- } while( 10000 == count( $result ) );
27
-
28
- $get_urls = array_count_values( $urls );
29
-
30
- arsort( $get_urls );
31
- $get_urls = array_slice( $get_urls, 0, $count );
32
-
33
- ?>
34
- <table width="100%" class="widefat table-stats" id="last-referrer">
35
- <tr>
36
- <td width="10%"><?php _e( 'References', 'wp_statistics' ); ?></td>
37
- <td width="90%"><?php _e( 'Address', 'wp_statistics' ); ?></td>
38
- </tr>
39
-
40
- <?php
41
-
42
- foreach( $get_urls as $items => $value) {
43
-
44
- $referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
45
-
46
- echo "<tr>";
47
- echo "<td><a href='?page=" . WP_STATISTICS_REFERRERS_PAGE . "&referr=" . $referrer_html . "'>" . number_format_i18n($value) . "</a></td>";
48
- echo "<td>" . $WP_Statistics->get_referrer_link( $items ) . "</td>";
49
- echo "</tr>";
50
- }
51
- ?>
52
- </table>
53
- <?php
54
- }
 
 
 
1
  <?php
2
+ function wp_statistics_generate_referring_postbox_content( $count = 10 ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ $get_urls = array();
7
+ $urls = array();
8
+ $start = 0;
9
+
10
+ do {
11
+ $result = $wpdb->get_results( "SELECT referred FROM {$wpdb->prefix}statistics_visitor WHERE referred <> '' LIMIT {$start}, 10000" );
12
+
13
+ $start += count( $result );
14
+
15
+ foreach ( $result as $item ) {
16
+
17
+ $url = parse_url( $item->referred );
18
+
19
+ if ( empty( $url['host'] ) || stristr( get_bloginfo( 'url' ), $url['host'] ) ) {
20
+ continue;
 
 
 
21
  }
22
+
23
+ $urls[] = $url['host'];
24
+ }
25
+
26
+ } while ( 10000 == count( $result ) );
27
+
28
+ $get_urls = array_count_values( $urls );
29
+
30
+ arsort( $get_urls );
31
+ $get_urls = array_slice( $get_urls, 0, $count );
32
+
33
+ ?>
34
+ <table width="100%" class="widefat table-stats" id="last-referrer">
35
+ <tr>
36
+ <td width="10%"><?php _e( 'References', 'wp_statistics' ); ?></td>
37
+ <td width="90%"><?php _e( 'Address', 'wp_statistics' ); ?></td>
38
+ </tr>
39
+
40
+ <?php
41
+
42
+ foreach ( $get_urls as $items => $value ) {
43
+
44
+ $referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
45
+
46
+ echo "<tr>";
47
+ echo "<td><a href='?page=" . WP_STATISTICS_REFERRERS_PAGE . "&referr=" . $referrer_html . "'>" . number_format_i18n( $value ) . "</a></td>";
48
+ echo "<td>" . $WP_Statistics->get_referrer_link( $items ) . "</td>";
49
+ echo "</tr>";
50
+ }
51
+ ?>
52
+ </table>
53
+ <?php
54
+ }
includes/log/widgets/search.php CHANGED
@@ -1,130 +1,140 @@
1
  <?php
2
- function wp_statistics_generate_search_postbox_content($search_engines, $size = "300px", $days = 20) {
3
-
4
- global $wpdb, $WP_Statistics;
5
- ?>
6
- <script type="text/javascript">
7
- var referral_chart;
8
- jQuery(document).ready(function() {
9
- <?php
10
- $total_stats = $WP_Statistics->get_option( 'chart_totals' );
11
- $total_daily = array();
12
-
13
- foreach( $search_engines as $se ) {
14
-
15
- echo "var searches_data_line_" . $se['tag'] . " = [";
16
-
17
- for( $i=$days; $i>=0; $i--) {
18
- if( !array_key_exists( $i, $total_daily ) ) { $total_daily[$i] = 0; }
19
- $stat = wp_statistics_searchengine($se['tag'], '-'.$i);
20
- $total_daily[$i] += $stat;
21
-
22
- echo "['" . $WP_Statistics->Current_Date('Y-m-d', '-'.$i) . "'," . $stat . "], ";
23
-
24
- }
25
-
26
- echo "];\n";
27
- }
28
-
29
- if( $total_stats == 1 ) {
30
- echo "var searches_data_line_total = [";
31
-
32
- for( $i=$days; $i>=0; $i--) {
33
- echo "['" . $WP_Statistics->Current_Date('Y-m-d', '-'.$i) . "'," . $total_daily[$i] . "], ";
34
- }
35
-
36
- echo "];\n";
37
- }
38
-
39
- ?>
40
- referral_chart = jQuery.jqplot('search-stats', [<?php foreach( $search_engines as $se ) { echo "searches_data_line_" . $se['tag'] . ", "; } if( $total_stats == 1 ) { echo 'searches_data_line_total'; }?>], {
41
- title: {
42
- text: '<b>' + <?php echo json_encode(__('Search engine referrals in the last', 'wp_statistics') . ' ' . $days . ' ' . __('days', 'wp_statistics')); ?> + '</b>',
43
- fontSize: '12px',
44
- fontFamily: 'Tahoma',
45
- textColor: '#000000',
46
- },
47
- axes: {
48
- xaxis: {
49
- min: '<?php echo $WP_Statistics->Current_Date('Y-m-d', '-' . $days);?>',
50
- max: '<?php echo $WP_Statistics->Current_Date('Y-m-d', '');?>',
51
- tickInterval: '1 day',
52
- renderer:jQuery.jqplot.DateAxisRenderer,
53
- tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
54
- tickOptions: {
55
- angle: -45,
56
- formatString:'%b %#d',
57
- showGridline: false,
58
- },
59
- },
60
- yaxis: {
61
- min: 0,
62
- padMin: 1.0,
63
- label: <?php echo json_encode(__('Number of referrals', 'wp_statistics')); ?>,
64
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
65
- labelOptions: {
66
- angle: -90,
67
- fontSize: '12px',
68
- fontFamily: 'Tahoma',
69
- fontWeight: 'bold',
70
- },
71
- }
72
- },
73
- legend: {
74
- show: true,
75
- location: 's',
76
- placement: 'outsideGrid',
77
- labels: [<?php foreach( $search_engines as $se ) { echo json_encode($se['translated']) . ", "; } if( $total_stats == 1 ) { echo "'" . json_encode(__('Total', 'wp_statistics')) . "'"; }?>],
78
- renderer: jQuery.jqplot.EnhancedLegendRenderer,
79
- rendererOptions:
80
- {
81
- numberColumns: <?php echo count( $search_engines ) + 1;?>,
82
- disableIEFading: false,
83
- border: 'none',
84
- },
85
- },
86
- highlighter: {
87
- show: true,
88
- bringSeriesToFront: true,
89
- tooltipAxes: 'xy',
90
- formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
91
- tooltipContentEditor: tooltipContentEditor,
92
- },
93
- grid: {
94
- drawGridlines: true,
95
- borderColor: 'transparent',
96
- shadow: false,
97
- drawBorder: false,
98
- shadowColor: 'transparent'
99
- },
100
- } );
101
-
102
- function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
103
- // display series_label, x-axis_tick, y-axis value
104
- return plot.legend.labels[seriesIndex] + ", " + str;;
105
- }
106
-
107
- jQuery(window).resize(function() {
108
- JQPlotReferralChartLengendClickRedraw()
109
- });
110
-
111
- function JQPlotReferralChartLengendClickRedraw() {
112
- referral_chart.replot( {resetAxes: ['yaxis'] } );
113
- jQuery('div[id="search-stats"] .jqplot-table-legend').click(function() {
114
- JQPlotReferralChartLengendClickRedraw();
115
- });
116
- }
117
-
118
- jQuery('div[id="search-stats"] .jqplot-table-legend').click(function() {
119
- JQPlotReferralChartLengendClickRedraw()
120
- });
121
-
122
- });
123
-
124
- </script>
125
-
126
- <div id="search-stats" style="height:<?php echo $size; ?>;"></div>
127
-
128
- <?php
129
- }
 
 
 
 
 
 
 
 
 
 
130
 
1
  <?php
2
+ function wp_statistics_generate_search_postbox_content( $search_engines, $size = "300px", $days = 20 ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+ ?>
6
+ <script type="text/javascript">
7
+ var referral_chart;
8
+ jQuery(document).ready(function () {
9
+ <?php
10
+ $total_stats = $WP_Statistics->get_option( 'chart_totals' );
11
+ $total_daily = array();
12
+
13
+ foreach ( $search_engines as $se ) {
14
+
15
+ echo "var searches_data_line_" . $se['tag'] . " = [";
16
+
17
+ for ( $i = $days; $i >= 0; $i -- ) {
18
+ if ( ! array_key_exists( $i, $total_daily ) ) {
19
+ $total_daily[ $i ] = 0;
20
+ }
21
+ $stat = wp_statistics_searchengine( $se['tag'], '-' . $i );
22
+ $total_daily[ $i ] += $stat;
23
+
24
+ echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $stat . "], ";
25
+
26
+ }
27
+
28
+ echo "];\n";
29
+ }
30
+
31
+ if ( $total_stats == 1 ) {
32
+ echo "var searches_data_line_total = [";
33
+
34
+ for ( $i = $days; $i >= 0; $i -- ) {
35
+ echo "['" . $WP_Statistics->Current_Date( 'Y-m-d', '-' . $i ) . "'," . $total_daily[ $i ] . "], ";
36
+ }
37
+
38
+ echo "];\n";
39
+ }
40
+
41
+ ?>
42
+ referral_chart = jQuery.jqplot('search-stats', [<?php foreach ( $search_engines as $se ) {
43
+ echo "searches_data_line_" . $se['tag'] . ", ";
44
+ } if ( $total_stats == 1 ) {
45
+ echo 'searches_data_line_total';
46
+ }?>], {
47
+ title: {
48
+ text: '<b>' + <?php echo json_encode( __( 'Search engine referrals in the last', 'wp_statistics' ) . ' ' . $days . ' ' . __( 'days', 'wp_statistics' ) ); ?> +'</b>',
49
+ fontSize: '12px',
50
+ fontFamily: 'Tahoma',
51
+ textColor: '#000000',
52
+ },
53
+ axes: {
54
+ xaxis: {
55
+ min: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '-' . $days );?>',
56
+ max: '<?php echo $WP_Statistics->Current_Date( 'Y-m-d', '' );?>',
57
+ tickInterval: '1 day',
58
+ renderer: jQuery.jqplot.DateAxisRenderer,
59
+ tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
60
+ tickOptions: {
61
+ angle: -45,
62
+ formatString: '%b %#d',
63
+ showGridline: false,
64
+ },
65
+ },
66
+ yaxis: {
67
+ min: 0,
68
+ padMin: 1.0,
69
+ label: <?php echo json_encode( __( 'Number of referrals', 'wp_statistics' ) ); ?>,
70
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
71
+ labelOptions: {
72
+ angle: -90,
73
+ fontSize: '12px',
74
+ fontFamily: 'Tahoma',
75
+ fontWeight: 'bold',
76
+ },
77
+ }
78
+ },
79
+ legend: {
80
+ show: true,
81
+ location: 's',
82
+ placement: 'outsideGrid',
83
+ labels: [<?php foreach ( $search_engines as $se ) {
84
+ echo json_encode( $se['translated'] ) . ", ";
85
+ } if ( $total_stats == 1 ) {
86
+ echo "'" . json_encode( __( 'Total', 'wp_statistics' ) ) . "'";
87
+ }?>],
88
+ renderer: jQuery.jqplot.EnhancedLegendRenderer,
89
+ rendererOptions: {
90
+ numberColumns: <?php echo count( $search_engines ) + 1;?>,
91
+ disableIEFading: false,
92
+ border: 'none',
93
+ },
94
+ },
95
+ highlighter: {
96
+ show: true,
97
+ bringSeriesToFront: true,
98
+ tooltipAxes: 'xy',
99
+ formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
100
+ tooltipContentEditor: tooltipContentEditor,
101
+ },
102
+ grid: {
103
+ drawGridlines: true,
104
+ borderColor: 'transparent',
105
+ shadow: false,
106
+ drawBorder: false,
107
+ shadowColor: 'transparent'
108
+ },
109
+ });
110
+
111
+ function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
112
+ // display series_label, x-axis_tick, y-axis value
113
+ return plot.legend.labels[seriesIndex] + ", " + str;
114
+ ;
115
+ }
116
+
117
+ jQuery(window).resize(function () {
118
+ JQPlotReferralChartLengendClickRedraw()
119
+ });
120
+
121
+ function JQPlotReferralChartLengendClickRedraw() {
122
+ referral_chart.replot({resetAxes: ['yaxis']});
123
+ jQuery('div[id="search-stats"] .jqplot-table-legend').click(function () {
124
+ JQPlotReferralChartLengendClickRedraw();
125
+ });
126
+ }
127
+
128
+ jQuery('div[id="search-stats"] .jqplot-table-legend').click(function () {
129
+ JQPlotReferralChartLengendClickRedraw()
130
+ });
131
+
132
+ });
133
+
134
+ </script>
135
+
136
+ <div id="search-stats" style="height:<?php echo $size; ?>;"></div>
137
+
138
+ <?php
139
+ }
140
 
includes/log/widgets/summary.php CHANGED
@@ -1,133 +1,205 @@
1
  <?php
2
- function wp_statistics_generate_summary_postbox_content($search_engines, $search = true, $time = true) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- $show_visitors = $WP_Statistics->get_option('visitor');
7
- ?>
8
- <table width="100%" class="widefat table-stats" id="summary-stats">
9
- <tbody>
10
- <?php if( $WP_Statistics->get_option('useronline') ) {?>
11
- <tr>
12
- <th><?php _e('Users Online', 'wp_statistics'); ?>:</th>
13
- <th colspan="2" id="th-colspan">
14
- <span><a href="admin.php?page=<?php echo WP_STATISTICS_ONLINE_PAGE; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
15
- </th>
16
- </tr>
17
- <?php }
18
-
19
- if( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') ) {
20
- ?>
21
- <tr>
22
- <th width="60%"></th>
23
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { _e('Visitor', 'wp_statistics'); } else { echo ''; }?></th>
24
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { _e('Visit', 'wp_statistics'); } else { echo ''; }?></th>
25
- </tr>
26
-
27
- <tr>
28
- <th><?php _e('Today', 'wp_statistics'); ?>:</th>
29
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('today',null,true)) . '</span></a>'; } else { echo ''; }?></th>
30
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page='. WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('today')) . '</span></a>'; } else { echo ''; }?></th>
31
- </tr>
32
-
33
- <tr>
34
- <th><?php _e('Yesterday', 'wp_statistics'); ?>:</th>
35
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('yesterday',null,true)) . '</span></a>'; } else { echo ''; }?></th>
36
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('yesterday')) . '</span></a>'; } else { echo ''; }?></th>
37
- </tr>
38
-
39
- <tr>
40
- <th><?php _e('Last 7 Days', 'wp_statistics'); ?>:</th>
41
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=7"><span>' . number_format_i18n(wp_statistics_visitor('week',null,true)) . '</span></a>'; } else { echo ''; }?></th>
42
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE .'&hitdays=7"><span>' . number_format_i18n(wp_statistics_visit('week')) . '</span></a>'; } else { echo ''; }?></th>
43
- </tr>
44
-
45
- <tr>
46
- <th><?php _e('Last 30 Days', 'wp_statistics'); ?>:</th>
47
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=30"><span>' . number_format_i18n(wp_statistics_visitor('month',null,true)) . '</span></a>'; } else { echo ''; }?></th>
48
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=30"><span>' . number_format_i18n(wp_statistics_visit('month')) . '</span></a>'; } else { echo ''; }?></th>
49
- </tr>
50
-
51
- <tr>
52
- <th><?php _e('Last 365 Days', 'wp_statistics'); ?>:</th>
53
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('year',null,true)) . '</span></a>'; } else { echo ''; }?></th>
54
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('year')) . '</span></a>'; } else { echo ''; }?></th>
55
- </tr>
56
-
57
- <tr>
58
- <th><?php _e('Total', 'wp_statistics'); ?>:</th>
59
- <th class="th-center"><?php if( $WP_Statistics->get_option('visitors') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('total',null,true)) . '</span></a>'; } else { echo ''; }?></th>
60
- <th class="th-center"><?php if( $WP_Statistics->get_option('visits') ) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('total')) . '</span></a>'; } else { echo ''; }?></th>
61
- </tr>
62
-
63
- <?php
64
- }
65
-
66
- if( $search == true && $WP_Statistics->get_option('visitors' )) {
67
-
68
- if( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') || $WP_Statistics->get_option('useronline') ) {
69
- ?>
70
- <tr>
71
- <th colspan="3"><br><hr></th>
72
- </tr>
73
- <?php }?>
74
- <tr>
75
- <th colspan="3" style="text-align: center;"><?php _e('Search Engine Referrals', 'wp_statistics'); ?></th>
76
- </tr>
77
-
78
- <tr>
79
- <th width="60%"></th>
80
- <th class="th-center"><?php _e('Today', 'wp_statistics'); ?></th>
81
- <th class="th-center"><?php _e('Yesterday', 'wp_statistics'); ?></th>
82
- </tr>
83
-
84
- <?php
85
- $se_today_total = 0;
86
- $se_yesterday_total = 0;
87
- foreach( $search_engines as $se ) {
88
- ?>
89
- <tr>
90
- <th><img src='<?php echo plugins_url('wp-statistics/assets/images/' . $se['image'] );?>'> <?php _e($se['name'], 'wp_statistics'); ?>:</th>
91
- <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'today'); $se_today_total += $se_temp; echo number_format_i18n($se_temp);?></span></th>
92
- <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'yesterday'); $se_yesterday_total += $se_temp; echo number_format_i18n($se_temp);?></span></th>
93
- </tr>
94
-
95
- <?php
96
- }
97
- ?>
98
- <tr>
99
- <th><?php _e('Daily Total', 'wp_statistics'); ?>:</th>
100
- <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_today_total); ?></span></td>
101
- <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_yesterday_total); ?></span></td>
102
- </tr>
103
-
104
- <tr>
105
- <th><?php _e('Total', 'wp_statistics'); ?>:</th>
106
- <th colspan="2" id="th-colspan"><span><?php echo number_format_i18n(wp_statistics_searchengine('all')); ?></span></th>
107
- </tr>
108
- <?php
109
- }
110
-
111
- if( $time == true ) {
112
- ?>
113
- <tr>
114
- <th colspan="3"><br><hr></th>
115
- </tr>
116
-
117
- <tr>
118
- <th colspan="3" style="text-align: center;"><?php _e('Current Time and Date', 'wp_statistics'); ?> <span id="time_zone"><a href="<?php echo admin_url('options-general.php'); ?>"><?php _e('(Adjustment)', 'wp_statistics'); ?></a></span></th>
119
- </tr>
120
-
121
- <tr>
122
- <th colspan="3"><?php echo sprintf(__('Date: %s', 'wp_statistics'), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n(get_option('date_format')) . '</code>'); ?></th>
123
- </tr>
124
-
125
- <tr>
126
- <th colspan="3"><?php echo sprintf(__('Time: %s', 'wp_statistics'), '<code dir="ltr">' .$WP_Statistics->Current_Date_i18n(get_option('time_format')) . '</code>'); ?></th>
127
- </tr>
128
- <?php }?>
129
- </tbody>
130
- </table>
131
- <?php
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
1
  <?php
2
+ function wp_statistics_generate_summary_postbox_content( $search_engines, $search = true, $time = true ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ $show_visitors = $WP_Statistics->get_option( 'visitor' );
7
+ ?>
8
+ <table width="100%" class="widefat table-stats" id="summary-stats">
9
+ <tbody>
10
+ <?php if ( $WP_Statistics->get_option( 'useronline' ) ) { ?>
11
+ <tr>
12
+ <th><?php _e( 'Users Online', 'wp_statistics' ); ?>:</th>
13
+ <th colspan="2" id="th-colspan">
14
+ <span><a href="admin.php?page=<?php echo WP_STATISTICS_ONLINE_PAGE; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
15
+ </th>
16
+ </tr>
17
+ <?php }
18
+
19
+ if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) {
20
+ ?>
21
+ <tr>
22
+ <th width="60%"></th>
23
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
24
+ _e( 'Visitor', 'wp_statistics' );
25
+ } else {
26
+ echo '';
27
+ } ?></th>
28
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
29
+ _e( 'Visit', 'wp_statistics' );
30
+ } else {
31
+ echo '';
32
+ } ?></th>
33
+ </tr>
34
+
35
+ <tr>
36
+ <th><?php _e( 'Today', 'wp_statistics' ); ?>:</th>
37
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
38
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) . '</span></a>';
39
+ } else {
40
+ echo '';
41
+ } ?></th>
42
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
43
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visit( 'today' ) ) . '</span></a>';
44
+ } else {
45
+ echo '';
46
+ } ?></th>
47
+ </tr>
48
+
49
+ <tr>
50
+ <th><?php _e( 'Yesterday', 'wp_statistics' ); ?>:</th>
51
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
52
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) . '</span></a>';
53
+ } else {
54
+ echo '';
55
+ } ?></th>
56
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
57
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n( wp_statistics_visit( 'yesterday' ) ) . '</span></a>';
58
+ } else {
59
+ echo '';
60
+ } ?></th>
61
+ </tr>
62
+
63
+ <tr>
64
+ <th><?php _e( 'Last 7 Days', 'wp_statistics' ); ?>:</th>
65
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
66
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=7"><span>' . number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) . '</span></a>';
67
+ } else {
68
+ echo '';
69
+ } ?></th>
70
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
71
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=7"><span>' . number_format_i18n( wp_statistics_visit( 'week' ) ) . '</span></a>';
72
+ } else {
73
+ echo '';
74
+ } ?></th>
75
+ </tr>
76
+
77
+ <tr>
78
+ <th><?php _e( 'Last 30 Days', 'wp_statistics' ); ?>:</th>
79
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
80
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=30"><span>' . number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) . '</span></a>';
81
+ } else {
82
+ echo '';
83
+ } ?></th>
84
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
85
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=30"><span>' . number_format_i18n( wp_statistics_visit( 'month' ) ) . '</span></a>';
86
+ } else {
87
+ echo '';
88
+ } ?></th>
89
+ </tr>
90
+
91
+ <tr>
92
+ <th><?php _e( 'Last 365 Days', 'wp_statistics' ); ?>:</th>
93
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
94
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) . '</span></a>';
95
+ } else {
96
+ echo '';
97
+ } ?></th>
98
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
99
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visit( 'year' ) ) . '</span></a>';
100
+ } else {
101
+ echo '';
102
+ } ?></th>
103
+ </tr>
104
+
105
+ <tr>
106
+ <th><?php _e( 'Total', 'wp_statistics' ); ?>:</th>
107
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
108
+ echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) . '</span></a>';
109
+ } else {
110
+ echo '';
111
+ } ?></th>
112
+ <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
113
+ echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n( wp_statistics_visit( 'total' ) ) . '</span></a>';
114
+ } else {
115
+ echo '';
116
+ } ?></th>
117
+ </tr>
118
+
119
+ <?php
120
+ }
121
+
122
+ if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) {
123
+
124
+ if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) || $WP_Statistics->get_option( 'useronline' ) ) {
125
+ ?>
126
+ <tr>
127
+ <th colspan="3"><br>
128
+ <hr>
129
+ </th>
130
+ </tr>
131
+ <?php } ?>
132
+ <tr>
133
+ <th colspan="3" style="text-align: center;"><?php _e( 'Search Engine Referrals', 'wp_statistics' ); ?></th>
134
+ </tr>
135
+
136
+ <tr>
137
+ <th width="60%"></th>
138
+ <th class="th-center"><?php _e( 'Today', 'wp_statistics' ); ?></th>
139
+ <th class="th-center"><?php _e( 'Yesterday', 'wp_statistics' ); ?></th>
140
+ </tr>
141
+
142
+ <?php
143
+ $se_today_total = 0;
144
+ $se_yesterday_total = 0;
145
+ foreach ( $search_engines as $se ) {
146
+ ?>
147
+ <tr>
148
+ <th>
149
+ <img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e( $se['name'], 'wp_statistics' ); ?>
150
+ :
151
+ </th>
152
+ <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' );
153
+ $se_today_total += $se_temp;
154
+ echo number_format_i18n( $se_temp ); ?></span></th>
155
+ <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' );
156
+ $se_yesterday_total += $se_temp;
157
+ echo number_format_i18n( $se_temp ); ?></span></th>
158
+ </tr>
159
+
160
+ <?php
161
+ }
162
+ ?>
163
+ <tr>
164
+ <th><?php _e( 'Daily Total', 'wp_statistics' ); ?>:</th>
165
+ <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span>
166
+ </td>
167
+ <td id="th-colspan" class="th-center">
168
+ <span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td>
169
+ </tr>
170
+
171
+ <tr>
172
+ <th><?php _e( 'Total', 'wp_statistics' ); ?>:</th>
173
+ <th colspan="2" id="th-colspan">
174
+ <span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th>
175
+ </tr>
176
+ <?php
177
+ }
178
+
179
+ if ( $time == true ) {
180
+ ?>
181
+ <tr>
182
+ <th colspan="3"><br>
183
+ <hr>
184
+ </th>
185
+ </tr>
186
+
187
+ <tr>
188
+ <th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp_statistics' ); ?>
189
+ <span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e( '(Adjustment)', 'wp_statistics' ); ?></a></span>
190
+ </th>
191
+ </tr>
192
+
193
+ <tr>
194
+ <th colspan="3"><?php echo sprintf( __( 'Date: %s', 'wp_statistics' ), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) . '</code>' ); ?></th>
195
+ </tr>
196
+
197
+ <tr>
198
+ <th colspan="3"><?php echo sprintf( __( 'Time: %s', 'wp_statistics' ), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) . '</code>' ); ?></th>
199
+ </tr>
200
+ <?php } ?>
201
+ </tbody>
202
+ </table>
203
+ <?php
204
+ }
205
 
includes/log/widgets/top.visitors.php CHANGED
@@ -1,52 +1,58 @@
1
  <?php
2
- function wp_statistics_generate_top_visitors_postbox_content($ISOCountryCode, $day='today', $count=10, $compact=false) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- if( $day == 'today' ) { $sql_time = $WP_Statistics->Current_Date('Y-m-d'); } else { $sql_time = date( 'Y-m-d', strtotime( $day ) ); }
7
-
8
- ?>
9
- <table width="100%" class="widefat table-stats" id="last-referrer">
10
- <tr>
11
- <td style='text-align: left'><?php _e('Rank', 'wp_statistics'); ?></td>
12
- <td style='text-align: left'><?php _e('Hits', 'wp_statistics'); ?></td>
13
- <td style='text-align: left'><?php _e('Flag', 'wp_statistics'); ?></td>
14
- <td style='text-align: left'><?php _e('Country', 'wp_statistics'); ?></td>
15
- <td style='text-align: left'><?php _e('IP', 'wp_statistics'); ?></td>
16
- <?php if( $compact == false ) { ?>
17
- <td style='text-align: left'><?php _e('Agent', 'wp_statistics'); ?></td>
18
- <td style='text-align: left'><?php _e('Platform', 'wp_statistics'); ?></td>
19
- <td style='text-align: left'><?php _e('Version', 'wp_statistics'); ?></td>
20
- <?php } ?>
21
- </tr>
22
-
23
- <?php
24
- $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$sql_time}' ORDER BY hits DESC");
25
-
26
- $i = 0;
27
-
28
- foreach( $result as $visitor) {
29
- $i++;
30
-
31
- $item = strtoupper($visitor->location);
32
-
33
- echo "<tr>";
34
- echo "<td style='text-align: left'>$i</td>";
35
- echo "<td style='text-align: left'>" . (int)$visitor->hits . "</td>";
36
- echo "<td style='text-align: left'><img src='".plugins_url('wp-statistics/assets/images/flags/' . $item . '.png')."' title='{$ISOCountryCode[$item]}'/></td>";
37
- echo "<td style='text-align: left'>{$ISOCountryCode[$item]}</td>";
38
- echo "<td style='text-align: left'>{$visitor->ip}</td>";
39
-
40
- if( $compact == false ) {
41
- echo "<td style='text-align: left'>{$visitor->agent}</td>";
42
- echo "<td style='text-align: left'>{$visitor->platform}</td>";
43
- echo "<td style='text-align: left'>{$visitor->version}</td>";
44
- }
45
- echo "</tr>";
46
-
47
- if( $i == $count ) { break; }
48
- }
49
- ?>
50
- </table>
51
- <?php
52
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ function wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, $day = 'today', $count = 10, $compact = false ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ if ( $day == 'today' ) {
7
+ $sql_time = $WP_Statistics->Current_Date( 'Y-m-d' );
8
+ } else {
9
+ $sql_time = date( 'Y-m-d', strtotime( $day ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
+
12
+ ?>
13
+ <table width="100%" class="widefat table-stats" id="last-referrer">
14
+ <tr>
15
+ <td style='text-align: left'><?php _e( 'Rank', 'wp_statistics' ); ?></td>
16
+ <td style='text-align: left'><?php _e( 'Hits', 'wp_statistics' ); ?></td>
17
+ <td style='text-align: left'><?php _e( 'Flag', 'wp_statistics' ); ?></td>
18
+ <td style='text-align: left'><?php _e( 'Country', 'wp_statistics' ); ?></td>
19
+ <td style='text-align: left'><?php _e( 'IP', 'wp_statistics' ); ?></td>
20
+ <?php if ( $compact == false ) { ?>
21
+ <td style='text-align: left'><?php _e( 'Agent', 'wp_statistics' ); ?></td>
22
+ <td style='text-align: left'><?php _e( 'Platform', 'wp_statistics' ); ?></td>
23
+ <td style='text-align: left'><?php _e( 'Version', 'wp_statistics' ); ?></td>
24
+ <?php } ?>
25
+ </tr>
26
+
27
+ <?php
28
+ $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$sql_time}' ORDER BY hits DESC" );
29
+
30
+ $i = 0;
31
+
32
+ foreach ( $result as $visitor ) {
33
+ $i ++;
34
+
35
+ $item = strtoupper( $visitor->location );
36
+
37
+ echo "<tr>";
38
+ echo "<td style='text-align: left'>$i</td>";
39
+ echo "<td style='text-align: left'>" . (int) $visitor->hits . "</td>";
40
+ echo "<td style='text-align: left'><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item . '.png' ) . "' title='{$ISOCountryCode[$item]}'/></td>";
41
+ echo "<td style='text-align: left'>{$ISOCountryCode[$item]}</td>";
42
+ echo "<td style='text-align: left'>{$visitor->ip}</td>";
43
+
44
+ if ( $compact == false ) {
45
+ echo "<td style='text-align: left'>{$visitor->agent}</td>";
46
+ echo "<td style='text-align: left'>{$visitor->platform}</td>";
47
+ echo "<td style='text-align: left'>{$visitor->version}</td>";
48
+ }
49
+ echo "</tr>";
50
+
51
+ if ( $i == $count ) {
52
+ break;
53
+ }
54
+ }
55
+ ?>
56
+ </table>
57
+ <?php
58
+ }
includes/log/widgets/words.php CHANGED
@@ -1,68 +1,81 @@
1
  <?php
2
- function wp_statistics_generate_words_postbox_content($ISOCountryCode, $count = 10) {
3
-
4
- global $wpdb, $WP_Statistics;
5
-
6
- // Retrieve MySQL data for the search words.
7
- $search_query = wp_statistics_searchword_query('all');
8
-
9
- // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
10
- $tablename = $wpdb->prefix . 'statistics_';
11
-
12
- if( $WP_Statistics->get_option('search_converted') ) {
13
- $tabletwo = $tablename . 'visitor';
14
- $tablename .= 'search';
15
- $result = $wpdb->get_results("SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}");
16
- } else {
17
- $tablename .= 'visitor';
18
- $result = $wpdb->get_results("SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}");
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- if( sizeof($result) > 0 ) {
22
- echo "<div class='log-latest'>";
23
-
24
- foreach($result as $items) {
25
- if( !$WP_Statistics->Search_Engine_QueryString($items->referred) ) continue;
26
-
27
- if( substr( $items->ip, 0, 6 ) == '#hash#' ) { $ip_string = __('#hash#', 'wp_statistics'); } else { $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>"; }
28
-
29
- if( $WP_Statistics->get_option('search_converted') ) {
30
- $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine($items->engine);
31
- $words = $items->words;
32
- } else {
33
- $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
34
- $words = $WP_Statistics->Search_Engine_QueryString($items->referred);
35
- }
36
-
37
- echo "<div class='log-item'>";
38
- echo "<div class='log-referred'>".$words."</div>";
39
- echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . " - {$ip_string}</div>";
40
- echo "<div class='clear'></div>";
41
- echo "<div class='log-url'>";
42
- echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='".__('Map', 'wp_statistics')."'>".wp_statistics_icons('dashicons-location-alt', 'map')."</a>";
43
-
44
- if($WP_Statistics->get_option('geoip')) {
45
- echo "<img src='".plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png')."' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
46
- }
47
-
48
- $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
49
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='".plugins_url('wp-statistics/assets/images/' . $this_search_engine['image'])."' class='log-tools' title='".$this_search_engine['translated']."'/></a>";
50
-
51
- if( array_search( strtolower( $items->agent ), array( "chrome", "firefox", "msie", "opera", "safari" ) ) !== FALSE ){
52
- $agent = "<img src='".plugins_url('wp-statistics/assets/images/').$items->agent.".png' class='log-tools' title='{$items->agent}'/>";
53
- } else {
54
- $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
55
- }
56
-
57
- echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
58
-
59
- $referrer_html = $WP_Statistics->html_sanitize_referrer( $items->referred );
60
-
61
- echo "<a href='" . $referrer_html . "' title='" . $referrer_html . "'>" . wp_statistics_icons('dashicons-admin-links', 'link') . " " . $referrer_html . "</a></div>";
62
- echo "</div>";
63
  }
64
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  echo "</div>";
66
  }
 
 
67
  }
 
68
 
1
  <?php
2
+ function wp_statistics_generate_words_postbox_content( $ISOCountryCode, $count = 10 ) {
3
+
4
+ global $wpdb, $WP_Statistics;
5
+
6
+ // Retrieve MySQL data for the search words.
7
+ $search_query = wp_statistics_searchword_query( 'all' );
8
+
9
+ // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
10
+ $tablename = $wpdb->prefix . 'statistics_';
11
+
12
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
13
+ $tabletwo = $tablename . 'visitor';
14
+ $tablename .= 'search';
15
+ $result = $wpdb->get_results( "SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}" );
16
+ } else {
17
+ $tablename .= 'visitor';
18
+ $result = $wpdb->get_results( "SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}" );
19
+ }
20
+
21
+ if ( sizeof( $result ) > 0 ) {
22
+ echo "<div class='log-latest'>";
23
+
24
+ foreach ( $result as $items ) {
25
+ if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) {
26
+ continue;
27
+ }
28
+
29
+ if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
30
+ $ip_string = __( '#hash#', 'wp_statistics' );
31
+ } else {
32
+ $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
33
+ }
34
 
35
+ if ( $WP_Statistics->get_option( 'search_converted' ) ) {
36
+ $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine( $items->engine );
37
+ $words = $items->words;
38
+ } else {
39
+ $this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
40
+ $words = $WP_Statistics->Search_Engine_QueryString( $items->referred );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
+
43
+ echo "<div class='log-item'>";
44
+ echo "<div class='log-referred'>" . $words . "</div>";
45
+ echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . " - {$ip_string}</div>";
46
+ echo "<div class='clear'></div>";
47
+ echo "<div class='log-url'>";
48
+ echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp_statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>";
49
+
50
+ if ( $WP_Statistics->get_option( 'geoip' ) ) {
51
+ echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
52
+ }
53
+
54
+ $this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
55
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" . plugins_url( 'wp-statistics/assets/images/' . $this_search_engine['image'] ) . "' class='log-tools' title='" . $this_search_engine['translated'] . "'/></a>";
56
+
57
+ if ( array_search( strtolower( $items->agent ), array(
58
+ "chrome",
59
+ "firefox",
60
+ "msie",
61
+ "opera",
62
+ "safari"
63
+ ) ) !== false
64
+ ) {
65
+ $agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
66
+ } else {
67
+ $agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
68
+ }
69
+
70
+ echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
71
+
72
+ $referrer_html = $WP_Statistics->html_sanitize_referrer( $items->referred );
73
+
74
+ echo "<a href='" . $referrer_html . "' title='" . $referrer_html . "'>" . wp_statistics_icons( 'dashicons-admin-links', 'link' ) . " " . $referrer_html . "</a></div>";
75
  echo "</div>";
76
  }
77
+
78
+ echo "</div>";
79
  }
80
+ }
81
 
includes/optimization/tabs/wps-optimization-database.php CHANGED
@@ -1,124 +1,121 @@
1
  <div class="wrap">
2
- <table class="form-table">
3
- <tbody>
4
- <tr valign="top">
5
- <th scope="row" colspan="2"><h3><?php _e('Database Setup', 'wp_statistics'); ?></h3></th>
6
- </tr>
7
-
8
- <tr valign="top">
9
- <th scope="row">
10
- <label for="index-submit"><?php _e('Re-run Install', 'wp_statistics'); ?>:</label>
11
- </th>
12
-
13
- <td>
14
- <input id="install-submit" class="button button-primary" type="button" value="<?php _e('Install Now!', 'wp_statistics'); ?>" name="install-submit" onclick="location.href=document.URL+'&install=1&tab=database'">
15
- <p class="description"><?php _e('If for some reason your installation of WP Statistics is missing the database tables or other core items, this will re-execute the install process.', 'wp_statistics'); ?></p>
16
- </td>
17
- </tr>
18
-
19
- <tr valign="top">
20
- <th scope="row" colspan="2"><h3><?php _e('Database Index', 'wp_statistics'); ?></h3></th>
21
- </tr>
22
-
23
- <tr valign="top">
24
- <th scope="row">
25
- <label for="index-submit"><?php _e('Countries', 'wp_statistics'); ?>:</label>
26
- </th>
27
-
28
- <td>
29
- <?php
30
- GLOBAL $wpdb, $WP_Statistics;
31
- $wp_prefix = $wpdb->prefix;
32
-
33
- $dbupdates = $WP_Statistics->get_option('pending_db_updates');
34
-
35
- // Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
36
- $result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip_agent'");
37
-
38
- // Note, the result will be the number of fields contained in the index, so in our case 5.
39
- if( $result != 5 ) {
40
- $dbupdates['date_ip_agent'] = true;
41
- ?>
42
- <input id="index-submit" class="button button-primary" type="button" value="<?php _e('Update Now!', 'wp_statistics'); ?>" name="index-submit" onclick="location.href=document.URL+'&index=1&tab=database'">
43
- <p class="description"><?php _e('Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case. Newer installs protect against this with a unique index on the table. To create the index on the older installs duplicate entries must be deleted first. Clicking "Update Now" will scan the vistitors table, delete duplicate entries and add the index.', 'wp_statistics'); ?></p>
44
- <p class="description"><?php _e('This operation could take a long time on installs with many rows in the visitors table.', 'wp_statistics'); ?></p>
45
- <?php
46
- }
47
- else {
48
- $dbupdates['date_ip_agent'] = false;
49
- ?>
50
- <p class="description"><?php _e('Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case. Newer installs protect against this with a unique index on the table.', 'wp_statistics'); ?></p>
51
- <p class="description"><?php _e('Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics'); ?></p>
52
- <?php
53
- }
54
- ?>
55
- </td>
56
- </tr>
57
-
58
- <tr valign="top">
59
- <th scope="row">
60
- <label for="index-submit"><?php _e('Visits Table', 'wp_statistics'); ?>:</label>
61
- </th>
62
- <td>
63
- <?php
64
- GLOBAL $wpdb;
65
- $wp_prefix = $wpdb->prefix;
66
-
67
- // Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
68
- $result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'");
69
-
70
- // Note, the result will be the number of fields contained in the index, so in our case 1.
71
- if( $result != 1 ) {
72
- $dbupdates['unique_date'] = true;
73
- ?>
74
- <input id="visits-submit" class="button button-primary" type="button" value="<?php _e('Update Now!', 'wp_statistics'); ?>" name="visit-submit" onclick="location.href=document.URL+'&visits=1&tab=database'">
75
- <p class="description"><?php _e('Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case. Newer installs protect against this with a unique index on the table. To create the index on the older installs duplicate entries must be deleted first. Clicking "Update Now" will scan the vistits table, delete duplicate entries and add the index.', 'wp_statistics'); ?></p>
76
- <p class="description"><?php _e('This operation could take a long time on installs with many rows in the visits table.', 'wp_statistics'); ?></p>
77
- <?php
78
- }
79
- else {
80
- $dbupdates['unique_date'] = false;
81
- ?>
82
- <p class="description"><?php _e('Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case. Newer installs protect against this with a unique index on the table.', 'wp_statistics'); ?></p>
83
- <p class="description"><?php _e('Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics'); ?></p>
84
- <?php
85
- }
86
-
87
- $WP_Statistics->update_option('pending_db_updates', $dbupdates);
88
- ?>
89
- </td>
90
-
91
- </tr>
92
-
93
- <tr valign="top">
94
- <th scope="row" colspan="2"><h3><?php _e('Search Table', 'wp_statistics'); ?></h3></th>
95
- </tr>
96
-
97
- <tr valign="top">
98
- <th scope="row">
99
- <label for="index-submit"><?php _e('Convert', 'wp_statistics'); ?>:</label>
100
- </th>
101
- <td>
102
- <?php
103
- // Note, the result will be the number of fields contained in the index, so in our case 1.
104
- if( $WP_Statistics->get_option('search_converted') != 1 ) {
105
- ?>
106
- <input id="visits-submit" class="button button-primary" type="button" value="<?php _e('Convert Now!', 'wp_statistics'); ?>" name="search-submit" onclick="location.href=document.URL+'&search=1&tab=database'">
107
- <p class="description"><?php _e('Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets. A new table has been created to hold this information in a more scalable fashion, however the old data must first be converted to the new format before it can be used.', 'wp_statistics'); ?></p>
108
- <p class="description"><?php _e('This operation could take a long time on installs with many rows in the visitors table.', 'wp_statistics'); ?></p>
109
- <?php
110
- }
111
- else {
112
- ?>
113
- <p class="description"><?php _e('Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets. A new table has been created to hold this information in a more scalable fashion.', 'wp_statistics'); ?></p>
114
- <p class="description"><?php _e('Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics'); ?></p>
115
- <?php
116
- }
117
- ?>
118
- </td>
119
-
120
- </tr>
121
-
122
- </tbody>
123
- </table>
124
  </div>
1
  <div class="wrap">
2
+ <table class="form-table">
3
+ <tbody>
4
+ <tr valign="top">
5
+ <th scope="row" colspan="2"><h3><?php _e( 'Database Setup', 'wp_statistics' ); ?></h3></th>
6
+ </tr>
7
+
8
+ <tr valign="top">
9
+ <th scope="row">
10
+ <label for="index-submit"><?php _e( 'Re-run Install', 'wp_statistics' ); ?>:</label>
11
+ </th>
12
+
13
+ <td>
14
+ <input id="install-submit" class="button button-primary" type="button" value="<?php _e( 'Install Now!', 'wp_statistics' ); ?>" name="install-submit" onclick="location.href=document.URL+'&install=1&tab=database'">
15
+ <p class="description"><?php _e( 'If for some reason your installation of WP Statistics is missing the database tables or other core items, this will re-execute the install process.', 'wp_statistics' ); ?></p>
16
+ </td>
17
+ </tr>
18
+
19
+ <tr valign="top">
20
+ <th scope="row" colspan="2"><h3><?php _e( 'Database Index', 'wp_statistics' ); ?></h3></th>
21
+ </tr>
22
+
23
+ <tr valign="top">
24
+ <th scope="row">
25
+ <label for="index-submit"><?php _e( 'Countries', 'wp_statistics' ); ?>:</label>
26
+ </th>
27
+
28
+ <td>
29
+ <?php
30
+ GLOBAL $wpdb, $WP_Statistics;
31
+ $wp_prefix = $wpdb->prefix;
32
+
33
+ $dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
34
+
35
+ // Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
36
+ $result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip_agent'" );
37
+
38
+ // Note, the result will be the number of fields contained in the index, so in our case 5.
39
+ if ( $result != 5 ) {
40
+ $dbupdates['date_ip_agent'] = true;
41
+ ?>
42
+ <input id="index-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp_statistics' ); ?>" name="index-submit" onclick="location.href=document.URL+'&index=1&tab=database'">
43
+ <p class="description"><?php _e( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case. Newer installs protect against this with a unique index on the table. To create the index on the older installs duplicate entries must be deleted first. Clicking "Update Now" will scan the vistitors table, delete duplicate entries and add the index.', 'wp_statistics' ); ?></p>
44
+ <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp_statistics' ); ?></p>
45
+ <?php
46
+ } else {
47
+ $dbupdates['date_ip_agent'] = false;
48
+ ?>
49
+ <p class="description"><?php _e( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case. Newer installs protect against this with a unique index on the table.', 'wp_statistics' ); ?></p>
50
+ <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics' ); ?></p>
51
+ <?php
52
+ }
53
+ ?>
54
+ </td>
55
+ </tr>
56
+
57
+ <tr valign="top">
58
+ <th scope="row">
59
+ <label for="index-submit"><?php _e( 'Visits Table', 'wp_statistics' ); ?>:</label>
60
+ </th>
61
+ <td>
62
+ <?php
63
+ GLOBAL $wpdb;
64
+ $wp_prefix = $wpdb->prefix;
65
+
66
+ // Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
67
+ $result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
68
+
69
+ // Note, the result will be the number of fields contained in the index, so in our case 1.
70
+ if ( $result != 1 ) {
71
+ $dbupdates['unique_date'] = true;
72
+ ?>
73
+ <input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp_statistics' ); ?>" name="visit-submit" onclick="location.href=document.URL+'&visits=1&tab=database'">
74
+ <p class="description"><?php _e( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case. Newer installs protect against this with a unique index on the table. To create the index on the older installs duplicate entries must be deleted first. Clicking "Update Now" will scan the vistits table, delete duplicate entries and add the index.', 'wp_statistics' ); ?></p>
75
+ <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visits table.', 'wp_statistics' ); ?></p>
76
+ <?php
77
+ } else {
78
+ $dbupdates['unique_date'] = false;
79
+ ?>
80
+ <p class="description"><?php _e( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case. Newer installs protect against this with a unique index on the table.', 'wp_statistics' ); ?></p>
81
+ <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics' ); ?></p>
82
+ <?php
83
+ }
84
+
85
+ $WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
86
+ ?>
87
+ </td>
88
+
89
+ </tr>
90
+
91
+ <tr valign="top">
92
+ <th scope="row" colspan="2"><h3><?php _e( 'Search Table', 'wp_statistics' ); ?></h3></th>
93
+ </tr>
94
+
95
+ <tr valign="top">
96
+ <th scope="row">
97
+ <label for="index-submit"><?php _e( 'Convert', 'wp_statistics' ); ?>:</label>
98
+ </th>
99
+ <td>
100
+ <?php
101
+ // Note, the result will be the number of fields contained in the index, so in our case 1.
102
+ if ( $WP_Statistics->get_option( 'search_converted' ) != 1 ) {
103
+ ?>
104
+ <input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Convert Now!', 'wp_statistics' ); ?>" name="search-submit" onclick="location.href=document.URL+'&search=1&tab=database'">
105
+ <p class="description"><?php _e( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets. A new table has been created to hold this information in a more scalable fashion, however the old data must first be converted to the new format before it can be used.', 'wp_statistics' ); ?></p>
106
+ <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp_statistics' ); ?></p>
107
+ <?php
108
+ } else {
109
+ ?>
110
+ <p class="description"><?php _e( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets. A new table has been created to hold this information in a more scalable fashion.', 'wp_statistics' ); ?></p>
111
+ <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp_statistics' ); ?></p>
112
+ <?php
113
+ }
114
+ ?>
115
+ </td>
116
+
117
+ </tr>
118
+
119
+ </tbody>
120
+ </table>
 
 
 
121
  </div>
includes/optimization/tabs/wps-optimization-export.php CHANGED
@@ -1,61 +1,61 @@
1
  <div class="wrap">
2
-
3
- <form method="post">
4
- <input type="hidden" name="wps_export" value="true">
5
- <table class="form-table">
6
- <tbody>
7
- <tr valign="top">
8
- <th scope="row" colspan="2"><h3><?php _e('Export', 'wp_statistics'); ?></h3></th>
9
- </tr>
10
-
11
- <tr valign="top">
12
- <th scope="row">
13
- <label for="table-to-export"><?php _e('Export from', 'wp_statistics'); ?>:</label>
14
- </th>
15
-
16
- <td>
17
- <select id="table-to-export" name="table-to-export">
18
- <option value="0"><?php _e('Please select', 'wp_statistics'); ?></option>
19
- <option value="useronline"><?php echo $wpdb->prefix . 'statistics_useronline'; ?></option>
20
- <option value="visit"><?php echo $wpdb->prefix . 'statistics_visit'; ?></option>
21
- <option value="visitor"><?php echo $wpdb->prefix . 'statistics_visitor'; ?></option>
22
- <option value="exclusions"><?php echo $wpdb->prefix . 'statistics_exclusions'; ?></option>
23
- <option value="pages"><?php echo $wpdb->prefix . 'statistics_pages'; ?></option>
24
- <option value="search"><?php echo $wpdb->prefix . 'statistics_search'; ?></option>
25
- </select>
26
- <p class="description"><?php _e('Select the table for the output file.', 'wp_statistics'); ?></p>
27
- </td>
28
- </tr>
29
-
30
- <tr valign="top">
31
- <th scope="row">
32
- <label for="export-file-type"><?php _e('Export To', 'wp_statistics'); ?>:</label>
33
- </th>
34
-
35
- <td>
36
- <select id="export-file-type" name="export-file-type">
37
- <option value="0"><?php _e('Please select', 'wp_statistics'); ?></option>
38
- <option value="xml">XML</option>
39
- <option value="csv">CSV</option>
40
- <option value="tsv">TSV</option>
41
- </select>
42
- <p class="description"><?php _e('Select the output file type.', 'wp_statistics'); ?></p>
43
- </td>
44
- </tr>
45
-
46
- <tr valign="top">
47
- <th scope="row">
48
- <label for="export-headers"><?php _e('Include Header Row', 'wp_statistics'); ?>:</label>
49
- </th>
50
-
51
- <td>
52
- <input id="export-headers" type="checkbox" value="1" name="export-headers">
53
- <p class="description"><?php _e('Include a header row as the first line of the exported file.', 'wp_statistics'); ?></p>
54
- <?php submit_button(__('Start Now!', 'wp_statistics'), 'primary', 'export-file-submit'); ?>
55
- </td>
56
- </tr>
57
-
58
- </tbody>
59
- </table>
60
- </form>
61
  </div>
1
  <div class="wrap">
2
+
3
+ <form method="post">
4
+ <input type="hidden" name="wps_export" value="true">
5
+ <table class="form-table">
6
+ <tbody>
7
+ <tr valign="top">
8
+ <th scope="row" colspan="2"><h3><?php _e( 'Export', 'wp_statistics' ); ?></h3></th>
9
+ </tr>
10
+
11
+ <tr valign="top">
12
+ <th scope="row">
13
+ <label for="table-to-export"><?php _e( 'Export from', 'wp_statistics' ); ?>:</label>
14
+ </th>
15
+
16
+ <td>
17
+ <select id="table-to-export" name="table-to-export">
18
+ <option value="0"><?php _e( 'Please select', 'wp_statistics' ); ?></option>
19
+ <option value="useronline"><?php echo $wpdb->prefix . 'statistics_useronline'; ?></option>
20
+ <option value="visit"><?php echo $wpdb->prefix . 'statistics_visit'; ?></option>
21
+ <option value="visitor"><?php echo $wpdb->prefix . 'statistics_visitor'; ?></option>
22
+ <option value="exclusions"><?php echo $wpdb->prefix . 'statistics_exclusions'; ?></option>
23
+ <option value="pages"><?php echo $wpdb->prefix . 'statistics_pages'; ?></option>
24
+ <option value="search"><?php echo $wpdb->prefix . 'statistics_search'; ?></option>
25
+ </select>
26
+ <p class="description"><?php _e( 'Select the table for the output file.', 'wp_statistics' ); ?></p>
27
+ </td>
28
+ </tr>
29
+
30
+ <tr valign="top">
31
+ <th scope="row">
32
+ <label for="export-file-type"><?php _e( 'Export To', 'wp_statistics' ); ?>:</label>
33
+ </th>
34
+
35
+ <td>
36
+ <select id="export-file-type" name="export-file-type">
37
+ <option value="0"><?php _e( 'Please select', 'wp_statistics' ); ?></option>
38
+ <option value="xml">XML</option>
39
+ <option value="csv">CSV</option>
40
+ <option value="tsv">TSV</option>
41
+ </select>
42
+ <p class="description"><?php _e( 'Select the output file type.', 'wp_statistics' ); ?></p>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr valign="top">
47
+ <th scope="row">
48
+ <label for="export-headers"><?php _e( 'Include Header Row', 'wp_statistics' ); ?>:</label>
49
+ </th>
50
+
51
+ <td>
52
+ <input id="export-headers" type="checkbox" value="1" name="export-headers">
53
+ <p class="description"><?php _e( 'Include a header row as the first line of the exported file.', 'wp_statistics' ); ?></p>
54
+ <?php submit_button( __( 'Start Now!', 'wp_statistics' ), 'primary', 'export-file-submit' ); ?>
55
+ </td>
56
+ </tr>
57
+
58
+ </tbody>
59
+ </table>
60
+ </form>
61
  </div>
includes/optimization/tabs/wps-optimization-historical.php CHANGED
@@ -1,58 +1,58 @@
1
  <?php
2
- // Get the historical number of visitors to the site
3
- $historical_visitors = $WP_Statistics->Get_Historical_Data( 'visitors' );
4
 
5
- // Get the historical number of visits to the site
6
- $historical_visits = $WP_Statistics->Get_Historical_Data( 'visits' );
7
 
8
  ?>
9
- <div class="wrap">
10
- <form id="wps_historical_form" method="post">
11
- <?php wp_nonce_field('historical_form', 'wp-statistics-nonce');?>
12
- <table class="form-table">
13
- <tbody>
14
- <tr valign="top">
15
- <th scope="row" colspan="2"><h3><?php _e('Historical Values', 'wp_statistics'); ?></h3></th>
16
- </tr>
17
-
18
- <tr valign="top" id="wps_historical_purge" style="display: none">
19
- <th scope="row" colspan=2>
20
- <?php _e('Note: As you have just purged the database you must reload this page for these numbers to be correct.', 'wp_statistics'); ?>
21
- </th>
22
- </tr>
23
-
24
- <tr valign="top">
25
- <th scope="row">
26
- <?php _e('Visitors', 'wp_statistics'); ?>:
27
- </th>
28
-
29
- <td>
30
- <input type="text" size="10" value="<?php echo $historical_visitors; ?>" id="wps_historical_visitors" name="wps_historical_visitors">
31
- <p class="description"><?php echo sprintf( __('Number of historical number of visitors to the site (current value is %s).', 'wp_statistics'), number_format_i18n( $historical_visitors )); ?></p>
32
- </td>
33
- </tr>
34
-
35
- <tr valign="top">
36
- <th scope="row">
37
- <?php _e('Visits', 'wp_statistics'); ?>:
38
- </th>
39
-
40
- <td>
41
- <input type="text" size="10" value="<?php echo $historical_visits; ?>" id="wps_historical_visits" name="wps_historical_visits">
42
- <p class="description"><?php echo sprintf( __('Number of historical number of visits to the site (current value is %s).', 'wp_statistics'), number_format_i18n( $historical_visits )); ?></p>
43
- </td>
44
- </tr>
45
-
46
- <tr valign="top">
47
- <td colspan=2>
48
- <input id="historical-submit" class="button button-primary" type="submit" value="<?php _e('Update now!', 'wp_statistics'); ?>" name="historical-submit"/>
49
- </td>
50
- </tr>
51
-
52
- </tbody>
53
-
54
- </table>
55
-
56
- </form>
57
-
58
- </div>
1
  <?php
2
+ // Get the historical number of visitors to the site
3
+ $historical_visitors = $WP_Statistics->Get_Historical_Data( 'visitors' );
4
 
5
+ // Get the historical number of visits to the site
6
+ $historical_visits = $WP_Statistics->Get_Historical_Data( 'visits' );
7
 
8
  ?>
9
+ <div class="wrap">
10
+ <form id="wps_historical_form" method="post">
11
+ <?php wp_nonce_field( 'historical_form', 'wp-statistics-nonce' ); ?>
12
+ <table class="form-table">
13
+ <tbody>
14
+ <tr valign="top">
15
+ <th scope="row" colspan="2"><h3><?php _e( 'Historical Values', 'wp_statistics' ); ?></h3></th>
16
+ </tr>
17
+
18
+ <tr valign="top" id="wps_historical_purge" style="display: none">
19
+ <th scope="row" colspan=2>
20
+ <?php _e( 'Note: As you have just purged the database you must reload this page for these numbers to be correct.', 'wp_statistics' ); ?>
21
+ </th>
22
+ </tr>
23
+
24
+ <tr valign="top">
25
+ <th scope="row">
26
+ <?php _e( 'Visitors', 'wp_statistics' ); ?>:
27
+ </th>
28
+
29
+ <td>
30
+ <input type="text" size="10" value="<?php echo $historical_visitors; ?>" id="wps_historical_visitors" name="wps_historical_visitors">
31
+ <p class="description"><?php echo sprintf( __( 'Number of historical number of visitors to the site (current value is %s).', 'wp_statistics' ), number_format_i18n( $historical_visitors ) ); ?></p>
32
+ </td>
33
+ </tr>
34
+
35
+ <tr valign="top">
36
+ <th scope="row">
37
+ <?php _e( 'Visits', 'wp_statistics' ); ?>:
38
+ </th>
39
+
40
+ <td>
41
+ <input type="text" size="10" value="<?php echo $historical_visits; ?>" id="wps_historical_visits" name="wps_historical_visits">
42
+ <p class="description"><?php echo sprintf( __( 'Number of historical number of visits to the site (current value is %s).', 'wp_statistics' ), number_format_i18n( $historical_visits ) ); ?></p>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr valign="top">
47
+ <td colspan=2>
48
+ <input id="historical-submit" class="button button-primary" type="submit" value="<?php _e( 'Update now!', 'wp_statistics' ); ?>" name="historical-submit"/>
49
+ </td>
50
+ </tr>
51
+
52
+ </tbody>
53
+
54
+ </table>
55
+
56
+ </form>
57
+
58
+ </div>
includes/optimization/tabs/wps-optimization-purging.php CHANGED
@@ -1,284 +1,290 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function() {
3
- jQuery("#purge-data-submit").click(function(){
4
-
5
- var action = jQuery('#purge-data').val();
6
-
7
- if(action == 0)
8
- return false;
9
-
10
- var agree = confirm('<?php _e('Are you sure?', 'wp_statistics'); ?>');
11
-
12
- if(!agree)
13
- return false;
14
-
15
- jQuery("#purge-data-submit").attr("disabled", "disabled");
16
- jQuery("#purge-data-status").html("<img src='<?php echo plugins_url('wp-statistics'); ?>/assets/images/loading.gif'/>");
17
-
18
- var data = {
19
- 'action': 'wp_statistics_purge_data',
20
- 'purge-days': action,
21
- };
22
-
23
- jQuery.ajax({ url: ajaxurl,
24
- type: 'post',
25
- data: data,
26
- datatype: 'json',
27
- })
28
- .always(function(result){
29
- jQuery("#purge-data-status").html("");
30
- jQuery("#purge-data-result").html(result);
31
- jQuery("#purge-data-submit").removeAttr("disabled");
32
- jQuery("#wps_historical_purge").show();
33
- });
34
- });
35
-
36
- jQuery("#purge-visitor-hits-submit").click(function(){
37
-
38
- var action = jQuery('#purge-visitor-hits').val();
39
-
40
- if(action == 0)
41
- return false;
42
-
43
- var agree = confirm('<?php _e('Are you sure?', 'wp_statistics'); ?>');
44
-
45
- if(!agree)
46
- return false;
47
-
48
- jQuery("#purge-visitor-hits-submit").attr("disabled", "disabled");
49
- jQuery("#purge-visitor-hits-status").html("<img src='<?php echo plugins_url('wp-statistics'); ?>/assets/images/loading.gif'/>");
50
-
51
- var data = {
52
- 'action': 'wp_statistics_purge_visitor_hits',
53
- 'purge-hits': action,
54
- };
55
-
56
- jQuery.ajax({ url: ajaxurl,
57
- type: 'post',
58
- data: data,
59
- datatype: 'json',
60
- })
61
- .always(function(result){
62
- jQuery("#purge-visitor-hits-status").html("");
63
- jQuery("#purge-visitor-hits-result").html(result);
64
- jQuery("#purge-visitor-hits-submit").removeAttr("disabled");
65
- });
66
- });
67
-
68
- jQuery("#empty-table-submit").click(function(){
69
-
70
- var action = jQuery('#empty-table').val();
71
-
72
- if(action == 0)
73
- return false;
74
-
75
- var agree = confirm('<?php _e('Are you sure?', 'wp_statistics'); ?>');
76
-
77
- if(!agree)
78
- return false;
79
-
80
- jQuery("#empty-table-submit").attr("disabled", "disabled");
81
- jQuery("#empty-status").html("<img src='<?php echo plugins_url('wp-statistics'); ?>/assets/images/loading.gif'/>");
82
-
83
- var data = {
84
- 'action': 'wp_statistics_empty_table',
85
- 'table-name': action,
86
- };
87
-
88
- jQuery.ajax({ url: ajaxurl,
89
- type: 'post',
90
- data: data,
91
- datatype: 'json',
92
- })
93
- .always(function(result){
94
- jQuery("#empty-status").html("");
95
- jQuery("#empty-result").html(result);
96
- jQuery("#empty-table-submit").removeAttr("disabled");
97
- });
98
- });
99
-
100
- jQuery("#delete-agents-submit").click(function(){
101
-
102
- var action = jQuery('#delete-agent').val();
103
-
104
- if(action == 0)
105
- return false;
106
-
107
- var agree = confirm('<?php _e('Are you sure?', 'wp_statistics'); ?>');
108
-
109
- if(!agree)
110
- return false;
111
-
112
- jQuery("#delete-agents-submit").attr("disabled", "disabled");
113
- jQuery("#delete-agents-status").html("<img src='<?php echo plugins_url('wp-statistics'); ?>/assets/images/loading.gif'/>");
114
-
115
- var data = {
116
- 'action': 'wp_statistics_delete_agents',
117
- 'agent-name': action,
118
- };
119
-
120
- jQuery.ajax({ url: ajaxurl,
121
- type: 'post',
122
- data: data,
123
- datatype: 'json',
124
- })
125
- .always(function(result){
126
- jQuery("#delete-agents-status").html("");
127
- jQuery("#delete-agents-result").html(result);
128
- jQuery("#delete-agents-submit").removeAttr("disabled");
129
- aid = data['agent-name'].replace(/[^a-zA-Z]/g, "");
130
- jQuery("#agent-" + aid + "-id").remove();
131
- });
132
- });
133
-
134
- jQuery("#delete-platforms-submit").click(function(){
135
-
136
- var action = jQuery('#delete-platform').val();
137
-
138
- if(action == 0)
139
- return false;
140
-
141
- var agree = confirm('<?php _e('Are you sure?', 'wp_statistics'); ?>');
142
-
143
- if(!agree)
144
- return false;
145
-
146
- jQuery("#delete-platforms-submit").attr("disabled", "disabled");
147
- jQuery("#delete-platforms-status").html("<img src='<?php echo plugins_url('wp-statistics'); ?>/assets/images/loading.gif'/>");
148
-
149
- var data = {
150
- 'action': 'wp_statistics_delete_platforms',
151
- 'platform-name': action,
152
- };
153
-
154
- jQuery.ajax({ url: ajaxurl,
155
- type: 'post',
156
- data: data,
157
- datatype: 'json',
158
- })
159
- .always(function(result){
160
- jQuery("#delete-platforms-status").html("");
161
- jQuery("#delete-platforms-result").html(result);
162
- jQuery("#delete-platforms-submit").removeAttr("disabled");
163
- pid = data['platform-name'].replace(/[^a-zA-Z]/g, "");
164
- jQuery("#platform-" + pid + "-id").remove();
165
- });
166
- });
167
-
168
- });
 
 
 
 
 
169
  </script>
170
 
171
  <div class="wrap">
172
- <table class="form-table">
173
- <tbody>
174
- <tr valign="top">
175
- <th scope="row" colspan="2"><h3><?php _e('Data', 'wp_statistics'); ?></h3></th>
176
- </tr>
177
-
178
- <tr valign="top">
179
- <th scope="row">
180
- <label for="empty-table"><?php _e('Empty Table', 'wp_statistics'); ?>:</label>
181
- </th>
182
-
183
- <td>
184
- <select id="empty-table" name="empty-table">
185
- <option value="0"><?php _e('Please select', 'wp_statistics'); ?></option>
186
- <option value="useronline"><?php echo $wpdb->prefix . 'statistics_useronline'; ?></option>
187
- <option value="visit"><?php echo $wpdb->prefix . 'statistics_visit'; ?></option>
188
- <option value="visitor"><?php echo $wpdb->prefix . 'statistics_visitor'; ?></option>
189
- <option value="exclusions"><?php echo $wpdb->prefix . 'statistics_exclusions'; ?></option>
190
- <option value="pages"><?php echo $wpdb->prefix . 'statistics_pages'; ?></option>
191
- <option value="search"><?php echo $wpdb->prefix . 'statistics_search'; ?></option>
192
- <option value="all"><?php echo __('All','wp_statistics'); ?></option>
193
- </select>
194
- <p class="description"><?php _e('All data table will be lost.', 'wp_statistics'); ?></p>
195
- <input id="empty-table-submit" class="button button-primary" type="submit" value="<?php _e('Clear now!', 'wp_statistics'); ?>" name="empty-table-submit" Onclick="return false;"/>
196
- <span id="empty-status"></span>
197
- <div id="empty-result"></div>
198
- </td>
199
- </tr>
200
-
201
- <tr>
202
- <th scope="row">
203
- <label for="purge-data"><?php _e('Purge records older than', 'wp_statistics'); ?>:</label>
204
- </th>
205
-
206
- <td>
207
- <input type="text" class="small-text code" id="purge-data" name="wps_purge_data" value="365"/>
208
- <label for="purge-data"><?php _e('days', 'wp_statistics'); ?></label>
209
- <p class="description"><?php _e('Deleted user statistics data older than the selected number of days. Minimum value is 30 days.', 'wp_statistics'); ?></p>
210
- <input id="purge-data-submit" class="button button-primary" type="submit" value="<?php _e('Purge now!', 'wp_statistics'); ?>" name="purge-data-submit" Onclick="return false;"/>
211
- <span id="purge-data-status"></span>
212
- <div id="purge-data-result"></div>
213
- </td>
214
- </tr>
215
-
216
- <tr>
217
- <th scope="row">
218
- <label for="purge-visitor-hits"><?php _e('Purge visitors with more than', 'wp_statistics'); ?>:</label>
219
- </th>
220
-
221
- <td>
222
- <input type="text" class="small-text code" id="purge-visitor-hits" name="wps_purge_visitor_hits" value="10"/>
223
- <label for="purge-visitor-hits"><?php _e('hits', 'wp_statistics'); ?></label>
224
- <p class="description"><?php _e('Deleted user statistics data where the user has more than the defined number of hits in a day. This can be useful to clear up old data when your site has been hit by a bot. This will remove the visitor and their hits to the site, however it will not remove individual page hits as that data is not recorded on a per use basis. Minimum value is 10 hits.', 'wp_statistics'); ?></p>
225
- <input id="purge-visitor-hits-submit" class="button button-primary" type="submit" value="<?php _e('Purge now!', 'wp_statistics'); ?>" name="purge-visitor-hits-submit" Onclick="return false;"/>
226
- <span id="purge-visitor-hits-status"></span>
227
- <div id="purge-visitor-hits-result"></div>
228
- </td>
229
- </tr>
230
-
231
- <tr valign="top">
232
- <th scope="row" colspan="2"><h3><?php _e('Delete User Agent Types', 'wp_statistics'); ?></h3></th>
233
- </tr>
234
-
235
- <tr valign="top">
236
- <th scope="row">
237
- <label for="delete-agent"><?php _e('Delete Agents', 'wp_statistics'); ?>:</label>
238
- </th>
239
-
240
- <td>
241
- <select id="delete-agent" name="delete-agent">
242
- <option value="0"><?php _e('Please select', 'wp_statistics'); ?></option>
243
- <?php
244
- $agents = wp_statistics_ua_list();
245
-
246
- foreach($agents as $agent) {
247
- $aid = preg_replace( "/[^a-zA-Z]/", "", $agent );
248
- echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>";
249
- }
250
- ?>
251
- </select>
252
- <p class="description"><?php _e('All visitor data will be lost for this agent type.', 'wp_statistics'); ?></p>
253
- <input id="delete-agents-submit" class="button button-primary" type="submit" value="<?php _e('Delete now!', 'wp_statistics'); ?>" name="delete-agents-submit" Onclick="return false;">
254
- <span id="delete-agents-status"></span>
255
- <div id="delete-agents-result"></div>
256
- </td>
257
- </tr>
258
-
259
- <tr valign="top">
260
- <th scope="row">
261
- <label for="delete-platform"><?php _e('Delete Platforms', 'wp_statistics'); ?>:</label>
262
- </th>
263
-
264
- <td>
265
- <select id="delete-platform" name="delete-platform">
266
- <option value="0"><?php _e('Please select', 'wp_statistics'); ?></option>
267
- <?php
268
- $platforms = wp_statistics_platform_list();
269
-
270
- foreach($platforms as $platform) {
271
- $pid = preg_replace( "/[^a-zA-Z]/", "", $platform );
272
- echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>";
273
- }
274
- ?>
275
- </select>
276
- <p class="description"><?php _e('All visitor data will be lost for this platform type.', 'wp_statistics'); ?></p>
277
- <input id="delete-platforms-submit" class="button button-primary" type="submit" value="<?php _e('Delete now!', 'wp_statistics'); ?>" name="delete-platforms-submit" Onclick="return false;">
278
- <span id="delete-platforms-status"></span>
279
- <div id="delete-platforms-result"></div>
280
- </td>
281
- </tr>
282
- </tbody>
283
- </table>
 
284
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ jQuery("#purge-data-submit").click(function () {
4
+
5
+ var action = jQuery('#purge-data').val();
6
+
7
+ if (action == 0)
8
+ return false;
9
+
10
+ var agree = confirm('<?php _e( 'Are you sure?', 'wp_statistics' ); ?>');
11
+
12
+ if (!agree)
13
+ return false;
14
+
15
+ jQuery("#purge-data-submit").attr("disabled", "disabled");
16
+ jQuery("#purge-data-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
17
+
18
+ var data = {
19
+ 'action': 'wp_statistics_purge_data',
20
+ 'purge-days': action,
21
+ };
22
+
23
+ jQuery.ajax({
24
+ url: ajaxurl,
25
+ type: 'post',
26
+ data: data,
27
+ datatype: 'json',
28
+ })
29
+ .always(function (result) {
30
+ jQuery("#purge-data-status").html("");
31
+ jQuery("#purge-data-result").html(result);
32
+ jQuery("#purge-data-submit").removeAttr("disabled");
33
+ jQuery("#wps_historical_purge").show();
34
+ });
35
+ });
36
+
37
+ jQuery("#purge-visitor-hits-submit").click(function () {
38
+
39
+ var action = jQuery('#purge-visitor-hits').val();
40
+
41
+ if (action == 0)
42
+ return false;
43
+
44
+ var agree = confirm('<?php _e( 'Are you sure?', 'wp_statistics' ); ?>');
45
+
46
+ if (!agree)
47
+ return false;
48
+
49
+ jQuery("#purge-visitor-hits-submit").attr("disabled", "disabled");
50
+ jQuery("#purge-visitor-hits-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
51
+
52
+ var data = {
53
+ 'action': 'wp_statistics_purge_visitor_hits',
54
+ 'purge-hits': action,
55
+ };
56
+
57
+ jQuery.ajax({
58
+ url: ajaxurl,
59
+ type: 'post',
60
+ data: data,
61
+ datatype: 'json',
62
+ })
63
+ .always(function (result) {
64
+ jQuery("#purge-visitor-hits-status").html("");
65
+ jQuery("#purge-visitor-hits-result").html(result);
66
+ jQuery("#purge-visitor-hits-submit").removeAttr("disabled");
67
+ });
68
+ });
69
+
70
+ jQuery("#empty-table-submit").click(function () {
71
+
72
+ var action = jQuery('#empty-table').val();
73
+
74
+ if (action == 0)
75
+ return false;
76
+
77
+ var agree = confirm('<?php _e( 'Are you sure?', 'wp_statistics' ); ?>');
78
+
79
+ if (!agree)
80
+ return false;
81
+
82
+ jQuery("#empty-table-submit").attr("disabled", "disabled");
83
+ jQuery("#empty-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
84
+
85
+ var data = {
86
+ 'action': 'wp_statistics_empty_table',
87
+ 'table-name': action,
88
+ };
89
+
90
+ jQuery.ajax({
91
+ url: ajaxurl,
92
+ type: 'post',
93
+ data: data,
94
+ datatype: 'json',
95
+ })
96
+ .always(function (result) {
97
+ jQuery("#empty-status").html("");
98
+ jQuery("#empty-result").html(result);
99
+ jQuery("#empty-table-submit").removeAttr("disabled");
100
+ });
101
+ });
102
+
103
+ jQuery("#delete-agents-submit").click(function () {
104
+
105
+ var action = jQuery('#delete-agent').val();
106
+
107
+ if (action == 0)
108
+ return false;
109
+
110
+ var agree = confirm('<?php _e( 'Are you sure?', 'wp_statistics' ); ?>');
111
+
112
+ if (!agree)
113
+ return false;
114
+
115
+ jQuery("#delete-agents-submit").attr("disabled", "disabled");
116
+ jQuery("#delete-agents-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
117
+
118
+ var data = {
119
+ 'action': 'wp_statistics_delete_agents',
120
+ 'agent-name': action,
121
+ };
122
+
123
+ jQuery.ajax({
124
+ url: ajaxurl,
125
+ type: 'post',
126
+ data: data,
127
+ datatype: 'json',
128
+ })
129
+ .always(function (result) {
130
+ jQuery("#delete-agents-status").html("");
131
+ jQuery("#delete-agents-result").html(result);
132
+ jQuery("#delete-agents-submit").removeAttr("disabled");
133
+ aid = data['agent-name'].replace(/[^a-zA-Z]/g, "");
134
+ jQuery("#agent-" + aid + "-id").remove();
135
+ });
136
+ });
137
+
138
+ jQuery("#delete-platforms-submit").click(function () {
139
+
140
+ var action = jQuery('#delete-platform').val();
141
+
142
+ if (action == 0)
143
+ return false;
144
+
145
+ var agree = confirm('<?php _e( 'Are you sure?', 'wp_statistics' ); ?>');
146
+
147
+ if (!agree)
148
+ return false;
149
+
150
+ jQuery("#delete-platforms-submit").attr("disabled", "disabled");
151
+ jQuery("#delete-platforms-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
152
+
153
+ var data = {
154
+ 'action': 'wp_statistics_delete_platforms',
155
+ 'platform-name': action,
156
+ };
157
+
158
+ jQuery.ajax({
159
+ url: ajaxurl,
160
+ type: 'post',
161
+ data: data,
162
+ datatype: 'json',
163
+ })
164
+ .always(function (result) {
165
+ jQuery("#delete-platforms-status").html("");
166
+ jQuery("#delete-platforms-result").html(result);
167
+ jQuery("#delete-platforms-submit").removeAttr("disabled");
168
+ pid = data['platform-name'].replace(/[^a-zA-Z]/g, "");
169
+ jQuery("#platform-" + pid + "-id").remove();
170
+ });
171
+ });
172
+
173
+ });
174
  </script>
175
 
176
  <div class="wrap">
177
+ <table class="form-table">
178
+ <tbody>
179
+ <tr valign="top">
180
+ <th scope="row" colspan="2"><h3><?php _e( 'Data', 'wp_statistics' ); ?></h3></th>
181
+ </tr>
182
+
183
+ <tr valign="top">
184
+ <th scope="row">
185
+ <label for="empty-table"><?php _e( 'Empty Table', 'wp_statistics' ); ?>:</label>
186
+ </th>
187
+
188
+ <td>
189
+ <select id="empty-table" name="empty-table">
190
+ <option value="0"><?php _e( 'Please select', 'wp_statistics' ); ?></option>
191
+ <option value="useronline"><?php echo $wpdb->prefix . 'statistics_useronline'; ?></option>
192
+ <option value="visit"><?php echo $wpdb->prefix . 'statistics_visit'; ?></option>
193
+ <option value="visitor"><?php echo $wpdb->prefix . 'statistics_visitor'; ?></option>
194
+ <option value="exclusions"><?php echo $wpdb->prefix . 'statistics_exclusions'; ?></option>
195
+ <option value="pages"><?php echo $wpdb->prefix . 'statistics_pages'; ?></option>
196
+ <option value="search"><?php echo $wpdb->prefix . 'statistics_search'; ?></option>
197
+ <option value="all"><?php echo __( 'All', 'wp_statistics' ); ?></option>
198
+ </select>
199
+ <p class="description"><?php _e( 'All data table will be lost.', 'wp_statistics' ); ?></p>
200
+ <input id="empty-table-submit" class="button button-primary" type="submit" value="<?php _e( 'Clear now!', 'wp_statistics' ); ?>" name="empty-table-submit" Onclick="return false;"/>
201
+ <span id="empty-status"></span>
202
+ <div id="empty-result"></div>
203
+ </td>
204
+ </tr>
205
+
206
+ <tr>
207
+ <th scope="row">
208
+ <label for="purge-data"><?php _e( 'Purge records older than', 'wp_statistics' ); ?>:</label>
209
+ </th>
210
+
211
+ <td>
212
+ <input type="text" class="small-text code" id="purge-data" name="wps_purge_data" value="365"/>
213
+ <label for="purge-data"><?php _e( 'days', 'wp_statistics' ); ?></label>
214
+ <p class="description"><?php _e( 'Deleted user statistics data older than the selected number of days. Minimum value is 30 days.', 'wp_statistics' ); ?></p>
215
+ <input id="purge-data-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp_statistics' ); ?>" name="purge-data-submit" Onclick="return false;"/>
216
+ <span id="purge-data-status"></span>
217
+ <div id="purge-data-result"></div>
218
+ </td>
219
+ </tr>
220
+
221
+ <tr>
222
+ <th scope="row">
223
+ <label for="purge-visitor-hits"><?php _e( 'Purge visitors with more than', 'wp_statistics' ); ?>
224
+ :</label>
225
+ </th>
226
+
227
+ <td>
228
+ <input type="text" class="small-text code" id="purge-visitor-hits" name="wps_purge_visitor_hits" value="10"/>
229
+ <label for="purge-visitor-hits"><?php _e( 'hits', 'wp_statistics' ); ?></label>
230
+ <p class="description"><?php _e( 'Deleted user statistics data where the user has more than the defined number of hits in a day. This can be useful to clear up old data when your site has been hit by a bot. This will remove the visitor and their hits to the site, however it will not remove individual page hits as that data is not recorded on a per use basis. Minimum value is 10 hits.', 'wp_statistics' ); ?></p>
231
+ <input id="purge-visitor-hits-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp_statistics' ); ?>" name="purge-visitor-hits-submit" Onclick="return false;"/>
232
+ <span id="purge-visitor-hits-status"></span>
233
+ <div id="purge-visitor-hits-result"></div>
234
+ </td>
235
+ </tr>
236
+
237
+ <tr valign="top">
238
+ <th scope="row" colspan="2"><h3><?php _e( 'Delete User Agent Types', 'wp_statistics' ); ?></h3></th>
239
+ </tr>
240
+
241
+ <tr valign="top">
242
+ <th scope="row">
243
+ <label for="delete-agent"><?php _e( 'Delete Agents', 'wp_statistics' ); ?>:</label>
244
+ </th>
245
+
246
+ <td>
247
+ <select id="delete-agent" name="delete-agent">
248
+ <option value="0"><?php _e( 'Please select', 'wp_statistics' ); ?></option>
249
+ <?php
250
+ $agents = wp_statistics_ua_list();
251
+
252
+ foreach ( $agents as $agent ) {
253
+ $aid = preg_replace( "/[^a-zA-Z]/", "", $agent );
254
+ echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>";
255
+ }
256
+ ?>
257
+ </select>
258
+ <p class="description"><?php _e( 'All visitor data will be lost for this agent type.', 'wp_statistics' ); ?></p>
259
+ <input id="delete-agents-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp_statistics' ); ?>" name="delete-agents-submit" Onclick="return false;">
260
+ <span id="delete-agents-status"></span>
261
+ <div id="delete-agents-result"></div>
262
+ </td>
263
+ </tr>
264
+
265
+ <tr valign="top">
266
+ <th scope="row">
267
+ <label for="delete-platform"><?php _e( 'Delete Platforms', 'wp_statistics' ); ?>:</label>
268
+ </th>
269
+
270
+ <td>
271
+ <select id="delete-platform" name="delete-platform">
272
+ <option value="0"><?php _e( 'Please select', 'wp_statistics' ); ?></option>
273
+ <?php
274
+ $platforms = wp_statistics_platform_list();
275
+
276
+ foreach ( $platforms as $platform ) {
277
+ $pid = preg_replace( "/[^a-zA-Z]/", "", $platform );
278
+ echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>";
279
+ }
280
+ ?>
281
+ </select>
282
+ <p class="description"><?php _e( 'All visitor data will be lost for this platform type.', 'wp_statistics' ); ?></p>
283
+ <input id="delete-platforms-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp_statistics' ); ?>" name="delete-platforms-submit" Onclick="return false;">
284
+ <span id="delete-platforms-status"></span>
285
+ <div id="delete-platforms-result"></div>
286
+ </td>
287
+ </tr>
288
+ </tbody>
289
+ </table>
290
  </div>
includes/optimization/tabs/wps-optimization-resources.php CHANGED
@@ -1,346 +1,384 @@
1
- <?php
2
- /* format size of file
3
- * @author Mike Zriel
4
- * @date 7 March 2011
5
- * @website www.zriel.com
6
- */
7
- function formatSize($size) {
8
- $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
9
- if ($size == 0) { return('n/a'); } else {
10
- return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
 
 
11
  }
 
 
12
  ?>
13
  <div class="wrap">
14
- <table class="form-table">
15
- <tbody>
16
- <tr valign="top">
17
- <th scope="row" colspan="2"><h3><?php _e('Resources', 'wp_statistics'); ?></h3></th>
18
- </tr>
19
-
20
- <tr valign="top">
21
- <th scope="row">
22
- <?php _e('Memory usage in PHP', 'wp_statistics'); ?>:
23
- </th>
24
-
25
- <td>
26
- <strong><?php echo number_format_i18n(memory_get_usage()); ?></strong> <?php _e('Byte', 'wp_statistics'); ?>
27
- <p class="description"><?php _e('Memory usage in PHP', 'wp_statistics'); ?></p>
28
- </td>
29
- </tr>
30
-
31
- <tr valign="top">
32
- <th scope="row">
33
- <?php _e('PHP Memory Limit', 'wp_statistics'); ?>:
34
- </th>
35
-
36
- <td>
37
- <strong><?php echo ini_get('memory_limit'); ?></strong>
38
- <p class="description"><?php _e('The memory limit a script is allowed to consume, set in php.ini.', 'wp_statistics'); ?></p>
39
- </td>
40
- </tr>
41
-
42
- <tr valign="top">
43
- <th scope="row">
44
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'useronline' . '</code>'); ?>:
45
- </th>
46
-
47
- <td>
48
- <strong><?php echo number_format_i18n($result['useronline']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
49
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
50
- </td>
51
- </tr>
52
-
53
- <tr valign="top">
54
- <th scope="row">
55
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'visit' . '</code>'); ?>:
56
- </th>
57
-
58
- <td>
59
- <strong><?php echo number_format_i18n($result['visit']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
60
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
61
- </td>
62
- </tr>
63
-
64
- <tr valign="top">
65
- <th scope="row">
66
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'visitor' . '</code>'); ?>:
67
- </th>
68
-
69
- <td>
70
- <strong><?php echo number_format_i18n($result['visitor']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
71
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
72
- </td>
73
- </tr>
74
-
75
- <tr valign="top">
76
- <th scope="row">
77
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'exclusions' . '</code>'); ?>:
78
- </th>
79
-
80
- <td>
81
- <strong><?php echo number_format_i18n($result['exclusions']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
82
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
83
- </td>
84
- </tr>
85
-
86
- <tr valign="top">
87
- <th scope="row">
88
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'pages' . '</code>'); ?>:
89
- </th>
90
-
91
- <td>
92
- <strong><?php echo number_format_i18n($result['pages']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
93
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
94
- </td>
95
- </tr>
96
-
97
- <tr valign="top">
98
- <th scope="row">
99
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'historical' . '</code>'); ?>:
100
- </th>
101
-
102
- <td>
103
- <strong><?php echo number_format_i18n($result['historical']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
104
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
105
- </td>
106
- </tr>
107
-
108
- <tr valign="top">
109
- <th scope="row">
110
- <?php echo sprintf(__('Number of rows in the %s table', 'wp_statistics'), '<code>' . $wpdb->prefix . 'statistics_' . 'search' . '</code>'); ?>:
111
- </th>
112
-
113
- <td>
114
- <strong><?php echo number_format_i18n($result['search']); ?></strong> <?php _e('Row', 'wp_statistics'); ?>
115
- <p class="description"><?php _e('Number of rows', 'wp_statistics'); ?></p>
116
- </td>
117
- </tr>
118
-
119
- <tr valign="top">
120
- <th scope="row" colspan="2"><h3><?php _e('Version Info', 'wp_statistics'); ?></h3></th>
121
- </tr>
122
-
123
- <tr valign="top">
124
- <th scope="row">
125
- <?php _e('WP Statistics Version', 'wp_statistics'); ?>:
126
- </th>
127
-
128
- <td>
129
- <strong><?php echo WP_STATISTICS_VERSION; ?></strong>
130
- <p class="description"><?php _e('The WP Statistics version you are running.', 'wp_statistics'); ?></p>
131
- </td>
132
- </tr>
133
-
134
- <tr valign="top">
135
- <th scope="row">
136
- <?php _e('PHP Version', 'wp_statistics'); ?>:
137
- </th>
138
-
139
- <td>
140
- <strong><?php echo phpversion(); ?></strong>
141
- <p class="description"><?php _e('The PHP version you are running.', 'wp_statistics'); ?></p>
142
- </td>
143
- </tr>
144
-
145
- <tr valign="top">
146
- <th scope="row">
147
- <?php _e('PHP Safe Mode', 'wp_statistics'); ?>:
148
- </th>
149
-
150
- <td>
151
- <strong><?php if( ini_get('safe_mode') ) { echo 'Yes'; } else { echo 'No'; } ?></strong>
152
- <p class="description"><?php _e('Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.', 'wp_statistics'); ?></p>
153
- </td>
154
- </tr>
155
-
156
- <tr valign="top">
157
- <th scope="row">
158
- <?php _e('PHP IPv6 Enabled', 'wp_statistics'); ?>:
159
- </th>
160
-
161
- <td>
162
- <strong><?php if( defined( 'AF_INET6' ) ) { echo 'Yes'; } else { echo 'No'; } ?></strong>
163
- <p class="description"><?php _e('Is PHP compiled with IPv6 support. You may see warning messages in your PHP log if it is not and you receive HTTP headers with IPv6 addresses in them.', 'wp_statistics'); ?></p>
164
- </td>
165
- </tr>
166
-
167
- <tr valign="top">
168
- <th scope="row">
169
- <?php _e('jQuery Version', 'wp_statistics'); ?>:
170
- </th>
171
-
172
- <td>
173
- <strong><script type="text/javascript">document.write(jQuery().jquery);</script></strong>
174
- <p class="description"><?php _e('The jQuery version you are running.', 'wp_statistics'); ?></p>
175
- </td>
176
- </tr>
177
-
178
- <tr valign="top">
179
- <th scope="row">
180
- <?php _e('cURL Version', 'wp_statistics'); ?>:
181
- </th>
182
-
183
- <td>
184
- <strong><?php if( function_exists('curl_version') ) { $curl_ver = curl_version(); echo $curl_ver['version']; } else { _e('cURL not installed', 'wp_statistics'); }?></strong>
185
- <p class="description"><?php _e('The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.', 'wp_statistics'); ?></p>
186
- </td>
187
- </tr>
188
-
189
- <tr valign="top">
190
- <th scope="row">
191
- <?php _e('Zlib gzopen()', 'wp_statistics'); ?>:
192
- </th>
193
-
194
- <td>
195
- <strong><?php if( function_exists('gzopen') ) { _e('Installed','wp_statistics'); } else { _e('Not installed', 'wp_statistics'); }?></strong>
196
- <p class="description"><?php _e('If the gzopen() function is installed. gzopen() is required for the GeoIP database to be downloaded successfully.', 'wp_statistics'); ?></p>
197
- </td>
198
- </tr>
199
-
200
- <tr valign="top">
201
- <th scope="row">
202
- <?php _e('GMP PHP extension', 'wp_statistics'); ?>:
203
- </th>
204
-
205
- <td>
206
- <strong><?php if( extension_loaded( 'gmp' ) ) { _e('Installed','wp_statistics'); } else { _e('Not installed', 'wp_statistics'); }?></strong>
207
- <p class="description"><?php _e('If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp_statistics'); ?></p>
208
- </td>
209
- </tr>
210
-
211
- <tr valign="top">
212
- <th scope="row">
213
- <?php _e('BCMath PHP extension', 'wp_statistics'); ?>:
214
- </th>
215
-
216
- <td>
217
- <strong><?php if( extension_loaded( 'bcmath' ) ) { _e('Installed','wp_statistics'); } else { _e('Not installed', 'wp_statistics'); }?></strong>
218
- <p class="description"><?php _e('If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp_statistics'); ?></p>
219
- </td>
220
- </tr>
221
-
222
- <tr valign="top">
223
- <th scope="row" colspan="2"><h3><?php _e('File Info', 'wp_statistics'); ?></h3></th>
224
- </tr>
225
-
226
- <tr valign="top">
227
- <th scope="row">
228
- <?php _e('GeoIP Database', 'wp_statistics'); ?>:
229
- </th>
230
-
231
- <td>
232
- <strong><?php $upload_dir = wp_upload_dir();
233
- $GeoIP_filename = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
234
- $GeoIP_filedate = @filemtime( $GeoIP_filename );
235
-
236
- if( $GeoIP_filedate === FALSE ) {
237
- _e('Database file does not exist.', 'wp_statistics');
238
  } else {
239
- echo formatSize( @filesize( $GeoIP_filename ) ) . __(', created on ', 'wp_statistics') . date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $GeoIP_filedate);
240
- }?></strong>
241
- <p class="description"><?php _e('The file size and date of the GeoIP database.', 'wp_statistics'); ?></p>
242
- </td>
243
- </tr>
244
-
245
- <tr valign="top">
246
- <th scope="row">
247
- <?php _e('browscap.ini File', 'wp_statistics'); ?>:
248
- </th>
249
-
250
- <td>
251
- <strong><?php
252
- $browscap_filename = $upload_dir['basedir'] . '/wp-statistics/browscap.ini';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  $browscap_filedate = @filemtime( $browscap_filename );
254
-
255
- if( $browscap_filedate === FALSE ) {
256
- _e('browscap.ini file does not exist.', 'wp_statistics');
257
  } else {
258
- echo formatSize( @filesize( $browscap_filename ) ) . __(', created on ', 'wp_statistics') . date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $browscap_filedate);
259
- }?></strong>
260
- <p class="description"><?php _e('The file size and date of the browscap.ini file.', 'wp_statistics'); ?></p>
261
- </td>
262
- </tr>
263
-
264
- <tr valign="top">
265
- <th scope="row">
266
- <?php _e('browscap Cache File', 'wp_statistics'); ?>:
267
- </th>
268
-
269
- <td>
270
- <strong><?php
271
- $browscap_filename = $upload_dir['basedir'] . '/wp-statistics/cache.php';
272
  $browscap_filedate = @filemtime( $browscap_filename );
273
-
274
- if( $browscap_filedate === FALSE ) {
275
- _e('browscap cache file does not exist.', 'wp_statistics');
276
  } else {
277
- echo formatSize( @filesize( $browscap_filename ) ) . __(', created on ', 'wp_statistics') . date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $browscap_filedate);
278
- }?></strong>
279
- <p class="description"><?php _e('The file size and date of the browscap cache file.', 'wp_statistics'); ?></p>
280
- </td>
281
- </tr>
282
-
283
- <tr valign="top">
284
- <th scope="row" colspan="2"><h3><?php _e('Client Info', 'wp_statistics'); ?></h3></th>
285
- </tr>
286
-
287
- <tr valign="top">
288
- <th scope="row">
289
- <?php _e('Client IP', 'wp_statistics'); ?>:
290
- </th>
291
-
292
- <td>
293
- <strong><?php echo $WP_Statistics->get_IP(); ?></strong>
294
- <p class="description"><?php _e('The client IP address.', 'wp_statistics'); ?></p>
295
- </td>
296
- </tr>
297
-
298
- <tr valign="top">
299
- <th scope="row">
300
- <?php _e('User Agent', 'wp_statistics'); ?>:
301
- </th>
302
-
303
- <td>
304
- <strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong>
305
- <p class="description"><?php _e('The client user agent string.', 'wp_statistics'); ?></p>
306
- </td>
307
- </tr>
308
-
309
- <tr valign="top">
310
- <th scope="row">
311
- <?php _e('Browser', 'wp_statistics'); ?>:
312
- </th>
313
-
314
- <td>
315
- <strong><?php $agent = $WP_Statistics->get_UserAgent();
316
  echo $agent['browser'];
317
  ?></strong>
318
- <p class="description"><?php _e('The detected client browser.', 'wp_statistics'); ?></p>
319
- </td>
320
- </tr>
321
-
322
- <tr valign="top">
323
- <th scope="row">
324
- <?php _e('Version', 'wp_statistics'); ?>:
325
- </th>
326
-
327
- <td>
328
- <strong><?php echo $agent['version'];?></strong>
329
- <p class="description"><?php _e('The detected client browser version.', 'wp_statistics'); ?></p>
330
- </td>
331
- </tr>
332
-
333
- <tr valign="top">
334
- <th scope="row">
335
- <?php _e('Platform', 'wp_statistics'); ?>:
336
- </th>
337
-
338
- <td>
339
- <strong><?php echo $agent['platform'];?></strong>
340
- <p class="description"><?php _e('The detected client platform.', 'wp_statistics'); ?></p>
341
- </td>
342
- </tr>
343
-
344
- </tbody>
345
- </table>
346
  </div>
1
+ <?php
2
+ /* format size of file
3
+ * @author Mike Zriel
4
+ * @date 7 March 2011
5
+ * @website www.zriel.com
6
+ */
7
+ function formatSize( $size ) {
8
+ $sizes = array( " Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB" );
9
+ if ( $size == 0 ) {
10
+ return ( 'n/a' );
11
+ } else {
12
+ return ( round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2 ) . $sizes[ $i ] );
13
  }
14
+ }
15
+
16
  ?>
17
  <div class="wrap">
18
+ <table class="form-table">
19
+ <tbody>
20
+ <tr valign="top">
21
+ <th scope="row" colspan="2"><h3><?php _e( 'Resources', 'wp_statistics' ); ?></h3></th>
22
+ </tr>
23
+
24
+ <tr valign="top">
25
+ <th scope="row">
26
+ <?php _e( 'Memory usage in PHP', 'wp_statistics' ); ?>:
27
+ </th>
28
+
29
+ <td>
30
+ <strong><?php echo number_format_i18n( memory_get_usage() ); ?></strong> <?php _e( 'Byte', 'wp_statistics' ); ?>
31
+ <p class="description"><?php _e( 'Memory usage in PHP', 'wp_statistics' ); ?></p>
32
+ </td>
33
+ </tr>
34
+
35
+ <tr valign="top">
36
+ <th scope="row">
37
+ <?php _e( 'PHP Memory Limit', 'wp_statistics' ); ?>:
38
+ </th>
39
+
40
+ <td>
41
+ <strong><?php echo ini_get( 'memory_limit' ); ?></strong>
42
+ <p class="description"><?php _e( 'The memory limit a script is allowed to consume, set in php.ini.', 'wp_statistics' ); ?></p>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr valign="top">
47
+ <th scope="row">
48
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'useronline' . '</code>' ); ?>
49
+ :
50
+ </th>
51
+
52
+ <td>
53
+ <strong><?php echo number_format_i18n( $result['useronline'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
54
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
55
+ </td>
56
+ </tr>
57
+
58
+ <tr valign="top">
59
+ <th scope="row">
60
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'visit' . '</code>' ); ?>
61
+ :
62
+ </th>
63
+
64
+ <td>
65
+ <strong><?php echo number_format_i18n( $result['visit'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
66
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
67
+ </td>
68
+ </tr>
69
+
70
+ <tr valign="top">
71
+ <th scope="row">
72
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'visitor' . '</code>' ); ?>
73
+ :
74
+ </th>
75
+
76
+ <td>
77
+ <strong><?php echo number_format_i18n( $result['visitor'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
78
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
79
+ </td>
80
+ </tr>
81
+
82
+ <tr valign="top">
83
+ <th scope="row">
84
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'exclusions' . '</code>' ); ?>
85
+ :
86
+ </th>
87
+
88
+ <td>
89
+ <strong><?php echo number_format_i18n( $result['exclusions'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
90
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
91
+ </td>
92
+ </tr>
93
+
94
+ <tr valign="top">
95
+ <th scope="row">
96
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'pages' . '</code>' ); ?>
97
+ :
98
+ </th>
99
+
100
+ <td>
101
+ <strong><?php echo number_format_i18n( $result['pages'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
102
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
103
+ </td>
104
+ </tr>
105
+
106
+ <tr valign="top">
107
+ <th scope="row">
108
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'historical' . '</code>' ); ?>
109
+ :
110
+ </th>
111
+
112
+ <td>
113
+ <strong><?php echo number_format_i18n( $result['historical'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
114
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
115
+ </td>
116
+ </tr>
117
+
118
+ <tr valign="top">
119
+ <th scope="row">
120
+ <?php echo sprintf( __( 'Number of rows in the %s table', 'wp_statistics' ), '<code>' . $wpdb->prefix . 'statistics_' . 'search' . '</code>' ); ?>
121
+ :
122
+ </th>
123
+
124
+ <td>
125
+ <strong><?php echo number_format_i18n( $result['search'] ); ?></strong> <?php _e( 'Row', 'wp_statistics' ); ?>
126
+ <p class="description"><?php _e( 'Number of rows', 'wp_statistics' ); ?></p>
127
+ </td>
128
+ </tr>
129
+
130
+ <tr valign="top">
131
+ <th scope="row" colspan="2"><h3><?php _e( 'Version Info', 'wp_statistics' ); ?></h3></th>
132
+ </tr>
133
+
134
+ <tr valign="top">
135
+ <th scope="row">
136
+ <?php _e( 'WP Statistics Version', 'wp_statistics' ); ?>:
137
+ </th>
138
+
139
+ <td>
140
+ <strong><?php echo WP_STATISTICS_VERSION; ?></strong>
141
+ <p class="description"><?php _e( 'The WP Statistics version you are running.', 'wp_statistics' ); ?></p>
142
+ </td>
143
+ </tr>
144
+
145
+ <tr valign="top">
146
+ <th scope="row">
147
+ <?php _e( 'PHP Version', 'wp_statistics' ); ?>:
148
+ </th>
149
+
150
+ <td>
151
+ <strong><?php echo phpversion(); ?></strong>
152
+ <p class="description"><?php _e( 'The PHP version you are running.', 'wp_statistics' ); ?></p>
153
+ </td>
154
+ </tr>
155
+
156
+ <tr valign="top">
157
+ <th scope="row">
158
+ <?php _e( 'PHP Safe Mode', 'wp_statistics' ); ?>:
159
+ </th>
160
+
161
+ <td>
162
+ <strong><?php if ( ini_get( 'safe_mode' ) ) {
163
+ echo 'Yes';
164
+ } else {
165
+ echo 'No';
166
+ } ?></strong>
167
+ <p class="description"><?php _e( 'Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.', 'wp_statistics' ); ?></p>
168
+ </td>
169
+ </tr>
170
+
171
+ <tr valign="top">
172
+ <th scope="row">
173
+ <?php _e( 'PHP IPv6 Enabled', 'wp_statistics' ); ?>:
174
+ </th>
175
+
176
+ <td>
177
+ <strong><?php if ( defined( 'AF_INET6' ) ) {
178
+ echo 'Yes';
179
+ } else {
180
+ echo 'No';
181
+ } ?></strong>
182
+ <p class="description"><?php _e( 'Is PHP compiled with IPv6 support. You may see warning messages in your PHP log if it is not and you receive HTTP headers with IPv6 addresses in them.', 'wp_statistics' ); ?></p>
183
+ </td>
184
+ </tr>
185
+
186
+ <tr valign="top">
187
+ <th scope="row">
188
+ <?php _e( 'jQuery Version', 'wp_statistics' ); ?>:
189
+ </th>
190
+
191
+ <td>
192
+ <strong>
193
+ <script type="text/javascript">document.write(jQuery().jquery);</script>
194
+ </strong>
195
+ <p class="description"><?php _e( 'The jQuery version you are running.', 'wp_statistics' ); ?></p>
196
+ </td>
197
+ </tr>
198
+
199
+ <tr valign="top">
200
+ <th scope="row">
201
+ <?php _e( 'cURL Version', 'wp_statistics' ); ?>:
202
+ </th>
203
+
204
+ <td>
205
+ <strong><?php if ( function_exists( 'curl_version' ) ) {
206
+ $curl_ver = curl_version();
207
+ echo $curl_ver['version'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  } else {
209
+ _e( 'cURL not installed', 'wp_statistics' );
210
+ } ?></strong>
211
+ <p class="description"><?php _e( 'The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.', 'wp_statistics' ); ?></p>
212
+ </td>
213
+ </tr>
214
+
215
+ <tr valign="top">
216
+ <th scope="row">
217
+ <?php _e( 'Zlib gzopen()', 'wp_statistics' ); ?>:
218
+ </th>
219
+
220
+ <td>
221
+ <strong><?php if ( function_exists( 'gzopen' ) ) {
222
+ _e( 'Installed', 'wp_statistics' );
223
+ } else {
224
+ _e( 'Not installed', 'wp_statistics' );
225
+ } ?></strong>
226
+ <p class="description"><?php _e( 'If the gzopen() function is installed. gzopen() is required for the GeoIP database to be downloaded successfully.', 'wp_statistics' ); ?></p>
227
+ </td>
228
+ </tr>
229
+
230
+ <tr valign="top">
231
+ <th scope="row">
232
+ <?php _e( 'GMP PHP extension', 'wp_statistics' ); ?>:
233
+ </th>
234
+
235
+ <td>
236
+ <strong><?php if ( extension_loaded( 'gmp' ) ) {
237
+ _e( 'Installed', 'wp_statistics' );
238
+ } else {
239
+ _e( 'Not installed', 'wp_statistics' );
240
+ } ?></strong>
241
+ <p class="description"><?php _e( 'If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp_statistics' ); ?></p>
242
+ </td>
243
+ </tr>
244
+
245
+ <tr valign="top">
246
+ <th scope="row">
247
+ <?php _e( 'BCMath PHP extension', 'wp_statistics' ); ?>:
248
+ </th>
249
+
250
+ <td>
251
+ <strong><?php if ( extension_loaded( 'bcmath' ) ) {
252
+ _e( 'Installed', 'wp_statistics' );
253
+ } else {
254
+ _e( 'Not installed', 'wp_statistics' );
255
+ } ?></strong>
256
+ <p class="description"><?php _e( 'If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp_statistics' ); ?></p>
257
+ </td>
258
+ </tr>
259
+
260
+ <tr valign="top">
261
+ <th scope="row" colspan="2"><h3><?php _e( 'File Info', 'wp_statistics' ); ?></h3></th>
262
+ </tr>
263
+
264
+ <tr valign="top">
265
+ <th scope="row">
266
+ <?php _e( 'GeoIP Database', 'wp_statistics' ); ?>:
267
+ </th>
268
+
269
+ <td>
270
+ <strong><?php $upload_dir = wp_upload_dir();
271
+ $GeoIP_filename = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
272
+ $GeoIP_filedate = @filemtime( $GeoIP_filename );
273
+
274
+ if ( $GeoIP_filedate === false ) {
275
+ _e( 'Database file does not exist.', 'wp_statistics' );
276
+ } else {
277
+ echo formatSize( @filesize( $GeoIP_filename ) ) . __( ', created on ', 'wp_statistics' ) . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $GeoIP_filedate );
278
+ } ?></strong>
279
+ <p class="description"><?php _e( 'The file size and date of the GeoIP database.', 'wp_statistics' ); ?></p>
280
+ </td>
281
+ </tr>
282
+
283
+ <tr valign="top">
284
+ <th scope="row">
285
+ <?php _e( 'browscap.ini File', 'wp_statistics' ); ?>:
286
+ </th>
287
+
288
+ <td>
289
+ <strong><?php
290
+ $browscap_filename = $upload_dir['basedir'] . '/wp-statistics/browscap.ini';
291
  $browscap_filedate = @filemtime( $browscap_filename );
292
+
293
+ if ( $browscap_filedate === false ) {
294
+ _e( 'browscap.ini file does not exist.', 'wp_statistics' );
295
  } else {
296
+ echo formatSize( @filesize( $browscap_filename ) ) . __( ', created on ', 'wp_statistics' ) . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $browscap_filedate );
297
+ } ?></strong>
298
+ <p class="description"><?php _e( 'The file size and date of the browscap.ini file.', 'wp_statistics' ); ?></p>
299
+ </td>
300
+ </tr>
301
+
302
+ <tr valign="top">
303
+ <th scope="row">
304
+ <?php _e( 'browscap Cache File', 'wp_statistics' ); ?>:
305
+ </th>
306
+
307
+ <td>
308
+ <strong><?php
309
+ $browscap_filename = $upload_dir['basedir'] . '/wp-statistics/cache.php';
310
  $browscap_filedate = @filemtime( $browscap_filename );
311
+
312
+ if ( $browscap_filedate === false ) {
313
+ _e( 'browscap cache file does not exist.', 'wp_statistics' );
314
  } else {
315
+ echo formatSize( @filesize( $browscap_filename ) ) . __( ', created on ', 'wp_statistics' ) . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $browscap_filedate );
316
+ } ?></strong>
317
+ <p class="description"><?php _e( 'The file size and date of the browscap cache file.', 'wp_statistics' ); ?></p>
318
+ </td>
319
+ </tr>
320
+
321
+ <tr valign="top">
322
+ <th scope="row" colspan="2"><h3><?php _e( 'Client Info', 'wp_statistics' ); ?></h3></th>
323
+ </tr>
324
+
325
+ <tr valign="top">
326
+ <th scope="row">
327
+ <?php _e( 'Client IP', 'wp_statistics' ); ?>:
328
+ </th>
329
+
330
+ <td>
331
+ <strong><?php echo $WP_Statistics->get_IP(); ?></strong>
332
+ <p class="description"><?php _e( 'The client IP address.', 'wp_statistics' ); ?></p>
333
+ </td>
334
+ </tr>
335
+
336
+ <tr valign="top">
337
+ <th scope="row">
338
+ <?php _e( 'User Agent', 'wp_statistics' ); ?>:
339
+ </th>
340
+
341
+ <td>
342
+ <strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong>
343
+ <p class="description"><?php _e( 'The client user agent string.', 'wp_statistics' ); ?></p>
344
+ </td>
345
+ </tr>
346
+
347
+ <tr valign="top">
348
+ <th scope="row">
349
+ <?php _e( 'Browser', 'wp_statistics' ); ?>:
350
+ </th>
351
+
352
+ <td>
353
+ <strong><?php $agent = $WP_Statistics->get_UserAgent();
354
  echo $agent['browser'];
355
  ?></strong>
356
+ <p class="description"><?php _e( 'The detected client browser.', 'wp_statistics' ); ?></p>
357
+ </td>
358
+ </tr>
359
+
360
+ <tr valign="top">
361
+ <th scope="row">
362
+ <?php _e( 'Version', 'wp_statistics' ); ?>:
363
+ </th>
364
+
365
+ <td>
366
+ <strong><?php echo $agent['version']; ?></strong>
367
+ <p class="description"><?php _e( 'The detected client browser version.', 'wp_statistics' ); ?></p>
368
+ </td>
369
+ </tr>
370
+
371
+ <tr valign="top">
372
+ <th scope="row">
373
+ <?php _e( 'Platform', 'wp_statistics' ); ?>:
374
+ </th>
375
+
376
+ <td>
377
+ <strong><?php echo $agent['platform']; ?></strong>
378
+ <p class="description"><?php _e( 'The detected client platform.', 'wp_statistics' ); ?></p>
379
+ </td>
380
+ </tr>
381
+
382
+ </tbody>
383
+ </table>
384
  </div>
includes/optimization/tabs/wps-optimization-updates.php CHANGED
@@ -1,47 +1,47 @@
1
  <script type="text/javascript">
2
- jQuery(document).ready(function() {
3
- jQuery("#hash-ips-submit").click(function(){
4
- var agree = confirm('<?php _e('This will replace all IP addresses in the database with hash values and cannot be undo, are you sure?', 'wp_statistics'); ?>');
5
-
6
- if(agree)
7
- location.href=document.URL+'&tab=updates&hash-ips=1';
8
-
9
- });
10
- });
11
  </script>
12
  <div class="wrap">
13
- <table class="form-table">
14
- <tbody>
15
- <tr valign="top">
16
- <th scope="row" colspan="2"><h3><?php _e('GeoIP Options', 'wp_statistics'); ?></h3></th>
17
- </tr>
18
-
19
- <tr valign="top">
20
- <th scope="row">
21
- <label for="populate-submit"><?php _e('Countries', 'wp_statistics'); ?>:</label>
22
- </th>
23
-
24
- <td>
25
- <input id="populate-submit" class="button button-primary" type="button" value="<?php _e('Update Now!', 'wp_statistics'); ?>" name="populate-submit" onclick="location.href=document.URL+'&tab=updates&populate=1'">
26
- <p class="description"><?php _e('Updates any unknown location data in the database, this may take a while', 'wp_statistics'); ?></p>
27
- </td>
28
- </tr>
29
-
30
- <tr valign="top">
31
- <th scope="row" colspan="2"><h3><?php _e('IP Addresses', 'wp_statistics'); ?></h3></th>
32
- </tr>
33
-
34
- <tr valign="top">
35
- <th scope="row">
36
- <label for="populate-submit"><?php _e('Hash IP Addresses', 'wp_statistics'); ?>:</label>
37
- </th>
38
-
39
- <td>
40
- <input id="hash-ips-submit" class="button button-primary" type="button" value="<?php _e('Update Now!', 'wp_statistics'); ?>" name="hash-ips-submit">
41
- <p class="description"><?php _e('Replace IP addresses in the database with hash values, you will not be able to recover the IP addresses in the future to populate location information afterwards and this may take a while', 'wp_statistics'); ?></p>
42
- </td>
43
- </tr>
44
-
45
- </tbody>
46
- </table>
47
  </div>
1
  <script type="text/javascript">
2
+ jQuery(document).ready(function () {
3
+ jQuery("#hash-ips-submit").click(function () {
4
+ var agree = confirm('<?php _e( 'This will replace all IP addresses in the database with hash values and cannot be undo, are you sure?', 'wp_statistics' ); ?>');
5
+
6
+ if (agree)
7
+ location.href = document.URL + '&tab=updates&hash-ips=1';
8
+
9
+ });
10
+ });
11
  </script>
12
  <div class="wrap">
13
+ <table class="form-table">
14
+ <tbody>
15
+ <tr valign="top">
16
+ <th scope="row" colspan="2"><h3><?php _e( 'GeoIP Options', 'wp_statistics' ); ?></h3></th>
17
+ </tr>
18
+
19
+ <tr valign="top">
20
+ <th scope="row">
21
+ <label for="populate-submit"><?php _e( 'Countries', 'wp_statistics' ); ?>:</label>
22
+ </th>
23
+
24
+ <td>
25
+ <input id="populate-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp_statistics' ); ?>" name="populate-submit" onclick="location.href=document.URL+'&tab=updates&populate=1'">
26
+ <p class="description"><?php _e( 'Updates any unknown location data in the database, this may take a while', 'wp_statistics' ); ?></p>
27
+ </td>
28
+ </tr>
29
+
30
+ <tr valign="top">
31
+ <th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp_statistics' ); ?></h3></th>
32
+ </tr>
33
+
34
+ <tr valign="top">
35
+ <th scope="row">
36
+ <label for="populate-submit"><?php _e( 'Hash IP Addresses', 'wp_statistics' ); ?>:</label>
37
+ </th>
38
+
39
+ <td>
40
+ <input id="hash-ips-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp_statistics' ); ?>" name="hash-ips-submit">
41
+ <p class="description"><?php _e( 'Replace IP addresses in the database with hash values, you will not be able to recover the IP addresses in the future to populate location information afterwards and this may take a while', 'wp_statistics' ); ?></p>
42
+ </td>
43
+ </tr>
44
+
45
+ </tbody>
46
+ </table>
47
  </div>
includes/optimization/wps-optimization.php CHANGED
@@ -1,207 +1,223 @@
1
  <?php
2
- GLOBAL $wpdb, $WP_Statistics;
3
- $wp_prefix = $wpdb->prefix;
4
-
5
- if( !is_super_admin() )
6
- wp_die(__('Access denied!', 'wp_statistics'));
7
-
8
- if( array_key_exists( 'populate', $_GET ) ) {
9
- if( intval($_GET['populate']) == 1 ) {
10
- require_once( plugin_dir_path( __FILE__ ) . '../functions/geoip-populate.php' );
11
- echo wp_statistics_populate_geoip_info();
12
- }
13
  }
14
-
15
- if( array_key_exists( 'hash-ips', $_GET ) ) {
16
- if( intval($_GET['hash-ips']) == 1 ) {
17
- // Generate a random salt
18
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
19
- $randomString = '';
20
- for ($i = 0; $i < 50; $i++) {
21
- $randomString .= $characters[rand(0, strlen($characters) - 1)];
22
- }
23
-
24
- // Get the rows from the Visitors table.
25
- $result = $wpdb->get_results( "SELECT DISTINCT ip FROM {$wp_prefix}statistics_visitor" );
26
-
27
- foreach( $result as $row ) {
28
-
29
- if( substr( $row->ip, 0, 6 ) != '#hash#' ) {
30
-
31
- $wpdb->update(
32
- $wp_prefix . "statistics_visitor",
33
- array(
34
- 'ip' => '#hash#' . sha1( $row->ip . $randomString ),
35
- ),
36
- array(
37
- 'ip' => $row->ip,
38
- )
39
- );
40
- }
41
  }
42
-
43
- echo "<div class='updated settings-error'><p><strong>" . __('IP Addresses replaced with hash values.', 'wp_statistics') . "</strong></p></div>";
44
  }
 
 
45
  }
 
46
 
47
- if( array_key_exists( 'install', $_GET ) ) {
48
- if( intval($_GET['install']) == 1 ) {
49
- $WPS_Installed = "1.0";
50
- include( plugin_dir_path( __FILE__ ) . "../../wps-install.php" );
51
- echo "<div class='updated settings-error'><p><strong>" . __('Install routine complete.', 'wp_statistics') . "</strong></p></div>";
52
- }
53
  }
54
-
55
- if( array_key_exists( 'index', $_GET ) ) {
56
- if( intval($_GET['index']) == 1 ) {
57
- // Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
58
- $result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'");
59
-
60
- if( $result != 5 ) {
61
- // We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
62
- $result = $wpdb->get_results( "SELECT ID, last_counter, ip FROM {$wp_prefix}statistics_visitor ORDER BY last_counter, ip" );
63
-
64
- // Setup the inital values.
65
- $lastrow = array( 'last_counter' => '', 'ip' => '' );
66
- $deleterows = array();
67
-
68
- // Ok, now iterate over the results.
69
- foreach( $result as $row ) {
70
- // if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
71
- if( $row->last_counter == $lastrow['last_counter'] && $row->ip == $lastrow['ip'] ) { $deleterows[] .= $row->ID;}
72
-
73
- // Update the lastrow data.
74
- $lastrow['last_counter'] = $row->last_counter;
75
- $lastrow['ip'] = $row->ip;
76
- }
77
-
78
- // Now do the acutal deletions.
79
- foreach( $deleterows as $row ) {
80
- $wpdb->delete( $wp_prefix . 'statistics_visitor', array( 'ID' => $row ) );
81
  }
82
-
83
- // The table should be ready to be updated now with the new index, so let's do it.
84
- $result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visitor' . " ADD UNIQUE `date_ip_agent` ( `last_counter`, `ip`, `agent` (75), `platform` (75), `version` (75) )" );
85
 
86
- // We might have an old index left over from 7.1-7.3 so lets make sure to delete it.
87
- $wpdb->query( "DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor" );
 
 
88
 
89
- // Record in the options that we've done this update.
90
- $dbupdates = $WP_Statistics->get_option('pending_db_updates');
91
- $dbupdates['date_ip_agent'] = false;
92
- $WP_Statistics->update_option('pending_db_updates', $dbupdates);
93
  }
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
  }
 
96
 
97
- if( array_key_exists( 'visits', $_GET ) ) {
98
- if( intval($_GET['visits']) == 1 ) {
99
- // Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
100
- $result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'");
101
-
102
- // Note, the result will be the number of fields contained in the index, so in our case 1.
103
- if( $result != 1 ) {
104
- // We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
105
- $result = $wpdb->get_results( "SELECT ID, last_counter, visit FROM {$wp_prefix}statistics_visit ORDER BY last_counter, visit DESC" );
106
-
107
- // Setup the initial values.
108
- $lastrow = array( 'last_counter' => '', 'visit' => 0, 'id' => 0 );
109
- $deleterows = array();
110
-
111
- // Ok, now iterate over the results.
112
- foreach( $result as $row ) {
113
- // if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
114
- if( $row->last_counter == $lastrow['last_counter'] ) { $deleterows[] .= $row->ID; }
115
-
116
- // Update the lastrow data.
117
- $lastrow['last_counter'] = $row->last_counter;
118
- $lastrow['id'] = $row->ID;
119
- $lastrow['visit'] = $row->visit;
120
- }
121
-
122
- // Now do the acutal deletions.
123
- foreach( $deleterows as $row ) {
124
- $wpdb->delete( $wp_prefix . 'statistics_visit', array( 'ID' => $row ) );
125
  }
126
-
127
- // The table should be ready to be updated now with the new index, so let's do it.
128
- $result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visit' . " ADD UNIQUE `unique_date` ( `last_counter` )" );
129
-
130
- // Record in the options that we've done this update.
131
- $dbupdates = $WP_Statistics->get_option('pending_db_updates');
132
- $dbupdates['unique_date'] = false;
133
- $WP_Statistics->update_option('pending_db_updates', $dbupdates);
134
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
  }
 
137
 
138
- if( array_key_exists( 'historical-submit', $_POST ) ) {
139
 
140
- if( array_key_exists( 'wps_historical_visitors', $_POST ) ) {
141
- $result = $wpdb->update( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visitors'] ), array( 'category' => 'visitors' ) );
142
 
143
- if( $result == 0 ) {
144
- $result = $wpdb->insert( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visitors'], 'category' => 'visitors', 'page_id' => -1, 'uri' => '-1' ) );
145
- }
146
- }
147
-
148
- if( array_key_exists( 'wps_historical_visits', $_POST ) ) {
149
- $result = $wpdb->update( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visits'] ), array( 'category' => 'visits' ) );
150
-
151
- if( $result == 0 ) {
152
- $result = $wpdb->insert( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visits'], 'category' => 'visits', 'page_id' => -2, 'uri' => '-2' ) );
153
- }
154
  }
 
 
 
 
155
 
 
 
 
 
 
 
 
156
  }
157
-
158
- if( array_key_exists( 'search', $_GET ) ) {
159
-
160
- // Make sure we get all the search engines, even the ones the disabled ones.
161
- $se_list = wp_statistics_searchengine_list();
162
- $total = 0;
163
- $limitsize = 10000;
164
-
165
- foreach( $se_list as $key => $se ) {
166
-
167
- $sql = wp_statistics_searchengine_query( $key );
168
- $rowcount = $wpdb->get_var( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}" );
169
- $offset = 0;
170
-
171
- while( $rowcount > 0 ) {
172
-
173
- $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}" );
174
-
175
- foreach( $result as $row ) {
176
- $parts = parse_url( $row->referred );
177
-
178
- $data['last_counter'] = $row->last_counter;
179
- $data['engine'] = $key;
180
- $data['host'] = $parts['host'];
181
- $data['words'] = $WP_Statistics->Search_Engine_QueryString( $row->referred );
182
- $data['visitor'] = $row->ID;
183
-
184
- if( $data['words'] == 'No search query found!' ) { $data['words'] = ''; }
185
-
186
- $wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
187
- $total++;
188
  }
189
-
190
- $rowcount -= $limitsize;
191
- $offset += $limitsize;
192
  }
 
 
 
193
  }
 
194
 
195
- $WP_Statistics->update_option('search_converted', 1);
196
- echo "<div class='updated settings-error'><p><strong>" . sprintf( __('Search table conversion complete, %d rows added.', 'wp_statistics'), $total ) . "</strong></p></div>";
197
 
198
- }
199
 
200
  $selected_tab = "";
201
- if( array_key_exists( 'tab', $_GET ) ) { $selected_tab = $_GET['tab']; }
 
 
202
 
203
- switch( $selected_tab )
204
- {
205
  case 'export':
206
  $current_tab = 1;
207
  break;
@@ -220,48 +236,62 @@ switch( $selected_tab )
220
  default:
221
  $current_tab = 0;
222
 
223
- }
224
  ?>
225
  <script type="text/javascript">
226
- jQuery(document).ready(function() {
227
- jQuery("#tabs").tabs();
228
- <?php if( $current_tab != 0 ) { echo 'jQuery("#tabs").tabs("option", "active",' . $current_tab. ');' . "\n"; }?>
229
- } );
 
 
230
  </script>
231
  <div class="wrap">
232
- <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
233
- <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
234
- <li class="ui-state-default ui-corner-top"><a href="#resources" class="ui-tabs-anchor"><span><?php _e('Resources/Information', 'wp_statistics'); ?></span></a></li>
235
- <li class="ui-state-default ui-corner-top"><a href="#export" class="ui-tabs-anchor"><span><?php _e('Export', 'wp_statistics'); ?></span></a></li>
236
- <li class="ui-state-default ui-corner-top"><a href="#purging" class="ui-tabs-anchor"><span><?php _e('Purging', 'wp_statistics'); ?></span></a></li>
237
- <li class="ui-state-default ui-corner-top"><a href="#database" class="ui-tabs-anchor"><span><?php _e('Database', 'wp_statistics'); ?></span></a></li>
238
- <li class="ui-state-default ui-corner-top"><a href="#updates" class="ui-tabs-anchor"><span><?php _e('Updates', 'wp_statistics'); ?></span></a></li>
239
- <li class="ui-state-default ui-corner-top"><a href="#historical" class="ui-tabs-anchor"><span><?php _e('Historical', 'wp_statistics'); ?></span></a></li>
240
- </ul>
241
-
242
- <div id="resources">
243
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-resources.php' ); ?>
244
- </div>
245
-
246
- <div id="export">
247
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-export.php' ); ?>
248
- </div>
249
-
250
- <div id="purging">
251
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-purging.php' ); ?>
252
- </div>
253
-
254
- <div id="database">
255
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-database.php' ); ?>
256
- </div>
257
-
258
- <div id="updates">
259
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-updates.php' ); ?>
260
- </div>
261
-
262
- <div id="historical">
263
- <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-historical.php' ); ?>
264
- </div>
265
-
266
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
267
  </div>
1
  <?php
2
+ GLOBAL $wpdb, $WP_Statistics;
3
+ $wp_prefix = $wpdb->prefix;
4
+
5
+ if ( ! is_super_admin() ) {
6
+ wp_die( __( 'Access denied!', 'wp_statistics' ) );
7
+ }
8
+
9
+ if ( array_key_exists( 'populate', $_GET ) ) {
10
+ if ( intval( $_GET['populate'] ) == 1 ) {
11
+ require_once( plugin_dir_path( __FILE__ ) . '../functions/geoip-populate.php' );
12
+ echo wp_statistics_populate_geoip_info();
13
  }
14
+ }
15
+
16
+ if ( array_key_exists( 'hash-ips', $_GET ) ) {
17
+ if ( intval( $_GET['hash-ips'] ) == 1 ) {
18
+ // Generate a random salt
19
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
20
+ $randomString = '';
21
+ for ( $i = 0; $i < 50; $i ++ ) {
22
+ $randomString .= $characters[ rand( 0, strlen( $characters ) - 1 ) ];
23
+ }
24
+
25
+ // Get the rows from the Visitors table.
26
+ $result = $wpdb->get_results( "SELECT DISTINCT ip FROM {$wp_prefix}statistics_visitor" );
27
+
28
+ foreach ( $result as $row ) {
29
+
30
+ if ( substr( $row->ip, 0, 6 ) != '#hash#' ) {
31
+
32
+ $wpdb->update(
33
+ $wp_prefix . "statistics_visitor",
34
+ array(
35
+ 'ip' => '#hash#' . sha1( $row->ip . $randomString ),
36
+ ),
37
+ array(
38
+ 'ip' => $row->ip,
39
+ )
40
+ );
41
  }
 
 
42
  }
43
+
44
+ echo "<div class='updated settings-error'><p><strong>" . __( 'IP Addresses replaced with hash values.', 'wp_statistics' ) . "</strong></p></div>";
45
  }
46
+ }
47
 
48
+ if ( array_key_exists( 'install', $_GET ) ) {
49
+ if ( intval( $_GET['install'] ) == 1 ) {
50
+ $WPS_Installed = "1.0";
51
+ include( plugin_dir_path( __FILE__ ) . "../../wps-install.php" );
52
+ echo "<div class='updated settings-error'><p><strong>" . __( 'Install routine complete.', 'wp_statistics' ) . "</strong></p></div>";
 
53
  }
54
+ }
55
+
56
+ if ( array_key_exists( 'index', $_GET ) ) {
57
+ if ( intval( $_GET['index'] ) == 1 ) {
58
+ // Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
59
+ $result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'" );
60
+
61
+ if ( $result != 5 ) {
62
+ // We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
63
+ $result = $wpdb->get_results( "SELECT ID, last_counter, ip FROM {$wp_prefix}statistics_visitor ORDER BY last_counter, ip" );
64
+
65
+ // Setup the inital values.
66
+ $lastrow = array( 'last_counter' => '', 'ip' => '' );
67
+ $deleterows = array();
68
+
69
+ // Ok, now iterate over the results.
70
+ foreach ( $result as $row ) {
71
+ // if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
72
+ if ( $row->last_counter == $lastrow['last_counter'] && $row->ip == $lastrow['ip'] ) {
73
+ $deleterows[] .= $row->ID;
 
 
 
 
 
 
 
74
  }
 
 
 
75
 
76
+ // Update the lastrow data.
77
+ $lastrow['last_counter'] = $row->last_counter;
78
+ $lastrow['ip'] = $row->ip;
79
+ }
80
 
81
+ // Now do the acutal deletions.
82
+ foreach ( $deleterows as $row ) {
83
+ $wpdb->delete( $wp_prefix . 'statistics_visitor', array( 'ID' => $row ) );
 
84
  }
85
+
86
+ // The table should be ready to be updated now with the new index, so let's do it.
87
+ $result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visitor' . " ADD UNIQUE `date_ip_agent` ( `last_counter`, `ip`, `agent` (75), `platform` (75), `version` (75) )" );
88
+
89
+ // We might have an old index left over from 7.1-7.3 so lets make sure to delete it.
90
+ $wpdb->query( "DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor" );
91
+
92
+ // Record in the options that we've done this update.
93
+ $dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
94
+ $dbupdates['date_ip_agent'] = false;
95
+ $WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
96
  }
97
  }
98
+ }
99
 
100
+ if ( array_key_exists( 'visits', $_GET ) ) {
101
+ if ( intval( $_GET['visits'] ) == 1 ) {
102
+ // Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
103
+ $result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
104
+
105
+ // Note, the result will be the number of fields contained in the index, so in our case 1.
106
+ if ( $result != 1 ) {
107
+ // We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
108
+ $result = $wpdb->get_results( "SELECT ID, last_counter, visit FROM {$wp_prefix}statistics_visit ORDER BY last_counter, visit DESC" );
109
+
110
+ // Setup the initial values.
111
+ $lastrow = array( 'last_counter' => '', 'visit' => 0, 'id' => 0 );
112
+ $deleterows = array();
113
+
114
+ // Ok, now iterate over the results.
115
+ foreach ( $result as $row ) {
116
+ // if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
117
+ if ( $row->last_counter == $lastrow['last_counter'] ) {
118
+ $deleterows[] .= $row->ID;
 
 
 
 
 
 
 
 
 
119
  }
120
+
121
+ // Update the lastrow data.
122
+ $lastrow['last_counter'] = $row->last_counter;
123
+ $lastrow['id'] = $row->ID;
124
+ $lastrow['visit'] = $row->visit;
 
 
 
125
  }
126
+
127
+ // Now do the acutal deletions.
128
+ foreach ( $deleterows as $row ) {
129
+ $wpdb->delete( $wp_prefix . 'statistics_visit', array( 'ID' => $row ) );
130
+ }
131
+
132
+ // The table should be ready to be updated now with the new index, so let's do it.
133
+ $result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visit' . " ADD UNIQUE `unique_date` ( `last_counter` )" );
134
+
135
+ // Record in the options that we've done this update.
136
+ $dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
137
+ $dbupdates['unique_date'] = false;
138
+ $WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
139
  }
140
  }
141
+ }
142
 
143
+ if ( array_key_exists( 'historical-submit', $_POST ) ) {
144
 
145
+ if ( array_key_exists( 'wps_historical_visitors', $_POST ) ) {
146
+ $result = $wpdb->update( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visitors'] ), array( 'category' => 'visitors' ) );
147
 
148
+ if ( $result == 0 ) {
149
+ $result = $wpdb->insert( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visitors'],
150
+ 'category' => 'visitors',
151
+ 'page_id' => - 1,
152
+ 'uri' => '-1'
153
+ ) );
 
 
 
 
 
154
  }
155
+ }
156
+
157
+ if ( array_key_exists( 'wps_historical_visits', $_POST ) ) {
158
+ $result = $wpdb->update( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visits'] ), array( 'category' => 'visits' ) );
159
 
160
+ if ( $result == 0 ) {
161
+ $result = $wpdb->insert( $wp_prefix . "statistics_historical", array( 'value' => $_POST['wps_historical_visits'],
162
+ 'category' => 'visits',
163
+ 'page_id' => - 2,
164
+ 'uri' => '-2'
165
+ ) );
166
+ }
167
  }
168
+
169
+ }
170
+
171
+ if ( array_key_exists( 'search', $_GET ) ) {
172
+
173
+ // Make sure we get all the search engines, even the ones the disabled ones.
174
+ $se_list = wp_statistics_searchengine_list();
175
+ $total = 0;
176
+ $limitsize = 10000;
177
+
178
+ foreach ( $se_list as $key => $se ) {
179
+
180
+ $sql = wp_statistics_searchengine_query( $key );
181
+ $rowcount = $wpdb->get_var( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}" );
182
+ $offset = 0;
183
+
184
+ while ( $rowcount > 0 ) {
185
+
186
+ $result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}" );
187
+
188
+ foreach ( $result as $row ) {
189
+ $parts = parse_url( $row->referred );
190
+
191
+ $data['last_counter'] = $row->last_counter;
192
+ $data['engine'] = $key;
193
+ $data['host'] = $parts['host'];
194
+ $data['words'] = $WP_Statistics->Search_Engine_QueryString( $row->referred );
195
+ $data['visitor'] = $row->ID;
196
+
197
+ if ( $data['words'] == 'No search query found!' ) {
198
+ $data['words'] = '';
199
  }
200
+
201
+ $wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
202
+ $total ++;
203
  }
204
+
205
+ $rowcount -= $limitsize;
206
+ $offset += $limitsize;
207
  }
208
+ }
209
 
210
+ $WP_Statistics->update_option( 'search_converted', 1 );
211
+ echo "<div class='updated settings-error'><p><strong>" . sprintf( __( 'Search table conversion complete, %d rows added.', 'wp_statistics' ), $total ) . "</strong></p></div>";
212
 
213
+ }
214
 
215
  $selected_tab = "";
216
+ if ( array_key_exists( 'tab', $_GET ) ) {
217
+ $selected_tab = $_GET['tab'];
218
+ }
219
 
220
+ switch ( $selected_tab ) {
 
221
  case 'export':
222
  $current_tab = 1;
223
  break;
236
  default:
237
  $current_tab = 0;
238
 
239
+ }
240
  ?>
241
  <script type="text/javascript">
242
+ jQuery(document).ready(function () {
243
+ jQuery("#tabs").tabs();
244
+ <?php if ( $current_tab != 0 ) {
245
+ echo 'jQuery("#tabs").tabs("option", "active",' . $current_tab . ');' . "\n";
246
+ }?>
247
+ });
248
  </script>
249
  <div class="wrap">
250
+ <h2><?php _e( 'Optimization', 'wp_statistics' ); ?></h2>
251
+ <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
252
+ <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
253
+ <li class="ui-state-default ui-corner-top">
254
+ <a href="#resources" class="ui-tabs-anchor"><span><?php _e( 'Resources/Information', 'wp_statistics' ); ?></span></a>
255
+ </li>
256
+ <li class="ui-state-default ui-corner-top">
257
+ <a href="#export" class="ui-tabs-anchor"><span><?php _e( 'Export', 'wp_statistics' ); ?></span></a></li>
258
+ <li class="ui-state-default ui-corner-top">
259
+ <a href="#purging" class="ui-tabs-anchor"><span><?php _e( 'Purging', 'wp_statistics' ); ?></span></a>
260
+ </li>
261
+ <li class="ui-state-default ui-corner-top">
262
+ <a href="#database" class="ui-tabs-anchor"><span><?php _e( 'Database', 'wp_statistics' ); ?></span></a>
263
+ </li>
264
+ <li class="ui-state-default ui-corner-top">
265
+ <a href="#updates" class="ui-tabs-anchor"><span><?php _e( 'Updates', 'wp_statistics' ); ?></span></a>
266
+ </li>
267
+ <li class="ui-state-default ui-corner-top">
268
+ <a href="#historical" class="ui-tabs-anchor"><span><?php _e( 'Historical', 'wp_statistics' ); ?></span></a>
269
+ </li>
270
+ </ul>
271
+
272
+ <div id="resources">
273
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-resources.php' ); ?>
274
+ </div>
275
+
276
+ <div id="export">
277
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-export.php' ); ?>
278
+ </div>
279
+
280
+ <div id="purging">
281
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-purging.php' ); ?>
282
+ </div>
283
+
284
+ <div id="database">
285
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-database.php' ); ?>
286
+ </div>
287
+
288
+ <div id="updates">
289
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-updates.php' ); ?>
290
+ </div>
291
+
292
+ <div id="historical">
293
+ <?php include( dirname( __FILE__ ) . '/tabs/wps-optimization-historical.php' ); ?>
294
+ </div>
295
+
296
+ </div>
297
  </div>
includes/settings/tabs/wps-about.php CHANGED
@@ -1,88 +1,94 @@
1
  <table class="form-table">
2
- <tbody>
3
- <tr valign="top">
4
- <td scope="row" align="center"><img src="<?php echo plugins_url('wp-statistics/assets/images/logo-250.png'); ?>"></td>
5
- </tr>
6
-
7
- <tr valign="top">
8
- <td scope="row" align="center"><h2><?php echo sprintf(__('WP Statistics V%s', 'wp_statistics'), WP_STATISTICS_VERSION); ?></h2></td>
9
- </tr>
10
-
11
- <tr valign="top">
12
- <td scope="row" align="center"><?php echo sprintf(__('This product includes GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics'), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>'); ?></td>
13
- </tr>
14
-
15
- <tr valign="top">
16
- <td scope="row" align="center"><hr /></td>
17
- </tr>
18
-
19
- <tr valign="top">
20
- <td scope="row" colspan="2"><h2><?php _e('Donate', 'wp_statistics'); ?></h2></td>
21
- </tr>
22
-
23
- <tr valign="top">
24
- <td scope="row" colspan="2"><?php echo sprintf( __('Fell like showing us how much you enjoy WP Statistics? Drop by our %s page and show us some love!', 'wp_statistics'), '<a href="http://wp-statistics.com/donate" target="_blank">' . __('donation', 'wp_statistics') . '</a>');?></td>
25
- </tr>
26
-
27
- <tr valign="top">
28
- <td scope="row" colspan="2"><h2><?php _e('Visit Us Online', 'wp_statistics'); ?></h2></td>
29
- </tr>
30
-
31
- <tr valign="top">
32
- <td scope="row" colspan="2"><?php echo sprintf( __('Come visit our great new %s and keep up to date on the latest news about WP Statistics.', 'wp_statistics'), '<a href="http://wp-statistics.com" target="_blank">' . __('website', 'wp_statistics') . '</a>');?></td>
33
- </tr>
34
-
35
- <tr valign="top">
36
- <td scope="row" colspan="2"><h2><?php _e('Rate and Review at WordPress.org', 'wp_statistics'); ?></h2></td>
37
- </tr>
38
-
39
- <tr valign="top">
40
- <td scope="row" colspan="2"><?php _e('Thanks for installing WP Statistics, we encourage you to submit a ', 'wp_statistics');?> <a href="http://wordpress.org/support/view/plugin-reviews/wp-statistics" target="_blank"><?php _e('rating and review', 'wp_statistics'); ?></a> <?php _e('over at WordPress.org. Your feedback is greatly appreciated!','wp_statistics');?></td>
41
- </tr>
42
-
43
- <tr valign="top">
44
- <td scope="row" colspan="2"><h2><?php _e('Translations', 'wp_statistics'); ?></h2></td>
45
- </tr>
46
-
47
- <tr valign="top">
48
- <td scope="row" colspan="2"><?php echo sprintf( __('WP Statistics supports internationalization and we encourage our users to submit translations, please visit our %s to see the current status and %s if you would like to help.', 'wp_statistics'), '<a href="http://wp-statistics.com/translations/" target="_blank">' . __('translation collaboration site', 'wp_statistics') . '</a>', '<a href="http://wp-statistics.com/contact/" target="_blank">' . __( 'drop us a line', 'wp_statistics') . '</a>');?></td>
49
- </tr>
50
-
51
- <tr valign="top">
52
- <td scope="row" colspan="2"><h2><?php _e('Support', 'wp_statistics'); ?></h2></td>
53
- </tr>
54
-
55
- <tr valign="top">
56
- <td scope="row" colspan="2">
57
- <p><?php _e("We're sorry you're having problem with WP Statistics and we're happy to help out. Here are a few things to do before contacting us:", 'wp_statistics'); ?></p>
58
-
59
- <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
60
- <li><?php echo sprintf( __('Have you read the %s?', 'wp_statistics' ), '<a title="' . __('FAQs', 'wp_statistics') . '" href="http://wp-statistics.com/?page_id=19" target="_blank">' . __('FAQs', 'wp_statistics'). '</a>');?></li>
61
- <li><?php echo sprintf( __('Have you read the %s?', 'wp_statistics' ), '<a title="' . __('manual', 'wp_statistics') . '" href="?page=' . WP_STATISTICS_MANUAL_PAGE . '">' . __('manual', 'wp_statistics') . '</a>');?></li>
62
- <li><?php echo sprintf( __('Have you search the %s for a similar issue?', 'wp_statistics' ), '<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">' . __('support forum', 'wp_statistics') . '</a>');?></li>
63
- <li><?php _e('Have you search the Internet for any error messages you are receiving?', 'wp_statistics' );?></li>
64
- <li><?php _e('Make sure you have access to your PHP error logs.', 'wp_statistics' );?></li>
65
- </ul>
66
-
67
- <p><?php _e('And a few things to double-check:', 'wp_statistics' );?></p>
68
-
69
- <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
70
- <li><?php _e('How\'s your memory_limit in php.ini?', 'wp_statistics' );?></li>
71
- <li><?php _e('Have you tried disabling any other plugins you may have installed?', 'wp_statistics' );?></li>
72
- <li><?php _e('Have you tried using the default WordPress theme?', 'wp_statistics' );?></li>
73
- <li><?php _e('Have you double checked the plugin settings?', 'wp_statistics' );?></li>
74
- <li><?php _e('Do you have all the required PHP extensions installed?', 'wp_statistics' );?></li>
75
- <li><?php _e('Are you getting a blank or incomplete page displayed in your browser? Did you view the source for the page and check for any fatal errors?', 'wp_statistics' );?></li>
76
- <li><?php _e('Have you checked your PHP and web server error logs?', 'wp_statistics' );?></li>
77
- </ul>
78
-
79
- <p><?php _e('Still not having any luck?', 'wp_statistics' );?> <?php echo sprintf(__('Then please open a new thread on the %s and we\'ll respond as soon as possible.', 'wp_statistics' ), '<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">' . __('WordPress.org support forum', 'wp_statistics') . '</a>');?></p>
80
-
81
- <p><br /></p>
82
-
83
- <p><?php echo sprintf( __('Alternatively %s support is available as well.', 'wp_statistics' ), '<a href="http://forum.wp-parsi.com/forum/17-%D9%85%D8%B4%DA%A9%D9%84%D8%A7%D8%AA-%D8%AF%DB%8C%DA%AF%D8%B1/" target="_blank">' . __('Farsi', 'wp_statistics' ) .'</a>');?></p>
84
- </td>
85
- </tr>
86
-
87
- </tbody>
 
 
 
 
 
 
88
  </table>
1
  <table class="form-table">
2
+ <tbody>
3
+ <tr valign="top">
4
+ <td scope="row" align="center">
5
+ <img src="<?php echo plugins_url( 'wp-statistics/assets/images/logo-250.png' ); ?>"></td>
6
+ </tr>
7
+
8
+ <tr valign="top">
9
+ <td scope="row" align="center">
10
+ <h2><?php echo sprintf( __( 'WP Statistics V%s', 'wp_statistics' ), WP_STATISTICS_VERSION ); ?></h2></td>
11
+ </tr>
12
+
13
+ <tr valign="top">
14
+ <td scope="row" align="center"><?php echo sprintf( __( 'This product includes GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics' ), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>' ); ?></td>
15
+ </tr>
16
+
17
+ <tr valign="top">
18
+ <td scope="row" align="center">
19
+ <hr/>
20
+ </td>
21
+ </tr>
22
+
23
+ <tr valign="top">
24
+ <td scope="row" colspan="2"><h2><?php _e( 'Donate', 'wp_statistics' ); ?></h2></td>
25
+ </tr>
26
+
27
+ <tr valign="top">
28
+ <td scope="row" colspan="2"><?php echo sprintf( __( 'Fell like showing us how much you enjoy WP Statistics? Drop by our %s page and show us some love!', 'wp_statistics' ), '<a href="http://wp-statistics.com/donate" target="_blank">' . __( 'donation', 'wp_statistics' ) . '</a>' ); ?></td>
29
+ </tr>
30
+
31
+ <tr valign="top">
32
+ <td scope="row" colspan="2"><h2><?php _e( 'Visit Us Online', 'wp_statistics' ); ?></h2></td>
33
+ </tr>
34
+
35
+ <tr valign="top">
36
+ <td scope="row" colspan="2"><?php echo sprintf( __( 'Come visit our great new %s and keep up to date on the latest news about WP Statistics.', 'wp_statistics' ), '<a href="http://wp-statistics.com" target="_blank">' . __( 'website', 'wp_statistics' ) . '</a>' ); ?></td>
37
+ </tr>
38
+
39
+ <tr valign="top">
40
+ <td scope="row" colspan="2"><h2><?php _e( 'Rate and Review at WordPress.org', 'wp_statistics' ); ?></h2></td>
41
+ </tr>
42
+
43
+ <tr valign="top">
44
+ <td scope="row" colspan="2"><?php _e( 'Thanks for installing WP Statistics, we encourage you to submit a ', 'wp_statistics' ); ?>
45
+ <a href="http://wordpress.org/support/view/plugin-reviews/wp-statistics" target="_blank"><?php _e( 'rating and review', 'wp_statistics' ); ?></a> <?php _e( 'over at WordPress.org. Your feedback is greatly appreciated!', 'wp_statistics' ); ?>
46
+ </td>
47
+ </tr>
48
+
49
+ <tr valign="top">
50
+ <td scope="row" colspan="2"><h2><?php _e( 'Translations', 'wp_statistics' ); ?></h2></td>
51
+ </tr>
52
+
53
+ <tr valign="top">
54
+ <td scope="row" colspan="2"><?php echo sprintf( __( 'WP Statistics supports internationalization. please visit %s to see the current status and help to translation.', 'wp_statistics' ), '<a href="https://translate.wordpress.org/projects/wp-plugins/wp-statistics" target="_blank">' . __( 'WP Statistics Translating page', 'wp_statistics' ) . '</a>' ); ?></td>
55
+ </tr>
56
+
57
+ <tr valign="top">
58
+ <td scope="row" colspan="2"><h2><?php _e( 'Support', 'wp_statistics' ); ?></h2></td>
59
+ </tr>
60
+
61
+ <tr valign="top">
62
+ <td scope="row" colspan="2">
63
+ <p><?php _e( "We're sorry you're having problem with WP Statistics and we're happy to help out. Here are a few things to do before contacting us:", 'wp_statistics' ); ?></p>
64
+
65
+ <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
66
+ <li><?php echo sprintf( __( 'Have you read the %s?', 'wp_statistics' ), '<a title="' . __( 'FAQs', 'wp_statistics' ) . '" href="http://wp-statistics.com/category/faq/" target="_blank">' . __( 'FAQs', 'wp_statistics' ) . '</a>' ); ?></li>
67
+ <li><?php echo sprintf( __( 'Have you read the %s?', 'wp_statistics' ), '<a title="' . __( 'Documentation', 'wp_statistics' ) . '" href="http://wp-statistics.com/category/documentation/">' . __( 'documentation', 'wp_statistics' ) . '</a>' ); ?></li>
68
+ <li><?php echo sprintf( __( 'Have you search the %s for a similar issue?', 'wp_statistics' ), '<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">' . __( 'support forum', 'wp_statistics' ) . '</a>' ); ?></li>
69
+ <li><?php _e( 'Have you search the Internet for any error messages you are receiving?', 'wp_statistics' ); ?></li>
70
+ <li><?php _e( 'Make sure you have access to your PHP error logs.', 'wp_statistics' ); ?></li>
71
+ </ul>
72
+
73
+ <p><?php _e( 'And a few things to double-check:', 'wp_statistics' ); ?></p>
74
+
75
+ <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
76
+ <li><?php _e( 'How\'s your memory_limit in php.ini?', 'wp_statistics' ); ?></li>
77
+ <li><?php _e( 'Have you tried disabling any other plugins you may have installed?', 'wp_statistics' ); ?></li>
78
+ <li><?php _e( 'Have you tried using the default WordPress theme?', 'wp_statistics' ); ?></li>
79
+ <li><?php _e( 'Have you double checked the plugin settings?', 'wp_statistics' ); ?></li>
80
+ <li><?php _e( 'Do you have all the required PHP extensions installed?', 'wp_statistics' ); ?></li>
81
+ <li><?php _e( 'Are you getting a blank or incomplete page displayed in your browser? Did you view the source for the page and check for any fatal errors?', 'wp_statistics' ); ?></li>
82
+ <li><?php _e( 'Have you checked your PHP and web server error logs?', 'wp_statistics' ); ?></li>
83
+ </ul>
84
+
85
+ <p><?php _e( 'Still not having any luck?', 'wp_statistics' ); ?><?php echo sprintf( __( 'Then please open a new thread on the %s and we\'ll respond as soon as possible.', 'wp_statistics' ), '<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">' . __( 'WordPress.org support forum', 'wp_statistics' ) . '</a>' ); ?></p>
86
+
87
+ <p><br/></p>
88
+
89
+ <p><?php echo sprintf( __( 'Alternatively %s support is available as well.', 'wp_statistics' ), '<a href="http://forum.wp-parsi.com/forum/17-%D9%85%D8%B4%DA%A9%D9%84%D8%A7%D8%AA-%D8%AF%DB%8C%DA%AF%D8%B1/" target="_blank">' . __( 'Farsi', 'wp_statistics' ) . '</a>' ); ?></p>
90
+ </td>
91
+ </tr>
92
+
93
+ </tbody>
94
  </table>
includes/settings/tabs/wps-access-level.php CHANGED
@@ -1,85 +1,101 @@
1
- <?php
2
  global $wp_roles;
3
 
4
  $role_list = $wp_roles->get_names();
5
 
6
- if( $wps_nonce_valid ) {
7
 
8
- $wps_option_list = array_merge( $wps_option_list, array('wps_read_capability','wps_manage_capability' ) );
9
-
10
- foreach( $wps_option_list as $option ) {
11
  $new_option = str_replace( "wps_", "", $option );
12
 
13
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
14
- $WP_Statistics->store_option($new_option, $value);
 
 
 
 
15
  }
16
  }
17
 
18
  ?>
19
 
20
- <table class="form-table">
21
- <tbody>
22
- <tr valign="top">
23
- <th scope="row" colspan="2"><h3><?php _e('Access Levels', 'wp_statistics'); ?></h3></th>
24
- </tr>
25
  <?php
26
- global $wp_roles;
27
-
28
- $role_list = $wp_roles->get_names();
29
-
30
- foreach( $wp_roles->roles as $role ) {
31
-
32
- $cap_list = $role['capabilities'];
33
-
34
- foreach( $cap_list as $key => $cap ) {
35
- if( substr($key,0,6) != 'level_' ) {
36
- $all_caps[$key] = 1;
37
- }
38
  }
39
  }
40
-
41
- ksort( $all_caps );
42
-
43
- $read_cap = $WP_Statistics->get_option('read_capability','manage_options');
44
- $option_list = '';
45
-
46
- foreach( $all_caps as $key => $cap ) {
47
- if( $key == $read_cap ) { $selected = " SELECTED"; } else { $selected = ""; }
48
- $option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
 
 
 
49
  }
 
 
50
  ?>
51
- <tr valign="top">
52
- <th scope="row"><label for="wps_read_capability"><?php _e('Required user level to view WP Statistics', 'wp_statistics')?>:</label></th>
53
- <td>
54
- <select id="wps_read_capability" name="wps_read_capability"><?php echo $option_list;?></select>
55
- </td>
56
- </tr>
 
 
57
 
58
  <?php
59
- $manage_cap = $WP_Statistics->get_option('manage_capability','manage_options');
60
-
61
- foreach( $all_caps as $key => $cap ) {
62
- if( $key == $manage_cap ) { $selected = " SELECTED"; } else { $selected = ""; }
63
- $option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
 
 
64
  }
 
 
65
  ?>
66
- <tr valign="top">
67
- <th scope="row"><label for="wps_manage_capability"><?php _e('Required user level to manage WP Statistics', 'wp_statistics')?>:</label></th>
68
- <td>
69
- <select id="wps_manage_capability" name="wps_manage_capability"><?php echo $option_list;?></select>
70
- </td>
71
- </tr>
72
-
73
- <tr valign="top">
74
- <th scope="row" colspan="2">
75
- <p class="description"><?php echo sprintf(__('See the %s for details on capability levels.', 'wp_statistics'), '<a target=_blank href="http://codex.wordpress.org/Roles_and_Capabilities">' . __('WordPress Roles and Capabilities page', 'wp_statistics') . '</a>'); ?></p>
76
- <p class="description"><?php echo __('Hint: manage_network = Super Admin Network, manage_options = Administrator, edit_others_posts = Editor, publish_posts = Author, edit_posts = Contributor, read = Everyone.', 'wp_statistics'); ?></p>
77
- <p class="description"><?php echo __('Each of the above casscades the rights upwards in the default WordPress configuration. So for example selecting publish_posts grants the right to Authors, Editors, Admins and Super Admins.', 'wp_statistics'); ?></p>
78
- <p class="description"><?php echo sprintf(__('If you need a more robust solution to delegate access you might want to look at %s in the WordPress plugin directory.', 'wp_statistics'), '<a href="http://wordpress.org/plugins/capability-manager-enhanced/" target=_blank>Capability Manager Enhanced</a>'); ?></p>
79
- </th>
80
- </tr>
81
-
82
- </tbody>
83
- </table>
84
-
85
- <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>
 
 
1
+ <?php
2
  global $wp_roles;
3
 
4
  $role_list = $wp_roles->get_names();
5
 
6
+ if ( $wps_nonce_valid ) {
7
 
8
+ $wps_option_list = array_merge( $wps_option_list, array( 'wps_read_capability', 'wps_manage_capability' ) );
9
+
10
+ foreach ( $wps_option_list as $option ) {
11
  $new_option = str_replace( "wps_", "", $option );
12
 
13
+ if ( array_key_exists( $option, $_POST ) ) {
14
+ $value = $_POST[ $option ];
15
+ } else {
16
+ $value = '';
17
+ }
18
+ $WP_Statistics->store_option( $new_option, $value );
19
  }
20
  }
21
 
22
  ?>
23
 
24
+ <table class="form-table">
25
+ <tbody>
26
+ <tr valign="top">
27
+ <th scope="row" colspan="2"><h3><?php _e( 'Access Levels', 'wp_statistics' ); ?></h3></th>
28
+ </tr>
29
  <?php
30
+ global $wp_roles;
31
+
32
+ $role_list = $wp_roles->get_names();
33
+
34
+ foreach ( $wp_roles->roles as $role ) {
35
+
36
+ $cap_list = $role['capabilities'];
37
+
38
+ foreach ( $cap_list as $key => $cap ) {
39
+ if ( substr( $key, 0, 6 ) != 'level_' ) {
40
+ $all_caps[ $key ] = 1;
 
41
  }
42
  }
43
+ }
44
+
45
+ ksort( $all_caps );
46
+
47
+ $read_cap = $WP_Statistics->get_option( 'read_capability', 'manage_options' );
48
+ $option_list = '';
49
+
50
+ foreach ( $all_caps as $key => $cap ) {
51
+ if ( $key == $read_cap ) {
52
+ $selected = " SELECTED";
53
+ } else {
54
+ $selected = "";
55
  }
56
+ $option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
57
+ }
58
  ?>
59
+ <tr valign="top">
60
+ <th scope="row">
61
+ <label for="wps_read_capability"><?php _e( 'Required user level to view WP Statistics', 'wp_statistics' ) ?>
62
+ :</label></th>
63
+ <td>
64
+ <select id="wps_read_capability" name="wps_read_capability"><?php echo $option_list; ?></select>
65
+ </td>
66
+ </tr>
67
 
68
  <?php
69
+ $manage_cap = $WP_Statistics->get_option( 'manage_capability', 'manage_options' );
70
+
71
+ foreach ( $all_caps as $key => $cap ) {
72
+ if ( $key == $manage_cap ) {
73
+ $selected = " SELECTED";
74
+ } else {
75
+ $selected = "";
76
  }
77
+ $option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
78
+ }
79
  ?>
80
+ <tr valign="top">
81
+ <th scope="row">
82
+ <label for="wps_manage_capability"><?php _e( 'Required user level to manage WP Statistics', 'wp_statistics' ) ?>
83
+ :</label></th>
84
+ <td>
85
+ <select id="wps_manage_capability" name="wps_manage_capability"><?php echo $option_list; ?></select>
86
+ </td>
87
+ </tr>
88
+
89
+ <tr valign="top">
90
+ <th scope="row" colspan="2">
91
+ <p class="description"><?php echo sprintf( __( 'See the %s for details on capability levels.', 'wp_statistics' ), '<a target=_blank href="http://codex.wordpress.org/Roles_and_Capabilities">' . __( 'WordPress Roles and Capabilities page', 'wp_statistics' ) . '</a>' ); ?></p>
92
+ <p class="description"><?php echo __( 'Hint: manage_network = Super Admin Network, manage_options = Administrator, edit_others_posts = Editor, publish_posts = Author, edit_posts = Contributor, read = Everyone.', 'wp_statistics' ); ?></p>
93
+ <p class="description"><?php echo __( 'Each of the above casscades the rights upwards in the default WordPress configuration. So for example selecting publish_posts grants the right to Authors, Editors, Admins and Super Admins.', 'wp_statistics' ); ?></p>
94
+ <p class="description"><?php echo sprintf( __( 'If you need a more robust solution to delegate access you might want to look at %s in the WordPress plugin directory.', 'wp_statistics' ), '<a href="http://wordpress.org/plugins/capability-manager-enhanced/" target=_blank>Capability Manager Enhanced</a>' ); ?></p>
95
+ </th>
96
+ </tr>
97
+
98
+ </tbody>
99
+ </table>
100
+
101
+ <?php submit_button( __( 'Update', 'wp_statistics' ), 'primary', 'submit' ); ?>
includes/settings/tabs/wps-exclusions.php CHANGED
@@ -3,242 +3,276 @@ global $wp_roles;
3
 
4
  $role_list = $wp_roles->get_names();
5
 
6
- if( $wps_nonce_valid ) {
7
 
8
- foreach( $role_list as $role ) {
9
- $role_post = 'wps_exclude_' . str_replace(" ", "_", strtolower($role) );
10
 
11
- if( array_key_exists( $role_post, $_POST ) ) { $value = $_POST[$role_post]; } else { $value = ''; }
 
 
 
 
12
 
13
  $new_option = str_replace( "wps_", "", $role_post );
14
- $WP_Statistics->store_option($new_option, $value);
15
 
16
  }
17
 
18
- if( array_key_exists( 'wps_create_honeypot', $_POST ) ) {
19
  $my_post = array(
20
- 'post_type' => 'page',
21
- 'post_title' => __('WP Statistics Honey Pot Page', 'wp_statistics' ) . ' [' . $WP_Statistics->Current_Date() . ']',
22
- 'post_content' => __('This is the honey pot for WP Statistics to use, do not delete.', 'wp_statistics' ),
23
- 'post_status' => 'publish',
24
- 'post_author' => 1,
25
  );
26
 
27
  $_POST['wps_honeypot_postid'] = wp_insert_post( $my_post );
28
  }
29
 
30
- $wps_option_list = array_merge( $wps_option_list, array('wps_record_exclusions','wps_robotlist','wps_exclude_ip','wps_exclude_loginpage','wps_exclude_adminpage','wps_force_robot_update','wps_excluded_countries','wps_included_countries','wps_excluded_hosts','wps_robot_threshold','wps_use_honeypot','wps_honeypot_postid','wps_exclude_feeds','wps_excluded_urls','wps_exclude_404s', 'wps_corrupt_browser_info', 'wps_exclude_ajax' ) );
31
-
32
- foreach( $wps_option_list as $option ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  $new_option = str_replace( "wps_", "", $option );
34
 
35
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
36
- $WP_Statistics->store_option($new_option, $value);
 
 
 
 
37
  }
38
  }
39
 
40
  ?>
41
 
42
- <table class="form-table">
43
- <tbody>
44
-
45
- <tr valign="top">
46
- <th scope="row" colspan="2"><h3><?php _e('Exclusions', 'wp_statistics'); ?></h3></th>
47
- </tr>
48
-
49
- <tr valign="top">
50
- <th scope="row"><label for="wps-exclusions"><?php _e('Record exclusions', 'wp_statistics'); ?></label>:</th>
51
- <td>
52
- <input id="wps-exclusions" type="checkbox" value="1" name="wps_record_exclusions" <?php echo $WP_Statistics->get_option('record_exclusions')==true? "checked='checked'":'';?>><label for="wps-exclusions"><?php _e('Enable', 'wp_statistics'); ?></label>
53
- <p class="description"><?php _e('This will record all the excluded hits in a separate table with the reasons why it was excluded but no other information. This will generate a lot of data but is useful if you want to see the total number of hits your site gets, not just actual user visits.', 'wp_statistics'); ?></p>
54
- </td>
55
- </tr>
56
-
57
- <tr valign="top">
58
- <th scope="row" colspan="2"><h3><?php _e('Exclude User Roles', 'wp_statistics'); ?></h3></th>
59
- </tr>
 
60
  <?php
61
- $role_option_list = '';
62
-
63
- foreach( $role_list as $role ) {
64
- $store_name = 'exclude_' . str_replace(" ", "_", strtolower($role) );
65
- $option_name = 'wps_' . $store_name;
66
- $role_option_list .= $option_name . ',';
67
-
68
- $translated_role_name = translate_user_role($role);
69
- ?>
70
-
71
- <tr valign="top">
72
- <th scope="row"><label for="<?php echo $option_name;?>"><?php echo $translated_role_name; ?>:</label></th>
73
- <td>
74
- <input id="<?php echo $option_name;?>" type="checkbox" value="1" name="<?php echo $option_name;?>" <?php echo $WP_Statistics->get_option($store_name)==true? "checked='checked'":'';?>><label for="<?php echo $option_name;?>"><?php _e('Exclude', 'wp_statistics'); ?></label>
75
- <p class="description"><?php echo sprintf(__('Exclude %s role from data collection.', 'wp_statistics'), $translated_role_name); ?></p>
76
- </td>
77
- </tr>
 
78
  <?php } ?>
79
 
80
- <tr valign="top">
81
- <th scope="row" colspan="2"><h3><?php _e('IP/Robot Exclusions', 'wp_statistics'); ?></h3></th>
82
- </tr>
83
 
84
- <tr valign="top">
85
- <th scope="row"><?php _e('Robot list', 'wp_statistics'); ?>:</th>
86
- <td>
87
  <textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php
88
- $robotlist = $WP_Statistics->get_option('robotlist');
89
 
90
- include_once(dirname( __FILE__ ) . '/../../../robotslist.php');
91
 
92
- if( $robotlist == '' ) {
93
  $robotlist = implode( "\n", $wps_robotarray );
94
  update_option( 'wps_robotlist', $robotlist );
95
  }
96
 
97
- echo htmlentities( $robotlist, ENT_QUOTES );?></textarea>
98
- <p class="description"><?php echo __('A list of words (one per line) to match against to detect robots. Entries must be at least 4 characters long or they will be ignored.', 'wp_statistics'); ?></p>
99
- <a onclick="var wps_robotlist = getElementById('wps_robotlist'); wps_robotlist.value = '<?php echo implode('\n', $wps_robotarray);?>';" class="button"><?php _e('Reset to Default', 'wp_statistics');?></a>
100
- </td>
101
- </tr>
102
-
103
- <tr valign="top">
104
- <th scope="row"><label for="force_robot_update"><?php _e('Force robot list update after upgrades', 'wp_statistics'); ?>:</label></th>
105
- <td>
106
- <input id="force_robot_update" type="checkbox" value="1" name="wps_force_robot_update" <?php echo $WP_Statistics->get_option('force_robot_update')==true? "checked='checked'":'';?>><label for="force_robot_update"><?php _e('Enable', 'wp_statistics'); ?></label>
107
- <p class="description"><?php echo sprintf(__('Force the robot list to be reset to the default after an update to WP Statistics takes place. Note if this option is enabled any custom robots you have added to the list will be lost.', 'wp_statistics'), $role); ?></p>
108
- </td>
109
- </tr>
110
-
111
- <tr valign="top">
112
- <th scope="row"><label for="wps_robot_threshold"><?php _e('Robot visit threshold', 'wp_statistics'); ?>:</label></th>
113
- <td>
114
- <input id="wps_robot_threshold" type="text" size="5" name="wps_robot_threshold" value="<?php echo $WP_Statistics->get_option('robot_threshold');?>">
115
- <p class="description"><?php echo __('Treat visitors with more than this number of visits per day as robots. 0 = disabled.', 'wp_statistics'); ?></p>
116
- </td>
117
- </tr>
118
-
119
- <tr valign="top">
120
- <th scope="row"><?php _e('Excluded IP address list', 'wp_statistics'); ?>:</th>
121
- <td>
122
- <textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('exclude_ip'), ENT_QUOTES );?></textarea>
123
- <p class="description"><?php echo __('A list of IP addresses and subnet masks (one per line) to exclude from statistics collection.', 'wp_statistics'); ?></p>
124
- <p class="description"><?php echo __('For IPv4 addresses, both 192.168.0.0/24 and 192.168.0.0/255.255.255.0 formats are accepted. To specify an IP address only, use a subnet value of 32 or 255.255.255.255.', 'wp_statistics'); ?></p>
125
- <p class="description"><?php echo __('For IPv6 addresses use the fc00::/7 format.', 'wp_statistics'); ?></p>
126
- <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n10.0.0.0/8' ); }" class="button"><?php _e('Add 10.0.0.0', 'wp_statistics');?></a>
127
- <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n172.16.0.0/12' ); }" class="button"><?php _e('Add 172.16.0.0', 'wp_statistics');?></a>
128
- <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n192.168.0.0/16' ); }" class="button"><?php _e('Add 192.168.0.0', 'wp_statistics');?></a>
129
- <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\nfc00::/7' ); }" class="button"><?php _e('Add fc00::/7', 'wp_statistics');?></a>
130
- </td>
131
- </tr>
132
-
133
- <tr valign="top">
134
- <th scope="row"><?php _e('Use honey pot', 'wp_statistics'); ?>:</th>
135
- <td>
136
- <input id="use_honeypot" type="checkbox" value="1" name="wps_use_honeypot" <?php echo $WP_Statistics->get_option('use_honeypot')==true? "checked='checked'":'';?>><label for="wps_use_honeypot"><?php _e('Enable', 'wp_statistics'); ?></label>
137
- <p class="description"><?php echo __('Use a honey pot page to identify robots.', 'wp_statistics'); ?></p>
138
- </td>
139
- </tr>
140
-
141
- <tr valign="top">
142
- <th scope="row"><label for="honeypot_postid"><?php _e('Honey pot post id', 'wp_statistics'); ?>:</label></th>
143
- <td>
144
- <input id="honeypot_postid" type="text" value="<?php echo htmlentities( $WP_Statistics->get_option('honeypot_postid'), ENT_QUOTES );?>" size="5" name="wps_honeypot_postid">
145
- <p class="description"><?php echo __('The post id to use for the honeypot page.', 'wp_statistics'); ?></p>
146
- <input id="wps_create_honeypot" type="checkbox" value="1" name="wps_create_honeypot"><label for="wps_create_honeypot"><?php _e('Create a new honey pot page', 'wp_statistics'); ?></label>
147
- </td>
148
- </tr>
149
-
150
- <tr valign="top">
151
- <th scope="row"><label for="corrupt_browser_info"><?php _e('Treat corrupt browser info as a bot', 'wp_statistics'); ?>:</label></th>
152
- <td>
153
- <input id="corrupt_browser_info" type="checkbox" value="1" name="wps_corrupt_browser_info" <?php echo $WP_Statistics->get_option('corrupt_browser_info')==true? "checked='checked'":'';?>><label for="wps_corrupt_browser_info"><?php _e('Enable', 'wp_statistics'); ?></label>
154
- <p class="description"><?php echo __('Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.', 'wp_statistics'); ?></p>
155
- </td>
156
- </tr>
157
-
158
- <tr valign="top">
159
- <th scope="row" colspan="2"><h3><?php _e('GeoIP Exclusions', 'wp_statistics'); ?></h3></th>
160
- </tr>
161
-
162
- <tr valign="top">
163
- <th scope="row"><?php _e('Excluded countries list', 'wp_statistics'); ?>:</th>
164
- <td>
165
- <textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_countries'), ENT_QUOTES );?></textarea>
166
- <p class="description"><?php echo __('A list of country codes (one per line, two letters each) to exclude from statistics collection. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics'); ?></p>
167
- </td>
168
- </tr>
169
-
170
- <tr valign="top">
171
- <th scope="row"><?php _e('Included countries list', 'wp_statistics'); ?>:</th>
172
- <td>
173
- <textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('included_countries'), ENT_QUOTES );?></textarea>
174
- <p class="description"><?php echo __('A list of country codes (one per line, two letters each) to include in statistics collection, if this list is not empty, only visitors from the included countries will be recorded. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics'); ?></p>
175
- </td>
176
- </tr>
177
-
178
- <tr valign="top">
179
- <th scope="row" colspan="2"><h3><?php _e('Host Exclusions', 'wp_statistics'); ?></h3></th>
180
- </tr>
181
-
182
- <tr valign="top">
183
- <th scope="row"><?php _e('Excluded hosts list', 'wp_statistics'); ?>:</th>
184
- <td>
185
- <textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_hosts'), ENT_QUOTES );?></textarea>
186
- <p class="description"><?php echo __('A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.', 'wp_statistics'); ?></p>
187
- <br>
188
- <p class="description"><?php echo __('Note: this option will NOT perform a reverse DNS lookup on each page load but instead cache the IP address for the provided hostnames for one hour. If you are excluding dynamically assigned hosts you may find some degree of overlap when the host changes it\'s IP address and when the cache is updated resulting in some hits recorded.', 'wp_statistics'); ?></p>
189
- </td>
190
- </tr>
191
-
192
- <tr valign="top">
193
- <th scope="row" colspan="2"><h3><?php _e('Site URL Exclusions', 'wp_statistics'); ?></h3></th>
194
- </tr>
195
-
196
- <tr valign="top">
197
- <th scope="row"><?php _e('Excluded login page', 'wp_statistics'); ?>:</th>
198
- <td>
199
- <input id="wps-exclude-loginpage" type="checkbox" value="1" name="wps_exclude_loginpage" <?php echo $WP_Statistics->get_option('exclude_loginpage')==true? "checked='checked'":'';?>><label for="wps-exclude-loginpage"><?php _e('Exclude', 'wp_statistics'); ?></label>
200
- <p class="description"><?php _e('Exclude the login page for registering as a hit.', 'wp_statistics'); ?></p>
201
- </td>
202
- </tr>
203
- <tr valign="top">
204
- <th scope="row"><?php _e('Excluded admin pages', 'wp_statistics'); ?>:</th>
205
- <td>
206
- <input id="wps-exclude-adminpage" type="checkbox" value="1" name="wps_exclude_adminpage" <?php echo $WP_Statistics->get_option('exclude_adminpage')==true? "checked='checked'":'';?>><label for="wps-exclude-adminpage"><?php _e('Exclude', 'wp_statistics'); ?></label>
207
- <p class="description"><?php _e('Exclude the admin pages for registering as a hit.', 'wp_statistics'); ?></p>
208
- </td>
209
- </tr>
210
- <tr valign="top">
211
- <th scope="row"><?php _e('Excluded RSS feeds', 'wp_statistics'); ?>:</th>
212
- <td>
213
- <input id="wps-exclude-feeds" type="checkbox" value="1" name="wps_exclude_feeds" <?php echo $WP_Statistics->get_option('exclude_feeds')==true? "checked='checked'":'';?>><label for="wps-exclude-feeds"><?php _e('Exclude', 'wp_statistics'); ?></label>
214
- <p class="description"><?php _e('Exclude the RSS feeds for registering as a hit.', 'wp_statistics'); ?></p>
215
- </td>
216
- </tr>
217
- <tr valign="top">
218
- <th scope="row"><?php _e('Excluded 404 pages', 'wp_statistics'); ?>:</th>
219
- <td>
220
- <input id="wps-exclude-404s" type="checkbox" value="1" name="wps_exclude_404s" <?php echo $WP_Statistics->get_option('exclude_404s')==true? "checked='checked'":'';?>><label for="wps-exclude-404s"><?php _e('Exclude', 'wp_statistics'); ?></label>
221
- <p class="description"><?php _e('Exclude any URL that returns a "404 - Not Found" message.', 'wp_statistics'); ?></p>
222
- </td>
223
- </tr>
224
- <tr valign="top">
225
- <th scope="row"><?php _e('Excluded AJAX calls', 'wp_statistics'); ?>:</th>
226
- <td>
227
- <input id="wps-exclude-ajax" type="checkbox" value="1" name="wps_exclude_ajax" <?php echo $WP_Statistics->get_option('exclude_ajax')==true? "checked='checked'":'';?>><label for="wps-exclude-ajax"><?php _e('Exclude', 'wp_statistics'); ?></label>
228
- <p class="description"><?php _e('Exclude any call to the WordPress AJAX system.', 'wp_statistics'); ?></p>
229
- </td>
230
- </tr>
231
- <tr valign="top">
232
- <th scope="row"><?php _e('Excluded URLs list', 'wp_statistics'); ?>:</th>
233
- <td>
234
- <textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_urls'), ENT_QUOTES );?></textarea>
235
- <p class="description"><?php echo __('A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.', 'wp_statistics'); ?></p>
236
- <br>
237
- <p class="description"><?php echo __('Note: this option will NOT handle url parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.', 'wp_statistics'); ?></p>
238
- </td>
239
- </tr>
240
-
241
- </tbody>
242
- </table>
243
-
244
- <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>
 
 
 
 
 
 
3
 
4
  $role_list = $wp_roles->get_names();
5
 
6
+ if ( $wps_nonce_valid ) {
7
 
8
+ foreach ( $role_list as $role ) {
9
+ $role_post = 'wps_exclude_' . str_replace( " ", "_", strtolower( $role ) );
10
 
11
+ if ( array_key_exists( $role_post, $_POST ) ) {
12
+ $value = $_POST[ $role_post ];
13
+ } else {
14
+ $value = '';
15
+ }
16
 
17
  $new_option = str_replace( "wps_", "", $role_post );
18
+ $WP_Statistics->store_option( $new_option, $value );
19
 
20
  }
21
 
22
+ if ( array_key_exists( 'wps_create_honeypot', $_POST ) ) {
23
  $my_post = array(
24
+ 'post_type' => 'page',
25
+ 'post_title' => __( 'WP Statistics Honey Pot Page', 'wp_statistics' ) . ' [' . $WP_Statistics->Current_Date() . ']',
26
+ 'post_content' => __( 'This is the honey pot for WP Statistics to use, do not delete.', 'wp_statistics' ),
27
+ 'post_status' => 'publish',
28
+ 'post_author' => 1,
29
  );
30
 
31
  $_POST['wps_honeypot_postid'] = wp_insert_post( $my_post );
32
  }
33
 
34
+ $wps_option_list = array_merge( $wps_option_list, array(
35
+ 'wps_record_exclusions',
36
+ 'wps_robotlist',
37
+ 'wps_exclude_ip',
38
+ 'wps_exclude_loginpage',
39
+ 'wps_exclude_adminpage',
40
+ 'wps_force_robot_update',
41
+ 'wps_excluded_countries',
42
+ 'wps_included_countries',
43
+ 'wps_excluded_hosts',
44
+ 'wps_robot_threshold',
45
+ 'wps_use_honeypot',
46
+ 'wps_honeypot_postid',
47
+ 'wps_exclude_feeds',
48
+ 'wps_excluded_urls',
49
+ 'wps_exclude_404s',
50
+ 'wps_corrupt_browser_info',
51
+ 'wps_exclude_ajax'
52
+ ) );
53
+
54
+ foreach ( $wps_option_list as $option ) {
55
  $new_option = str_replace( "wps_", "", $option );
56
 
57
+ if ( array_key_exists( $option, $_POST ) ) {
58
+ $value = $_POST[ $option ];
59
+ } else {
60
+ $value = '';
61
+ }
62
+ $WP_Statistics->store_option( $new_option, $value );
63
  }
64
  }
65
 
66
  ?>
67
 
68
+ <table class="form-table">
69
+ <tbody>
70
+
71
+ <tr valign="top">
72
+ <th scope="row" colspan="2"><h3><?php _e( 'Exclusions', 'wp_statistics' ); ?></h3></th>
73
+ </tr>
74
+
75
+ <tr valign="top">
76
+ <th scope="row"><label for="wps-exclusions"><?php _e( 'Record exclusions', 'wp_statistics' ); ?></label>:
77
+ </th>
78
+ <td>
79
+ <input id="wps-exclusions" type="checkbox" value="1" name="wps_record_exclusions" <?php echo $WP_Statistics->get_option( 'record_exclusions' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclusions"><?php _e( 'Enable', 'wp_statistics' ); ?></label>
80
+ <p class="description"><?php _e( 'This will record all the excluded hits in a separate table with the reasons why it was excluded but no other information. This will generate a lot of data but is useful if you want to see the total number of hits your site gets, not just actual user visits.', 'wp_statistics' ); ?></p>
81
+ </td>
82
+ </tr>
83
+
84
+ <tr valign="top">
85
+ <th scope="row" colspan="2"><h3><?php _e( 'Exclude User Roles', 'wp_statistics' ); ?></h3></th>
86
+ </tr>
87
  <?php
88
+ $role_option_list = '';
89
+
90
+ foreach ( $role_list as $role ) {
91
+ $store_name = 'exclude_' . str_replace( " ", "_", strtolower( $role ) );
92
+ $option_name = 'wps_' . $store_name;
93
+ $role_option_list .= $option_name . ',';
94
+
95
+ $translated_role_name = translate_user_role( $role );
96
+ ?>
97
+
98
+ <tr valign="top">
99
+ <th scope="row"><label for="<?php echo $option_name; ?>"><?php echo $translated_role_name; ?>:</label>
100
+ </th>
101
+ <td>
102
+ <input id="<?php echo $option_name; ?>" type="checkbox" value="1" name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true ? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
103
+ <p class="description"><?php echo sprintf( __( 'Exclude %s role from data collection.', 'wp_statistics' ), $translated_role_name ); ?></p>
104
+ </td>
105
+ </tr>
106
  <?php } ?>
107
 
108
+ <tr valign="top">
109
+ <th scope="row" colspan="2"><h3><?php _e( 'IP/Robot Exclusions', 'wp_statistics' ); ?></h3></th>
110
+ </tr>
111
 
112
+ <tr valign="top">
113
+ <th scope="row"><?php _e( 'Robot list', 'wp_statistics' ); ?>:</th>
114
+ <td>
115
  <textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php
116
+ $robotlist = $WP_Statistics->get_option( 'robotlist' );
117
 
118
+ include_once( dirname( __FILE__ ) . '/../../../robotslist.php' );
119
 
120
+ if ( $robotlist == '' ) {
121
  $robotlist = implode( "\n", $wps_robotarray );
122
  update_option( 'wps_robotlist', $robotlist );
123
  }
124
 
125
+ echo htmlentities( $robotlist, ENT_QUOTES ); ?></textarea>
126
+ <p class="description"><?php echo __( 'A list of words (one per line) to match against to detect robots. Entries must be at least 4 characters long or they will be ignored.', 'wp_statistics' ); ?></p>
127
+ <a onclick="var wps_robotlist = getElementById('wps_robotlist'); wps_robotlist.value = '<?php echo implode( '\n', $wps_robotarray ); ?>';" class="button"><?php _e( 'Reset to Default', 'wp_statistics' ); ?></a>
128
+ </td>
129
+ </tr>
130
+
131
+ <tr valign="top">
132
+ <th scope="row">
133
+ <label for="force_robot_update"><?php _e( 'Force robot list update after upgrades', 'wp_statistics' ); ?>
134
+ :</label></th>
135
+ <td>
136
+ <input id="force_robot_update" type="checkbox" value="1" name="wps_force_robot_update" <?php echo $WP_Statistics->get_option( 'force_robot_update' ) == true ? "checked='checked'" : ''; ?>><label for="force_robot_update"><?php _e( 'Enable', 'wp_statistics' ); ?></label>
137
+ <p class="description"><?php echo sprintf( __( 'Force the robot list to be reset to the default after an update to WP Statistics takes place. Note if this option is enabled any custom robots you have added to the list will be lost.', 'wp_statistics' ), $role ); ?></p>
138
+ </td>
139
+ </tr>
140
+
141
+ <tr valign="top">
142
+ <th scope="row"><label for="wps_robot_threshold"><?php _e( 'Robot visit threshold', 'wp_statistics' ); ?>
143
+ :</label></th>
144
+ <td>
145
+ <input id="wps_robot_threshold" type="text" size="5" name="wps_robot_threshold" value="<?php echo $WP_Statistics->get_option( 'robot_threshold' ); ?>">
146
+ <p class="description"><?php echo __( 'Treat visitors with more than this number of visits per day as robots. 0 = disabled.', 'wp_statistics' ); ?></p>
147
+ </td>
148
+ </tr>
149
+
150
+ <tr valign="top">
151
+ <th scope="row"><?php _e( 'Excluded IP address list', 'wp_statistics' ); ?>:</th>
152
+ <td>
153
+ <textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option( 'exclude_ip' ), ENT_QUOTES ); ?></textarea>
154
+ <p class="description"><?php echo __( 'A list of IP addresses and subnet masks (one per line) to exclude from statistics collection.', 'wp_statistics' ); ?></p>
155
+ <p class="description"><?php echo __( 'For IPv4 addresses, both 192.168.0.0/24 and 192.168.0.0/255.255.255.0 formats are accepted. To specify an IP address only, use a subnet value of 32 or 255.255.255.255.', 'wp_statistics' ); ?></p>
156
+ <p class="description"><?php echo __( 'For IPv6 addresses use the fc00::/7 format.', 'wp_statistics' ); ?></p>
157
+ <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n10.0.0.0/8' ); }" class="button"><?php _e( 'Add 10.0.0.0', 'wp_statistics' ); ?></a>
158
+ <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n172.16.0.0/12' ); }" class="button"><?php _e( 'Add 172.16.0.0', 'wp_statistics' ); ?></a>
159
+ <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n192.168.0.0/16' ); }" class="button"><?php _e( 'Add 192.168.0.0', 'wp_statistics' ); ?></a>
160
+ <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\nfc00::/7' ); }" class="button"><?php _e( 'Add fc00::/7', 'wp_statistics' ); ?></a>
161
+ </td>
162
+ </tr>
163
+
164
+ <tr valign="top">
165
+ <th scope="row"><?php _e( 'Use honey pot', 'wp_statistics' ); ?>:</th>
166
+ <td>
167
+ <input id="use_honeypot" type="checkbox" value="1" name="wps_use_honeypot" <?php echo $WP_Statistics->get_option( 'use_honeypot' ) == true ? "checked='checked'" : ''; ?>><label for="wps_use_honeypot"><?php _e( 'Enable', 'wp_statistics' ); ?></label>
168
+ <p class="description"><?php echo __( 'Use a honey pot page to identify robots.', 'wp_statistics' ); ?></p>
169
+ </td>
170
+ </tr>
171
+
172
+ <tr valign="top">
173
+ <th scope="row"><label for="honeypot_postid"><?php _e( 'Honey pot post id', 'wp_statistics' ); ?>:</label>
174
+ </th>
175
+ <td>
176
+ <input id="honeypot_postid" type="text" value="<?php echo htmlentities( $WP_Statistics->get_option( 'honeypot_postid' ), ENT_QUOTES ); ?>" size="5" name="wps_honeypot_postid">
177
+ <p class="description"><?php echo __( 'The post id to use for the honeypot page.', 'wp_statistics' ); ?></p>
178
+ <input id="wps_create_honeypot" type="checkbox" value="1" name="wps_create_honeypot"><label for="wps_create_honeypot"><?php _e( 'Create a new honey pot page', 'wp_statistics' ); ?></label>
179
+ </td>
180
+ </tr>
181
+
182
+ <tr valign="top">
183
+ <th scope="row">
184
+ <label for="corrupt_browser_info"><?php _e( 'Treat corrupt browser info as a bot', 'wp_statistics' ); ?>
185
+ :</label></th>
186
+ <td>
187
+ <input id="corrupt_browser_info" type="checkbox" value="1" name="wps_corrupt_browser_info" <?php echo $WP_Statistics->get_option( 'corrupt_browser_info' ) == true ? "checked='checked'" : ''; ?>><label for="wps_corrupt_browser_info"><?php _e( 'Enable', 'wp_statistics' ); ?></label>
188
+ <p class="description"><?php echo __( 'Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.', 'wp_statistics' ); ?></p>
189
+ </td>
190
+ </tr>
191
+
192
+ <tr valign="top">
193
+ <th scope="row" colspan="2"><h3><?php _e( 'GeoIP Exclusions', 'wp_statistics' ); ?></h3></th>
194
+ </tr>
195
+
196
+ <tr valign="top">
197
+ <th scope="row"><?php _e( 'Excluded countries list', 'wp_statistics' ); ?>:</th>
198
+ <td>
199
+ <textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option( 'excluded_countries' ), ENT_QUOTES ); ?></textarea>
200
+ <p class="description"><?php echo __( 'A list of country codes (one per line, two letters each) to exclude from statistics collection. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics' ); ?></p>
201
+ </td>
202
+ </tr>
203
+
204
+ <tr valign="top">
205
+ <th scope="row"><?php _e( 'Included countries list', 'wp_statistics' ); ?>:</th>
206
+ <td>
207
+ <textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option( 'included_countries' ), ENT_QUOTES ); ?></textarea>
208
+ <p class="description"><?php echo __( 'A list of country codes (one per line, two letters each) to include in statistics collection, if this list is not empty, only visitors from the included countries will be recorded. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics' ); ?></p>
209
+ </td>
210
+ </tr>
211
+
212
+ <tr valign="top">
213
+ <th scope="row" colspan="2"><h3><?php _e( 'Host Exclusions', 'wp_statistics' ); ?></h3></th>
214
+ </tr>
215
+
216
+ <tr valign="top">
217
+ <th scope="row"><?php _e( 'Excluded hosts list', 'wp_statistics' ); ?>:</th>
218
+ <td>
219
+ <textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option( 'excluded_hosts' ), ENT_QUOTES ); ?></textarea>
220
+ <p class="description"><?php echo __( 'A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.', 'wp_statistics' ); ?></p>
221
+ <br>
222
+ <p class="description"><?php echo __( 'Note: this option will NOT perform a reverse DNS lookup on each page load but instead cache the IP address for the provided hostnames for one hour. If you are excluding dynamically assigned hosts you may find some degree of overlap when the host changes it\'s IP address and when the cache is updated resulting in some hits recorded.', 'wp_statistics' ); ?></p>
223
+ </td>
224
+ </tr>
225
+
226
+ <tr valign="top">
227
+ <th scope="row" colspan="2"><h3><?php _e( 'Site URL Exclusions', 'wp_statistics' ); ?></h3></th>
228
+ </tr>
229
+
230
+ <tr valign="top">
231
+ <th scope="row"><?php _e( 'Excluded login page', 'wp_statistics' ); ?>:</th>
232
+ <td>
233
+ <input id="wps-exclude-loginpage" type="checkbox" value="1" name="wps_exclude_loginpage" <?php echo $WP_Statistics->get_option( 'exclude_loginpage' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclude-loginpage"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
234
+ <p class="description"><?php _e( 'Exclude the login page for registering as a hit.', 'wp_statistics' ); ?></p>
235
+ </td>
236
+ </tr>
237
+ <tr valign="top">
238
+ <th scope="row"><?php _e( 'Excluded admin pages', 'wp_statistics' ); ?>:</th>
239
+ <td>
240
+ <input id="wps-exclude-adminpage" type="checkbox" value="1" name="wps_exclude_adminpage" <?php echo $WP_Statistics->get_option( 'exclude_adminpage' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclude-adminpage"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
241
+ <p class="description"><?php _e( 'Exclude the admin pages for registering as a hit.', 'wp_statistics' ); ?></p>
242
+ </td>
243
+ </tr>
244
+ <tr valign="top">
245
+ <th scope="row"><?php _e( 'Excluded RSS feeds', 'wp_statistics' ); ?>:</th>
246
+ <td>
247
+ <input id="wps-exclude-feeds" type="checkbox" value="1" name="wps_exclude_feeds" <?php echo $WP_Statistics->get_option( 'exclude_feeds' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclude-feeds"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
248
+ <p class="description"><?php _e( 'Exclude the RSS feeds for registering as a hit.', 'wp_statistics' ); ?></p>
249
+ </td>
250
+ </tr>
251
+ <tr valign="top">
252
+ <th scope="row"><?php _e( 'Excluded 404 pages', 'wp_statistics' ); ?>:</th>
253
+ <td>
254
+ <input id="wps-exclude-404s" type="checkbox" value="1" name="wps_exclude_404s" <?php echo $WP_Statistics->get_option( 'exclude_404s' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclude-404s"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
255
+ <p class="description"><?php _e( 'Exclude any URL that returns a "404 - Not Found" message.', 'wp_statistics' ); ?></p>
256
+ </td>
257
+ </tr>
258
+ <tr valign="top">
259
+ <th scope="row"><?php _e( 'Excluded AJAX calls', 'wp_statistics' ); ?>:</th>
260
+ <td>
261
+ <input id="wps-exclude-ajax" type="checkbox" value="1" name="wps_exclude_ajax" <?php echo $WP_Statistics->get_option( 'exclude_ajax' ) == true ? "checked='checked'" : ''; ?>><label for="wps-exclude-ajax"><?php _e( 'Exclude', 'wp_statistics' ); ?></label>
262
+ <p class="description"><?php _e( 'Exclude any call to the WordPress AJAX system.', 'wp_statistics' ); ?></p>
263
+ </td>
264
+ </tr>
265
+ <tr valign="top">
266
+ <th scope="row"><?php _e( 'Excluded URLs list', 'wp_statistics' ); ?>:</th>
267
+ <td>
268
+ <textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option( 'excluded_urls' ), ENT_QUOTES ); ?></textarea>
269
+ <p class="description"><?php echo __( 'A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.', 'wp_statistics' ); ?></p>
270
+ <br>
271
+ <p class="description"><?php echo __( 'Note: this option will NOT handle url parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.', 'wp_statistics' ); ?></p>
272
+ </td>
273
+ </tr>
274
+
275
+ </tbody>
276
+ </table>
277
+
278
+ <?php submit_button( __( 'Update', 'wp_statistics' ), 'primary', 'submit' ); ?>
includes/settings/tabs/wps-externals.php CHANGED
@@ -1,286 +1,317 @@
1
- <?php
2
- if( $wps_nonce_valid ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- $wps_option_list = array('wps_geoip','wps_update_geoip','wps_schedule_geoip','wps_auto_pop','wps_private_country_code','wps_browscap','wps_update_browscap','wps_schedule_browscap','wps_referrerspam','wps_update_referrerspam','wps_schedule_referrerspam');
5
-
6
  // For country codes we always use upper case, otherwise default to 000 which is 'unknown'.
7
- if( array_key_exists( 'wps_private_country_code', $_POST ) ) {
8
- $_POST['wps_private_country_code'] = trim( strtoupper( $_POST['wps_private_country_code'] ) );
9
- }
10
- else {
11
- $_POST['wps_private_country_code'] = '000';
12
  }
13
 
14
- if( $_POST['wps_private_country_code'] == '' ) { $_POST['wps_private_country_code'] = '000'; }
15
-
16
- foreach( $wps_option_list as $option ) {
 
 
17
  $new_option = str_replace( "wps_", "", $option );
18
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
19
- $WP_Statistics->store_option($new_option, $value);
 
 
 
 
20
  }
21
 
22
  // If we're focing the download of the browscap.ini file, make sure to flush the last download time from the options.
23
- if( array_key_exists( 'wps_update_browscap', $_POST ) ) {
24
- $WP_Statistics->store_option('last_browscap_dl', 0);
25
  }
26
  }
27
 
28
  ?>
29
- <table class="form-table">
30
- <tbody>
31
- <tr valign="top">
32
- <th scope="row" colspan="2"><h3><?php _e('GeoIP settings', 'wp_statistics'); ?></h3></th>
33
- </tr>
34
-
35
- <tr valign="top">
36
- <th scope="row" colspan="2">
37
- <?php echo sprintf(__('IP location services provided by GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics'), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>'); ?>
38
- </th>
39
- </tr>
40
-
41
  <?php
42
- if( wp_statistics_geoip_supported() )
43
- {
44
- ?>
45
- <tr valign="top">
46
- <th scope="row">
47
- <label for="geoip-enable"><?php _e('GeoIP collection', 'wp_statistics'); ?>:</label>
48
- </th>
49
-
50
- <td>
51
- <input id="geoip-enable" type="checkbox" name="wps_geoip" <?php echo $WP_Statistics->get_option('geoip')==true? "checked='checked'":'';?>>
52
- <label for="geoip-enable"><?php _e('Active', 'wp_statistics'); ?></label>
53
- <p class="description"><?php _e('For get more information and location (country) from visitor, enable this feature.', 'wp_statistics'); ?></p>
54
- </td>
55
- </tr>
56
-
57
- <tr valign="top">
58
- <th scope="row">
59
- <label for="geoip-update"><?php _e('Update GeoIP Info', 'wp_statistics'); ?>:</label>
60
- </th>
61
-
62
- <td>
63
- <input id="geoip-update" type="checkbox" name="wps_update_geoip" <?php echo $WP_Statistics->get_option('update_geoip')==true? "checked='checked'":'';?>>
64
- <label for="geoip-update"><?php _e('Download GeoIP Database', 'wp_statistics'); ?></label>
65
- <p class="description"><?php _e('Save changes on this page to download the update.', 'wp_statistics'); ?></p>
66
- </td>
67
- </tr>
68
-
69
- <tr valign="top">
70
- <th scope="row">
71
- <label for="geoip-schedule"><?php _e('Schedule monthly update of GeoIP DB', 'wp_statistics'); ?>:</label>
72
- </th>
73
-
74
- <td>
75
- <input id="geoip-schedule" type="checkbox" name="wps_schedule_geoip" <?php echo $WP_Statistics->get_option('schedule_geoip')==true? "checked='checked'":'';?>>
76
- <label for="geoip-schedule"><?php _e('Active', 'wp_statistics'); ?></label>
77
- <?php
78
- if( $WP_Statistics->get_option('schedule_geoip') ) {
79
- echo '<p class="description">' . __('Next update will be') .': <code>';
80
- $last_update = $WP_Statistics->get_option('last_geoip_dl');
81
- $this_month = strtotime('First Tuesday of this month');
82
-
83
- if( $last_update > $this_month ) { $next_update = strtotime('First Tuesday of next month') + (86400 * 2);}
84
- else { $next_update = $this_month + (86400 * 2); }
85
-
86
- $next_schedule = wp_next_scheduled('wp_statistics_geoip_hook');
87
-
88
- if( $next_schedule ) {
89
- echo $WP_Statistics->Local_Date( get_option('date_format'), $next_update ) . ' @ ' . $WP_Statistics->Local_Date( get_option('time_format'), $next_schedule );
90
- } else {
91
- echo $WP_Statistics->Local_Date( get_option('date_format'), $next_update ) . ' @ ' . $WP_Statistics->Local_Date( get_option('time_format'), time() );
92
- }
93
-
94
- echo '</code></p>';
95
- }
96
- ?>
97
- <p class="description"><?php _e('Download of the GeoIP database will be scheduled for 2 days after the first Tuesday of the month.', 'wp_statistics'); ?></p>
98
- <p class="description"><?php _e('This option will also download the database if the local filesize is less than 1k (which usually means the stub that comes with the plugin is still in place).', 'wp_statistics'); ?></p>
99
- </td>
100
- </tr>
101
-
102
- <tr valign="top">
103
- <th scope="row">
104
- <label for="geoip-schedule"><?php _e('Populate missing GeoIP after update of GeoIP DB', 'wp_statistics'); ?>:</label>
105
- </th>
106
-
107
- <td>
108
- <input id="geoip-auto-pop" type="checkbox" name="wps_auto_pop" <?php echo $WP_Statistics->get_option('auto_pop')==true? "checked='checked'":'';?>>
109
- <label for="geoip-auto-pop"><?php _e('Active', 'wp_statistics'); ?></label>
110
- <p class="description"><?php _e('Update any missing GeoIP data after downloading a new database.', 'wp_statistics'); ?></p>
111
- </td>
112
- </tr>
113
-
114
- <tr valign="top">
115
- <th scope="row">
116
- <label for="geoip-schedule"><?php _e('Country code for private IP addresses', 'wp_statistics'); ?>:</label>
117
- </th>
118
-
119
- <td>
120
- <input type="text" size="3" id="geoip-private-country-code" name="wps_private_country_code" value="<?php echo htmlentities( $WP_Statistics->get_option('private_country_code', '000'), ENT_QUOTES );?>">
121
- <p class="description"><?php _e('The international standard two letter country code (ie. US = United States, CA = Canada, etc.) for private (non-routable) IP addresses (ie. 10.0.0.1, 192.158.1.1, 127.0.0.1, etc.). Use "000" (three zeros) to use "Unknown" as the country code.', 'wp_statistics'); ?></p>
122
- </td>
123
- </tr>
124
- <?php
125
- }
126
- else
127
- {
128
- ?>
129
- <tr valign="top">
130
- <th scope="row" colspan="2">
131
- <?php
132
- echo __('GeoIP collection is disabled due to the following reasons:', 'wp_statistics') . '<br><br>';
133
-
134
- if( !version_compare(phpversion(), WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION, '>') ) {
135
- printf( '&nbsp;&nbsp;&nbsp;&nbsp;* ' . __('GeoIP collection requires PHP %s or above, it is currently disabled due to the installed PHP version being ', 'wp_statistics'), '<code>' . WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION . '</code>' ); echo '<code>' . phpversion() . '</code>.<br>';
136
- }
137
 
138
- if( !function_exists('curl_init') ) {
139
- echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
140
- _e('GeoIP collection requires the cURL PHP extension and it is not loaded on your version of PHP!','wp_statistics');
141
- echo '<br>';
142
- }
 
143
 
144
- if( !function_exists('bcadd') ) {
145
- echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
146
- _e('GeoIP collection requires the BC Math PHP extension and it is not loaded on your version of PHP!','wp_statistics');
147
- echo '<br>';
148
- }
149
 
150
- if( ini_get('safe_mode') ) {
151
- echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
152
- _e('PHP safe mode detected! GeoIP collection is not supported with PHP\'s safe mode enabled!','wp_statistics');
153
- echo '<br>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
- ?>
156
- </th>
157
- </tr>
158
- <?php
159
- } ?>
160
-
161
- <tr valign="top">
162
- <th scope="row" colspan="2"><h3><?php _e('browscap settings', 'wp_statistics'); ?></h3></th>
163
- </tr>
164
-
165
- <tr valign="top">
166
- <th scope="row">
167
- <label for="browscap-enable"><?php _e('browscap usage', 'wp_statistics'); ?>:</label>
168
- </th>
169
-
170
- <td>
171
- <input id="browscap-enable" type="checkbox" name="wps_browscap" <?php echo $WP_Statistics->get_option('browscap')==true? "checked='checked'":'';?>>
172
- <label for="browscap-enable"><?php _e('Active', 'wp_statistics'); ?></label>
173
- <p class="description"><?php _e('The browscap database will be downloaded and used to detect robots.', 'wp_statistics'); ?></p>
174
- </td>
175
- </tr>
176
-
177
- <tr valign="top">
178
- <th scope="row">
179
- <label for="browscap-update"><?php _e('Update browscap Info', 'wp_statistics'); ?>:</label>
180
- </th>
181
-
182
- <td>
183
- <input id="browscap-update" type="checkbox" name="wps_update_browscap" <?php echo $WP_Statistics->get_option('update_browscap')==true? "checked='checked'":'';?>>
184
- <label for="browscap-update"><?php _e('Download browscap Database', 'wp_statistics'); ?></label>
185
- <p class="description"><?php _e('Save changes on this page to download the update.', 'wp_statistics'); ?></p>
186
- </td>
187
- </tr>
188
-
189
- <tr valign="top">
190
- <th scope="row">
191
- <label for="browscap-schedule"><?php _e('Schedule weekly update of browscap DB', 'wp_statistics'); ?>:</label>
192
- </th>
193
-
194
- <td>
195
- <input id="browscap-schedule" type="checkbox" name="wps_schedule_browscap" <?php echo $WP_Statistics->get_option('schedule_browscap')==true? "checked='checked'":'';?>>
196
- <label for="browscap-schedule"><?php _e('Active', 'wp_statistics'); ?></label>
197
- <?php
198
- if( $WP_Statistics->get_option('schedule_browscap') ) {
199
- echo '<p class="description">' . __('Next update will be') .': <code>';
200
- $last_update = $WP_Statistics->get_option('last_browscap_dl');
201
- if( $last_update == 0 ) { $last_update = time(); }
202
- $next_update = $last_update + (86400 * 7);
203
-
204
- $next_schedule = wp_next_scheduled('wp_statistics_browscap_hook');
205
-
206
- if( $next_schedule ) {
207
- echo date( get_option('date_format'), $next_schedule ) . ' @ ' . date( get_option('time_format'), $next_schedule );
208
  } else {
209
- echo date( get_option('date_format'), $next_update ) . ' @ ' . date( get_option('time_format'), time() );
210
  }
211
-
212
  echo '</code></p>';
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  ?>
215
- <p class="description"><?php _e('Download of the browscap database will be scheduled for once a week.', 'wp_statistics'); ?></p>
216
- </td>
217
- </tr>
218
-
219
- <tr valign="top">
220
- <th scope="row" colspan="2"><h3><?php _e('Piwik Referrer Spam Blacklist settings', 'wp_statistics'); ?></h3></th>
221
- </tr>
222
-
223
- <tr valign="top">
224
- <th scope="row" colspan="2">
225
- <?php echo sprintf(__('Referrer spam blacklist is provided by Piwik, available from %s.', 'wp_statistics'), '<a href="https://github.com/piwik/referrer-spam-blacklist" target=_blank>https://github.com/piwik/referrer-spam-blacklist</a>'); ?>
226
- </th>
227
- </tr>
228
-
229
- <tr valign="top">
230
- <th scope="row">
231
- <label for="referrerspam-enable"><?php _e('Piwik Referrer Spam Blacklist usage', 'wp_statistics'); ?>:</label>
232
- </th>
233
-
234
- <td>
235
- <input id="referrerspam-enable" type="checkbox" name="wps_referrerspam" <?php echo $WP_Statistics->get_option('referrerspam')==true? "checked='checked'":'';?>>
236
- <label for="referrerspam-enable"><?php _e('Active', 'wp_statistics'); ?></label>
237
- <p class="description"><?php _e('The Piwik Referrer Spam Blacklist database will be downloaded and used to detect referrer spam.', 'wp_statistics'); ?></p>
238
- </td>
239
- </tr>
240
-
241
- <tr valign="top">
242
- <th scope="row">
243
- <label for="geoip-update"><?php _e('Update Piwik Referrer Spam Blacklist Info', 'wp_statistics'); ?>:</label>
244
- </th>
245
-
246
- <td>
247
- <input id="referrerspam-update" type="checkbox" name="wps_update_referrerspam" <?php echo $WP_Statistics->get_option('update_referrerspam')==true? "checked='checked'":'';?>>
248
- <label for="referrerspam-update"><?php _e('Download Piwik Referrer Spam Blacklist Database', 'wp_statistics'); ?></label>
249
- <p class="description"><?php _e('Save changes on this page to download the update.', 'wp_statistics'); ?></p>
250
- </td>
251
- </tr>
252
-
253
- <tr valign="top">
254
- <th scope="row">
255
- <label for="referrerspam-schedule"><?php _e('Schedule weekly update of Piwik Referrer Spam Blacklist DB', 'wp_statistics'); ?>:</label>
256
- </th>
257
-
258
- <td>
259
- <input id="referrerspam-schedule" type="checkbox" name="wps_schedule_referrerspam" <?php echo $WP_Statistics->get_option('schedule_referrerspam')==true? "checked='checked'":'';?>>
260
- <label for="referrerspam-schedule"><?php _e('Active', 'wp_statistics'); ?></label>
261
- <?php
262
- if( $WP_Statistics->get_option('schedule_referrerspam') ) {
263
- echo '<p class="description">' . __('Next update will be') .': <code>';
264
- $last_update = $WP_Statistics->get_option('schedule_referrerspam');
265
- if( $last_update == 0 ) { $last_update = time(); }
266
- $next_update = $last_update + (86400 * 7);
267
-
268
- $next_schedule = wp_next_scheduled('wp_statistics_referrerspam_hook');
269
-
270
- if( $next_schedule ) {
271
- echo date( get_option('date_format'), $next_schedule ) . ' @ ' . date( get_option('time_format'), $next_schedule );
272
- } else {
273
- echo date( get_option('date_format'), $next_update ) . ' @ ' . date( get_option('time_format'), time() );
274
- }
275
-
276
- echo '</code></p>';
277
  }
 
 
 
 
 
 
 
 
 
 
 
 
278
  ?>
279
- <p class="description"><?php _e('Download of the Piwik Referrer Spam Blacklist database will be scheduled for once a week.', 'wp_statistics'); ?></p>
280
- </td>
281
- </tr>
282
 
283
- </tbody>
284
- </table>
285
 
286
- <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>
1
+ <?php
2
+ if ( $wps_nonce_valid ) {
3
+
4
+ $wps_option_list = array(
5
+ 'wps_geoip',
6
+ 'wps_update_geoip',
7
+ 'wps_schedule_geoip',
8
+ 'wps_auto_pop',
9
+ 'wps_private_country_code',
10
+ 'wps_browscap',
11
+ 'wps_update_browscap',
12
+ 'wps_schedule_browscap',
13
+ 'wps_referrerspam',
14
+ 'wps_update_referrerspam',
15
+ 'wps_schedule_referrerspam'
16
+ );
17
 
 
 
18
  // For country codes we always use upper case, otherwise default to 000 which is 'unknown'.
19
+ if ( array_key_exists( 'wps_private_country_code', $_POST ) ) {
20
+ $_POST['wps_private_country_code'] = trim( strtoupper( $_POST['wps_private_country_code'] ) );
21
+ } else {
22
+ $_POST['wps_private_country_code'] = '000';
 
23
  }
24
 
25
+ if ( $_POST['wps_private_country_code'] == '' ) {
26
+ $_POST['wps_private_country_code'] = '000';
27
+ }
28
+
29
+ foreach ( $wps_option_list as $option ) {
30
  $new_option = str_replace( "wps_", "", $option );
31
+ if ( array_key_exists( $option, $_POST ) ) {
32
+ $value = $_POST[ $option ];
33
+ } else {
34
+ $value = '';
35
+ }
36
+ $WP_Statistics->store_option( $new_option, $value );
37
  }
38
 
39
  // If we're focing the download of the browscap.ini file, make sure to flush the last download time from the options.
40
+ if ( array_key_exists( 'wps_update_browscap', $_POST ) ) {
41
+ $WP_Statistics->store_option( 'last_browscap_dl', 0 );
42
  }
43
  }
44
 
45
  ?>
46
+ <table class="form-table">
47
+ <tbody>
48
+ <tr valign="top">
49
+ <th scope="row" colspan="2"><h3><?php _e( 'GeoIP settings', 'wp_statistics' ); ?></h3></th>
50
+ </tr>
51
+
52
+ <tr valign="top">
53
+ <th scope="row" colspan="2">
54
+ <?php echo sprintf( __( 'IP location services provided by GeoLite2 data created by MaxMind, available from %s.', 'wp_statistics' ), '<a href="http://www.maxmind.com" target=_blank>http://www.maxmind.com</a>' ); ?>
55
+ </th>
56
+ </tr>
57
+
58
  <?php
59
+ if ( wp_statistics_geoip_supported() ) {
60
+ ?>
61
+ <tr valign="top">
62
+ <th scope="row">
63
+ <label for="geoip-enable"><?php _e( 'GeoIP collection', 'wp_statistics' ); ?>:</label>
64
+ </th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
+ <td>
67
+ <input id="geoip-enable" type="checkbox" name="wps_geoip" <?php echo $WP_Statistics->get_option( 'geoip' ) == true ? "checked='checked'" : ''; ?>>
68
+ <label for="geoip-enable"><?php _e( 'Active', 'wp_statistics' ); ?></label>
69
+ <p class="description"><?php _e( 'For get more information and location (country) from visitor, enable this feature.', 'wp_statistics' ); ?></p>
70
+ </td>
71
+ </tr>
72
 
73
+ <tr valign="top">
74
+ <th scope="row">
75
+ <label for="geoip-update"><?php _e( 'Update GeoIP Info', 'wp_statistics' ); ?>:</label>
76
+ </th>
 
77
 
78
+ <td>
79
+ <input id="geoip-update" type="checkbox" name="wps_update_geoip" <?php echo $WP_Statistics->get_option( 'update_geoip' ) == true ? "checked='checked'" : ''; ?>>
80
+ <label for="geoip-update"><?php _e( 'Download GeoIP Database', 'wp_statistics' ); ?></label>
81
+ <p class="description"><?php _e( 'Save changes on this page to download the update.', 'wp_statistics' ); ?></p>
82
+ </td>
83
+ </tr>
84
+
85
+ <tr valign="top">
86
+ <th scope="row">
87
+ <label for="geoip-schedule"><?php _e( 'Schedule monthly update of GeoIP DB', 'wp_statistics' ); ?>
88
+ :</label>
89
+ </th>
90
+
91
+ <td>
92
+ <input id="geoip-schedule" type="checkbox" name="wps_schedule_geoip" <?php echo $WP_Statistics->get_option( 'schedule_geoip' ) == true ? "checked='checked'" : ''; ?>>
93
+ <label for="geoip-schedule"><?php _e( 'Active', 'wp_statistics' ); ?></label>
94
+ <?php
95
+ if ( $WP_Statistics->get_option( 'schedule_geoip' ) ) {
96
+ echo '<p class="description">' . __( 'Next update will be' ) . ': <code>';
97
+ $last_update = $WP_Statistics->get_option( 'last_geoip_dl' );
98
+ $this_month = strtotime( 'First Tuesday of this month' );
99
+
100
+ if ( $last_update > $this_month ) {
101
+ $next_update = strtotime( 'First Tuesday of next month' ) + ( 86400 * 2 );
102
+ } else {
103
+ $next_update = $this_month + ( 86400 * 2 );
104
  }
105
+
106
+ $next_schedule = wp_next_scheduled( 'wp_statistics_geoip_hook' );
107
+
108
+ if ( $next_schedule ) {
109
+ echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) . ' @ ' . $WP_Statistics->Local_Date( get_option( 'time_format' ), $next_schedule );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  } else {
111
+ echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) . ' @ ' . $WP_Statistics->Local_Date( get_option( 'time_format' ), time() );
112
  }
113
+
114
  echo '</code></p>';
115
  }
116
+ ?>
117
+ <p class="description"><?php _e( 'Download of the GeoIP database will be scheduled for 2 days after the first Tuesday of the month.', 'wp_statistics' ); ?></p>
118
+ <p class="description"><?php _e( 'This option will also download the database if the local filesize is less than 1k (which usually means the stub that comes with the plugin is still in place).', 'wp_statistics' ); ?></p>
119
+ </td>
120
+ </tr>
121
+
122
+ <tr valign="top">
123
+ <th scope="row">
124
+ <label for="geoip-schedule"><?php _e( 'Populate missing GeoIP after update of GeoIP DB', 'wp_statistics' ); ?>
125
+ :</label>
126
+ </th>
127
+
128
+ <td>
129
+ <input id="geoip-auto-pop" type="checkbox" name="wps_auto_pop" <?php echo $WP_Statistics->get_option( 'auto_pop' ) == true ? "checked='checked'" : ''; ?>>
130
+ <label for="geoip-auto-pop"><?php _e( 'Active', 'wp_statistics' ); ?></label>
131
+ <p class="description"><?php _e( 'Update any missing GeoIP data after downloading a new database.', 'wp_statistics' ); ?></p>
132
+ </td>
133
+ </tr>
134
+
135
+ <tr valign="top">
136
+ <th scope="row">
137
+ <label for="geoip-schedule"><?php _e( 'Country code for private IP addresses', 'wp_statistics' ); ?>
138
+ :</label>
139
+ </th>
140
+
141
+ <td>
142
+ <input type="text" size="3" id="geoip-private-country-code" name="wps_private_country_code" value="<?php echo htmlentities( $WP_Statistics->get_option( 'private_country_code', '000' ), ENT_QUOTES ); ?>">
143
+ <p class="description"><?php _e( 'The international standard two letter country code (ie. US = United States, CA = Canada, etc.) for private (non-routable) IP addresses (ie. 10.0.0.1, 192.158.1.1, 127.0.0.1, etc.). Use "000" (three zeros) to use "Unknown" as the country code.', 'wp_statistics' ); ?></p>
144
+ </td>
145
+ </tr>
146
+ <?php
147
+ } else {
148
+ ?>
149
+ <tr valign="top">
150
+ <th scope="row" colspan="2">
151
+ <?php
152
+ echo __( 'GeoIP collection is disabled due to the following reasons:', 'wp_statistics' ) . '<br><br>';
153
+
154
+ if ( ! version_compare( phpversion(), WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION, '>' ) ) {
155
+ printf( '&nbsp;&nbsp;&nbsp;&nbsp;* ' . __( 'GeoIP collection requires PHP %s or above, it is currently disabled due to the installed PHP version being ', 'wp_statistics' ), '<code>' . WP_STATISTICS_REQUIRED_GEOIP_PHP_VERSION . '</code>' );
156
+ echo '<code>' . phpversion() . '</code>.<br>';
157
+ }
158
+
159
+ if ( ! function_exists( 'curl_init' ) ) {
160
+ echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
161
+ _e( 'GeoIP collection requires the cURL PHP extension and it is not loaded on your version of PHP!', 'wp_statistics' );
162
+ echo '<br>';
163
+ }
164
+
165
+ if ( ! function_exists( 'bcadd' ) ) {
166
+ echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
167
+ _e( 'GeoIP collection requires the BC Math PHP extension and it is not loaded on your version of PHP!', 'wp_statistics' );
168
+ echo '<br>';
169
+ }
170
+
171
+ if ( ini_get( 'safe_mode' ) ) {
172
+ echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;* ';
173
+ _e( 'PHP safe mode detected! GeoIP collection is not supported with PHP\'s safe mode enabled!', 'wp_statistics' );
174
+ echo '<br>';
175
+ }
176
+ ?>
177
+ </th>
178
+ </tr>
179
+ <?php
180
+ } ?>
181
+
182
+ <tr valign="top">
183
+ <th scope="row" colspan="2"><h3><?php _e( 'browscap settings', 'wp_statistics' ); ?></h3></th>
184
+ </tr>
185
+
186
+ <tr valign="top">
187
+ <th scope="row">
188
+ <label for="browscap-enable"><?php _e( 'browscap usage', 'wp_statistics' ); ?>:</label>
189
+ </th>
190
+
191
+ <td>
192
+ <input id="browscap-enable" type="checkbox" name="wps_browscap" <?php echo $WP_Statistics->get_option( 'browscap' ) == true ? "checked='checked'" : ''; ?>>
193
+ <label for="browscap-enable"><?php _e( 'Active', 'wp_statistics' ); ?></label>
194
+ <p class="description"><?php _e( 'The browscap database will be downloaded and used to detect robots.', 'wp_statistics' ); ?></p>
195
+ </td>
196
+ </tr>
197
+
198
+ <tr valign="top">
199
+ <th scope="row">
200
+ <label for="browscap-update"><?php _e( 'Update browscap Info', 'wp_statistics' ); ?>:</label>
201
+ </th>
202
+
203
+ <td>
204
+ <input id="browscap-update" type="checkbox" name="wps_update_browscap" <?php echo $WP_Statistics->get_option( 'update_browscap' ) == true ? "checked='checked'" : ''; ?>>
205
+ <label for="browscap-update"><?php _e( 'Download browscap Database', 'wp_statistics' ); ?></label>
206
+ <p class="description"><?php _e( 'Save changes on this page to download the update.', 'wp_statistics' ); ?></p>
207
+ </td>
208
+ </tr>
209
+
210
+ <tr valign="top">
211
+ <th scope="row">
212
+ <label for="browscap-schedule"><?php _e( 'Schedule weekly update of browscap DB', 'wp_statistics' ); ?>
213
+ :</label>
214
+ </th>
215
+
216
+ <td>
217
+ <input id="browscap-schedule" type="checkbox" name="wps_schedule_browscap" <?php echo $WP_Statistics->get_option( 'schedule_browscap' ) == true ? "checked='checked'" : ''; ?>>
218
+ <label for="browscap-schedule"><?php _e( 'Active', 'wp_statistics' ); ?></label>
219
+ <?php
220
+ if ( $WP_Statistics->get_option( 'schedule_browscap' ) ) {
221
+ echo '<p class="description">' . __( 'Next update will be' ) . ': <code>';
222
+ $last_update = $WP_Statistics->get_option( 'last_browscap_dl' );
223
+ if ( $last_update == 0 ) {
224
+ $last_update = time();
225
+ }
226
+ $next_update = $last_update + ( 86400 * 7 );
227
+
228
+ $next_schedule = wp_next_scheduled( 'wp_statistics_browscap_hook' );
229
+
230
+ if ( $next_schedule ) {
231
+ echo date( get_option( 'date_format' ), $next_schedule ) . ' @ ' . date( get_option( 'time_format' ), $next_schedule );
232
+ } else {
233
+ echo date( get_option( 'date_format' ), $next_update ) . ' @ ' . date( get_option( 'time_format' ), time() );
234
+ }
235
+
236
+ echo '</code></p>';
237
+ }
238
  ?>
239
+ <p class="description"><?php _e( 'Download of the browscap database will be scheduled for once a week.', 'wp_statistics' ); ?></p>
240
+ </td>
241
+ </tr>
242
+
243
+ <tr valign="top">
244
+ <th scope="row" colspan="2">
245
+ <h3><?php _e( 'Piwik Referrer Spam Blacklist settings', 'wp_statistics' ); ?></h3>
246
+ </th>
247
+ </tr>
248
+
249
+ <tr valign="top">
250
+ <th scope="row" colspan="2">
251
+ <?php echo sprintf( __( 'Referrer spam blacklist is provided by Piwik, available from %s.', 'wp_statistics' ), '<a href="https://github.com/piwik/referrer-spam-blacklist" target=_blank>https://github.com/piwik/referrer-spam-blacklist</a>' ); ?>
252
+ </th>
253
+ </tr>
254
+
255
+ <tr valign="top">
256
+ <th scope="row">
257
+ <label for="referrerspam-enable"><?php _e( 'Piwik Referrer Spam Blacklist usage', 'wp_statistics' ); ?>
258
+ :</label>
259
+ </th>
260
+
261
+ <td>
262
+ <input id="referrerspam-enable" type="checkbox" name="wps_referrerspam" <?php echo $WP_Statistics->get_option( 'referrerspam' ) == true ? "checked='checked'" : ''; ?>>
263
+ <label for="referrerspam-enable"><?php _e( 'Active', 'wp_statistics' ); ?></label>
264
+ <p class="description"><?php _e( 'The Piwik Referrer Spam Blacklist database will be downloaded and used to detect referrer spam.', 'wp_statistics' ); ?></p>
265
+ </td>
266
+ </tr>
267
+
268
+ <tr valign="top">
269
+ <th scope="row">
270
+ <label for="geoip-update"><?php _e( 'Update Piwik Referrer Spam Blacklist Info', 'wp_statistics' ); ?>
271
+ :</label>
272
+ </th>
273
+
274
+ <td>
275
+ <input id="referrerspam-update" type="checkbox" name="wps_update_referrerspam" <?php echo $WP_Statistics->get_option( 'update_referrerspam' ) == true ? "checked='checked'" : ''; ?>>
276
+ <label for="referrerspam-update"><?php _e( 'Download Piwik Referrer Spam Blacklist Database', 'wp_statistics' ); ?></label>
277
+ <p class="description"><?php _e( 'Save changes on this page to download the update.', 'wp_statistics' ); ?></p>
278
+ </td>
279
+ </tr>
280
+
281
+ <tr valign="top">
282
+ <th scope="row">
283
+ <label for="referrerspam-schedule"><?php _e( 'Schedule weekly update of Piwik Referrer Spam Blacklist DB', 'wp_statistics' ); ?>
284
+ :</label>
285
+ </th>
286
+
287
+ <td>
288
+ <input id="referrerspam-schedule" type="checkbox" name="wps_schedule_referrerspam" <?php echo $WP_Statistics->get_option( 'schedule_referrerspam' ) == true ? "checked='checked'" : ''; ?>>
289
+ <label for="referrerspam-schedule"><?php _e( 'Active', 'wp_statistics' ); ?></label>
290
+ <?php
291
+ if ( $WP_Statistics->get_option( 'schedule_referrerspam' ) ) {
292
+ echo '<p class="description">' . __( 'Next update will be' ) . ': <code>';
293
+ $last_update = $WP_Statistics->get_option( 'schedule_referrerspam' );
294
+ if ( $last_update == 0 ) {
295
+ $last_update = time();
 
 
 
 
 
296
  }
297
+ $next_update = $last_update + ( 86400 * 7 );
298
+
299
+ $next_schedule = wp_next_scheduled( 'wp_statistics_referrerspam_hook' );
300
+
301
+ if ( $next_schedule ) {
302
+ echo date( get_option( 'date_format' ), $next_schedule ) . ' @ ' . date( get_option( 'time_format' ), $next_schedule );
303
+ } else {
304
+ echo date( get_option( 'date_format' ), $next_update ) . ' @ ' . date( get_option( 'time_format' ), time() );
305
+ }
306
+
307
+ echo '</code></p>';
308
+ }
309
  ?>
310
+ <p class="description"><?php _e( 'Download of the Piwik Referrer Spam Blacklist database will be scheduled for once a week.', 'wp_statistics' ); ?></p>
311
+ </td>
312
+ </tr>
313
 
314
+ </tbody>
315
+ </table>
316
 
317
+ <?php submit_button( __( 'Update', 'wp_statistics' ), 'primary', 'submit' ); ?>
includes/settings/tabs/wps-general.php CHANGED
@@ -1,349 +1,347 @@
1
- <?php
2
- $selist = wp_statistics_searchengine_list( true );
3
-
4
- $permalink = get_option( 'permalink_structure' );
5
-
6
  $disable_strip_uri_parameters = false;
7
- if( $permalink == '' || strpos( $permalink, '?' ) !== false ) {
 
8
  $disable_strip_uri_parameters = true;
9
  }
10
 
11
- if( $wps_nonce_valid ) {
12
- foreach( $selist as $se ) {
13
  $se_post = 'wps_disable_se_' . $se['tag'];
14
-
15
- if( array_key_exists( $se_post, $_POST ) ) { $value = $_POST[$se_post]; } else { $value = ''; }
 
 
 
 
16
  $new_option = str_replace( "wps_", "", $se_post );
17
- $WP_Statistics->store_option($new_option, $value);
18
  }
19
 
20
- $wps_option_list = array('wps_useronline','wps_visits','wps_visitors','wps_pages','wps_track_all_pages','wps_disable_column','wps_check_online','wps_menu_bar','wps_coefficient','wps_chart_totals','wps_store_ua','wps_hide_notices','wps_delete_manual','wps_hash_ips', 'wps_all_online', 'wps_strip_uri_parameters', 'wps_override_language','wps_addsearchwords' );
21
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  // If the IP hash's are enabled, disable storing the complete user agent.
23
- if( array_key_exists( 'wps_hash_ips', $_POST ) ) { $_POST['wps_store_ua'] = ''; }
24
-
25
- // We need to check the permalink format for the strip_uri_parameters option, if the permalink is the default or contains uri parameters, we can't strip them.
26
- if( $disable_strip_uri_parameters ) { $_POST['wps_strip_uri_parameters'] = ''; }
27
-
28
- foreach( $wps_option_list as $option ) {
29
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
30
- $new_option = str_replace( "wps_", "", $option );
31
- $WP_Statistics->store_option($new_option, $value);
32
  }
33
 
34
- if( $WP_Statistics->get_option('delete_manual') == true ) {
35
- $filepath = realpath( plugin_dir_path(__FILE__) . "../../../" ) . "/";
36
-
37
- if( file_exists( $filepath . WP_STATISTICS_MANUAL . 'html' ) ) { unlink( $filepath . WP_STATISTICS_MANUAL . 'html' ); }
38
- if( file_exists( $filepath . WP_STATISTICS_MANUAL . 'odt' ) ) { unlink( $filepath . WP_STATISTICS_MANUAL . 'odt' ); }
39
  }
40
-
41
- }
42
 
43
- ?>
44
- <script type="text/javascript">
45
- jQuery(document).ready(function() {
46
- jQuery("#delete_manual").click(function(){
47
- if(!this.checked)
48
- return;
49
-
50
- var agree = confirm('<?php _e('This will delete the manual when you save the settings, are you sure?', 'wp_statistics'); ?>');
51
-
52
- if(!agree)
53
- jQuery("#delete_manual").attr("checked", false);
54
-
55
- });
56
- });
57
-
58
- function ToggleStatOptions() {
59
- jQuery('[id^="wps_stats_report_option"]').fadeToggle();
60
- }
61
- </script>
62
-
63
- <table class="form-table">
64
- <tbody>
65
- <tr valign="top">
66
- <th scope="row" colspan="2"><h3><?php _e('IP Addresses', 'wp_statistics'); ?></h3></th>
67
- </tr>
68
-
69
- <tr valign="top">
70
- <th scope="row">
71
- <label for="useronline"><?php _e('Hash IP Addresses', 'wp_statistics'); ?>:</label>
72
- </th>
73
-
74
- <td>
75
- <input id="hash_ips" type="checkbox" value="1" name="wps_hash_ips" <?php echo $WP_Statistics->get_option('hash_ips')==true? "checked='checked'":'';?>>
76
- <label for="hash_ips"><?php _e('Active', 'wp_statistics'); ?></label>
77
- <p class="description"><?php _e('This feature will not store IP addresses in the database but instead used a unique hash. The "Store entire user agent string" setting will be disabled if this is selected. You will not be able to recover the IP addresses in the future to recover location information if this is enabled.', 'wp_statistics'); ?></p>
78
- </td>
79
- </tr>
80
-
81
- <tr valign="top">
82
- <th scope="row" colspan="2"><h3><?php _e('Users Online', 'wp_statistics'); ?></h3></th>
83
- </tr>
84
-
85
- <tr valign="top">
86
- <th scope="row">
87
- <label for="useronline"><?php _e('User online', 'wp_statistics'); ?>:</label>
88
- </th>
89
-
90
- <td>
91
- <input id="useronline" type="checkbox" value="1" name="wps_useronline" <?php echo $WP_Statistics->get_option('useronline')==true? "checked='checked'":'';?>>
92
- <label for="useronline"><?php _e('Active', 'wp_statistics'); ?></label>
93
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
94
- </td>
95
- </tr>
96
-
97
- <tr valign="top">
98
- <th scope="row">
99
- <label for="check_online"><?php _e('Check for online users every', 'wp_statistics'); ?>:</label>
100
- </th>
101
-
102
- <td>
103
- <input type="text" class="small-text code" id="check_online" name="wps_check_online" value="<?php echo htmlentities($WP_Statistics->get_option('check_online'), ENT_QUOTES ); ?>"/>
104
- <?php _e('Second', 'wp_statistics'); ?>
105
- <p class="description"><?php echo sprintf(__('Time for the check accurate online user in the site. Now: %s Second', 'wp_statistics'), $WP_Statistics->get_option('check_online')); ?></p>
106
- </td>
107
- </tr>
108
-
109
- <tr valign="top">
110
- <th scope="row">
111
- <label for="useronline"><?php _e('Record all user', 'wp_statistics'); ?>:</label>
112
- </th>
113
-
114
- <td>
115
- <input id="allonline" type="checkbox" value="1" name="wps_all_online" <?php echo $WP_Statistics->get_option('all_online')==true? "checked='checked'":'';?>>
116
- <label for="allonline"><?php _e('Active', 'wp_statistics'); ?></label>
117
- <p class="description"><?php _e('Ignores the exclusion settings and records all users that are online (including self referrals and robots). Should only be used for troubleshooting.', 'wp_statistics'); ?></p>
118
- </td>
119
- </tr>
120
-
121
- <tr valign="top">
122
- <th scope="row" colspan="2"><h3><?php _e('Visits', 'wp_statistics'); ?></h3></th>
123
- </tr>
124
-
125
- <tr valign="top">
126
- <th scope="row">
127
- <label for="visits"><?php _e('Visits', 'wp_statistics'); ?>:</label>
128
- </th>
129
-
130
- <td>
131
- <input id="visits" type="checkbox" value="1" name="wps_visits" <?php echo $WP_Statistics->get_option('visits')==true? "checked='checked'":'';?>>
132
- <label for="visits"><?php _e('Active', 'wp_statistics'); ?></label>
133
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
134
- </td>
135
- </tr>
136
-
137
- <tr valign="top">
138
- <th scope="row" colspan="2"><h3><?php _e('Visitors', 'wp_statistics'); ?></h3></th>
139
- </tr>
140
-
141
- <tr valign="top">
142
- <th scope="row">
143
- <label for="visitors"><?php _e('Visitors', 'wp_statistics'); ?>:</label>
144
- </th>
145
-
146
- <td>
147
- <input id="visitors" type="checkbox" value="1" name="wps_visitors" <?php echo $WP_Statistics->get_option('visitors')==true? "checked='checked'":'';?>>
148
- <label for="visitors"><?php _e('Active', 'wp_statistics'); ?></label>
149
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
150
- </td>
151
- </tr>
152
-
153
- <tr valign="top">
154
- <th scope="row">
155
- <label for="visitors"><?php _e('Store entire user agent string', 'wp_statistics'); ?>:</label>
156
- </th>
157
-
158
- <td>
159
- <input id="store_ua" type="checkbox" value="1" name="wps_store_ua" <?php echo $WP_Statistics->get_option('store_ua')==true? "checked='checked'":'';?>>
160
- <label for="store_ua"><?php _e('Active', 'wp_statistics'); ?></label>
161
- <p class="description"><?php _e('Only enabled for debugging', 'wp_statistics'); ?></p>
162
- </td>
163
- </tr>
164
-
165
- <tr valign="top">
166
- <th scope="row">
167
- <label for="coefficient"><?php _e('Coefficient per visitor', 'wp_statistics'); ?>:</label>
168
- </th>
169
-
170
- <td>
171
- <input type="text" class="small-text code" id="coefficient" name="wps_coefficient" value="<?php echo htmlentities($WP_Statistics->get_option('coefficient'), ENT_QUOTES ); ?>"/>
172
- <p class="description"><?php echo sprintf(__('For each visit to account for several hits. Currently %s.', 'wp_statistics'), $WP_Statistics->get_option('coefficient')); ?></p>
173
- </td>
174
- </tr>
175
-
176
- <tr valign="top">
177
- <th scope="row" colspan="2"><h3><?php _e('Pages', 'wp_statistics'); ?></h3></th>
178
- </tr>
179
-
180
- <tr valign="top">
181
- <th scope="row">
182
- <label for="pages"><?php _e('Pages', 'wp_statistics'); ?>:</label>
183
- </th>
184
-
185
- <td>
186
- <input id="pages" type="checkbox" value="1" name="wps_pages" <?php echo $WP_Statistics->get_option('pages')==true? "checked='checked'":'';?>>
187
- <label for="pages"><?php _e('Active', 'wp_statistics'); ?></label>
188
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
189
- </td>
190
- </tr>
191
-
192
- <tr valign="top">
193
- <th scope="row">
194
- <label for="pages"><?php _e('Track all pages', 'wp_statistics'); ?>:</label>
195
- </th>
196
-
197
- <td>
198
- <input id="all_pages" type="checkbox" value="1" name="wps_track_all_pages" <?php echo $WP_Statistics->get_option('track_all_pages')==true? "checked='checked'":'';?>>
199
- <label for="all_pages"><?php _e('Active', 'wp_statistics'); ?></label>
200
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
201
- </td>
202
- </tr>
203
-
204
- <?php
205
- if( !$disable_strip_uri_parameters ) {
206
- ?>
207
- <tr valign="top">
208
- <th scope="row">
209
- <label for="pages"><?php _e('Strip parameters from URI', 'wp_statistics'); ?>:</label>
210
- </th>
211
-
212
- <td>
213
- <input id="strip_uri_parameters" type="checkbox" value="1" name="wps_strip_uri_parameters" <?php echo $WP_Statistics->get_option('strip_uri_parameters')==true? "checked='checked'":'';?>>
214
- <label for="strip_uri_parameters"><?php _e('Active', 'wp_statistics'); ?></label>
215
- <p class="description"><?php _e('This will remove anything after the ? in a URL.', 'wp_statistics'); ?></p>
216
- </td>
217
- </tr>
218
- <?php
219
  }
 
220
  ?>
221
- <tr valign="top">
222
- <th scope="row">
223
- <label for="pages"><?php _e('Disable hits column in post/pages list', 'wp_statistics'); ?>:</label>
224
- </th>
225
-
226
- <td>
227
- <input id="disable_column" type="checkbox" value="1" name="wps_disable_column" <?php echo $WP_Statistics->get_option('disable_column')==true? "checked='checked'":'';?>>
228
- <label for="disable_column"><?php _e('Active', 'wp_statistics'); ?></label>
229
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
230
- </td>
231
- </tr>
232
-
233
- <tr valign="top">
234
- <th scope="row" colspan="2"><h3><?php _e('Miscellaneous', 'wp_statistics'); ?></h3></th>
235
- </tr>
236
-
237
- <tr valign="top">
238
- <th scope="row">
239
- <label for="menu-bar"><?php _e('Show stats in menu bar', 'wp_statistics'); ?>:</label>
240
- </th>
241
-
242
- <td>
243
- <select name="wps_menu_bar" id="menu-bar">
244
- <option value="0" <?php selected($WP_Statistics->get_option('menu_bar'), '0'); ?>><?php _e('No', 'wp_statistics'); ?></option>
245
- <option value="1" <?php selected($WP_Statistics->get_option('menu_bar'), '1'); ?>><?php _e('Yes', 'wp_statistics'); ?></option>
246
- </select>
247
- <p class="description"><?php _e('Show stats in admin menu bar', 'wp_statistics'); ?></p>
248
- </td>
249
- </tr>
250
-
251
- <tr valign="top">
252
- <th scope="row">
253
- <label for="hide_notices"><?php _e('Hide admin notices about non active features', 'wp_statistics'); ?>:</label>
254
- </th>
255
-
256
- <td>
257
- <input id="hide_notices" type="checkbox" value="1" name="wps_hide_notices" <?php echo $WP_Statistics->get_option('hide_notices')==true? "checked='checked'":'';?>>
258
- <label for="store_ua"><?php _e('Active', 'wp_statistics'); ?></label>
259
- <p class="description"><?php _e('By default WP Statistics displays an alert if any of the core features are disabled on every admin page, this option will disable these notices.', 'wp_statistics'); ?></p>
260
- </td>
261
- </tr>
262
-
263
- <tr valign="top">
264
- <th scope="row">
265
- <label for="hide_notices"><?php _e('Delete the manual', 'wp_statistics'); ?>:</label>
266
- </th>
267
-
268
- <td>
269
- <input id="delete_manual" type="checkbox" value="1" name="wps_delete_manual" <?php echo $WP_Statistics->get_option('delete_manual')==true? "checked='checked'":'';?>>
270
- <label for="delete_manual"><?php _e('Active', 'wp_statistics'); ?></label>
271
- <p class="description"><?php _e('By default WP Statistics stores the admin manual in the plugin directory (~5 meg), if this option is enabled it will be deleted now and during upgrades in the future.', 'wp_statistics'); ?></p>
272
- </td>
273
- </tr>
274
-
275
- <tr valign="top">
276
- <th scope="row" colspan="2"><h3><?php _e('Search Engines', 'wp_statistics'); ?></h3></th>
277
- </tr>
278
-
279
- <tr valign="top">
280
- <th scope="row">
281
- <label for="hide_notices"><?php _e('Add page title to empty search words', 'wp_statistics'); ?>:</label>
282
- </th>
283
-
284
- <td>
285
- <input id="addsearchwords" type="checkbox" value="1" name="wps_addsearchwords" <?php echo $WP_Statistics->get_option('addsearchwords')==true? "checked='checked'":'';?>>
286
- <label for="addsearchwords"><?php _e('Active', 'wp_statistics'); ?></label>
287
- <p class="description"><?php _e('If a search engine is identified as the referrer but it does not include the search query this option will substitute the page title in quotes preceded by "~:" as the search query to help identify what the user may have been searching for.', 'wp_statistics'); ?></p>
288
- </td>
289
- </tr>
290
-
291
- <tr valign="top">
292
- <th scope="row" colspan="2">
293
- <p class="description"><?php _e('Disabling all search engines is not allowed, doing so will result in all search engines being active.', 'wp_statistics');?></p>
294
- </th>
295
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  <?php
297
- $se_option_list = '';
298
-
299
- foreach( $selist as $se ) {
300
- $option_name = 'wps_disable_se_' . $se['tag'];
301
- $store_name = 'disable_se_' . $se['tag'];
302
- $se_option_list .= $option_name . ',';
 
 
 
 
 
 
 
 
 
303
  ?>
304
-
305
- <tr valign="top">
306
- <th scope="row"><label for="<?php echo $option_name;?>"><?php _e($se['name'], 'wp_statistics'); ?>:</label></th>
307
- <td>
308
- <input id="<?php echo $option_name;?>" type="checkbox" value="1" name="<?php echo $option_name;?>" <?php echo $WP_Statistics->get_option($store_name)==true? "checked='checked'":'';?>><label for="<?php echo $option_name;?>"><?php _e('disable', 'wp_statistics'); ?></label>
309
- <p class="description"><?php echo sprintf(__('Disable %s from data collection and reporting.', 'wp_statistics'), $se['name']); ?></p>
310
- </td>
311
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  <?php } ?>
313
 
314
- <tr valign="top">
315
- <th scope="row" colspan="2"><h3><?php _e('Charts', 'wp_statistics'); ?></h3></th>
316
- </tr>
317
-
318
- <tr valign="top">
319
- <th scope="row">
320
- <label for="chart-totals"><?php _e('Include totals', 'wp_statistics'); ?>:</label>
321
- </th>
322
-
323
- <td>
324
- <input id="chart-totals" type="checkbox" value="1" name="wps_chart_totals" <?php echo $WP_Statistics->get_option('chart_totals')==true? "checked='checked'":'';?>>
325
- <label for="chart-totals"><?php _e('Active', 'wp_statistics'); ?></label>
326
- <p class="description"><?php _e('Add a total line to charts with multiple values, like the search engine referrals', 'wp_statistics'); ?></p>
327
- </td>
328
- </tr>
329
-
330
- <tr valign="top">
331
- <th scope="row" colspan="2"><h3><?php _e('Languages', 'wp_statistics'); ?></h3></th>
332
- </tr>
333
-
334
- <tr valign="top">
335
- <th scope="row">
336
- <label for="chart-totals"><?php _e('Force English', 'wp_statistics'); ?>:</label>
337
- </th>
338
-
339
- <td>
340
- <input id="override-language" type="checkbox" value="1" name="wps_override_language" <?php echo $WP_Statistics->get_option('override_language')==true? "checked='checked'":'';?>>
341
- <label for="override-language"><?php _e('Active', 'wp_statistics'); ?></label>
342
- <p class="description"><?php _e('Do not use the translations and instead use the English defaults for WP Statistics (requires two page loads)', 'wp_statistics'); ?></p>
343
- </td>
344
- </tr>
345
-
346
- </tbody>
347
- </table>
348
-
349
- <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>
1
+ <?php
2
+ $selist = wp_statistics_searchengine_list( true );
3
+ $permalink = get_option( 'permalink_structure' );
 
 
4
  $disable_strip_uri_parameters = false;
5
+
6
+ if ( $permalink == '' || strpos( $permalink, '?' ) !== false ) {
7
  $disable_strip_uri_parameters = true;
8
  }
9
 
10
+ if ( $wps_nonce_valid ) {
11
+ foreach ( $selist as $se ) {
12
  $se_post = 'wps_disable_se_' . $se['tag'];
13
+
14
+ if ( array_key_exists( $se_post, $_POST ) ) {
15
+ $value = $_POST[ $se_post ];
16
+ } else {
17
+ $value = '';
18
+ }
19
  $new_option = str_replace( "wps_", "", $se_post );
20
+ $WP_Statistics->store_option( $new_option, $value );
21
  }
22
 
23
+ $wps_option_list = array(
24
+ 'wps_useronline',
25
+ 'wps_visits',
26
+ 'wps_visitors',
27
+ 'wps_pages',
28
+ 'wps_track_all_pages',
29
+ 'wps_disable_column',
30
+ 'wps_check_online',
31
+ 'wps_menu_bar',
32
+ 'wps_coefficient',
33
+ 'wps_chart_totals',
34
+ 'wps_store_ua',
35
+ 'wps_hide_notices',
36
+ 'wps_hash_ips',
37
+ 'wps_all_online',
38
+ 'wps_strip_uri_parameters',
39
+ 'wps_override_language',
40
+ 'wps_addsearchwords'
41
+ );
42
+
43
  // If the IP hash's are enabled, disable storing the complete user agent.
44
+ if ( array_key_exists( 'wps_hash_ips', $_POST ) ) {
45
+ $_POST['wps_store_ua'] = '';
 
 
 
 
 
 
 
46
  }
47
 
48
+ // We need to check the permalink format for the strip_uri_parameters option, if the permalink is the default or contains uri parameters, we can't strip them.
49
+ if ( $disable_strip_uri_parameters ) {
50
+ $_POST['wps_strip_uri_parameters'] = '';
 
 
51
  }
 
 
52
 
53
+ foreach ( $wps_option_list as $option ) {
54
+ if ( array_key_exists( $option, $_POST ) ) {
55
+ $value = $_POST[ $option ];
56
+ } else {
57
+ $value = '';
58
+ }
59
+ $new_option = str_replace( "wps_", "", $option );
60
+ $WP_Statistics->store_option( $new_option, $value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
+ }
63
  ?>
64
+ <script type="text/javascript">
65
+ function ToggleStatOptions() {
66
+ jQuery('[id^="wps_stats_report_option"]').fadeToggle();
67
+ }
68
+ </script>
69
+
70
+ <table class="form-table">
71
+ <tbody>
72
+ <tr valign="top">
73
+ <th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp_statistics' ); ?></h3></th>
74
+ </tr>
75
+
76
+ <tr valign="top">
77
+ <th scope="row">
78
+ <label for="useronline"><?php _e( 'Hash IP Addresses', 'wp_statistics' ); ?>:</label>
79
+ </th>
80
+
81
+ <td>
82
+ <input id="hash_ips" type="checkbox" value="1" name="wps_hash_ips" <?php echo $WP_Statistics->get_option( 'hash_ips' ) == true ? "checked='checked'" : ''; ?>>
83
+ <label for="hash_ips"><?php _e( 'Active', 'wp_statistics' ); ?></label>
84
+ <p class="description"><?php _e( 'This feature will not store IP addresses in the database but instead used a unique hash. The "Store entire user agent string" setting will be disabled if this is selected. You will not be able to recover the IP addresses in the future to recover location information if this is enabled.', 'wp_statistics' ); ?></p>
85
+ </td>
86
+ </tr>
87
+
88
+ <tr valign="top">
89
+ <th scope="row" colspan="2"><h3><?php _e( 'Users Online', 'wp_statistics' ); ?></h3></th>
90
+ </tr>
91
+
92
+ <tr valign="top">
93
+ <th scope="row">
94
+ <label for="useronline"><?php _e( 'User online', 'wp_statistics' ); ?>:</label>
95
+ </th>
96
+
97
+ <td>
98
+ <input id="useronline" type="checkbox" value="1" name="wps_useronline" <?php echo $WP_Statistics->get_option( 'useronline' ) == true ? "checked='checked'" : ''; ?>>
99
+ <label for="useronline"><?php _e( 'Active', 'wp_statistics' ); ?></label>
100
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
101
+ </td>
102
+ </tr>
103
+
104
+ <tr valign="top">
105
+ <th scope="row">
106
+ <label for="check_online"><?php _e( 'Check for online users every', 'wp_statistics' ); ?>:</label>
107
+ </th>
108
+
109
+ <td>
110
+ <input type="text" class="small-text code" id="check_online" name="wps_check_online" value="<?php echo htmlentities( $WP_Statistics->get_option( 'check_online' ), ENT_QUOTES ); ?>"/>
111
+ <?php _e( 'Second', 'wp_statistics' ); ?>
112
+ <p class="description"><?php echo sprintf( __( 'Time for the check accurate online user in the site. Now: %s Second', 'wp_statistics' ), $WP_Statistics->get_option( 'check_online' ) ); ?></p>
113
+ </td>
114
+ </tr>
115
+
116
+ <tr valign="top">
117
+ <th scope="row">
118
+ <label for="useronline"><?php _e( 'Record all user', 'wp_statistics' ); ?>:</label>
119
+ </th>
120
+
121
+ <td>
122
+ <input id="allonline" type="checkbox" value="1" name="wps_all_online" <?php echo $WP_Statistics->get_option( 'all_online' ) == true ? "checked='checked'" : ''; ?>>
123
+ <label for="allonline"><?php _e( 'Active', 'wp_statistics' ); ?></label>
124
+ <p class="description"><?php _e( 'Ignores the exclusion settings and records all users that are online (including self referrals and robots). Should only be used for troubleshooting.', 'wp_statistics' ); ?></p>
125
+ </td>
126
+ </tr>
127
+
128
+ <tr valign="top">
129
+ <th scope="row" colspan="2"><h3><?php _e( 'Visits', 'wp_statistics' ); ?></h3></th>
130
+ </tr>
131
+
132
+ <tr valign="top">
133
+ <th scope="row">
134
+ <label for="visits"><?php _e( 'Visits', 'wp_statistics' ); ?>:</label>
135
+ </th>
136
+
137
+ <td>
138
+ <input id="visits" type="checkbox" value="1" name="wps_visits" <?php echo $WP_Statistics->get_option( 'visits' ) == true ? "checked='checked'" : ''; ?>>
139
+ <label for="visits"><?php _e( 'Active', 'wp_statistics' ); ?></label>
140
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
141
+ </td>
142
+ </tr>
143
+
144
+ <tr valign="top">
145
+ <th scope="row" colspan="2"><h3><?php _e( 'Visitors', 'wp_statistics' ); ?></h3></th>
146
+ </tr>
147
+
148
+ <tr valign="top">
149
+ <th scope="row">
150
+ <label for="visitors"><?php _e( 'Visitors', 'wp_statistics' ); ?>:</label>
151
+ </th>
152
+
153
+ <td>
154
+ <input id="visitors" type="checkbox" value="1" name="wps_visitors" <?php echo $WP_Statistics->get_option( 'visitors' ) == true ? "checked='checked'" : ''; ?>>
155
+ <label for="visitors"><?php _e( 'Active', 'wp_statistics' ); ?></label>
156
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
157
+ </td>
158
+ </tr>
159
+
160
+ <tr valign="top">
161
+ <th scope="row">
162
+ <label for="visitors"><?php _e( 'Store entire user agent string', 'wp_statistics' ); ?>:</label>
163
+ </th>
164
+
165
+ <td>
166
+ <input id="store_ua" type="checkbox" value="1" name="wps_store_ua" <?php echo $WP_Statistics->get_option( 'store_ua' ) == true ? "checked='checked'" : ''; ?>>
167
+ <label for="store_ua"><?php _e( 'Active', 'wp_statistics' ); ?></label>
168
+ <p class="description"><?php _e( 'Only enabled for debugging', 'wp_statistics' ); ?></p>
169
+ </td>
170
+ </tr>
171
+
172
+ <tr valign="top">
173
+ <th scope="row">
174
+ <label for="coefficient"><?php _e( 'Coefficient per visitor', 'wp_statistics' ); ?>:</label>
175
+ </th>
176
+
177
+ <td>
178
+ <input type="text" class="small-text code" id="coefficient" name="wps_coefficient" value="<?php echo htmlentities( $WP_Statistics->get_option( 'coefficient' ), ENT_QUOTES ); ?>"/>
179
+ <p class="description"><?php echo sprintf( __( 'For each visit to account for several hits. Currently %s.', 'wp_statistics' ), $WP_Statistics->get_option( 'coefficient' ) ); ?></p>
180
+ </td>
181
+ </tr>
182
+
183
+ <tr valign="top">
184
+ <th scope="row" colspan="2"><h3><?php _e( 'Pages', 'wp_statistics' ); ?></h3></th>
185
+ </tr>
186
+
187
+ <tr valign="top">
188
+ <th scope="row">
189
+ <label for="pages"><?php _e( 'Pages', 'wp_statistics' ); ?>:</label>
190
+ </th>
191
+
192
+ <td>
193
+ <input id="pages" type="checkbox" value="1" name="wps_pages" <?php echo $WP_Statistics->get_option( 'pages' ) == true ? "checked='checked'" : ''; ?>>
194
+ <label for="pages"><?php _e( 'Active', 'wp_statistics' ); ?></label>
195
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
196
+ </td>
197
+ </tr>
198
+
199
+ <tr valign="top">
200
+ <th scope="row">
201
+ <label for="pages"><?php _e( 'Track all pages', 'wp_statistics' ); ?>:</label>
202
+ </th>
203
+
204
+ <td>
205
+ <input id="all_pages" type="checkbox" value="1" name="wps_track_all_pages" <?php echo $WP_Statistics->get_option( 'track_all_pages' ) == true ? "checked='checked'" : ''; ?>>
206
+ <label for="all_pages"><?php _e( 'Active', 'wp_statistics' ); ?></label>
207
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
208
+ </td>
209
+ </tr>
210
+
211
  <?php
212
+ if ( ! $disable_strip_uri_parameters ) {
213
+ ?>
214
+ <tr valign="top">
215
+ <th scope="row">
216
+ <label for="pages"><?php _e( 'Strip parameters from URI', 'wp_statistics' ); ?>:</label>
217
+ </th>
218
+
219
+ <td>
220
+ <input id="strip_uri_parameters" type="checkbox" value="1" name="wps_strip_uri_parameters" <?php echo $WP_Statistics->get_option( 'strip_uri_parameters' ) == true ? "checked='checked'" : ''; ?>>
221
+ <label for="strip_uri_parameters"><?php _e( 'Active', 'wp_statistics' ); ?></label>
222
+ <p class="description"><?php _e( 'This will remove anything after the ? in a URL.', 'wp_statistics' ); ?></p>
223
+ </td>
224
+ </tr>
225
+ <?php
226
+ }
227
  ?>
228
+ <tr valign="top">
229
+ <th scope="row">
230
+ <label for="pages"><?php _e( 'Disable hits column in post/pages list', 'wp_statistics' ); ?>:</label>
231
+ </th>
232
+
233
+ <td>
234
+ <input id="disable_column" type="checkbox" value="1" name="wps_disable_column" <?php echo $WP_Statistics->get_option( 'disable_column' ) == true ? "checked='checked'" : ''; ?>>
235
+ <label for="disable_column"><?php _e( 'Active', 'wp_statistics' ); ?></label>
236
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
237
+ </td>
238
+ </tr>
239
+
240
+ <tr valign="top">
241
+ <th scope="row" colspan="2"><h3><?php _e( 'Miscellaneous', 'wp_statistics' ); ?></h3></th>
242
+ </tr>
243
+
244
+ <tr valign="top">
245
+ <th scope="row">
246
+ <label for="menu-bar"><?php _e( 'Show stats in menu bar', 'wp_statistics' ); ?>:</label>
247
+ </th>
248
+
249
+ <td>
250
+ <select name="wps_menu_bar" id="menu-bar">
251
+ <option value="0" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '0' ); ?>><?php _e( 'No', 'wp_statistics' ); ?></option>
252
+ <option value="1" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '1' ); ?>><?php _e( 'Yes', 'wp_statistics' ); ?></option>
253
+ </select>
254
+ <p class="description"><?php _e( 'Show stats in admin menu bar', 'wp_statistics' ); ?></p>
255
+ </td>
256
+ </tr>
257
+
258
+ <tr valign="top">
259
+ <th scope="row">
260
+ <label for="hide_notices"><?php _e( 'Hide admin notices about non active features', 'wp_statistics' ); ?>
261
+ :</label>
262
+ </th>
263
+
264
+ <td>
265
+ <input id="hide_notices" type="checkbox" value="1" name="wps_hide_notices" <?php echo $WP_Statistics->get_option( 'hide_notices' ) == true ? "checked='checked'" : ''; ?>>
266
+ <label for="store_ua"><?php _e( 'Active', 'wp_statistics' ); ?></label>
267
+ <p class="description"><?php _e( 'By default WP Statistics displays an alert if any of the core features are disabled on every admin page, this option will disable these notices.', 'wp_statistics' ); ?></p>
268
+ </td>
269
+ </tr>
270
+
271
+ <tr valign="top">
272
+ <th scope="row" colspan="2"><h3><?php _e( 'Search Engines', 'wp_statistics' ); ?></h3></th>
273
+ </tr>
274
+
275
+ <tr valign="top">
276
+ <th scope="row">
277
+ <label for="hide_notices"><?php _e( 'Add page title to empty search words', 'wp_statistics' ); ?>
278
+ :</label>
279
+ </th>
280
+
281
+ <td>
282
+ <input id="addsearchwords" type="checkbox" value="1" name="wps_addsearchwords" <?php echo $WP_Statistics->get_option( 'addsearchwords' ) == true ? "checked='checked'" : ''; ?>>
283
+ <label for="addsearchwords"><?php _e( 'Active', 'wp_statistics' ); ?></label>
284
+ <p class="description"><?php _e( 'If a search engine is identified as the referrer but it does not include the search query this option will substitute the page title in quotes preceded by "~:" as the search query to help identify what the user may have been searching for.', 'wp_statistics' ); ?></p>
285
+ </td>
286
+ </tr>
287
+
288
+ <tr valign="top">
289
+ <th scope="row" colspan="2">
290
+ <p class="description"><?php _e( 'Disabling all search engines is not allowed, doing so will result in all search engines being active.', 'wp_statistics' ); ?></p>
291
+ </th>
292
+ </tr>
293
+ <?php
294
+ $se_option_list = '';
295
+
296
+ foreach ( $selist as $se ) {
297
+ $option_name = 'wps_disable_se_' . $se['tag'];
298
+ $store_name = 'disable_se_' . $se['tag'];
299
+ $se_option_list .= $option_name . ',';
300
+ ?>
301
+
302
+ <tr valign="top">
303
+ <th scope="row"><label for="<?php echo $option_name; ?>"><?php _e( $se['name'], 'wp_statistics' ); ?>
304
+ :</label></th>
305
+ <td>
306
+ <input id="<?php echo $option_name; ?>" type="checkbox" value="1" name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true ? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e( 'disable', 'wp_statistics' ); ?></label>
307
+ <p class="description"><?php echo sprintf( __( 'Disable %s from data collection and reporting.', 'wp_statistics' ), $se['name'] ); ?></p>
308
+ </td>
309
+ </tr>
310
  <?php } ?>
311
 
312
+ <tr valign="top">
313
+ <th scope="row" colspan="2"><h3><?php _e( 'Charts', 'wp_statistics' ); ?></h3></th>
314
+ </tr>
315
+
316
+ <tr valign="top">
317
+ <th scope="row">
318
+ <label for="chart-totals"><?php _e( 'Include totals', 'wp_statistics' ); ?>:</label>
319
+ </th>
320
+
321
+ <td>
322
+ <input id="chart-totals" type="checkbox" value="1" name="wps_chart_totals" <?php echo $WP_Statistics->get_option( 'chart_totals' ) == true ? "checked='checked'" : ''; ?>>
323
+ <label for="chart-totals"><?php _e( 'Active', 'wp_statistics' ); ?></label>
324
+ <p class="description"><?php _e( 'Add a total line to charts with multiple values, like the search engine referrals', 'wp_statistics' ); ?></p>
325
+ </td>
326
+ </tr>
327
+
328
+ <tr valign="top">
329
+ <th scope="row" colspan="2"><h3><?php _e( 'Languages', 'wp_statistics' ); ?></h3></th>
330
+ </tr>
331
+
332
+ <tr valign="top">
333
+ <th scope="row">
334
+ <label for="chart-totals"><?php _e( 'Force English', 'wp_statistics' ); ?>:</label>
335
+ </th>
336
+
337
+ <td>
338
+ <input id="override-language" type="checkbox" value="1" name="wps_override_language" <?php echo $WP_Statistics->get_option( 'override_language' ) == true ? "checked='checked'" : ''; ?>>
339
+ <label for="override-language"><?php _e( 'Active', 'wp_statistics' ); ?></label>
340
+ <p class="description"><?php _e( 'Do not use the translations and instead use the English defaults for WP Statistics (requires two page loads)', 'wp_statistics' ); ?></p>
341
+ </td>
342
+ </tr>
343
+
344
+ </tbody>
345
+ </table>
346
+
347
+ <?php submit_button( __( 'Update', 'wp_statistics' ), 'primary', 'submit' ); ?>
includes/settings/tabs/wps-maintenance.php CHANGED
@@ -1,88 +1,98 @@
1
- <?php
2
- if( $wps_nonce_valid ) {
3
 
4
- $wps_option_list = array('wps_schedule_dbmaint', 'wps_schedule_dbmaint_days', 'wps_schedule_dbmaint_visitor', 'wps_schedule_dbmaint_visitor_hits');
5
-
6
- foreach( $wps_option_list as $option ) {
 
 
 
 
 
7
  $new_option = str_replace( "wps_", "", $option );
8
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
9
- $WP_Statistics->store_option($new_option, $value);
 
 
 
 
10
  }
11
  }
12
 
13
  ?>
14
- <script type="text/javascript">
15
- function DBMaintWarning() {
16
- var checkbox = jQuery('#wps_schedule_dbmaint');
17
-
18
- if( checkbox.attr('checked') == 'checked' )
19
- {
20
- if(!confirm('<?php _e('This will permanently delete data from the database each day, are you sure you want to enable this option?', 'wp_statistics'); ?>'))
21
- checkbox.attr('checked', false);
22
- }
23
-
24
 
25
- }
26
- </script>
27
- <table class="form-table">
28
- <tbody>
29
- <tr valign="top">
30
- <th scope="row" colspan="2"><h3><?php _e('Purge Old Data Daily', 'wp_statistics'); ?></h3></th>
31
- </tr>
32
-
33
- <tr valign="top">
34
- <th scope="row">
35
- <label for="wps_schedule_dbmaint"><?php _e('Enabled', 'wp_statistics'); ?>:</label>
36
- </th>
37
-
38
- <td>
39
- <input id="wps_schedule_dbmaint" type="checkbox" name="wps_schedule_dbmaint" <?php echo $WP_Statistics->get_option('schedule_dbmaint')==true? "checked='checked'":'';?> onclick='DBMaintWarning();'>
40
- <label for="wps_schedule_dbmaint"><?php _e('Active', 'wp_statistics'); ?></label>
41
- <p class="description"><?php _e('A WP Cron job will be run daily to purge any data older than a set number of days.', 'wp_statistics'); ?></p>
42
- </td>
43
- </tr>
44
-
45
- <tr valign="top">
46
- <th scope="row">
47
- <label for="wps_schedule_dbmaint_days"><?php _e('Purge data older than', 'wp_statistics'); ?>:</label>
48
- </th>
49
-
50
- <td>
51
- <input type="text" class="small-text code" id="wps_schedule_dbmaint_days" name="wps_schedule_dbmaint_days" value="<?php echo htmlentities( $WP_Statistics->get_option('schedule_dbmaint_days', "365"), ENT_QUOTES ); ?>"/>
52
- <?php _e('Days', 'wp_statistics'); ?>
53
- <p class="description"><?php echo __('The number of days to keep statistics for. Minimum value is 30 days. Invalid values will disable the daily maintenance.', 'wp_statistics'); ?></p>
54
- </td>
55
- </tr>
56
-
57
- <tr valign="top">
58
- <th scope="row" colspan="2"><h3><?php _e('Purge High Hit Count Visitors Daily', 'wp_statistics'); ?></h3></th>
59
- </tr>
60
-
61
- <tr valign="top">
62
- <th scope="row">
63
- <label for="wps_schedule_dbmaint_visitor"><?php _e('Enabled', 'wp_statistics'); ?>:</label>
64
- </th>
65
-
66
- <td>
67
- <input id="wps_schedule_dbmaint_visitor" type="checkbox" name="wps_schedule_dbmaint_visitor" <?php echo $WP_Statistics->get_option('schedule_dbmaint_visitor')==true? "checked='checked'":'';?> onclick='DBMaintWarning();'>
68
- <label for="wps_schedule_dbmaint_visitor"><?php _e('Active', 'wp_statistics'); ?></label>
69
- <p class="description"><?php _e('A WP Cron job will be run daily to purge any users statistics data where the user has more than the defined number of hits in a day (aka they are probably a bot).', 'wp_statistics'); ?></p>
70
- </td>
71
- </tr>
72
-
73
- <tr valign="top">
74
- <th scope="row">
75
- <label for="wps_schedule_dbmaint_visitor_hits"><?php _e('Purge visitors with more than', 'wp_statistics'); ?>:</label>
76
- </th>
77
-
78
- <td>
79
- <input type="text" class="small-text code" id="wps_schedule_dbmaint_visitor_hits" name="wps_schedule_dbmaint_visitor_hits" value="<?php echo htmlentities( $WP_Statistics->get_option('schedule_dbmaint_visitor_hits', '50'), ENT_QUOTES ); ?>"/>
80
- <?php _e('Hits', 'wp_statistics'); ?>
81
- <p class="description"><?php echo __('The number of hits required to delete the visitor. Minimum value is 10 hits. Invalid values will disable the daily maintenance.', 'wp_statistics'); ?></p>
82
- </td>
83
- </tr>
84
-
85
- </tbody>
86
- </table>
87
-
88
- <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( $wps_nonce_valid ) {
3
 
4
+ $wps_option_list = array(
5
+ 'wps_schedule_dbmaint',
6
+ 'wps_schedule_dbmaint_days',
7
+ 'wps_schedule_dbmaint_visitor',
8
+ 'wps_schedule_dbmaint_visitor_hits'
9
+ );
10
+
11
+ foreach ( $wps_option_list as $option ) {
12
  $new_option = str_replace( "wps_", "", $option );
13
+ if ( array_key_exists( $option, $_POST ) ) {
14
+ $value = $_POST[ $option ];
15
+ } else {
16
+ $value = '';
17
+ }
18
+ $WP_Statistics->store_option( $new_option, $value );
19
  }
20
  }
21
 
22
  ?>
23
+ <script type="text/javascript">
24
+ function DBMaintWarning() {
25
+ var checkbox = jQuery('#wps_schedule_dbmaint');
 
 
 
 
 
 
 
26
 
27
+ if (checkbox.attr('checked') == 'checked') {
28
+ if (!confirm('<?php _e( 'This will permanently delete data from the database each day, are you sure you want to enable this option?', 'wp_statistics' ); ?>'))
29
+ checkbox.attr('checked', false);
30
+ }
31
+
32
+
33
+ }
34
+ </script>
35
+ <table class="form-table">
36
+ <tbody>
37
+ <tr valign="top">
38
+ <th scope="row" colspan="2"><h3><?php _e( 'Purge Old Data Daily', 'wp_statistics' ); ?></h3></th>
39
+ </tr>
40
+
41
+ <tr valign="top">
42
+ <th scope="row">
43
+ <label for="wps_schedule_dbmaint"><?php _e( 'Enabled', 'wp_statistics' ); ?>:</label>
44
+ </th>
45
+
46
+ <td>
47
+ <input id="wps_schedule_dbmaint" type="checkbox" name="wps_schedule_dbmaint" <?php echo $WP_Statistics->get_option( 'schedule_dbmaint' ) == true ? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
48
+ <label for="wps_schedule_dbmaint"><?php _e( 'Active', 'wp_statistics' ); ?></label>
49
+ <p class="description"><?php _e( 'A WP Cron job will be run daily to purge any data older than a set number of days.', 'wp_statistics' ); ?></p>
50
+ </td>
51
+ </tr>
52
+
53
+ <tr valign="top">
54
+ <th scope="row">
55
+ <label for="wps_schedule_dbmaint_days"><?php _e( 'Purge data older than', 'wp_statistics' ); ?>:</label>
56
+ </th>
57
+
58
+ <td>
59
+ <input type="text" class="small-text code" id="wps_schedule_dbmaint_days" name="wps_schedule_dbmaint_days" value="<?php echo htmlentities( $WP_Statistics->get_option( 'schedule_dbmaint_days', "365" ), ENT_QUOTES ); ?>"/>
60
+ <?php _e( 'Days', 'wp_statistics' ); ?>
61
+ <p class="description"><?php echo __( 'The number of days to keep statistics for. Minimum value is 30 days. Invalid values will disable the daily maintenance.', 'wp_statistics' ); ?></p>
62
+ </td>
63
+ </tr>
64
+
65
+ <tr valign="top">
66
+ <th scope="row" colspan="2"><h3><?php _e( 'Purge High Hit Count Visitors Daily', 'wp_statistics' ); ?></h3>
67
+ </th>
68
+ </tr>
69
+
70
+ <tr valign="top">
71
+ <th scope="row">
72
+ <label for="wps_schedule_dbmaint_visitor"><?php _e( 'Enabled', 'wp_statistics' ); ?>:</label>
73
+ </th>
74
+
75
+ <td>
76
+ <input id="wps_schedule_dbmaint_visitor" type="checkbox" name="wps_schedule_dbmaint_visitor" <?php echo $WP_Statistics->get_option( 'schedule_dbmaint_visitor' ) == true ? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
77
+ <label for="wps_schedule_dbmaint_visitor"><?php _e( 'Active', 'wp_statistics' ); ?></label>
78
+ <p class="description"><?php _e( 'A WP Cron job will be run daily to purge any users statistics data where the user has more than the defined number of hits in a day (aka they are probably a bot).', 'wp_statistics' ); ?></p>
79
+ </td>
80
+ </tr>
81
+
82
+ <tr valign="top">
83
+ <th scope="row">
84
+ <label for="wps_schedule_dbmaint_visitor_hits"><?php _e( 'Purge visitors with more than', 'wp_statistics' ); ?>
85
+ :</label>
86
+ </th>
87
+
88
+ <td>
89
+ <input type="text" class="small-text code" id="wps_schedule_dbmaint_visitor_hits" name="wps_schedule_dbmaint_visitor_hits" value="<?php echo htmlentities( $WP_Statistics->get_option( 'schedule_dbmaint_visitor_hits', '50' ), ENT_QUOTES ); ?>"/>
90
+ <?php _e( 'Hits', 'wp_statistics' ); ?>
91
+ <p class="description"><?php echo __( 'The number of hits required to delete the visitor. Minimum value is 10 hits. Invalid values will disable the daily maintenance.', 'wp_statistics' ); ?></p>
92
+ </td>
93
+ </tr>
94
+
95
+ </tbody>
96
+ </table>
97
+
98
+ <?php submit_button( __( 'Update', 'wp_statistics' ), 'primary', 'submit' ); ?>
includes/settings/tabs/wps-notifications.php CHANGED
@@ -1,201 +1,234 @@
1
- <?php
2
  $selist = wp_statistics_searchengine_list( true );
3
 
4
- if( $wps_nonce_valid ) {
5
 
6
  // We need to handle a change in the report schedule manually, so check to see it has been set.
7
- if( array_key_exists( 'wps_time_report', $_POST ) ) {
8
  // If the report has been changed, we need to update the schedule.
9
- if( $WP_Statistics->get_option('time_report') != $_POST['wps_time_report'] ) {
10
  // Remove the old schedule if it exists.
11
- if( wp_next_scheduled('report_hook') ) {
12
- wp_unschedule_event(wp_next_scheduled('report_hook'), 'report_hook');
13
  }
14
 
15
  // Setup the new schedule, we could just let this fall through and let the code in schedule.php deal with it
16
  // but that would require an extra page load to start the schedule so do it here instead.
17
- wp_schedule_event(time(), $_POST['wps_time_report'], 'report_hook');
18
  }
19
  }
20
 
21
- $wps_option_list = array("wps_stats_report","wps_time_report","wps_send_report","wps_content_report","wps_email_list","wps_browscap_report","wps_geoip_report","wps_prune_report","wps_upgrade_report");
22
-
23
- foreach( $wps_option_list as $option ) {
24
- if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  // WordPress escapes form data no matter what the setting of magic quotes is in PHP (http://www.theblog.ca/wordpress-addslashes-magic-quotes).
27
- $value = stripslashes($value);
28
-
29
  $new_option = str_replace( "wps_", "", $option );
30
- $WP_Statistics->store_option($new_option, $value);
31
  }
32
  }
33
 
34
  ?>
35
- <script type="text/javascript">
36
- function ToggleStatOptions() {
37
- jQuery('[id^="wps_stats_report_option"]').fadeToggle();
38
- }
39
- </script>
40
-
41
- <table class="form-table">
42
- <tbody>
43
- <tr valign="top">
44
- <th scope="row" colspan="2"><h3><?php _e('Common Report Options', 'wp_statistics'); ?></h3></th>
45
- </tr>
46
-
47
- <tr valign="top">
48
- <td scope="row" style="vertical-align: top;">
49
- <label for="email-report"><?php _e('E-mail addresses', 'wp_statistics'); ?>:</label>
50
- </td>
51
-
52
- <td>
53
- <input type="text" id="email_list" name="wps_email_list" size="30" value="<?php if( $WP_Statistics->get_option('email_list') == '' ) { $WP_Statistics->store_option('email_list', get_bloginfo('admin_email')); } echo htmlentities( $WP_Statistics->get_option('email_list'), ENT_QUOTES ); ?>"/>
54
- <p class="description"><?php _e('A comma separated list of e-mail addresses to send reports to.', 'wp_statistics'); ?></p>
55
- </td>
56
- </tr>
57
-
58
- <tr valign="top">
59
- <th scope="row" colspan="2"><h3><?php _e('Update Reports', 'wp_statistics'); ?></h3></th>
60
- </tr>
61
-
62
- <tr valign="top">
63
- <td scope="row">
64
- <label for="browscap-report"><?php _e('Browscap', 'wp_statistics'); ?>:</label>
65
- </td>
66
-
67
- <td>
68
- <input id="browscap-report" type="checkbox" value="1" name="wps_browscap_report" <?php echo $WP_Statistics->get_option('browscap_report')==true? "checked='checked'":'';?>>
69
- <label for="browscap-report"><?php _e('Active', 'wp_statistics'); ?></label>
70
- <p class="description"><?php _e('Send a report whenever the browscap.ini is updated.', 'wp_statistics'); ?></p>
71
- </td>
72
- </tr>
73
-
74
- <tr valign="top">
75
- <td scope="row">
76
- <label for="geoip-report"><?php _e('GeoIP', 'wp_statistics'); ?>:</label>
77
- </td>
78
-
79
- <td>
80
- <input id="geoip-report" type="checkbox" value="1" name="wps_geoip_report" <?php echo $WP_Statistics->get_option('geoip_report')==true? "checked='checked'":'';?>>
81
- <label for="geoip-report"><?php _e('Active', 'wp_statistics'); ?></label>
82
- <p class="description"><?php _e('Send a report whenever the GeoIP database is updated.', 'wp_statistics'); ?></p>
83
- </td>
84
- </tr>
85
-
86
- <tr valign="top">
87
- <td scope="row">
88
- <label for="prune-report"><?php _e('Pruning', 'wp_statistics'); ?>:</label>
89
- </td>
90
-
91
- <td>
92
- <input id="prune-report" type="checkbox" value="1" name="wps_prune_report" <?php echo $WP_Statistics->get_option('prune_report')==true? "checked='checked'":'';?>>
93
- <label for="prune-report"><?php _e('Active', 'wp_statistics'); ?></label>
94
- <p class="description"><?php _e('Send a report whenever the pruning of database is run.', 'wp_statistics'); ?></p>
95
- </td>
96
- </tr>
97
-
98
- <tr valign="top">
99
- <td scope="row">
100
- <label for="upgrade-report"><?php _e('Upgrade', 'wp_statistics'); ?>:</label>
101
- </td>
102
-
103
- <td>
104
- <input id="upgrade-report" type="checkbox" value="1" name="wps_upgrade_report" <?php echo $WP_Statistics->get_option('upgrade_report')==true? "checked='checked'":'';?>>
105
- <label for="upgrade-report"><?php _e('Active', 'wp_statistics'); ?></label>
106
- <p class="description"><?php _e('Send a report whenever the plugin is upgraded.', 'wp_statistics'); ?></p>
107
- </td>
108
- </tr>
109
-
110
- <tr valign="top">
111
- <th scope="row" colspan="2"><h3><?php _e('Statistical reporting', 'wp_statistics'); ?></h3></th>
112
- </tr>
113
-
114
- <tr valign="top">
115
- <th scope="row">
116
- <label for="stats-report"><?php _e('Statistical reporting', 'wp_statistics'); ?>:</label>
117
- </th>
118
-
119
- <td>
120
- <input id="stats-report" type="checkbox" value="1" name="wps_stats_report" <?php echo $WP_Statistics->get_option('stats_report')==true? "checked='checked'":'';?> onClick='ToggleStatOptions();'>
121
- <label for="stats-report"><?php _e('Active', 'wp_statistics'); ?></label>
122
- <p class="description"><?php _e('Enable or disable this feature', 'wp_statistics'); ?></p>
123
- </td>
124
- </tr>
125
-
126
- <?php if( $WP_Statistics->get_option('stats_report') ) { $hidden=""; } else { $hidden=" style='display: none;'"; }?>
127
- <tr valign="top"<?php echo $hidden;?> id='wps_stats_report_option'>
128
- <td scope="row" style="vertical-align: top;">
129
- <label for="time-report"><?php _e('Schedule', 'wp_statistics'); ?>:</label>
130
- </td>
131
-
132
- <td>
133
- <select name="wps_time_report" id="time-report">
134
- <option value="0" <?php selected($WP_Statistics->get_option('time_report'), '0'); ?>><?php _e('Please select', 'wp_statistics'); ?></option>
135
- <?php
 
 
 
 
 
 
 
136
  function wp_statistics_schedule_sort( $a, $b ) {
137
- if ($a['interval'] == $b['interval']) {
138
  return 0;
139
- }
140
-
141
- return ($a['interval'] < $b['interval']) ? -1 : 1;
142
  }
143
-
144
  $schedules = wp_get_schedules();
145
-
146
  uasort( $schedules, 'wp_statistics_schedule_sort' );
147
-
148
- foreach( $schedules as $key => $value ) {
149
- echo ' <option value="' . $key . '" ' . selected($WP_Statistics->get_option('time_report'), $key) . '>' . $value['display'] . '</option>';
150
  }
151
- ?>
152
- </select>
153
- <p class="description"><?php _e('Select how often to receive statistical report.', 'wp_statistics'); ?></p>
154
- </td>
155
- </tr>
156
-
157
- <tr valign="top"<?php echo $hidden;?> id='wps_stats_report_option'>
158
- <td scope="row" style="vertical-align: top;">
159
- <label for="send-report"><?php _e('Send reports via', 'wp_statistics'); ?>:</label>
160
- </td>
161
-
162
- <td>
163
- <select name="wps_send_report" id="send-report">
164
- <option value="0" <?php selected($WP_Statistics->get_option('send_report'), '0'); ?>><?php _e('Please select', 'wp_statistics'); ?></option>
165
- <option value="mail" <?php selected($WP_Statistics->get_option('send_report'), 'mail'); ?>><?php _e('Email', 'wp_statistics'); ?></option>
166
- <?php if( is_plugin_active('wp-sms/wp-sms.php') || is_plugin_active('wp-sms-pro/wp-sms.php') ) { ?>
167
- <option value="sms" <?php selected($WP_Statistics->get_option('send_report'), 'sms'); ?>><?php _e('SMS', 'wp_statistics'); ?></option>
168
- <?php } ?>
169
- </select>
170
- <p class="description"><?php _e('Select delivery method for statistical report.', 'wp_statistics'); ?></p>
171
-
172
- <?php if( !is_plugin_active('wp-sms/wp-sms.php') ) { ?>
173
- <p class="description note"><?php echo sprintf(__('Note: To send SMS text messages please install the %s plugin.', 'wp_statistics'), '<a href="http://wordpress.org/extend/plugins/wp-sms/" target="_blank">' . __('WordPress SMS', 'wp_statistics') . '</a>'); ?></p>
1
+ <?php
2
  $selist = wp_statistics_searchengine_list( true );
3
 
4
+ if ( $wps_nonce_valid ) {
5
 
6
  // We need to handle a change in the report schedule manually, so check to see it has been set.
7
+ if ( array_key_exists( 'wps_time_report', $_POST ) ) {
8
  // If the report has been changed, we need to update the schedule.
9
+ if ( $WP_Statistics->get_option( 'time_report' ) != $_POST['wps_time_report'] ) {
10
  // Remove the old schedule if it exists.
11
+ if ( wp_next_scheduled( 'report_hook' ) ) {
12
+ wp_unschedule_event( wp_next_scheduled( 'report_hook' ), 'report_hook' );
13
  }
14
 
15
  // Setup the new schedule, we could just let this fall through and let the code in schedule.php deal with it
16
  // but that would require an extra page load to start the schedule so do it here instead.
17
+ wp_schedule_event( time(), $_POST['wps_time_report'], 'report_hook' );
18
  }
19
  }
20
 
21
+ $wps_option_list = array(
22
+ "wps_stats_report",
23
+ "wps_time_report",
24
+ "wps_send_report",
25
+ "wps_content_report",
26
+ "wps_email_list",
27
+ "wps_browscap_report",
28
+ "wps_geoip_report",
29
+ "wps_prune_report",
30
+ "wps_upgrade_report"
31
+ );
32
+
33
+ foreach ( $wps_option_list as $option ) {
34
+ if ( array_key_exists( $option, $_POST ) ) {
35
+ $value = $_POST[ $option ];
36
+ } else {
37
+ $value = '';
38
+ }
39
 
40
  // WordPress escapes form data no matter what the setting of magic quotes is in PHP (http://www.theblog.ca/wordpress-addslashes-magic-quotes).
41
+ $value = stripslashes( $value );
42
+
43
  $new_option = str_replace( "wps_", "", $option );
44
+ $WP_Statistics->store_option( $new_option, $value );
45
  }
46
  }
47
 
48
  ?>
49
+ <script type="text/javascript">
50
+ function ToggleStatOptions() {
51
+ jQuery('[id^="wps_stats_report_option"]').fadeToggle();
52
+ }
53
+ </script>
54
+
55
+ <table class="form-table">
56
+ <tbody>
57
+ <tr valign="top">
58
+ <th scope="row" colspan="2"><h3><?php _e( 'Common Report Options', 'wp_statistics' ); ?></h3></th>
59
+ </tr>
60
+
61
+ <tr valign="top">
62
+ <td scope="row" style="vertical-align: top;">
63
+ <label for="email-report"><?php _e( 'E-mail addresses', 'wp_statistics' ); ?>:</label>
64
+ </td>
65
+
66
+ <td>
67
+ <input type="text" id="email_list" name="wps_email_list" size="30" value="<?php if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
68
+ $WP_Statistics->store_option( 'email_list', get_bloginfo( 'admin_email' ) );
69
+ }
70
+ echo htmlentities( $WP_Statistics->get_option( 'email_list' ), ENT_QUOTES ); ?>"/>
71
+ <p class="description"><?php _e( 'A comma separated list of e-mail addresses to send reports to.', 'wp_statistics' ); ?></p>
72
+ </td>
73
+ </tr>
74
+
75
+ <tr valign="top">
76
+ <th scope="row" colspan="2"><h3><?php _e( 'Update Reports', 'wp_statistics' ); ?></h3></th>
77
+ </tr>
78
+
79
+ <tr valign="top">
80
+ <td scope="row">
81
+ <label for="browscap-report"><?php _e( 'Browscap', 'wp_statistics' ); ?>:</label>
82
+ </td>
83
+
84
+ <td>
85
+ <input id="browscap-report" type="checkbox" value="1" name="wps_browscap_report" <?php echo $WP_Statistics->get_option( 'browscap_report' ) == true ? "checked='checked'" : ''; ?>>
86
+ <label for="browscap-report"><?php _e( 'Active', 'wp_statistics' ); ?></label>
87
+ <p class="description"><?php _e( 'Send a report whenever the browscap.ini is updated.', 'wp_statistics' ); ?></p>
88
+ </td>
89
+ </tr>
90
+
91
+ <tr valign="top">
92
+ <td scope="row">
93
+ <label for="geoip-report"><?php _e( 'GeoIP', 'wp_statistics' ); ?>:</label>
94
+ </td>
95
+
96
+ <td>
97
+ <input id="geoip-report" type="checkbox" value="1" name="wps_geoip_report" <?php echo $WP_Statistics->get_option( 'geoip_report' ) == true ? "checked='checked'" : ''; ?>>
98
+ <label for="geoip-report"><?php _e( 'Active', 'wp_statistics' ); ?></label>
99
+ <p class="description"><?php _e( 'Send a report whenever the GeoIP database is updated.', 'wp_statistics' ); ?></p>
100
+ </td>
101
+ </tr>
102
+
103
+ <tr valign="top">
104
+ <td scope="row">
105
+ <label for="prune-report"><?php _e( 'Pruning', 'wp_statistics' ); ?>:</label>
106
+ </td>
107
+
108
+ <td>
109
+ <input id="prune-report" type="checkbox" value="1" name="wps_prune_report" <?php echo $WP_Statistics->get_option( 'prune_report' ) == true ? "checked='checked'" : ''; ?>>
110
+ <label for="prune-report"><?php _e( 'Active', 'wp_statistics' ); ?></label>
111
+ <p class="description"><?php _e( 'Send a report whenever the pruning of database is run.', 'wp_statistics' ); ?></p>
112
+ </td>
113
+ </tr>
114
+
115
+ <tr valign="top">
116
+ <td scope="row">
117
+ <label for="upgrade-report"><?php _e( 'Upgrade', 'wp_statistics' ); ?>:</label>
118
+ </td>
119
+
120
+ <td>
121
+ <input id="upgrade-report" type="checkbox" value="1" name="wps_upgrade_report" <?php echo $WP_Statistics->get_option( 'upgrade_report' ) == true ? "checked='checked'" : ''; ?>>
122
+ <label for="upgrade-report"><?php _e( 'Active', 'wp_statistics' ); ?></label>
123
+ <p class="description"><?php _e( 'Send a report whenever the plugin is upgraded.', 'wp_statistics' ); ?></p>
124
+ </td>
125
+ </tr>
126
+
127
+ <tr valign="top">
128
+ <th scope="row" colspan="2"><h3><?php _e( 'Statistical reporting', 'wp_statistics' ); ?></h3></th>
129
+ </tr>
130
+
131
+ <tr valign="top">
132
+ <th scope="row">
133
+ <label for="stats-report"><?php _e( 'Statistical reporting', 'wp_statistics' ); ?>:</label>
134
+ </th>
135
+
136
+ <td>
137
+ <input id="stats-report" type="checkbox" value="1" name="wps_stats_report" <?php echo $WP_Statistics->get_option( 'stats_report' ) == true ? "checked='checked'" : ''; ?> onClick='ToggleStatOptions();'>
138
+ <label for="stats-report"><?php _e( 'Active', 'wp_statistics' ); ?></label>
139
+ <p class="description"><?php _e( 'Enable or disable this feature', 'wp_statistics' ); ?></p>
140
+ </td>
141
+ </tr>
142
+
143
+ <?php if ( $WP_Statistics->get_option( 'stats_report' ) ) {
144
+ $hidden = "";
145
+ } else {
146
+ $hidden = " style='display: none;'";
147
+ } ?>
148
+ <tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'>
149
+ <td scope="row" style="vertical-align: top;">
150
+ <label for="time-report"><?php _e( 'Schedule', 'wp_statistics' ); ?>:</label>
151
+ </td>
152
+
153
+ <td>
154
+ <select name="wps_time_report" id="time-report">
155
+ <option value="0" <?php selected( $WP_Statistics->get_option( 'time_report' ), '0' ); ?>><?php _e( 'Please select', 'wp_statistics' ); ?></option>
156
+ <?php
157
  function wp_statistics_schedule_sort( $a, $b ) {
158
+ if ( $a['interval'] == $b['interval'] ) {
159
  return 0;
160
+ }
161
+
162
+ return ( $a['interval'] < $b['interval'] ) ? - 1 : 1;
163
  }
164
+
165
  $schedules = wp_get_schedules();
166
+
167
  uasort( $schedules, 'wp_statistics_schedule_sort' );
168
+
169
+ foreach ( $schedules as $key => $value ) {
170
+ echo ' <option value="' . $key . '" ' . selected( $WP_Statistics->get_option( 'time_report' ), $key ) . '>' . $value['display'] . '</option>';
171
  }
172
+ ?>
173
+ </select>
174
+ <p class="description"><?php _e( 'Select how often to receive statistical report.', 'wp_statistics' ); ?></p>
175
+ </td>
176
+ </tr>
177
+
178
+