Version Description
- Improvement: Isolation Browscap cache processes to reduce memory usage.
- Improvement: Include
file.php
andpluggable.php
in GeoIP downloader when is not exists. - Fixed: GeoIP database update problem. Added an alternative server for download database when impossible access to maxmind.com
Download this release
Release Info
Developer | mostafa.s1990 |
Plugin | WP Statistics |
Version | 12.3.5 |
Comparing to | |
See all releases |
Code changes from version 12.3.2 to 12.3.5
- README.md +3 -0
- assets/css/admin.css +1 -11
- assets/images/welcome/{screenshots-1.png → screenshot-hits.png} +0 -0
- assets/images/welcome/screenshot-maxmind-geoip.png +0 -0
- assets/images/welcome/{screenshots-2.png → screenshot-page-dropdown.png} +0 -0
- composer.json +1 -1
- composer.lock +1190 -429
- includes/classes/class-wp-statistics-admin-pages.php +74 -74
- includes/classes/class-wp-statistics-admin.php +177 -130
- includes/classes/class-wp-statistics-ajax.php +96 -96
- includes/classes/class-wp-statistics-dashboard.php +92 -92
- includes/classes/class-wp-statistics-editor.php +58 -58
- includes/classes/class-wp-statistics-frontend.php +24 -63
- includes/classes/class-wp-statistics-geo-ip-hits.php +7 -7
- includes/classes/class-wp-statistics-hits.php +91 -90
- includes/classes/class-wp-statistics-install.php +48 -48
- includes/classes/class-wp-statistics-network-admin.php +52 -52
- includes/classes/class-wp-statistics-pagination.php +50 -52
- includes/classes/class-wp-statistics-schedule.php +77 -77
- includes/classes/class-wp-statistics-shortcode.php +57 -57
- includes/classes/class-wp-statistics-uninstall.php +6 -6
- includes/classes/class-wp-statistics-updates.php +108 -319
- includes/classes/class-wp-statistics-welcome.php +8 -2
- includes/classes/class-wp-statistics-widget.php +173 -173
- includes/classes/class-wp-statistics.php +197 -195
- includes/functions/country-codes.php +1 -1
- includes/functions/export.php +16 -16
- includes/functions/functions.php +201 -201
- includes/functions/purge-hits.php +14 -14
- includes/functions/purge.php +28 -28
- includes/log/all-browsers.php +201 -201
- includes/log/authors.php +161 -161
- includes/log/categories.php +160 -160
- includes/log/exclusions.php +132 -132
- includes/log/hit-statistics.php +125 -125
- includes/log/last-search.php +55 -55
- includes/log/last-visitor.php +54 -54
- includes/log/log.php +99 -98
- includes/log/online.php +41 -41
- includes/log/search-statistics.php +90 -90
- includes/log/searched-phrases.php +61 -61
- includes/log/tags.php +159 -159
- includes/log/top-countries.php +43 -43
- includes/log/top-pages.php +104 -104
- includes/log/top-referring.php +74 -74
- includes/log/top-visitors.php +28 -28
- includes/log/widgets/about.php +14 -14
- includes/log/widgets/browsers.php +45 -45
- includes/log/widgets/countries.php +14 -14
- includes/log/widgets/hits.php +59 -59
- includes/log/widgets/jqv.map.php +26 -26
- includes/log/widgets/page.php +54 -54
- includes/log/widgets/pages.php +8 -8
- includes/log/widgets/quickstats.php +128 -129
- includes/log/widgets/recent.php +12 -12
- includes/log/widgets/referring.php +5 -5
- includes/log/widgets/search.php +69 -69
- includes/log/widgets/searched.phrases.php +6 -6
- includes/log/widgets/summary.php +124 -125
- includes/log/widgets/top.visitors.php +17 -17
- includes/log/widgets/words.php +25 -25
- includes/optimization/tabs/wps-optimization-database.php +74 -74
- includes/optimization/tabs/wps-optimization-export.php +51 -51
- includes/optimization/tabs/wps-optimization-historical.php +44 -44
- includes/optimization/tabs/wps-optimization-purging.php +280 -279
- includes/optimization/tabs/wps-optimization-resources.php +302 -302
- includes/optimization/tabs/wps-optimization-updates.php +41 -41
- includes/optimization/wps-optimization.php +74 -74
- includes/settings/tabs/wps-about.php +79 -78
- includes/settings/tabs/wps-access-level.php +41 -41
- includes/settings/tabs/wps-exclusions.php +217 -217
- includes/settings/tabs/wps-externals.php +205 -205
- includes/settings/tabs/wps-general.php +274 -271
- includes/settings/tabs/wps-maintenance.php +80 -80
- includes/settings/tabs/wps-notifications.php +162 -162
- includes/settings/tabs/wps-overview-display.php +60 -60
- includes/settings/tabs/wps-removal.php +49 -49
- includes/settings/wps-settings.php +46 -46
- includes/templates/plugins.php +66 -66
- includes/templates/postbox.php +27 -27
- includes/templates/{welcome.php → welcomes/last-version.php} +30 -9
- includes/vendor/bin/browscap-php +17 -0
- includes/vendor/bin/browscap-php.bat +4 -0
- includes/vendor/browscap/browscap-php/.gitattributes +1 -3
- includes/vendor/browscap/browscap-php/.gitignore +3 -3
- includes/vendor/browscap/browscap-php/.php_cs +91 -0
- includes/vendor/browscap/browscap-php/.scrutinizer.yml +4 -1
- includes/vendor/browscap/browscap-php/.travis.yml +34 -14
- includes/vendor/browscap/browscap-php/CHANGELOG.md +0 -55
- includes/vendor/browscap/browscap-php/LICENSE +3 -2
- includes/vendor/browscap/browscap-php/README.md +260 -14
- includes/vendor/browscap/browscap-php/bin/browscap-php +41 -0
- includes/vendor/browscap/browscap-php/composer.json +51 -43
- includes/vendor/browscap/browscap-php/phpcs.xml +14 -0
- includes/vendor/browscap/browscap-php/phpunit.xml +0 -15
- includes/vendor/browscap/browscap-php/phpunit.xml.dist +20 -5
- includes/vendor/browscap/browscap-php/{tests/data/buildCache → resources}/.gitkeep +0 -0
- includes/vendor/browscap/browscap-php/src/Browscap.php +251 -0
- includes/vendor/browscap/browscap-php/src/BrowscapUpdater.php +431 -0
- includes/vendor/browscap/browscap-php/src/Cache/BrowscapCache.php +253 -0
- includes/vendor/browscap/browscap-php/src/Cache/BrowscapCacheInterface.php +130 -0
- includes/vendor/browscap/browscap-php/src/Command/CheckUpdateCommand.php +147 -0
- includes/vendor/browscap/browscap-php/src/Command/ConvertCommand.php +165 -0
- includes/vendor/browscap/browscap-php/src/Command/FetchCommand.php +124 -0
- includes/vendor/browscap/browscap-php/src/Command/LogfileCommand.php +527 -0
- includes/vendor/browscap/browscap-php/src/Command/ParserCommand.php +158 -0
- includes/vendor/browscap/browscap-php/src/Command/UpdateCommand.php +162 -0
- includes/vendor/browscap/browscap-php/src/Data/PropertyFormatter.php +96 -0
- includes/vendor/browscap/browscap-php/src/Data/PropertyHolder.php +239 -0
- includes/vendor/browscap/browscap-php/src/Exception.php +56 -0
- includes/vendor/browscap/browscap-php/src/Exception/DomainException.php +47 -0
- includes/vendor/browscap/browscap-php/src/Exception/FetcherException.php +56 -0
- includes/vendor/browscap/browscap-php/src/Exception/FileNotFoundException.php +55 -0
- includes/vendor/browscap/browscap-php/src/Exception/InvalidArgumentException.php +13 -0
README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
# WP Statistics
|
2 |
A free and advanced stats plugin for WordPress
|
3 |
|
1 |
+
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/wp-statistics/wp-statistics.svg)](http://isitmaintained.com/project/wp-statistics/wp-statistics "Average time to resolve an issue")
|
2 |
+
[![Percentage of issues still open](http://isitmaintained.com/badge/open/wp-statistics/wp-statistics.svg)](http://isitmaintained.com/project/wp-statistics/wp-statistics "Percentage of issues still open")
|
3 |
+
|
4 |
# WP Statistics
|
5 |
A free and advanced stats plugin for WordPress
|
6 |
|
assets/css/admin.css
CHANGED
@@ -169,22 +169,12 @@
|
|
169 |
}
|
170 |
|
171 |
/** Other CSS **/
|
172 |
-
.note {
|
173 |
color: #FF0000;
|
174 |
font-size: 11px !important;
|
175 |
font-weight: bold;
|
176 |
}
|
177 |
|
178 |
-
.data {
|
179 |
-
border-top: 1px solid #CFCDCD;
|
180 |
-
font-size: 11px !important;
|
181 |
-
padding: 5px 0 0;
|
182 |
-
}
|
183 |
-
|
184 |
-
.data code {
|
185 |
-
border-radius: 2px 2px 2px 2px;
|
186 |
-
}
|
187 |
-
|
188 |
.wps-center {
|
189 |
text-align: center;
|
190 |
}
|
169 |
}
|
170 |
|
171 |
/** Other CSS **/
|
172 |
+
.wp-statistics-settings .note {
|
173 |
color: #FF0000;
|
174 |
font-size: 11px !important;
|
175 |
font-weight: bold;
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
.wps-center {
|
179 |
text-align: center;
|
180 |
}
|
assets/images/welcome/{screenshots-1.png → screenshot-hits.png}
RENAMED
File without changes
|
assets/images/welcome/screenshot-maxmind-geoip.png
ADDED
Binary file
|
assets/images/welcome/{screenshots-2.png → screenshot-page-dropdown.png}
RENAMED
File without changes
|
composer.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
"geoip2/geoip2": "^2.7.0",
|
4 |
"s1lentium/iptools": "^1.1.0",
|
5 |
"donatj/phpuseragentparser": "^0.9.0",
|
6 |
-
"browscap/browscap-php": "
|
7 |
"erusev/parsedown": "^1.6"
|
8 |
},
|
9 |
"config": {
|
3 |
"geoip2/geoip2": "^2.7.0",
|
4 |
"s1lentium/iptools": "^1.1.0",
|
5 |
"donatj/phpuseragentparser": "^0.9.0",
|
6 |
+
"browscap/browscap-php": "3.1.0",
|
7 |
"erusev/parsedown": "^1.6"
|
8 |
},
|
9 |
"config": {
|
composer.lock
CHANGED
@@ -1,429 +1,1190 @@
|
|
1 |
-
{
|
2 |
-
"_readme": [
|
3 |
-
"This file locks the dependencies of your project to a known state",
|
4 |
-
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
-
"This file is @generated automatically"
|
6 |
-
],
|
7 |
-
"content-hash": "
|
8 |
-
"packages": [
|
9 |
-
{
|
10 |
-
"name": "browscap/browscap-php",
|
11 |
-
"version": "
|
12 |
-
"source": {
|
13 |
-
"type": "git",
|
14 |
-
"url": "https://github.com/browscap/browscap-php.git",
|
15 |
-
"reference": "
|
16 |
-
},
|
17 |
-
"dist": {
|
18 |
-
"type": "zip",
|
19 |
-
"url": "https://api.github.com/repos/browscap/browscap-php/zipball/
|
20 |
-
"reference": "
|
21 |
-
"shasum": ""
|
22 |
-
},
|
23 |
-
"require": {
|
24 |
-
"
|
25 |
-
|
26 |
-
|
27 |
-
"
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
"
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
"
|
73 |
-
"
|
74 |
-
"
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
"
|
84 |
-
"
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
"
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
"
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
"
|
101 |
-
|
102 |
-
"
|
103 |
-
|
104 |
-
|
105 |
-
"
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
"
|
116 |
-
],
|
117 |
-
"
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
"
|
129 |
-
"
|
130 |
-
"
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
"
|
137 |
-
|
138 |
-
"
|
139 |
-
"
|
140 |
-
|
141 |
-
|
142 |
-
"
|
143 |
-
"
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
"
|
149 |
-
"
|
150 |
-
|
151 |
-
"
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
"
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
"
|
180 |
-
"
|
181 |
-
"
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
"
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
"
|
224 |
-
|
225 |
-
"
|
226 |
-
"
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
"
|
236 |
-
"
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
"
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
"
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
"
|
278 |
-
"
|
279 |
-
"
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
"
|
286 |
-
|
287 |
-
"
|
288 |
-
"
|
289 |
-
"
|
290 |
-
},
|
291 |
-
"
|
292 |
-
"
|
293 |
-
"
|
294 |
-
"
|
295 |
-
|
296 |
-
|
297 |
-
"
|
298 |
-
"
|
299 |
-
|
300 |
-
|
301 |
-
},
|
302 |
-
"
|
303 |
-
|
304 |
-
"
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
"
|
318 |
-
|
319 |
-
|
320 |
-
"
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
"
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
"
|
340 |
-
"
|
341 |
-
"
|
342 |
-
"
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
"
|
350 |
-
"
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
},
|
356 |
-
"
|
357 |
-
|
358 |
-
"
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
"
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
"
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
"
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
"
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
"
|
411 |
-
"
|
412 |
-
|
413 |
-
|
414 |
-
"
|
415 |
-
"
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"content-hash": "a78ff495b1ab570d41df716b5cd5526f",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "browscap/browscap-php",
|
11 |
+
"version": "3.1.0",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/browscap/browscap-php.git",
|
15 |
+
"reference": "d46c0cf6d0a3d7dea895dc2c97a0ec374a89bbd9"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/browscap/browscap-php/zipball/d46c0cf6d0a3d7dea895dc2c97a0ec374a89bbd9",
|
20 |
+
"reference": "d46c0cf6d0a3d7dea895dc2c97a0ec374a89bbd9",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"require": {
|
24 |
+
"guzzlehttp/guzzle": "^6.2",
|
25 |
+
"mimmi20/wurflcache": "^1.3",
|
26 |
+
"monolog/monolog": "^1.7",
|
27 |
+
"php": "^5.6 || ^7.0",
|
28 |
+
"symfony/console": "^2.6 || ^3.0",
|
29 |
+
"symfony/filesystem": "^2.6 || ^3.0",
|
30 |
+
"symfony/finder": "^2.6 || ^3.0"
|
31 |
+
},
|
32 |
+
"require-dev": {
|
33 |
+
"friendsofphp/php-cs-fixer": "^1.11",
|
34 |
+
"mikey179/vfsstream": "^1.6",
|
35 |
+
"phpunit/phpunit": "^5.3",
|
36 |
+
"squizlabs/php_codesniffer": "^2.5"
|
37 |
+
},
|
38 |
+
"suggest": {
|
39 |
+
"ext-curl": "to use curl requests to get the ini file"
|
40 |
+
},
|
41 |
+
"bin": [
|
42 |
+
"bin/browscap-php"
|
43 |
+
],
|
44 |
+
"type": "library",
|
45 |
+
"autoload": {
|
46 |
+
"psr-4": {
|
47 |
+
"BrowscapPHP\\": "src/"
|
48 |
+
}
|
49 |
+
},
|
50 |
+
"notification-url": "https://packagist.org/downloads/",
|
51 |
+
"license": [
|
52 |
+
"MIT"
|
53 |
+
],
|
54 |
+
"authors": [
|
55 |
+
{
|
56 |
+
"name": "Jonathan Stoppani",
|
57 |
+
"email": "jonathan.stoppani@gmail.com"
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"name": "Thomas Mueller",
|
61 |
+
"email": "t_mueller_stolzenhain@yahoo.de"
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"name": "James Titcumb",
|
65 |
+
"email": "james@asgrim.com"
|
66 |
+
}
|
67 |
+
],
|
68 |
+
"description": "Standalone replacement for php's native get_browser() function",
|
69 |
+
"homepage": "https://github.com/browscap/browscap-php",
|
70 |
+
"keywords": [
|
71 |
+
"browser",
|
72 |
+
"capabilities",
|
73 |
+
"get_browser",
|
74 |
+
"user agent"
|
75 |
+
],
|
76 |
+
"time": "2017-03-28T13:29:55+00:00"
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"name": "composer/ca-bundle",
|
80 |
+
"version": "1.1.0",
|
81 |
+
"source": {
|
82 |
+
"type": "git",
|
83 |
+
"url": "https://github.com/composer/ca-bundle.git",
|
84 |
+
"reference": "943b2c4fcad1ef178d16a713c2468bf7e579c288"
|
85 |
+
},
|
86 |
+
"dist": {
|
87 |
+
"type": "zip",
|
88 |
+
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/943b2c4fcad1ef178d16a713c2468bf7e579c288",
|
89 |
+
"reference": "943b2c4fcad1ef178d16a713c2468bf7e579c288",
|
90 |
+
"shasum": ""
|
91 |
+
},
|
92 |
+
"require": {
|
93 |
+
"ext-openssl": "*",
|
94 |
+
"ext-pcre": "*",
|
95 |
+
"php": "^5.3.2 || ^7.0"
|
96 |
+
},
|
97 |
+
"require-dev": {
|
98 |
+
"phpunit/phpunit": "^4.8.35",
|
99 |
+
"psr/log": "^1.0",
|
100 |
+
"symfony/process": "^2.5 || ^3.0 || ^4.0"
|
101 |
+
},
|
102 |
+
"type": "library",
|
103 |
+
"extra": {
|
104 |
+
"branch-alias": {
|
105 |
+
"dev-master": "1.x-dev"
|
106 |
+
}
|
107 |
+
},
|
108 |
+
"autoload": {
|
109 |
+
"psr-4": {
|
110 |
+
"Composer\\CaBundle\\": "src"
|
111 |
+
}
|
112 |
+
},
|
113 |
+
"notification-url": "https://packagist.org/downloads/",
|
114 |
+
"license": [
|
115 |
+
"MIT"
|
116 |
+
],
|
117 |
+
"authors": [
|
118 |
+
{
|
119 |
+
"name": "Jordi Boggiano",
|
120 |
+
"email": "j.boggiano@seld.be",
|
121 |
+
"homepage": "http://seld.be"
|
122 |
+
}
|
123 |
+
],
|
124 |
+
"description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
|
125 |
+
"keywords": [
|
126 |
+
"cabundle",
|
127 |
+
"cacert",
|
128 |
+
"certificate",
|
129 |
+
"ssl",
|
130 |
+
"tls"
|
131 |
+
],
|
132 |
+
"time": "2017-11-29T09:37:33+00:00"
|
133 |
+
},
|
134 |
+
{
|
135 |
+
"name": "donatj/phpuseragentparser",
|
136 |
+
"version": "v0.9.0",
|
137 |
+
"source": {
|
138 |
+
"type": "git",
|
139 |
+
"url": "https://github.com/donatj/PhpUserAgent.git",
|
140 |
+
"reference": "ea79de6a18e52285e62cd75cf1cebe276ecaf503"
|
141 |
+
},
|
142 |
+
"dist": {
|
143 |
+
"type": "zip",
|
144 |
+
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/ea79de6a18e52285e62cd75cf1cebe276ecaf503",
|
145 |
+
"reference": "ea79de6a18e52285e62cd75cf1cebe276ecaf503",
|
146 |
+
"shasum": ""
|
147 |
+
},
|
148 |
+
"require": {
|
149 |
+
"php": ">=5.3.0"
|
150 |
+
},
|
151 |
+
"require-dev": {
|
152 |
+
"camspiers/json-pretty": "0.1.*",
|
153 |
+
"donatj/drop": "*",
|
154 |
+
"phpunit/phpunit": "~4.8"
|
155 |
+
},
|
156 |
+
"type": "library",
|
157 |
+
"autoload": {
|
158 |
+
"files": [
|
159 |
+
"Source/UserAgentParser.php"
|
160 |
+
]
|
161 |
+
},
|
162 |
+
"notification-url": "https://packagist.org/downloads/",
|
163 |
+
"license": [
|
164 |
+
"MIT"
|
165 |
+
],
|
166 |
+
"authors": [
|
167 |
+
{
|
168 |
+
"name": "Jesse G. Donat",
|
169 |
+
"email": "donatj@gmail.com",
|
170 |
+
"homepage": "http://donatstudios.com",
|
171 |
+
"role": "Developer"
|
172 |
+
}
|
173 |
+
],
|
174 |
+
"description": "Simple, streamlined PHP user-agent parser",
|
175 |
+
"homepage": "http://donatstudios.com/PHP-Parser-HTTP_USER_AGENT",
|
176 |
+
"keywords": [
|
177 |
+
"browser",
|
178 |
+
"browser detection",
|
179 |
+
"parser",
|
180 |
+
"user agent",
|
181 |
+
"useragent"
|
182 |
+
],
|
183 |
+
"time": "2017-10-23T16:52:52+00:00"
|
184 |
+
},
|
185 |
+
{
|
186 |
+
"name": "erusev/parsedown",
|
187 |
+
"version": "1.6.4",
|
188 |
+
"source": {
|
189 |
+
"type": "git",
|
190 |
+
"url": "https://github.com/erusev/parsedown.git",
|
191 |
+
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548"
|
192 |
+
},
|
193 |
+
"dist": {
|
194 |
+
"type": "zip",
|
195 |
+
"url": "https://api.github.com/repos/erusev/parsedown/zipball/fbe3fe878f4fe69048bb8a52783a09802004f548",
|
196 |
+
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548",
|
197 |
+
"shasum": ""
|
198 |
+
},
|
199 |
+
"require": {
|
200 |
+
"php": ">=5.3.0"
|
201 |
+
},
|
202 |
+
"require-dev": {
|
203 |
+
"phpunit/phpunit": "^4.8.35"
|
204 |
+
},
|
205 |
+
"type": "library",
|
206 |
+
"autoload": {
|
207 |
+
"psr-0": {
|
208 |
+
"Parsedown": ""
|
209 |
+
}
|
210 |
+
},
|
211 |
+
"notification-url": "https://packagist.org/downloads/",
|
212 |
+
"license": [
|
213 |
+
"MIT"
|
214 |
+
],
|
215 |
+
"authors": [
|
216 |
+
{
|
217 |
+
"name": "Emanuil Rusev",
|
218 |
+
"email": "hello@erusev.com",
|
219 |
+
"homepage": "http://erusev.com"
|
220 |
+
}
|
221 |
+
],
|
222 |
+
"description": "Parser for Markdown.",
|
223 |
+
"homepage": "http://parsedown.org",
|
224 |
+
"keywords": [
|
225 |
+
"markdown",
|
226 |
+
"parser"
|
227 |
+
],
|
228 |
+
"time": "2017-11-14T20:44:03+00:00"
|
229 |
+
},
|
230 |
+
{
|
231 |
+
"name": "geoip2/geoip2",
|
232 |
+
"version": "v2.7.0",
|
233 |
+
"source": {
|
234 |
+
"type": "git",
|
235 |
+
"url": "https://github.com/maxmind/GeoIP2-php.git",
|
236 |
+
"reference": "ca9f9a244474d97eac1ef542aaced7cc944bafbe"
|
237 |
+
},
|
238 |
+
"dist": {
|
239 |
+
"type": "zip",
|
240 |
+
"url": "https://api.github.com/repos/maxmind/GeoIP2-php/zipball/ca9f9a244474d97eac1ef542aaced7cc944bafbe",
|
241 |
+
"reference": "ca9f9a244474d97eac1ef542aaced7cc944bafbe",
|
242 |
+
"shasum": ""
|
243 |
+
},
|
244 |
+
"require": {
|
245 |
+
"maxmind-db/reader": "~1.0",
|
246 |
+
"maxmind/web-service-common": "~0.4",
|
247 |
+
"php": ">=5.4"
|
248 |
+
},
|
249 |
+
"require-dev": {
|
250 |
+
"apigen/apigen": "*",
|
251 |
+
"friendsofphp/php-cs-fixer": "2.*",
|
252 |
+
"phpunit/phpunit": "4.*",
|
253 |
+
"squizlabs/php_codesniffer": "3.*"
|
254 |
+
},
|
255 |
+
"type": "library",
|
256 |
+
"autoload": {
|
257 |
+
"psr-4": {
|
258 |
+
"GeoIp2\\": "src"
|
259 |
+
}
|
260 |
+
},
|
261 |
+
"notification-url": "https://packagist.org/downloads/",
|
262 |
+
"license": [
|
263 |
+
"Apache-2.0"
|
264 |
+
],
|
265 |
+
"authors": [
|
266 |
+
{
|
267 |
+
"name": "Gregory J. Oschwald",
|
268 |
+
"email": "goschwald@maxmind.com",
|
269 |
+
"homepage": "http://www.maxmind.com/"
|
270 |
+
}
|
271 |
+
],
|
272 |
+
"description": "MaxMind GeoIP2 PHP API",
|
273 |
+
"homepage": "https://github.com/maxmind/GeoIP2-php",
|
274 |
+
"keywords": [
|
275 |
+
"IP",
|
276 |
+
"geoip",
|
277 |
+
"geoip2",
|
278 |
+
"geolocation",
|
279 |
+
"maxmind"
|
280 |
+
],
|
281 |
+
"time": "2017-10-27T19:20:22+00:00"
|
282 |
+
},
|
283 |
+
{
|
284 |
+
"name": "guzzlehttp/guzzle",
|
285 |
+
"version": "6.3.0",
|
286 |
+
"source": {
|
287 |
+
"type": "git",
|
288 |
+
"url": "https://github.com/guzzle/guzzle.git",
|
289 |
+
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
|
290 |
+
},
|
291 |
+
"dist": {
|
292 |
+
"type": "zip",
|
293 |
+
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
294 |
+
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
295 |
+
"shasum": ""
|
296 |
+
},
|
297 |
+
"require": {
|
298 |
+
"guzzlehttp/promises": "^1.0",
|
299 |
+
"guzzlehttp/psr7": "^1.4",
|
300 |
+
"php": ">=5.5"
|
301 |
+
},
|
302 |
+
"require-dev": {
|
303 |
+
"ext-curl": "*",
|
304 |
+
"phpunit/phpunit": "^4.0 || ^5.0",
|
305 |
+
"psr/log": "^1.0"
|
306 |
+
},
|
307 |
+
"suggest": {
|
308 |
+
"psr/log": "Required for using the Log middleware"
|
309 |
+
},
|
310 |
+
"type": "library",
|
311 |
+
"extra": {
|
312 |
+
"branch-alias": {
|
313 |
+
"dev-master": "6.2-dev"
|
314 |
+
}
|
315 |
+
},
|
316 |
+
"autoload": {
|
317 |
+
"files": [
|
318 |
+
"src/functions_include.php"
|
319 |
+
],
|
320 |
+
"psr-4": {
|
321 |
+
"GuzzleHttp\\": "src/"
|
322 |
+
}
|
323 |
+
},
|
324 |
+
"notification-url": "https://packagist.org/downloads/",
|
325 |
+
"license": [
|
326 |
+
"MIT"
|
327 |
+
],
|
328 |
+
"authors": [
|
329 |
+
{
|
330 |
+
"name": "Michael Dowling",
|
331 |
+
"email": "mtdowling@gmail.com",
|
332 |
+
"homepage": "https://github.com/mtdowling"
|
333 |
+
}
|
334 |
+
],
|
335 |
+
"description": "Guzzle is a PHP HTTP client library",
|
336 |
+
"homepage": "http://guzzlephp.org/",
|
337 |
+
"keywords": [
|
338 |
+
"client",
|
339 |
+
"curl",
|
340 |
+
"framework",
|
341 |
+
"http",
|
342 |
+
"http client",
|
343 |
+
"rest",
|
344 |
+
"web service"
|
345 |
+
],
|
346 |
+
"time": "2017-06-22T18:50:49+00:00"
|
347 |
+
},
|
348 |
+
{
|
349 |
+
"name": "guzzlehttp/promises",
|
350 |
+
"version": "v1.3.1",
|
351 |
+
"source": {
|
352 |
+
"type": "git",
|
353 |
+
"url": "https://github.com/guzzle/promises.git",
|
354 |
+
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
|
355 |
+
},
|
356 |
+
"dist": {
|
357 |
+
"type": "zip",
|
358 |
+
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
359 |
+
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
360 |
+
"shasum": ""
|
361 |
+
},
|
362 |
+
"require": {
|
363 |
+
"php": ">=5.5.0"
|
364 |
+
},
|
365 |
+
"require-dev": {
|
366 |
+
"phpunit/phpunit": "^4.0"
|
367 |
+
},
|
368 |
+
"type": "library",
|
369 |
+
"extra": {
|
370 |
+
"branch-alias": {
|
371 |
+
"dev-master": "1.4-dev"
|
372 |
+
}
|
373 |
+
},
|
374 |
+
"autoload": {
|
375 |
+
"psr-4": {
|
376 |
+
"GuzzleHttp\\Promise\\": "src/"
|
377 |
+
},
|
378 |
+
"files": [
|
379 |
+
"src/functions_include.php"
|
380 |
+
]
|
381 |
+
},
|
382 |
+
"notification-url": "https://packagist.org/downloads/",
|
383 |
+
"license": [
|
384 |
+
"MIT"
|
385 |
+
],
|
386 |
+
"authors": [
|
387 |
+
{
|
388 |
+
"name": "Michael Dowling",
|
389 |
+
"email": "mtdowling@gmail.com",
|
390 |
+
"homepage": "https://github.com/mtdowling"
|
391 |
+
}
|
392 |
+
],
|
393 |
+
"description": "Guzzle promises library",
|
394 |
+
"keywords": [
|
395 |
+
"promise"
|
396 |
+
],
|
397 |
+
"time": "2016-12-20T10:07:11+00:00"
|
398 |
+
},
|
399 |
+
{
|
400 |
+
"name": "guzzlehttp/psr7",
|
401 |
+
"version": "1.4.2",
|
402 |
+
"source": {
|
403 |
+
"type": "git",
|
404 |
+
"url": "https://github.com/guzzle/psr7.git",
|
405 |
+
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
|
406 |
+
},
|
407 |
+
"dist": {
|
408 |
+
"type": "zip",
|
409 |
+
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
410 |
+
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
411 |
+
"shasum": ""
|
412 |
+
},
|
413 |
+
"require": {
|
414 |
+
"php": ">=5.4.0",
|
415 |
+
"psr/http-message": "~1.0"
|
416 |
+
},
|
417 |
+
"provide": {
|
418 |
+
"psr/http-message-implementation": "1.0"
|
419 |
+
},
|
420 |
+
"require-dev": {
|
421 |
+
"phpunit/phpunit": "~4.0"
|
422 |
+
},
|
423 |
+
"type": "library",
|
424 |
+
"extra": {
|
425 |
+
"branch-alias": {
|
426 |
+
"dev-master": "1.4-dev"
|
427 |
+
}
|
428 |
+
},
|
429 |
+
"autoload": {
|
430 |
+
"psr-4": {
|
431 |
+
"GuzzleHttp\\Psr7\\": "src/"
|
432 |
+
},
|
433 |
+
"files": [
|
434 |
+
"src/functions_include.php"
|
435 |
+
]
|
436 |
+
},
|
437 |
+
"notification-url": "https://packagist.org/downloads/",
|
438 |
+
"license": [
|
439 |
+
"MIT"
|
440 |
+
],
|
441 |
+
"authors": [
|
442 |
+
{
|
443 |
+
"name": "Michael Dowling",
|
444 |
+
"email": "mtdowling@gmail.com",
|
445 |
+
"homepage": "https://github.com/mtdowling"
|
446 |
+
},
|
447 |
+
{
|
448 |
+
"name": "Tobias Schultze",
|
449 |
+
"homepage": "https://github.com/Tobion"
|
450 |
+
}
|
451 |
+
],
|
452 |
+
"description": "PSR-7 message implementation that also provides common utility methods",
|
453 |
+
"keywords": [
|
454 |
+
"http",
|
455 |
+
"message",
|
456 |
+
"request",
|
457 |
+
"response",
|
458 |
+
"stream",
|
459 |
+
"uri",
|
460 |
+
"url"
|
461 |
+
],
|
462 |
+
"time": "2017-03-20T17:10:46+00:00"
|
463 |
+
},
|
464 |
+
{
|
465 |
+
"name": "maxmind-db/reader",
|
466 |
+
"version": "v1.2.0",
|
467 |
+
"source": {
|
468 |
+
"type": "git",
|
469 |
+
"url": "https://github.com/maxmind/MaxMind-DB-Reader-php.git",
|
470 |
+
"reference": "1647820dfbcb552222fb5feb3a8387e2636394c9"
|
471 |
+
},
|
472 |
+
"dist": {
|
473 |
+
"type": "zip",
|
474 |
+
"url": "https://api.github.com/repos/maxmind/MaxMind-DB-Reader-php/zipball/1647820dfbcb552222fb5feb3a8387e2636394c9",
|
475 |
+
"reference": "1647820dfbcb552222fb5feb3a8387e2636394c9",
|
476 |
+
"shasum": ""
|
477 |
+
},
|
478 |
+
"require": {
|
479 |
+
"php": ">=5.4"
|
480 |
+
},
|
481 |
+
"require-dev": {
|
482 |
+
"friendsofphp/php-cs-fixer": "2.*",
|
483 |
+
"phpunit/phpunit": "4.*",
|
484 |
+
"satooshi/php-coveralls": "1.0.*",
|
485 |
+
"squizlabs/php_codesniffer": "3.*"
|
486 |
+
},
|
487 |
+
"suggest": {
|
488 |
+
"ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
|
489 |
+
"ext-gmp": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
|
490 |
+
"ext-maxminddb": "A C-based database decoder that provides significantly faster lookups"
|
491 |
+
},
|
492 |
+
"type": "library",
|
493 |
+
"autoload": {
|
494 |
+
"psr-4": {
|
495 |
+
"MaxMind\\Db\\": "src/MaxMind/Db"
|
496 |
+
}
|
497 |
+
},
|
498 |
+
"notification-url": "https://packagist.org/downloads/",
|
499 |
+
"license": [
|
500 |
+
"Apache-2.0"
|
501 |
+
],
|
502 |
+
"authors": [
|
503 |
+
{
|
504 |
+
"name": "Gregory J. Oschwald",
|
505 |
+
"email": "goschwald@maxmind.com",
|
506 |
+
"homepage": "http://www.maxmind.com/"
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"description": "MaxMind DB Reader API",
|
510 |
+
"homepage": "https://github.com/maxmind/MaxMind-DB-Reader-php",
|
511 |
+
"keywords": [
|
512 |
+
"database",
|
513 |
+
"geoip",
|
514 |
+
"geoip2",
|
515 |
+
"geolocation",
|
516 |
+
"maxmind"
|
517 |
+
],
|
518 |
+
"time": "2017-10-27T19:15:33+00:00"
|
519 |
+
},
|
520 |
+
{
|
521 |
+
"name": "maxmind/web-service-common",
|
522 |
+
"version": "v0.4.0",
|
523 |
+
"source": {
|
524 |
+
"type": "git",
|
525 |
+
"url": "https://github.com/maxmind/web-service-common-php.git",
|
526 |
+
"reference": "622f7c732a7f9c4c62497fc103939e042b6bdb88"
|
527 |
+
},
|
528 |
+
"dist": {
|
529 |
+
"type": "zip",
|
530 |
+
"url": "https://api.github.com/repos/maxmind/web-service-common-php/zipball/622f7c732a7f9c4c62497fc103939e042b6bdb88",
|
531 |
+
"reference": "622f7c732a7f9c4c62497fc103939e042b6bdb88",
|
532 |
+
"shasum": ""
|
533 |
+
},
|
534 |
+
"require": {
|
535 |
+
"composer/ca-bundle": "^1.0.3",
|
536 |
+
"ext-curl": "*",
|
537 |
+
"ext-json": "*",
|
538 |
+
"php": ">=5.4"
|
539 |
+
},
|
540 |
+
"require-dev": {
|
541 |
+
"friendsofphp/php-cs-fixer": "2.*",
|
542 |
+
"phpunit/phpunit": "4.*",
|
543 |
+
"squizlabs/php_codesniffer": "3.*"
|
544 |
+
},
|
545 |
+
"type": "library",
|
546 |
+
"autoload": {
|
547 |
+
"psr-4": {
|
548 |
+
"MaxMind\\Exception\\": "src/Exception",
|
549 |
+
"MaxMind\\WebService\\": "src/WebService"
|
550 |
+
}
|
551 |
+
},
|
552 |
+
"notification-url": "https://packagist.org/downloads/",
|
553 |
+
"license": [
|
554 |
+
"Apache-2.0"
|
555 |
+
],
|
556 |
+
"authors": [
|
557 |
+
{
|
558 |
+
"name": "Gregory Oschwald",
|
559 |
+
"email": "goschwald@maxmind.com"
|
560 |
+
}
|
561 |
+
],
|
562 |
+
"description": "Internal MaxMind Web Service API",
|
563 |
+
"homepage": "https://github.com/maxmind/web-service-common-php",
|
564 |
+
"time": "2017-07-06T17:48:21+00:00"
|
565 |
+
},
|
566 |
+
{
|
567 |
+
"name": "mimmi20/wurfl-constants",
|
568 |
+
"version": "1.7.1.1",
|
569 |
+
"source": {
|
570 |
+
"type": "git",
|
571 |
+
"url": "https://github.com/mimmi20/wurfl-constants.git",
|
572 |
+
"reference": "d0bd0154120cb833dbdf8a8075d5f14bcc521e42"
|
573 |
+
},
|
574 |
+
"dist": {
|
575 |
+
"type": "zip",
|
576 |
+
"url": "https://api.github.com/repos/mimmi20/wurfl-constants/zipball/d0bd0154120cb833dbdf8a8075d5f14bcc521e42",
|
577 |
+
"reference": "d0bd0154120cb833dbdf8a8075d5f14bcc521e42",
|
578 |
+
"shasum": ""
|
579 |
+
},
|
580 |
+
"require": {
|
581 |
+
"php": ">=5.3.3"
|
582 |
+
},
|
583 |
+
"require-dev": {
|
584 |
+
"fabpot/php-cs-fixer": "^1.11",
|
585 |
+
"phpunit/phpunit": "^4.8|^5.0",
|
586 |
+
"squizlabs/php_codesniffer": "^2.5"
|
587 |
+
},
|
588 |
+
"type": "library",
|
589 |
+
"autoload": {
|
590 |
+
"psr-4": {
|
591 |
+
"Wurfl\\": "src/"
|
592 |
+
}
|
593 |
+
},
|
594 |
+
"notification-url": "https://packagist.org/downloads/",
|
595 |
+
"license": [
|
596 |
+
"LGPL-2.1"
|
597 |
+
],
|
598 |
+
"description": "the Constants extracted from Wurfl for PHP 5.3",
|
599 |
+
"homepage": "https://github.com/mimmi20/wurfl-constants",
|
600 |
+
"keywords": [
|
601 |
+
"Wurfl",
|
602 |
+
"browser",
|
603 |
+
"http",
|
604 |
+
"parser",
|
605 |
+
"user agent",
|
606 |
+
"user-agent"
|
607 |
+
],
|
608 |
+
"time": "2016-04-23T18:18:10+00:00"
|
609 |
+
},
|
610 |
+
{
|
611 |
+
"name": "mimmi20/wurflcache",
|
612 |
+
"version": "1.7.1.1",
|
613 |
+
"source": {
|
614 |
+
"type": "git",
|
615 |
+
"url": "https://github.com/mimmi20/WurflCache.git",
|
616 |
+
"reference": "9fc307df74f782a879f4604ab99bf61ecfc165d4"
|
617 |
+
},
|
618 |
+
"dist": {
|
619 |
+
"type": "zip",
|
620 |
+
"url": "https://api.github.com/repos/mimmi20/WurflCache/zipball/9fc307df74f782a879f4604ab99bf61ecfc165d4",
|
621 |
+
"reference": "9fc307df74f782a879f4604ab99bf61ecfc165d4",
|
622 |
+
"shasum": ""
|
623 |
+
},
|
624 |
+
"require": {
|
625 |
+
"mimmi20/wurfl-constants": "^1.7",
|
626 |
+
"php": ">=5.3.3",
|
627 |
+
"symfony/filesystem": "^2.8|^3.0"
|
628 |
+
},
|
629 |
+
"require-dev": {
|
630 |
+
"desarrolla2/cache": "^1.8",
|
631 |
+
"doctrine/cache": "^1.5",
|
632 |
+
"fabpot/php-cs-fixer": "^1.11",
|
633 |
+
"mikey179/vfsstream": "^1.3",
|
634 |
+
"phpunit/phpunit": "^4.8 || ^5.0",
|
635 |
+
"squizlabs/php_codesniffer": "^2.0",
|
636 |
+
"zendframework/zend-cache": "^2.5",
|
637 |
+
"zetacomponents/cache": "dev-master"
|
638 |
+
},
|
639 |
+
"suggest": {
|
640 |
+
"desarrolla2/cache": "to use other caches handled by desarrolla",
|
641 |
+
"doctrine/cache": "to use other caches handled by doctrine",
|
642 |
+
"zendframework/zend-cache": "to use other caches handled by zend",
|
643 |
+
"zetacomponents/cache": "to use other caches handled by zeta"
|
644 |
+
},
|
645 |
+
"type": "library",
|
646 |
+
"autoload": {
|
647 |
+
"psr-4": {
|
648 |
+
"WurflCache\\": "src/"
|
649 |
+
}
|
650 |
+
},
|
651 |
+
"notification-url": "https://packagist.org/downloads/",
|
652 |
+
"license": [
|
653 |
+
"MIT"
|
654 |
+
],
|
655 |
+
"authors": [
|
656 |
+
{
|
657 |
+
"name": "Thomas Müller",
|
658 |
+
"homepage": "https://github.com/mimmi20",
|
659 |
+
"role": "Developer"
|
660 |
+
},
|
661 |
+
{
|
662 |
+
"name": "Contributors",
|
663 |
+
"homepage": "https://github.com/mimmi20/WurflCache/graphs/contributors"
|
664 |
+
}
|
665 |
+
],
|
666 |
+
"description": "the Cache Classes for the Wurfl PHP Library for PHP 5.3",
|
667 |
+
"homepage": "https://github.com/mimmi20/WurflCache",
|
668 |
+
"keywords": [
|
669 |
+
"Wurfl",
|
670 |
+
"cache"
|
671 |
+
],
|
672 |
+
"time": "2016-08-06T11:25:21+00:00"
|
673 |
+
},
|
674 |
+
{
|
675 |
+
"name": "monolog/monolog",
|
676 |
+
"version": "1.23.0",
|
677 |
+
"source": {
|
678 |
+
"type": "git",
|
679 |
+
"url": "https://github.com/Seldaek/monolog.git",
|
680 |
+
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
|
681 |
+
},
|
682 |
+
"dist": {
|
683 |
+
"type": "zip",
|
684 |
+
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
|
685 |
+
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
|
686 |
+
"shasum": ""
|
687 |
+
},
|
688 |
+
"require": {
|
689 |
+
"php": ">=5.3.0",
|
690 |
+
"psr/log": "~1.0"
|
691 |
+
},
|
692 |
+
"provide": {
|
693 |
+
"psr/log-implementation": "1.0.0"
|
694 |
+
},
|
695 |
+
"require-dev": {
|
696 |
+
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
697 |
+
"doctrine/couchdb": "~1.0@dev",
|
698 |
+
"graylog2/gelf-php": "~1.0",
|
699 |
+
"jakub-onderka/php-parallel-lint": "0.9",
|
700 |
+
"php-amqplib/php-amqplib": "~2.4",
|
701 |
+
"php-console/php-console": "^3.1.3",
|
702 |
+
"phpunit/phpunit": "~4.5",
|
703 |
+
"phpunit/phpunit-mock-objects": "2.3.0",
|
704 |
+
"ruflin/elastica": ">=0.90 <3.0",
|
705 |
+
"sentry/sentry": "^0.13",
|
706 |
+
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
707 |
+
},
|
708 |
+
"suggest": {
|
709 |
+
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
710 |
+
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
711 |
+
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
712 |
+
"ext-mongo": "Allow sending log messages to a MongoDB server",
|
713 |
+
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
714 |
+
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
|
715 |
+
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
716 |
+
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
717 |
+
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
718 |
+
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
|
719 |
+
"sentry/sentry": "Allow sending log messages to a Sentry server"
|
720 |
+
},
|
721 |
+
"type": "library",
|
722 |
+
"extra": {
|
723 |
+
"branch-alias": {
|
724 |
+
"dev-master": "2.0.x-dev"
|
725 |
+
}
|
726 |
+
},
|
727 |
+
"autoload": {
|
728 |
+
"psr-4": {
|
729 |
+
"Monolog\\": "src/Monolog"
|
730 |
+
}
|
731 |
+
},
|
732 |
+
"notification-url": "https://packagist.org/downloads/",
|
733 |
+
"license": [
|
734 |
+
"MIT"
|
735 |
+
],
|
736 |
+
"authors": [
|
737 |
+
{
|
738 |
+
"name": "Jordi Boggiano",
|
739 |
+
"email": "j.boggiano@seld.be",
|
740 |
+
"homepage": "http://seld.be"
|
741 |
+
}
|
742 |
+
],
|
743 |
+
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
|
744 |
+
"homepage": "http://github.com/Seldaek/monolog",
|
745 |
+
"keywords": [
|
746 |
+
"log",
|
747 |
+
"logging",
|
748 |
+
"psr-3"
|
749 |
+
],
|
750 |
+
"time": "2017-06-19T01:22:40+00:00"
|
751 |
+
},
|
752 |
+
{
|
753 |
+
"name": "psr/http-message",
|
754 |
+
"version": "1.0.1",
|
755 |
+
"source": {
|
756 |
+
"type": "git",
|
757 |
+
"url": "https://github.com/php-fig/http-message.git",
|
758 |
+
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
759 |
+
},
|
760 |
+
"dist": {
|
761 |
+
"type": "zip",
|
762 |
+
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
763 |
+
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
764 |
+
"shasum": ""
|
765 |
+
},
|
766 |
+
"require": {
|
767 |
+
"php": ">=5.3.0"
|
768 |
+
},
|
769 |
+
"type": "library",
|
770 |
+
"extra": {
|
771 |
+
"branch-alias": {
|
772 |
+
"dev-master": "1.0.x-dev"
|
773 |
+
}
|
774 |
+
},
|
775 |
+
"autoload": {
|
776 |
+
"psr-4": {
|
777 |
+
"Psr\\Http\\Message\\": "src/"
|
778 |
+
}
|
779 |
+
},
|
780 |
+
"notification-url": "https://packagist.org/downloads/",
|
781 |
+
"license": [
|
782 |
+
"MIT"
|
783 |
+
],
|
784 |
+
"authors": [
|
785 |
+
{
|
786 |
+
"name": "PHP-FIG",
|
787 |
+
"homepage": "http://www.php-fig.org/"
|
788 |
+
}
|
789 |
+
],
|
790 |
+
"description": "Common interface for HTTP messages",
|
791 |
+
"homepage": "https://github.com/php-fig/http-message",
|
792 |
+
"keywords": [
|
793 |
+
"http",
|
794 |
+
"http-message",
|
795 |
+
"psr",
|
796 |
+
"psr-7",
|
797 |
+
"request",
|
798 |
+
"response"
|
799 |
+
],
|
800 |
+
"time": "2016-08-06T14:39:51+00:00"
|
801 |
+
},
|
802 |
+
{
|
803 |
+
"name": "psr/log",
|
804 |
+
"version": "1.0.2",
|
805 |
+
"source": {
|
806 |
+
"type": "git",
|
807 |
+
"url": "https://github.com/php-fig/log.git",
|
808 |
+
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
|
809 |
+
},
|
810 |
+
"dist": {
|
811 |
+
"type": "zip",
|
812 |
+
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
813 |
+
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
814 |
+
"shasum": ""
|
815 |
+
},
|
816 |
+
"require": {
|
817 |
+
"php": ">=5.3.0"
|
818 |
+
},
|
819 |
+
"type": "library",
|
820 |
+
"extra": {
|
821 |
+
"branch-alias": {
|
822 |
+
"dev-master": "1.0.x-dev"
|
823 |
+
}
|
824 |
+
},
|
825 |
+
"autoload": {
|
826 |
+
"psr-4": {
|
827 |
+
"Psr\\Log\\": "Psr/Log/"
|
828 |
+
}
|
829 |
+
},
|
830 |
+
"notification-url": "https://packagist.org/downloads/",
|
831 |
+
"license": [
|
832 |
+
"MIT"
|
833 |
+
],
|
834 |
+
"authors": [
|
835 |
+
{
|
836 |
+
"name": "PHP-FIG",
|
837 |
+
"homepage": "http://www.php-fig.org/"
|
838 |
+
}
|
839 |
+
],
|
840 |
+
"description": "Common interface for logging libraries",
|
841 |
+
"homepage": "https://github.com/php-fig/log",
|
842 |
+
"keywords": [
|
843 |
+
"log",
|
844 |
+
"psr",
|
845 |
+
"psr-3"
|
846 |
+
],
|
847 |
+
"time": "2016-10-10T12:19:37+00:00"
|
848 |
+
},
|
849 |
+
{
|
850 |
+
"name": "s1lentium/iptools",
|
851 |
+
"version": "v1.1.0",
|
852 |
+
"source": {
|
853 |
+
"type": "git",
|
854 |
+
"url": "https://github.com/S1lentium/IPTools.git",
|
855 |
+
"reference": "cb4843d4077872643b5d38d18b8591b4aaf605ea"
|
856 |
+
},
|
857 |
+
"dist": {
|
858 |
+
"type": "zip",
|
859 |
+
"url": "https://api.github.com/repos/S1lentium/IPTools/zipball/cb4843d4077872643b5d38d18b8591b4aaf605ea",
|
860 |
+
"reference": "cb4843d4077872643b5d38d18b8591b4aaf605ea",
|
861 |
+
"shasum": ""
|
862 |
+
},
|
863 |
+
"require": {
|
864 |
+
"ext-bcmath": "*",
|
865 |
+
"php": ">=5.4.0"
|
866 |
+
},
|
867 |
+
"require-dev": {
|
868 |
+
"satooshi/php-coveralls": "~1.0"
|
869 |
+
},
|
870 |
+
"type": "library",
|
871 |
+
"autoload": {
|
872 |
+
"psr-4": {
|
873 |
+
"IPTools\\": "src/"
|
874 |
+
}
|
875 |
+
},
|
876 |
+
"notification-url": "https://packagist.org/downloads/",
|
877 |
+
"license": [
|
878 |
+
"MIT"
|
879 |
+
],
|
880 |
+
"authors": [
|
881 |
+
{
|
882 |
+
"name": "Safarov Alisher",
|
883 |
+
"email": "alisher.safarov@outlook.com",
|
884 |
+
"homepage": "https://github.com/S1lentium"
|
885 |
+
}
|
886 |
+
],
|
887 |
+
"description": "PHP Library for manipulating network addresses (IPv4 and IPv6)",
|
888 |
+
"keywords": [
|
889 |
+
"IP",
|
890 |
+
"IP-Tools",
|
891 |
+
"cidr",
|
892 |
+
"ipv4",
|
893 |
+
"ipv6",
|
894 |
+
"network",
|
895 |
+
"subnet"
|
896 |
+
],
|
897 |
+
"time": "2016-08-21T15:57:09+00:00"
|
898 |
+
},
|
899 |
+
{
|
900 |
+
"name": "symfony/console",
|
901 |
+
"version": "v3.4.3",
|
902 |
+
"source": {
|
903 |
+
"type": "git",
|
904 |
+
"url": "https://github.com/symfony/console.git",
|
905 |
+
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d"
|
906 |
+
},
|
907 |
+
"dist": {
|
908 |
+
"type": "zip",
|
909 |
+
"url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d",
|
910 |
+
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d",
|
911 |
+
"shasum": ""
|
912 |
+
},
|
913 |
+
"require": {
|
914 |
+
"php": "^5.5.9|>=7.0.8",
|
915 |
+
"symfony/debug": "~2.8|~3.0|~4.0",
|
916 |
+
"symfony/polyfill-mbstring": "~1.0"
|
917 |
+
},
|
918 |
+
"conflict": {
|
919 |
+
"symfony/dependency-injection": "<3.4",
|
920 |
+
"symfony/process": "<3.3"
|
921 |
+
},
|
922 |
+
"require-dev": {
|
923 |
+
"psr/log": "~1.0",
|
924 |
+
"symfony/config": "~3.3|~4.0",
|
925 |
+
"symfony/dependency-injection": "~3.4|~4.0",
|
926 |
+
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
927 |
+
"symfony/lock": "~3.4|~4.0",
|
928 |
+
"symfony/process": "~3.3|~4.0"
|
929 |
+
},
|
930 |
+
"suggest": {
|
931 |
+
"psr/log": "For using the console logger",
|
932 |
+
"symfony/event-dispatcher": "",
|
933 |
+
"symfony/lock": "",
|
934 |
+
"symfony/process": ""
|
935 |
+
},
|
936 |
+
"type": "library",
|
937 |
+
"extra": {
|
938 |
+
"branch-alias": {
|
939 |
+
"dev-master": "3.4-dev"
|
940 |
+
}
|
941 |
+
},
|
942 |
+
"autoload": {
|
943 |
+
"psr-4": {
|
944 |
+
"Symfony\\Component\\Console\\": ""
|
945 |
+
},
|
946 |
+
"exclude-from-classmap": [
|
947 |
+
"/Tests/"
|
948 |
+
]
|
949 |
+
},
|
950 |
+
"notification-url": "https://packagist.org/downloads/",
|
951 |
+
"license": [
|
952 |
+
"MIT"
|
953 |
+
],
|
954 |
+
"authors": [
|
955 |
+
{
|
956 |
+
"name": "Fabien Potencier",
|
957 |
+
"email": "fabien@symfony.com"
|
958 |
+
},
|
959 |
+
{
|
960 |
+
"name": "Symfony Community",
|
961 |
+
"homepage": "https://symfony.com/contributors"
|
962 |
+
}
|
963 |
+
],
|
964 |
+
"description": "Symfony Console Component",
|
965 |
+
"homepage": "https://symfony.com",
|
966 |
+
"time": "2018-01-03T07:37:34+00:00"
|
967 |
+
},
|
968 |
+
{
|
969 |
+
"name": "symfony/debug",
|
970 |
+
"version": "v3.4.3",
|
971 |
+
"source": {
|
972 |
+
"type": "git",
|
973 |
+
"url": "https://github.com/symfony/debug.git",
|
974 |
+
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245"
|
975 |
+
},
|
976 |
+
"dist": {
|
977 |
+
"type": "zip",
|
978 |
+
"url": "https://api.github.com/repos/symfony/debug/zipball/603b95dda8b00020e4e6e60dc906e7b715b1c245",
|
979 |
+
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245",
|
980 |
+
"shasum": ""
|
981 |
+
},
|
982 |
+
"require": {
|
983 |
+
"php": "^5.5.9|>=7.0.8",
|
984 |
+
"psr/log": "~1.0"
|
985 |
+
},
|
986 |
+
"conflict": {
|
987 |
+
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
|
988 |
+
},
|
989 |
+
"require-dev": {
|
990 |
+
"symfony/http-kernel": "~2.8|~3.0|~4.0"
|
991 |
+
},
|
992 |
+
"type": "library",
|
993 |
+
"extra": {
|
994 |
+
"branch-alias": {
|
995 |
+
"dev-master": "3.4-dev"
|
996 |
+
}
|
997 |
+
},
|
998 |
+
"autoload": {
|
999 |
+
"psr-4": {
|
1000 |
+
"Symfony\\Component\\Debug\\": ""
|
1001 |
+
},
|
1002 |
+
"exclude-from-classmap": [
|
1003 |
+
"/Tests/"
|
1004 |
+
]
|
1005 |
+
},
|
1006 |
+
"notification-url": "https://packagist.org/downloads/",
|
1007 |
+
"license": [
|
1008 |
+
"MIT"
|
1009 |
+
],
|
1010 |
+
"authors": [
|
1011 |
+
{
|
1012 |
+
"name": "Fabien Potencier",
|
1013 |
+
"email": "fabien@symfony.com"
|
1014 |
+
},
|
1015 |
+
{
|
1016 |
+
"name": "Symfony Community",
|
1017 |
+
"homepage": "https://symfony.com/contributors"
|
1018 |
+
}
|
1019 |
+
],
|
1020 |
+
"description": "Symfony Debug Component",
|
1021 |
+
"homepage": "https://symfony.com",
|
1022 |
+
"time": "2018-01-03T17:14:19+00:00"
|
1023 |
+
},
|
1024 |
+
{
|
1025 |
+
"name": "symfony/filesystem",
|
1026 |
+
"version": "v3.4.3",
|
1027 |
+
"source": {
|
1028 |
+
"type": "git",
|
1029 |
+
"url": "https://github.com/symfony/filesystem.git",
|
1030 |
+
"reference": "e078773ad6354af38169faf31c21df0f18ace03d"
|
1031 |
+
},
|
1032 |
+
"dist": {
|
1033 |
+
"type": "zip",
|
1034 |
+
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e078773ad6354af38169faf31c21df0f18ace03d",
|
1035 |
+
"reference": "e078773ad6354af38169faf31c21df0f18ace03d",
|
1036 |
+
"shasum": ""
|
1037 |
+
},
|
1038 |
+
"require": {
|
1039 |
+
"php": "^5.5.9|>=7.0.8"
|
1040 |
+
},
|
1041 |
+
"type": "library",
|
1042 |
+
"extra": {
|
1043 |
+
"branch-alias": {
|
1044 |
+
"dev-master": "3.4-dev"
|
1045 |
+
}
|
1046 |
+
},
|
1047 |
+
"autoload": {
|
1048 |
+
"psr-4": {
|
1049 |
+
"Symfony\\Component\\Filesystem\\": ""
|
1050 |
+
},
|
1051 |
+
"exclude-from-classmap": [
|
1052 |
+
"/Tests/"
|
1053 |
+
]
|
1054 |
+
},
|
1055 |
+
"notification-url": "https://packagist.org/downloads/",
|
1056 |
+
"license": [
|
1057 |
+
"MIT"
|
1058 |
+
],
|
1059 |
+
"authors": [
|
1060 |
+
{
|
1061 |
+
"name": "Fabien Potencier",
|
1062 |
+
"email": "fabien@symfony.com"
|
1063 |
+
},
|
1064 |
+
{
|
1065 |
+
"name": "Symfony Community",
|
1066 |
+
"homepage": "https://symfony.com/contributors"
|
1067 |
+
}
|
1068 |
+
],
|
1069 |
+
"description": "Symfony Filesystem Component",
|
1070 |
+
"homepage": "https://symfony.com",
|
1071 |
+
"time": "2018-01-03T07:37:34+00:00"
|
1072 |
+
},
|
1073 |
+
{
|
1074 |
+
"name": "symfony/finder",
|
1075 |
+
"version": "v3.4.3",
|
1076 |
+
"source": {
|
1077 |
+
"type": "git",
|
1078 |
+
"url": "https://github.com/symfony/finder.git",
|
1079 |
+
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
|
1080 |
+
},
|
1081 |
+
"dist": {
|
1082 |
+
"type": "zip",
|
1083 |
+
"url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
|
1084 |
+
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
|
1085 |
+
"shasum": ""
|
1086 |
+
},
|
1087 |
+
"require": {
|
1088 |
+
"php": "^5.5.9|>=7.0.8"
|
1089 |
+
},
|
1090 |
+
"type": "library",
|
1091 |
+
"extra": {
|
1092 |
+
"branch-alias": {
|
1093 |
+
"dev-master": "3.4-dev"
|
1094 |
+
}
|
1095 |
+
},
|
1096 |
+
"autoload": {
|
1097 |
+
"psr-4": {
|
1098 |
+
"Symfony\\Component\\Finder\\": ""
|
1099 |
+
},
|
1100 |
+
"exclude-from-classmap": [
|
1101 |
+
"/Tests/"
|
1102 |
+
]
|
1103 |
+
},
|
1104 |
+
"notification-url": "https://packagist.org/downloads/",
|
1105 |
+
"license": [
|
1106 |
+
"MIT"
|
1107 |
+
],
|
1108 |
+
"authors": [
|
1109 |
+
{
|
1110 |
+
"name": "Fabien Potencier",
|
1111 |
+
"email": "fabien@symfony.com"
|
1112 |
+
},
|
1113 |
+
{
|
1114 |
+
"name": "Symfony Community",
|
1115 |
+
"homepage": "https://symfony.com/contributors"
|
1116 |
+
}
|
1117 |
+
],
|
1118 |
+
"description": "Symfony Finder Component",
|
1119 |
+
"homepage": "https://symfony.com",
|
1120 |
+
"time": "2018-01-03T07:37:34+00:00"
|
1121 |
+
},
|
1122 |
+
{
|
1123 |
+
"name": "symfony/polyfill-mbstring",
|
1124 |
+
"version": "v1.6.0",
|
1125 |
+
"source": {
|
1126 |
+
"type": "git",
|
1127 |
+
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
1128 |
+
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
|
1129 |
+
},
|
1130 |
+
"dist": {
|
1131 |
+
"type": "zip",
|
1132 |
+
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
1133 |
+
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
1134 |
+
"shasum": ""
|
1135 |
+
},
|
1136 |
+
"require": {
|
1137 |
+
"php": ">=5.3.3"
|
1138 |
+
},
|
1139 |
+
"suggest": {
|
1140 |
+
"ext-mbstring": "For best performance"
|
1141 |
+
},
|
1142 |
+
"type": "library",
|
1143 |
+
"extra": {
|
1144 |
+
"branch-alias": {
|
1145 |
+
"dev-master": "1.6-dev"
|
1146 |
+
}
|
1147 |
+
},
|
1148 |
+
"autoload": {
|
1149 |
+
"psr-4": {
|
1150 |
+
"Symfony\\Polyfill\\Mbstring\\": ""
|
1151 |
+
},
|
1152 |
+
"files": [
|
1153 |
+
"bootstrap.php"
|
1154 |
+
]
|
1155 |
+
},
|
1156 |
+
"notification-url": "https://packagist.org/downloads/",
|
1157 |
+
"license": [
|
1158 |
+
"MIT"
|
1159 |
+
],
|
1160 |
+
"authors": [
|
1161 |
+
{
|
1162 |
+
"name": "Nicolas Grekas",
|
1163 |
+
"email": "p@tchwork.com"
|
1164 |
+
},
|
1165 |
+
{
|
1166 |
+
"name": "Symfony Community",
|
1167 |
+
"homepage": "https://symfony.com/contributors"
|
1168 |
+
}
|
1169 |
+
],
|
1170 |
+
"description": "Symfony polyfill for the Mbstring extension",
|
1171 |
+
"homepage": "https://symfony.com",
|
1172 |
+
"keywords": [
|
1173 |
+
"compatibility",
|
1174 |
+
"mbstring",
|
1175 |
+
"polyfill",
|
1176 |
+
"portable",
|
1177 |
+
"shim"
|
1178 |
+
],
|
1179 |
+
"time": "2017-10-11T12:05:26+00:00"
|
1180 |
+
}
|
1181 |
+
],
|
1182 |
+
"packages-dev": [],
|
1183 |
+
"aliases": [],
|
1184 |
+
"minimum-stability": "stable",
|
1185 |
+
"stability-flags": [],
|
1186 |
+
"prefer-stable": false,
|
1187 |
+
"prefer-lowest": false,
|
1188 |
+
"platform": [],
|
1189 |
+
"platform-dev": []
|
1190 |
+
}
|
includes/classes/class-wp-statistics-admin-pages.php
CHANGED
@@ -12,10 +12,10 @@ class WP_Statistics_Admin_Pages {
|
|
12 |
global $WP_Statistics;
|
13 |
|
14 |
// Right side "wide" widgets
|
15 |
-
if ( $WP_Statistics->get_option('visits') ) {
|
16 |
add_meta_box(
|
17 |
'wps_hits_postbox',
|
18 |
-
__('Hit Statistics', 'wp-statistics'),
|
19 |
'wp_statistics_generate_overview_postbox_contents',
|
20 |
$WP_Statistics->menu_slugs['overview'],
|
21 |
'normal',
|
@@ -24,10 +24,10 @@ class WP_Statistics_Admin_Pages {
|
|
24 |
);
|
25 |
}
|
26 |
|
27 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
28 |
add_meta_box(
|
29 |
'wps_top_visitors_postbox',
|
30 |
-
__('Top Visitors', 'wp-statistics'),
|
31 |
'wp_statistics_generate_overview_postbox_contents',
|
32 |
$WP_Statistics->menu_slugs['overview'],
|
33 |
'normal',
|
@@ -36,7 +36,7 @@ class WP_Statistics_Admin_Pages {
|
|
36 |
);
|
37 |
add_meta_box(
|
38 |
'wps_search_postbox',
|
39 |
-
__('Search Engine Referrals', 'wp-statistics'),
|
40 |
'wp_statistics_generate_overview_postbox_contents',
|
41 |
$WP_Statistics->menu_slugs['overview'],
|
42 |
'normal',
|
@@ -45,7 +45,7 @@ class WP_Statistics_Admin_Pages {
|
|
45 |
);
|
46 |
add_meta_box(
|
47 |
'wps_words_postbox',
|
48 |
-
__('Top Searched Phrases (30 Days)', 'wp-statistics'),
|
49 |
'wp_statistics_generate_overview_postbox_contents',
|
50 |
$WP_Statistics->menu_slugs['overview'],
|
51 |
'normal',
|
@@ -54,7 +54,7 @@ class WP_Statistics_Admin_Pages {
|
|
54 |
);
|
55 |
add_meta_box(
|
56 |
'wps_words_postbox',
|
57 |
-
__('Latest Search Words', 'wp-statistics'),
|
58 |
'wp_statistics_generate_overview_postbox_contents',
|
59 |
$WP_Statistics->menu_slugs['overview'],
|
60 |
'normal',
|
@@ -63,7 +63,7 @@ class WP_Statistics_Admin_Pages {
|
|
63 |
);
|
64 |
add_meta_box(
|
65 |
'wps_recent_postbox',
|
66 |
-
__('Recent Visitors', 'wp-statistics'),
|
67 |
'wp_statistics_generate_overview_postbox_contents',
|
68 |
$WP_Statistics->menu_slugs['overview'],
|
69 |
'normal',
|
@@ -71,10 +71,10 @@ class WP_Statistics_Admin_Pages {
|
|
71 |
array( 'widget' => 'recent' )
|
72 |
);
|
73 |
|
74 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
75 |
add_meta_box(
|
76 |
'wps_map_postbox',
|
77 |
-
__('Today\'s Visitors Map', 'wp-statistics'),
|
78 |
'wp_statistics_generate_overview_postbox_contents',
|
79 |
$WP_Statistics->menu_slugs['overview'],
|
80 |
'normal',
|
@@ -84,10 +84,10 @@ class WP_Statistics_Admin_Pages {
|
|
84 |
}
|
85 |
}
|
86 |
|
87 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
88 |
add_meta_box(
|
89 |
'wps_pages_postbox',
|
90 |
-
__('Top 10 Pages', 'wp-statistics'),
|
91 |
'wp_statistics_generate_overview_postbox_contents',
|
92 |
$WP_Statistics->menu_slugs['overview'],
|
93 |
'normal',
|
@@ -97,10 +97,10 @@ class WP_Statistics_Admin_Pages {
|
|
97 |
}
|
98 |
|
99 |
// Left side "thin" widgets.
|
100 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
101 |
add_meta_box(
|
102 |
'wps_summary_postbox',
|
103 |
-
__('Summary', 'wp-statistics'),
|
104 |
'wp_statistics_generate_overview_postbox_contents',
|
105 |
$WP_Statistics->menu_slugs['overview'],
|
106 |
'side',
|
@@ -109,7 +109,7 @@ class WP_Statistics_Admin_Pages {
|
|
109 |
);
|
110 |
add_meta_box(
|
111 |
'wps_browsers_postbox',
|
112 |
-
__('Browsers', 'wp-statistics'),
|
113 |
'wp_statistics_generate_overview_postbox_contents',
|
114 |
$WP_Statistics->menu_slugs['overview'],
|
115 |
'side',
|
@@ -118,7 +118,7 @@ class WP_Statistics_Admin_Pages {
|
|
118 |
);
|
119 |
add_meta_box(
|
120 |
'wps_referring_postbox',
|
121 |
-
__('Top Referring Sites', 'wp-statistics'),
|
122 |
'wp_statistics_generate_overview_postbox_contents',
|
123 |
$WP_Statistics->menu_slugs['overview'],
|
124 |
'side',
|
@@ -126,10 +126,10 @@ class WP_Statistics_Admin_Pages {
|
|
126 |
array( 'widget' => 'referring' )
|
127 |
);
|
128 |
|
129 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
130 |
add_meta_box(
|
131 |
'wps_countries_postbox',
|
132 |
-
__('Top 10 Countries', 'wp-statistics'),
|
133 |
'wp_statistics_generate_overview_postbox_contents',
|
134 |
$WP_Statistics->menu_slugs['overview'],
|
135 |
'side',
|
@@ -155,32 +155,32 @@ class WP_Statistics_Admin_Pages {
|
|
155 |
// Activate or deactivate the selected plugin
|
156 |
if ( isset( $_GET['action'] ) ) {
|
157 |
if ( $_GET['action'] == 'activate' ) {
|
158 |
-
$result = activate_plugin($_GET['plugin'] . '/' . $_GET['plugin'] . '.php');
|
159 |
-
if ( is_wp_error($result) ) {
|
160 |
-
wp_statistics_admin_notice_result('error', $result->get_error_message());
|
161 |
} else {
|
162 |
-
wp_statistics_admin_notice_result('success', __('Add-On activated.', 'wp-statistics'));
|
163 |
}
|
164 |
}
|
165 |
if ( $_GET['action'] == 'deactivate' ) {
|
166 |
-
$result = deactivate_plugins($_GET['plugin'] . '/' . $_GET['plugin'] . '.php');
|
167 |
-
if ( is_wp_error($result) ) {
|
168 |
-
wp_statistics_admin_notice_result('error', $result->get_error_message());
|
169 |
} else {
|
170 |
-
wp_statistics_admin_notice_result('success', __('Add-On deactivated.', 'wp-statistics'));
|
171 |
}
|
172 |
}
|
173 |
}
|
174 |
-
$response = wp_remote_get('https://wp-statistics.com/wp-json/plugin/addons');
|
175 |
-
$response_code = wp_remote_retrieve_response_code($response);
|
176 |
$error = null;
|
177 |
$plugins = array();
|
178 |
// Check response
|
179 |
-
if ( is_wp_error($response) ) {
|
180 |
$error = $response->get_error_message();
|
181 |
} else {
|
182 |
if ( $response_code == '200' ) {
|
183 |
-
$plugins = json_decode($response['body']);
|
184 |
} else {
|
185 |
$error = $response['body'];
|
186 |
}
|
@@ -211,7 +211,7 @@ class WP_Statistics_Admin_Pages {
|
|
211 |
)
|
212 |
)
|
213 |
) {
|
214 |
-
wp_die(__('You do not have sufficient permissions to access this page.'));
|
215 |
}
|
216 |
|
217 |
// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences
|
@@ -227,17 +227,17 @@ class WP_Statistics_Admin_Pages {
|
|
227 |
);
|
228 |
|
229 |
if ( is_rtl() ) {
|
230 |
-
wp_enqueue_style('rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, WP_Statistics::$reg['version']);
|
231 |
}
|
232 |
|
233 |
// Get the row count for each of the tables, we'll use this later on in the wps_optimization.php file.
|
234 |
-
$result['useronline'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_useronline`");
|
235 |
-
$result['visit'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_visit`");
|
236 |
-
$result['visitor'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_visitor`");
|
237 |
-
$result['exclusions'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_exclusions`");
|
238 |
-
$result['pages'] = $wpdb->get_var("SELECT COUNT(uri) FROM `{$wpdb->prefix}statistics_pages`");
|
239 |
-
$result['historical'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_historical`");
|
240 |
-
$result['search'] = $wpdb->get_var("SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_search`");
|
241 |
|
242 |
include WP_Statistics::$reg['plugin-dir'] . "includes/optimization/wps-optimization.php";
|
243 |
}
|
@@ -258,7 +258,7 @@ class WP_Statistics_Admin_Pages {
|
|
258 |
)
|
259 |
)
|
260 |
) {
|
261 |
-
wp_die(__('You do not have sufficient permissions to access this page.'));
|
262 |
}
|
263 |
|
264 |
// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences
|
@@ -274,12 +274,12 @@ class WP_Statistics_Admin_Pages {
|
|
274 |
);
|
275 |
|
276 |
if ( is_rtl() ) {
|
277 |
-
wp_enqueue_style('rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, '1.1');
|
278 |
}
|
279 |
|
280 |
// We could let the download happen at the end of the page, but this way we get to give some
|
281 |
// feedback to the users about the result.
|
282 |
-
if ( $WP_Statistics->get_option('update_geoip') == true ) {
|
283 |
echo WP_Statistics_Updates::download_geoip();
|
284 |
}
|
285 |
|
@@ -296,63 +296,63 @@ class WP_Statistics_Admin_Pages {
|
|
296 |
case WP_Statistics::$page['browser']:
|
297 |
$log_type = 'all-browsers';
|
298 |
|
299 |
-
|
300 |
case WP_Statistics::$page['countries']:
|
301 |
$log_type = 'top-countries';
|
302 |
|
303 |
-
|
304 |
case WP_Statistics::$page['exclusions']:
|
305 |
$log_type = 'exclusions';
|
306 |
|
307 |
-
|
308 |
case WP_Statistics::$page['hits']:
|
309 |
$log_type = 'hit-statistics';
|
310 |
|
311 |
-
|
312 |
case WP_Statistics::$page['online']:
|
313 |
$log_type = 'online';
|
314 |
|
315 |
-
|
316 |
case WP_Statistics::$page['pages']:
|
317 |
$log_type = 'top-pages';
|
318 |
|
319 |
-
|
320 |
case WP_Statistics::$page['categories']:
|
321 |
$log_type = 'categories';
|
322 |
|
323 |
-
|
324 |
case WP_Statistics::$page['tags']:
|
325 |
$log_type = 'tags';
|
326 |
|
327 |
-
|
328 |
case WP_Statistics::$page['authors']:
|
329 |
$log_type = 'authors';
|
330 |
|
331 |
-
|
332 |
case WP_Statistics::$page['referrers']:
|
333 |
$log_type = 'top-referring-site';
|
334 |
|
335 |
-
|
336 |
case WP_Statistics::$page['searched-phrases']:
|
337 |
$log_type = 'searched-phrases';
|
338 |
|
339 |
-
|
340 |
case WP_Statistics::$page['searches']:
|
341 |
$log_type = 'search-statistics';
|
342 |
|
343 |
-
|
344 |
case WP_Statistics::$page['words']:
|
345 |
$log_type = 'last-all-search';
|
346 |
|
347 |
-
|
348 |
case WP_Statistics::$page['top-visitors']:
|
349 |
$log_type = 'top-visitors';
|
350 |
|
351 |
-
|
352 |
case WP_Statistics::$page['visitors']:
|
353 |
$log_type = 'last-all-visitor';
|
354 |
|
355 |
-
|
356 |
default:
|
357 |
$log_type = "";
|
358 |
}
|
@@ -362,7 +362,7 @@ class WP_Statistics_Admin_Pages {
|
|
362 |
$WP_Statistics->load_user_options();
|
363 |
|
364 |
// We allow for a get style variable to be passed to define which function to use.
|
365 |
-
if ( $log_type == "" && array_key_exists('type', $_GET) ) {
|
366 |
$log_type = $_GET['type'];
|
367 |
}
|
368 |
|
@@ -376,7 +376,7 @@ class WP_Statistics_Admin_Pages {
|
|
376 |
)
|
377 |
)
|
378 |
) {
|
379 |
-
wp_die(__('You do not have sufficient permissions to access this page.'));
|
380 |
}
|
381 |
|
382 |
// We want to make sure the tables actually exist before we blindly start access them.
|
@@ -398,7 +398,7 @@ class WP_Statistics_Admin_Pages {
|
|
398 |
if ( $result != 1 ) {
|
399 |
$missing_tables[] = $wpdb->prefix . 'statistics_visitor';
|
400 |
}
|
401 |
-
$result = $wpdb->query("SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visit'");
|
402 |
if ( $result != 1 ) {
|
403 |
$missing_tables[] = $wpdb->prefix . 'statistics_visit';
|
404 |
}
|
@@ -420,7 +420,7 @@ class WP_Statistics_Admin_Pages {
|
|
420 |
if ( $result != 1 ) {
|
421 |
$missing_tables[] = $wpdb->prefix . 'statistics_useronline';
|
422 |
}
|
423 |
-
$result = $wpdb->query("SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_pages'");
|
424 |
if ( $result != 1 ) {
|
425 |
$missing_tables[] = $wpdb->prefix . 'statistics_pages';
|
426 |
}
|
@@ -439,14 +439,14 @@ class WP_Statistics_Admin_Pages {
|
|
439 |
),
|
440 |
'<a href="' . $get_bloginfo_url . '">',
|
441 |
'</a>'
|
442 |
-
) . implode(', ', $missing_tables) . '</p></div>'
|
443 |
);
|
444 |
}
|
445 |
|
446 |
// Load the postbox script that provides the widget style boxes.
|
447 |
-
wp_enqueue_script('common');
|
448 |
-
wp_enqueue_script('wp-lists');
|
449 |
-
wp_enqueue_script('postbox');
|
450 |
|
451 |
// Load the css we use for the statistics pages.
|
452 |
wp_enqueue_style(
|
@@ -485,32 +485,32 @@ class WP_Statistics_Admin_Pages {
|
|
485 |
case 'tags':
|
486 |
case 'authors':
|
487 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/' . $log_type . '.php';
|
488 |
-
|
489 |
case 'last-all-search':
|
490 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-search.php';
|
491 |
|
492 |
-
|
493 |
case 'last-all-visitor':
|
494 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-visitor.php';
|
495 |
|
496 |
-
|
497 |
case 'top-referring-site':
|
498 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-referring.php';
|
499 |
|
500 |
-
|
501 |
case 'searched-phrases':
|
502 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/searched-phrases.php';
|
503 |
|
504 |
-
|
505 |
case 'top-pages':
|
506 |
// If we've been given a page id or uri to get statistics for, load the page stats, otherwise load the page stats overview page.
|
507 |
-
if ( array_key_exists('page-id', $_GET) || array_key_exists('page-uri', $_GET) || array_key_exists('prepage', $_GET) ) {
|
508 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/page-statistics.php';
|
509 |
} else {
|
510 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-pages.php';
|
511 |
}
|
512 |
|
513 |
-
|
514 |
default:
|
515 |
wp_enqueue_style(
|
516 |
'wpstatistics-jqvmap-css',
|
@@ -532,11 +532,11 @@ class WP_Statistics_Admin_Pages {
|
|
532 |
);
|
533 |
|
534 |
// Load our custom widgets handling javascript.
|
535 |
-
wp_enqueue_script('wp_statistics_log', WP_Statistics::$reg['plugin-url'] . 'assets/js/log.js');
|
536 |
|
537 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/log.php';
|
538 |
|
539 |
-
|
540 |
}
|
541 |
}
|
542 |
|
12 |
global $WP_Statistics;
|
13 |
|
14 |
// Right side "wide" widgets
|
15 |
+
if ( $WP_Statistics->get_option( 'visits' ) ) {
|
16 |
add_meta_box(
|
17 |
'wps_hits_postbox',
|
18 |
+
__( 'Hit Statistics', 'wp-statistics' ),
|
19 |
'wp_statistics_generate_overview_postbox_contents',
|
20 |
$WP_Statistics->menu_slugs['overview'],
|
21 |
'normal',
|
24 |
);
|
25 |
}
|
26 |
|
27 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
28 |
add_meta_box(
|
29 |
'wps_top_visitors_postbox',
|
30 |
+
__( 'Top Visitors', 'wp-statistics' ),
|
31 |
'wp_statistics_generate_overview_postbox_contents',
|
32 |
$WP_Statistics->menu_slugs['overview'],
|
33 |
'normal',
|
36 |
);
|
37 |
add_meta_box(
|
38 |
'wps_search_postbox',
|
39 |
+
__( 'Search Engine Referrals', 'wp-statistics' ),
|
40 |
'wp_statistics_generate_overview_postbox_contents',
|
41 |
$WP_Statistics->menu_slugs['overview'],
|
42 |
'normal',
|
45 |
);
|
46 |
add_meta_box(
|
47 |
'wps_words_postbox',
|
48 |
+
__( 'Top Searched Phrases (30 Days)', 'wp-statistics' ),
|
49 |
'wp_statistics_generate_overview_postbox_contents',
|
50 |
$WP_Statistics->menu_slugs['overview'],
|
51 |
'normal',
|
54 |
);
|
55 |
add_meta_box(
|
56 |
'wps_words_postbox',
|
57 |
+
__( 'Latest Search Words', 'wp-statistics' ),
|
58 |
'wp_statistics_generate_overview_postbox_contents',
|
59 |
$WP_Statistics->menu_slugs['overview'],
|
60 |
'normal',
|
63 |
);
|
64 |
add_meta_box(
|
65 |
'wps_recent_postbox',
|
66 |
+
__( 'Recent Visitors', 'wp-statistics' ),
|
67 |
'wp_statistics_generate_overview_postbox_contents',
|
68 |
$WP_Statistics->menu_slugs['overview'],
|
69 |
'normal',
|
71 |
array( 'widget' => 'recent' )
|
72 |
);
|
73 |
|
74 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
75 |
add_meta_box(
|
76 |
'wps_map_postbox',
|
77 |
+
__( 'Today\'s Visitors Map', 'wp-statistics' ),
|
78 |
'wp_statistics_generate_overview_postbox_contents',
|
79 |
$WP_Statistics->menu_slugs['overview'],
|
80 |
'normal',
|
84 |
}
|
85 |
}
|
86 |
|
87 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
88 |
add_meta_box(
|
89 |
'wps_pages_postbox',
|
90 |
+
__( 'Top 10 Pages', 'wp-statistics' ),
|
91 |
'wp_statistics_generate_overview_postbox_contents',
|
92 |
$WP_Statistics->menu_slugs['overview'],
|
93 |
'normal',
|
97 |
}
|
98 |
|
99 |
// Left side "thin" widgets.
|
100 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
101 |
add_meta_box(
|
102 |
'wps_summary_postbox',
|
103 |
+
__( 'Summary', 'wp-statistics' ),
|
104 |
'wp_statistics_generate_overview_postbox_contents',
|
105 |
$WP_Statistics->menu_slugs['overview'],
|
106 |
'side',
|
109 |
);
|
110 |
add_meta_box(
|
111 |
'wps_browsers_postbox',
|
112 |
+
__( 'Browsers', 'wp-statistics' ),
|
113 |
'wp_statistics_generate_overview_postbox_contents',
|
114 |
$WP_Statistics->menu_slugs['overview'],
|
115 |
'side',
|
118 |
);
|
119 |
add_meta_box(
|
120 |
'wps_referring_postbox',
|
121 |
+
__( 'Top Referring Sites', 'wp-statistics' ),
|
122 |
'wp_statistics_generate_overview_postbox_contents',
|
123 |
$WP_Statistics->menu_slugs['overview'],
|
124 |
'side',
|
126 |
array( 'widget' => 'referring' )
|
127 |
);
|
128 |
|
129 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
130 |
add_meta_box(
|
131 |
'wps_countries_postbox',
|
132 |
+
__( 'Top 10 Countries', 'wp-statistics' ),
|
133 |
'wp_statistics_generate_overview_postbox_contents',
|
134 |
$WP_Statistics->menu_slugs['overview'],
|
135 |
'side',
|
155 |
// Activate or deactivate the selected plugin
|
156 |
if ( isset( $_GET['action'] ) ) {
|
157 |
if ( $_GET['action'] == 'activate' ) {
|
158 |
+
$result = activate_plugin( $_GET['plugin'] . '/' . $_GET['plugin'] . '.php' );
|
159 |
+
if ( is_wp_error( $result ) ) {
|
160 |
+
wp_statistics_admin_notice_result( 'error', $result->get_error_message() );
|
161 |
} else {
|
162 |
+
wp_statistics_admin_notice_result( 'success', __( 'Add-On activated.', 'wp-statistics' ) );
|
163 |
}
|
164 |
}
|
165 |
if ( $_GET['action'] == 'deactivate' ) {
|
166 |
+
$result = deactivate_plugins( $_GET['plugin'] . '/' . $_GET['plugin'] . '.php' );
|
167 |
+
if ( is_wp_error( $result ) ) {
|
168 |
+
wp_statistics_admin_notice_result( 'error', $result->get_error_message() );
|
169 |
} else {
|
170 |
+
wp_statistics_admin_notice_result( 'success', __( 'Add-On deactivated.', 'wp-statistics' ) );
|
171 |
}
|
172 |
}
|
173 |
}
|
174 |
+
$response = wp_remote_get( 'https://wp-statistics.com/wp-json/plugin/addons' );
|
175 |
+
$response_code = wp_remote_retrieve_response_code( $response );
|
176 |
$error = null;
|
177 |
$plugins = array();
|
178 |
// Check response
|
179 |
+
if ( is_wp_error( $response ) ) {
|
180 |
$error = $response->get_error_message();
|
181 |
} else {
|
182 |
if ( $response_code == '200' ) {
|
183 |
+
$plugins = json_decode( $response['body'] );
|
184 |
} else {
|
185 |
$error = $response['body'];
|
186 |
}
|
211 |
)
|
212 |
)
|
213 |
) {
|
214 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
215 |
}
|
216 |
|
217 |
// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences
|
227 |
);
|
228 |
|
229 |
if ( is_rtl() ) {
|
230 |
+
wp_enqueue_style( 'rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, WP_Statistics::$reg['version'] );
|
231 |
}
|
232 |
|
233 |
// Get the row count for each of the tables, we'll use this later on in the wps_optimization.php file.
|
234 |
+
$result['useronline'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_useronline`" );
|
235 |
+
$result['visit'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_visit`" );
|
236 |
+
$result['visitor'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_visitor`" );
|
237 |
+
$result['exclusions'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_exclusions`" );
|
238 |
+
$result['pages'] = $wpdb->get_var( "SELECT COUNT(uri) FROM `{$wpdb->prefix}statistics_pages`" );
|
239 |
+
$result['historical'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_historical`" );
|
240 |
+
$result['search'] = $wpdb->get_var( "SELECT COUNT(ID) FROM `{$wpdb->prefix}statistics_search`" );
|
241 |
|
242 |
include WP_Statistics::$reg['plugin-dir'] . "includes/optimization/wps-optimization.php";
|
243 |
}
|
258 |
)
|
259 |
)
|
260 |
) {
|
261 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
262 |
}
|
263 |
|
264 |
// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences
|
274 |
);
|
275 |
|
276 |
if ( is_rtl() ) {
|
277 |
+
wp_enqueue_style( 'rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, '1.1' );
|
278 |
}
|
279 |
|
280 |
// We could let the download happen at the end of the page, but this way we get to give some
|
281 |
// feedback to the users about the result.
|
282 |
+
if ( $WP_Statistics->get_option( 'update_geoip' ) == true ) {
|
283 |
echo WP_Statistics_Updates::download_geoip();
|
284 |
}
|
285 |
|
296 |
case WP_Statistics::$page['browser']:
|
297 |
$log_type = 'all-browsers';
|
298 |
|
299 |
+
break;
|
300 |
case WP_Statistics::$page['countries']:
|
301 |
$log_type = 'top-countries';
|
302 |
|
303 |
+
break;
|
304 |
case WP_Statistics::$page['exclusions']:
|
305 |
$log_type = 'exclusions';
|
306 |
|
307 |
+
break;
|
308 |
case WP_Statistics::$page['hits']:
|
309 |
$log_type = 'hit-statistics';
|
310 |
|
311 |
+
break;
|
312 |
case WP_Statistics::$page['online']:
|
313 |
$log_type = 'online';
|
314 |
|
315 |
+
break;
|
316 |
case WP_Statistics::$page['pages']:
|
317 |
$log_type = 'top-pages';
|
318 |
|
319 |
+
break;
|
320 |
case WP_Statistics::$page['categories']:
|
321 |
$log_type = 'categories';
|
322 |
|
323 |
+
break;
|
324 |
case WP_Statistics::$page['tags']:
|
325 |
$log_type = 'tags';
|
326 |
|
327 |
+
break;
|
328 |
case WP_Statistics::$page['authors']:
|
329 |
$log_type = 'authors';
|
330 |
|
331 |
+
break;
|
332 |
case WP_Statistics::$page['referrers']:
|
333 |
$log_type = 'top-referring-site';
|
334 |
|
335 |
+
break;
|
336 |
case WP_Statistics::$page['searched-phrases']:
|
337 |
$log_type = 'searched-phrases';
|
338 |
|
339 |
+
break;
|
340 |
case WP_Statistics::$page['searches']:
|
341 |
$log_type = 'search-statistics';
|
342 |
|
343 |
+
break;
|
344 |
case WP_Statistics::$page['words']:
|
345 |
$log_type = 'last-all-search';
|
346 |
|
347 |
+
break;
|
348 |
case WP_Statistics::$page['top-visitors']:
|
349 |
$log_type = 'top-visitors';
|
350 |
|
351 |
+
break;
|
352 |
case WP_Statistics::$page['visitors']:
|
353 |
$log_type = 'last-all-visitor';
|
354 |
|
355 |
+
break;
|
356 |
default:
|
357 |
$log_type = "";
|
358 |
}
|
362 |
$WP_Statistics->load_user_options();
|
363 |
|
364 |
// We allow for a get style variable to be passed to define which function to use.
|
365 |
+
if ( $log_type == "" && array_key_exists( 'type', $_GET ) ) {
|
366 |
$log_type = $_GET['type'];
|
367 |
}
|
368 |
|
376 |
)
|
377 |
)
|
378 |
) {
|
379 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
380 |
}
|
381 |
|
382 |
// We want to make sure the tables actually exist before we blindly start access them.
|
398 |
if ( $result != 1 ) {
|
399 |
$missing_tables[] = $wpdb->prefix . 'statistics_visitor';
|
400 |
}
|
401 |
+
$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visit'" );
|
402 |
if ( $result != 1 ) {
|
403 |
$missing_tables[] = $wpdb->prefix . 'statistics_visit';
|
404 |
}
|
420 |
if ( $result != 1 ) {
|
421 |
$missing_tables[] = $wpdb->prefix . 'statistics_useronline';
|
422 |
}
|
423 |
+
$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_pages'" );
|
424 |
if ( $result != 1 ) {
|
425 |
$missing_tables[] = $wpdb->prefix . 'statistics_pages';
|
426 |
}
|
439 |
),
|
440 |
'<a href="' . $get_bloginfo_url . '">',
|
441 |
'</a>'
|
442 |
+
) . implode( ', ', $missing_tables ) . '</p></div>'
|
443 |
);
|
444 |
}
|
445 |
|
446 |
// Load the postbox script that provides the widget style boxes.
|
447 |
+
wp_enqueue_script( 'common' );
|
448 |
+
wp_enqueue_script( 'wp-lists' );
|
449 |
+
wp_enqueue_script( 'postbox' );
|
450 |
|
451 |
// Load the css we use for the statistics pages.
|
452 |
wp_enqueue_style(
|
485 |
case 'tags':
|
486 |
case 'authors':
|
487 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/' . $log_type . '.php';
|
488 |
+
break;
|
489 |
case 'last-all-search':
|
490 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-search.php';
|
491 |
|
492 |
+
break;
|
493 |
case 'last-all-visitor':
|
494 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-visitor.php';
|
495 |
|
496 |
+
break;
|
497 |
case 'top-referring-site':
|
498 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-referring.php';
|
499 |
|
500 |
+
break;
|
501 |
case 'searched-phrases':
|
502 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/searched-phrases.php';
|
503 |
|
504 |
+
break;
|
505 |
case 'top-pages':
|
506 |
// If we've been given a page id or uri to get statistics for, load the page stats, otherwise load the page stats overview page.
|
507 |
+
if ( array_key_exists( 'page-id', $_GET ) || array_key_exists( 'page-uri', $_GET ) || array_key_exists( 'prepage', $_GET ) ) {
|
508 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/page-statistics.php';
|
509 |
} else {
|
510 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-pages.php';
|
511 |
}
|
512 |
|
513 |
+
break;
|
514 |
default:
|
515 |
wp_enqueue_style(
|
516 |
'wpstatistics-jqvmap-css',
|
532 |
);
|
533 |
|
534 |
// Load our custom widgets handling javascript.
|
535 |
+
wp_enqueue_script( 'wp_statistics_log', WP_Statistics::$reg['plugin-url'] . 'assets/js/log.js' );
|
536 |
|
537 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/log/log.php';
|
538 |
|
539 |
+
break;
|
540 |
}
|
541 |
}
|
542 |
|
includes/classes/class-wp-statistics-admin.php
CHANGED
@@ -12,64 +12,67 @@ class WP_Statistics_Admin {
|
|
12 |
global $WP_Statistics;
|
13 |
|
14 |
// Check to see if we're installed and are the current version.
|
15 |
-
WP_Statistics::$installed_version = get_option('wp_statistics_plugin_version');
|
16 |
if ( WP_Statistics::$installed_version != WP_Statistics::$reg['version'] ) {
|
17 |
new WP_Statistics_Install;
|
18 |
}
|
19 |
|
20 |
// If we've been flagged to remove all of the data, then do so now.
|
21 |
-
if ( get_option('wp_statistics_removal') == 'true' ) {
|
22 |
new WP_Statistics_Uninstall;
|
23 |
}
|
24 |
// If we've been removed, return without doing anything else.
|
25 |
-
if ( get_option('wp_statistics_removal') == 'done' ) {
|
26 |
-
add_action('admin_notices', array( $this, 'removal_admin_notice' ), 10, 2);
|
27 |
|
28 |
return;
|
29 |
}
|
30 |
|
31 |
-
add_action('admin_init', 'WP_Statistics_Admin::export_data', 9);
|
32 |
|
33 |
-
add_action('wp_dashboard_setup', 'WP_Statistics_Dashboard::widget_load');
|
34 |
-
add_action('admin_footer', 'WP_Statistics_Dashboard::inline_javascript');
|
35 |
-
add_action('add_meta_boxes', 'WP_Statistics_Editor::add_meta_box');
|
36 |
new WP_Statistics_Ajax;
|
37 |
|
38 |
// Display the admin notices if we should.
|
39 |
-
if ( isset( $pagenow ) && array_key_exists('page', $_GET) ) {
|
40 |
-
if ( $pagenow == "admin.php" && substr($_GET['page'], 0, 14) == 'wp-statistics/' ) {
|
41 |
-
add_action('admin_notices', 'WP_Statistics_Admin::not_enable');
|
42 |
}
|
43 |
}
|
44 |
|
45 |
add_filter(
|
46 |
-
'plugin_action_links_' . plugin_basename(WP_Statistics::$reg['main-file']),
|
47 |
'WP_Statistics_Admin::settings_links',
|
48 |
10,
|
49 |
2
|
50 |
);
|
51 |
|
52 |
-
add_filter('plugin_row_meta', 'WP_Statistics_Admin::add_meta_links', 10, 2);
|
53 |
|
54 |
-
add_action('load-edit.php', 'WP_Statistics_Admin::load_edit_init');
|
55 |
|
56 |
-
if ( $WP_Statistics->get_option('pages') && ! $WP_Statistics->get_option('disable_column') ) {
|
57 |
-
add_action('post_submitbox_misc_actions', 'WP_Statistics_Admin::post_init');
|
58 |
}
|
59 |
|
60 |
-
add_action('admin_menu', 'WP_Statistics_Admin::menu');
|
61 |
|
62 |
if ( is_multisite() ) {
|
63 |
-
add_action('network_admin_menu', 'WP_Statistics_Network_Admin::menu');
|
64 |
}
|
65 |
|
66 |
-
add_action('admin_enqueue_scripts', 'WP_Statistics_Admin::enqueue_scripts');
|
67 |
-
add_action('admin_init', 'WP_Statistics_Shortcode::shortcake');
|
68 |
|
69 |
// WP-Statistics welcome page hooks
|
70 |
-
add_action('admin_menu', 'WP_Statistics_Welcome::menu');
|
71 |
-
add_action('upgrader_process_complete', 'WP_Statistics_Welcome::do_welcome', 10, 2);
|
72 |
-
add_action('admin_init', 'WP_Statistics_Welcome::init');
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -77,8 +80,8 @@ class WP_Statistics_Admin {
|
|
77 |
*/
|
78 |
static function export_data() {
|
79 |
|
80 |
-
if ( array_key_exists('wps_export', $_POST) ) {
|
81 |
-
if ( ! function_exists('wp_statistics_export_data') ) {
|
82 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/functions/export.php';
|
83 |
}
|
84 |
wp_statistics_export_data();
|
@@ -97,14 +100,14 @@ class WP_Statistics_Admin {
|
|
97 |
}
|
98 |
|
99 |
?>
|
100 |
-
|
101 |
-
|
102 |
|
103 |
echo '<p>';
|
104 |
-
echo __('WP Statistics has been removed, please disable and delete it.', 'wp-statistics');
|
105 |
echo '</p>';
|
106 |
?></p>
|
107 |
-
|
108 |
<?php
|
109 |
}
|
110 |
|
@@ -116,7 +119,7 @@ class WP_Statistics_Admin {
|
|
116 |
global $WP_Statistics;
|
117 |
|
118 |
// If the user had told us to be quite, do so.
|
119 |
-
if ( ! $WP_Statistics->get_option('hide_notices') ) {
|
120 |
|
121 |
// Check to make sure the current user can manage WP Statistics,
|
122 |
// if not there's no point displaying the warnings.
|
@@ -126,27 +129,27 @@ class WP_Statistics_Admin {
|
|
126 |
'manage_options'
|
127 |
)
|
128 |
);
|
129 |
-
if ( ! current_user_can($manage_cap) ) {
|
130 |
return;
|
131 |
}
|
132 |
|
133 |
$get_bloginfo_url = get_admin_url() . "admin.php?page=" . WP_Statistics::$page['settings'];
|
134 |
|
135 |
$itemstoenable = array();
|
136 |
-
if ( ! $WP_Statistics->get_option('useronline') ) {
|
137 |
-
$itemstoenable[] = __('online user tracking', 'wp-statistics');
|
138 |
}
|
139 |
-
if ( ! $WP_Statistics->get_option('visits') ) {
|
140 |
-
$itemstoenable[] = __('hit tracking', 'wp-statistics');
|
141 |
}
|
142 |
-
if ( ! $WP_Statistics->get_option('visitors') ) {
|
143 |
-
$itemstoenable[] = __('visitor tracking', 'wp-statistics');
|
144 |
}
|
145 |
-
if ( ! $WP_Statistics->get_option('geoip') && wp_statistics_geoip_supported() ) {
|
146 |
-
$itemstoenable[] = __('geoip collection', 'wp-statistics');
|
147 |
}
|
148 |
|
149 |
-
if ( count($itemstoenable) > 0 ) {
|
150 |
echo '<div class="update-nag">' . sprintf(
|
151 |
__(
|
152 |
'The following features are disabled, please go to %ssettings page%s and enable them: %s',
|
@@ -154,7 +157,7 @@ class WP_Statistics_Admin {
|
|
154 |
),
|
155 |
'<a href="' . $get_bloginfo_url . '">',
|
156 |
'</a>',
|
157 |
-
implode(__(',', 'wp-statistics'), $itemstoenable)
|
158 |
) . '</div>';
|
159 |
}
|
160 |
|
@@ -165,18 +168,18 @@ class WP_Statistics_Admin {
|
|
165 |
|
166 |
$dbupdatestodo = array();
|
167 |
|
168 |
-
if ( ! $WP_Statistics->get_option('search_converted') ) {
|
169 |
-
$dbupdatestodo[] = __('search table', 'wp-statistics');
|
170 |
}
|
171 |
|
172 |
// Check to see if there are any database changes the user hasn't done yet.
|
173 |
-
$dbupdates = $WP_Statistics->get_option('pending_db_updates', false);
|
174 |
|
175 |
// The database updates are stored in an array so loop thorugh it and output some notices.
|
176 |
-
if ( is_array($dbupdates) ) {
|
177 |
$dbstrings = array(
|
178 |
-
'date_ip_agent' => __('countries database index', 'wp-statistics'),
|
179 |
-
'unique_date' => __('visit database index', 'wp-statistics'),
|
180 |
);
|
181 |
|
182 |
foreach ( $dbupdates as $key => $update ) {
|
@@ -185,7 +188,7 @@ class WP_Statistics_Admin {
|
|
185 |
}
|
186 |
}
|
187 |
|
188 |
-
if ( count($dbupdatestodo) > 0 ) {
|
189 |
echo '<div class="update-nag">' . sprintf(
|
190 |
__(
|
191 |
'Database updates are required, please go to %soptimization page%s and update the following: %s',
|
@@ -193,7 +196,7 @@ class WP_Statistics_Admin {
|
|
193 |
),
|
194 |
'<a href="' . $get_bloginfo_url . '">',
|
195 |
'</a>',
|
196 |
-
implode(__(',', 'wp-statistics'), $dbupdatestodo)
|
197 |
) . '</div>';
|
198 |
}
|
199 |
}
|
@@ -204,7 +207,7 @@ class WP_Statistics_Admin {
|
|
204 |
* Add a settings link to the plugin list.
|
205 |
*
|
206 |
* @param string $links Links
|
207 |
-
* @param string $file
|
208 |
*
|
209 |
* @return string Links
|
210 |
*/
|
@@ -212,13 +215,13 @@ class WP_Statistics_Admin {
|
|
212 |
global $WP_Statistics;
|
213 |
|
214 |
$manage_cap = wp_statistics_validate_capability(
|
215 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
216 |
);
|
217 |
|
218 |
-
if ( current_user_can($manage_cap) ) {
|
219 |
array_unshift(
|
220 |
$links,
|
221 |
-
'<a href="' . admin_url('admin.php?page=' . WP_Statistics::$page['settings']) . '">' . __(
|
222 |
'Settings',
|
223 |
'wp-statistics'
|
224 |
) . '</a>'
|
@@ -232,24 +235,24 @@ class WP_Statistics_Admin {
|
|
232 |
* Add a WordPress plugin page and rating links to the meta information to the plugin list.
|
233 |
*
|
234 |
* @param string $links Links
|
235 |
-
* @param string $file
|
236 |
*
|
237 |
* @return array Links
|
238 |
*/
|
239 |
static function add_meta_links( $links, $file ) {
|
240 |
-
if ( $file == plugin_basename(WP_Statistics::$reg['main-file']) ) {
|
241 |
$plugin_url = 'http://wordpress.org/plugins/wp-statistics/';
|
242 |
|
243 |
$links[] = '<a href="' . $plugin_url . '" target="_blank" title="' . __(
|
244 |
'Click here to visit the plugin on WordPress.org',
|
245 |
'wp-statistics'
|
246 |
-
) . '">' . __('Visit WordPress.org page', 'wp-statistics') . '</a>';
|
247 |
|
248 |
$rate_url = 'https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post';
|
249 |
$links[] = '<a href="' . $rate_url . '" target="_blank" title="' . __(
|
250 |
'Click here to rate and review this plugin on WordPress.org',
|
251 |
'wp-statistics'
|
252 |
-
) . '">' . __('Rate this plugin', 'wp-statistics') . '</a>';
|
253 |
}
|
254 |
|
255 |
return $links;
|
@@ -262,17 +265,17 @@ class WP_Statistics_Admin {
|
|
262 |
GLOBAL $WP_Statistics;
|
263 |
|
264 |
$read_cap = wp_statistics_validate_capability(
|
265 |
-
$WP_Statistics->get_option('read_capability', 'manage_options')
|
266 |
);
|
267 |
|
268 |
-
if ( current_user_can($read_cap) && $WP_Statistics->get_option('pages') && ! $WP_Statistics->get_option(
|
269 |
'disable_column'
|
270 |
)
|
271 |
) {
|
272 |
-
$post_types = (array) get_post_types(array( 'show_ui' => true ), 'object');
|
273 |
|
274 |
foreach ( $post_types as $type ) {
|
275 |
-
add_action('manage_' . $type->name . '_posts_columns', 'WP_Statistics_Admin::add_column', 10, 2);
|
276 |
add_action(
|
277 |
'manage_' . $type->name . '_posts_custom_column',
|
278 |
'WP_Statistics_Admin::render_column',
|
@@ -291,7 +294,7 @@ class WP_Statistics_Admin {
|
|
291 |
* @return array Columns
|
292 |
*/
|
293 |
static function add_column( $columns ) {
|
294 |
-
$columns['wp-statistics'] = __('Hits', 'wp-statistics');
|
295 |
|
296 |
return $columns;
|
297 |
}
|
@@ -300,7 +303,7 @@ class WP_Statistics_Admin {
|
|
300 |
* Render the custom column on the post/pages lists.
|
301 |
*
|
302 |
* @param string $column_name Column Name
|
303 |
-
* @param string $post_id
|
304 |
*/
|
305 |
static function render_column( $column_name, $post_id ) {
|
306 |
if ( $column_name == 'wp-statistics' ) {
|
@@ -309,7 +312,7 @@ class WP_Statistics_Admin {
|
|
309 |
"admin.php?page=" .
|
310 |
WP_Statistics::$page['pages'] .
|
311 |
"&page-id={$post_id}'>" .
|
312 |
-
wp_statistics_pages('total', "", $post_id) .
|
313 |
"</a>";
|
314 |
}
|
315 |
}
|
@@ -323,13 +326,13 @@ class WP_Statistics_Admin {
|
|
323 |
$id = $post->ID;
|
324 |
|
325 |
echo "<div class='misc-pub-section'>" .
|
326 |
-
__('WP Statistics - Hits', 'wp-statistics') .
|
327 |
": <b><a href='" .
|
328 |
get_admin_url() .
|
329 |
"admin.php?page=" .
|
330 |
WP_Statistics::$page['pages'] .
|
331 |
"&page-id={$id}'>" .
|
332 |
-
wp_statistics_pages('total', "", $id) .
|
333 |
"</a></b></div>";
|
334 |
}
|
335 |
|
@@ -341,16 +344,16 @@ class WP_Statistics_Admin {
|
|
341 |
|
342 |
// Get the read/write capabilities required to view/manage the plugin as set by the user.
|
343 |
$read_cap = wp_statistics_validate_capability(
|
344 |
-
$WP_Statistics->get_option('read_capability', 'manage_options')
|
345 |
);
|
346 |
$manage_cap = wp_statistics_validate_capability(
|
347 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
348 |
);
|
349 |
|
350 |
// Add the top level menu.
|
351 |
$WP_Statistics->menu_slugs['top'] = add_menu_page(
|
352 |
-
__('Statistics', 'wp-statistics'),
|
353 |
-
__('Statistics', 'wp-statistics'),
|
354 |
$read_cap,
|
355 |
WP_Statistics::$page['overview'],
|
356 |
'WP_Statistics_Admin_Pages::log',
|
@@ -360,157 +363,157 @@ class WP_Statistics_Admin {
|
|
360 |
// Add the sub items.
|
361 |
$WP_Statistics->menu_slugs['overview'] = add_submenu_page(
|
362 |
WP_Statistics::$page['overview'],
|
363 |
-
__('Overview', 'wp-statistics'),
|
364 |
-
__('Overview', 'wp-statistics'),
|
365 |
$read_cap,
|
366 |
WP_Statistics::$page['overview'],
|
367 |
'WP_Statistics_Admin_Pages::log'
|
368 |
);
|
369 |
-
if ( $WP_Statistics->get_option('visits') ) {
|
370 |
$WP_Statistics->menu_slugs['hits'] = add_submenu_page(
|
371 |
WP_Statistics::$page['overview'],
|
372 |
-
__('Hits', 'wp-statistics'),
|
373 |
-
__('Hits', 'wp-statistics'),
|
374 |
$read_cap,
|
375 |
WP_Statistics::$page['hits'],
|
376 |
'WP_Statistics_Admin_Pages::log'
|
377 |
);
|
378 |
}
|
379 |
-
if ( $WP_Statistics->get_option('useronline') ) {
|
380 |
$WP_Statistics->menu_slugs['online'] = add_submenu_page(
|
381 |
WP_Statistics::$page['overview'],
|
382 |
-
__('Online', 'wp-statistics'),
|
383 |
-
__('Online', 'wp-statistics'),
|
384 |
$read_cap,
|
385 |
WP_Statistics::$page['online'],
|
386 |
'WP_Statistics_Admin_Pages::log'
|
387 |
);
|
388 |
}
|
389 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
390 |
$WP_Statistics->menu_slugs['referrers'] = add_submenu_page(
|
391 |
WP_Statistics::$page['overview'],
|
392 |
-
__('Referrers', 'wp-statistics'),
|
393 |
-
__('Referrers', 'wp-statistics'),
|
394 |
$read_cap,
|
395 |
WP_Statistics::$page['referrers'],
|
396 |
'WP_Statistics_Admin_Pages::log'
|
397 |
);
|
398 |
}
|
399 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
400 |
$WP_Statistics->menu_slugs['words'] = add_submenu_page(
|
401 |
WP_Statistics::$page['overview'],
|
402 |
-
__('Search Words', 'wp-statistics'),
|
403 |
-
__('Search Words', 'wp-statistics'),
|
404 |
$read_cap,
|
405 |
WP_Statistics::$page['words'],
|
406 |
'WP_Statistics_Admin_Pages::log'
|
407 |
);
|
408 |
}
|
409 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
410 |
$WP_Statistics->menu_slugs['searched.phrases'] = add_submenu_page(
|
411 |
WP_Statistics::$page['overview'],
|
412 |
-
__('Top Search Words', 'wp-statistics'),
|
413 |
-
__('Top Search Words', 'wp-statistics'),
|
414 |
$read_cap,
|
415 |
WP_Statistics::$page['searched-phrases'],
|
416 |
'WP_Statistics_Admin_Pages::log'
|
417 |
);
|
418 |
}
|
419 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
420 |
$WP_Statistics->menu_slugs['searches'] = add_submenu_page(
|
421 |
WP_Statistics::$page['overview'],
|
422 |
-
__('Search Engines', 'wp-statistics'),
|
423 |
-
__('Search Engines', 'wp-statistics'),
|
424 |
$read_cap,
|
425 |
WP_Statistics::$page['searches'],
|
426 |
'WP_Statistics_Admin_Pages::log'
|
427 |
);
|
428 |
}
|
429 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
430 |
$WP_Statistics->menu_slugs['pages'] = add_submenu_page(
|
431 |
WP_Statistics::$page['overview'],
|
432 |
-
__('Pages', 'wp-statistics'),
|
433 |
-
__('Pages', 'wp-statistics'),
|
434 |
$read_cap,
|
435 |
WP_Statistics::$page['pages'],
|
436 |
'WP_Statistics_Admin_Pages::log'
|
437 |
);
|
438 |
}
|
439 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
440 |
$WP_Statistics->menu_slugs['visitors'] = add_submenu_page(
|
441 |
WP_Statistics::$page['overview'],
|
442 |
-
__('Visitors', 'wp-statistics'),
|
443 |
-
__('Visitors', 'wp-statistics'),
|
444 |
$read_cap,
|
445 |
WP_Statistics::$page['visitors'],
|
446 |
'WP_Statistics_Admin_Pages::log'
|
447 |
);
|
448 |
}
|
449 |
-
if ( $WP_Statistics->get_option('geoip') && $WP_Statistics->get_option('visitors') ) {
|
450 |
$WP_Statistics->menu_slugs['countries'] = add_submenu_page(
|
451 |
WP_Statistics::$page['overview'],
|
452 |
-
__('Countries', 'wp-statistics'),
|
453 |
-
__('Countries', 'wp-statistics'),
|
454 |
$read_cap,
|
455 |
WP_Statistics::$page['countries'],
|
456 |
'WP_Statistics_Admin_Pages::log'
|
457 |
);
|
458 |
}
|
459 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
460 |
$WP_Statistics->menu_slugs['categories'] = add_submenu_page(
|
461 |
WP_Statistics::$page['overview'],
|
462 |
-
__('Categories', 'wp-statistics'),
|
463 |
-
__('Categories', 'wp-statistics'),
|
464 |
$read_cap,
|
465 |
WP_Statistics::$page['categories'],
|
466 |
'WP_Statistics_Admin_Pages::log'
|
467 |
);
|
468 |
}
|
469 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
470 |
$WP_Statistics->menu_slugs['tags'] = add_submenu_page(
|
471 |
WP_Statistics::$page['overview'],
|
472 |
-
__('Tags', 'wp-statistics'),
|
473 |
-
__('Tags', 'wp-statistics'),
|
474 |
$read_cap,
|
475 |
WP_Statistics::$page['tags'],
|
476 |
'WP_Statistics_Admin_Pages::log'
|
477 |
);
|
478 |
}
|
479 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
480 |
$WP_Statistics->menu_slugs['authors'] = add_submenu_page(
|
481 |
WP_Statistics::$page['overview'],
|
482 |
-
__('Authors', 'wp-statistics'),
|
483 |
-
__('Authors', 'wp-statistics'),
|
484 |
$read_cap,
|
485 |
WP_Statistics::$page['authors'],
|
486 |
'WP_Statistics_Admin_Pages::log'
|
487 |
);
|
488 |
}
|
489 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
490 |
$WP_Statistics->menu_slugs['browsers'] = add_submenu_page(
|
491 |
WP_Statistics::$page['overview'],
|
492 |
-
__('Browsers', 'wp-statistics'),
|
493 |
-
__('Browsers', 'wp-statistics'),
|
494 |
$read_cap,
|
495 |
WP_Statistics::$page['browser'],
|
496 |
'WP_Statistics_Admin_Pages::log'
|
497 |
);
|
498 |
}
|
499 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
500 |
$WP_Statistics->menu_slugs['top.visotors'] = add_submenu_page(
|
501 |
WP_Statistics::$page['overview'],
|
502 |
-
__('Top Visitors Today', 'wp-statistics'),
|
503 |
-
__('Top Visitors Today', 'wp-statistics'),
|
504 |
$read_cap,
|
505 |
WP_Statistics::$page['top-visitors'],
|
506 |
'WP_Statistics_Admin_Pages::log'
|
507 |
);
|
508 |
}
|
509 |
-
if ( $WP_Statistics->get_option('record_exclusions') ) {
|
510 |
$WP_Statistics->menu_slugs['exclusions'] = add_submenu_page(
|
511 |
WP_Statistics::$page['overview'],
|
512 |
-
__('Exclusions', 'wp-statistics'),
|
513 |
-
__('Exclusions', 'wp-statistics'),
|
514 |
$read_cap,
|
515 |
WP_Statistics::$page['exclusions'],
|
516 |
'WP_Statistics_Admin_Pages::log'
|
@@ -526,39 +529,39 @@ class WP_Statistics_Admin {
|
|
526 |
);
|
527 |
$WP_Statistics->menu_slugs['optimize'] = add_submenu_page(
|
528 |
WP_Statistics::$page['overview'],
|
529 |
-
__('Optimization', 'wp-statistics'),
|
530 |
-
__('Optimization', 'wp-statistics'),
|
531 |
$manage_cap,
|
532 |
WP_Statistics::$page['optimization'],
|
533 |
'WP_Statistics_Admin_Pages::optimization'
|
534 |
);
|
535 |
$WP_Statistics->menu_slugs['settings'] = add_submenu_page(
|
536 |
WP_Statistics::$page['overview'],
|
537 |
-
__('Settings', 'wp-statistics'),
|
538 |
-
__('Settings', 'wp-statistics'),
|
539 |
$read_cap,
|
540 |
WP_Statistics::$page['settings'],
|
541 |
'WP_Statistics_Admin_Pages::settings'
|
542 |
);
|
543 |
$WP_Statistics->menu_slugs['plugins'] = add_submenu_page(
|
544 |
WP_Statistics::$page['overview'],
|
545 |
-
__('Add-Ons', 'wp-statistics'),
|
546 |
-
'<span style="color:#dc6b26">' . __('Add-Ons', 'wp-statistics') . '</span>',
|
547 |
$read_cap,
|
548 |
WP_Statistics::$page['plugins'],
|
549 |
'WP_Statistics_Admin_Pages::plugins'
|
550 |
);
|
551 |
$WP_Statistics->menu_slugs['donate'] = add_submenu_page(
|
552 |
WP_Statistics::$page['overview'],
|
553 |
-
__('Donate', 'wp-statistics'),
|
554 |
-
'<span style="color:#459605">' . __('Donate', 'wp-statistics') . '</span>',
|
555 |
$read_cap,
|
556 |
WP_Statistics::$page['donate'],
|
557 |
'WP_Statistics_Admin_Pages::donate'
|
558 |
);
|
559 |
|
560 |
// Add action to load the meta boxes to the overview page.
|
561 |
-
add_action('load-' . $WP_Statistics->menu_slugs['overview'], 'WP_Statistics_Admin_Pages::overview');
|
562 |
|
563 |
}
|
564 |
|
@@ -578,7 +581,7 @@ class WP_Statistics_Admin {
|
|
578 |
);
|
579 |
|
580 |
if ( is_rtl() ) {
|
581 |
-
wp_enqueue_style('rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, WP_Statistics::$reg['version']);
|
582 |
}
|
583 |
|
584 |
if ( ! isset( $_GET['page'] ) ) {
|
@@ -596,7 +599,7 @@ class WP_Statistics_Admin {
|
|
596 |
'wps_searches_page',
|
597 |
);
|
598 |
|
599 |
-
if ( array_search($_GET['page'], $pages_required_chart) !== false ) {
|
600 |
$load_in_footer = true;
|
601 |
$pages_required_load_in_head = array(
|
602 |
'wps_browsers_page',
|
@@ -608,7 +611,7 @@ class WP_Statistics_Admin {
|
|
608 |
'wps_searches_page',
|
609 |
);
|
610 |
|
611 |
-
if ( array_search($_GET['page'], $pages_required_load_in_head) !== false ) {
|
612 |
$load_in_footer = false;
|
613 |
}
|
614 |
|
@@ -622,5 +625,49 @@ class WP_Statistics_Admin {
|
|
622 |
}
|
623 |
}
|
624 |
|
625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
}
|
12 |
global $WP_Statistics;
|
13 |
|
14 |
// Check to see if we're installed and are the current version.
|
15 |
+
WP_Statistics::$installed_version = get_option( 'wp_statistics_plugin_version' );
|
16 |
if ( WP_Statistics::$installed_version != WP_Statistics::$reg['version'] ) {
|
17 |
new WP_Statistics_Install;
|
18 |
}
|
19 |
|
20 |
// If we've been flagged to remove all of the data, then do so now.
|
21 |
+
if ( get_option( 'wp_statistics_removal' ) == 'true' ) {
|
22 |
new WP_Statistics_Uninstall;
|
23 |
}
|
24 |
// If we've been removed, return without doing anything else.
|
25 |
+
if ( get_option( 'wp_statistics_removal' ) == 'done' ) {
|
26 |
+
add_action( 'admin_notices', array( $this, 'removal_admin_notice' ), 10, 2 );
|
27 |
|
28 |
return;
|
29 |
}
|
30 |
|
31 |
+
add_action( 'admin_init', 'WP_Statistics_Admin::export_data', 9 );
|
32 |
|
33 |
+
add_action( 'wp_dashboard_setup', 'WP_Statistics_Dashboard::widget_load' );
|
34 |
+
add_action( 'admin_footer', 'WP_Statistics_Dashboard::inline_javascript' );
|
35 |
+
add_action( 'add_meta_boxes', 'WP_Statistics_Editor::add_meta_box' );
|
36 |
new WP_Statistics_Ajax;
|
37 |
|
38 |
// Display the admin notices if we should.
|
39 |
+
if ( isset( $pagenow ) && array_key_exists( 'page', $_GET ) ) {
|
40 |
+
if ( $pagenow == "admin.php" && substr( $_GET['page'], 0, 14 ) == 'wp-statistics/' ) {
|
41 |
+
add_action( 'admin_notices', 'WP_Statistics_Admin::not_enable' );
|
42 |
}
|
43 |
}
|
44 |
|
45 |
add_filter(
|
46 |
+
'plugin_action_links_' . plugin_basename( WP_Statistics::$reg['main-file'] ),
|
47 |
'WP_Statistics_Admin::settings_links',
|
48 |
10,
|
49 |
2
|
50 |
);
|
51 |
|
52 |
+
add_filter( 'plugin_row_meta', 'WP_Statistics_Admin::add_meta_links', 10, 2 );
|
53 |
|
54 |
+
add_action( 'load-edit.php', 'WP_Statistics_Admin::load_edit_init' );
|
55 |
|
56 |
+
if ( $WP_Statistics->get_option( 'pages' ) && ! $WP_Statistics->get_option( 'disable_column' ) ) {
|
57 |
+
add_action( 'post_submitbox_misc_actions', 'WP_Statistics_Admin::post_init' );
|
58 |
}
|
59 |
|
60 |
+
add_action( 'admin_menu', 'WP_Statistics_Admin::menu' );
|
61 |
|
62 |
if ( is_multisite() ) {
|
63 |
+
add_action( 'network_admin_menu', 'WP_Statistics_Network_Admin::menu' );
|
64 |
}
|
65 |
|
66 |
+
add_action( 'admin_enqueue_scripts', 'WP_Statistics_Admin::enqueue_scripts' );
|
67 |
+
add_action( 'admin_init', 'WP_Statistics_Shortcode::shortcake' );
|
68 |
|
69 |
// WP-Statistics welcome page hooks
|
70 |
+
add_action( 'admin_menu', 'WP_Statistics_Welcome::menu' );
|
71 |
+
add_action( 'upgrader_process_complete', 'WP_Statistics_Welcome::do_welcome', 10, 2 );
|
72 |
+
add_action( 'admin_init', 'WP_Statistics_Welcome::init' );
|
73 |
+
|
74 |
+
// Runs some scripts at the end of the admin panel inside the body tag.
|
75 |
+
add_action('admin_footer', array($this, 'admin_footer_scripts'));
|
76 |
}
|
77 |
|
78 |
/**
|
80 |
*/
|
81 |
static function export_data() {
|
82 |
|
83 |
+
if ( array_key_exists( 'wps_export', $_POST ) ) {
|
84 |
+
if ( ! function_exists( 'wp_statistics_export_data' ) ) {
|
85 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/functions/export.php';
|
86 |
}
|
87 |
wp_statistics_export_data();
|
100 |
}
|
101 |
|
102 |
?>
|
103 |
+
<div class="error">
|
104 |
+
<p style="max-width:800px;"><?php
|
105 |
|
106 |
echo '<p>';
|
107 |
+
echo __( 'WP Statistics has been removed, please disable and delete it.', 'wp-statistics' );
|
108 |
echo '</p>';
|
109 |
?></p>
|
110 |
+
</div>
|
111 |
<?php
|
112 |
}
|
113 |
|
119 |
global $WP_Statistics;
|
120 |
|
121 |
// If the user had told us to be quite, do so.
|
122 |
+
if ( ! $WP_Statistics->get_option( 'hide_notices' ) ) {
|
123 |
|
124 |
// Check to make sure the current user can manage WP Statistics,
|
125 |
// if not there's no point displaying the warnings.
|
129 |
'manage_options'
|
130 |
)
|
131 |
);
|
132 |
+
if ( ! current_user_can( $manage_cap ) ) {
|
133 |
return;
|
134 |
}
|
135 |
|
136 |
$get_bloginfo_url = get_admin_url() . "admin.php?page=" . WP_Statistics::$page['settings'];
|
137 |
|
138 |
$itemstoenable = array();
|
139 |
+
if ( ! $WP_Statistics->get_option( 'useronline' ) ) {
|
140 |
+
$itemstoenable[] = __( 'online user tracking', 'wp-statistics' );
|
141 |
}
|
142 |
+
if ( ! $WP_Statistics->get_option( 'visits' ) ) {
|
143 |
+
$itemstoenable[] = __( 'hit tracking', 'wp-statistics' );
|
144 |
}
|
145 |
+
if ( ! $WP_Statistics->get_option( 'visitors' ) ) {
|
146 |
+
$itemstoenable[] = __( 'visitor tracking', 'wp-statistics' );
|
147 |
}
|
148 |
+
if ( ! $WP_Statistics->get_option( 'geoip' ) && wp_statistics_geoip_supported() ) {
|
149 |
+
$itemstoenable[] = __( 'geoip collection', 'wp-statistics' );
|
150 |
}
|
151 |
|
152 |
+
if ( count( $itemstoenable ) > 0 ) {
|
153 |
echo '<div class="update-nag">' . sprintf(
|
154 |
__(
|
155 |
'The following features are disabled, please go to %ssettings page%s and enable them: %s',
|
157 |
),
|
158 |
'<a href="' . $get_bloginfo_url . '">',
|
159 |
'</a>',
|
160 |
+
implode( __( ',', 'wp-statistics' ), $itemstoenable )
|
161 |
) . '</div>';
|
162 |
}
|
163 |
|
168 |
|
169 |
$dbupdatestodo = array();
|
170 |
|
171 |
+
if ( ! $WP_Statistics->get_option( 'search_converted' ) ) {
|
172 |
+
$dbupdatestodo[] = __( 'search table', 'wp-statistics' );
|
173 |
}
|
174 |
|
175 |
// Check to see if there are any database changes the user hasn't done yet.
|
176 |
+
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates', false );
|
177 |
|
178 |
// The database updates are stored in an array so loop thorugh it and output some notices.
|
179 |
+
if ( is_array( $dbupdates ) ) {
|
180 |
$dbstrings = array(
|
181 |
+
'date_ip_agent' => __( 'countries database index', 'wp-statistics' ),
|
182 |
+
'unique_date' => __( 'visit database index', 'wp-statistics' ),
|
183 |
);
|
184 |
|
185 |
foreach ( $dbupdates as $key => $update ) {
|
188 |
}
|
189 |
}
|
190 |
|
191 |
+
if ( count( $dbupdatestodo ) > 0 ) {
|
192 |
echo '<div class="update-nag">' . sprintf(
|
193 |
__(
|
194 |
'Database updates are required, please go to %soptimization page%s and update the following: %s',
|
196 |
),
|
197 |
'<a href="' . $get_bloginfo_url . '">',
|
198 |
'</a>',
|
199 |
+
implode( __( ',', 'wp-statistics' ), $dbupdatestodo )
|
200 |
) . '</div>';
|
201 |
}
|
202 |
}
|
207 |
* Add a settings link to the plugin list.
|
208 |
*
|
209 |
* @param string $links Links
|
210 |
+
* @param string $file Not Used!
|
211 |
*
|
212 |
* @return string Links
|
213 |
*/
|
215 |
global $WP_Statistics;
|
216 |
|
217 |
$manage_cap = wp_statistics_validate_capability(
|
218 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
219 |
);
|
220 |
|
221 |
+
if ( current_user_can( $manage_cap ) ) {
|
222 |
array_unshift(
|
223 |
$links,
|
224 |
+
'<a href="' . admin_url( 'admin.php?page=' . WP_Statistics::$page['settings'] ) . '">' . __(
|
225 |
'Settings',
|
226 |
'wp-statistics'
|
227 |
) . '</a>'
|
235 |
* Add a WordPress plugin page and rating links to the meta information to the plugin list.
|
236 |
*
|
237 |
* @param string $links Links
|
238 |
+
* @param string $file File
|
239 |
*
|
240 |
* @return array Links
|
241 |
*/
|
242 |
static function add_meta_links( $links, $file ) {
|
243 |
+
if ( $file == plugin_basename( WP_Statistics::$reg['main-file'] ) ) {
|
244 |
$plugin_url = 'http://wordpress.org/plugins/wp-statistics/';
|
245 |
|
246 |
$links[] = '<a href="' . $plugin_url . '" target="_blank" title="' . __(
|
247 |
'Click here to visit the plugin on WordPress.org',
|
248 |
'wp-statistics'
|
249 |
+
) . '">' . __( 'Visit WordPress.org page', 'wp-statistics' ) . '</a>';
|
250 |
|
251 |
$rate_url = 'https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post';
|
252 |
$links[] = '<a href="' . $rate_url . '" target="_blank" title="' . __(
|
253 |
'Click here to rate and review this plugin on WordPress.org',
|
254 |
'wp-statistics'
|
255 |
+
) . '">' . __( 'Rate this plugin', 'wp-statistics' ) . '</a>';
|
256 |
}
|
257 |
|
258 |
return $links;
|
265 |
GLOBAL $WP_Statistics;
|
266 |
|
267 |
$read_cap = wp_statistics_validate_capability(
|
268 |
+
$WP_Statistics->get_option( 'read_capability', 'manage_options' )
|
269 |
);
|
270 |
|
271 |
+
if ( current_user_can( $read_cap ) && $WP_Statistics->get_option( 'pages' ) && ! $WP_Statistics->get_option(
|
272 |
'disable_column'
|
273 |
)
|
274 |
) {
|
275 |
+
$post_types = (array) get_post_types( array( 'show_ui' => true ), 'object' );
|
276 |
|
277 |
foreach ( $post_types as $type ) {
|
278 |
+
add_action( 'manage_' . $type->name . '_posts_columns', 'WP_Statistics_Admin::add_column', 10, 2 );
|
279 |
add_action(
|
280 |
'manage_' . $type->name . '_posts_custom_column',
|
281 |
'WP_Statistics_Admin::render_column',
|
294 |
* @return array Columns
|
295 |
*/
|
296 |
static function add_column( $columns ) {
|
297 |
+
$columns['wp-statistics'] = __( 'Hits', 'wp-statistics' );
|
298 |
|
299 |
return $columns;
|
300 |
}
|
303 |
* Render the custom column on the post/pages lists.
|
304 |
*
|
305 |
* @param string $column_name Column Name
|
306 |
+
* @param string $post_id Post ID
|
307 |
*/
|
308 |
static function render_column( $column_name, $post_id ) {
|
309 |
if ( $column_name == 'wp-statistics' ) {
|
312 |
"admin.php?page=" .
|
313 |
WP_Statistics::$page['pages'] .
|
314 |
"&page-id={$post_id}'>" .
|
315 |
+
wp_statistics_pages( 'total', "", $post_id ) .
|
316 |
"</a>";
|
317 |
}
|
318 |
}
|
326 |
$id = $post->ID;
|
327 |
|
328 |
echo "<div class='misc-pub-section'>" .
|
329 |
+
__( 'WP Statistics - Hits', 'wp-statistics' ) .
|
330 |
": <b><a href='" .
|
331 |
get_admin_url() .
|
332 |
"admin.php?page=" .
|
333 |
WP_Statistics::$page['pages'] .
|
334 |
"&page-id={$id}'>" .
|
335 |
+
wp_statistics_pages( 'total', "", $id ) .
|
336 |
"</a></b></div>";
|
337 |
}
|
338 |
|
344 |
|
345 |
// Get the read/write capabilities required to view/manage the plugin as set by the user.
|
346 |
$read_cap = wp_statistics_validate_capability(
|
347 |
+
$WP_Statistics->get_option( 'read_capability', 'manage_options' )
|
348 |
);
|
349 |
$manage_cap = wp_statistics_validate_capability(
|
350 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
351 |
);
|
352 |
|
353 |
// Add the top level menu.
|
354 |
$WP_Statistics->menu_slugs['top'] = add_menu_page(
|
355 |
+
__( 'Statistics', 'wp-statistics' ),
|
356 |
+
__( 'Statistics', 'wp-statistics' ),
|
357 |
$read_cap,
|
358 |
WP_Statistics::$page['overview'],
|
359 |
'WP_Statistics_Admin_Pages::log',
|
363 |
// Add the sub items.
|
364 |
$WP_Statistics->menu_slugs['overview'] = add_submenu_page(
|
365 |
WP_Statistics::$page['overview'],
|
366 |
+
__( 'Overview', 'wp-statistics' ),
|
367 |
+
__( 'Overview', 'wp-statistics' ),
|
368 |
$read_cap,
|
369 |
WP_Statistics::$page['overview'],
|
370 |
'WP_Statistics_Admin_Pages::log'
|
371 |
);
|
372 |
+
if ( $WP_Statistics->get_option( 'visits' ) ) {
|
373 |
$WP_Statistics->menu_slugs['hits'] = add_submenu_page(
|
374 |
WP_Statistics::$page['overview'],
|
375 |
+
__( 'Hits', 'wp-statistics' ),
|
376 |
+
__( 'Hits', 'wp-statistics' ),
|
377 |
$read_cap,
|
378 |
WP_Statistics::$page['hits'],
|
379 |
'WP_Statistics_Admin_Pages::log'
|
380 |
);
|
381 |
}
|
382 |
+
if ( $WP_Statistics->get_option( 'useronline' ) ) {
|
383 |
$WP_Statistics->menu_slugs['online'] = add_submenu_page(
|
384 |
WP_Statistics::$page['overview'],
|
385 |
+
__( 'Online', 'wp-statistics' ),
|
386 |
+
__( 'Online', 'wp-statistics' ),
|
387 |
$read_cap,
|
388 |
WP_Statistics::$page['online'],
|
389 |
'WP_Statistics_Admin_Pages::log'
|
390 |
);
|
391 |
}
|
392 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
393 |
$WP_Statistics->menu_slugs['referrers'] = add_submenu_page(
|
394 |
WP_Statistics::$page['overview'],
|
395 |
+
__( 'Referrers', 'wp-statistics' ),
|
396 |
+
__( 'Referrers', 'wp-statistics' ),
|
397 |
$read_cap,
|
398 |
WP_Statistics::$page['referrers'],
|
399 |
'WP_Statistics_Admin_Pages::log'
|
400 |
);
|
401 |
}
|
402 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
403 |
$WP_Statistics->menu_slugs['words'] = add_submenu_page(
|
404 |
WP_Statistics::$page['overview'],
|
405 |
+
__( 'Search Words', 'wp-statistics' ),
|
406 |
+
__( 'Search Words', 'wp-statistics' ),
|
407 |
$read_cap,
|
408 |
WP_Statistics::$page['words'],
|
409 |
'WP_Statistics_Admin_Pages::log'
|
410 |
);
|
411 |
}
|
412 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
413 |
$WP_Statistics->menu_slugs['searched.phrases'] = add_submenu_page(
|
414 |
WP_Statistics::$page['overview'],
|
415 |
+
__( 'Top Search Words', 'wp-statistics' ),
|
416 |
+
__( 'Top Search Words', 'wp-statistics' ),
|
417 |
$read_cap,
|
418 |
WP_Statistics::$page['searched-phrases'],
|
419 |
'WP_Statistics_Admin_Pages::log'
|
420 |
);
|
421 |
}
|
422 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
423 |
$WP_Statistics->menu_slugs['searches'] = add_submenu_page(
|
424 |
WP_Statistics::$page['overview'],
|
425 |
+
__( 'Search Engines', 'wp-statistics' ),
|
426 |
+
__( 'Search Engines', 'wp-statistics' ),
|
427 |
$read_cap,
|
428 |
WP_Statistics::$page['searches'],
|
429 |
'WP_Statistics_Admin_Pages::log'
|
430 |
);
|
431 |
}
|
432 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
433 |
$WP_Statistics->menu_slugs['pages'] = add_submenu_page(
|
434 |
WP_Statistics::$page['overview'],
|
435 |
+
__( 'Pages', 'wp-statistics' ),
|
436 |
+
__( 'Pages', 'wp-statistics' ),
|
437 |
$read_cap,
|
438 |
WP_Statistics::$page['pages'],
|
439 |
'WP_Statistics_Admin_Pages::log'
|
440 |
);
|
441 |
}
|
442 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
443 |
$WP_Statistics->menu_slugs['visitors'] = add_submenu_page(
|
444 |
WP_Statistics::$page['overview'],
|
445 |
+
__( 'Visitors', 'wp-statistics' ),
|
446 |
+
__( 'Visitors', 'wp-statistics' ),
|
447 |
$read_cap,
|
448 |
WP_Statistics::$page['visitors'],
|
449 |
'WP_Statistics_Admin_Pages::log'
|
450 |
);
|
451 |
}
|
452 |
+
if ( $WP_Statistics->get_option( 'geoip' ) && $WP_Statistics->get_option( 'visitors' ) ) {
|
453 |
$WP_Statistics->menu_slugs['countries'] = add_submenu_page(
|
454 |
WP_Statistics::$page['overview'],
|
455 |
+
__( 'Countries', 'wp-statistics' ),
|
456 |
+
__( 'Countries', 'wp-statistics' ),
|
457 |
$read_cap,
|
458 |
WP_Statistics::$page['countries'],
|
459 |
'WP_Statistics_Admin_Pages::log'
|
460 |
);
|
461 |
}
|
462 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
463 |
$WP_Statistics->menu_slugs['categories'] = add_submenu_page(
|
464 |
WP_Statistics::$page['overview'],
|
465 |
+
__( 'Categories', 'wp-statistics' ),
|
466 |
+
__( 'Categories', 'wp-statistics' ),
|
467 |
$read_cap,
|
468 |
WP_Statistics::$page['categories'],
|
469 |
'WP_Statistics_Admin_Pages::log'
|
470 |
);
|
471 |
}
|
472 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
473 |
$WP_Statistics->menu_slugs['tags'] = add_submenu_page(
|
474 |
WP_Statistics::$page['overview'],
|
475 |
+
__( 'Tags', 'wp-statistics' ),
|
476 |
+
__( 'Tags', 'wp-statistics' ),
|
477 |
$read_cap,
|
478 |
WP_Statistics::$page['tags'],
|
479 |
'WP_Statistics_Admin_Pages::log'
|
480 |
);
|
481 |
}
|
482 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
483 |
$WP_Statistics->menu_slugs['authors'] = add_submenu_page(
|
484 |
WP_Statistics::$page['overview'],
|
485 |
+
__( 'Authors', 'wp-statistics' ),
|
486 |
+
__( 'Authors', 'wp-statistics' ),
|
487 |
$read_cap,
|
488 |
WP_Statistics::$page['authors'],
|
489 |
'WP_Statistics_Admin_Pages::log'
|
490 |
);
|
491 |
}
|
492 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
493 |
$WP_Statistics->menu_slugs['browsers'] = add_submenu_page(
|
494 |
WP_Statistics::$page['overview'],
|
495 |
+
__( 'Browsers', 'wp-statistics' ),
|
496 |
+
__( 'Browsers', 'wp-statistics' ),
|
497 |
$read_cap,
|
498 |
WP_Statistics::$page['browser'],
|
499 |
'WP_Statistics_Admin_Pages::log'
|
500 |
);
|
501 |
}
|
502 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
503 |
$WP_Statistics->menu_slugs['top.visotors'] = add_submenu_page(
|
504 |
WP_Statistics::$page['overview'],
|
505 |
+
__( 'Top Visitors Today', 'wp-statistics' ),
|
506 |
+
__( 'Top Visitors Today', 'wp-statistics' ),
|
507 |
$read_cap,
|
508 |
WP_Statistics::$page['top-visitors'],
|
509 |
'WP_Statistics_Admin_Pages::log'
|
510 |
);
|
511 |
}
|
512 |
+
if ( $WP_Statistics->get_option( 'record_exclusions' ) ) {
|
513 |
$WP_Statistics->menu_slugs['exclusions'] = add_submenu_page(
|
514 |
WP_Statistics::$page['overview'],
|
515 |
+
__( 'Exclusions', 'wp-statistics' ),
|
516 |
+
__( 'Exclusions', 'wp-statistics' ),
|
517 |
$read_cap,
|
518 |
WP_Statistics::$page['exclusions'],
|
519 |
'WP_Statistics_Admin_Pages::log'
|
529 |
);
|
530 |
$WP_Statistics->menu_slugs['optimize'] = add_submenu_page(
|
531 |
WP_Statistics::$page['overview'],
|
532 |
+
__( 'Optimization', 'wp-statistics' ),
|
533 |
+
__( 'Optimization', 'wp-statistics' ),
|
534 |
$manage_cap,
|
535 |
WP_Statistics::$page['optimization'],
|
536 |
'WP_Statistics_Admin_Pages::optimization'
|
537 |
);
|
538 |
$WP_Statistics->menu_slugs['settings'] = add_submenu_page(
|
539 |
WP_Statistics::$page['overview'],
|
540 |
+
__( 'Settings', 'wp-statistics' ),
|
541 |
+
__( 'Settings', 'wp-statistics' ),
|
542 |
$read_cap,
|
543 |
WP_Statistics::$page['settings'],
|
544 |
'WP_Statistics_Admin_Pages::settings'
|
545 |
);
|
546 |
$WP_Statistics->menu_slugs['plugins'] = add_submenu_page(
|
547 |
WP_Statistics::$page['overview'],
|
548 |
+
__( 'Add-Ons', 'wp-statistics' ),
|
549 |
+
'<span style="color:#dc6b26">' . __( 'Add-Ons', 'wp-statistics' ) . '</span>',
|
550 |
$read_cap,
|
551 |
WP_Statistics::$page['plugins'],
|
552 |
'WP_Statistics_Admin_Pages::plugins'
|
553 |
);
|
554 |
$WP_Statistics->menu_slugs['donate'] = add_submenu_page(
|
555 |
WP_Statistics::$page['overview'],
|
556 |
+
__( 'Donate', 'wp-statistics' ),
|
557 |
+
'<span style="color:#459605">' . __( 'Donate', 'wp-statistics' ) . '</span>',
|
558 |
$read_cap,
|
559 |
WP_Statistics::$page['donate'],
|
560 |
'WP_Statistics_Admin_Pages::donate'
|
561 |
);
|
562 |
|
563 |
// Add action to load the meta boxes to the overview page.
|
564 |
+
add_action( 'load-' . $WP_Statistics->menu_slugs['overview'], 'WP_Statistics_Admin_Pages::overview' );
|
565 |
|
566 |
}
|
567 |
|
581 |
);
|
582 |
|
583 |
if ( is_rtl() ) {
|
584 |
+
wp_enqueue_style( 'rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, WP_Statistics::$reg['version'] );
|
585 |
}
|
586 |
|
587 |
if ( ! isset( $_GET['page'] ) ) {
|
599 |
'wps_searches_page',
|
600 |
);
|
601 |
|
602 |
+
if ( array_search( $_GET['page'], $pages_required_chart ) !== false ) {
|
603 |
$load_in_footer = true;
|
604 |
$pages_required_load_in_head = array(
|
605 |
'wps_browsers_page',
|
611 |
'wps_searches_page',
|
612 |
);
|
613 |
|
614 |
+
if ( array_search( $_GET['page'], $pages_required_load_in_head ) !== false ) {
|
615 |
$load_in_footer = false;
|
616 |
}
|
617 |
|
625 |
}
|
626 |
}
|
627 |
|
628 |
+
/**
|
629 |
+
* Admin footer scripts
|
630 |
+
*/
|
631 |
+
public function admin_footer_scripts() {
|
632 |
+
global $WP_Statistics;
|
633 |
+
|
634 |
+
// Check to see if the browscap database needs to be downloaded and do so if required.
|
635 |
+
if ( $WP_Statistics->get_option( 'update_browscap' ) ) {
|
636 |
+
echo WP_Statistics_Updates::download_browscap();
|
637 |
+
}
|
638 |
+
|
639 |
+
// Check to see if the GeoIP database needs to be downloaded and do so if required.
|
640 |
+
if ( $WP_Statistics->get_option( 'update_geoip' ) ) {
|
641 |
+
echo WP_Statistics_Updates::download_geoip();
|
642 |
+
}
|
643 |
+
|
644 |
+
// Check to see if the referrer spam database needs to be downloaded and do so if required.
|
645 |
+
if ( $WP_Statistics->get_option( 'update_referrerspam' ) ) {
|
646 |
+
WP_Statistics_Updates::download_referrerspam();
|
647 |
+
}
|
648 |
+
|
649 |
+
if ( $WP_Statistics->get_option( 'send_upgrade_email' ) ) {
|
650 |
+
$WP_Statistics->update_option( 'send_upgrade_email', false );
|
651 |
+
|
652 |
+
$blogname = get_bloginfo( 'name' );
|
653 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
654 |
+
|
655 |
+
$headers[] = "From: $blogname <$blogemail>";
|
656 |
+
$headers[] = "MIME-Version: 1.0";
|
657 |
+
$headers[] = "Content-type: text/html; charset=utf-8";
|
658 |
+
|
659 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
660 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
661 |
+
}
|
662 |
+
|
663 |
+
wp_mail(
|
664 |
+
$WP_Statistics->get_option( 'email_list' ),
|
665 |
+
sprintf( __( 'WP Statistics %s installed on', 'wp-statistics' ), WP_Statistics::$reg['version'] ) .
|
666 |
+
' ' .
|
667 |
+
$blogname,
|
668 |
+
"Installation/upgrade complete!",
|
669 |
+
$headers
|
670 |
+
);
|
671 |
+
}
|
672 |
+
}
|
673 |
}
|
includes/classes/class-wp-statistics-ajax.php
CHANGED
@@ -13,18 +13,18 @@ class WP_Statistics_Ajax {
|
|
13 |
'wp_ajax_wp_statistics_close_donation_nag',
|
14 |
'WP_Statistics_Ajax::close_donation_nag_action_callback'
|
15 |
);
|
16 |
-
add_action('wp_ajax_wp_statistics_delete_agents', 'WP_Statistics_Ajax::delete_agents_action_callback');
|
17 |
add_action(
|
18 |
'wp_ajax_wp_statistics_delete_platforms',
|
19 |
'WP_Statistics_Ajax::delete_platforms_action_callback'
|
20 |
);
|
21 |
-
add_action('wp_ajax_wp_statistics_empty_table', 'WP_Statistics_Ajax::empty_table_action_callback');
|
22 |
-
add_action('wp_ajax_wp_statistics_purge_data', 'WP_Statistics_Ajax::purge_data_action_callback');
|
23 |
add_action(
|
24 |
'wp_ajax_wp_statistics_purge_visitor_hits',
|
25 |
'WP_Statistics_Ajax::purge_visitor_hits_action_callback'
|
26 |
);
|
27 |
-
add_action('wp_ajax_wp_statistics_get_widget_contents', 'WP_Statistics_Ajax::get_widget_contents_callback');
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -34,11 +34,11 @@ class WP_Statistics_Ajax {
|
|
34 |
GLOBAL $WP_Statistics; // this is how you get access to the database
|
35 |
|
36 |
$manage_cap = wp_statistics_validate_capability(
|
37 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
38 |
);
|
39 |
|
40 |
-
if ( current_user_can($manage_cap) ) {
|
41 |
-
$WP_Statistics->update_option('disable_donation_nag', true);
|
42 |
}
|
43 |
|
44 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -51,32 +51,32 @@ class WP_Statistics_Ajax {
|
|
51 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
52 |
|
53 |
$manage_cap = wp_statistics_validate_capability(
|
54 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
55 |
);
|
56 |
|
57 |
-
if ( current_user_can($manage_cap) ) {
|
58 |
$agent = $_POST['agent-name'];
|
59 |
|
60 |
if ( $agent ) {
|
61 |
|
62 |
$result = $wpdb->query(
|
63 |
-
$wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent)
|
64 |
);
|
65 |
|
66 |
if ( $result ) {
|
67 |
echo sprintf(
|
68 |
-
__('%s agent data deleted successfully.', 'wp-statistics'),
|
69 |
'<code>' . $agent . '</code>'
|
70 |
);
|
71 |
} else {
|
72 |
-
_e('No agent data found to remove!', 'wp-statistics');
|
73 |
}
|
74 |
|
75 |
} else {
|
76 |
-
_e('Please select the desired items.', 'wp-statistics');
|
77 |
}
|
78 |
} else {
|
79 |
-
_e('Access denied!', 'wp-statistics');
|
80 |
}
|
81 |
|
82 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -89,31 +89,31 @@ class WP_Statistics_Ajax {
|
|
89 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
90 |
|
91 |
$manage_cap = wp_statistics_validate_capability(
|
92 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
93 |
);
|
94 |
|
95 |
-
if ( current_user_can($manage_cap) ) {
|
96 |
$platform = $_POST['platform-name'];
|
97 |
|
98 |
if ( $platform ) {
|
99 |
|
100 |
$result = $wpdb->query(
|
101 |
-
$wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform)
|
102 |
);
|
103 |
|
104 |
if ( $result ) {
|
105 |
echo sprintf(
|
106 |
-
__('%s platform data deleted successfully.', 'wp-statistics'),
|
107 |
-
'<code>' . htmlentities($platform, ENT_QUOTES) . '</code>'
|
108 |
);
|
109 |
} else {
|
110 |
-
_e('No platform data found to remove!', 'wp-statistics');
|
111 |
}
|
112 |
} else {
|
113 |
-
_e('Please select the desired items.', 'wp-statistics');
|
114 |
}
|
115 |
} else {
|
116 |
-
_e('Access denied!', 'wp-statistics');
|
117 |
}
|
118 |
|
119 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -126,55 +126,55 @@ class WP_Statistics_Ajax {
|
|
126 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
127 |
|
128 |
$manage_cap = wp_statistics_validate_capability(
|
129 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
130 |
);
|
131 |
|
132 |
-
if ( current_user_can($manage_cap) ) {
|
133 |
$table_name = $_POST['table-name'];
|
134 |
|
135 |
if ( $table_name ) {
|
136 |
|
137 |
switch ( $table_name ) {
|
138 |
case 'useronline':
|
139 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_useronline');
|
140 |
-
|
141 |
case 'visit':
|
142 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visit');
|
143 |
-
|
144 |
case 'visitors':
|
145 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visitor');
|
146 |
-
|
147 |
case 'exclusions':
|
148 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_exclusions');
|
149 |
-
|
150 |
case 'pages':
|
151 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_pages');
|
152 |
-
|
153 |
case 'search':
|
154 |
-
echo wp_statitiscs_empty_table($wpdb->prefix . 'statistics_search');
|
155 |
-
|
156 |
case 'all':
|
157 |
-
$result_string = wp_statitiscs_empty_table($wpdb->prefix . 'statistics_useronline');
|
158 |
-
$result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visit');
|
159 |
-
$result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_visitor');
|
160 |
-
$result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_exclusions');
|
161 |
-
$result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_pages');
|
162 |
-
$result_string .= '<br>' . wp_statitiscs_empty_table($wpdb->prefix . 'statistics_search');
|
163 |
|
164 |
echo $result_string;
|
165 |
|
166 |
-
|
167 |
default:
|
168 |
-
_e('Please select the desired items.', 'wp-statistics');
|
169 |
}
|
170 |
|
171 |
$WP_Statistics->Primary_Values();
|
172 |
|
173 |
} else {
|
174 |
-
_e('Please select the desired items.', 'wp-statistics');
|
175 |
}
|
176 |
} else {
|
177 |
-
_e('Access denied!', 'wp-statistics');
|
178 |
}
|
179 |
|
180 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -189,20 +189,20 @@ class WP_Statistics_Ajax {
|
|
189 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' );
|
190 |
|
191 |
$manage_cap = wp_statistics_validate_capability(
|
192 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
193 |
);
|
194 |
|
195 |
-
if ( current_user_can($manage_cap) ) {
|
196 |
$purge_days = 0;
|
197 |
|
198 |
-
if ( array_key_exists('purge-days', $_POST) ) {
|
199 |
// Get the number of days to purge data before.
|
200 |
-
$purge_days = intval($_POST['purge-days']);
|
201 |
}
|
202 |
|
203 |
-
echo wp_statistics_purge_data($purge_days);
|
204 |
} else {
|
205 |
-
_e('Access denied!', 'wp-statistics');
|
206 |
}
|
207 |
|
208 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -217,24 +217,24 @@ class WP_Statistics_Ajax {
|
|
217 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' );
|
218 |
|
219 |
$manage_cap = wp_statistics_validate_capability(
|
220 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
221 |
);
|
222 |
|
223 |
-
if ( current_user_can($manage_cap) ) {
|
224 |
$purge_hits = 10;
|
225 |
|
226 |
-
if ( array_key_exists('purge-hits', $_POST) ) {
|
227 |
// Get the number of days to purge data before.
|
228 |
-
$purge_hits = intval($_POST['purge-hits']);
|
229 |
}
|
230 |
|
231 |
if ( $purge_hits < 10 ) {
|
232 |
-
_e('Number of hits must be greater than or equal to 10!', 'wp-statistics');
|
233 |
} else {
|
234 |
-
echo wp_statistics_purge_visitor_hits($purge_hits);
|
235 |
}
|
236 |
} else {
|
237 |
-
_e('Access denied!', 'wp-statistics');
|
238 |
}
|
239 |
|
240 |
wp_die(); // this is required to terminate immediately and return a proper response
|
@@ -265,7 +265,7 @@ class WP_Statistics_Ajax {
|
|
265 |
'searched.phrases',
|
266 |
);
|
267 |
|
268 |
-
if ( array_key_exists('format', $_POST) and $_POST['format'] == 'dashboard' ) {
|
269 |
$size = 220;
|
270 |
$days = 10;
|
271 |
} else {
|
@@ -274,16 +274,16 @@ class WP_Statistics_Ajax {
|
|
274 |
}
|
275 |
|
276 |
$view_cap = wp_statistics_validate_capability(
|
277 |
-
$WP_Statistics->get_option('read_capability', 'manage_options')
|
278 |
);
|
279 |
|
280 |
-
if ( current_user_can($view_cap) ) {
|
281 |
$widget = '';
|
282 |
|
283 |
-
if ( array_key_exists('widget', $_POST) ) {
|
284 |
// Get the widget we're going to display.
|
285 |
|
286 |
-
if ( in_array($_POST['widget'], $widgets) ) {
|
287 |
$widget = $_POST['widget'];
|
288 |
}
|
289 |
}
|
@@ -293,7 +293,7 @@ class WP_Statistics_Ajax {
|
|
293 |
}
|
294 |
|
295 |
if ( '' == $widget ) {
|
296 |
-
_e('No matching widget found!', 'wp-statistics');
|
297 |
wp_die();
|
298 |
}
|
299 |
|
@@ -304,54 +304,54 @@ class WP_Statistics_Ajax {
|
|
304 |
|
305 |
switch ( $widget ) {
|
306 |
case 'summary':
|
307 |
-
wp_statistics_generate_summary_postbox_content($search_engines);
|
308 |
|
309 |
-
|
310 |
case 'quickstats':
|
311 |
-
wp_statistics_generate_quickstats_postbox_content($search_engines);
|
312 |
|
313 |
-
|
314 |
|
315 |
case 'browsers':
|
316 |
wp_statistics_generate_browsers_postbox_content();
|
317 |
|
318 |
-
|
319 |
case 'referring':
|
320 |
wp_statistics_generate_referring_postbox_content();
|
321 |
|
322 |
-
|
323 |
case 'searched.phrases':
|
324 |
wp_statistics_generate_searched_phrases_postbox_content();
|
325 |
|
326 |
-
|
327 |
case 'countries':
|
328 |
-
wp_statistics_generate_countries_postbox_content($ISOCountryCode);
|
329 |
|
330 |
-
|
331 |
case 'jqv.map':
|
332 |
-
wp_statistics_generate_map_postbox_content($ISOCountryCode);
|
333 |
|
334 |
-
|
335 |
case 'hits':
|
336 |
-
wp_statistics_generate_hits_postbox_content($size, $days);
|
337 |
|
338 |
-
|
339 |
case 'search':
|
340 |
-
wp_statistics_generate_search_postbox_content($search_engines, $size, $days);
|
341 |
|
342 |
-
|
343 |
case 'words':
|
344 |
-
wp_statistics_generate_words_postbox_content($ISOCountryCode);
|
345 |
|
346 |
-
|
347 |
case 'page':
|
348 |
-
_e('This feature temporarily disabled.', 'wp-statistics');
|
349 |
|
350 |
-
if ( array_key_exists('page-id', $_POST) ) {
|
351 |
$pageid = (int) $_POST['page-id'];
|
352 |
echo ' ';
|
353 |
echo sprintf(
|
354 |
-
__('<a href="%s">Click here</a> to see page stats.', 'wp-statistics'),
|
355 |
'admin.php?page=wps_pages_page&page-id=' . $pageid
|
356 |
);
|
357 |
|
@@ -359,34 +359,34 @@ class WP_Statistics_Ajax {
|
|
359 |
//wp_statistics_generate_page_postbox_content( null, $pageid );
|
360 |
}
|
361 |
|
362 |
-
|
363 |
case 'pages':
|
364 |
wp_statistics_generate_pages_postbox_content();
|
365 |
|
366 |
-
|
367 |
case 'recent':
|
368 |
-
wp_statistics_generate_recent_postbox_content($ISOCountryCode);
|
369 |
|
370 |
-
|
371 |
case 'top.visitors':
|
372 |
$format = null;
|
373 |
|
374 |
-
if ( array_key_exists('format', $_POST) ) {
|
375 |
$format = 'compact';
|
376 |
}
|
377 |
|
378 |
-
wp_statistics_generate_top_visitors_postbox_content($ISOCountryCode, 'today', 10, $format);
|
379 |
|
380 |
-
|
381 |
case 'about':
|
382 |
-
wp_statistics_generate_about_postbox_content($ISOCountryCode);
|
383 |
|
384 |
-
|
385 |
default:
|
386 |
-
_e('ERROR: Widget not found!', 'wp-statistics');
|
387 |
}
|
388 |
} else {
|
389 |
-
_e('Access denied!', 'wp-statistics');
|
390 |
}
|
391 |
|
392 |
wp_die(); // this is required to terminate immediately and return a proper response
|
13 |
'wp_ajax_wp_statistics_close_donation_nag',
|
14 |
'WP_Statistics_Ajax::close_donation_nag_action_callback'
|
15 |
);
|
16 |
+
add_action( 'wp_ajax_wp_statistics_delete_agents', 'WP_Statistics_Ajax::delete_agents_action_callback' );
|
17 |
add_action(
|
18 |
'wp_ajax_wp_statistics_delete_platforms',
|
19 |
'WP_Statistics_Ajax::delete_platforms_action_callback'
|
20 |
);
|
21 |
+
add_action( 'wp_ajax_wp_statistics_empty_table', 'WP_Statistics_Ajax::empty_table_action_callback' );
|
22 |
+
add_action( 'wp_ajax_wp_statistics_purge_data', 'WP_Statistics_Ajax::purge_data_action_callback' );
|
23 |
add_action(
|
24 |
'wp_ajax_wp_statistics_purge_visitor_hits',
|
25 |
'WP_Statistics_Ajax::purge_visitor_hits_action_callback'
|
26 |
);
|
27 |
+
add_action( 'wp_ajax_wp_statistics_get_widget_contents', 'WP_Statistics_Ajax::get_widget_contents_callback' );
|
28 |
}
|
29 |
|
30 |
/**
|
34 |
GLOBAL $WP_Statistics; // this is how you get access to the database
|
35 |
|
36 |
$manage_cap = wp_statistics_validate_capability(
|
37 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
38 |
);
|
39 |
|
40 |
+
if ( current_user_can( $manage_cap ) ) {
|
41 |
+
$WP_Statistics->update_option( 'disable_donation_nag', true );
|
42 |
}
|
43 |
|
44 |
wp_die(); // this is required to terminate immediately and return a proper response
|
51 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
52 |
|
53 |
$manage_cap = wp_statistics_validate_capability(
|
54 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
55 |
);
|
56 |
|
57 |
+
if ( current_user_can( $manage_cap ) ) {
|
58 |
$agent = $_POST['agent-name'];
|
59 |
|
60 |
if ( $agent ) {
|
61 |
|
62 |
$result = $wpdb->query(
|
63 |
+
$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent )
|
64 |
);
|
65 |
|
66 |
if ( $result ) {
|
67 |
echo sprintf(
|
68 |
+
__( '%s agent data deleted successfully.', 'wp-statistics' ),
|
69 |
'<code>' . $agent . '</code>'
|
70 |
);
|
71 |
} else {
|
72 |
+
_e( 'No agent data found to remove!', 'wp-statistics' );
|
73 |
}
|
74 |
|
75 |
} else {
|
76 |
+
_e( 'Please select the desired items.', 'wp-statistics' );
|
77 |
}
|
78 |
} else {
|
79 |
+
_e( 'Access denied!', 'wp-statistics' );
|
80 |
}
|
81 |
|
82 |
wp_die(); // this is required to terminate immediately and return a proper response
|
89 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
90 |
|
91 |
$manage_cap = wp_statistics_validate_capability(
|
92 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
93 |
);
|
94 |
|
95 |
+
if ( current_user_can( $manage_cap ) ) {
|
96 |
$platform = $_POST['platform-name'];
|
97 |
|
98 |
if ( $platform ) {
|
99 |
|
100 |
$result = $wpdb->query(
|
101 |
+
$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform )
|
102 |
);
|
103 |
|
104 |
if ( $result ) {
|
105 |
echo sprintf(
|
106 |
+
__( '%s platform data deleted successfully.', 'wp-statistics' ),
|
107 |
+
'<code>' . htmlentities( $platform, ENT_QUOTES ) . '</code>'
|
108 |
);
|
109 |
} else {
|
110 |
+
_e( 'No platform data found to remove!', 'wp-statistics' );
|
111 |
}
|
112 |
} else {
|
113 |
+
_e( 'Please select the desired items.', 'wp-statistics' );
|
114 |
}
|
115 |
} else {
|
116 |
+
_e( 'Access denied!', 'wp-statistics' );
|
117 |
}
|
118 |
|
119 |
wp_die(); // this is required to terminate immediately and return a proper response
|
126 |
GLOBAL $WP_Statistics, $wpdb; // this is how you get access to the database
|
127 |
|
128 |
$manage_cap = wp_statistics_validate_capability(
|
129 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
130 |
);
|
131 |
|
132 |
+
if ( current_user_can( $manage_cap ) ) {
|
133 |
$table_name = $_POST['table-name'];
|
134 |
|
135 |
if ( $table_name ) {
|
136 |
|
137 |
switch ( $table_name ) {
|
138 |
case 'useronline':
|
139 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_useronline' );
|
140 |
+
break;
|
141 |
case 'visit':
|
142 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visit' );
|
143 |
+
break;
|
144 |
case 'visitors':
|
145 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visitor' );
|
146 |
+
break;
|
147 |
case 'exclusions':
|
148 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_exclusions' );
|
149 |
+
break;
|
150 |
case 'pages':
|
151 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_pages' );
|
152 |
+
break;
|
153 |
case 'search':
|
154 |
+
echo wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_search' );
|
155 |
+
break;
|
156 |
case 'all':
|
157 |
+
$result_string = wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_useronline' );
|
158 |
+
$result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visit' );
|
159 |
+
$result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_visitor' );
|
160 |
+
$result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_exclusions' );
|
161 |
+
$result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_pages' );
|
162 |
+
$result_string .= '<br>' . wp_statitiscs_empty_table( $wpdb->prefix . 'statistics_search' );
|
163 |
|
164 |
echo $result_string;
|
165 |
|
166 |
+
break;
|
167 |
default:
|
168 |
+
_e( 'Please select the desired items.', 'wp-statistics' );
|
169 |
}
|
170 |
|
171 |
$WP_Statistics->Primary_Values();
|
172 |
|
173 |
} else {
|
174 |
+
_e( 'Please select the desired items.', 'wp-statistics' );
|
175 |
}
|
176 |
} else {
|
177 |
+
_e( 'Access denied!', 'wp-statistics' );
|
178 |
}
|
179 |
|
180 |
wp_die(); // this is required to terminate immediately and return a proper response
|
189 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' );
|
190 |
|
191 |
$manage_cap = wp_statistics_validate_capability(
|
192 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
193 |
);
|
194 |
|
195 |
+
if ( current_user_can( $manage_cap ) ) {
|
196 |
$purge_days = 0;
|
197 |
|
198 |
+
if ( array_key_exists( 'purge-days', $_POST ) ) {
|
199 |
// Get the number of days to purge data before.
|
200 |
+
$purge_days = intval( $_POST['purge-days'] );
|
201 |
}
|
202 |
|
203 |
+
echo wp_statistics_purge_data( $purge_days );
|
204 |
} else {
|
205 |
+
_e( 'Access denied!', 'wp-statistics' );
|
206 |
}
|
207 |
|
208 |
wp_die(); // this is required to terminate immediately and return a proper response
|
217 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' );
|
218 |
|
219 |
$manage_cap = wp_statistics_validate_capability(
|
220 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
221 |
);
|
222 |
|
223 |
+
if ( current_user_can( $manage_cap ) ) {
|
224 |
$purge_hits = 10;
|
225 |
|
226 |
+
if ( array_key_exists( 'purge-hits', $_POST ) ) {
|
227 |
// Get the number of days to purge data before.
|
228 |
+
$purge_hits = intval( $_POST['purge-hits'] );
|
229 |
}
|
230 |
|
231 |
if ( $purge_hits < 10 ) {
|
232 |
+
_e( 'Number of hits must be greater than or equal to 10!', 'wp-statistics' );
|
233 |
} else {
|
234 |
+
echo wp_statistics_purge_visitor_hits( $purge_hits );
|
235 |
}
|
236 |
} else {
|
237 |
+
_e( 'Access denied!', 'wp-statistics' );
|
238 |
}
|
239 |
|
240 |
wp_die(); // this is required to terminate immediately and return a proper response
|
265 |
'searched.phrases',
|
266 |
);
|
267 |
|
268 |
+
if ( array_key_exists( 'format', $_POST ) and $_POST['format'] == 'dashboard' ) {
|
269 |
$size = 220;
|
270 |
$days = 10;
|
271 |
} else {
|
274 |
}
|
275 |
|
276 |
$view_cap = wp_statistics_validate_capability(
|
277 |
+
$WP_Statistics->get_option( 'read_capability', 'manage_options' )
|
278 |
);
|
279 |
|
280 |
+
if ( current_user_can( $view_cap ) ) {
|
281 |
$widget = '';
|
282 |
|
283 |
+
if ( array_key_exists( 'widget', $_POST ) ) {
|
284 |
// Get the widget we're going to display.
|
285 |
|
286 |
+
if ( in_array( $_POST['widget'], $widgets ) ) {
|
287 |
$widget = $_POST['widget'];
|
288 |
}
|
289 |
}
|
293 |
}
|
294 |
|
295 |
if ( '' == $widget ) {
|
296 |
+
_e( 'No matching widget found!', 'wp-statistics' );
|
297 |
wp_die();
|
298 |
}
|
299 |
|
304 |
|
305 |
switch ( $widget ) {
|
306 |
case 'summary':
|
307 |
+
wp_statistics_generate_summary_postbox_content( $search_engines );
|
308 |
|
309 |
+
break;
|
310 |
case 'quickstats':
|
311 |
+
wp_statistics_generate_quickstats_postbox_content( $search_engines );
|
312 |
|
313 |
+
break;
|
314 |
|
315 |
case 'browsers':
|
316 |
wp_statistics_generate_browsers_postbox_content();
|
317 |
|
318 |
+
break;
|
319 |
case 'referring':
|
320 |
wp_statistics_generate_referring_postbox_content();
|
321 |
|
322 |
+
break;
|
323 |
case 'searched.phrases':
|
324 |
wp_statistics_generate_searched_phrases_postbox_content();
|
325 |
|
326 |
+
break;
|
327 |
case 'countries':
|
328 |
+
wp_statistics_generate_countries_postbox_content( $ISOCountryCode );
|
329 |
|
330 |
+
break;
|
331 |
case 'jqv.map':
|
332 |
+
wp_statistics_generate_map_postbox_content( $ISOCountryCode );
|
333 |
|
334 |
+
break;
|
335 |
case 'hits':
|
336 |
+
wp_statistics_generate_hits_postbox_content( $size, $days );
|
337 |
|
338 |
+
break;
|
339 |
case 'search':
|
340 |
+
wp_statistics_generate_search_postbox_content( $search_engines, $size, $days );
|
341 |
|
342 |
+
break;
|
343 |
case 'words':
|
344 |
+
wp_statistics_generate_words_postbox_content( $ISOCountryCode );
|
345 |
|
346 |
+
break;
|
347 |
case 'page':
|
348 |
+
_e( 'This feature temporarily disabled.', 'wp-statistics' );
|
349 |
|
350 |
+
if ( array_key_exists( 'page-id', $_POST ) ) {
|
351 |
$pageid = (int) $_POST['page-id'];
|
352 |
echo ' ';
|
353 |
echo sprintf(
|
354 |
+
__( '<a href="%s">Click here</a> to see page stats.', 'wp-statistics' ),
|
355 |
'admin.php?page=wps_pages_page&page-id=' . $pageid
|
356 |
);
|
357 |
|
359 |
//wp_statistics_generate_page_postbox_content( null, $pageid );
|
360 |
}
|
361 |
|
362 |
+
break;
|
363 |
case 'pages':
|
364 |
wp_statistics_generate_pages_postbox_content();
|
365 |
|
366 |
+
break;
|
367 |
case 'recent':
|
368 |
+
wp_statistics_generate_recent_postbox_content( $ISOCountryCode );
|
369 |
|
370 |
+
break;
|
371 |
case 'top.visitors':
|
372 |
$format = null;
|
373 |
|
374 |
+
if ( array_key_exists( 'format', $_POST ) ) {
|
375 |
$format = 'compact';
|
376 |
}
|
377 |
|
378 |
+
wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, 'today', 10, $format );
|
379 |
|
380 |
+
break;
|
381 |
case 'about':
|
382 |
+
wp_statistics_generate_about_postbox_content( $ISOCountryCode );
|
383 |
|
384 |
+
break;
|
385 |
default:
|
386 |
+
_e( 'ERROR: Widget not found!', 'wp-statistics' );
|
387 |
}
|
388 |
} else {
|
389 |
+
_e( 'Access denied!', 'wp-statistics' );
|
390 |
}
|
391 |
|
392 |
wp_die(); // this is required to terminate immediately and return a proper response
|
includes/classes/class-wp-statistics-dashboard.php
CHANGED
@@ -12,11 +12,11 @@ class WP_Statistics_Dashboard {
|
|
12 |
|
13 |
// 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
|
14 |
// the first time they visit the dashboard though so check to see if we've been here before.
|
15 |
-
if ( ! $WP_Statistics->get_user_option('dashboard_set') ) {
|
16 |
-
$WP_Statistics->update_user_option('dashboard_set', WP_Statistics::$reg['version']);
|
17 |
|
18 |
-
$hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
|
19 |
-
if ( ! is_array($hidden_widgets) ) {
|
20 |
$hidden_widgets = array();
|
21 |
}
|
22 |
|
@@ -36,32 +36,32 @@ class WP_Statistics_Dashboard {
|
|
36 |
);
|
37 |
|
38 |
foreach ( $default_hidden as $widget ) {
|
39 |
-
if ( ! in_array($widget, $hidden_widgets) ) {
|
40 |
$hidden_widgets[] = $widget;
|
41 |
}
|
42 |
}
|
43 |
|
44 |
-
update_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets);
|
45 |
-
} elseif ( $WP_Statistics->get_user_option('dashboard_set') != WP_Statistics::$reg['version'] ) {
|
46 |
// We also have to fudge things when we add new widgets to the code base.
|
47 |
-
if ( version_compare($WP_Statistics->get_user_option('dashboard_set'), '8.7', '<') ) {
|
48 |
|
49 |
-
$WP_Statistics->update_user_option('dashboard_set', WP_Statistics::$reg['version']);
|
50 |
|
51 |
-
$hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', true);
|
52 |
-
if ( ! is_array($hidden_widgets) ) {
|
53 |
$hidden_widgets = array();
|
54 |
}
|
55 |
|
56 |
$default_hidden = array( 'wp-statistics-top-visitors-widget' );
|
57 |
|
58 |
foreach ( $default_hidden as $widget ) {
|
59 |
-
if ( ! in_array($widget, $hidden_widgets) ) {
|
60 |
$hidden_widgets[] = $widget;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
update_user_meta($WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets);
|
65 |
}
|
66 |
}
|
67 |
|
@@ -79,81 +79,81 @@ class WP_Statistics_Dashboard {
|
|
79 |
}
|
80 |
|
81 |
// If the admin has disabled the widgets, don't display them.
|
82 |
-
if ( ! $WP_Statistics->get_option('disable_dashboard') ) {
|
83 |
wp_add_dashboard_widget(
|
84 |
'wp-statistics-quickstats-widget',
|
85 |
-
__('Quick Stats', 'wp-statistics'),
|
86 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
87 |
$control_callback = null,
|
88 |
array( 'widget' => 'quickstats' )
|
89 |
);
|
90 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
91 |
wp_add_dashboard_widget(
|
92 |
'wp-statistics-browsers-widget',
|
93 |
-
__('Top 10 Browsers', 'wp-statistics'),
|
94 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
95 |
$control_callback = null,
|
96 |
array( 'widget' => 'browsers' )
|
97 |
);
|
98 |
}
|
99 |
-
if ( $WP_Statistics->get_option('geoip') && $WP_Statistics->get_option('visitors') ) {
|
100 |
wp_add_dashboard_widget(
|
101 |
'wp-statistics-countries-widget',
|
102 |
-
__('Top 10 Countries', 'wp-statistics'),
|
103 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
104 |
$control_callback = null,
|
105 |
array( 'widget' => 'countries' )
|
106 |
);
|
107 |
}
|
108 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
109 |
wp_add_dashboard_widget(
|
110 |
'wp-statistics-hitsmap-widget',
|
111 |
-
__('Today\'s Visitors Map', 'wp-statistics'),
|
112 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
113 |
$control_callback = null,
|
114 |
array( 'widget' => 'hitsmap' )
|
115 |
);
|
116 |
}
|
117 |
-
if ( $WP_Statistics->get_option('visits') ) {
|
118 |
wp_add_dashboard_widget(
|
119 |
'wp-statistics-hits-widget',
|
120 |
-
__('Hit Statistics', 'wp-statistics'),
|
121 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
122 |
$control_callback = null,
|
123 |
array( 'widget' => 'hits' )
|
124 |
);
|
125 |
}
|
126 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
127 |
wp_add_dashboard_widget(
|
128 |
'wp-statistics-pages-widget',
|
129 |
-
__('Top 10 Pages', 'wp-statistics'),
|
130 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
131 |
$control_callback = null,
|
132 |
array( 'widget' => 'pages' )
|
133 |
);
|
134 |
}
|
135 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
136 |
wp_add_dashboard_widget(
|
137 |
'wp-statistics-recent-widget',
|
138 |
-
__('Recent Visitors', 'wp-statistics'),
|
139 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
140 |
$control_callback = null,
|
141 |
array( 'widget' => 'recent' )
|
142 |
);
|
143 |
}
|
144 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
145 |
wp_add_dashboard_widget(
|
146 |
'wp-statistics-referring-widget',
|
147 |
-
__('Top Referring Sites', 'wp-statistics'),
|
148 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
149 |
$control_callback = null,
|
150 |
array( 'widget' => 'referring' )
|
151 |
);
|
152 |
}
|
153 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
154 |
wp_add_dashboard_widget(
|
155 |
'wp-statistics-search-widget',
|
156 |
-
__('Search Engine Referrals', 'wp-statistics'),
|
157 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
158 |
$control_callback = null,
|
159 |
array( 'widget' => 'search' )
|
@@ -161,33 +161,33 @@ class WP_Statistics_Dashboard {
|
|
161 |
}
|
162 |
wp_add_dashboard_widget(
|
163 |
'wp-statistics-summary-widget',
|
164 |
-
__('Summary', 'wp-statistics'),
|
165 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
166 |
$control_callback = null,
|
167 |
array( 'widget' => 'summary' )
|
168 |
);
|
169 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
170 |
wp_add_dashboard_widget(
|
171 |
'wp-statistics-words-widget',
|
172 |
-
__('Latest Search Words', 'wp-statistics'),
|
173 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
174 |
$control_callback = null,
|
175 |
array( 'widget' => 'words' )
|
176 |
);
|
177 |
}
|
178 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
179 |
wp_add_dashboard_widget(
|
180 |
'wp-statistics-top-visitors-widget',
|
181 |
-
__('Top 10 Visitors Today', 'wp-statistics'),
|
182 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
183 |
$control_callback = null,
|
184 |
array( 'widget' => 'top.visitors' )
|
185 |
);
|
186 |
}
|
187 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
188 |
wp_add_dashboard_widget(
|
189 |
'wp-statistics-searched-phrases-widget',
|
190 |
-
__('Top Searched Phrases (30 Days)', 'wp-statistics'),
|
191 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
192 |
$control_callback = null,
|
193 |
array( 'widget' => 'searched.phrases' )
|
@@ -200,15 +200,15 @@ class WP_Statistics_Dashboard {
|
|
200 |
global $WP_Statistics;
|
201 |
|
202 |
// Load the css we use for the statistics pages.
|
203 |
-
wp_enqueue_style('wpstatistics-log-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/log.css', true, '1.2');
|
204 |
|
205 |
// Don't forget the right to left support.
|
206 |
if ( is_rtl() ) {
|
207 |
-
wp_enqueue_style('rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, '1.1');
|
208 |
}
|
209 |
|
210 |
// Load the map code.
|
211 |
-
wp_enqueue_style('jqvmap-css', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jqvmap.css', true, '1.5.1');
|
212 |
wp_enqueue_script(
|
213 |
'jquery-vmap',
|
214 |
WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jquery.vmap.js',
|
@@ -236,9 +236,9 @@ class WP_Statistics_Dashboard {
|
|
236 |
|
237 |
// Load our custom widgets handling javascript.
|
238 |
if ( 'post' == $screen->id || 'page' == $screen->id ) {
|
239 |
-
wp_enqueue_script('wp_statistics_editor', WP_Statistics::$reg['plugin-url'] . 'assets/js/editor.js');
|
240 |
} else {
|
241 |
-
wp_enqueue_script('wp_statistics_dashboard', WP_Statistics::$reg['plugin-url'] . 'assets/js/dashboard.js');
|
242 |
}
|
243 |
}
|
244 |
|
@@ -252,26 +252,26 @@ class WP_Statistics_Dashboard {
|
|
252 |
WP_Statistics_Dashboard::load_widget_css_and_scripts();
|
253 |
|
254 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
255 |
-
plugins_url('wp-statistics/assets/images/') .
|
256 |
'ajax-loading.gif" alt="' .
|
257 |
-
__('Reloading...', 'wp-statistics') .
|
258 |
'"></div>';
|
259 |
|
260 |
$new_buttons
|
261 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
262 |
-
wp_statistics_icons('dashicons-update') .
|
263 |
'<span class="screen-reader-text">' .
|
264 |
-
__('Reload', 'wp-statistics') .
|
265 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
266 |
-
wp_statistics_icons('dashicons-migrate') .
|
267 |
'<span class="screen-reader-text">' .
|
268 |
-
__('More Details', 'wp-statistics') .
|
269 |
'</span></button>';
|
270 |
$new_button
|
271 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
272 |
-
wp_statistics_icons('dashicons-update') .
|
273 |
'<span class="screen-reader-text">' .
|
274 |
-
__('Reload', 'wp-statistics') .
|
275 |
'</span></button>';
|
276 |
|
277 |
$admin_url = get_admin_url() . "admin.php?page=";
|
@@ -298,70 +298,70 @@ class WP_Statistics_Dashboard {
|
|
298 |
$page_urls['wp-statistics-quickstats-widget_more_button'] = $admin_url . WP_Statistics::$page['overview'];
|
299 |
|
300 |
?>
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
|
305 |
-
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
|
311 |
-
|
312 |
-
|
313 |
|
314 |
-
|
315 |
-
|
316 |
|
317 |
-
|
318 |
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
|
328 |
-
|
329 |
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
|
344 |
-
|
345 |
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
<?php
|
352 |
}
|
353 |
|
354 |
static function generate_postbox_contents( $post, $args ) {
|
355 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
356 |
-
plugins_url('wp-statistics/assets/images/') .
|
357 |
'ajax-loading.gif" alt="' .
|
358 |
-
__('Loading...', 'wp-statistics') .
|
359 |
'"></div>';
|
360 |
$widget = $args['args']['widget'];
|
361 |
-
$container_id = 'wp-statistics-' . str_replace('.', '-', $widget) . '-div';
|
362 |
|
363 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
364 |
-
wp_statistics_generate_widget_load_javascript($widget, $container_id);
|
365 |
}
|
366 |
|
367 |
}
|
12 |
|
13 |
// 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
|
14 |
// the first time they visit the dashboard though so check to see if we've been here before.
|
15 |
+
if ( ! $WP_Statistics->get_user_option( 'dashboard_set' ) ) {
|
16 |
+
$WP_Statistics->update_user_option( 'dashboard_set', WP_Statistics::$reg['version'] );
|
17 |
|
18 |
+
$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', true );
|
19 |
+
if ( ! is_array( $hidden_widgets ) ) {
|
20 |
$hidden_widgets = array();
|
21 |
}
|
22 |
|
36 |
);
|
37 |
|
38 |
foreach ( $default_hidden as $widget ) {
|
39 |
+
if ( ! in_array( $widget, $hidden_widgets ) ) {
|
40 |
$hidden_widgets[] = $widget;
|
41 |
}
|
42 |
}
|
43 |
|
44 |
+
update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
|
45 |
+
} elseif ( $WP_Statistics->get_user_option( 'dashboard_set' ) != WP_Statistics::$reg['version'] ) {
|
46 |
// We also have to fudge things when we add new widgets to the code base.
|
47 |
+
if ( version_compare( $WP_Statistics->get_user_option( 'dashboard_set' ), '8.7', '<' ) ) {
|
48 |
|
49 |
+
$WP_Statistics->update_user_option( 'dashboard_set', WP_Statistics::$reg['version'] );
|
50 |
|
51 |
+
$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', true );
|
52 |
+
if ( ! is_array( $hidden_widgets ) ) {
|
53 |
$hidden_widgets = array();
|
54 |
}
|
55 |
|
56 |
$default_hidden = array( 'wp-statistics-top-visitors-widget' );
|
57 |
|
58 |
foreach ( $default_hidden as $widget ) {
|
59 |
+
if ( ! in_array( $widget, $hidden_widgets ) ) {
|
60 |
$hidden_widgets[] = $widget;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_dashboard', $hidden_widgets );
|
65 |
}
|
66 |
}
|
67 |
|
79 |
}
|
80 |
|
81 |
// If the admin has disabled the widgets, don't display them.
|
82 |
+
if ( ! $WP_Statistics->get_option( 'disable_dashboard' ) ) {
|
83 |
wp_add_dashboard_widget(
|
84 |
'wp-statistics-quickstats-widget',
|
85 |
+
__( 'Quick Stats', 'wp-statistics' ),
|
86 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
87 |
$control_callback = null,
|
88 |
array( 'widget' => 'quickstats' )
|
89 |
);
|
90 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
91 |
wp_add_dashboard_widget(
|
92 |
'wp-statistics-browsers-widget',
|
93 |
+
__( 'Top 10 Browsers', 'wp-statistics' ),
|
94 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
95 |
$control_callback = null,
|
96 |
array( 'widget' => 'browsers' )
|
97 |
);
|
98 |
}
|
99 |
+
if ( $WP_Statistics->get_option( 'geoip' ) && $WP_Statistics->get_option( 'visitors' ) ) {
|
100 |
wp_add_dashboard_widget(
|
101 |
'wp-statistics-countries-widget',
|
102 |
+
__( 'Top 10 Countries', 'wp-statistics' ),
|
103 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
104 |
$control_callback = null,
|
105 |
array( 'widget' => 'countries' )
|
106 |
);
|
107 |
}
|
108 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
109 |
wp_add_dashboard_widget(
|
110 |
'wp-statistics-hitsmap-widget',
|
111 |
+
__( 'Today\'s Visitors Map', 'wp-statistics' ),
|
112 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
113 |
$control_callback = null,
|
114 |
array( 'widget' => 'hitsmap' )
|
115 |
);
|
116 |
}
|
117 |
+
if ( $WP_Statistics->get_option( 'visits' ) ) {
|
118 |
wp_add_dashboard_widget(
|
119 |
'wp-statistics-hits-widget',
|
120 |
+
__( 'Hit Statistics', 'wp-statistics' ),
|
121 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
122 |
$control_callback = null,
|
123 |
array( 'widget' => 'hits' )
|
124 |
);
|
125 |
}
|
126 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
127 |
wp_add_dashboard_widget(
|
128 |
'wp-statistics-pages-widget',
|
129 |
+
__( 'Top 10 Pages', 'wp-statistics' ),
|
130 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
131 |
$control_callback = null,
|
132 |
array( 'widget' => 'pages' )
|
133 |
);
|
134 |
}
|
135 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
136 |
wp_add_dashboard_widget(
|
137 |
'wp-statistics-recent-widget',
|
138 |
+
__( 'Recent Visitors', 'wp-statistics' ),
|
139 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
140 |
$control_callback = null,
|
141 |
array( 'widget' => 'recent' )
|
142 |
);
|
143 |
}
|
144 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
145 |
wp_add_dashboard_widget(
|
146 |
'wp-statistics-referring-widget',
|
147 |
+
__( 'Top Referring Sites', 'wp-statistics' ),
|
148 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
149 |
$control_callback = null,
|
150 |
array( 'widget' => 'referring' )
|
151 |
);
|
152 |
}
|
153 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
154 |
wp_add_dashboard_widget(
|
155 |
'wp-statistics-search-widget',
|
156 |
+
__( 'Search Engine Referrals', 'wp-statistics' ),
|
157 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
158 |
$control_callback = null,
|
159 |
array( 'widget' => 'search' )
|
161 |
}
|
162 |
wp_add_dashboard_widget(
|
163 |
'wp-statistics-summary-widget',
|
164 |
+
__( 'Summary', 'wp-statistics' ),
|
165 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
166 |
$control_callback = null,
|
167 |
array( 'widget' => 'summary' )
|
168 |
);
|
169 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
170 |
wp_add_dashboard_widget(
|
171 |
'wp-statistics-words-widget',
|
172 |
+
__( 'Latest Search Words', 'wp-statistics' ),
|
173 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
174 |
$control_callback = null,
|
175 |
array( 'widget' => 'words' )
|
176 |
);
|
177 |
}
|
178 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
179 |
wp_add_dashboard_widget(
|
180 |
'wp-statistics-top-visitors-widget',
|
181 |
+
__( 'Top 10 Visitors Today', 'wp-statistics' ),
|
182 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
183 |
$control_callback = null,
|
184 |
array( 'widget' => 'top.visitors' )
|
185 |
);
|
186 |
}
|
187 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
188 |
wp_add_dashboard_widget(
|
189 |
'wp-statistics-searched-phrases-widget',
|
190 |
+
__( 'Top Searched Phrases (30 Days)', 'wp-statistics' ),
|
191 |
'WP_Statistics_Dashboard::generate_postbox_contents',
|
192 |
$control_callback = null,
|
193 |
array( 'widget' => 'searched.phrases' )
|
200 |
global $WP_Statistics;
|
201 |
|
202 |
// Load the css we use for the statistics pages.
|
203 |
+
wp_enqueue_style( 'wpstatistics-log-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/log.css', true, '1.2' );
|
204 |
|
205 |
// Don't forget the right to left support.
|
206 |
if ( is_rtl() ) {
|
207 |
+
wp_enqueue_style( 'rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, '1.1' );
|
208 |
}
|
209 |
|
210 |
// Load the map code.
|
211 |
+
wp_enqueue_style( 'jqvmap-css', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jqvmap.css', true, '1.5.1' );
|
212 |
wp_enqueue_script(
|
213 |
'jquery-vmap',
|
214 |
WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jquery.vmap.js',
|
236 |
|
237 |
// Load our custom widgets handling javascript.
|
238 |
if ( 'post' == $screen->id || 'page' == $screen->id ) {
|
239 |
+
wp_enqueue_script( 'wp_statistics_editor', WP_Statistics::$reg['plugin-url'] . 'assets/js/editor.js' );
|
240 |
} else {
|
241 |
+
wp_enqueue_script( 'wp_statistics_dashboard', WP_Statistics::$reg['plugin-url'] . 'assets/js/dashboard.js' );
|
242 |
}
|
243 |
}
|
244 |
|
252 |
WP_Statistics_Dashboard::load_widget_css_and_scripts();
|
253 |
|
254 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
255 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
256 |
'ajax-loading.gif" alt="' .
|
257 |
+
__( 'Reloading...', 'wp-statistics' ) .
|
258 |
'"></div>';
|
259 |
|
260 |
$new_buttons
|
261 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
262 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
263 |
'<span class="screen-reader-text">' .
|
264 |
+
__( 'Reload', 'wp-statistics' ) .
|
265 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
266 |
+
wp_statistics_icons( 'dashicons-migrate' ) .
|
267 |
'<span class="screen-reader-text">' .
|
268 |
+
__( 'More Details', 'wp-statistics' ) .
|
269 |
'</span></button>';
|
270 |
$new_button
|
271 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
272 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
273 |
'<span class="screen-reader-text">' .
|
274 |
+
__( 'Reload', 'wp-statistics' ) .
|
275 |
'</span></button>';
|
276 |
|
277 |
$admin_url = get_admin_url() . "admin.php?page=";
|
298 |
$page_urls['wp-statistics-quickstats-widget_more_button'] = $admin_url . WP_Statistics::$page['overview'];
|
299 |
|
300 |
?>
|
301 |
+
<script type="text/javascript">
|
302 |
+
var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
|
303 |
+
var wp_statistics_loading_image = '<?php echo $loading_img; ?>';
|
304 |
|
305 |
+
function wp_statistics_wait_for_postboxes() {
|
306 |
|
307 |
+
if (!jQuery('#show-settings-link').is(':visible')) {
|
308 |
+
setTimeout(wp_statistics_wait_for_postboxes, 500);
|
309 |
+
}
|
310 |
|
311 |
+
jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
|
312 |
+
jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
|
313 |
|
314 |
+
jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
|
315 |
+
}
|
316 |
|
317 |
+
jQuery(document).ready(function () {
|
318 |
|
319 |
+
// Add the "more" and "refresh" buttons.
|
320 |
+
jQuery('.postbox').each(function () {
|
321 |
+
var temp = jQuery(this);
|
322 |
+
var temp_id = temp.attr('id');
|
323 |
|
324 |
+
if (temp_id.substr(0, 14) != 'wp-statistics-') {
|
325 |
+
return;
|
326 |
+
}
|
327 |
|
328 |
+
var temp_html = temp.html();
|
329 |
|
330 |
+
if (temp_id == 'wp-statistics-summary-widget') {
|
331 |
+
new_text = '<?php echo $new_button;?>';
|
332 |
+
new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
|
333 |
|
334 |
+
temp_html = temp_html.replace('</button>', new_text);
|
335 |
+
} else {
|
336 |
+
new_text = '<?php echo $new_buttons;?>';
|
337 |
+
new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
|
338 |
+
new_text = new_text.replace('{{moreid}}', temp_id + '_more_button');
|
339 |
|
340 |
+
temp_html = temp_html.replace('</button>', new_text);
|
341 |
+
}
|
342 |
|
343 |
+
temp.html(temp_html);
|
344 |
+
});
|
345 |
|
346 |
+
// We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
|
347 |
+
// Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
|
348 |
+
setTimeout(wp_statistics_wait_for_postboxes, 100);
|
349 |
+
});
|
350 |
+
</script>
|
351 |
<?php
|
352 |
}
|
353 |
|
354 |
static function generate_postbox_contents( $post, $args ) {
|
355 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
356 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
357 |
'ajax-loading.gif" alt="' .
|
358 |
+
__( 'Loading...', 'wp-statistics' ) .
|
359 |
'"></div>';
|
360 |
$widget = $args['args']['widget'];
|
361 |
+
$container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
|
362 |
|
363 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
364 |
+
wp_statistics_generate_widget_load_javascript( $widget, $container_id );
|
365 |
}
|
366 |
|
367 |
}
|
includes/classes/class-wp-statistics-editor.php
CHANGED
@@ -15,42 +15,42 @@ class WP_Statistics_Editor {
|
|
15 |
|
16 |
// 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
|
17 |
// the first time they visit the dashboard though so check to see if we've been here before.
|
18 |
-
if ( ! $WP_Statistics->get_user_option('editor_set') ) {
|
19 |
-
$WP_Statistics->update_user_option('editor_set', WP_Statistics::$reg['version']);
|
20 |
|
21 |
-
$hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_post', true);
|
22 |
-
if ( ! is_array($hidden_widgets) ) {
|
23 |
$hidden_widgets = array();
|
24 |
}
|
25 |
|
26 |
-
if ( ! in_array('wp_statistics_editor_meta_box', $hidden_widgets) ) {
|
27 |
$hidden_widgets[] = 'wp_statistics_editor_meta_box';
|
28 |
}
|
29 |
|
30 |
-
update_user_meta($WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets);
|
31 |
|
32 |
-
$hidden_widgets = get_user_meta($WP_Statistics->user_id, 'metaboxhidden_page', true);
|
33 |
-
if ( ! is_array($hidden_widgets) ) {
|
34 |
$hidden_widgets = array();
|
35 |
}
|
36 |
|
37 |
-
if ( ! in_array('wp_statistics_editor_meta_box', $hidden_widgets) ) {
|
38 |
$hidden_widgets[] = 'wp_statistics_editor_meta_box';
|
39 |
}
|
40 |
|
41 |
-
update_user_meta($WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets);
|
42 |
}
|
43 |
|
44 |
// If the user does not have at least read access to the status plugin, just return without adding the widgets.
|
45 |
if ( ! current_user_can(
|
46 |
-
wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_option'))
|
47 |
)
|
48 |
) {
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
// If the admin has disabled the widgets don't display them.
|
53 |
-
if ( $WP_Statistics->get_option('disable_editor') ) {
|
54 |
return;
|
55 |
}
|
56 |
|
@@ -60,7 +60,7 @@ class WP_Statistics_Editor {
|
|
60 |
|
61 |
add_meta_box(
|
62 |
'wp_statistics_editor_meta_box',
|
63 |
-
__('Hit Statistics', 'wp-statistics'),
|
64 |
'WP_Statistics_Editor::meta_box',
|
65 |
$screen,
|
66 |
'normal',
|
@@ -73,28 +73,28 @@ class WP_Statistics_Editor {
|
|
73 |
static function meta_box( $post ) {
|
74 |
// 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.
|
75 |
if ( $post->post_status != 'publish' && $post->post_status != 'private' ) {
|
76 |
-
_e('This post is not yet published.', 'wp-statistics');
|
77 |
|
78 |
return;
|
79 |
}
|
80 |
|
81 |
-
add_action('admin_footer', 'WP_Statistics_Editor::inline_javascript');
|
82 |
|
83 |
-
WP_Statistics_Editor::generate_postbox_contents($post->ID, array( 'args' => array( 'widget' => 'page' ) ));
|
84 |
}
|
85 |
|
86 |
static function generate_postbox_contents( $post, $args ) {
|
87 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
88 |
-
plugins_url('wp-statistics/assets/images/') .
|
89 |
'ajax-loading.gif" alt="' .
|
90 |
-
__('Loading...', 'wp-statistics') .
|
91 |
'"></div>';
|
92 |
$widget = $args['args']['widget'];
|
93 |
-
$container_id = 'wp-statistics-' . str_replace('.', '-', $widget) . '-div';
|
94 |
|
95 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
96 |
echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
|
97 |
-
wp_statistics_generate_widget_load_javascript($widget, $container_id);
|
98 |
}
|
99 |
|
100 |
static function inline_javascript() {
|
@@ -107,26 +107,26 @@ class WP_Statistics_Editor {
|
|
107 |
WP_Statistics_Dashboard::load_widget_css_and_scripts();
|
108 |
|
109 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
110 |
-
plugins_url('wp-statistics/assets/images/') .
|
111 |
'ajax-loading.gif" alt="' .
|
112 |
-
__('Reloading...', 'wp-statistics') .
|
113 |
'"></div>';
|
114 |
|
115 |
$new_buttons
|
116 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
117 |
-
wp_statistics_icons('dashicons-update') .
|
118 |
'<span class="screen-reader-text">' .
|
119 |
-
__('Reload', 'wp-statistics') .
|
120 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
121 |
-
wp_statistics_icons('dashicons-migrate') .
|
122 |
'<span class="screen-reader-text">' .
|
123 |
-
__('More Details', 'wp-statistics') .
|
124 |
'</span></button>';
|
125 |
$new_button
|
126 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
127 |
-
wp_statistics_icons('dashicons-update') .
|
128 |
'<span class="screen-reader-text">' .
|
129 |
-
__('Reload', 'wp-statistics') .
|
130 |
'</span></button>';
|
131 |
|
132 |
$admin_url = get_admin_url() . "/admin.php?page=";
|
@@ -138,48 +138,48 @@ class WP_Statistics_Editor {
|
|
138 |
'&page-id=';
|
139 |
|
140 |
?>
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
|
164 |
-
|
165 |
|
166 |
-
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
<?php
|
184 |
}
|
185 |
}
|
15 |
|
16 |
// 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
|
17 |
// the first time they visit the dashboard though so check to see if we've been here before.
|
18 |
+
if ( ! $WP_Statistics->get_user_option( 'editor_set' ) ) {
|
19 |
+
$WP_Statistics->update_user_option( 'editor_set', WP_Statistics::$reg['version'] );
|
20 |
|
21 |
+
$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', true );
|
22 |
+
if ( ! is_array( $hidden_widgets ) ) {
|
23 |
$hidden_widgets = array();
|
24 |
}
|
25 |
|
26 |
+
if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
|
27 |
$hidden_widgets[] = 'wp_statistics_editor_meta_box';
|
28 |
}
|
29 |
|
30 |
+
update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets );
|
31 |
|
32 |
+
$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', true );
|
33 |
+
if ( ! is_array( $hidden_widgets ) ) {
|
34 |
$hidden_widgets = array();
|
35 |
}
|
36 |
|
37 |
+
if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) {
|
38 |
$hidden_widgets[] = 'wp_statistics_editor_meta_box';
|
39 |
}
|
40 |
|
41 |
+
update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets );
|
42 |
}
|
43 |
|
44 |
// If the user does not have at least read access to the status plugin, just return without adding the widgets.
|
45 |
if ( ! current_user_can(
|
46 |
+
wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_option' ) )
|
47 |
)
|
48 |
) {
|
49 |
return;
|
50 |
}
|
51 |
|
52 |
// If the admin has disabled the widgets don't display them.
|
53 |
+
if ( $WP_Statistics->get_option( 'disable_editor' ) ) {
|
54 |
return;
|
55 |
}
|
56 |
|
60 |
|
61 |
add_meta_box(
|
62 |
'wp_statistics_editor_meta_box',
|
63 |
+
__( 'Hit Statistics', 'wp-statistics' ),
|
64 |
'WP_Statistics_Editor::meta_box',
|
65 |
$screen,
|
66 |
'normal',
|
73 |
static function meta_box( $post ) {
|
74 |
// 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.
|
75 |
if ( $post->post_status != 'publish' && $post->post_status != 'private' ) {
|
76 |
+
_e( 'This post is not yet published.', 'wp-statistics' );
|
77 |
|
78 |
return;
|
79 |
}
|
80 |
|
81 |
+
add_action( 'admin_footer', 'WP_Statistics_Editor::inline_javascript' );
|
82 |
|
83 |
+
WP_Statistics_Editor::generate_postbox_contents( $post->ID, array( 'args' => array( 'widget' => 'page' ) ) );
|
84 |
}
|
85 |
|
86 |
static function generate_postbox_contents( $post, $args ) {
|
87 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
88 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
89 |
'ajax-loading.gif" alt="' .
|
90 |
+
__( 'Loading...', 'wp-statistics' ) .
|
91 |
'"></div>';
|
92 |
$widget = $args['args']['widget'];
|
93 |
+
$container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
|
94 |
|
95 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
96 |
echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
|
97 |
+
wp_statistics_generate_widget_load_javascript( $widget, $container_id );
|
98 |
}
|
99 |
|
100 |
static function inline_javascript() {
|
107 |
WP_Statistics_Dashboard::load_widget_css_and_scripts();
|
108 |
|
109 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
110 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
111 |
'ajax-loading.gif" alt="' .
|
112 |
+
__( 'Reloading...', 'wp-statistics' ) .
|
113 |
'"></div>';
|
114 |
|
115 |
$new_buttons
|
116 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
117 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
118 |
'<span class="screen-reader-text">' .
|
119 |
+
__( 'Reload', 'wp-statistics' ) .
|
120 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
121 |
+
wp_statistics_icons( 'dashicons-migrate' ) .
|
122 |
'<span class="screen-reader-text">' .
|
123 |
+
__( 'More Details', 'wp-statistics' ) .
|
124 |
'</span></button>';
|
125 |
$new_button
|
126 |
= '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
127 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
128 |
'<span class="screen-reader-text">' .
|
129 |
+
__( 'Reload', 'wp-statistics' ) .
|
130 |
'</span></button>';
|
131 |
|
132 |
$admin_url = get_admin_url() . "/admin.php?page=";
|
138 |
'&page-id=';
|
139 |
|
140 |
?>
|
141 |
+
<script type="text/javascript">
|
142 |
+
var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
|
143 |
+
var wp_statistics_loading_image = '<?php echo $loading_img; ?>';
|
144 |
|
145 |
+
function wp_statistics_wait_for_postboxes() {
|
146 |
|
147 |
+
if (!jQuery('#show-settings-link').is(':visible')) {
|
148 |
+
setTimeout(wp_statistics_wait_for_postboxes, 500);
|
149 |
+
}
|
150 |
|
151 |
+
jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
|
152 |
+
jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
|
153 |
|
154 |
+
jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
|
155 |
+
}
|
156 |
|
157 |
+
jQuery(document).ready(function () {
|
158 |
|
159 |
+
// Add the "more" and "refresh" buttons.
|
160 |
+
jQuery('.postbox').each(function () {
|
161 |
+
var temp = jQuery(this);
|
162 |
+
var temp_id = temp.attr('id');
|
163 |
|
164 |
+
if (temp_id == 'wp_statistics_editor_meta_box') {
|
165 |
|
166 |
+
var temp_html = temp.html();
|
167 |
|
168 |
+
new_text = '<?php echo $new_buttons;?>';
|
169 |
+
new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button');
|
170 |
+
new_text = new_text.replace('{{moreid}}', temp_id + '_more_button');
|
171 |
|
172 |
+
temp_html = temp_html.replace('</button>', new_text);
|
173 |
|
174 |
+
temp.html(temp_html);
|
175 |
+
}
|
176 |
+
});
|
177 |
|
178 |
+
// We have use a timeout here because we don't now what order this code will run in comparison to the postbox code.
|
179 |
+
// Any timeout value should work as the timeout won't run until the rest of the javascript as run through once.
|
180 |
+
setTimeout(wp_statistics_wait_for_postboxes, 100);
|
181 |
+
});
|
182 |
+
</script>
|
183 |
<?php
|
184 |
}
|
185 |
}
|
includes/classes/class-wp-statistics-frontend.php
CHANGED
@@ -8,20 +8,20 @@ class WP_Statistics_Frontend {
|
|
8 |
public function __construct() {
|
9 |
global $WP_Statistics;
|
10 |
|
11 |
-
add_filter('widget_text', 'do_shortcode');
|
12 |
|
13 |
new WP_Statistics_Schedule;
|
14 |
|
15 |
// Add the honey trap code in the footer.
|
16 |
-
add_action('wp_footer', 'WP_Statistics_Frontend::add_honeypot');
|
17 |
|
18 |
-
if ( $WP_Statistics->get_option('menu_bar') ) {
|
19 |
-
add_action('wp_enqueue_scripts', 'WP_Statistics_Frontend::enqueue_scripts');
|
20 |
}
|
21 |
-
|
22 |
// We can wait until the very end of the page to process the statistics,
|
23 |
// that way the page loads and displays quickly.
|
24 |
-
add_action('wp', 'WP_Statistics_Frontend::init');
|
25 |
}
|
26 |
|
27 |
/**
|
@@ -29,8 +29,8 @@ class WP_Statistics_Frontend {
|
|
29 |
*/
|
30 |
static function add_honeypot() {
|
31 |
global $WP_Statistics;
|
32 |
-
if ( $WP_Statistics->get_option('use_honeypot') && $WP_Statistics->get_option('honeypot_postid') > 0 ) {
|
33 |
-
$post_url = get_permalink($WP_Statistics->get_option('honeypot_postid'));
|
34 |
echo '<a href="' . $post_url . '" style="display: none;"> </a>';
|
35 |
}
|
36 |
}
|
@@ -43,10 +43,10 @@ class WP_Statistics_Frontend {
|
|
43 |
static function enqueue_scripts( $hook ) {
|
44 |
// Load our CSS to be used.
|
45 |
wp_enqueue_style(
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
);
|
51 |
}
|
52 |
|
@@ -58,73 +58,34 @@ class WP_Statistics_Frontend {
|
|
58 |
|
59 |
// If something has gone horribly wrong and $WP_Statistics isn't an object, bail out.
|
60 |
// This seems to happen sometimes with WP Cron calls.
|
61 |
-
if ( ! is_object($WP_Statistics) ) {
|
62 |
return;
|
63 |
}
|
64 |
|
65 |
$h = new WP_Statistics_GEO_IP_Hits;
|
66 |
|
67 |
// Call the online users tracking code.
|
68 |
-
if ( $WP_Statistics->get_option('useronline') ) {
|
69 |
$h->Check_online();
|
70 |
}
|
71 |
|
72 |
// Call the visitor tracking code.
|
73 |
-
if ( $WP_Statistics->get_option('visitors') ) {
|
74 |
$h->Visitors();
|
75 |
}
|
76 |
|
77 |
// Call the visit tracking code.
|
78 |
-
if ( $WP_Statistics->get_option('visits') ) {
|
79 |
$h->Visits();
|
80 |
}
|
81 |
|
82 |
// Call the page tracking code.
|
83 |
-
if ( $WP_Statistics->get_option('pages') ) {
|
84 |
$h->Pages();
|
85 |
}
|
86 |
|
87 |
-
// Check to see if the GeoIP database needs to be downloaded and do so if required.
|
88 |
-
if ( $WP_Statistics->get_option('update_geoip') ) {
|
89 |
-
WP_Statistics_Updates::download_geoip();
|
90 |
-
}
|
91 |
-
|
92 |
-
// Check to see if the browscap database needs to be downloaded and do so if required.
|
93 |
-
if ( $WP_Statistics->get_option('update_browscap') ) {
|
94 |
-
WP_Statistics_Updates::download_browscap();
|
95 |
-
}
|
96 |
-
|
97 |
-
// Check to see if the referrerspam database needs to be downloaded and do so if required.
|
98 |
-
if ( $WP_Statistics->get_option('update_referrerspam') ) {
|
99 |
-
WP_Statistics_Updates::download_referrerspam();
|
100 |
-
}
|
101 |
-
|
102 |
-
if ( $WP_Statistics->get_option('send_upgrade_email') ) {
|
103 |
-
$WP_Statistics->update_option('send_upgrade_email', false);
|
104 |
-
|
105 |
-
$blogname = get_bloginfo('name');
|
106 |
-
$blogemail = get_bloginfo('admin_email');
|
107 |
-
|
108 |
-
$headers[] = "From: $blogname <$blogemail>";
|
109 |
-
$headers[] = "MIME-Version: 1.0";
|
110 |
-
$headers[] = "Content-type: text/html; charset=utf-8";
|
111 |
-
|
112 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
113 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
114 |
-
}
|
115 |
-
|
116 |
-
wp_mail(
|
117 |
-
$WP_Statistics->get_option('email_list'),
|
118 |
-
sprintf(__('WP Statistics %s installed on', 'wp-statistics'), WP_Statistics::$reg['version']) .
|
119 |
-
' ' .
|
120 |
-
$blogname,
|
121 |
-
"Installation/upgrade complete!",
|
122 |
-
$headers
|
123 |
-
);
|
124 |
-
}
|
125 |
-
|
126 |
// Check to show hits in posts/pages
|
127 |
-
if ( $WP_Statistics->get_option('show_hits') ) {
|
128 |
add_filter( 'the_content', 'WP_Statistics_Frontend::show_hits' );
|
129 |
}
|
130 |
}
|
@@ -134,25 +95,25 @@ class WP_Statistics_Frontend {
|
|
134 |
*
|
135 |
* @return string
|
136 |
*/
|
137 |
-
public static function show_hits($content) {
|
138 |
global $WP_Statistics;
|
139 |
|
140 |
// Get post ID
|
141 |
$post_id = get_the_ID();
|
142 |
|
143 |
// Check post ID
|
144 |
-
if(
|
145 |
return $content;
|
146 |
}
|
147 |
|
148 |
// Get post hits
|
149 |
-
$hits
|
150 |
-
$hits_html = sprintf(__('
|
151 |
|
152 |
// Check hits position
|
153 |
-
if ( $WP_Statistics->get_option('display_hits_position') == 'before_content' ) {
|
154 |
return $hits_html . $content;
|
155 |
-
} elseif ( $WP_Statistics->get_option('display_hits_position') == 'after_content' ) {
|
156 |
return $content . $hits_html;
|
157 |
} else {
|
158 |
return $content;
|
8 |
public function __construct() {
|
9 |
global $WP_Statistics;
|
10 |
|
11 |
+
add_filter( 'widget_text', 'do_shortcode' );
|
12 |
|
13 |
new WP_Statistics_Schedule;
|
14 |
|
15 |
// Add the honey trap code in the footer.
|
16 |
+
add_action( 'wp_footer', 'WP_Statistics_Frontend::add_honeypot' );
|
17 |
|
18 |
+
if ( $WP_Statistics->get_option( 'menu_bar' ) ) {
|
19 |
+
add_action( 'wp_enqueue_scripts', 'WP_Statistics_Frontend::enqueue_scripts' );
|
20 |
}
|
21 |
+
|
22 |
// We can wait until the very end of the page to process the statistics,
|
23 |
// that way the page loads and displays quickly.
|
24 |
+
add_action( 'wp', 'WP_Statistics_Frontend::init' );
|
25 |
}
|
26 |
|
27 |
/**
|
29 |
*/
|
30 |
static function add_honeypot() {
|
31 |
global $WP_Statistics;
|
32 |
+
if ( $WP_Statistics->get_option( 'use_honeypot' ) && $WP_Statistics->get_option( 'honeypot_postid' ) > 0 ) {
|
33 |
+
$post_url = get_permalink( $WP_Statistics->get_option( 'honeypot_postid' ) );
|
34 |
echo '<a href="' . $post_url . '" style="display: none;"> </a>';
|
35 |
}
|
36 |
}
|
43 |
static function enqueue_scripts( $hook ) {
|
44 |
// Load our CSS to be used.
|
45 |
wp_enqueue_style(
|
46 |
+
'wpstatistics-css',
|
47 |
+
WP_Statistics::$reg['plugin-url'] . 'assets/css/frontend.css',
|
48 |
+
true,
|
49 |
+
WP_Statistics::$reg['version']
|
50 |
);
|
51 |
}
|
52 |
|
58 |
|
59 |
// If something has gone horribly wrong and $WP_Statistics isn't an object, bail out.
|
60 |
// This seems to happen sometimes with WP Cron calls.
|
61 |
+
if ( ! is_object( $WP_Statistics ) ) {
|
62 |
return;
|
63 |
}
|
64 |
|
65 |
$h = new WP_Statistics_GEO_IP_Hits;
|
66 |
|
67 |
// Call the online users tracking code.
|
68 |
+
if ( $WP_Statistics->get_option( 'useronline' ) ) {
|
69 |
$h->Check_online();
|
70 |
}
|
71 |
|
72 |
// Call the visitor tracking code.
|
73 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
74 |
$h->Visitors();
|
75 |
}
|
76 |
|
77 |
// Call the visit tracking code.
|
78 |
+
if ( $WP_Statistics->get_option( 'visits' ) ) {
|
79 |
$h->Visits();
|
80 |
}
|
81 |
|
82 |
// Call the page tracking code.
|
83 |
+
if ( $WP_Statistics->get_option( 'pages' ) ) {
|
84 |
$h->Pages();
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
// Check to show hits in posts/pages
|
88 |
+
if ( $WP_Statistics->get_option( 'show_hits' ) ) {
|
89 |
add_filter( 'the_content', 'WP_Statistics_Frontend::show_hits' );
|
90 |
}
|
91 |
}
|
95 |
*
|
96 |
* @return string
|
97 |
*/
|
98 |
+
public static function show_hits( $content ) {
|
99 |
global $WP_Statistics;
|
100 |
|
101 |
// Get post ID
|
102 |
$post_id = get_the_ID();
|
103 |
|
104 |
// Check post ID
|
105 |
+
if ( ! $post_id ) {
|
106 |
return $content;
|
107 |
}
|
108 |
|
109 |
// Get post hits
|
110 |
+
$hits = wp_statistics_pages( 'total', "", $post_id );
|
111 |
+
$hits_html = '<p>' . sprintf( __( 'Hits: %s', 'wp-statistics' ), $hits ) . '</p>';
|
112 |
|
113 |
// Check hits position
|
114 |
+
if ( $WP_Statistics->get_option( 'display_hits_position' ) == 'before_content' ) {
|
115 |
return $hits_html . $content;
|
116 |
+
} elseif ( $WP_Statistics->get_option( 'display_hits_position' ) == 'after_content' ) {
|
117 |
return $content . $hits_html;
|
118 |
} else {
|
119 |
return $content;
|
includes/classes/class-wp-statistics-geo-ip-hits.php
CHANGED
@@ -21,10 +21,10 @@ class WP_Statistics_GEO_IP_Hits extends WP_Statistics_Hits {
|
|
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');
|
25 |
|
26 |
// Look up the IP address
|
27 |
-
$record = $reader->country($WP_Statistics->ip);
|
28 |
|
29 |
// Get the location.
|
30 |
$location = $record->country->isoCode;
|
@@ -46,25 +46,25 @@ class WP_Statistics_GEO_IP_Hits extends WP_Statistics_Hits {
|
|
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(
|
48 |
"\n",
|
49 |
-
strtoupper(str_replace("\r\n", "\n", $WP_Statistics->get_option('excluded_countries')))
|
50 |
);
|
51 |
$included_countries_string = trim(
|
52 |
-
strtoupper(str_replace("\r\n", "\n", $WP_Statistics->get_option('included_countries')))
|
53 |
);
|
54 |
|
55 |
// We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none.
|
56 |
if ( $included_countries_string == '' ) {
|
57 |
$included_countries = array();
|
58 |
} else {
|
59 |
-
$included_countries = explode("\n", $included_countries_string);
|
60 |
}
|
61 |
|
62 |
// Check to see if the current location is in the excluded countries list.
|
63 |
-
if ( in_array($this->location, $excluded_countries) ) {
|
64 |
$this->exclusion_match = true;
|
65 |
$this->exclusion_reason = "geoip";
|
66 |
} // Check to see if the current location is not the included countries list.
|
67 |
-
else if ( ! in_array($this->location, $included_countries) && count($included_countries) > 0 ) {
|
68 |
$this->exclusion_match = true;
|
69 |
$this->exclusion_reason = "geoip";
|
70 |
}
|
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' );
|
25 |
|
26 |
// Look up the IP address
|
27 |
+
$record = $reader->country( $WP_Statistics->ip );
|
28 |
|
29 |
// Get the location.
|
30 |
$location = $record->country->isoCode;
|
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(
|
48 |
"\n",
|
49 |
+
strtoupper( str_replace( "\r\n", "\n", $WP_Statistics->get_option( 'excluded_countries' ) ) )
|
50 |
);
|
51 |
$included_countries_string = trim(
|
52 |
+
strtoupper( str_replace( "\r\n", "\n", $WP_Statistics->get_option( 'included_countries' ) ) )
|
53 |
);
|
54 |
|
55 |
// We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none.
|
56 |
if ( $included_countries_string == '' ) {
|
57 |
$included_countries = array();
|
58 |
} else {
|
59 |
+
$included_countries = explode( "\n", $included_countries_string );
|
60 |
}
|
61 |
|
62 |
// Check to see if the current location is in the excluded countries list.
|
63 |
+
if ( in_array( $this->location, $excluded_countries ) ) {
|
64 |
$this->exclusion_match = true;
|
65 |
$this->exclusion_reason = "geoip";
|
66 |
} // Check to see if the current location is not the included countries list.
|
67 |
+
else if ( ! in_array( $this->location, $included_countries ) && count( $included_countries ) > 0 ) {
|
68 |
$this->exclusion_match = true;
|
69 |
$this->exclusion_reason = "geoip";
|
70 |
}
|
includes/classes/class-wp-statistics-hits.php
CHANGED
@@ -4,7 +4,8 @@
|
|
4 |
This class handles; visits, visitors and pages.
|
5 |
*/
|
6 |
|
7 |
-
use
|
|
|
8 |
use IPTools\IP;
|
9 |
use IPTools\Network;
|
10 |
use IPTools\Range;
|
@@ -14,8 +15,8 @@ class WP_Statistics_Hits {
|
|
14 |
// Setup our public/private/protected variables.
|
15 |
public $result = null;
|
16 |
|
17 |
-
protected $location
|
18 |
-
protected $exclusion_match
|
19 |
protected $exclusion_reason = '';
|
20 |
|
21 |
private $exclusion_record = false;
|
@@ -28,32 +29,32 @@ class WP_Statistics_Hits {
|
|
28 |
global $wp_version, $WP_Statistics;
|
29 |
|
30 |
// Set the timestamp value.
|
31 |
-
$this->timestamp = $WP_Statistics->current_date('U');
|
32 |
|
33 |
// Set the default seconds a user needs to visit the site before they are considered offline.
|
34 |
$this->second = 30;
|
35 |
|
36 |
// Get the user set value for seconds to check for users online.
|
37 |
-
if ( $WP_Statistics->get_option('check_online') ) {
|
38 |
-
$this->second = $WP_Statistics->get_option('check_online');
|
39 |
}
|
40 |
|
41 |
// Check to see if the user wants us to record why we're excluding hits.
|
42 |
-
if ( $WP_Statistics->get_option('record_exclusions') ) {
|
43 |
$this->exclusion_record = true;
|
44 |
}
|
45 |
|
46 |
// Create a IP Tools instance from the current IP address for use later.
|
47 |
// Fall back to the localhost if it can't be parsed.
|
48 |
try {
|
49 |
-
$ip = new IP($WP_Statistics->ip);
|
50 |
} catch ( Exception $e ) {
|
51 |
-
$ip = new IP('127.0.0.1');
|
52 |
}
|
53 |
|
54 |
// Let's check to see if our subnet matches a private IP address range, if so go ahead and set the location information now.
|
55 |
-
if ( $WP_Statistics->get_option('private_country_code') != '000' &&
|
56 |
-
$WP_Statistics->get_option('private_country_code') != ''
|
57 |
) {
|
58 |
$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' );
|
59 |
|
@@ -61,13 +62,13 @@ class WP_Statistics_Hits {
|
|
61 |
$contains_ip = false;
|
62 |
|
63 |
try {
|
64 |
-
$contains_ip = Range::parse($psub)->contains($ip);
|
65 |
} catch ( Exception $e ) {
|
66 |
$contains_ip = false;
|
67 |
}
|
68 |
|
69 |
if ( $contains_ip ) {
|
70 |
-
$this->location = $WP_Statistics->get_option('private_country_code');
|
71 |
break;
|
72 |
}
|
73 |
}
|
@@ -95,14 +96,14 @@ class WP_Statistics_Hits {
|
|
95 |
$page_uri = wp_statistics_get_uri();
|
96 |
$ajax_string = 'admin-ajax.php';
|
97 |
|
98 |
-
if ( strpos($page_uri, $ajax_string) !== false ) {
|
99 |
$this->exclusion_match = true;
|
100 |
$this->exclusion_reason = 'ajax';
|
101 |
|
102 |
return;
|
103 |
}
|
104 |
|
105 |
-
if ( ( defined('DOING_CRON') && DOING_CRON === true ) || ( function_exists('wp_doing_cron') && wp_doing_cron() === true ) ) {
|
106 |
$this->exclusion_match = true;
|
107 |
$this->exclusion_reason = 'cronjob';
|
108 |
|
@@ -113,24 +114,24 @@ class WP_Statistics_Hits {
|
|
113 |
$crawler = false;
|
114 |
$ua_string = '';
|
115 |
|
116 |
-
if ( array_key_exists('HTTP_USER_AGENT', $_SERVER) ) {
|
117 |
$ua_string = $_SERVER['HTTP_USER_AGENT'];
|
118 |
}
|
119 |
|
120 |
-
if ( $WP_Statistics->get_option('last_browscap_dl') > 1 && $WP_Statistics->get_option('browscap') ) {
|
121 |
// Get the upload directory from WordPress.
|
122 |
$upload_dir = wp_upload_dir();
|
123 |
|
124 |
-
|
125 |
-
$BrowscapFile = $upload_dir['basedir'] . '/wp-statistics';
|
126 |
|
127 |
// Get the Browser Capabilities use Browscap.
|
128 |
-
$bc = new Browscap($BrowscapFile);
|
129 |
-
$bc->doAutoUpdate = false; // We don't want to auto update.
|
130 |
try {
|
131 |
-
$
|
|
|
|
|
|
|
132 |
// Make sure we got an object back and it has the Crawler property before accessing it.
|
133 |
-
if (
|
134 |
$crawler = $current_browser->Crawler;
|
135 |
} else {
|
136 |
$crawler = false;
|
@@ -139,7 +140,7 @@ class WP_Statistics_Hits {
|
|
139 |
$crawler = false;
|
140 |
}
|
141 |
} else {
|
142 |
-
$WP_Statistics->update_option('update_browscap', true);
|
143 |
}
|
144 |
|
145 |
// If we're a crawler as per browscap, exclude us, otherwise double check based on the WP Statistics robot list.
|
@@ -150,15 +151,15 @@ class WP_Statistics_Hits {
|
|
150 |
return;
|
151 |
} else {
|
152 |
// Pull the robots from the database.
|
153 |
-
$robots = explode("\n", $WP_Statistics->get_option('robotlist'));
|
154 |
|
155 |
// Check to see if we match any of the robots.
|
156 |
foreach ( $robots as $robot ) {
|
157 |
-
$robot = trim($robot);
|
158 |
|
159 |
// If the match case is less than 4 characters long, it might match too much so don't execute it.
|
160 |
-
if ( strlen($robot) > 3 ) {
|
161 |
-
if ( stripos($ua_string, $robot) !== false ) {
|
162 |
$this->exclusion_match = true;
|
163 |
$this->exclusion_reason = 'robot';
|
164 |
|
@@ -168,7 +169,7 @@ class WP_Statistics_Hits {
|
|
168 |
}
|
169 |
|
170 |
// Finally check to see if we have corrupt header information.
|
171 |
-
if ( ! $this->exclusion_match && $WP_Statistics->get_option('corrupt_browser_info') ) {
|
172 |
if ( $ua_string == '' || $WP_Statistics->ip == '' ) {
|
173 |
$this->exclusion_match = true;
|
174 |
$this->exclusion_reason = 'robot';
|
@@ -181,18 +182,18 @@ class WP_Statistics_Hits {
|
|
181 |
// If we didn't match a robot, check ip subnets.
|
182 |
|
183 |
// Pull the subnets from the database.
|
184 |
-
$subnets = explode("\n", $WP_Statistics->get_option('exclude_ip'));
|
185 |
|
186 |
// Check to see if we match any of the excluded addresses.
|
187 |
foreach ( $subnets as $subnet ) {
|
188 |
-
$subnet = trim($subnet);
|
189 |
|
190 |
// The shortest ip address is 1.1.1.1, anything less must be a malformed entry.
|
191 |
-
if ( strlen($subnet) > 6 ) {
|
192 |
$range_prased = false;
|
193 |
|
194 |
try {
|
195 |
-
$range_prased = Range::parse($subnet)->contains($ip);
|
196 |
} catch ( Exception $e ) {
|
197 |
$range_parased = false;
|
198 |
}
|
@@ -207,7 +208,7 @@ class WP_Statistics_Hits {
|
|
207 |
}
|
208 |
|
209 |
// Check to see if we are being referred to ourselves.
|
210 |
-
if ( $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url(null, '/') ||
|
211 |
$ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url()
|
212 |
) {
|
213 |
$this->exclusion_match = true;
|
@@ -217,8 +218,8 @@ class WP_Statistics_Hits {
|
|
217 |
}
|
218 |
|
219 |
// Check to see if we're excluding the login page.
|
220 |
-
if ( $WP_Statistics->get_option('exclude_loginpage') ) {
|
221 |
-
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https';
|
222 |
$host = $_SERVER['HTTP_HOST'];
|
223 |
$script = $_SERVER['SCRIPT_NAME'];
|
224 |
|
@@ -234,19 +235,19 @@ class WP_Statistics_Hits {
|
|
234 |
}
|
235 |
|
236 |
// Check to see if we're excluding referrer spam.
|
237 |
-
if ( $WP_Statistics->get_option('referrerspam') ) {
|
238 |
$referrer = $WP_Statistics->get_Referred();
|
239 |
|
240 |
// Pull the referrer spam list from the database.
|
241 |
-
$referrerspamlist = explode("\n", $WP_Statistics->get_option('referrerspamlist'));
|
242 |
|
243 |
// Check to see if we match any of the robots.
|
244 |
foreach ( $referrerspamlist as $item ) {
|
245 |
-
$item = trim($item);
|
246 |
|
247 |
// If the match case is less than 4 characters long, it might match too much so don't execute it.
|
248 |
-
if ( strlen($item) > 3 ) {
|
249 |
-
if ( stripos($referrer, $item) !== false ) {
|
250 |
$this->exclusion_match = true;
|
251 |
$this->exclusion_reason = 'referrer_spam';
|
252 |
|
@@ -257,7 +258,7 @@ class WP_Statistics_Hits {
|
|
257 |
}
|
258 |
|
259 |
// Check to see if we're excluding RSS feeds.
|
260 |
-
if ( $WP_Statistics->get_option('exclude_feeds') ) {
|
261 |
if ( is_feed() ) {
|
262 |
$this->exclusion_match = true;
|
263 |
$this->exclusion_reason = 'feed';
|
@@ -267,7 +268,7 @@ class WP_Statistics_Hits {
|
|
267 |
}
|
268 |
|
269 |
// Check to see if we're excluding 404 pages.
|
270 |
-
if ( $WP_Statistics->get_option('exclude_404s') ) {
|
271 |
if ( is_404() ) {
|
272 |
$this->exclusion_match = true;
|
273 |
$this->exclusion_reason = '404';
|
@@ -277,20 +278,20 @@ class WP_Statistics_Hits {
|
|
277 |
}
|
278 |
|
279 |
// Check to see if we're excluding the current page url.
|
280 |
-
if ( $WP_Statistics->get_option('excluded_urls') ) {
|
281 |
$script = $_SERVER['REQUEST_URI'];
|
282 |
-
$delimiter = strpos($script, '?');
|
283 |
if ( $delimiter > 0 ) {
|
284 |
-
$script = substr($script, 0, $delimiter);
|
285 |
}
|
286 |
|
287 |
-
$excluded_urls = explode("\n", $WP_Statistics->get_option('excluded_urls'));
|
288 |
|
289 |
foreach ( $excluded_urls as $url ) {
|
290 |
-
$this_url = trim($url);
|
291 |
|
292 |
-
if ( strlen($this_url) > 2 ) {
|
293 |
-
if ( stripos($script, $this_url) === 0 ) {
|
294 |
$this->exclusion_match = true;
|
295 |
$this->exclusion_reason = 'excluded url';
|
296 |
|
@@ -305,8 +306,8 @@ class WP_Statistics_Hits {
|
|
305 |
$current_user = wp_get_current_user();
|
306 |
|
307 |
foreach ( $current_user->roles as $role ) {
|
308 |
-
$option_name = 'exclude_' . str_replace(' ', '_', strtolower($role));
|
309 |
-
if ( $WP_Statistics->get_option($option_name) == true ) {
|
310 |
$this->exclusion_match = true;
|
311 |
$this->exclusion_reason = 'user role';
|
312 |
|
@@ -317,14 +318,14 @@ class WP_Statistics_Hits {
|
|
317 |
|
318 |
// Check to see if we are excluded by the host name.
|
319 |
if ( ! $this->exclusion_match ) {
|
320 |
-
$excluded_host = explode("\n", $WP_Statistics->get_option('excluded_hosts'));
|
321 |
|
322 |
// If there's nothing in the excluded host list, don't do anything.
|
323 |
-
if ( count($excluded_host) > 0 ) {
|
324 |
$transient_name = 'wps_excluded_hostname_to_ip_cache';
|
325 |
|
326 |
// Get the transient with the hostname cache.
|
327 |
-
$hostname_cache = get_transient($transient_name);
|
328 |
|
329 |
// If the transient has expired (or has never been set), create one now.
|
330 |
if ( $hostname_cache === false ) {
|
@@ -333,18 +334,18 @@ class WP_Statistics_Hits {
|
|
333 |
|
334 |
// Loop through the list of hosts and look them up.
|
335 |
foreach ( $excluded_host as $host ) {
|
336 |
-
if ( strpos($host, '.') > 0 ) {
|
337 |
// 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.
|
338 |
-
$hostname_cache[ $host ] = gethostbyname($host . '.');
|
339 |
}
|
340 |
}
|
341 |
|
342 |
// Set the transient and store it for 1 hour.
|
343 |
-
set_transient($transient_name, $hostname_cache, 360);
|
344 |
}
|
345 |
|
346 |
// Check if the current IP address matches one of the ones in the excluded hosts list.
|
347 |
-
if ( in_array($WP_Statistics->ip, $hostname_cache) ) {
|
348 |
$this->exclusion_match = true;
|
349 |
$this->exclusion_reason = 'hostname';
|
350 |
|
@@ -367,7 +368,7 @@ class WP_Statistics_Hits {
|
|
367 |
);
|
368 |
|
369 |
// If we're a returning visitor, update the current record in the database, otherwise, create a new one.
|
370 |
-
if ( $this->result->last_counter != $WP_Statistics->Current_Date('Y-m-d') ) {
|
371 |
// 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
|
372 |
// for this IP address we want to do an "INSERT ... ON DUPLICATE KEY" which WordPress doesn't support.
|
373 |
$sqlstring = $wpdb->prepare(
|
@@ -376,11 +377,11 @@ class WP_Statistics_Hits {
|
|
376 |
'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d) ON DUPLICATE KEY UPDATE visit = visit + ' .
|
377 |
$WP_Statistics->coefficient,
|
378 |
$WP_Statistics->Current_Date(),
|
379 |
-
$WP_Statistics->Current_date('Y-m-d'),
|
380 |
$WP_Statistics->coefficient
|
381 |
);
|
382 |
|
383 |
-
$wpdb->query($sqlstring);
|
384 |
} else {
|
385 |
$sqlstring = $wpdb->prepare(
|
386 |
'UPDATE ' .
|
@@ -391,7 +392,7 @@ class WP_Statistics_Hits {
|
|
391 |
$this->result->last_counter
|
392 |
);
|
393 |
|
394 |
-
$wpdb->query($sqlstring);
|
395 |
}
|
396 |
}
|
397 |
}
|
@@ -401,13 +402,13 @@ class WP_Statistics_Hits {
|
|
401 |
global $wpdb, $wp_query, $WP_Statistics;
|
402 |
|
403 |
// Get the pages or posts ID if it exists.
|
404 |
-
if ( is_object($wp_query) ) {
|
405 |
$this->current_page_id = $wp_query->get_queried_object_id();
|
406 |
}
|
407 |
|
408 |
-
if ( $WP_Statistics->get_option('use_honeypot') &&
|
409 |
-
$WP_Statistics->get_option('honeypot_postid') > 0 &&
|
410 |
-
$WP_Statistics->get_option('honeypot_postid') == $this->current_page_id &&
|
411 |
$this->current_page_id > 0
|
412 |
) {
|
413 |
$this->exclusion_match = true;
|
@@ -440,7 +441,7 @@ class WP_Statistics_Hits {
|
|
440 |
if ( ! $this->result ) {
|
441 |
|
442 |
// If we've been told to store the entire user agent, do so.
|
443 |
-
if ( $WP_Statistics->get_option('store_ua') == true ) {
|
444 |
$ua = $_SERVER['HTTP_USER_AGENT'];
|
445 |
} else {
|
446 |
$ua = '';
|
@@ -453,7 +454,7 @@ class WP_Statistics_Hits {
|
|
453 |
'INSERT IGNORE INTO ' .
|
454 |
$wpdb->prefix .
|
455 |
'statistics_visitor (last_counter, referred, agent, platform, version, ip, location, UAString, hits, honeypot) VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, 1, %s )',
|
456 |
-
$WP_Statistics->Current_date('Y-m-d'),
|
457 |
$WP_Statistics->get_Referred(),
|
458 |
$WP_Statistics->agent['browser'],
|
459 |
$WP_Statistics->agent['platform'],
|
@@ -464,28 +465,28 @@ class WP_Statistics_Hits {
|
|
464 |
$honeypot
|
465 |
);
|
466 |
|
467 |
-
$wpdb->query($sqlstring);
|
468 |
|
469 |
// Now parse the referrer and store the results in the search table if the database has been converted.
|
470 |
// Also make sure we actually inserted a row on the INSERT IGNORE above or we'll create duplicate entries.
|
471 |
-
if ( $WP_Statistics->get_option('search_converted') && $wpdb->insert_id ) {
|
472 |
|
473 |
$search_engines = wp_statistics_searchengine_list();
|
474 |
$referred = $WP_Statistics->get_Referred();
|
475 |
|
476 |
// Parse the URL in to it's component parts.
|
477 |
-
$parts = parse_url($referred);
|
478 |
|
479 |
// Loop through the SE list until we find which search engine matches.
|
480 |
foreach ( $search_engines as $key => $value ) {
|
481 |
-
$search_regex = wp_statistics_searchengine_regex($key);
|
482 |
|
483 |
-
preg_match('/' . $search_regex . '/', $parts['host'], $matches);
|
484 |
|
485 |
if ( isset( $matches[1] ) ) {
|
486 |
-
$data['last_counter'] = $WP_Statistics->Current_date('Y-m-d');
|
487 |
$data['engine'] = $key;
|
488 |
-
$data['words'] = $WP_Statistics->Search_Engine_QueryString($referred);
|
489 |
$data['host'] = $parts['host'];
|
490 |
$data['visitor'] = $wpdb->insert_id;
|
491 |
|
@@ -493,14 +494,14 @@ class WP_Statistics_Hits {
|
|
493 |
$data['words'] = '';
|
494 |
}
|
495 |
|
496 |
-
$wpdb->insert($wpdb->prefix . 'statistics_search', $data);
|
497 |
}
|
498 |
}
|
499 |
}
|
500 |
} else {
|
501 |
// 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.
|
502 |
-
if ( $WP_Statistics->get_option('robot_threshold') > 0 &&
|
503 |
-
$this->result->hits + 1 > $WP_Statistics->get_option('robot_threshold')
|
504 |
) {
|
505 |
$this->exclusion_match = true;
|
506 |
$this->exclusion_reason = 'robot_threshold';
|
@@ -518,7 +519,7 @@ class WP_Statistics_Hits {
|
|
518 |
$this->result->ID
|
519 |
);
|
520 |
|
521 |
-
$wpdb->query($sqlstring);
|
522 |
}
|
523 |
}
|
524 |
}
|
@@ -543,7 +544,7 @@ class WP_Statistics_Hits {
|
|
543 |
$wpdb->insert(
|
544 |
$wpdb->prefix . 'statistics_exclusions',
|
545 |
array(
|
546 |
-
'date' => $WP_Statistics->Current_date('Y-m-d'),
|
547 |
'reason' => $this->exclusion_reason,
|
548 |
'count' => 1,
|
549 |
)
|
@@ -559,9 +560,9 @@ class WP_Statistics_Hits {
|
|
559 |
if ( ! $this->exclusion_match ) {
|
560 |
|
561 |
// Don't track anything but actual pages and posts, unless we've been told to.
|
562 |
-
if ( $WP_Statistics->get_option('track_all_pages') || is_page() || is_single() || is_front_page() ) {
|
563 |
// Get the pages or posts ID if it exists and we haven't set it in the visitors code.
|
564 |
-
if ( ! $this->current_page_id && is_object($wp_query) ) {
|
565 |
$this->current_page_id = $wp_query->get_queried_object_id();
|
566 |
}
|
567 |
|
@@ -573,22 +574,22 @@ class WP_Statistics_Hits {
|
|
573 |
// Get the current page URI.
|
574 |
$page_uri = wp_statistics_get_uri();
|
575 |
|
576 |
-
if ( $WP_Statistics->get_option('strip_uri_parameters') ) {
|
577 |
-
$temp = explode('?', $page_uri);
|
578 |
if ( $temp !== false ) {
|
579 |
$page_uri = $temp[0];
|
580 |
}
|
581 |
}
|
582 |
|
583 |
// Limit the URI length to 255 characters, otherwise we may overrun the SQL field size.
|
584 |
-
$page_uri = substr($page_uri, 0, 255);
|
585 |
|
586 |
// If we have already been to this page today (a likely scenario), just update the count on the record.
|
587 |
$sql = $wpdb->prepare(
|
588 |
"UPDATE {$wpdb->prefix}statistics_pages SET `count` = `count` + 1 WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND `uri` = %s",
|
589 |
$page_uri
|
590 |
);
|
591 |
-
$this->result = $wpdb->query($sql);
|
592 |
|
593 |
// 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
|
594 |
// exists where two people load the same page a the roughly the same time. In that case two inserts would be attempted but
|
@@ -599,7 +600,7 @@ class WP_Statistics_Hits {
|
|
599 |
$wpdb->prefix . 'statistics_pages',
|
600 |
array(
|
601 |
'uri' => $page_uri,
|
602 |
-
'date' => $WP_Statistics->Current_date('Y-m-d'),
|
603 |
'count' => 1,
|
604 |
'id' => $this->current_page_id,
|
605 |
)
|
@@ -633,7 +634,7 @@ class WP_Statistics_Hits {
|
|
633 |
public function Check_online() {
|
634 |
global $WP_Statistics;
|
635 |
// 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.
|
636 |
-
if ( ! $this->exclusion_match || $WP_Statistics->get_option('all_online') ) {
|
637 |
|
638 |
// If the current user exists in the database already,
|
639 |
// Just update them, otherwise add them
|
@@ -704,6 +705,6 @@ class WP_Statistics_Hits {
|
|
704 |
$timediff = $this->timestamp - $this->second;
|
705 |
|
706 |
// Call the deletion query.
|
707 |
-
$wpdb->query("DELETE FROM {$wpdb->prefix}statistics_useronline WHERE timestamp < '{$timediff}'");
|
708 |
}
|
709 |
}
|
4 |
This class handles; visits, visitors and pages.
|
5 |
*/
|
6 |
|
7 |
+
use BrowscapPHP\Browscap;
|
8 |
+
use WurflCache\Adapter\File;
|
9 |
use IPTools\IP;
|
10 |
use IPTools\Network;
|
11 |
use IPTools\Range;
|
15 |
// Setup our public/private/protected variables.
|
16 |
public $result = null;
|
17 |
|
18 |
+
protected $location = '000';
|
19 |
+
protected $exclusion_match = false;
|
20 |
protected $exclusion_reason = '';
|
21 |
|
22 |
private $exclusion_record = false;
|
29 |
global $wp_version, $WP_Statistics;
|
30 |
|
31 |
// Set the timestamp value.
|
32 |
+
$this->timestamp = $WP_Statistics->current_date( 'U' );
|
33 |
|
34 |
// Set the default seconds a user needs to visit the site before they are considered offline.
|
35 |
$this->second = 30;
|
36 |
|
37 |
// Get the user set value for seconds to check for users online.
|
38 |
+
if ( $WP_Statistics->get_option( 'check_online' ) ) {
|
39 |
+
$this->second = $WP_Statistics->get_option( 'check_online' );
|
40 |
}
|
41 |
|
42 |
// Check to see if the user wants us to record why we're excluding hits.
|
43 |
+
if ( $WP_Statistics->get_option( 'record_exclusions' ) ) {
|
44 |
$this->exclusion_record = true;
|
45 |
}
|
46 |
|
47 |
// Create a IP Tools instance from the current IP address for use later.
|
48 |
// Fall back to the localhost if it can't be parsed.
|
49 |
try {
|
50 |
+
$ip = new IP( $WP_Statistics->ip );
|
51 |
} catch ( Exception $e ) {
|
52 |
+
$ip = new IP( '127.0.0.1' );
|
53 |
}
|
54 |
|
55 |
// Let's check to see if our subnet matches a private IP address range, if so go ahead and set the location information now.
|
56 |
+
if ( $WP_Statistics->get_option( 'private_country_code' ) != '000' &&
|
57 |
+
$WP_Statistics->get_option( 'private_country_code' ) != ''
|
58 |
) {
|
59 |
$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' );
|
60 |
|
62 |
$contains_ip = false;
|
63 |
|
64 |
try {
|
65 |
+
$contains_ip = Range::parse( $psub )->contains( $ip );
|
66 |
} catch ( Exception $e ) {
|
67 |
$contains_ip = false;
|
68 |
}
|
69 |
|
70 |
if ( $contains_ip ) {
|
71 |
+
$this->location = $WP_Statistics->get_option( 'private_country_code' );
|
72 |
break;
|
73 |
}
|
74 |
}
|
96 |
$page_uri = wp_statistics_get_uri();
|
97 |
$ajax_string = 'admin-ajax.php';
|
98 |
|
99 |
+
if ( strpos( $page_uri, $ajax_string ) !== false ) {
|
100 |
$this->exclusion_match = true;
|
101 |
$this->exclusion_reason = 'ajax';
|
102 |
|
103 |
return;
|
104 |
}
|
105 |
|
106 |
+
if ( ( defined( 'DOING_CRON' ) && DOING_CRON === true ) || ( function_exists( 'wp_doing_cron' ) && wp_doing_cron() === true ) ) {
|
107 |
$this->exclusion_match = true;
|
108 |
$this->exclusion_reason = 'cronjob';
|
109 |
|
114 |
$crawler = false;
|
115 |
$ua_string = '';
|
116 |
|
117 |
+
if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) {
|
118 |
$ua_string = $_SERVER['HTTP_USER_AGENT'];
|
119 |
}
|
120 |
|
121 |
+
if ( $WP_Statistics->get_option( 'last_browscap_dl' ) > 1 && $WP_Statistics->get_option( 'browscap' ) ) {
|
122 |
// Get the upload directory from WordPress.
|
123 |
$upload_dir = wp_upload_dir();
|
124 |
|
125 |
+
$adapter = new File( array( File::DIR => $upload_dir['basedir'] . '/wp-statistics' ) );
|
|
|
126 |
|
127 |
// Get the Browser Capabilities use Browscap.
|
|
|
|
|
128 |
try {
|
129 |
+
$browscap = new Browscap();
|
130 |
+
$browscap->setCache($adapter);
|
131 |
+
$current_browser = $browscap->getBrowser();
|
132 |
+
|
133 |
// Make sure we got an object back and it has the Crawler property before accessing it.
|
134 |
+
if ( isset( $current_browser->Crawler ) ) {
|
135 |
$crawler = $current_browser->Crawler;
|
136 |
} else {
|
137 |
$crawler = false;
|
140 |
$crawler = false;
|
141 |
}
|
142 |
} else {
|
143 |
+
$WP_Statistics->update_option( 'update_browscap', true );
|
144 |
}
|
145 |
|
146 |
// If we're a crawler as per browscap, exclude us, otherwise double check based on the WP Statistics robot list.
|
151 |
return;
|
152 |
} else {
|
153 |
// Pull the robots from the database.
|
154 |
+
$robots = explode( "\n", $WP_Statistics->get_option( 'robotlist' ) );
|
155 |
|
156 |
// Check to see if we match any of the robots.
|
157 |
foreach ( $robots as $robot ) {
|
158 |
+
$robot = trim( $robot );
|
159 |
|
160 |
// If the match case is less than 4 characters long, it might match too much so don't execute it.
|
161 |
+
if ( strlen( $robot ) > 3 ) {
|
162 |
+
if ( stripos( $ua_string, $robot ) !== false ) {
|
163 |
$this->exclusion_match = true;
|
164 |
$this->exclusion_reason = 'robot';
|
165 |
|
169 |
}
|
170 |
|
171 |
// Finally check to see if we have corrupt header information.
|
172 |
+
if ( ! $this->exclusion_match && $WP_Statistics->get_option( 'corrupt_browser_info' ) ) {
|
173 |
if ( $ua_string == '' || $WP_Statistics->ip == '' ) {
|
174 |
$this->exclusion_match = true;
|
175 |
$this->exclusion_reason = 'robot';
|
182 |
// If we didn't match a robot, check ip subnets.
|
183 |
|
184 |
// Pull the subnets from the database.
|
185 |
+
$subnets = explode( "\n", $WP_Statistics->get_option( 'exclude_ip' ) );
|
186 |
|
187 |
// Check to see if we match any of the excluded addresses.
|
188 |
foreach ( $subnets as $subnet ) {
|
189 |
+
$subnet = trim( $subnet );
|
190 |
|
191 |
// The shortest ip address is 1.1.1.1, anything less must be a malformed entry.
|
192 |
+
if ( strlen( $subnet ) > 6 ) {
|
193 |
$range_prased = false;
|
194 |
|
195 |
try {
|
196 |
+
$range_prased = Range::parse( $subnet )->contains( $ip );
|
197 |
} catch ( Exception $e ) {
|
198 |
$range_parased = false;
|
199 |
}
|
208 |
}
|
209 |
|
210 |
// Check to see if we are being referred to ourselves.
|
211 |
+
if ( $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url( null, '/' ) ||
|
212 |
$ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url()
|
213 |
) {
|
214 |
$this->exclusion_match = true;
|
218 |
}
|
219 |
|
220 |
// Check to see if we're excluding the login page.
|
221 |
+
if ( $WP_Statistics->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 |
|
235 |
}
|
236 |
|
237 |
// Check to see if we're excluding referrer spam.
|
238 |
+
if ( $WP_Statistics->get_option( 'referrerspam' ) ) {
|
239 |
$referrer = $WP_Statistics->get_Referred();
|
240 |
|
241 |
// Pull the referrer spam list from the database.
|
242 |
+
$referrerspamlist = explode( "\n", $WP_Statistics->get_option( 'referrerspamlist' ) );
|
243 |
|
244 |
// Check to see if we match any of the robots.
|
245 |
foreach ( $referrerspamlist as $item ) {
|
246 |
+
$item = trim( $item );
|
247 |
|
248 |
// If the match case is less than 4 characters long, it might match too much so don't execute it.
|
249 |
+
if ( strlen( $item ) > 3 ) {
|
250 |
+
if ( stripos( $referrer, $item ) !== false ) {
|
251 |
$this->exclusion_match = true;
|
252 |
$this->exclusion_reason = 'referrer_spam';
|
253 |
|
258 |
}
|
259 |
|
260 |
// Check to see if we're excluding RSS feeds.
|
261 |
+
if ( $WP_Statistics->get_option( 'exclude_feeds' ) ) {
|
262 |
if ( is_feed() ) {
|
263 |
$this->exclusion_match = true;
|
264 |
$this->exclusion_reason = 'feed';
|
268 |
}
|
269 |
|
270 |
// Check to see if we're excluding 404 pages.
|
271 |
+
if ( $WP_Statistics->get_option( 'exclude_404s' ) ) {
|
272 |
if ( is_404() ) {
|
273 |
$this->exclusion_match = true;
|
274 |
$this->exclusion_reason = '404';
|
278 |
}
|
279 |
|
280 |
// Check to see if we're excluding the current page url.
|
281 |
+
if ( $WP_Statistics->get_option( 'excluded_urls' ) ) {
|
282 |
$script = $_SERVER['REQUEST_URI'];
|
283 |
+
$delimiter = strpos( $script, '?' );
|
284 |
if ( $delimiter > 0 ) {
|
285 |
+
$script = substr( $script, 0, $delimiter );
|
286 |
}
|
287 |
|
288 |
+
$excluded_urls = explode( "\n", $WP_Statistics->get_option( 'excluded_urls' ) );
|
289 |
|
290 |
foreach ( $excluded_urls as $url ) {
|
291 |
+
$this_url = trim( $url );
|
292 |
|
293 |
+
if ( strlen( $this_url ) > 2 ) {
|
294 |
+
if ( stripos( $script, $this_url ) === 0 ) {
|
295 |
$this->exclusion_match = true;
|
296 |
$this->exclusion_reason = 'excluded url';
|
297 |
|
306 |
$current_user = wp_get_current_user();
|
307 |
|
308 |
foreach ( $current_user->roles as $role ) {
|
309 |
+
$option_name = 'exclude_' . str_replace( ' ', '_', strtolower( $role ) );
|
310 |
+
if ( $WP_Statistics->get_option( $option_name ) == true ) {
|
311 |
$this->exclusion_match = true;
|
312 |
$this->exclusion_reason = 'user role';
|
313 |
|
318 |
|
319 |
// Check to see if we are excluded by the host name.
|
320 |
if ( ! $this->exclusion_match ) {
|
321 |
+
$excluded_host = explode( "\n", $WP_Statistics->get_option( 'excluded_hosts' ) );
|
322 |
|
323 |
// If there's nothing in the excluded host list, don't do anything.
|
324 |
+
if ( count( $excluded_host ) > 0 ) {
|
325 |
$transient_name = 'wps_excluded_hostname_to_ip_cache';
|
326 |
|
327 |
// Get the transient with the hostname cache.
|
328 |
+
$hostname_cache = get_transient( $transient_name );
|
329 |
|
330 |
// If the transient has expired (or has never been set), create one now.
|
331 |
if ( $hostname_cache === false ) {
|
334 |
|
335 |
// Loop through the list of hosts and look them up.
|
336 |
foreach ( $excluded_host as $host ) {
|
337 |
+
if ( strpos( $host, '.' ) > 0 ) {
|
338 |
// 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.
|
339 |
+
$hostname_cache[ $host ] = gethostbyname( $host . '.' );
|
340 |
}
|
341 |
}
|
342 |
|
343 |
// Set the transient and store it for 1 hour.
|
344 |
+
set_transient( $transient_name, $hostname_cache, 360 );
|
345 |
}
|
346 |
|
347 |
// Check if the current IP address matches one of the ones in the excluded hosts list.
|
348 |
+
if ( in_array( $WP_Statistics->ip, $hostname_cache ) ) {
|
349 |
$this->exclusion_match = true;
|
350 |
$this->exclusion_reason = 'hostname';
|
351 |
|
368 |
);
|
369 |
|
370 |
// If we're a returning visitor, update the current record in the database, otherwise, create a new one.
|
371 |
+
if ( $this->result->last_counter != $WP_Statistics->Current_Date( 'Y-m-d' ) ) {
|
372 |
// 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
|
373 |
// for this IP address we want to do an "INSERT ... ON DUPLICATE KEY" which WordPress doesn't support.
|
374 |
$sqlstring = $wpdb->prepare(
|
377 |
'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d) ON DUPLICATE KEY UPDATE visit = visit + ' .
|
378 |
$WP_Statistics->coefficient,
|
379 |
$WP_Statistics->Current_Date(),
|
380 |
+
$WP_Statistics->Current_date( 'Y-m-d' ),
|
381 |
$WP_Statistics->coefficient
|
382 |
);
|
383 |
|
384 |
+
$wpdb->query( $sqlstring );
|
385 |
} else {
|
386 |
$sqlstring = $wpdb->prepare(
|
387 |
'UPDATE ' .
|
392 |
$this->result->last_counter
|
393 |
);
|
394 |
|
395 |
+
$wpdb->query( $sqlstring );
|
396 |
}
|
397 |
}
|
398 |
}
|
402 |
global $wpdb, $wp_query, $WP_Statistics;
|
403 |
|
404 |
// Get the pages or posts ID if it exists.
|
405 |
+
if ( is_object( $wp_query ) ) {
|
406 |
$this->current_page_id = $wp_query->get_queried_object_id();
|
407 |
}
|
408 |
|
409 |
+
if ( $WP_Statistics->get_option( 'use_honeypot' ) &&
|
410 |
+
$WP_Statistics->get_option( 'honeypot_postid' ) > 0 &&
|
411 |
+
$WP_Statistics->get_option( 'honeypot_postid' ) == $this->current_page_id &&
|
412 |
$this->current_page_id > 0
|
413 |
) {
|
414 |
$this->exclusion_match = true;
|
441 |
if ( ! $this->result ) {
|
442 |
|
443 |
// If we've been told to store the entire user agent, do so.
|
444 |
+
if ( $WP_Statistics->get_option( 'store_ua' ) == true ) {
|
445 |
$ua = $_SERVER['HTTP_USER_AGENT'];
|
446 |
} else {
|
447 |
$ua = '';
|
454 |
'INSERT IGNORE INTO ' .
|
455 |
$wpdb->prefix .
|
456 |
'statistics_visitor (last_counter, referred, agent, platform, version, ip, location, UAString, hits, honeypot) VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, 1, %s )',
|
457 |
+
$WP_Statistics->Current_date( 'Y-m-d' ),
|
458 |
$WP_Statistics->get_Referred(),
|
459 |
$WP_Statistics->agent['browser'],
|
460 |
$WP_Statistics->agent['platform'],
|
465 |
$honeypot
|
466 |
);
|
467 |
|
468 |
+
$wpdb->query( $sqlstring );
|
469 |
|
470 |
// Now parse the referrer and store the results in the search table if the database has been converted.
|
471 |
// Also make sure we actually inserted a row on the INSERT IGNORE above or we'll create duplicate entries.
|
472 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) && $wpdb->insert_id ) {
|
473 |
|
474 |
$search_engines = wp_statistics_searchengine_list();
|
475 |
$referred = $WP_Statistics->get_Referred();
|
476 |
|
477 |
// Parse the URL in to it's component parts.
|
478 |
+
$parts = parse_url( $referred );
|
479 |
|
480 |
// Loop through the SE list until we find which search engine matches.
|
481 |
foreach ( $search_engines as $key => $value ) {
|
482 |
+
$search_regex = wp_statistics_searchengine_regex( $key );
|
483 |
|
484 |
+
preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
|
485 |
|
486 |
if ( isset( $matches[1] ) ) {
|
487 |
+
$data['last_counter'] = $WP_Statistics->Current_date( 'Y-m-d' );
|
488 |
$data['engine'] = $key;
|
489 |
+
$data['words'] = $WP_Statistics->Search_Engine_QueryString( $referred );
|
490 |
$data['host'] = $parts['host'];
|
491 |
$data['visitor'] = $wpdb->insert_id;
|
492 |
|
494 |
$data['words'] = '';
|
495 |
}
|
496 |
|
497 |
+
$wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
|
498 |
}
|
499 |
}
|
500 |
}
|
501 |
} else {
|
502 |
// 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.
|
503 |
+
if ( $WP_Statistics->get_option( 'robot_threshold' ) > 0 &&
|
504 |
+
$this->result->hits + 1 > $WP_Statistics->get_option( 'robot_threshold' )
|
505 |
) {
|
506 |
$this->exclusion_match = true;
|
507 |
$this->exclusion_reason = 'robot_threshold';
|
519 |
$this->result->ID
|
520 |
);
|
521 |
|
522 |
+
$wpdb->query( $sqlstring );
|
523 |
}
|
524 |
}
|
525 |
}
|
544 |
$wpdb->insert(
|
545 |
$wpdb->prefix . 'statistics_exclusions',
|
546 |
array(
|
547 |
+
'date' => $WP_Statistics->Current_date( 'Y-m-d' ),
|
548 |
'reason' => $this->exclusion_reason,
|
549 |
'count' => 1,
|
550 |
)
|
560 |
if ( ! $this->exclusion_match ) {
|
561 |
|
562 |
// Don't track anything but actual pages and posts, unless we've been told to.
|
563 |
+
if ( $WP_Statistics->get_option( 'track_all_pages' ) || is_page() || is_single() || is_front_page() ) {
|
564 |
// Get the pages or posts ID if it exists and we haven't set it in the visitors code.
|
565 |
+
if ( ! $this->current_page_id && is_object( $wp_query ) ) {
|
566 |
$this->current_page_id = $wp_query->get_queried_object_id();
|
567 |
}
|
568 |
|
574 |
// Get the current page URI.
|
575 |
$page_uri = wp_statistics_get_uri();
|
576 |
|
577 |
+
if ( $WP_Statistics->get_option( 'strip_uri_parameters' ) ) {
|
578 |
+
$temp = explode( '?', $page_uri );
|
579 |
if ( $temp !== false ) {
|
580 |
$page_uri = $temp[0];
|
581 |
}
|
582 |
}
|
583 |
|
584 |
// Limit the URI length to 255 characters, otherwise we may overrun the SQL field size.
|
585 |
+
$page_uri = substr( $page_uri, 0, 255 );
|
586 |
|
587 |
// If we have already been to this page today (a likely scenario), just update the count on the record.
|
588 |
$sql = $wpdb->prepare(
|
589 |
"UPDATE {$wpdb->prefix}statistics_pages SET `count` = `count` + 1 WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND `uri` = %s",
|
590 |
$page_uri
|
591 |
);
|
592 |
+
$this->result = $wpdb->query( $sql );
|
593 |
|
594 |
// 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
|
595 |
// exists where two people load the same page a the roughly the same time. In that case two inserts would be attempted but
|
600 |
$wpdb->prefix . 'statistics_pages',
|
601 |
array(
|
602 |
'uri' => $page_uri,
|
603 |
+
'date' => $WP_Statistics->Current_date( 'Y-m-d' ),
|
604 |
'count' => 1,
|
605 |
'id' => $this->current_page_id,
|
606 |
)
|
634 |
public function Check_online() {
|
635 |
global $WP_Statistics;
|
636 |
// 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.
|
637 |
+
if ( ! $this->exclusion_match || $WP_Statistics->get_option( 'all_online' ) ) {
|
638 |
|
639 |
// If the current user exists in the database already,
|
640 |
// Just update them, otherwise add them
|
705 |
$timediff = $this->timestamp - $this->second;
|
706 |
|
707 |
// Call the deletion query.
|
708 |
+
$wpdb->query( "DELETE FROM {$wpdb->prefix}statistics_useronline WHERE timestamp < '{$timediff}'" );
|
709 |
}
|
710 |
}
|
includes/classes/class-wp-statistics-install.php
CHANGED
@@ -140,13 +140,13 @@ class WP_Statistics_Install {
|
|
140 |
|
141 |
if ( $result == 1 ) {
|
142 |
// Before we update the historical table, check to see if it exists with the old keys
|
143 |
-
$result = $wpdb->query("SHOW COLUMNS FROM {$wpdb->prefix}statistics_historical LIKE 'key'");
|
144 |
|
145 |
if ( $result > 0 ) {
|
146 |
$wpdb->query(
|
147 |
"ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `id` `page_id` bigint(20)"
|
148 |
);
|
149 |
-
$wpdb->query("ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `key` `ID` bigint(20)");
|
150 |
$wpdb->query(
|
151 |
"ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `type` `category` varchar(25)"
|
152 |
);
|
@@ -154,18 +154,18 @@ class WP_Statistics_Install {
|
|
154 |
}
|
155 |
|
156 |
// This includes the dbDelta function from WordPress.
|
157 |
-
if ( ! function_exists('dbDelta') ) {
|
158 |
require( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
159 |
}
|
160 |
|
161 |
// Create/update the plugin tables.
|
162 |
-
dbDelta($create_useronline_table);
|
163 |
-
dbDelta($create_visit_table);
|
164 |
-
dbDelta($create_visitor_table);
|
165 |
-
dbDelta($create_exclusion_table);
|
166 |
-
dbDelta($create_pages_table);
|
167 |
-
dbDelta($create_historical_table);
|
168 |
-
dbDelta($create_search_table);
|
169 |
|
170 |
// Some old versions (in the 5.0.x line) of MySQL have issue with the compound index on the visitor table
|
171 |
// so let's make sure it was created, if not, use the older format to create the table manually instead of
|
@@ -175,27 +175,27 @@ class WP_Statistics_Install {
|
|
175 |
);
|
176 |
|
177 |
if ( $result != 1 ) {
|
178 |
-
$wpdb->query($create_visitor_table_old);
|
179 |
}
|
180 |
|
181 |
// Check to see if the date_ip index still exists, if so get rid of it.
|
182 |
-
$result = $wpdb->query("SHOW INDEX FROM {$wpdb->prefix}statistics_visitor WHERE Key_name = 'date_ip'");
|
183 |
|
184 |
// Note, the result will be the number of fields contained in the index.
|
185 |
if ( $result > 1 ) {
|
186 |
-
$wpdb->query("DROP INDEX `date_ip` ON {$wpdb->prefix}statistics_visitor");
|
187 |
}
|
188 |
|
189 |
// One final database change, drop the 'AString' column from visitors if it exists as it's a typo from an old version.
|
190 |
-
$result = $wpdb->query("SHOW COLUMNS FROM {$wpdb->prefix}statistics_visitor LIKE 'AString'");
|
191 |
|
192 |
if ( $result > 0 ) {
|
193 |
-
$wpdb->query("ALTER TABLE `{$wpdb->prefix}statistics_visitor` DROP `AString`");
|
194 |
}
|
195 |
|
196 |
// Store the new version information.
|
197 |
-
update_option('wp_statistics_plugin_version', WP_Statistics::$reg['version']);
|
198 |
-
update_option('wp_statistics_db_version', WP_Statistics::$reg['version']);
|
199 |
|
200 |
// Now check to see what database updates may be required and record them for a user notice later.
|
201 |
$dbupdates = array( 'date_ip_agent' => false, 'unique_date' => false );
|
@@ -220,7 +220,7 @@ class WP_Statistics_Install {
|
|
220 |
$dbupdates['unique_date'] = true;
|
221 |
}
|
222 |
|
223 |
-
$WP_Statistics->update_option('pending_db_updates', $dbupdates);
|
224 |
|
225 |
$default_options = $WP_Statistics->Default_Options();
|
226 |
|
@@ -231,14 +231,14 @@ class WP_Statistics_Install {
|
|
231 |
$WP_Statistics->Primary_Values();
|
232 |
|
233 |
// By default, on new installs, use the new search table.
|
234 |
-
$WP_Statistics->update_option('search_converted', 1);
|
235 |
|
236 |
} else {
|
237 |
|
238 |
// If this is an upgrade, we need to check to see if we need to convert anything from old to new formats.
|
239 |
|
240 |
// Check to see if the "new" settings code is in place or not, if not, upgrade the old settings to the new system.
|
241 |
-
if ( get_option('wp_statistics') === false ) {
|
242 |
$core_options = array(
|
243 |
'wps_disable_map',
|
244 |
'wps_map_location',
|
@@ -303,23 +303,23 @@ class WP_Statistics_Install {
|
|
303 |
|
304 |
// Handle the core options, we're going to strip off the 'wps_' header as we store them in the new settings array.
|
305 |
foreach ( $core_options as $option ) {
|
306 |
-
$new_name = substr($option, 4);
|
307 |
|
308 |
-
$WP_Statistics->store_option($new_name, get_option($option));
|
309 |
|
310 |
-
delete_option($option);
|
311 |
}
|
312 |
|
313 |
$widget = array();
|
314 |
|
315 |
// Handle the widget options, we're going to store them in a sub-array.
|
316 |
foreach ( $widget_options as $option ) {
|
317 |
-
$widget[ $option ] = get_option($option);
|
318 |
|
319 |
-
delete_option($option);
|
320 |
}
|
321 |
|
322 |
-
$WP_Statistics->store_option('widget', $widget);
|
323 |
|
324 |
foreach ( $var_options as $option ) {
|
325 |
// Handle the special variables options.
|
@@ -328,11 +328,11 @@ class WP_Statistics_Install {
|
|
328 |
);
|
329 |
|
330 |
foreach ( $result as $opt ) {
|
331 |
-
$new_name = substr($opt->option_name, 4);
|
332 |
|
333 |
-
$WP_Statistics->store_option($new_name, $opt->option_value);
|
334 |
|
335 |
-
delete_option($opt->option_name);
|
336 |
}
|
337 |
}
|
338 |
|
@@ -340,10 +340,10 @@ class WP_Statistics_Install {
|
|
340 |
}
|
341 |
|
342 |
// If the robot list is empty, fill in the defaults.
|
343 |
-
$wps_temp_robotslist = $WP_Statistics->get_option('robotlist');
|
344 |
|
345 |
-
if ( trim($wps_temp_robotslist) == "" || $WP_Statistics->get_option('force_robot_update') == true ) {
|
346 |
-
$WP_Statistics->update_option('robotlist', $default_options['robotlist']);
|
347 |
}
|
348 |
|
349 |
// WP Statistics V4.2 and below automatically exclude the administrator for statistics collection
|
@@ -351,25 +351,25 @@ class WP_Statistics_Install {
|
|
351 |
// 4.2 behaviour when we upgrade, so see if the option exists in the database and if not, set it.
|
352 |
// This will not work correctly on a WordPress install that has removed the administrator role.
|
353 |
// However that seems VERY unlikely.
|
354 |
-
$exclude_admins = $WP_Statistics->get_option('exclude_administrator', '2');
|
355 |
if ( $exclude_admins == '2' ) {
|
356 |
-
$WP_Statistics->update_option('exclude_administrator', '1');
|
357 |
}
|
358 |
|
359 |
// WordPress 4.3 broke the diplay of the sidebar widget because it no longer accepted a null value
|
360 |
// to be returned from the widget update function, let's look to see if we need to update any
|
361 |
// occurances in the options table.
|
362 |
-
$widget_options = get_option('widget_wpstatistics_widget');
|
363 |
-
if ( is_array($widget_options) ) {
|
364 |
foreach ( $widget_options as $key => $value ) {
|
365 |
// We want to update all null array keys that are integers.
|
366 |
-
if ( $value === null && is_int($key) ) {
|
367 |
$widget_options[ $key ] = array();
|
368 |
}
|
369 |
}
|
370 |
|
371 |
// Store the widget options back to the database.
|
372 |
-
update_option('widget_wpstatistics_widget', $widget_options);
|
373 |
}
|
374 |
}
|
375 |
|
@@ -378,21 +378,21 @@ class WP_Statistics_Install {
|
|
378 |
|
379 |
// If this is a first time install or an upgrade and we've added options, set some intelligent defaults.
|
380 |
foreach ( $default_options as $key => $value ) {
|
381 |
-
if ( ! in_array($key, $excluded_defaults) && false === $WP_Statistics->get_option($key) ) {
|
382 |
-
$WP_Statistics->store_option($key, $value);
|
383 |
}
|
384 |
}
|
385 |
|
386 |
if ( WP_Statistics::$installed_version == false ) {
|
387 |
// We now need to set the robot list to update during the next release. This is only done for new installs to ensure we don't overwrite existing custom robot lists.
|
388 |
-
$WP_Statistics->store_option('force_robot_update', true);
|
389 |
}
|
390 |
|
391 |
// For version 8.0, we're removing the old %option% types from the reports, so let's upgrade anyone who still has them to short codes.
|
392 |
-
$report_content = $WP_Statistics->get_option('content_report');
|
393 |
|
394 |
// Check to make sure we have a report to process.
|
395 |
-
if ( trim($report_content) == '' ) {
|
396 |
// These are the variables we can replace in the template and the short codes we're going to replace them with.
|
397 |
$template_vars = array(
|
398 |
'user_online' => '[wpstatistics stat=usersonline]',
|
@@ -414,14 +414,14 @@ class WP_Statistics_Install {
|
|
414 |
);
|
415 |
|
416 |
// Store the updated report content.
|
417 |
-
$WP_Statistics->store_option('content_report', $final_report);
|
418 |
}
|
419 |
|
420 |
// Save the settings now that we've set them.
|
421 |
$WP_Statistics->save_options();
|
422 |
|
423 |
-
if ( $WP_Statistics->get_option('upgrade_report') == true ) {
|
424 |
-
$WP_Statistics->update_option('send_upgrade_email', true);
|
425 |
}
|
426 |
|
427 |
// Handle multi site implementations
|
@@ -436,11 +436,11 @@ class WP_Statistics_Install {
|
|
436 |
if ( $blog_id != $current_blog ) {
|
437 |
|
438 |
// Get the admin url for the current site.
|
439 |
-
$url = get_admin_url($blog_id);
|
440 |
|
441 |
// Go and visit the admin url of the site, this will rerun the install script for each site.
|
442 |
// We turn blocking off because we don't really care about the response so why wait for it.
|
443 |
-
wp_remote_request($url, array( 'blocking' => false ));
|
444 |
}
|
445 |
}
|
446 |
}
|
140 |
|
141 |
if ( $result == 1 ) {
|
142 |
// Before we update the historical table, check to see if it exists with the old keys
|
143 |
+
$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_historical LIKE 'key'" );
|
144 |
|
145 |
if ( $result > 0 ) {
|
146 |
$wpdb->query(
|
147 |
"ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `id` `page_id` bigint(20)"
|
148 |
);
|
149 |
+
$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `key` `ID` bigint(20)" );
|
150 |
$wpdb->query(
|
151 |
"ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `type` `category` varchar(25)"
|
152 |
);
|
154 |
}
|
155 |
|
156 |
// This includes the dbDelta function from WordPress.
|
157 |
+
if ( ! function_exists( 'dbDelta' ) ) {
|
158 |
require( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
159 |
}
|
160 |
|
161 |
// Create/update the plugin tables.
|
162 |
+
dbDelta( $create_useronline_table );
|
163 |
+
dbDelta( $create_visit_table );
|
164 |
+
dbDelta( $create_visitor_table );
|
165 |
+
dbDelta( $create_exclusion_table );
|
166 |
+
dbDelta( $create_pages_table );
|
167 |
+
dbDelta( $create_historical_table );
|
168 |
+
dbDelta( $create_search_table );
|
169 |
|
170 |
// Some old versions (in the 5.0.x line) of MySQL have issue with the compound index on the visitor table
|
171 |
// so let's make sure it was created, if not, use the older format to create the table manually instead of
|
175 |
);
|
176 |
|
177 |
if ( $result != 1 ) {
|
178 |
+
$wpdb->query( $create_visitor_table_old );
|
179 |
}
|
180 |
|
181 |
// Check to see if the date_ip index still exists, if so get rid of it.
|
182 |
+
$result = $wpdb->query( "SHOW INDEX FROM {$wpdb->prefix}statistics_visitor WHERE Key_name = 'date_ip'" );
|
183 |
|
184 |
// Note, the result will be the number of fields contained in the index.
|
185 |
if ( $result > 1 ) {
|
186 |
+
$wpdb->query( "DROP INDEX `date_ip` ON {$wpdb->prefix}statistics_visitor" );
|
187 |
}
|
188 |
|
189 |
// One final database change, drop the 'AString' column from visitors if it exists as it's a typo from an old version.
|
190 |
+
$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_visitor LIKE 'AString'" );
|
191 |
|
192 |
if ( $result > 0 ) {
|
193 |
+
$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_visitor` DROP `AString`" );
|
194 |
}
|
195 |
|
196 |
// Store the new version information.
|
197 |
+
update_option( 'wp_statistics_plugin_version', WP_Statistics::$reg['version'] );
|
198 |
+
update_option( 'wp_statistics_db_version', WP_Statistics::$reg['version'] );
|
199 |
|
200 |
// Now check to see what database updates may be required and record them for a user notice later.
|
201 |
$dbupdates = array( 'date_ip_agent' => false, 'unique_date' => false );
|
220 |
$dbupdates['unique_date'] = true;
|
221 |
}
|
222 |
|
223 |
+
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
224 |
|
225 |
$default_options = $WP_Statistics->Default_Options();
|
226 |
|
231 |
$WP_Statistics->Primary_Values();
|
232 |
|
233 |
// By default, on new installs, use the new search table.
|
234 |
+
$WP_Statistics->update_option( 'search_converted', 1 );
|
235 |
|
236 |
} else {
|
237 |
|
238 |
// If this is an upgrade, we need to check to see if we need to convert anything from old to new formats.
|
239 |
|
240 |
// Check to see if the "new" settings code is in place or not, if not, upgrade the old settings to the new system.
|
241 |
+
if ( get_option( 'wp_statistics' ) === false ) {
|
242 |
$core_options = array(
|
243 |
'wps_disable_map',
|
244 |
'wps_map_location',
|
303 |
|
304 |
// Handle the core options, we're going to strip off the 'wps_' header as we store them in the new settings array.
|
305 |
foreach ( $core_options as $option ) {
|
306 |
+
$new_name = substr( $option, 4 );
|
307 |
|
308 |
+
$WP_Statistics->store_option( $new_name, get_option( $option ) );
|
309 |
|
310 |
+
delete_option( $option );
|
311 |
}
|
312 |
|
313 |
$widget = array();
|
314 |
|
315 |
// Handle the widget options, we're going to store them in a sub-array.
|
316 |
foreach ( $widget_options as $option ) {
|
317 |
+
$widget[ $option ] = get_option( $option );
|
318 |
|
319 |
+
delete_option( $option );
|
320 |
}
|
321 |
|
322 |
+
$WP_Statistics->store_option( 'widget', $widget );
|
323 |
|
324 |
foreach ( $var_options as $option ) {
|
325 |
// Handle the special variables options.
|
328 |
);
|
329 |
|
330 |
foreach ( $result as $opt ) {
|
331 |
+
$new_name = substr( $opt->option_name, 4 );
|
332 |
|
333 |
+
$WP_Statistics->store_option( $new_name, $opt->option_value );
|
334 |
|
335 |
+
delete_option( $opt->option_name );
|
336 |
}
|
337 |
}
|
338 |
|
340 |
}
|
341 |
|
342 |
// If the robot list is empty, fill in the defaults.
|
343 |
+
$wps_temp_robotslist = $WP_Statistics->get_option( 'robotlist' );
|
344 |
|
345 |
+
if ( trim( $wps_temp_robotslist ) == "" || $WP_Statistics->get_option( 'force_robot_update' ) == true ) {
|
346 |
+
$WP_Statistics->update_option( 'robotlist', $default_options['robotlist'] );
|
347 |
}
|
348 |
|
349 |
// WP Statistics V4.2 and below automatically exclude the administrator for statistics collection
|
351 |
// 4.2 behaviour when we upgrade, so see if the option exists in the database and if not, set it.
|
352 |
// This will not work correctly on a WordPress install that has removed the administrator role.
|
353 |
// However that seems VERY unlikely.
|
354 |
+
$exclude_admins = $WP_Statistics->get_option( 'exclude_administrator', '2' );
|
355 |
if ( $exclude_admins == '2' ) {
|
356 |
+
$WP_Statistics->update_option( 'exclude_administrator', '1' );
|
357 |
}
|
358 |
|
359 |
// WordPress 4.3 broke the diplay of the sidebar widget because it no longer accepted a null value
|
360 |
// to be returned from the widget update function, let's look to see if we need to update any
|
361 |
// occurances in the options table.
|
362 |
+
$widget_options = get_option( 'widget_wpstatistics_widget' );
|
363 |
+
if ( is_array( $widget_options ) ) {
|
364 |
foreach ( $widget_options as $key => $value ) {
|
365 |
// We want to update all null array keys that are integers.
|
366 |
+
if ( $value === null && is_int( $key ) ) {
|
367 |
$widget_options[ $key ] = array();
|
368 |
}
|
369 |
}
|
370 |
|
371 |
// Store the widget options back to the database.
|
372 |
+
update_option( 'widget_wpstatistics_widget', $widget_options );
|
373 |
}
|
374 |
}
|
375 |
|
378 |
|
379 |
// If this is a first time install or an upgrade and we've added options, set some intelligent defaults.
|
380 |
foreach ( $default_options as $key => $value ) {
|
381 |
+
if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) {
|
382 |
+
$WP_Statistics->store_option( $key, $value );
|
383 |
}
|
384 |
}
|
385 |
|
386 |
if ( WP_Statistics::$installed_version == false ) {
|
387 |
// We now need to set the robot list to update during the next release. This is only done for new installs to ensure we don't overwrite existing custom robot lists.
|
388 |
+
$WP_Statistics->store_option( 'force_robot_update', true );
|
389 |
}
|
390 |
|
391 |
// For version 8.0, we're removing the old %option% types from the reports, so let's upgrade anyone who still has them to short codes.
|
392 |
+
$report_content = $WP_Statistics->get_option( 'content_report' );
|
393 |
|
394 |
// Check to make sure we have a report to process.
|
395 |
+
if ( trim( $report_content ) == '' ) {
|
396 |
// These are the variables we can replace in the template and the short codes we're going to replace them with.
|
397 |
$template_vars = array(
|
398 |
'user_online' => '[wpstatistics stat=usersonline]',
|
414 |
);
|
415 |
|
416 |
// Store the updated report content.
|
417 |
+
$WP_Statistics->store_option( 'content_report', $final_report );
|
418 |
}
|
419 |
|
420 |
// Save the settings now that we've set them.
|
421 |
$WP_Statistics->save_options();
|
422 |
|
423 |
+
if ( $WP_Statistics->get_option( 'upgrade_report' ) == true ) {
|
424 |
+
$WP_Statistics->update_option( 'send_upgrade_email', true );
|
425 |
}
|
426 |
|
427 |
// Handle multi site implementations
|
436 |
if ( $blog_id != $current_blog ) {
|
437 |
|
438 |
// Get the admin url for the current site.
|
439 |
+
$url = get_admin_url( $blog_id );
|
440 |
|
441 |
// Go and visit the admin url of the site, this will rerun the install script for each site.
|
442 |
// We turn blocking off because we don't really care about the response so why wait for it.
|
443 |
+
wp_remote_request( $url, array( 'blocking' => false ) );
|
444 |
}
|
445 |
}
|
446 |
}
|
includes/classes/class-wp-statistics-network-admin.php
CHANGED
@@ -13,16 +13,16 @@ class WP_Statistics_Network_Admin {
|
|
13 |
|
14 |
// Get the read/write capabilities required to view/manage the plugin as set by the user.
|
15 |
$read_cap = wp_statistics_validate_capability(
|
16 |
-
$WP_Statistics->get_option('read_capability', 'manage_options')
|
17 |
);
|
18 |
$manage_cap = wp_statistics_validate_capability(
|
19 |
-
$WP_Statistics->get_option('manage_capability', 'manage_options')
|
20 |
);
|
21 |
|
22 |
// Add the top level menu.
|
23 |
add_menu_page(
|
24 |
-
__('Statistics', 'wp-statistics'),
|
25 |
-
__('Statistics', 'wp-statistics'),
|
26 |
$read_cap,
|
27 |
WP_Statistics::$reg['main-file'],
|
28 |
'WP_Statistics_Network_Admin::overview',
|
@@ -32,8 +32,8 @@ class WP_Statistics_Network_Admin {
|
|
32 |
// Add the sub items.
|
33 |
add_submenu_page(
|
34 |
WP_Statistics::$reg['main-file'],
|
35 |
-
__('Overview', 'wp-statistics'),
|
36 |
-
__('Overview', 'wp-statistics'),
|
37 |
$read_cap,
|
38 |
WP_Statistics::$reg['main-file'],
|
39 |
'WP_Statistics_Network_Admin::overview'
|
@@ -43,7 +43,7 @@ class WP_Statistics_Network_Admin {
|
|
43 |
$sites = $WP_Statistics->get_wp_sites_list();
|
44 |
|
45 |
foreach ( $sites as $blog_id ) {
|
46 |
-
$details = get_blog_details($blog_id);
|
47 |
add_submenu_page(
|
48 |
WP_Statistics::$reg['main-file'],
|
49 |
$details->blogname,
|
@@ -53,7 +53,7 @@ class WP_Statistics_Network_Admin {
|
|
53 |
'WP_Statistics_Network_Admin::goto_blog'
|
54 |
);
|
55 |
|
56 |
-
$count++;
|
57 |
if ( $count > 15 ) {
|
58 |
break;
|
59 |
}
|
@@ -66,44 +66,44 @@ class WP_Statistics_Network_Admin {
|
|
66 |
static function overview() {
|
67 |
global $WP_Statistics;
|
68 |
?>
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
<?php
|
82 |
$i = 0;
|
83 |
|
84 |
$options = array(
|
85 |
-
__('Overview', 'wp-statistics') => WP_Statistics::$page['overview'],
|
86 |
-
__('Hits', 'wp-statistics') => WP_Statistics::$page['hits'],
|
87 |
-
__('Online', 'wp-statistics') => WP_Statistics::$page['online'],
|
88 |
-
__('Referrers', 'wp-statistics') => WP_Statistics::$page['referrers'],
|
89 |
-
__('Search Words', 'wp-statistics') => WP_Statistics::$page['words'],
|
90 |
-
__('Searched Phrases', 'wp-statistics') => WP_Statistics::$page['searched-phrases'],
|
91 |
-
__('Searches', 'wp-statistics') => WP_Statistics::$page['searches'],
|
92 |
-
__('Pages', 'wp-statistics') => WP_Statistics::$page['pages'],
|
93 |
-
__('Visitors', 'wp-statistics') => WP_Statistics::$page['visitors'],
|
94 |
-
__('Countries', 'wp-statistics') => WP_Statistics::$page['countries'],
|
95 |
-
__('Browsers', 'wp-statistics') => WP_Statistics::$page['browser'],
|
96 |
-
__('Top Visitors Today', 'wp-statistics') => WP_Statistics::$page['top-visitors'],
|
97 |
-
__('Exclusions', 'wp-statistics') => WP_Statistics::$page['exclusions'],
|
98 |
-
__('Optimization', 'wp-statistics') => WP_Statistics::$page['optimization'],
|
99 |
-
__('Settings', 'wp-statistics') => WP_Statistics::$page['settings'],
|
100 |
);
|
101 |
|
102 |
$sites = $WP_Statistics->get_wp_sites_list();
|
103 |
|
104 |
foreach ( $sites as $blog_id ) {
|
105 |
-
$details = get_blog_details($blog_id);
|
106 |
-
$url = get_admin_url($blog_id, '/') . 'admin.php?page=';
|
107 |
$alternate = '';
|
108 |
|
109 |
if ( $i % 2 == 0 ) {
|
@@ -111,32 +111,32 @@ class WP_Statistics_Network_Admin {
|
|
111 |
}
|
112 |
?>
|
113 |
|
114 |
-
|
115 |
-
|
116 |
<?php echo $details->blogname; ?>
|
117 |
-
|
118 |
-
|
119 |
<?php
|
120 |
-
$options_len = count($options);
|
121 |
$j = 0;
|
122 |
|
123 |
foreach ( $options as $key => $value ) {
|
124 |
echo '<a href="' . $url . $value . '">' . $key . '</a>';
|
125 |
-
$j++;
|
126 |
if ( $j < $options_len ) {
|
127 |
echo ' - ';
|
128 |
}
|
129 |
}
|
130 |
?>
|
131 |
-
|
132 |
-
|
133 |
<?php
|
134 |
-
$i++;
|
135 |
}
|
136 |
?>
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
<?php
|
141 |
}
|
142 |
|
@@ -146,12 +146,12 @@ class WP_Statistics_Network_Admin {
|
|
146 |
static function goto_blog() {
|
147 |
global $plugin_page;
|
148 |
|
149 |
-
$blog_id = str_replace('wp_statistics_blogid_', '', $plugin_page);
|
150 |
|
151 |
-
$details = get_blog_details($blog_id);
|
152 |
|
153 |
// Get the admin url for the current site.
|
154 |
-
$url = get_admin_url($blog_id) . '/admin.php?page=' . WP_Statistics::$page['overview'];
|
155 |
|
156 |
echo "<script>window.location.href = '$url';</script>";
|
157 |
}
|
13 |
|
14 |
// Get the read/write capabilities required to view/manage the plugin as set by the user.
|
15 |
$read_cap = wp_statistics_validate_capability(
|
16 |
+
$WP_Statistics->get_option( 'read_capability', 'manage_options' )
|
17 |
);
|
18 |
$manage_cap = wp_statistics_validate_capability(
|
19 |
+
$WP_Statistics->get_option( 'manage_capability', 'manage_options' )
|
20 |
);
|
21 |
|
22 |
// Add the top level menu.
|
23 |
add_menu_page(
|
24 |
+
__( 'Statistics', 'wp-statistics' ),
|
25 |
+
__( 'Statistics', 'wp-statistics' ),
|
26 |
$read_cap,
|
27 |
WP_Statistics::$reg['main-file'],
|
28 |
'WP_Statistics_Network_Admin::overview',
|
32 |
// Add the sub items.
|
33 |
add_submenu_page(
|
34 |
WP_Statistics::$reg['main-file'],
|
35 |
+
__( 'Overview', 'wp-statistics' ),
|
36 |
+
__( 'Overview', 'wp-statistics' ),
|
37 |
$read_cap,
|
38 |
WP_Statistics::$reg['main-file'],
|
39 |
'WP_Statistics_Network_Admin::overview'
|
43 |
$sites = $WP_Statistics->get_wp_sites_list();
|
44 |
|
45 |
foreach ( $sites as $blog_id ) {
|
46 |
+
$details = get_blog_details( $blog_id );
|
47 |
add_submenu_page(
|
48 |
WP_Statistics::$reg['main-file'],
|
49 |
$details->blogname,
|
53 |
'WP_Statistics_Network_Admin::goto_blog'
|
54 |
);
|
55 |
|
56 |
+
$count ++;
|
57 |
if ( $count > 15 ) {
|
58 |
break;
|
59 |
}
|
66 |
static function overview() {
|
67 |
global $WP_Statistics;
|
68 |
?>
|
69 |
+
<div id="wrap">
|
70 |
+
<br/>
|
71 |
+
|
72 |
+
<table class="widefat wp-list-table" style="width: auto;">
|
73 |
+
<thead>
|
74 |
+
<tr>
|
75 |
+
<th style='text-align: left'><?php _e( 'Site', 'wp-statistics' ); ?></th>
|
76 |
+
<th style='text-align: left'><?php _e( 'Options', 'wp-statistics' ); ?></th>
|
77 |
+
</tr>
|
78 |
+
</thead>
|
79 |
+
|
80 |
+
<tbody>
|
81 |
<?php
|
82 |
$i = 0;
|
83 |
|
84 |
$options = array(
|
85 |
+
__( 'Overview', 'wp-statistics' ) => WP_Statistics::$page['overview'],
|
86 |
+
__( 'Hits', 'wp-statistics' ) => WP_Statistics::$page['hits'],
|
87 |
+
__( 'Online', 'wp-statistics' ) => WP_Statistics::$page['online'],
|
88 |
+
__( 'Referrers', 'wp-statistics' ) => WP_Statistics::$page['referrers'],
|
89 |
+
__( 'Search Words', 'wp-statistics' ) => WP_Statistics::$page['words'],
|
90 |
+
__( 'Searched Phrases', 'wp-statistics' ) => WP_Statistics::$page['searched-phrases'],
|
91 |
+
__( 'Searches', 'wp-statistics' ) => WP_Statistics::$page['searches'],
|
92 |
+
__( 'Pages', 'wp-statistics' ) => WP_Statistics::$page['pages'],
|
93 |
+
__( 'Visitors', 'wp-statistics' ) => WP_Statistics::$page['visitors'],
|
94 |
+
__( 'Countries', 'wp-statistics' ) => WP_Statistics::$page['countries'],
|
95 |
+
__( 'Browsers', 'wp-statistics' ) => WP_Statistics::$page['browser'],
|
96 |
+
__( 'Top Visitors Today', 'wp-statistics' ) => WP_Statistics::$page['top-visitors'],
|
97 |
+
__( 'Exclusions', 'wp-statistics' ) => WP_Statistics::$page['exclusions'],
|
98 |
+
__( 'Optimization', 'wp-statistics' ) => WP_Statistics::$page['optimization'],
|
99 |
+
__( 'Settings', 'wp-statistics' ) => WP_Statistics::$page['settings'],
|
100 |
);
|
101 |
|
102 |
$sites = $WP_Statistics->get_wp_sites_list();
|
103 |
|
104 |
foreach ( $sites as $blog_id ) {
|
105 |
+
$details = get_blog_details( $blog_id );
|
106 |
+
$url = get_admin_url( $blog_id, '/' ) . 'admin.php?page=';
|
107 |
$alternate = '';
|
108 |
|
109 |
if ( $i % 2 == 0 ) {
|
111 |
}
|
112 |
?>
|
113 |
|
114 |
+
<tr<?php echo $alternate; ?>>
|
115 |
+
<td style='text-align: left'>
|
116 |
<?php echo $details->blogname; ?>
|
117 |
+
</td>
|
118 |
+
<td style='text-align: left'>
|
119 |
<?php
|
120 |
+
$options_len = count( $options );
|
121 |
$j = 0;
|
122 |
|
123 |
foreach ( $options as $key => $value ) {
|
124 |
echo '<a href="' . $url . $value . '">' . $key . '</a>';
|
125 |
+
$j ++;
|
126 |
if ( $j < $options_len ) {
|
127 |
echo ' - ';
|
128 |
}
|
129 |
}
|
130 |
?>
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
<?php
|
134 |
+
$i ++;
|
135 |
}
|
136 |
?>
|
137 |
+
</tbody>
|
138 |
+
</table>
|
139 |
+
</div>
|
140 |
<?php
|
141 |
}
|
142 |
|
146 |
static function goto_blog() {
|
147 |
global $plugin_page;
|
148 |
|
149 |
+
$blog_id = str_replace( 'wp_statistics_blogid_', '', $plugin_page );
|
150 |
|
151 |
+
$details = get_blog_details( $blog_id );
|
152 |
|
153 |
// Get the admin url for the current site.
|
154 |
+
$url = get_admin_url( $blog_id ) . '/admin.php?page=' . WP_Statistics::$page['overview'];
|
155 |
|
156 |
echo "<script>window.location.href = '$url';</script>";
|
157 |
}
|
includes/classes/class-wp-statistics-pagination.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
*
|
18 |
******************************************************************************************/
|
19 |
|
20 |
-
if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class definitions
|
21 |
|
22 |
class WP_Statistics_Pagination {
|
23 |
/*******************************************************
|
@@ -26,19 +26,19 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
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
|
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
|
36 |
private $_pagesPerSection = null; // Total number of pages displayed per section (supplied by admin)
|
37 |
-
private $_entriesPerPage
|
38 |
-
private $_currentPage
|
39 |
-
private $_displayOptions
|
40 |
-
private $_errors
|
41 |
-
private $_styles
|
42 |
|
43 |
|
44 |
/*******************************************************
|
@@ -55,10 +55,10 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
55 |
$styleErrors = "",
|
56 |
$styleSelect = ""
|
57 |
) {
|
58 |
-
$this->setPaginationID($paginationID); // Set ID name of pagination object
|
59 |
-
$this->setTotalEntries($totalEntries); // Set total entries
|
60 |
-
$this->setPagesPerSection($pagesPerSection); // Set pages per section
|
61 |
-
$this->setDisplayOptions($options); // Set viewing display options
|
62 |
$this->setEntriesPerPage(); // Set entries per page (input from POST or cookies)
|
63 |
$this->setCurrentPage(); // Set current page (input from GET)
|
64 |
// ! This function must follow after setEntriesPerPage()
|
@@ -82,7 +82,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
82 |
if ( isset( $_COOKIE[ $cookieVar ] ) ) // If cookie is set
|
83 |
{
|
84 |
$_COOKIE[ $cookieVar ] = ""; // Clear cookie
|
85 |
-
setcookie($cookieVar, "", time() - 3600, "/"); // Delete cookie
|
86 |
}
|
87 |
}
|
88 |
|
@@ -96,7 +96,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
96 |
unset($getVars["foo"], $getVars["bar"], ... ); // Remove any so they do not appear in URL
|
97 |
*/
|
98 |
|
99 |
-
$output = '?' . http_build_query(array_merge($getVars, array( $this->_getIDGETVarName() => $input )));
|
100 |
$output .= '#' . $this->getPaginationID(); // Add #xxx at the end of URL for auto-scrolling
|
101 |
|
102 |
return $output;
|
@@ -134,11 +134,10 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
134 |
|
135 |
private function _validEntry( $input ) // determines if input is valid
|
136 |
{
|
137 |
-
if ( is_array($input) ) // If array
|
138 |
{
|
139 |
-
foreach ( $input as $element )
|
140 |
-
|
141 |
-
if ( ! $this->_validEntry($element) ) // If invalid
|
142 |
{
|
143 |
return false;
|
144 |
}
|
@@ -147,8 +146,8 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
147 |
return true; // If function makes it to this point, it is valid
|
148 |
} else // If not array
|
149 |
{
|
150 |
-
if ( ( preg_match("/^\d+$/", $input) && $input > 0 ) ||
|
151 |
-
strtolower($input) == "all"
|
152 |
) // If positive digit or "all"
|
153 |
{
|
154 |
return true;
|
@@ -167,19 +166,19 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
167 |
switch ( $end ) {
|
168 |
case 1:
|
169 |
$title = "First page";
|
170 |
-
|
171 |
case 2:
|
172 |
$title = "Previous page";
|
173 |
-
|
174 |
case 3:
|
175 |
$title = "Next page";
|
176 |
-
|
177 |
case 4:
|
178 |
$title = "Last page (" . $this->getTotalPages() . ")";
|
179 |
-
|
180 |
default:
|
181 |
$title = "";
|
182 |
-
|
183 |
}
|
184 |
|
185 |
$title = ( $end > 0 && $title != "" ) ? 'title="' . $title . '"' : '';
|
@@ -199,7 +198,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
199 |
) // and destination page is not less than first page
|
200 |
{
|
201 |
$text = '<a href="' .
|
202 |
-
$this->_getURL($destinationPage) .
|
203 |
'">' .
|
204 |
$text .
|
205 |
'</a>'; // then make $text a link
|
@@ -264,15 +263,15 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
264 |
$pagesPerSection +
|
265 |
1; // Adjust section start to # of pages behind section end
|
266 |
|
267 |
-
$output = $this->_navBox("<<", $firstPage, 1); // First page
|
268 |
-
$output .= $this->_navBox("<", $previousPage, 2); // Previous page
|
269 |
|
270 |
-
for ( $i = $sectionStart; $i <= $sectionEnd;
|
271 |
-
$output .= $this->_navBox($i, $i);
|
272 |
} // Pagination
|
273 |
|
274 |
-
$output .= $this->_navBox(">", $nextPage, 3); // Next Page
|
275 |
-
$output .= $this->_navBox(">>", $lastPage, 4); // Last Page
|
276 |
|
277 |
return $output;
|
278 |
}
|
@@ -283,7 +282,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
283 |
return "No errors were encountered.";
|
284 |
}
|
285 |
|
286 |
-
$words = ( count($this->_errors) > 1 ) ? "errors were" : "error was";
|
287 |
|
288 |
// Determine CSS styling for error reporting
|
289 |
if ( $this->_styles["errors"] ) {
|
@@ -295,7 +294,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
295 |
$output
|
296 |
= '
|
297 |
<div ' . $css . '>
|
298 |
-
The following ' . $words . ' encountered while using the ' . get_class($this) . ' class:<br/><br/>
|
299 |
<ul>';
|
300 |
|
301 |
foreach ( $this->_errors as $error ) {
|
@@ -312,7 +311,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
312 |
|
313 |
public function displaySelectInterface() // displays the <select> interface for choosing display amount
|
314 |
{
|
315 |
-
if ( count($this->_displayOptions) < 2 ) // If only 1 or fewer options, do not display
|
316 |
{
|
317 |
return;
|
318 |
}
|
@@ -345,7 +344,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
345 |
$formName .
|
346 |
$formNumber .
|
347 |
'" method="post" style="display:inline-block;" action="' .
|
348 |
-
$this->_getURL($this->_currentPage) .
|
349 |
'">
|
350 |
Show:
|
351 |
<select ' .
|
@@ -378,7 +377,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
378 |
<noscript><input type="submit" name="paginationDisplaySubmit" value="Display"/></noscript>
|
379 |
</form>';
|
380 |
|
381 |
-
|
382 |
|
383 |
return $output;
|
384 |
}
|
@@ -401,16 +400,16 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
401 |
} // Otherwise use first page
|
402 |
|
403 |
if ( $page < 1 ||
|
404 |
-
! preg_match("/^\d+$/", $page)
|
405 |
) // If page is less than 1 or page value not a digit
|
406 |
{
|
407 |
-
header("Location: " . $this->_getURL()); // No argument for _getURL() sets it to 1 (first page)
|
408 |
exit;
|
409 |
}
|
410 |
|
411 |
if ( $page > $this->getTotalPages() && $this->getTotalPages() != 0 ) // If page exceeds last page
|
412 |
{ // 2nd condition prevents infinite loop should it equal 0
|
413 |
-
header("Location: " . $this->_getURL($this->getTotalPages()));
|
414 |
exit;
|
415 |
}
|
416 |
|
@@ -424,7 +423,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
424 |
)
|
425 |
) // If invalid entry encountered, register error and exit function
|
426 |
{
|
427 |
-
if ( is_array($input) ) // If array
|
428 |
{
|
429 |
$argument = "";
|
430 |
|
@@ -445,7 +444,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
445 |
return;
|
446 |
}
|
447 |
|
448 |
-
if ( ! is_array($input) && strtolower($input) == "all" ) // If Not Array and "All" selected
|
449 |
{
|
450 |
$input = $this->_totalEntries;
|
451 |
} // Set total entries value
|
@@ -462,16 +461,16 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
462 |
|
463 |
$varName = $this->_getPOSTVarName();
|
464 |
|
465 |
-
if ( count($this->_displayOptions) > 1 ) // If more than 1 display option
|
466 |
{
|
467 |
$value = $this->_displayOptions[0]; // Default is first selection
|
468 |
|
469 |
if ( isset( $_POST[ $varName ] ) ) // If POST is set
|
470 |
{
|
471 |
-
if ( in_array($_POST[ $varName ], $this->_displayOptions) ) // Check for valid post value
|
472 |
{
|
473 |
$value = $_POST[ $varName ];
|
474 |
-
setcookie($varName, $value, 604800 + time(), "/"); // Set cookie
|
475 |
$_COOKIE[ $varName ] = $value;
|
476 |
} else // If invalid post value
|
477 |
{
|
@@ -481,14 +480,13 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
481 |
} elseif ( isset( $_COOKIE[ $varName ] ) ) // If POST not set, but COOKIE set
|
482 |
{
|
483 |
// Check for valid cookie value
|
484 |
-
if ( in_array($_COOKIE[ $varName ], $this->_displayOptions) ) // Check for valid cookie value
|
485 |
{
|
486 |
$value = $_COOKIE[ $varName ]; // Set to value if valid
|
487 |
} else {
|
488 |
$value
|
489 |
= self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
|
490 |
-
$this->deleteCookie(
|
491 |
-
); // Delete invalid cookie
|
492 |
}
|
493 |
}
|
494 |
} else // If only one option, set either to default or displayOptions value
|
@@ -496,7 +494,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
496 |
$value = ( $this->_displayOptions ) ? $this->_displayOptions : self::DEFAULT_ENTRIES_DISPLAY;
|
497 |
}
|
498 |
|
499 |
-
if ( strtolower($value) == "all" ) // If set to "All", use total entries
|
500 |
{
|
501 |
$value = $this->_totalEntries;
|
502 |
}
|
@@ -506,7 +504,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
506 |
|
507 |
public function setPagesPerSection( $input ) // sets # of pages per section
|
508 |
{
|
509 |
-
if ( ! $this->_validEntry($input) ) {
|
510 |
$this->_errors[] = "The value set for <strong>pages per section</strong> is invalid: " . $input;
|
511 |
|
512 |
return;
|
@@ -517,7 +515,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
517 |
|
518 |
public function setPaginationID( $input ) {
|
519 |
if ( $input ) {
|
520 |
-
if ( preg_match("/^\d+$/", $input[0]) ) // Check if first character is a digit
|
521 |
{
|
522 |
$this->_errors[]
|
523 |
= "The first character of the <strong>pagination ID</strong> cannot be a number: " . $input;
|
@@ -546,7 +544,7 @@ if ( ! class_exists("WP_Statistics_Pagination") ): // Prevent multiple class
|
|
546 |
|
547 |
public function setTotalEntries( $input ) // sets total number of entries
|
548 |
{
|
549 |
-
if ( ! $this->_validEntry($input) ) {
|
550 |
$this->_errors[] = "The value set for <strong>total entries</strong> is invalid: " . $input;
|
551 |
|
552 |
return;
|
17 |
*
|
18 |
******************************************************************************************/
|
19 |
|
20 |
+
if ( ! class_exists( "WP_Statistics_Pagination" ) ): // Prevent multiple class definitions
|
21 |
|
22 |
class WP_Statistics_Pagination {
|
23 |
/*******************************************************
|
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 |
/*******************************************************
|
55 |
$styleErrors = "",
|
56 |
$styleSelect = ""
|
57 |
) {
|
58 |
+
$this->setPaginationID( $paginationID ); // Set ID name of pagination object
|
59 |
+
$this->setTotalEntries( $totalEntries ); // Set total entries
|
60 |
+
$this->setPagesPerSection( $pagesPerSection ); // Set pages per section
|
61 |
+
$this->setDisplayOptions( $options ); // Set viewing display options
|
62 |
$this->setEntriesPerPage(); // Set entries per page (input from POST or cookies)
|
63 |
$this->setCurrentPage(); // Set current page (input from GET)
|
64 |
// ! This function must follow after setEntriesPerPage()
|
82 |
if ( isset( $_COOKIE[ $cookieVar ] ) ) // If cookie is set
|
83 |
{
|
84 |
$_COOKIE[ $cookieVar ] = ""; // Clear cookie
|
85 |
+
setcookie( $cookieVar, "", time() - 3600, "/" ); // Delete cookie
|
86 |
}
|
87 |
}
|
88 |
|
96 |
unset($getVars["foo"], $getVars["bar"], ... ); // Remove any so they do not appear in URL
|
97 |
*/
|
98 |
|
99 |
+
$output = '?' . http_build_query( array_merge( $getVars, array( $this->_getIDGETVarName() => $input ) ) );
|
100 |
$output .= '#' . $this->getPaginationID(); // Add #xxx at the end of URL for auto-scrolling
|
101 |
|
102 |
return $output;
|
134 |
|
135 |
private function _validEntry( $input ) // determines if input is valid
|
136 |
{
|
137 |
+
if ( is_array( $input ) ) // If array
|
138 |
{
|
139 |
+
foreach ( $input as $element ) { // Recursion: evaluate each array element
|
140 |
+
if ( ! $this->_validEntry( $element ) ) // If invalid
|
|
|
141 |
{
|
142 |
return false;
|
143 |
}
|
146 |
return true; // If function makes it to this point, it is valid
|
147 |
} else // If not array
|
148 |
{
|
149 |
+
if ( ( preg_match( "/^\d+$/", $input ) && $input > 0 ) ||
|
150 |
+
strtolower( $input ) == "all"
|
151 |
) // If positive digit or "all"
|
152 |
{
|
153 |
return true;
|
166 |
switch ( $end ) {
|
167 |
case 1:
|
168 |
$title = "First page";
|
169 |
+
break;
|
170 |
case 2:
|
171 |
$title = "Previous page";
|
172 |
+
break;
|
173 |
case 3:
|
174 |
$title = "Next page";
|
175 |
+
break;
|
176 |
case 4:
|
177 |
$title = "Last page (" . $this->getTotalPages() . ")";
|
178 |
+
break;
|
179 |
default:
|
180 |
$title = "";
|
181 |
+
break;
|
182 |
}
|
183 |
|
184 |
$title = ( $end > 0 && $title != "" ) ? 'title="' . $title . '"' : '';
|
198 |
) // and destination page is not less than first page
|
199 |
{
|
200 |
$text = '<a href="' .
|
201 |
+
$this->_getURL( $destinationPage ) .
|
202 |
'">' .
|
203 |
$text .
|
204 |
'</a>'; // then make $text a link
|
263 |
$pagesPerSection +
|
264 |
1; // Adjust section start to # of pages behind section end
|
265 |
|
266 |
+
$output = $this->_navBox( "<<", $firstPage, 1 ); // First page
|
267 |
+
$output .= $this->_navBox( "<", $previousPage, 2 ); // Previous page
|
268 |
|
269 |
+
for ( $i = $sectionStart; $i <= $sectionEnd; ++ $i ) {
|
270 |
+
$output .= $this->_navBox( $i, $i );
|
271 |
} // Pagination
|
272 |
|
273 |
+
$output .= $this->_navBox( ">", $nextPage, 3 ); // Next Page
|
274 |
+
$output .= $this->_navBox( ">>", $lastPage, 4 ); // Last Page
|
275 |
|
276 |
return $output;
|
277 |
}
|
282 |
return "No errors were encountered.";
|
283 |
}
|
284 |
|
285 |
+
$words = ( count( $this->_errors ) > 1 ) ? "errors were" : "error was";
|
286 |
|
287 |
// Determine CSS styling for error reporting
|
288 |
if ( $this->_styles["errors"] ) {
|
294 |
$output
|
295 |
= '
|
296 |
<div ' . $css . '>
|
297 |
+
The following ' . $words . ' encountered while using the ' . get_class( $this ) . ' class:<br/><br/>
|
298 |
<ul>';
|
299 |
|
300 |
foreach ( $this->_errors as $error ) {
|
311 |
|
312 |
public function displaySelectInterface() // displays the <select> interface for choosing display amount
|
313 |
{
|
314 |
+
if ( count( $this->_displayOptions ) < 2 ) // If only 1 or fewer options, do not display
|
315 |
{
|
316 |
return;
|
317 |
}
|
344 |
$formName .
|
345 |
$formNumber .
|
346 |
'" method="post" style="display:inline-block;" action="' .
|
347 |
+
$this->_getURL( $this->_currentPage ) .
|
348 |
'">
|
349 |
Show:
|
350 |
<select ' .
|
377 |
<noscript><input type="submit" name="paginationDisplaySubmit" value="Display"/></noscript>
|
378 |
</form>';
|
379 |
|
380 |
+
++ $count; // Increase # of times this function has run
|
381 |
|
382 |
return $output;
|
383 |
}
|
400 |
} // Otherwise use first page
|
401 |
|
402 |
if ( $page < 1 ||
|
403 |
+
! preg_match( "/^\d+$/", $page )
|
404 |
) // If page is less than 1 or page value not a digit
|
405 |
{
|
406 |
+
header( "Location: " . $this->_getURL() ); // No argument for _getURL() sets it to 1 (first page)
|
407 |
exit;
|
408 |
}
|
409 |
|
410 |
if ( $page > $this->getTotalPages() && $this->getTotalPages() != 0 ) // If page exceeds last page
|
411 |
{ // 2nd condition prevents infinite loop should it equal 0
|
412 |
+
header( "Location: " . $this->_getURL( $this->getTotalPages() ) );
|
413 |
exit;
|
414 |
}
|
415 |
|
423 |
)
|
424 |
) // If invalid entry encountered, register error and exit function
|
425 |
{
|
426 |
+
if ( is_array( $input ) ) // If array
|
427 |
{
|
428 |
$argument = "";
|
429 |
|
444 |
return;
|
445 |
}
|
446 |
|
447 |
+
if ( ! is_array( $input ) && strtolower( $input ) == "all" ) // If Not Array and "All" selected
|
448 |
{
|
449 |
$input = $this->_totalEntries;
|
450 |
} // Set total entries value
|
461 |
|
462 |
$varName = $this->_getPOSTVarName();
|
463 |
|
464 |
+
if ( count( $this->_displayOptions ) > 1 ) // If more than 1 display option
|
465 |
{
|
466 |
$value = $this->_displayOptions[0]; // Default is first selection
|
467 |
|
468 |
if ( isset( $_POST[ $varName ] ) ) // If POST is set
|
469 |
{
|
470 |
+
if ( in_array( $_POST[ $varName ], $this->_displayOptions ) ) // Check for valid post value
|
471 |
{
|
472 |
$value = $_POST[ $varName ];
|
473 |
+
setcookie( $varName, $value, 604800 + time(), "/" ); // Set cookie
|
474 |
$_COOKIE[ $varName ] = $value;
|
475 |
} else // If invalid post value
|
476 |
{
|
480 |
} elseif ( isset( $_COOKIE[ $varName ] ) ) // If POST not set, but COOKIE set
|
481 |
{
|
482 |
// Check for valid cookie value
|
483 |
+
if ( in_array( $_COOKIE[ $varName ], $this->_displayOptions ) ) // Check for valid cookie value
|
484 |
{
|
485 |
$value = $_COOKIE[ $varName ]; // Set to value if valid
|
486 |
} else {
|
487 |
$value
|
488 |
= self::DEFAULT_ENTRIES_DISPLAY; // Set to default if invalid
|
489 |
+
$this->deleteCookie(); // Delete invalid cookie
|
|
|
490 |
}
|
491 |
}
|
492 |
} else // If only one option, set either to default or displayOptions value
|
494 |
$value = ( $this->_displayOptions ) ? $this->_displayOptions : self::DEFAULT_ENTRIES_DISPLAY;
|
495 |
}
|
496 |
|
497 |
+
if ( strtolower( $value ) == "all" ) // If set to "All", use total entries
|
498 |
{
|
499 |
$value = $this->_totalEntries;
|
500 |
}
|
504 |
|
505 |
public function setPagesPerSection( $input ) // sets # of pages per section
|
506 |
{
|
507 |
+
if ( ! $this->_validEntry( $input ) ) {
|
508 |
$this->_errors[] = "The value set for <strong>pages per section</strong> is invalid: " . $input;
|
509 |
|
510 |
return;
|
515 |
|
516 |
public function setPaginationID( $input ) {
|
517 |
if ( $input ) {
|
518 |
+
if ( preg_match( "/^\d+$/", $input[0] ) ) // Check if first character is a digit
|
519 |
{
|
520 |
$this->_errors[]
|
521 |
= "The first character of the <strong>pagination ID</strong> cannot be a number: " . $input;
|
544 |
|
545 |
public function setTotalEntries( $input ) // sets total number of entries
|
546 |
{
|
547 |
+
if ( ! $this->_validEntry( $input ) ) {
|
548 |
$this->_errors[] = "The value set for <strong>total entries</strong> is invalid: " . $input;
|
549 |
|
550 |
return;
|
includes/classes/class-wp-statistics-schedule.php
CHANGED
@@ -14,119 +14,119 @@ class WP_Statistics_Schedule {
|
|
14 |
global $WP_Statistics;
|
15 |
|
16 |
// before construct
|
17 |
-
add_filter('cron_schedules', 'WP_Statistics_Schedule::addcron');
|
18 |
|
19 |
// Add the report schedule if it doesn't exist and is enabled.
|
20 |
-
if ( ! wp_next_scheduled('report_hook') && $WP_Statistics->get_option('stats_report') ) {
|
21 |
|
22 |
-
wp_schedule_event(time(), $WP_Statistics->get_option('time_report'), 'report_hook');
|
23 |
}
|
24 |
|
25 |
// Remove the report schedule if it does exist and is disabled.
|
26 |
-
if ( wp_next_scheduled('report_hook') && ! $WP_Statistics->get_option('stats_report') ) {
|
27 |
|
28 |
-
wp_unschedule_event(wp_next_scheduled('report_hook'), 'report_hook');
|
29 |
}
|
30 |
|
31 |
// Add the GeoIP update schedule if it doesn't exist and it should be.
|
32 |
-
if ( ! wp_next_scheduled('wp_statistics_geoip_hook') &&
|
33 |
-
$WP_Statistics->get_option('schedule_geoip') &&
|
34 |
-
$WP_Statistics->get_option('geoip')
|
35 |
) {
|
36 |
|
37 |
-
wp_schedule_event(time(), 'daily', 'wp_statistics_geoip_hook');
|
38 |
}
|
39 |
|
40 |
// Remove the GeoIP update schedule if it does exist and it should shouldn't.
|
41 |
-
if ( wp_next_scheduled('wp_statistics_geoip_hook') &&
|
42 |
-
( ! $WP_Statistics->get_option('schedule_geoip') || ! $WP_Statistics->get_option('geoip') )
|
43 |
) {
|
44 |
|
45 |
-
wp_unschedule_event(wp_next_scheduled('wp_statistics_geoip_hook'), 'wp_statistics_geoip_hook');
|
46 |
}
|
47 |
|
48 |
// Add the browscap update schedule if it doesn't exist and it should be.
|
49 |
-
if ( ! wp_next_scheduled('wp_statistics_browscap_hook') && $WP_Statistics->get_option('schedule_browscap') ) {
|
50 |
|
51 |
-
wp_schedule_event(time(), 'weekly', 'wp_statistics_browscap_hook');
|
52 |
}
|
53 |
|
54 |
// Remove the browscap update schedule if it does exist and it should shouldn't.
|
55 |
-
if ( wp_next_scheduled('wp_statistics_browscap_hook') && ! $WP_Statistics->get_option('schedule_browscap') ) {
|
56 |
|
57 |
-
wp_unschedule_event(wp_next_scheduled('wp_statistics_browscap_hook'), 'wp_statistics_browscap_hook');
|
58 |
}
|
59 |
|
60 |
// Add the referrerspam update schedule if it doesn't exist and it should be.
|
61 |
-
if ( ! wp_next_scheduled('wp_statistics_referrerspam_hook') &&
|
62 |
-
$WP_Statistics->get_option('schedule_referrerspam')
|
63 |
) {
|
64 |
|
65 |
-
wp_schedule_event(time(), 'weekly', 'wp_statistics_referrerspam_hook');
|
66 |
}
|
67 |
|
68 |
// Remove the referrerspam update schedule if it does exist and it should shouldn't.
|
69 |
-
if ( wp_next_scheduled('wp_statistics_referrerspam_hook') &&
|
70 |
-
! $WP_Statistics->get_option('schedule_referrerspam')
|
71 |
) {
|
72 |
|
73 |
wp_unschedule_event(
|
74 |
-
wp_next_scheduled('wp_statistics_referrerspam_hook'),
|
75 |
'wp_statistics_referrerspam_hook'
|
76 |
);
|
77 |
}
|
78 |
|
79 |
// Add the database maintenance schedule if it doesn't exist and it should be.
|
80 |
-
if ( ! wp_next_scheduled('wp_statistics_dbmaint_hook') && $WP_Statistics->get_option('schedule_dbmaint') ) {
|
81 |
|
82 |
-
wp_schedule_event(time(), 'daily', 'wp_statistics_dbmaint_hook');
|
83 |
}
|
84 |
|
85 |
// Remove the database maintenance schedule if it does exist and it shouldn't.
|
86 |
-
if ( wp_next_scheduled('wp_statistics_dbmaint_hook') && ( ! $WP_Statistics->get_option('schedule_dbmaint') ) ) {
|
87 |
|
88 |
-
wp_unschedule_event(wp_next_scheduled('wp_statistics_dbmaint_hook'), 'wp_statistics_dbmaint_hook');
|
89 |
}
|
90 |
|
91 |
// Add the visitor database maintenance schedule if it doesn't exist and it should be.
|
92 |
-
if ( ! wp_next_scheduled('wp_statistics_dbmaint_visitor_hook') &&
|
93 |
-
$WP_Statistics->get_option('schedule_dbmaint_visitor')
|
94 |
) {
|
95 |
|
96 |
-
wp_schedule_event(time(), 'daily', 'wp_statistics_dbmaint_visitor_hook');
|
97 |
}
|
98 |
|
99 |
// Remove the visitor database maintenance schedule if it does exist and it shouldn't.
|
100 |
-
if ( wp_next_scheduled('wp_statistics_dbmaint_visitor_hook') &&
|
101 |
-
( ! $WP_Statistics->get_option('schedule_dbmaint_visitor') )
|
102 |
) {
|
103 |
|
104 |
wp_unschedule_event(
|
105 |
-
wp_next_scheduled('wp_statistics_dbmaint_visitor_hook'),
|
106 |
'wp_statistics_dbmaint_visitor_hook'
|
107 |
);
|
108 |
}
|
109 |
|
110 |
// Remove the add visit row schedule if it does exist and it shouldn't.
|
111 |
-
if ( wp_next_scheduled('wp_statistics_add_visit_hook') && ( ! $WP_Statistics->get_option('visits') ) ) {
|
112 |
|
113 |
-
wp_unschedule_event(wp_next_scheduled('wp_statistics_add_visit_hook'), 'wp_statistics_add_visit_hook');
|
114 |
}
|
115 |
|
116 |
// Add the add visit table row schedule if it does exist and it should.
|
117 |
-
if ( ! wp_next_scheduled('wp_statistics_add_visit_hook') && $WP_Statistics->get_option('visits') ) {
|
118 |
|
119 |
-
wp_schedule_event(time(), 'daily', 'wp_statistics_add_visit_hook');
|
120 |
}
|
121 |
|
122 |
//after construct
|
123 |
-
add_action('wp_statistics_add_visit_hook', 'WP_Statistics_Schedule::add_visit_event');
|
124 |
-
add_action('wp_statistics_geoip_hook', 'WP_Statistics_Schedule::geoip_event');
|
125 |
-
add_action('wp_statistics_browscap_hook', 'WP_Statistics_Schedule::browscap_event');
|
126 |
-
add_action('wp_statistics_referrerspam_hook', 'WP_Statistics_Schedule::referrerspam_event');
|
127 |
-
add_action('wp_statistics_dbmaint_hook', 'WP_Statistics_Schedule::dbmaint_event');
|
128 |
-
add_action('wp_statistics_dbmaint_visitor_hook', 'WP_Statistics_Schedule::dbmaint_visitor_event');
|
129 |
-
add_action('report_hook', 'WP_Statistics_Schedule::send_report');
|
130 |
|
131 |
}
|
132 |
|
@@ -137,24 +137,24 @@ class WP_Statistics_Schedule {
|
|
137 |
*/
|
138 |
static function addcron( $schedules ) {
|
139 |
// Adds once weekly to the existing schedules.
|
140 |
-
if ( ! array_key_exists('weekly', $schedules) ) {
|
141 |
$schedules['weekly'] = array(
|
142 |
'interval' => 604800,
|
143 |
-
'display' => __('Once Weekly'),
|
144 |
);
|
145 |
}
|
146 |
|
147 |
-
if ( ! array_key_exists('biweekly', $schedules) ) {
|
148 |
$schedules['biweekly'] = array(
|
149 |
'interval' => 1209600,
|
150 |
-
'display' => __('Once Every 2 Weeks'),
|
151 |
);
|
152 |
}
|
153 |
|
154 |
-
if ( ! array_key_exists('4weeks', $schedules) ) {
|
155 |
$schedules['4weeks'] = array(
|
156 |
'interval' => 2419200,
|
157 |
-
'display' => __('Once Every 4 Weeks'),
|
158 |
);
|
159 |
}
|
160 |
|
@@ -171,12 +171,12 @@ class WP_Statistics_Schedule {
|
|
171 |
|
172 |
$sqlstring = $wpdb->prepare(
|
173 |
'INSERT INTO ' . $wpdb->prefix . 'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d)',
|
174 |
-
$WP_Statistics->Current_Date(null, '+1'),
|
175 |
-
$WP_Statistics->Current_date('Y-m-d', '+1'),
|
176 |
0
|
177 |
);
|
178 |
|
179 |
-
$wpdb->query($sqlstring);
|
180 |
}
|
181 |
|
182 |
/**
|
@@ -188,22 +188,22 @@ class WP_Statistics_Schedule {
|
|
188 |
|
189 |
// Maxmind updates the geoip database on the first Tuesday of the month, to make sure we don't update before they post
|
190 |
// the update, download it two days later.
|
191 |
-
$thisupdate = strtotime(__('First Tuesday of this month', 'wp-statistics')) + ( 86400 * 2 );
|
192 |
|
193 |
-
$lastupdate = $WP_Statistics->get_option('last_geoip_dl');
|
194 |
|
195 |
$upload_dir = wp_upload_dir();
|
196 |
|
197 |
// We're also going to look to see if our filesize is to small, this means the plugin stub still exists and should
|
198 |
// be replaced with a proper file.
|
199 |
-
$dbsize = filesize($upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb');
|
200 |
|
201 |
if ( $lastupdate < $thisupdate || $dbsize < 1024 ) {
|
202 |
|
203 |
// We can't fire the download function directly here as we rely on some functions that haven't been loaded yet
|
204 |
// in WordPress, so instead just set the flag in the options table and the shutdown hook will take care of the
|
205 |
// actual download at the end of the page.
|
206 |
-
$WP_Statistics->update_option('update_geoip', true);
|
207 |
}
|
208 |
}
|
209 |
|
@@ -215,7 +215,7 @@ class WP_Statistics_Schedule {
|
|
215 |
GLOBAL $WP_Statistics;
|
216 |
|
217 |
// Check for a new browscap once a week
|
218 |
-
$WP_Statistics->update_option('update_browscap', true);
|
219 |
}
|
220 |
|
221 |
/**
|
@@ -226,7 +226,7 @@ class WP_Statistics_Schedule {
|
|
226 |
GLOBAL $WP_Statistics;
|
227 |
|
228 |
// Check for a new referrerspam once a week
|
229 |
-
$WP_Statistics->update_option('update_referrerspam', true);
|
230 |
}
|
231 |
|
232 |
/**
|
@@ -234,11 +234,11 @@ class WP_Statistics_Schedule {
|
|
234 |
*/
|
235 |
static function dbmaint_event() {
|
236 |
global $WP_Statistics;
|
237 |
-
if ( ! function_exists('wp_statistics_purge_data') ) {
|
238 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' );
|
239 |
}
|
240 |
-
$purge_days = intval($WP_Statistics->get_option('schedule_dbmaint_days', false));
|
241 |
-
wp_statistics_purge_data($purge_days);
|
242 |
}
|
243 |
|
244 |
/**
|
@@ -246,11 +246,11 @@ class WP_Statistics_Schedule {
|
|
246 |
*/
|
247 |
static function dbmaint_visitor_event() {
|
248 |
global $WP_Statistics;
|
249 |
-
if ( ! function_exists('wp_statistics_purge_visitor_hits') ) {
|
250 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' );
|
251 |
}
|
252 |
-
$purge_hits = intval($WP_Statistics->get_option('schedule_dbmaint_visitor_hits', false));
|
253 |
-
wp_statistics_purge_visitor_hits($purge_hits);
|
254 |
}
|
255 |
|
256 |
/**
|
@@ -260,38 +260,38 @@ class WP_Statistics_Schedule {
|
|
260 |
global $WP_Statistics, $sms;
|
261 |
|
262 |
// Retrieve the template from the options.
|
263 |
-
$final_text_report = $WP_Statistics->get_option('content_report');
|
264 |
|
265 |
// Process shortcodes in the template. Note that V8.0 upgrade script replaced the old %option% codes with the appropriate short codes.
|
266 |
-
$final_text_report = do_shortcode($final_text_report);
|
267 |
-
$final_text_report = apply_filters('wp_statistics_final_text_report_email', $final_text_report);
|
268 |
|
269 |
// Send the report through the selected transport agent.
|
270 |
-
if ( $WP_Statistics->get_option('send_report') == 'mail' ) {
|
271 |
|
272 |
-
$blogname = get_bloginfo('name');
|
273 |
-
$blogemail = get_bloginfo('admin_email');
|
274 |
|
275 |
$headers[] = "From: $blogname <$blogemail>";
|
276 |
$headers[] = "MIME-Version: 1.0";
|
277 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
278 |
|
279 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
280 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
281 |
}
|
282 |
|
283 |
wp_mail(
|
284 |
-
$WP_Statistics->get_option('email_list'),
|
285 |
-
__('Statistical reporting', 'wp-statistics'),
|
286 |
$final_text_report,
|
287 |
$headers
|
288 |
);
|
289 |
|
290 |
-
} else if ( $WP_Statistics->get_option('send_report') == 'sms' ) {
|
291 |
|
292 |
-
if ( class_exists(get_option('wp_webservice')) ) {
|
293 |
|
294 |
-
$sms->to = array( get_option('wp_admin_mobile') );
|
295 |
$sms->msg = $final_text_report;
|
296 |
$sms->SendSMS();
|
297 |
}
|
14 |
global $WP_Statistics;
|
15 |
|
16 |
// before construct
|
17 |
+
add_filter( 'cron_schedules', 'WP_Statistics_Schedule::addcron' );
|
18 |
|
19 |
// Add the report schedule if it doesn't exist and is enabled.
|
20 |
+
if ( ! wp_next_scheduled( 'report_hook' ) && $WP_Statistics->get_option( 'stats_report' ) ) {
|
21 |
|
22 |
+
wp_schedule_event( time(), $WP_Statistics->get_option( 'time_report' ), 'report_hook' );
|
23 |
}
|
24 |
|
25 |
// Remove the report schedule if it does exist and is disabled.
|
26 |
+
if ( wp_next_scheduled( 'report_hook' ) && ! $WP_Statistics->get_option( 'stats_report' ) ) {
|
27 |
|
28 |
+
wp_unschedule_event( wp_next_scheduled( 'report_hook' ), 'report_hook' );
|
29 |
}
|
30 |
|
31 |
// Add the GeoIP update schedule if it doesn't exist and it should be.
|
32 |
+
if ( ! wp_next_scheduled( 'wp_statistics_geoip_hook' ) &&
|
33 |
+
$WP_Statistics->get_option( 'schedule_geoip' ) &&
|
34 |
+
$WP_Statistics->get_option( 'geoip' )
|
35 |
) {
|
36 |
|
37 |
+
wp_schedule_event( time(), 'daily', 'wp_statistics_geoip_hook' );
|
38 |
}
|
39 |
|
40 |
// Remove the GeoIP update schedule if it does exist and it should shouldn't.
|
41 |
+
if ( wp_next_scheduled( 'wp_statistics_geoip_hook' ) &&
|
42 |
+
( ! $WP_Statistics->get_option( 'schedule_geoip' ) || ! $WP_Statistics->get_option( 'geoip' ) )
|
43 |
) {
|
44 |
|
45 |
+
wp_unschedule_event( wp_next_scheduled( 'wp_statistics_geoip_hook' ), 'wp_statistics_geoip_hook' );
|
46 |
}
|
47 |
|
48 |
// Add the browscap update schedule if it doesn't exist and it should be.
|
49 |
+
if ( ! wp_next_scheduled( 'wp_statistics_browscap_hook' ) && $WP_Statistics->get_option( 'schedule_browscap' ) ) {
|
50 |
|
51 |
+
wp_schedule_event( time(), 'weekly', 'wp_statistics_browscap_hook' );
|
52 |
}
|
53 |
|
54 |
// Remove the browscap update schedule if it does exist and it should shouldn't.
|
55 |
+
if ( wp_next_scheduled( 'wp_statistics_browscap_hook' ) && ! $WP_Statistics->get_option( 'schedule_browscap' ) ) {
|
56 |
|
57 |
+
wp_unschedule_event( wp_next_scheduled( 'wp_statistics_browscap_hook' ), 'wp_statistics_browscap_hook' );
|
58 |
}
|
59 |
|
60 |
// Add the referrerspam update schedule if it doesn't exist and it should be.
|
61 |
+
if ( ! wp_next_scheduled( 'wp_statistics_referrerspam_hook' ) &&
|
62 |
+
$WP_Statistics->get_option( 'schedule_referrerspam' )
|
63 |
) {
|
64 |
|
65 |
+
wp_schedule_event( time(), 'weekly', 'wp_statistics_referrerspam_hook' );
|
66 |
}
|
67 |
|
68 |
// Remove the referrerspam update schedule if it does exist and it should shouldn't.
|
69 |
+
if ( wp_next_scheduled( 'wp_statistics_referrerspam_hook' ) &&
|
70 |
+
! $WP_Statistics->get_option( 'schedule_referrerspam' )
|
71 |
) {
|
72 |
|
73 |
wp_unschedule_event(
|
74 |
+
wp_next_scheduled( 'wp_statistics_referrerspam_hook' ),
|
75 |
'wp_statistics_referrerspam_hook'
|
76 |
);
|
77 |
}
|
78 |
|
79 |
// Add the database maintenance schedule if it doesn't exist and it should be.
|
80 |
+
if ( ! wp_next_scheduled( 'wp_statistics_dbmaint_hook' ) && $WP_Statistics->get_option( 'schedule_dbmaint' ) ) {
|
81 |
|
82 |
+
wp_schedule_event( time(), 'daily', 'wp_statistics_dbmaint_hook' );
|
83 |
}
|
84 |
|
85 |
// Remove the database maintenance schedule if it does exist and it shouldn't.
|
86 |
+
if ( wp_next_scheduled( 'wp_statistics_dbmaint_hook' ) && ( ! $WP_Statistics->get_option( 'schedule_dbmaint' ) ) ) {
|
87 |
|
88 |
+
wp_unschedule_event( wp_next_scheduled( 'wp_statistics_dbmaint_hook' ), 'wp_statistics_dbmaint_hook' );
|
89 |
}
|
90 |
|
91 |
// Add the visitor database maintenance schedule if it doesn't exist and it should be.
|
92 |
+
if ( ! wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ) &&
|
93 |
+
$WP_Statistics->get_option( 'schedule_dbmaint_visitor' )
|
94 |
) {
|
95 |
|
96 |
+
wp_schedule_event( time(), 'daily', 'wp_statistics_dbmaint_visitor_hook' );
|
97 |
}
|
98 |
|
99 |
// Remove the visitor database maintenance schedule if it does exist and it shouldn't.
|
100 |
+
if ( wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ) &&
|
101 |
+
( ! $WP_Statistics->get_option( 'schedule_dbmaint_visitor' ) )
|
102 |
) {
|
103 |
|
104 |
wp_unschedule_event(
|
105 |
+
wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ),
|
106 |
'wp_statistics_dbmaint_visitor_hook'
|
107 |
);
|
108 |
}
|
109 |
|
110 |
// Remove the add visit row schedule if it does exist and it shouldn't.
|
111 |
+
if ( wp_next_scheduled( 'wp_statistics_add_visit_hook' ) && ( ! $WP_Statistics->get_option( 'visits' ) ) ) {
|
112 |
|
113 |
+
wp_unschedule_event( wp_next_scheduled( 'wp_statistics_add_visit_hook' ), 'wp_statistics_add_visit_hook' );
|
114 |
}
|
115 |
|
116 |
// Add the add visit table row schedule if it does exist and it should.
|
117 |
+
if ( ! wp_next_scheduled( 'wp_statistics_add_visit_hook' ) && $WP_Statistics->get_option( 'visits' ) ) {
|
118 |
|
119 |
+
wp_schedule_event( time(), 'daily', 'wp_statistics_add_visit_hook' );
|
120 |
}
|
121 |
|
122 |
//after construct
|
123 |
+
add_action( 'wp_statistics_add_visit_hook', 'WP_Statistics_Schedule::add_visit_event' );
|
124 |
+
add_action( 'wp_statistics_geoip_hook', 'WP_Statistics_Schedule::geoip_event' );
|
125 |
+
add_action( 'wp_statistics_browscap_hook', 'WP_Statistics_Schedule::browscap_event' );
|
126 |
+
add_action( 'wp_statistics_referrerspam_hook', 'WP_Statistics_Schedule::referrerspam_event' );
|
127 |
+
add_action( 'wp_statistics_dbmaint_hook', 'WP_Statistics_Schedule::dbmaint_event' );
|
128 |
+
add_action( 'wp_statistics_dbmaint_visitor_hook', 'WP_Statistics_Schedule::dbmaint_visitor_event' );
|
129 |
+
add_action( 'report_hook', 'WP_Statistics_Schedule::send_report' );
|
130 |
|
131 |
}
|
132 |
|
137 |
*/
|
138 |
static function addcron( $schedules ) {
|
139 |
// Adds once weekly to the existing schedules.
|
140 |
+
if ( ! array_key_exists( 'weekly', $schedules ) ) {
|
141 |
$schedules['weekly'] = array(
|
142 |
'interval' => 604800,
|
143 |
+
'display' => __( 'Once Weekly' ),
|
144 |
);
|
145 |
}
|
146 |
|
147 |
+
if ( ! array_key_exists( 'biweekly', $schedules ) ) {
|
148 |
$schedules['biweekly'] = array(
|
149 |
'interval' => 1209600,
|
150 |
+
'display' => __( 'Once Every 2 Weeks' ),
|
151 |
);
|
152 |
}
|
153 |
|
154 |
+
if ( ! array_key_exists( '4weeks', $schedules ) ) {
|
155 |
$schedules['4weeks'] = array(
|
156 |
'interval' => 2419200,
|
157 |
+
'display' => __( 'Once Every 4 Weeks' ),
|
158 |
);
|
159 |
}
|
160 |
|
171 |
|
172 |
$sqlstring = $wpdb->prepare(
|
173 |
'INSERT INTO ' . $wpdb->prefix . 'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d)',
|
174 |
+
$WP_Statistics->Current_Date( null, '+1' ),
|
175 |
+
$WP_Statistics->Current_date( 'Y-m-d', '+1' ),
|
176 |
0
|
177 |
);
|
178 |
|
179 |
+
$wpdb->query( $sqlstring );
|
180 |
}
|
181 |
|
182 |
/**
|
188 |
|
189 |
// Maxmind updates the geoip database on the first Tuesday of the month, to make sure we don't update before they post
|
190 |
// the update, download it two days later.
|
191 |
+
$thisupdate = strtotime( __( 'First Tuesday of this month', 'wp-statistics' ) ) + ( 86400 * 2 );
|
192 |
|
193 |
+
$lastupdate = $WP_Statistics->get_option( 'last_geoip_dl' );
|
194 |
|
195 |
$upload_dir = wp_upload_dir();
|
196 |
|
197 |
// We're also going to look to see if our filesize is to small, this means the plugin stub still exists and should
|
198 |
// be replaced with a proper file.
|
199 |
+
$dbsize = filesize( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
|
200 |
|
201 |
if ( $lastupdate < $thisupdate || $dbsize < 1024 ) {
|
202 |
|
203 |
// We can't fire the download function directly here as we rely on some functions that haven't been loaded yet
|
204 |
// in WordPress, so instead just set the flag in the options table and the shutdown hook will take care of the
|
205 |
// actual download at the end of the page.
|
206 |
+
$WP_Statistics->update_option( 'update_geoip', true );
|
207 |
}
|
208 |
}
|
209 |
|
215 |
GLOBAL $WP_Statistics;
|
216 |
|
217 |
// Check for a new browscap once a week
|
218 |
+
$WP_Statistics->update_option( 'update_browscap', true );
|
219 |
}
|
220 |
|
221 |
/**
|
226 |
GLOBAL $WP_Statistics;
|
227 |
|
228 |
// Check for a new referrerspam once a week
|
229 |
+
$WP_Statistics->update_option( 'update_referrerspam', true );
|
230 |
}
|
231 |
|
232 |
/**
|
234 |
*/
|
235 |
static function dbmaint_event() {
|
236 |
global $WP_Statistics;
|
237 |
+
if ( ! function_exists( 'wp_statistics_purge_data' ) ) {
|
238 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' );
|
239 |
}
|
240 |
+
$purge_days = intval( $WP_Statistics->get_option( 'schedule_dbmaint_days', false ) );
|
241 |
+
wp_statistics_purge_data( $purge_days );
|
242 |
}
|
243 |
|
244 |
/**
|
246 |
*/
|
247 |
static function dbmaint_visitor_event() {
|
248 |
global $WP_Statistics;
|
249 |
+
if ( ! function_exists( 'wp_statistics_purge_visitor_hits' ) ) {
|
250 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' );
|
251 |
}
|
252 |
+
$purge_hits = intval( $WP_Statistics->get_option( 'schedule_dbmaint_visitor_hits', false ) );
|
253 |
+
wp_statistics_purge_visitor_hits( $purge_hits );
|
254 |
}
|
255 |
|
256 |
/**
|
260 |
global $WP_Statistics, $sms;
|
261 |
|
262 |
// Retrieve the template from the options.
|
263 |
+
$final_text_report = $WP_Statistics->get_option( 'content_report' );
|
264 |
|
265 |
// Process shortcodes in the template. Note that V8.0 upgrade script replaced the old %option% codes with the appropriate short codes.
|
266 |
+
$final_text_report = do_shortcode( $final_text_report );
|
267 |
+
$final_text_report = apply_filters( 'wp_statistics_final_text_report_email', $final_text_report );
|
268 |
|
269 |
// Send the report through the selected transport agent.
|
270 |
+
if ( $WP_Statistics->get_option( 'send_report' ) == 'mail' ) {
|
271 |
|
272 |
+
$blogname = get_bloginfo( 'name' );
|
273 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
274 |
|
275 |
$headers[] = "From: $blogname <$blogemail>";
|
276 |
$headers[] = "MIME-Version: 1.0";
|
277 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
278 |
|
279 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
280 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
281 |
}
|
282 |
|
283 |
wp_mail(
|
284 |
+
$WP_Statistics->get_option( 'email_list' ),
|
285 |
+
__( 'Statistical reporting', 'wp-statistics' ),
|
286 |
$final_text_report,
|
287 |
$headers
|
288 |
);
|
289 |
|
290 |
+
} else if ( $WP_Statistics->get_option( 'send_report' ) == 'sms' ) {
|
291 |
|
292 |
+
if ( class_exists( get_option( 'wp_webservice' ) ) ) {
|
293 |
|
294 |
+
$sms->to = array( get_option( 'wp_admin_mobile' ) );
|
295 |
$sms->msg = $final_text_report;
|
296 |
$sms->SendSMS();
|
297 |
}
|
includes/classes/class-wp-statistics-shortcode.php
CHANGED
@@ -20,97 +20,97 @@ class WP_Statistics_Shortcode {
|
|
20 |
*/
|
21 |
static function shortcodes( $atts ) {
|
22 |
|
23 |
-
if ( ! is_array($atts) ) {
|
24 |
return;
|
25 |
}
|
26 |
-
if ( ! array_key_exists('stat', $atts) ) {
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
-
if ( ! array_key_exists('time', $atts) ) {
|
31 |
$atts['time'] = null;
|
32 |
}
|
33 |
-
if ( ! array_key_exists('provider', $atts) ) {
|
34 |
$atts['provider'] = 'all';
|
35 |
}
|
36 |
-
if ( ! array_key_exists('format', $atts) ) {
|
37 |
$atts['format'] = null;
|
38 |
}
|
39 |
-
if ( ! array_key_exists('id', $atts) ) {
|
40 |
-
$atts['id'] = -1;
|
41 |
}
|
42 |
|
43 |
-
$formatnumber = array_key_exists('format', $atts);
|
44 |
|
45 |
switch ( $atts['stat'] ) {
|
46 |
case 'usersonline':
|
47 |
$result = wp_statistics_useronline();
|
48 |
-
|
49 |
|
50 |
case 'visits':
|
51 |
-
$result = wp_statistics_visit($atts['time']);
|
52 |
-
|
53 |
|
54 |
case 'visitors':
|
55 |
-
$result = wp_statistics_visitor($atts['time'], null, true);
|
56 |
-
|
57 |
|
58 |
case 'pagevisits':
|
59 |
-
$result = wp_statistics_pages($atts['time'], null, $atts['id']);
|
60 |
-
|
61 |
|
62 |
case 'searches':
|
63 |
-
$result = wp_statistics_searchengine($atts['provider'], $atts['time']);
|
64 |
-
|
65 |
|
66 |
case 'postcount':
|
67 |
$result = wp_statistics_countposts();
|
68 |
-
|
69 |
|
70 |
case 'pagecount':
|
71 |
$result = wp_statistics_countpages();
|
72 |
-
|
73 |
|
74 |
case 'commentcount':
|
75 |
$result = wp_statistics_countcomment();
|
76 |
-
|
77 |
|
78 |
case 'spamcount':
|
79 |
$result = wp_statistics_countspam();
|
80 |
-
|
81 |
|
82 |
case 'usercount':
|
83 |
$result = wp_statistics_countusers();
|
84 |
-
|
85 |
|
86 |
case 'postaverage':
|
87 |
$result = wp_statistics_average_post();
|
88 |
-
|
89 |
|
90 |
case 'commentaverage':
|
91 |
$result = wp_statistics_average_comment();
|
92 |
-
|
93 |
|
94 |
case 'useraverage':
|
95 |
$result = wp_statistics_average_registeruser();
|
96 |
-
|
97 |
|
98 |
case 'lpd':
|
99 |
$result = wp_statistics_lastpostdate();
|
100 |
$formatnumber = false;
|
101 |
-
|
102 |
}
|
103 |
|
104 |
if ( $formatnumber ) {
|
105 |
-
switch ( strtolower($atts['format']) ) {
|
106 |
case 'i18n':
|
107 |
-
$result = number_format_i18n($result);
|
108 |
|
109 |
-
|
110 |
case 'english':
|
111 |
-
$result = number_format($result);
|
112 |
|
113 |
-
|
114 |
}
|
115 |
}
|
116 |
|
@@ -122,7 +122,7 @@ class WP_Statistics_Shortcode {
|
|
122 |
*/
|
123 |
static function shortcake() {
|
124 |
// ShortCake support if loaded.
|
125 |
-
if ( function_exists('shortcode_ui_register_for_shortcode') ) {
|
126 |
$se_list = wp_statistics_searchengine_list();
|
127 |
|
128 |
$se_options = array( '' => 'None' );
|
@@ -148,30 +148,30 @@ class WP_Statistics_Shortcode {
|
|
148 |
// Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date.
|
149 |
'attrs' => array(
|
150 |
array(
|
151 |
-
'label' => __('Statistic', 'wp-statistics'),
|
152 |
'attr' => 'stat',
|
153 |
'type' => 'select',
|
154 |
-
'description' => __('Select the statistic you wish to display.', 'wp-statistics'),
|
155 |
'value' => 'usersonline',
|
156 |
'options' => array(
|
157 |
-
'usersonline' => __('Online Users', 'wp-statistics'),
|
158 |
-
'visits' => __('Visits', 'wp-statistics'),
|
159 |
-
'visitors' => __('Visitors', 'wp-statistics'),
|
160 |
-
'pagevisits' => __('Page Visits', 'wp-statistics'),
|
161 |
-
'searches' => __('Searches', 'wp-statistics'),
|
162 |
-
'postcount' => __('Post Count', 'wp-statistics'),
|
163 |
-
'pagecount' => __('Page Count', 'wp-statistics'),
|
164 |
-
'commentcount' => __('Comment Count', 'wp-statistics'),
|
165 |
-
'spamcount' => __('Spam Count', 'wp-statistics'),
|
166 |
-
'usercount' => __('User Count', 'wp-statistics'),
|
167 |
-
'postaverage' => __('Post Average', 'wp-statistics'),
|
168 |
-
'commentaverage' => __('Comment Average', 'wp-statistics'),
|
169 |
-
'useraverage' => __('User Average', 'wp-statistics'),
|
170 |
-
'lpd' => __('Last Post Date', 'wp-statistics'),
|
171 |
),
|
172 |
),
|
173 |
array(
|
174 |
-
'label' => __('Time Frame', 'wp-statistics'),
|
175 |
'attr' => 'time',
|
176 |
'type' => 'url',
|
177 |
'description' => __(
|
@@ -181,14 +181,14 @@ class WP_Statistics_Shortcode {
|
|
181 |
'meta' => array( 'size' => '10' ),
|
182 |
),
|
183 |
array(
|
184 |
-
'label' => __('Search Provider', 'wp-statistics'),
|
185 |
'attr' => 'provider',
|
186 |
'type' => 'select',
|
187 |
-
'description' => __('The search provider to get statistics on.', 'wp-statistics'),
|
188 |
'options' => $se_options,
|
189 |
),
|
190 |
array(
|
191 |
-
'label' => __('Number Format', 'wp-statistics'),
|
192 |
'attr' => 'format',
|
193 |
'type' => 'select',
|
194 |
'description' => __(
|
@@ -197,16 +197,16 @@ class WP_Statistics_Shortcode {
|
|
197 |
),
|
198 |
'value' => 'none',
|
199 |
'options' => array(
|
200 |
-
'none' => __('None', 'wp-statistics'),
|
201 |
-
'english' => __('English', 'wp-statistics'),
|
202 |
-
'i18n' => __('International', 'wp-statistics'),
|
203 |
),
|
204 |
),
|
205 |
array(
|
206 |
-
'label' => __('Post/Page ID', 'wp-statistics'),
|
207 |
'attr' => 'id',
|
208 |
'type' => 'number',
|
209 |
-
'description' => __('The post/page id to get page statistics on.', 'wp-statistics'),
|
210 |
'meta' => array( 'size' => '5' ),
|
211 |
),
|
212 |
),
|
20 |
*/
|
21 |
static function shortcodes( $atts ) {
|
22 |
|
23 |
+
if ( ! is_array( $atts ) ) {
|
24 |
return;
|
25 |
}
|
26 |
+
if ( ! array_key_exists( 'stat', $atts ) ) {
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
+
if ( ! array_key_exists( 'time', $atts ) ) {
|
31 |
$atts['time'] = null;
|
32 |
}
|
33 |
+
if ( ! array_key_exists( 'provider', $atts ) ) {
|
34 |
$atts['provider'] = 'all';
|
35 |
}
|
36 |
+
if ( ! array_key_exists( 'format', $atts ) ) {
|
37 |
$atts['format'] = null;
|
38 |
}
|
39 |
+
if ( ! array_key_exists( 'id', $atts ) ) {
|
40 |
+
$atts['id'] = - 1;
|
41 |
}
|
42 |
|
43 |
+
$formatnumber = array_key_exists( 'format', $atts );
|
44 |
|
45 |
switch ( $atts['stat'] ) {
|
46 |
case 'usersonline':
|
47 |
$result = wp_statistics_useronline();
|
48 |
+
break;
|
49 |
|
50 |
case 'visits':
|
51 |
+
$result = wp_statistics_visit( $atts['time'] );
|
52 |
+
break;
|
53 |
|
54 |
case 'visitors':
|
55 |
+
$result = wp_statistics_visitor( $atts['time'], null, true );
|
56 |
+
break;
|
57 |
|
58 |
case 'pagevisits':
|
59 |
+
$result = wp_statistics_pages( $atts['time'], null, $atts['id'] );
|
60 |
+
break;
|
61 |
|
62 |
case 'searches':
|
63 |
+
$result = wp_statistics_searchengine( $atts['provider'], $atts['time'] );
|
64 |
+
break;
|
65 |
|
66 |
case 'postcount':
|
67 |
$result = wp_statistics_countposts();
|
68 |
+
break;
|
69 |
|
70 |
case 'pagecount':
|
71 |
$result = wp_statistics_countpages();
|
72 |
+
break;
|
73 |
|
74 |
case 'commentcount':
|
75 |
$result = wp_statistics_countcomment();
|
76 |
+
break;
|
77 |
|
78 |
case 'spamcount':
|
79 |
$result = wp_statistics_countspam();
|
80 |
+
break;
|
81 |
|
82 |
case 'usercount':
|
83 |
$result = wp_statistics_countusers();
|
84 |
+
break;
|
85 |
|
86 |
case 'postaverage':
|
87 |
$result = wp_statistics_average_post();
|
88 |
+
break;
|
89 |
|
90 |
case 'commentaverage':
|
91 |
$result = wp_statistics_average_comment();
|
92 |
+
break;
|
93 |
|
94 |
case 'useraverage':
|
95 |
$result = wp_statistics_average_registeruser();
|
96 |
+
break;
|
97 |
|
98 |
case 'lpd':
|
99 |
$result = wp_statistics_lastpostdate();
|
100 |
$formatnumber = false;
|
101 |
+
break;
|
102 |
}
|
103 |
|
104 |
if ( $formatnumber ) {
|
105 |
+
switch ( strtolower( $atts['format'] ) ) {
|
106 |
case 'i18n':
|
107 |
+
$result = number_format_i18n( $result );
|
108 |
|
109 |
+
break;
|
110 |
case 'english':
|
111 |
+
$result = number_format( $result );
|
112 |
|
113 |
+
break;
|
114 |
}
|
115 |
}
|
116 |
|
122 |
*/
|
123 |
static function shortcake() {
|
124 |
// ShortCake support if loaded.
|
125 |
+
if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
|
126 |
$se_list = wp_statistics_searchengine_list();
|
127 |
|
128 |
$se_options = array( '' => 'None' );
|
148 |
// Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date.
|
149 |
'attrs' => array(
|
150 |
array(
|
151 |
+
'label' => __( 'Statistic', 'wp-statistics' ),
|
152 |
'attr' => 'stat',
|
153 |
'type' => 'select',
|
154 |
+
'description' => __( 'Select the statistic you wish to display.', 'wp-statistics' ),
|
155 |
'value' => 'usersonline',
|
156 |
'options' => array(
|
157 |
+
'usersonline' => __( 'Online Users', 'wp-statistics' ),
|
158 |
+
'visits' => __( 'Visits', 'wp-statistics' ),
|
159 |
+
'visitors' => __( 'Visitors', 'wp-statistics' ),
|
160 |
+
'pagevisits' => __( 'Page Visits', 'wp-statistics' ),
|
161 |
+
'searches' => __( 'Searches', 'wp-statistics' ),
|
162 |
+
'postcount' => __( 'Post Count', 'wp-statistics' ),
|
163 |
+
'pagecount' => __( 'Page Count', 'wp-statistics' ),
|
164 |
+
'commentcount' => __( 'Comment Count', 'wp-statistics' ),
|
165 |
+
'spamcount' => __( 'Spam Count', 'wp-statistics' ),
|
166 |
+
'usercount' => __( 'User Count', 'wp-statistics' ),
|
167 |
+
'postaverage' => __( 'Post Average', 'wp-statistics' ),
|
168 |
+
'commentaverage' => __( 'Comment Average', 'wp-statistics' ),
|
169 |
+
'useraverage' => __( 'User Average', 'wp-statistics' ),
|
170 |
+
'lpd' => __( 'Last Post Date', 'wp-statistics' ),
|
171 |
),
|
172 |
),
|
173 |
array(
|
174 |
+
'label' => __( 'Time Frame', 'wp-statistics' ),
|
175 |
'attr' => 'time',
|
176 |
'type' => 'url',
|
177 |
'description' => __(
|
181 |
'meta' => array( 'size' => '10' ),
|
182 |
),
|
183 |
array(
|
184 |
+
'label' => __( 'Search Provider', 'wp-statistics' ),
|
185 |
'attr' => 'provider',
|
186 |
'type' => 'select',
|
187 |
+
'description' => __( 'The search provider to get statistics on.', 'wp-statistics' ),
|
188 |
'options' => $se_options,
|
189 |
),
|
190 |
array(
|
191 |
+
'label' => __( 'Number Format', 'wp-statistics' ),
|
192 |
'attr' => 'format',
|
193 |
'type' => 'select',
|
194 |
'description' => __(
|
197 |
),
|
198 |
'value' => 'none',
|
199 |
'options' => array(
|
200 |
+
'none' => __( 'None', 'wp-statistics' ),
|
201 |
+
'english' => __( 'English', 'wp-statistics' ),
|
202 |
+
'i18n' => __( 'International', 'wp-statistics' ),
|
203 |
),
|
204 |
),
|
205 |
array(
|
206 |
+
'label' => __( 'Post/Page ID', 'wp-statistics' ),
|
207 |
'attr' => 'id',
|
208 |
'type' => 'number',
|
209 |
+
'description' => __( 'The post/page id to get page statistics on.', 'wp-statistics' ),
|
210 |
'meta' => array( 'size' => '5' ),
|
211 |
),
|
212 |
),
|
includes/classes/class-wp-statistics-uninstall.php
CHANGED
@@ -19,7 +19,7 @@ class WP_Statistics_Uninstall {
|
|
19 |
// Loop through each of the sites.
|
20 |
$sites = $WP_Statistics->get_wp_sites_list();
|
21 |
foreach ( $sites as $blog_id ) {
|
22 |
-
switch_to_blog($blog_id);
|
23 |
$this->wp_statistics_site_removal();
|
24 |
}
|
25 |
restore_current_blog();
|
@@ -28,7 +28,7 @@ class WP_Statistics_Uninstall {
|
|
28 |
|
29 |
}
|
30 |
// Make sure we don't try and remove the data more than once.
|
31 |
-
update_option('wp_statistics_removal', 'done');
|
32 |
}
|
33 |
|
34 |
}
|
@@ -40,12 +40,12 @@ class WP_Statistics_Uninstall {
|
|
40 |
global $wpdb;
|
41 |
|
42 |
// Delete the options from the WordPress options table.
|
43 |
-
delete_option('wp_statistics');
|
44 |
-
delete_option('wp_statistics_db_version');
|
45 |
-
delete_option('wp_statistics_plugin_version');
|
46 |
|
47 |
// Delete the user options.
|
48 |
-
$wpdb->query("DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'");
|
49 |
|
50 |
// Drop the tables
|
51 |
$wpdb->query(
|
19 |
// Loop through each of the sites.
|
20 |
$sites = $WP_Statistics->get_wp_sites_list();
|
21 |
foreach ( $sites as $blog_id ) {
|
22 |
+
switch_to_blog( $blog_id );
|
23 |
$this->wp_statistics_site_removal();
|
24 |
}
|
25 |
restore_current_blog();
|
28 |
|
29 |
}
|
30 |
// Make sure we don't try and remove the data more than once.
|
31 |
+
update_option( 'wp_statistics_removal', 'done' );
|
32 |
}
|
33 |
|
34 |
}
|
40 |
global $wpdb;
|
41 |
|
42 |
// Delete the options from the WordPress options table.
|
43 |
+
delete_option( 'wp_statistics' );
|
44 |
+
delete_option( 'wp_statistics_db_version' );
|
45 |
+
delete_option( 'wp_statistics_plugin_version' );
|
46 |
|
47 |
// Delete the user options.
|
48 |
+
$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" );
|
49 |
|
50 |
// Drop the tables
|
51 |
$wpdb->query(
|
includes/classes/class-wp-statistics-updates.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
use
|
|
|
|
|
|
|
4 |
use GeoIp2\Database\Reader;
|
5 |
|
6 |
/**
|
@@ -14,39 +17,54 @@ class WP_Statistics_Updates {
|
|
14 |
* @return string
|
15 |
*/
|
16 |
static function download_geoip() {
|
17 |
-
|
18 |
GLOBAL $WP_Statistics;
|
19 |
|
20 |
-
// We need the download_url()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
// Also stop trying to update the database as it just won't work :)
|
22 |
-
if ( false === function_exists(
|
23 |
-
$WP_Statistics->update_option('update_geoip', false);
|
24 |
|
25 |
$result = "<div class='updated settings-error'><p><strong>" .
|
26 |
-
__('Error the
|
27 |
"</strong></p></div>";
|
28 |
|
29 |
return $result;
|
30 |
}
|
31 |
|
32 |
// If GeoIP is disabled, bail out.
|
33 |
-
if ( $WP_Statistics->get_option('geoip') == false ) {
|
34 |
return '';
|
35 |
}
|
36 |
|
37 |
// This is the location of the file to download.
|
38 |
$download_url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz';
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
// Get the upload directory from
|
41 |
$upload_dir = wp_upload_dir();
|
42 |
|
43 |
// Create a variable with the name of the database file to download.
|
44 |
$DBFile = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
|
45 |
|
46 |
// Check to see if the subdirectory we're going to upload to exists, if not create it.
|
47 |
-
if ( ! file_exists($upload_dir['basedir'] . '/wp-statistics') ) {
|
48 |
-
if ( ! @mkdir($upload_dir['basedir'] . '/wp-statistics', 0755) ) {
|
49 |
-
$WP_Statistics->update_option('update_geoip', false);
|
50 |
|
51 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
52 |
__(
|
@@ -60,8 +78,8 @@ class WP_Statistics_Updates {
|
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
if ( ! is_writable($upload_dir['basedir'] . '/wp-statistics') ) {
|
64 |
-
$WP_Statistics->update_option('update_geoip', false);
|
65 |
|
66 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
67 |
__(
|
@@ -75,63 +93,69 @@ class WP_Statistics_Updates {
|
|
75 |
}
|
76 |
|
77 |
// Download the file from MaxMind, this places it in a temporary location.
|
78 |
-
$TempFile = download_url($download_url);
|
79 |
|
80 |
// If we failed, through a message, otherwise proceed.
|
81 |
-
if ( is_wp_error($TempFile) ) {
|
|
|
|
|
82 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
83 |
-
__('Error downloading GeoIP database from: %s - %s', 'wp-statistics'),
|
84 |
$download_url,
|
85 |
$TempFile->get_error_message()
|
86 |
) . "</strong></p></div>";
|
87 |
} else {
|
88 |
// Open the downloaded file to unzip it.
|
89 |
-
$ZipHandle = gzopen($TempFile, 'rb');
|
90 |
|
91 |
// Create th new file to unzip to.
|
92 |
-
$DBfh = fopen($DBFile, 'wb');
|
93 |
|
94 |
// If we failed to open the downloaded file, through an error and remove the temporary file. Otherwise do the actual unzip.
|
95 |
if ( ! $ZipHandle ) {
|
|
|
|
|
96 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
97 |
-
__('Error could not open downloaded GeoIP database for reading: %s', 'wp-statistics'),
|
98 |
$TempFile
|
99 |
) . "</strong></p></div>";
|
100 |
|
101 |
-
unlink($TempFile);
|
102 |
} else {
|
103 |
// If we failed to open the new file, throw and error and remove the temporary file. Otherwise actually do the unzip.
|
104 |
if ( ! $DBfh ) {
|
|
|
|
|
105 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
106 |
-
__('Error could not open destination GeoIP database for writing %s', 'wp-statistics'),
|
107 |
$DBFile
|
108 |
) . "</strong></p></div>";
|
109 |
-
unlink($TempFile);
|
110 |
} else {
|
111 |
-
while ( ( $data = gzread($ZipHandle, 4096) ) != false ) {
|
112 |
-
fwrite($DBfh, $data);
|
113 |
}
|
114 |
|
115 |
// Close the files.
|
116 |
-
gzclose($ZipHandle);
|
117 |
-
fclose($DBfh);
|
118 |
|
119 |
// Delete the temporary file.
|
120 |
-
unlink($TempFile);
|
121 |
|
122 |
// Display the success message.
|
123 |
$result = "<div class='updated settings-error'><p><strong>" .
|
124 |
-
__('GeoIP Database updated successfully!', 'wp-statistics') .
|
125 |
"</strong></p></div>";
|
126 |
|
127 |
// Update the options to reflect the new download.
|
128 |
-
$WP_Statistics->update_option('last_geoip_dl', time());
|
129 |
-
$WP_Statistics->update_option('update_geoip', false);
|
130 |
|
131 |
// Populate any missing GeoIP information if the user has selected the option.
|
132 |
-
if ( $WP_Statistics->get_option('geoip') &&
|
133 |
wp_statistics_geoip_supported() &&
|
134 |
-
$WP_Statistics->get_option('auto_pop')
|
135 |
) {
|
136 |
$result .= WP_Statistics_Updates::populate_geoip_info();
|
137 |
}
|
@@ -139,27 +163,27 @@ class WP_Statistics_Updates {
|
|
139 |
}
|
140 |
}
|
141 |
|
142 |
-
if ( $WP_Statistics->get_option('geoip_report') == true ) {
|
143 |
-
$blogname = get_bloginfo('name');
|
144 |
-
$blogemail = get_bloginfo('admin_email');
|
145 |
|
146 |
$headers[] = "From: $blogname <$blogemail>";
|
147 |
$headers[] = "MIME-Version: 1.0";
|
148 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
149 |
|
150 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
151 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
152 |
}
|
153 |
|
154 |
wp_mail(
|
155 |
-
$WP_Statistics->get_option('email_list'),
|
156 |
-
__('GeoIP update on', 'wp-statistics') . ' ' . $blogname,
|
157 |
$result,
|
158 |
$headers
|
159 |
);
|
160 |
}
|
161 |
|
162 |
-
// All of the messages displayed above are stored in a
|
163 |
return $result;
|
164 |
}
|
165 |
|
@@ -167,307 +191,73 @@ class WP_Statistics_Updates {
|
|
167 |
* This function downloads the browscap database from browscap.org.
|
168 |
*
|
169 |
* @return string
|
170 |
-
* @throws \phpbrowscap\Exception
|
171 |
*/
|
172 |
static function download_browscap() {
|
173 |
global $WP_Statistics;
|
174 |
|
|
|
|
|
|
|
175 |
// We need the download_url() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out.
|
176 |
-
if ( ! function_exists('download_url') ) {
|
177 |
include( ABSPATH . 'wp-admin/includes/file.php' );
|
178 |
}
|
179 |
|
180 |
// If browscap is disabled, bail out.
|
181 |
-
if ( $WP_Statistics->get_option('browscap') == false ) {
|
182 |
return '';
|
183 |
}
|
184 |
|
185 |
-
// This is the location of the file to download.
|
186 |
-
$download_url = 'http://browscap.org/stream?q=Full_PHP_BrowsCapINI';
|
187 |
-
$download_version = 'http://browscap.org/version-number';
|
188 |
-
|
189 |
// Get the upload directory from WordPress.
|
190 |
$upload_dir = wp_upload_dir();
|
191 |
|
192 |
// Check to see if the subdirectory we're going to upload to exists, if not create it.
|
193 |
-
if ( ! file_exists($upload_dir['basedir'] . '/wp-statistics') ) {
|
194 |
-
mkdir($upload_dir['basedir'] . '/wp-statistics');
|
195 |
}
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
// Get the Browscap object, tell it NOT to autoupdate.
|
200 |
-
$bc = new Browscap($upload_dir['basedir'] . '/wp-statistics');
|
201 |
-
$bc->doAutoUpdate = false; // We don't want to auto update.
|
202 |
-
|
203 |
-
// If we already have a browscap.ini file (aka we're already done a download in the past) we can get it's version number.
|
204 |
-
// We can't execute this code if no browscap.ini exists as then the library will automatically download a full version, even
|
205 |
-
// though we've told it not to autoupdate above.
|
206 |
-
if ( $WP_Statistics->get_option('last_browscap_dl') > 1 ) {
|
207 |
-
// Get the current browser so that the version information is populated.
|
208 |
-
try {
|
209 |
-
$bc->getBrowser();
|
210 |
-
$LocalVersion = $bc->getSourceVersion();
|
211 |
-
} catch ( Exception $e ) {
|
212 |
-
$crawler = false;
|
213 |
-
$LocalVersion = 0;
|
214 |
-
}
|
215 |
-
|
216 |
-
}
|
217 |
-
|
218 |
-
// Get the remote version info from browscap.org.
|
219 |
-
$TempVersionFile = download_url($download_version);
|
220 |
-
|
221 |
-
// Read the version we just downloaded in to a string.
|
222 |
-
$RemoteVersion = file_get_contents($TempVersionFile);
|
223 |
-
|
224 |
-
// Get rid of the temporary file.
|
225 |
-
unlink($TempVersionFile);
|
226 |
-
|
227 |
-
// If there is a new version, let's go get it.
|
228 |
-
if ( intval($RemoteVersion) > $LocalVersion ) {
|
229 |
-
|
230 |
-
// Download the file from browscap.org, this places it in a temporary location.
|
231 |
-
$TempFile = download_url($download_url);
|
232 |
-
|
233 |
-
// If we failed, through a message, otherwise proceed.
|
234 |
-
if ( is_wp_error($TempFile) ) {
|
235 |
-
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
236 |
-
__('Error downloading browscap database from: %s - %s', 'wp-statistics'),
|
237 |
-
$download_url,
|
238 |
-
$TempFile->get_error_message()
|
239 |
-
) . "</strong></p></div>";
|
240 |
-
} else {
|
241 |
-
// Keep the current version just in case by renaming it.
|
242 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/browscap.old') ) {
|
243 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/browscap.old');
|
244 |
-
}
|
245 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/cache.old') ) {
|
246 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/cache.old');
|
247 |
-
}
|
248 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/browscap.ini') ) {
|
249 |
-
rename(
|
250 |
-
$upload_dir['basedir'] . '/wp-statistics/browscap.ini',
|
251 |
-
$upload_dir['basedir'] . '/wp-statistics/browscap.old'
|
252 |
-
);
|
253 |
-
}
|
254 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/cache.php') ) {
|
255 |
-
rename(
|
256 |
-
$upload_dir['basedir'] . '/wp-statistics/cache.php',
|
257 |
-
$upload_dir['basedir'] . '/wp-statistics/cache.old'
|
258 |
-
);
|
259 |
-
}
|
260 |
-
|
261 |
-
// Setup our file handles.
|
262 |
-
$infile = fopen($TempFile, 'r');
|
263 |
-
$outfile = fopen($upload_dir['basedir'] . '/wp-statistics/browscap.ini', 'w');
|
264 |
-
|
265 |
-
// We're going to need some variables to use as we process the new browscap.ini.
|
266 |
-
// $crawler has three possible settings:
|
267 |
-
// 0 = no setting found
|
268 |
-
// 1 = setting found but not a crawler
|
269 |
-
// 2 = setting found and a crawler
|
270 |
-
$parent = '';
|
271 |
-
$title = '';
|
272 |
-
$crawler = 0;
|
273 |
-
$parents = array( '' => false );
|
274 |
-
|
275 |
-
// Now read in the browscap.ini file we downloaded one line at a time.
|
276 |
-
while ( ( $buffer = fgets($infile) ) !== false ) {
|
277 |
-
// Let's get rid of the tailing carriage return extra spaces.
|
278 |
-
$buffer = trim($buffer);
|
279 |
-
|
280 |
-
// We're going to do some things based on the first charater on the line so let's just get it once.
|
281 |
-
$firstchar = substr($buffer, 0, 1);
|
282 |
-
|
283 |
-
// The first character will tell us what kind of line we're dealing with.
|
284 |
-
switch ( $firstchar ) {
|
285 |
-
// A square bracket means it's a section title.
|
286 |
-
case '[':
|
287 |
-
|
288 |
-
// We have three sections we need to copy verbatium so don't do the standard processing for them.
|
289 |
-
if ( $title != 'GJK_Browscap_Version' &&
|
290 |
-
$title != 'DefaultProperties' &&
|
291 |
-
$title != '*' &&
|
292 |
-
$title != ''
|
293 |
-
) {
|
294 |
-
// Write out the section if:
|
295 |
-
// the current section is a crawler and there is no parent
|
296 |
-
// OR
|
297 |
-
// the current section is a crawler, has a parent and the parent is a crawler as well
|
298 |
-
// (Note, this will drop some crawlers who's parent's aren't because we haven't written
|
299 |
-
// out all the parent's that aren't crawlers this could cause mis-identificaton of
|
300 |
-
// some users as crawlers).
|
301 |
-
// OR
|
302 |
-
// the current section isn't a crawler but the parent is
|
303 |
-
//
|
304 |
-
if ( ( $crawler == 2 && $parent == '' ) ||
|
305 |
-
( $crawler == 2 && $parent != '' && array_key_exists($parent, $parents) ) ||
|
306 |
-
( $crawler == 0 && array_key_exists($parent, $parents) )
|
307 |
-
) {
|
308 |
-
// Write out the section with just the parent/crawler setting saved.
|
309 |
-
fwrite($outfile, "[" . $title . "]\n");
|
310 |
-
fwrite($outfile, "Crawler=\"true\"\n");
|
311 |
-
}
|
312 |
-
}
|
313 |
-
|
314 |
-
// Reset our variables.
|
315 |
-
$crawler = 0;
|
316 |
-
$parent = '';
|
317 |
-
$title = substr($buffer, 1, strlen($buffer) - 2);
|
318 |
-
|
319 |
-
// We have three sections we need to copy verbatium so write out their
|
320 |
-
// headings immediatly instead of waiting to see if they are a crawler.
|
321 |
-
if ( $title == 'GJK_Browscap_Version' || $title == 'DefaultProperties' || $title == "*" ) {
|
322 |
-
fwrite($outfile, "[" . $title . "]\n");
|
323 |
-
}
|
324 |
-
|
325 |
-
break;
|
326 |
-
// A space or semi-colan means it's a comment.
|
327 |
-
case ' ':
|
328 |
-
case ';':
|
329 |
-
// Since we're hacking out lots of data the only comments we want to keep
|
330 |
-
// are the first few in the file before the first section is processed.
|
331 |
-
if ( $title == '' ) {
|
332 |
-
fwrite($outfile, $buffer . "\n");
|
333 |
-
}
|
334 |
-
|
335 |
-
break;
|
336 |
-
// Otherwise its a real setting line.
|
337 |
-
default:
|
338 |
-
// If the setting is for the crawler let's inidicate we found it and it's true.
|
339 |
-
// We can also set the parents array.
|
340 |
-
if ( $buffer == 'Crawler="true"' ) {
|
341 |
-
$crawler = 2;
|
342 |
-
$parents[ $title ] = true;
|
343 |
-
}
|
344 |
-
|
345 |
-
// If the setting for the parent then set it now.
|
346 |
-
if ( substr($buffer, 0, 7) == 'Parent=' ) {
|
347 |
-
$parent = substr($buffer, 8, -1);
|
348 |
-
}
|
349 |
-
|
350 |
-
// We have three sections we need to copy verbatium so write out their settings.
|
351 |
-
if ( $title == 'GJK_Browscap_Version' || $title == 'DefaultProperties' || $title == "*" ) {
|
352 |
-
fwrite($outfile, $buffer . "\n");
|
353 |
-
}
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
// Close the files.
|
358 |
-
fclose($outfile);
|
359 |
-
fclose($infile);
|
360 |
-
|
361 |
-
// Delete the temporary file.
|
362 |
-
unlink($TempFile);
|
363 |
-
|
364 |
-
// Check to see if an old (more than a minute old) lock file exists, if so delete it.
|
365 |
-
$cache_lock = $upload_dir['basedir'] . '/wp-statistics/cache.lock';
|
366 |
-
if ( file_exists($cache_lock) ) {
|
367 |
-
if ( time() - filemtime($cache_lock) > 60 ) {
|
368 |
-
unlink($cache_lock);
|
369 |
-
}
|
370 |
-
}
|
371 |
-
|
372 |
-
// Force the cache to be updated.
|
373 |
-
$bc->updateCache();
|
374 |
-
|
375 |
-
// Update the options to reflect the new download.
|
376 |
-
$WP_Statistics->update_option('last_browscap_dl', time());
|
377 |
-
$WP_Statistics->update_option('update_browscap', false);
|
378 |
|
379 |
-
|
380 |
-
__('browscap database updated successfully!', 'wp-statistics') .
|
381 |
-
"</strong></p></div>";
|
382 |
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
$fail = true;
|
391 |
-
$result = "<div class='updated settings-error'><p><strong>" . __(
|
392 |
-
'browscap database updated failed! Cache file too large, reverting to previous browscap.ini.',
|
393 |
-
'wp-statistics'
|
394 |
-
) . "</strong></p></div>";
|
395 |
-
} else {
|
396 |
-
// Check to make sure we don't resolve a typical user agent as a robot.
|
397 |
-
$test_browser = $bc->getBrowser(
|
398 |
-
"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
|
399 |
-
);
|
400 |
-
$crawler = $test_browser->Crawler;
|
401 |
-
|
402 |
-
if ( $crawler == true ) {
|
403 |
-
$fail = true;
|
404 |
-
$result = "<div class='updated settings-error'><p><strong>" . __(
|
405 |
-
'browscap database updated failed! New browscap.ini is mis-identifing user agents as crawlers, reverting to previous browscap.ini.',
|
406 |
-
'wp-statistics'
|
407 |
-
) . "</strong></p></div>";
|
408 |
-
}
|
409 |
-
}
|
410 |
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/browscap.ini');
|
415 |
-
}
|
416 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/cache.php') ) {
|
417 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/cache.php');
|
418 |
-
}
|
419 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/browscap.old') ) {
|
420 |
-
rename(
|
421 |
-
$upload_dir['basedir'] . '/wp-statistics/browscap.old',
|
422 |
-
$upload_dir['basedir'] . '/wp-statistics/browscap.ini'
|
423 |
-
);
|
424 |
-
}
|
425 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/cache.old') ) {
|
426 |
-
rename(
|
427 |
-
$upload_dir['basedir'] . '/wp-statistics/cache.old',
|
428 |
-
$upload_dir['basedir'] . '/wp-statistics/cache.php'
|
429 |
-
);
|
430 |
-
}
|
431 |
-
} else {
|
432 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/browscap.old') ) {
|
433 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/browscap.old');
|
434 |
-
}
|
435 |
-
if ( file_exists($upload_dir['basedir'] . '/wp-statistics/cache.old') ) {
|
436 |
-
unlink($upload_dir['basedir'] . '/wp-statistics/cache.old');
|
437 |
-
}
|
438 |
-
}
|
439 |
-
}
|
440 |
-
} else {
|
441 |
-
// Update the options to reflect the new download.
|
442 |
-
$WP_Statistics->update_option('last_browscap_dl', time());
|
443 |
-
$WP_Statistics->update_option('update_browscap', false);
|
444 |
-
|
445 |
-
$result = "<div class='updated settings-error'><p><strong>" .
|
446 |
-
__('browscap already at current version!', 'wp-statistics') .
|
447 |
-
"</strong></p></div>";
|
448 |
}
|
449 |
|
450 |
-
if ( $WP_Statistics->get_option('browscap_report') == true ) {
|
451 |
-
$blogname = get_bloginfo('name');
|
452 |
-
$blogemail = get_bloginfo('admin_email');
|
453 |
|
454 |
$headers[] = "From: $blogname <$blogemail>";
|
455 |
$headers[] = "MIME-Version: 1.0";
|
456 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
457 |
|
458 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
459 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
460 |
}
|
461 |
|
462 |
wp_mail(
|
463 |
-
$WP_Statistics->get_option('email_list'),
|
464 |
-
__('Browscap.ini update on', 'wp-statistics') . ' ' . $blogname,
|
465 |
-
$
|
466 |
$headers
|
467 |
);
|
468 |
}
|
469 |
|
470 |
-
//
|
|
|
|
|
|
|
471 |
return $result;
|
472 |
}
|
473 |
|
@@ -477,11 +267,10 @@ class WP_Statistics_Updates {
|
|
477 |
* @return string
|
478 |
*/
|
479 |
static function download_referrerspam() {
|
480 |
-
|
481 |
GLOBAL $WP_Statistics;
|
482 |
|
483 |
// If referrerspam is disabled, bail out.
|
484 |
-
if ( $WP_Statistics->get_option('referrerspam') == false ) {
|
485 |
return '';
|
486 |
}
|
487 |
|
@@ -489,16 +278,16 @@ class WP_Statistics_Updates {
|
|
489 |
$download_url = 'https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt';
|
490 |
|
491 |
// Download the file from MaxMind, this places it in a temporary location.
|
492 |
-
$referrerspamlist = file_get_contents($download_url);
|
493 |
if ( $referrerspamlist === false ) {
|
494 |
$referrerspamlist = '';
|
495 |
}
|
496 |
|
497 |
-
if ( $referrerspamlist != '' || $WP_Statistics->get_option('referrerspamlist') != '' ) {
|
498 |
-
$WP_Statistics->update_option('referrerspamlist', $referrerspamlist);
|
499 |
}
|
500 |
|
501 |
-
$WP_Statistics->update_option('update_referrerspam', false);
|
502 |
|
503 |
return;
|
504 |
}
|
@@ -522,24 +311,24 @@ class WP_Statistics_Updates {
|
|
522 |
// Try create a new reader instance.
|
523 |
try {
|
524 |
$upload_dir = wp_upload_dir();
|
525 |
-
$reader = new Reader($upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb');
|
526 |
} catch ( Exception $e ) {
|
527 |
return "<div class='updated settings-error'><p><strong>" . __(
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
}
|
532 |
|
533 |
$count = 0;
|
534 |
|
535 |
// Loop through all the missing rows and update them if we find a locaiton for them.
|
536 |
foreach ( $result as $item ) {
|
537 |
-
$count++;
|
538 |
|
539 |
// If the IP address is only a hash, don't bother updating the record.
|
540 |
-
if ( substr($item->ip, 0, 6) != '#hash#' ) {
|
541 |
try {
|
542 |
-
$record = $reader->country($item->ip);
|
543 |
$location = $record->country->isoCode;
|
544 |
if ( $location == "" ) {
|
545 |
$location = "000";
|
@@ -558,7 +347,7 @@ class WP_Statistics_Updates {
|
|
558 |
}
|
559 |
|
560 |
return "<div class='updated settings-error'><p><strong>" .
|
561 |
-
sprintf(__('Updated %s GeoIP records in the visitors database.', 'wp-statistics'), $count) .
|
562 |
"</strong></p></div>";
|
563 |
}
|
564 |
}
|
1 |
<?php
|
2 |
|
3 |
+
use BrowscapPHP\Browscap;
|
4 |
+
use BrowscapPHP\BrowscapUpdater;
|
5 |
+
use BrowscapPHP\Helper\IniLoader;
|
6 |
+
use WurflCache\Adapter\File;
|
7 |
use GeoIp2\Database\Reader;
|
8 |
|
9 |
/**
|
17 |
* @return string
|
18 |
*/
|
19 |
static function download_geoip() {
|
|
|
20 |
GLOBAL $WP_Statistics;
|
21 |
|
22 |
+
// We need the download_url() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out.
|
23 |
+
if ( ! function_exists( 'download_url' ) ) {
|
24 |
+
include( ABSPATH . 'wp-admin/includes/file.php' );
|
25 |
+
}
|
26 |
+
|
27 |
+
// We need the wp_generate_password() function.
|
28 |
+
if ( ! function_exists( 'wp_generate_password' ) ) {
|
29 |
+
include( ABSPATH . 'wp-includes/pluggable.php' );
|
30 |
+
}
|
31 |
+
|
32 |
+
// We need the gzopen() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out.
|
33 |
// Also stop trying to update the database as it just won't work :)
|
34 |
+
if ( false === function_exists( 'gzopen' ) ) {
|
35 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
36 |
|
37 |
$result = "<div class='updated settings-error'><p><strong>" .
|
38 |
+
__( 'Error the gzopen() function do not exist!', 'wp-statistics' ) .
|
39 |
"</strong></p></div>";
|
40 |
|
41 |
return $result;
|
42 |
}
|
43 |
|
44 |
// If GeoIP is disabled, bail out.
|
45 |
+
if ( $WP_Statistics->get_option( 'geoip' ) == false ) {
|
46 |
return '';
|
47 |
}
|
48 |
|
49 |
// This is the location of the file to download.
|
50 |
$download_url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz';
|
51 |
+
$response = wp_remote_get( $download_url );
|
52 |
+
|
53 |
+
// Change download url if the maxmind.com doesn't response.
|
54 |
+
if ( wp_remote_retrieve_response_code( $response ) != '200' ) {
|
55 |
+
$download_url = 'https://raw.githubusercontent.com/wp-statistics/GeoLite2-Country/master/GeoLite2-Country.mmdb.gz';
|
56 |
+
}
|
57 |
|
58 |
+
// Get the upload directory from WordPress.
|
59 |
$upload_dir = wp_upload_dir();
|
60 |
|
61 |
// Create a variable with the name of the database file to download.
|
62 |
$DBFile = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
|
63 |
|
64 |
// Check to see if the subdirectory we're going to upload to exists, if not create it.
|
65 |
+
if ( ! file_exists( $upload_dir['basedir'] . '/wp-statistics' ) ) {
|
66 |
+
if ( ! @mkdir( $upload_dir['basedir'] . '/wp-statistics', 0755 ) ) {
|
67 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
68 |
|
69 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
70 |
__(
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
if ( ! is_writable( $upload_dir['basedir'] . '/wp-statistics' ) ) {
|
82 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
83 |
|
84 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
85 |
__(
|
93 |
}
|
94 |
|
95 |
// Download the file from MaxMind, this places it in a temporary location.
|
96 |
+
$TempFile = download_url( $download_url );
|
97 |
|
98 |
// If we failed, through a message, otherwise proceed.
|
99 |
+
if ( is_wp_error( $TempFile ) ) {
|
100 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
101 |
+
|
102 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
103 |
+
__( 'Error downloading GeoIP database from: %s - %s', 'wp-statistics' ),
|
104 |
$download_url,
|
105 |
$TempFile->get_error_message()
|
106 |
) . "</strong></p></div>";
|
107 |
} else {
|
108 |
// Open the downloaded file to unzip it.
|
109 |
+
$ZipHandle = gzopen( $TempFile, 'rb' );
|
110 |
|
111 |
// Create th new file to unzip to.
|
112 |
+
$DBfh = fopen( $DBFile, 'wb' );
|
113 |
|
114 |
// If we failed to open the downloaded file, through an error and remove the temporary file. Otherwise do the actual unzip.
|
115 |
if ( ! $ZipHandle ) {
|
116 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
117 |
+
|
118 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
119 |
+
__( 'Error could not open downloaded GeoIP database for reading: %s', 'wp-statistics' ),
|
120 |
$TempFile
|
121 |
) . "</strong></p></div>";
|
122 |
|
123 |
+
unlink( $TempFile );
|
124 |
} else {
|
125 |
// If we failed to open the new file, throw and error and remove the temporary file. Otherwise actually do the unzip.
|
126 |
if ( ! $DBfh ) {
|
127 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
128 |
+
|
129 |
$result = "<div class='updated settings-error'><p><strong>" . sprintf(
|
130 |
+
__( 'Error could not open destination GeoIP database for writing %s', 'wp-statistics' ),
|
131 |
$DBFile
|
132 |
) . "</strong></p></div>";
|
133 |
+
unlink( $TempFile );
|
134 |
} else {
|
135 |
+
while ( ( $data = gzread( $ZipHandle, 4096 ) ) != false ) {
|
136 |
+
fwrite( $DBfh, $data );
|
137 |
}
|
138 |
|
139 |
// Close the files.
|
140 |
+
gzclose( $ZipHandle );
|
141 |
+
fclose( $DBfh );
|
142 |
|
143 |
// Delete the temporary file.
|
144 |
+
unlink( $TempFile );
|
145 |
|
146 |
// Display the success message.
|
147 |
$result = "<div class='updated settings-error'><p><strong>" .
|
148 |
+
__( 'GeoIP Database updated successfully!', 'wp-statistics' ) .
|
149 |
"</strong></p></div>";
|
150 |
|
151 |
// Update the options to reflect the new download.
|
152 |
+
$WP_Statistics->update_option( 'last_geoip_dl', time() );
|
153 |
+
$WP_Statistics->update_option( 'update_geoip', false );
|
154 |
|
155 |
// Populate any missing GeoIP information if the user has selected the option.
|
156 |
+
if ( $WP_Statistics->get_option( 'geoip' ) &&
|
157 |
wp_statistics_geoip_supported() &&
|
158 |
+
$WP_Statistics->get_option( 'auto_pop' )
|
159 |
) {
|
160 |
$result .= WP_Statistics_Updates::populate_geoip_info();
|
161 |
}
|
163 |
}
|
164 |
}
|
165 |
|
166 |
+
if ( $WP_Statistics->get_option( 'geoip_report' ) == true ) {
|
167 |
+
$blogname = get_bloginfo( 'name' );
|
168 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
169 |
|
170 |
$headers[] = "From: $blogname <$blogemail>";
|
171 |
$headers[] = "MIME-Version: 1.0";
|
172 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
173 |
|
174 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
175 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
176 |
}
|
177 |
|
178 |
wp_mail(
|
179 |
+
$WP_Statistics->get_option( 'email_list' ),
|
180 |
+
__( 'GeoIP update on', 'wp-statistics' ) . ' ' . $blogname,
|
181 |
$result,
|
182 |
$headers
|
183 |
);
|
184 |
}
|
185 |
|
186 |
+
// All of the messages displayed above are stored in a string, now it's time to actually output the messages.
|
187 |
return $result;
|
188 |
}
|
189 |
|
191 |
* This function downloads the browscap database from browscap.org.
|
192 |
*
|
193 |
* @return string
|
|
|
194 |
*/
|
195 |
static function download_browscap() {
|
196 |
global $WP_Statistics;
|
197 |
|
198 |
+
// Changing PHP memory limits
|
199 |
+
ini_set('memory_limit', '256M');
|
200 |
+
|
201 |
// We need the download_url() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out.
|
202 |
+
if ( ! function_exists( 'download_url' ) ) {
|
203 |
include( ABSPATH . 'wp-admin/includes/file.php' );
|
204 |
}
|
205 |
|
206 |
// If browscap is disabled, bail out.
|
207 |
+
if ( $WP_Statistics->get_option( 'browscap' ) == false ) {
|
208 |
return '';
|
209 |
}
|
210 |
|
|
|
|
|
|
|
|
|
211 |
// Get the upload directory from WordPress.
|
212 |
$upload_dir = wp_upload_dir();
|
213 |
|
214 |
// Check to see if the subdirectory we're going to upload to exists, if not create it.
|
215 |
+
if ( ! file_exists( $upload_dir['basedir'] . '/wp-statistics' ) ) {
|
216 |
+
mkdir( $upload_dir['basedir'] . '/wp-statistics' );
|
217 |
}
|
218 |
|
219 |
+
// First if all update the option to reflect the new download.
|
220 |
+
$WP_Statistics->update_option( 'update_browscap', false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
+
$adapter = new File( array( File::DIR => $upload_dir['basedir'] . '/wp-statistics' ) );
|
|
|
|
|
223 |
|
224 |
+
try {
|
225 |
+
$browscap_updater = new BrowscapUpdater();
|
226 |
+
$browscap_updater->setCache( $adapter );
|
227 |
+
$browscap_updater->update( IniLoader::PHP_INI );
|
228 |
|
229 |
+
// Update browscap last download time
|
230 |
+
$WP_Statistics->update_option( 'last_browscap_dl', time() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
+
$message = __( 'Browscap database updated successfully!', 'wp-statistics' );
|
233 |
+
} catch ( Exception $e ) {
|
234 |
+
$message = sprintf( __( 'Browscap database updated failed! %s', 'wp-statistics' ), $e->getMessage() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
|
237 |
+
if ( $WP_Statistics->get_option( 'browscap_report' ) == true ) {
|
238 |
+
$blogname = get_bloginfo( 'name' );
|
239 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
240 |
|
241 |
$headers[] = "From: $blogname <$blogemail>";
|
242 |
$headers[] = "MIME-Version: 1.0";
|
243 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
244 |
|
245 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
246 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
247 |
}
|
248 |
|
249 |
wp_mail(
|
250 |
+
$WP_Statistics->get_option( 'email_list' ),
|
251 |
+
__( 'Browscap.ini update on', 'wp-statistics' ) . ' ' . $blogname,
|
252 |
+
$message,
|
253 |
$headers
|
254 |
);
|
255 |
}
|
256 |
|
257 |
+
// Generate admin notice message
|
258 |
+
$result = "<div class='updated settings-error'><p><strong>" . $message . "</strong></p></div>";
|
259 |
+
|
260 |
+
// All of the messages displayed above are stored in a string, now it's time to actually output the messages.
|
261 |
return $result;
|
262 |
}
|
263 |
|
267 |
* @return string
|
268 |
*/
|
269 |
static function download_referrerspam() {
|
|
|
270 |
GLOBAL $WP_Statistics;
|
271 |
|
272 |
// If referrerspam is disabled, bail out.
|
273 |
+
if ( $WP_Statistics->get_option( 'referrerspam' ) == false ) {
|
274 |
return '';
|
275 |
}
|
276 |
|
278 |
$download_url = 'https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt';
|
279 |
|
280 |
// Download the file from MaxMind, this places it in a temporary location.
|
281 |
+
$referrerspamlist = file_get_contents( $download_url );
|
282 |
if ( $referrerspamlist === false ) {
|
283 |
$referrerspamlist = '';
|
284 |
}
|
285 |
|
286 |
+
if ( $referrerspamlist != '' || $WP_Statistics->get_option( 'referrerspamlist' ) != '' ) {
|
287 |
+
$WP_Statistics->update_option( 'referrerspamlist', $referrerspamlist );
|
288 |
}
|
289 |
|
290 |
+
$WP_Statistics->update_option( 'update_referrerspam', false );
|
291 |
|
292 |
return;
|
293 |
}
|
311 |
// Try create a new reader instance.
|
312 |
try {
|
313 |
$upload_dir = wp_upload_dir();
|
314 |
+
$reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' );
|
315 |
} catch ( Exception $e ) {
|
316 |
return "<div class='updated settings-error'><p><strong>" . __(
|
317 |
+
'Unable to load the GeoIP database, make sure you have downloaded it in the settings page.',
|
318 |
+
'wp-statistics'
|
319 |
+
) . "</strong></p></div>";
|
320 |
}
|
321 |
|
322 |
$count = 0;
|
323 |
|
324 |
// Loop through all the missing rows and update them if we find a locaiton for them.
|
325 |
foreach ( $result as $item ) {
|
326 |
+
$count ++;
|
327 |
|
328 |
// If the IP address is only a hash, don't bother updating the record.
|
329 |
+
if ( substr( $item->ip, 0, 6 ) != '#hash#' ) {
|
330 |
try {
|
331 |
+
$record = $reader->country( $item->ip );
|
332 |
$location = $record->country->isoCode;
|
333 |
if ( $location == "" ) {
|
334 |
$location = "000";
|
347 |
}
|
348 |
|
349 |
return "<div class='updated settings-error'><p><strong>" .
|
350 |
+
sprintf( __( 'Updated %s GeoIP records in the visitors database.', 'wp-statistics' ), $count ) .
|
351 |
"</strong></p></div>";
|
352 |
}
|
353 |
}
|
includes/classes/class-wp-statistics-welcome.php
CHANGED
@@ -4,6 +4,9 @@
|
|
4 |
* Class WP_Statistics_Welcome
|
5 |
*/
|
6 |
class WP_Statistics_Welcome {
|
|
|
|
|
|
|
7 |
public static function init() {
|
8 |
global $WP_Statistics;
|
9 |
if ( $WP_Statistics->get_option( 'show_welcome_page', false ) and ( strpos( $_SERVER['REQUEST_URI'], '/wp-admin/index.php' ) !== false or ( isset( $_GET['page'] ) and $_GET['page'] == 'wps_overview_page' ) ) ) {
|
@@ -24,7 +27,7 @@ class WP_Statistics_Welcome {
|
|
24 |
* Register menu
|
25 |
*/
|
26 |
public static function menu() {
|
27 |
-
add_submenu_page(
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -39,7 +42,7 @@ class WP_Statistics_Welcome {
|
|
39 |
'1.0'
|
40 |
);
|
41 |
|
42 |
-
include( WP_Statistics::$reg['plugin-dir'] . "includes/templates/
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -61,6 +64,9 @@ class WP_Statistics_Welcome {
|
|
61 |
}
|
62 |
}
|
63 |
|
|
|
|
|
|
|
64 |
public static function show_change_log() {
|
65 |
$response = wp_remote_get( 'https://api.github.com/repos/wp-statistics/wp-statistics/releases/latest' );
|
66 |
|
4 |
* Class WP_Statistics_Welcome
|
5 |
*/
|
6 |
class WP_Statistics_Welcome {
|
7 |
+
/**
|
8 |
+
* Initial
|
9 |
+
*/
|
10 |
public static function init() {
|
11 |
global $WP_Statistics;
|
12 |
if ( $WP_Statistics->get_option( 'show_welcome_page', false ) and ( strpos( $_SERVER['REQUEST_URI'], '/wp-admin/index.php' ) !== false or ( isset( $_GET['page'] ) and $_GET['page'] == 'wps_overview_page' ) ) ) {
|
27 |
* Register menu
|
28 |
*/
|
29 |
public static function menu() {
|
30 |
+
add_submenu_page( __( 'WP-Statistics Welcome', 'wp-statistics' ), __( 'WP-Statistics Welcome', 'wp-statistics' ), __( 'WP-Statistics Welcome', 'wp-statistics' ), 'administrator', 'wps_welcome', 'WP_Statistics_Welcome::page_callback' );
|
31 |
}
|
32 |
|
33 |
/**
|
42 |
'1.0'
|
43 |
);
|
44 |
|
45 |
+
include( WP_Statistics::$reg['plugin-dir'] . "includes/templates/welcomes/last-version.php" );
|
46 |
}
|
47 |
|
48 |
/**
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* Show change log
|
69 |
+
*/
|
70 |
public static function show_change_log() {
|
71 |
$response = wp_remote_get( 'https://api.github.com/repos/wp-statistics/wp-statistics/releases/latest' );
|
72 |
|
includes/classes/class-wp-statistics-widget.php
CHANGED
@@ -8,8 +8,8 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
8 |
public function __construct() {
|
9 |
parent::__construct(
|
10 |
'WP_Statistics_Widget', // Base ID
|
11 |
-
__('Statistics', 'wp-statistics'), // Name
|
12 |
-
array( 'description' => __('Show site stats in sidebar.', 'wp-statistics') ) // Args
|
13 |
);
|
14 |
}
|
15 |
|
@@ -21,8 +21,8 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
21 |
*/
|
22 |
public function widget( $args, $instance ) {
|
23 |
global $WP_Statistics;
|
24 |
-
extract($args);
|
25 |
-
$widget_options = $WP_Statistics->get_option('widget');
|
26 |
|
27 |
echo $before_widget;
|
28 |
echo $before_title . $widget_options['name_widget'] . $after_title;
|
@@ -30,148 +30,148 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
30 |
|
31 |
if ( $widget_options['useronline_widget'] ) {
|
32 |
echo '<li>';
|
33 |
-
echo '<label>' . __('Online Users', 'wp-statistics') . ': </label>';
|
34 |
-
echo number_format_i18n(wp_statistics_useronline());
|
35 |
echo '</li>';
|
36 |
}
|
37 |
|
38 |
if ( $widget_options['tvisit_widget'] ) {
|
39 |
echo '<li>';
|
40 |
-
echo '<label>' . __('Today\'s Visits', 'wp-statistics') . ': </label>';
|
41 |
-
echo number_format_i18n(wp_statistics_visit('today'));
|
42 |
echo '</li>';
|
43 |
}
|
44 |
|
45 |
if ( $widget_options['tvisitor_widget'] ) {
|
46 |
echo '<li>';
|
47 |
-
echo '<label>' . __('Today\'s Visitors', 'wp-statistics') . ': </label>';
|
48 |
-
echo number_format_i18n(wp_statistics_visitor('today', null, true));
|
49 |
echo '</li>';
|
50 |
}
|
51 |
|
52 |
if ( $widget_options['yvisit_widget'] ) {
|
53 |
echo '<li>';
|
54 |
-
echo '<label>' . __('Yesterday\'s Visits', 'wp-statistics') . ': </label>';
|
55 |
-
echo number_format_i18n(wp_statistics_visit('yesterday'));
|
56 |
echo '</li>';
|
57 |
}
|
58 |
|
59 |
if ( $widget_options['yvisitor_widget'] ) {
|
60 |
echo '<li>';
|
61 |
-
echo '<label>' . __('Yesterday\'s Visitors', 'wp-statistics') . ': </label>';
|
62 |
-
echo number_format_i18n(wp_statistics_visitor('yesterday', null, true));
|
63 |
echo '</li>';
|
64 |
}
|
65 |
|
66 |
if ( $widget_options['wvisit_widget'] ) {
|
67 |
echo '<li>';
|
68 |
-
echo '<label>' . __('Last 7 Days Visits', 'wp-statistics') . ': </label>';
|
69 |
-
echo number_format_i18n(wp_statistics_visit('week'));
|
70 |
echo '</li>';
|
71 |
}
|
72 |
|
73 |
if ( $widget_options['mvisit_widget'] ) {
|
74 |
echo '<li>';
|
75 |
-
echo '<label>' . __('Last 30 Days Visits', 'wp-statistics') . ': </label>';
|
76 |
-
echo number_format_i18n(wp_statistics_visit('month'));
|
77 |
echo '</li>';
|
78 |
}
|
79 |
|
80 |
if ( $widget_options['ysvisit_widget'] ) {
|
81 |
echo '<li>';
|
82 |
-
echo '<label>' . __('Last 365 Days Visits', 'wp-statistics') . ': </label>';
|
83 |
-
echo number_format_i18n(wp_statistics_visit('year'));
|
84 |
echo '</li>';
|
85 |
}
|
86 |
|
87 |
if ( $widget_options['ttvisit_widget'] ) {
|
88 |
echo '<li>';
|
89 |
-
echo '<label>' . __('Total Visits', 'wp-statistics') . ': </label>';
|
90 |
-
echo number_format_i18n(wp_statistics_visit('total'));
|
91 |
echo '</li>';
|
92 |
}
|
93 |
|
94 |
if ( $widget_options['ttvisitor_widget'] ) {
|
95 |
echo '<li>';
|
96 |
-
echo '<label>' . __('Total Visitors', 'wp-statistics') . ': </label>';
|
97 |
-
echo number_format_i18n(wp_statistics_visitor('total', null, true));
|
98 |
echo '</li>';
|
99 |
}
|
100 |
|
101 |
if ( $widget_options['tpviews_widget'] ) {
|
102 |
echo '<li>';
|
103 |
-
echo '<label>' . __('Total Page Views', 'wp-statistics') . ': </label>';
|
104 |
-
echo number_format_i18n(wp_statistics_pages('total'));
|
105 |
echo '</li>';
|
106 |
}
|
107 |
|
108 |
if ( $widget_options['ser_widget'] ) {
|
109 |
|
110 |
echo '<li>';
|
111 |
-
echo '<label>' . __('Search Engine Referrals', 'wp-statistics') . ': </label>';
|
112 |
-
echo number_format_i18n(wp_statistics_searchengine($widget_options['select_se']));
|
113 |
echo '</li>';
|
114 |
}
|
115 |
|
116 |
if ( $widget_options['tp_widget'] ) {
|
117 |
echo '<li>';
|
118 |
-
echo '<label>' . __('Total Posts', 'wp-statistics') . ': </label>';
|
119 |
-
echo number_format_i18n(wp_statistics_countposts());
|
120 |
echo '</li>';
|
121 |
}
|
122 |
|
123 |
if ( $widget_options['tpg_widget'] ) {
|
124 |
echo '<li>';
|
125 |
-
echo '<label>' . __('Total Pages', 'wp-statistics') . ': </label>';
|
126 |
-
echo number_format_i18n(wp_statistics_countpages());
|
127 |
echo '</li>';
|
128 |
}
|
129 |
|
130 |
if ( $widget_options['tc_widget'] ) {
|
131 |
echo '<li>';
|
132 |
-
echo '<label>' . __('Total Comments', 'wp-statistics') . ': </label>';
|
133 |
-
echo number_format_i18n(wp_statistics_countcomment());
|
134 |
echo '</li>';
|
135 |
}
|
136 |
|
137 |
if ( $widget_options['ts_widget'] ) {
|
138 |
echo '<li>';
|
139 |
-
echo '<label>' . __('Total Spams', 'wp-statistics') . ': </label>';
|
140 |
echo wp_statistics_countspam();
|
141 |
echo '</li>';
|
142 |
}
|
143 |
|
144 |
if ( $widget_options['tu_widget'] ) {
|
145 |
echo '<li>';
|
146 |
-
echo '<label>' . __('Total Users', 'wp-statistics') . ': </label>';
|
147 |
-
echo number_format_i18n(wp_statistics_countusers());
|
148 |
echo '</li>';
|
149 |
}
|
150 |
|
151 |
if ( $widget_options['ap_widget'] ) {
|
152 |
echo '<li>';
|
153 |
-
echo '<label>' . __('Average Posts', 'wp-statistics') . ': </label>';
|
154 |
-
echo number_format_i18n(wp_statistics_average_post());
|
155 |
echo '</li>';
|
156 |
}
|
157 |
|
158 |
if ( $widget_options['ac_widget'] ) {
|
159 |
echo '<li>';
|
160 |
-
echo '<label>' . __('Average Comments', 'wp-statistics') . ': </label>';
|
161 |
-
echo number_format_i18n(wp_statistics_average_comment());
|
162 |
echo '</li>';
|
163 |
}
|
164 |
|
165 |
if ( $widget_options['au_widget'] ) {
|
166 |
echo '<li>';
|
167 |
-
echo '<label>' . __('Average Users', 'wp-statistics') . ': </label>';
|
168 |
-
echo number_format_i18n(wp_statistics_average_registeruser());
|
169 |
echo '</li>';
|
170 |
}
|
171 |
|
172 |
if ( $widget_options['lpd_widget'] ) {
|
173 |
echo '<li>';
|
174 |
-
echo '<label>' . __('Last Post Date', 'wp-statistics') . ': </label>';
|
175 |
echo wp_statistics_lastpostdate();
|
176 |
echo '</li>';
|
177 |
}
|
@@ -191,43 +191,43 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
191 |
public function update( $new_instance, $old_instance ) {
|
192 |
GLOBAL $WP_Statistics;
|
193 |
|
194 |
-
if ( array_key_exists('wp_statistics_control_widget_submit', $_POST) ) {
|
195 |
$keys = array(
|
196 |
-
'name_widget'
|
197 |
'useronline_widget' => 'useronline_widget',
|
198 |
-
'tvisit_widget'
|
199 |
-
'tvisitor_widget'
|
200 |
-
'yvisit_widget'
|
201 |
-
'yvisitor_widget'
|
202 |
-
'wvisit_widget'
|
203 |
-
'mvisit_widget'
|
204 |
-
'ysvisit_widget'
|
205 |
-
'ttvisit_widget'
|
206 |
-
'ttvisitor_widget'
|
207 |
-
'tpviews_widget'
|
208 |
-
'ser_widget'
|
209 |
-
'select_se'
|
210 |
-
'tp_widget'
|
211 |
-
'tpg_widget'
|
212 |
-
'tc_widget'
|
213 |
-
'ts_widget'
|
214 |
-
'tu_widget'
|
215 |
-
'ap_widget'
|
216 |
-
'ac_widget'
|
217 |
-
'au_widget'
|
218 |
-
'lpd_widget'
|
219 |
-
'select_lps'
|
220 |
);
|
221 |
|
222 |
foreach ( $keys as $key => $post ) {
|
223 |
-
if ( array_key_exists($post, $_POST) ) {
|
224 |
$widget_options[ $key ] = $_POST[ $post ];
|
225 |
} else {
|
226 |
$widget_options[ $key ] = '';
|
227 |
}
|
228 |
}
|
229 |
|
230 |
-
$WP_Statistics->update_option('widget', $widget_options);
|
231 |
}
|
232 |
|
233 |
return array();
|
@@ -242,105 +242,105 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
242 |
*/
|
243 |
public function form( $instance ) {
|
244 |
GLOBAL $WP_Statistics;
|
245 |
-
$widget_options = $WP_Statistics->get_option('widget');
|
246 |
?>
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
<?php _e('Items', 'wp-statistics'); ?>:<br/>
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
'on',
|
259 |
$widget_options['useronline_widget']
|
260 |
); ?>/>
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
'on',
|
266 |
$widget_options['tvisit_widget']
|
267 |
); ?>/>
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
'on',
|
273 |
$widget_options['tvisitor_widget']
|
274 |
); ?>/>
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
'on',
|
280 |
$widget_options['yvisit_widget']
|
281 |
); ?>/>
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
'on',
|
287 |
$widget_options['yvisitor_widget']
|
288 |
); ?>/>
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
'on',
|
294 |
$widget_options['wvisit_widget']
|
295 |
); ?>/>
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
'on',
|
301 |
$widget_options['mvisit_widget']
|
302 |
); ?>/>
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
'on',
|
308 |
$widget_options['ysvisit_widget']
|
309 |
); ?>/>
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
'on',
|
315 |
$widget_options['ttvisit_widget']
|
316 |
); ?>/>
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
'on',
|
322 |
$widget_options['ttvisitor_widget']
|
323 |
); ?>/>
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
'on',
|
329 |
$widget_options['tpviews_widget']
|
330 |
); ?>/>
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
'on',
|
336 |
$widget_options['ser_widget']
|
337 |
); ?>/>
|
338 |
-
|
339 |
|
340 |
-
|
341 |
echo "display: none;";
|
342 |
} ?>">
|
343 |
-
<?php _e('Select type of search engine', 'wp-statistics'); ?>:<br/>
|
344 |
<?php
|
345 |
$search_engines = wp_statistics_searchengine_list();
|
346 |
|
@@ -350,86 +350,86 @@ class WP_Statistics_Widget extends WP_Widget {
|
|
350 |
'" name="select_se" value="' .
|
351 |
$se['tag'] .
|
352 |
'" ';
|
353 |
-
checked($se['tag'], $widget_options['select_se']);
|
354 |
echo "/>\n";
|
355 |
echo ' <label for="' . $se['name'] . '">' . $se['translated'] . "</label>\n";
|
356 |
echo "\n";
|
357 |
}
|
358 |
?>
|
359 |
-
|
360 |
'all',
|
361 |
$widget_options['select_se']
|
362 |
); ?>/>
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
'on',
|
369 |
$widget_options['tp_widget']
|
370 |
); ?>/>
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
'on',
|
376 |
$widget_options['tpg_widget']
|
377 |
); ?>/>
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
'on',
|
383 |
$widget_options['tc_widget']
|
384 |
); ?>/>
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
'on',
|
390 |
$widget_options['ts_widget']
|
391 |
); ?>/>
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
'on',
|
397 |
$widget_options['tu_widget']
|
398 |
); ?>/>
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
'on',
|
404 |
$widget_options['ap_widget']
|
405 |
); ?>/>
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
'on',
|
411 |
$widget_options['ac_widget']
|
412 |
); ?>/>
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
'on',
|
418 |
$widget_options['au_widget']
|
419 |
); ?>/>
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
'on',
|
425 |
$widget_options['lpd_widget']
|
426 |
); ?>/>
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
|
431 |
-
|
432 |
-
|
433 |
<?php
|
434 |
}
|
435 |
}
|
8 |
public function __construct() {
|
9 |
parent::__construct(
|
10 |
'WP_Statistics_Widget', // Base ID
|
11 |
+
__( 'Statistics', 'wp-statistics' ), // Name
|
12 |
+
array( 'description' => __( 'Show site stats in sidebar.', 'wp-statistics' ) ) // Args
|
13 |
);
|
14 |
}
|
15 |
|
21 |
*/
|
22 |
public function widget( $args, $instance ) {
|
23 |
global $WP_Statistics;
|
24 |
+
extract( $args );
|
25 |
+
$widget_options = $WP_Statistics->get_option( 'widget' );
|
26 |
|
27 |
echo $before_widget;
|
28 |
echo $before_title . $widget_options['name_widget'] . $after_title;
|
30 |
|
31 |
if ( $widget_options['useronline_widget'] ) {
|
32 |
echo '<li>';
|
33 |
+
echo '<label>' . __( 'Online Users', 'wp-statistics' ) . ': </label>';
|
34 |
+
echo number_format_i18n( wp_statistics_useronline() );
|
35 |
echo '</li>';
|
36 |
}
|
37 |
|
38 |
if ( $widget_options['tvisit_widget'] ) {
|
39 |
echo '<li>';
|
40 |
+
echo '<label>' . __( 'Today\'s Visits', 'wp-statistics' ) . ': </label>';
|
41 |
+
echo number_format_i18n( wp_statistics_visit( 'today' ) );
|
42 |
echo '</li>';
|
43 |
}
|
44 |
|
45 |
if ( $widget_options['tvisitor_widget'] ) {
|
46 |
echo '<li>';
|
47 |
+
echo '<label>' . __( 'Today\'s Visitors', 'wp-statistics' ) . ': </label>';
|
48 |
+
echo number_format_i18n( wp_statistics_visitor( 'today', null, true ) );
|
49 |
echo '</li>';
|
50 |
}
|
51 |
|
52 |
if ( $widget_options['yvisit_widget'] ) {
|
53 |
echo '<li>';
|
54 |
+
echo '<label>' . __( 'Yesterday\'s Visits', 'wp-statistics' ) . ': </label>';
|
55 |
+
echo number_format_i18n( wp_statistics_visit( 'yesterday' ) );
|
56 |
echo '</li>';
|
57 |
}
|
58 |
|
59 |
if ( $widget_options['yvisitor_widget'] ) {
|
60 |
echo '<li>';
|
61 |
+
echo '<label>' . __( 'Yesterday\'s Visitors', 'wp-statistics' ) . ': </label>';
|
62 |
+
echo number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) );
|
63 |
echo '</li>';
|
64 |
}
|
65 |
|
66 |
if ( $widget_options['wvisit_widget'] ) {
|
67 |
echo '<li>';
|
68 |
+
echo '<label>' . __( 'Last 7 Days Visits', 'wp-statistics' ) . ': </label>';
|
69 |
+
echo number_format_i18n( wp_statistics_visit( 'week' ) );
|
70 |
echo '</li>';
|
71 |
}
|
72 |
|
73 |
if ( $widget_options['mvisit_widget'] ) {
|
74 |
echo '<li>';
|
75 |
+
echo '<label>' . __( 'Last 30 Days Visits', 'wp-statistics' ) . ': </label>';
|
76 |
+
echo number_format_i18n( wp_statistics_visit( 'month' ) );
|
77 |
echo '</li>';
|
78 |
}
|
79 |
|
80 |
if ( $widget_options['ysvisit_widget'] ) {
|
81 |
echo '<li>';
|
82 |
+
echo '<label>' . __( 'Last 365 Days Visits', 'wp-statistics' ) . ': </label>';
|
83 |
+
echo number_format_i18n( wp_statistics_visit( 'year' ) );
|
84 |
echo '</li>';
|
85 |
}
|
86 |
|
87 |
if ( $widget_options['ttvisit_widget'] ) {
|
88 |
echo '<li>';
|
89 |
+
echo '<label>' . __( 'Total Visits', 'wp-statistics' ) . ': </label>';
|
90 |
+
echo number_format_i18n( wp_statistics_visit( 'total' ) );
|
91 |
echo '</li>';
|
92 |
}
|
93 |
|
94 |
if ( $widget_options['ttvisitor_widget'] ) {
|
95 |
echo '<li>';
|
96 |
+
echo '<label>' . __( 'Total Visitors', 'wp-statistics' ) . ': </label>';
|
97 |
+
echo number_format_i18n( wp_statistics_visitor( 'total', null, true ) );
|
98 |
echo '</li>';
|
99 |
}
|
100 |
|
101 |
if ( $widget_options['tpviews_widget'] ) {
|
102 |
echo '<li>';
|
103 |
+
echo '<label>' . __( 'Total Page Views', 'wp-statistics' ) . ': </label>';
|
104 |
+
echo number_format_i18n( wp_statistics_pages( 'total' ) );
|
105 |
echo '</li>';
|
106 |
}
|
107 |
|
108 |
if ( $widget_options['ser_widget'] ) {
|
109 |
|
110 |
echo '<li>';
|
111 |
+
echo '<label>' . __( 'Search Engine Referrals', 'wp-statistics' ) . ': </label>';
|
112 |
+
echo number_format_i18n( wp_statistics_searchengine( $widget_options['select_se'] ) );
|
113 |
echo '</li>';
|
114 |
}
|
115 |
|
116 |
if ( $widget_options['tp_widget'] ) {
|
117 |
echo '<li>';
|
118 |
+
echo '<label>' . __( 'Total Posts', 'wp-statistics' ) . ': </label>';
|
119 |
+
echo number_format_i18n( wp_statistics_countposts() );
|
120 |
echo '</li>';
|
121 |
}
|
122 |
|
123 |
if ( $widget_options['tpg_widget'] ) {
|
124 |
echo '<li>';
|
125 |
+
echo '<label>' . __( 'Total Pages', 'wp-statistics' ) . ': </label>';
|
126 |
+
echo number_format_i18n( wp_statistics_countpages() );
|
127 |
echo '</li>';
|
128 |
}
|
129 |
|
130 |
if ( $widget_options['tc_widget'] ) {
|
131 |
echo '<li>';
|
132 |
+
echo '<label>' . __( 'Total Comments', 'wp-statistics' ) . ': </label>';
|
133 |
+
echo number_format_i18n( wp_statistics_countcomment() );
|
134 |
echo '</li>';
|
135 |
}
|
136 |
|
137 |
if ( $widget_options['ts_widget'] ) {
|
138 |
echo '<li>';
|
139 |
+
echo '<label>' . __( 'Total Spams', 'wp-statistics' ) . ': </label>';
|
140 |
echo wp_statistics_countspam();
|
141 |
echo '</li>';
|
142 |
}
|
143 |
|
144 |
if ( $widget_options['tu_widget'] ) {
|
145 |
echo '<li>';
|
146 |
+
echo '<label>' . __( 'Total Users', 'wp-statistics' ) . ': </label>';
|
147 |
+
echo number_format_i18n( wp_statistics_countusers() );
|
148 |
echo '</li>';
|
149 |
}
|
150 |
|
151 |
if ( $widget_options['ap_widget'] ) {
|
152 |
echo '<li>';
|
153 |
+
echo '<label>' . __( 'Average Posts', 'wp-statistics' ) . ': </label>';
|
154 |
+
echo number_format_i18n( wp_statistics_average_post() );
|
155 |
echo '</li>';
|
156 |
}
|
157 |
|
158 |
if ( $widget_options['ac_widget'] ) {
|
159 |
echo '<li>';
|
160 |
+
echo '<label>' . __( 'Average Comments', 'wp-statistics' ) . ': </label>';
|
161 |
+
echo number_format_i18n( wp_statistics_average_comment() );
|
162 |
echo '</li>';
|
163 |
}
|
164 |
|
165 |
if ( $widget_options['au_widget'] ) {
|
166 |
echo '<li>';
|
167 |
+
echo '<label>' . __( 'Average Users', 'wp-statistics' ) . ': </label>';
|
168 |
+
echo number_format_i18n( wp_statistics_average_registeruser() );
|
169 |
echo '</li>';
|
170 |
}
|
171 |
|
172 |
if ( $widget_options['lpd_widget'] ) {
|
173 |
echo '<li>';
|
174 |
+
echo '<label>' . __( 'Last Post Date', 'wp-statistics' ) . ': </label>';
|
175 |
echo wp_statistics_lastpostdate();
|
176 |
echo '</li>';
|
177 |
}
|
191 |
public function update( $new_instance, $old_instance ) {
|
192 |
GLOBAL $WP_Statistics;
|
193 |
|
194 |
+
if ( array_key_exists( 'wp_statistics_control_widget_submit', $_POST ) ) {
|
195 |
$keys = array(
|
196 |
+
'name_widget' => 'name_widget',
|
197 |
'useronline_widget' => 'useronline_widget',
|
198 |
+
'tvisit_widget' => 'tvisit_widget',
|
199 |
+
'tvisitor_widget' => 'tvisitor_widget',
|
200 |
+
'yvisit_widget' => 'yvisit_widget',
|
201 |
+
'yvisitor_widget' => 'yvisitor_widget',
|
202 |
+
'wvisit_widget' => 'wvisit_widget',
|
203 |
+
'mvisit_widget' => 'mvisit_widget',
|
204 |
+
'ysvisit_widget' => 'ysvisit_widget',
|
205 |
+
'ttvisit_widget' => 'ttvisit_widget',
|
206 |
+
'ttvisitor_widget' => 'ttvisitor_widget',
|
207 |
+
'tpviews_widget' => 'tpviews_widget',
|
208 |
+
'ser_widget' => 'ser_widget',
|
209 |
+
'select_se' => 'select_se',
|
210 |
+
'tp_widget' => 'tp_widget',
|
211 |
+
'tpg_widget' => 'tpg_widget',
|
212 |
+
'tc_widget' => 'tc_widget',
|
213 |
+
'ts_widget' => 'ts_widget',
|
214 |
+
'tu_widget' => 'tu_widget',
|
215 |
+
'ap_widget' => 'ap_widget',
|
216 |
+
'ac_widget' => 'ac_widget',
|
217 |
+
'au_widget' => 'au_widget',
|
218 |
+
'lpd_widget' => 'lpd_widget',
|
219 |
+
'select_lps' => 'select_lps',
|
220 |
);
|
221 |
|
222 |
foreach ( $keys as $key => $post ) {
|
223 |
+
if ( array_key_exists( $post, $_POST ) ) {
|
224 |
$widget_options[ $key ] = $_POST[ $post ];
|
225 |
} else {
|
226 |
$widget_options[ $key ] = '';
|
227 |
}
|
228 |
}
|
229 |
|
230 |
+
$WP_Statistics->update_option( 'widget', $widget_options );
|
231 |
}
|
232 |
|
233 |
return array();
|
242 |
*/
|
243 |
public function form( $instance ) {
|
244 |
GLOBAL $WP_Statistics;
|
245 |
+
$widget_options = $WP_Statistics->get_option( 'widget' );
|
246 |
?>
|
247 |
+
<p>
|
248 |
+
<label for="name_widget"><?php _e( 'Name', 'wp-statistics' ); ?>:
|
249 |
+
<input id="name_widget" name="name_widget" type="text"
|
250 |
+
value="<?php echo $widget_options['name_widget']; ?>"/>
|
251 |
+
</label>
|
252 |
+
</p>
|
253 |
+
|
254 |
+
<?php _e( 'Items', 'wp-statistics' ); ?>:<br/>
|
255 |
+
<ul>
|
256 |
+
<li>
|
257 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'useronline_widget' ) ); ?>" name="useronline_widget" <?php checked(
|
258 |
'on',
|
259 |
$widget_options['useronline_widget']
|
260 |
); ?>/>
|
261 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'useronline_widget' ) ); ?>"><?php _e( 'Online Users', 'wp-statistics' ); ?></label>
|
262 |
+
</li>
|
263 |
+
<li>
|
264 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tvisit_widget' ) ); ?>" name="tvisit_widget" <?php checked(
|
265 |
'on',
|
266 |
$widget_options['tvisit_widget']
|
267 |
); ?>/>
|
268 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tvisit_widget' ) ); ?>"><?php _e( 'Today\'s Visits', 'wp-statistics' ); ?></label>
|
269 |
+
</li>
|
270 |
+
<li>
|
271 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tvisitor_widget' ) ); ?>" name="tvisitor_widget" <?php checked(
|
272 |
'on',
|
273 |
$widget_options['tvisitor_widget']
|
274 |
); ?>/>
|
275 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tvisitor_widget' ) ); ?>"><?php _e( 'Today\'s Visitors', 'wp-statistics' ); ?></label>
|
276 |
+
</li>
|
277 |
+
<li>
|
278 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'yvisit_widget' ) ); ?>" name="yvisit_widget" <?php checked(
|
279 |
'on',
|
280 |
$widget_options['yvisit_widget']
|
281 |
); ?>/>
|
282 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'yvisit_widget' ) ); ?>"><?php _e( 'Yesterday\'s Visits', 'wp-statistics' ); ?></label>
|
283 |
+
</li>
|
284 |
+
<li>
|
285 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'yvisitor_widget' ) ); ?>" name="yvisitor_widget" <?php checked(
|
286 |
'on',
|
287 |
$widget_options['yvisitor_widget']
|
288 |
); ?>/>
|
289 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'yvisitor_widget' ) ); ?>"><?php _e( 'Yesterday\'s Visitors', 'wp-statistics' ); ?></label>
|
290 |
+
</li>
|
291 |
+
<li>
|
292 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'wvisit_widget' ) ); ?>" name="wvisit_widget" <?php checked(
|
293 |
'on',
|
294 |
$widget_options['wvisit_widget']
|
295 |
); ?>/>
|
296 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'wvisit_widget' ) ); ?>"><?php _e( 'Last 7 Days Visits', 'wp-statistics' ); ?></label>
|
297 |
+
</li>
|
298 |
+
<li>
|
299 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'mvisit_widget' ) ); ?>" name="mvisit_widget" <?php checked(
|
300 |
'on',
|
301 |
$widget_options['mvisit_widget']
|
302 |
); ?>/>
|
303 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'mvisit_widget' ) ); ?>"><?php _e( 'Last 30 Days Visits', 'wp-statistics' ); ?></label>
|
304 |
+
</li>
|
305 |
+
<li>
|
306 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ysvisit_widget' ) ); ?>" name="ysvisit_widget" <?php checked(
|
307 |
'on',
|
308 |
$widget_options['ysvisit_widget']
|
309 |
); ?>/>
|
310 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ysvisit_widget' ) ); ?>"><?php _e( 'Last 365 Days Visits', 'wp-statistics' ); ?></label>
|
311 |
+
</li>
|
312 |
+
<li>
|
313 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ttvisit_widget' ) ); ?>" name="ttvisit_widget" <?php checked(
|
314 |
'on',
|
315 |
$widget_options['ttvisit_widget']
|
316 |
); ?>/>
|
317 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ttvisit_widget' ) ); ?>"><?php _e( 'Total Visits', 'wp-statistics' ); ?></label>
|
318 |
+
</li>
|
319 |
+
<li>
|
320 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ttvisitor_widget' ) ); ?>" name="ttvisitor_widget" <?php checked(
|
321 |
'on',
|
322 |
$widget_options['ttvisitor_widget']
|
323 |
); ?>/>
|
324 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ttvisitor_widget' ) ); ?>"><?php _e( 'Total Visitors', 'wp-statistics' ); ?></label>
|
325 |
+
</li>
|
326 |
+
<li>
|
327 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tpviews_widget' ) ); ?>" name="tpviews_widget" <?php checked(
|
328 |
'on',
|
329 |
$widget_options['tpviews_widget']
|
330 |
); ?>/>
|
331 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tpviews_widget' ) ); ?>"><?php _e( 'Total Page Views', 'wp-statistics' ); ?></label>
|
332 |
+
</li>
|
333 |
+
<li>
|
334 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ser_widget' ) ); ?>" class="ser_widget" name="ser_widget" <?php checked(
|
335 |
'on',
|
336 |
$widget_options['ser_widget']
|
337 |
); ?>/>
|
338 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ser_widget' ) ); ?>"><?php _e( 'Search Engine Referrals', 'wp-statistics' ); ?></label>
|
339 |
|
340 |
+
<p id="ser_option" style="<?php if ( ! $widget_options['ser_widget'] ) {
|
341 |
echo "display: none;";
|
342 |
} ?>">
|
343 |
+
<?php _e( 'Select type of search engine', 'wp-statistics' ); ?>:<br/>
|
344 |
<?php
|
345 |
$search_engines = wp_statistics_searchengine_list();
|
346 |
|
350 |
'" name="select_se" value="' .
|
351 |
$se['tag'] .
|
352 |
'" ';
|
353 |
+
checked( $se['tag'], $widget_options['select_se'] );
|
354 |
echo "/>\n";
|
355 |
echo ' <label for="' . $se['name'] . '">' . $se['translated'] . "</label>\n";
|
356 |
echo "\n";
|
357 |
}
|
358 |
?>
|
359 |
+
<input type="radio" id="select_all" name="select_se" value="all" <?php checked(
|
360 |
'all',
|
361 |
$widget_options['select_se']
|
362 |
); ?>/>
|
363 |
+
<label for="select_all"><?php _e( 'All', 'wp-statistics' ); ?></label>
|
364 |
+
</p>
|
365 |
+
</li>
|
366 |
+
<li>
|
367 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tp_widget' ) ); ?>" name="tp_widget" <?php checked(
|
368 |
'on',
|
369 |
$widget_options['tp_widget']
|
370 |
); ?>/>
|
371 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tp_widget' ) ); ?>"><?php _e( 'Total Posts', 'wp-statistics' ); ?></label>
|
372 |
+
</li>
|
373 |
+
<li>
|
374 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tpg_widget' ) ); ?>" name="tpg_widget" <?php checked(
|
375 |
'on',
|
376 |
$widget_options['tpg_widget']
|
377 |
); ?>/>
|
378 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tpg_widget' ) ); ?>"><?php _e( 'Total Pages', 'wp-statistics' ); ?></label>
|
379 |
+
</li>
|
380 |
+
<li>
|
381 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tc_widget' ) ); ?>" name="tc_widget" <?php checked(
|
382 |
'on',
|
383 |
$widget_options['tc_widget']
|
384 |
); ?>/>
|
385 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tc_widget' ) ); ?>"><?php _e( 'Total Comments', 'wp-statistics' ); ?></label>
|
386 |
+
</li>
|
387 |
+
<li>
|
388 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ts_widget' ) ); ?>" name="ts_widget" <?php checked(
|
389 |
'on',
|
390 |
$widget_options['ts_widget']
|
391 |
); ?>/>
|
392 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ts_widget' ) ); ?>"><?php _e( 'Total Spams', 'wp-statistics' ); ?></label>
|
393 |
+
</li>
|
394 |
+
<li>
|
395 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tu_widget' ) ); ?>" name="tu_widget" <?php checked(
|
396 |
'on',
|
397 |
$widget_options['tu_widget']
|
398 |
); ?>/>
|
399 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'tu_widget' ) ); ?>"><?php _e( 'Total Users', 'wp-statistics' ); ?></label>
|
400 |
+
</li>
|
401 |
+
<li>
|
402 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ap_widget' ) ); ?>" name="ap_widget" <?php checked(
|
403 |
'on',
|
404 |
$widget_options['ap_widget']
|
405 |
); ?>/>
|
406 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ap_widget' ) ); ?>"><?php _e( 'Average Posts', 'wp-statistics' ); ?></label>
|
407 |
+
</li>
|
408 |
+
<li>
|
409 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ac_widget' ) ); ?>" name="ac_widget" <?php checked(
|
410 |
'on',
|
411 |
$widget_options['ac_widget']
|
412 |
); ?>/>
|
413 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'ac_widget' ) ); ?>"><?php _e( 'Average Comments', 'wp-statistics' ); ?></label>
|
414 |
+
</li>
|
415 |
+
<li>
|
416 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'au_widget' ) ); ?>" name="au_widget" <?php checked(
|
417 |
'on',
|
418 |
$widget_options['au_widget']
|
419 |
); ?>/>
|
420 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'au_widget' ) ); ?>"><?php _e( 'Average Users', 'wp-statistics' ); ?></label>
|
421 |
+
</li>
|
422 |
+
<li>
|
423 |
+
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'lpd_widget' ) ); ?>" class="lpd_widget" name="lpd_widget" <?php checked(
|
424 |
'on',
|
425 |
$widget_options['lpd_widget']
|
426 |
); ?>/>
|
427 |
+
<label for="<?php echo esc_attr( $this->get_field_id( 'lpd_widget' ) ); ?>"><?php _e( 'Last Post Date', 'wp-statistics' ); ?></label>
|
428 |
+
</li>
|
429 |
+
</ul>
|
430 |
|
431 |
+
<input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'wp_statistics_control_widget_submit' ) ); ?>" name="wp_statistics_control_widget_submit"
|
432 |
+
value="1"/>
|
433 |
<?php
|
434 |
}
|
435 |
}
|
includes/classes/class-wp-statistics.php
CHANGED
@@ -131,12 +131,12 @@ class WP_Statistics {
|
|
131 |
/**
|
132 |
* Plugin URL
|
133 |
*/
|
134 |
-
WP_Statistics::$reg['plugin-url'] = plugin_dir_url(WP_STATISTICS_MAIN_FILE);
|
135 |
//define('WP_STATISTICS_PLUGIN_URL', plugin_dir_url(WP_STATISTICS_MAIN_FILE));
|
136 |
/**
|
137 |
* Plugin DIR
|
138 |
*/
|
139 |
-
WP_Statistics::$reg['plugin-dir'] = plugin_dir_path(WP_STATISTICS_MAIN_FILE);
|
140 |
//define('WP_STATISTICS_PLUGIN_DIR', plugin_dir_path(WP_STATISTICS_MAIN_FILE));
|
141 |
/**
|
142 |
* Plugin Main File
|
@@ -145,10 +145,10 @@ class WP_Statistics {
|
|
145 |
/**
|
146 |
* WP Statistics Version
|
147 |
*/
|
148 |
-
if ( ! function_exists('get_plugin_data') ) {
|
149 |
require( ABSPATH . 'wp-admin/includes/plugin.php' );
|
150 |
}
|
151 |
-
WP_Statistics::$reg['plugin-data'] = get_plugin_data(WP_STATISTICS_MAIN_FILE);
|
152 |
WP_Statistics::$reg['version'] = WP_Statistics::$reg['plugin-data']['Version'];
|
153 |
//define('WP_STATISTICS_VERSION', '12.1.3');
|
154 |
}
|
@@ -168,8 +168,8 @@ class WP_Statistics {
|
|
168 |
|
169 |
// Check the PHP version,
|
170 |
// if we don't meet the minimum version to run WP Statistics return so we don't cause a critical error.
|
171 |
-
if ( ! version_compare(phpversion(), WP_Statistics::$reg['required-php-version'], ">=") ) {
|
172 |
-
add_action('admin_notices', 'WP_Statistics::unsupported_version_admin_notice', 10, 2);
|
173 |
|
174 |
return;
|
175 |
}
|
@@ -184,21 +184,21 @@ class WP_Statistics {
|
|
184 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/vendor/autoload.php' );
|
185 |
|
186 |
// define an autoload method to automatically load classes in /includes/classes
|
187 |
-
spl_autoload_register(array( $this, 'autoload' ));
|
188 |
|
189 |
// Add init actions.
|
190 |
// For the main init we're going to set our priority to 9 to execute before most plugins
|
191 |
// so we can export data before and set the headers without
|
192 |
// worrying about bugs in other plugins that output text and don't allow us to set the headers.
|
193 |
-
add_action('init', array( $this, 'init' ), 9);
|
194 |
|
195 |
// Load the rest of the required files for our global functions,
|
196 |
// online user tracking and hit tracking.
|
197 |
-
if ( ! function_exists('wp_statistics_useronline') ) {
|
198 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/functions/functions.php';
|
199 |
}
|
200 |
|
201 |
-
$this->agent
|
202 |
$WP_Statistics = $this;
|
203 |
|
204 |
if ( is_admin() ) {
|
@@ -209,12 +209,12 @@ class WP_Statistics {
|
|
209 |
new WP_Statistics_Frontend;
|
210 |
}
|
211 |
|
212 |
-
if ( $WP_Statistics->get_option('menu_bar') ) {
|
213 |
-
add_action('admin_bar_menu', 'WP_Statistics::menubar', 20);
|
214 |
}
|
215 |
|
216 |
-
add_action('widgets_init', 'WP_Statistics::widget');
|
217 |
-
add_shortcode('wpstatistics', 'WP_Statistics_Shortcode::shortcodes');
|
218 |
}
|
219 |
|
220 |
/**
|
@@ -223,15 +223,15 @@ class WP_Statistics {
|
|
223 |
* @param string $class Class name
|
224 |
*/
|
225 |
public function autoload( $class ) {
|
226 |
-
if ( ! class_exists($class) && // This check is for performance of loading plugin classes
|
227 |
-
substr($class, 0, 14) === 'WP_Statistics_'
|
228 |
) {
|
229 |
-
$lower_class_name = str_replace('_', '-', strtolower($class));
|
230 |
$class_full_path = WP_Statistics::$reg['plugin-dir'] .
|
231 |
'includes/classes/class-' .
|
232 |
$lower_class_name .
|
233 |
'.php';
|
234 |
-
if ( file_exists($class_full_path) ) {
|
235 |
require $class_full_path;
|
236 |
}
|
237 |
}
|
@@ -241,20 +241,20 @@ class WP_Statistics {
|
|
241 |
* Loads the init code.
|
242 |
*/
|
243 |
public function init() {
|
244 |
-
load_plugin_textdomain('wp-statistics', false, WP_Statistics::$reg['plugin-dir'] . 'languages');
|
245 |
}
|
246 |
|
247 |
/**
|
248 |
* Set Time Zone
|
249 |
*/
|
250 |
-
public function set_timezone(){
|
251 |
-
if ( get_option('timezone_string') ) {
|
252 |
$this->tz_offset = timezone_offset_get(
|
253 |
-
|
254 |
-
|
255 |
);
|
256 |
-
} elseif ( get_option('gmt_offset') ) {
|
257 |
-
$this->tz_offset = get_option('gmt_offset') * 60 * 60;
|
258 |
}
|
259 |
}
|
260 |
|
@@ -369,9 +369,9 @@ class WP_Statistics {
|
|
369 |
/**
|
370 |
* Set Coefficient
|
371 |
*/
|
372 |
-
public function set_coefficient(){
|
373 |
// Set the default co-efficient.
|
374 |
-
$this->coefficient = $this->get_option('coefficient', 1);
|
375 |
// Double check the co-efficient setting to make sure it's not been set to 0.
|
376 |
if ( $this->coefficient <= 0 ) {
|
377 |
$this->coefficient = 1;
|
@@ -381,9 +381,9 @@ class WP_Statistics {
|
|
381 |
/**
|
382 |
* Set IP Hash
|
383 |
*/
|
384 |
-
public function set_ip_hash(){
|
385 |
-
if ( $this->get_option('hash_ips') == true ) {
|
386 |
-
$this->ip_hash = '#hash#' . sha1($this->ip . $_SERVER['HTTP_USER_AGENT']);
|
387 |
}
|
388 |
}
|
389 |
|
@@ -391,9 +391,9 @@ class WP_Statistics {
|
|
391 |
* loads the options from WordPress,
|
392 |
*/
|
393 |
public function load_options() {
|
394 |
-
$this->options = get_option('wp_statistics');
|
395 |
|
396 |
-
if ( ! is_array($this->options) ) {
|
397 |
$this->user_options = array();
|
398 |
}
|
399 |
}
|
@@ -402,7 +402,7 @@ class WP_Statistics {
|
|
402 |
* Registers Widget
|
403 |
*/
|
404 |
static function widget() {
|
405 |
-
register_widget('WP_Statistics_Widget');
|
406 |
}
|
407 |
|
408 |
/**
|
@@ -421,9 +421,9 @@ class WP_Statistics {
|
|
421 |
}
|
422 |
|
423 |
// Not sure why, but get_user_meta() is returning an array or array's unless $single is set to true.
|
424 |
-
$this->user_options = get_user_meta($this->user_id, 'wp_statistics', true);
|
425 |
|
426 |
-
if ( ! is_array($this->user_options) ) {
|
427 |
$this->user_options = array();
|
428 |
}
|
429 |
|
@@ -440,12 +440,12 @@ class WP_Statistics {
|
|
440 |
*/
|
441 |
public function get_option( $option, $default = null ) {
|
442 |
// If no options array exists, return FALSE.
|
443 |
-
if ( ! is_array($this->options) ) {
|
444 |
return false;
|
445 |
}
|
446 |
|
447 |
// if the option isn't set yet, return the $default if it exists, otherwise FALSE.
|
448 |
-
if ( ! array_key_exists($option, $this->options) ) {
|
449 |
if ( isset( $default ) ) {
|
450 |
return $default;
|
451 |
} else {
|
@@ -471,12 +471,12 @@ class WP_Statistics {
|
|
471 |
if ( $this->user_id == 0 ) {
|
472 |
return false;
|
473 |
}
|
474 |
-
if ( ! is_array($this->user_options) ) {
|
475 |
return false;
|
476 |
}
|
477 |
|
478 |
// if the option isn't set yet, return the $default if it exists, otherwise FALSE.
|
479 |
-
if ( ! array_key_exists($option, $this->user_options) ) {
|
480 |
if ( isset( $default ) ) {
|
481 |
return $default;
|
482 |
} else {
|
@@ -500,7 +500,7 @@ class WP_Statistics {
|
|
500 |
$this->options[ $option ] = $value;
|
501 |
|
502 |
// Write the array to the database.
|
503 |
-
update_option('wp_statistics', $this->options);
|
504 |
}
|
505 |
|
506 |
/**
|
@@ -522,7 +522,7 @@ class WP_Statistics {
|
|
522 |
$this->user_options[ $option ] = $value;
|
523 |
|
524 |
// Write the array to the database.
|
525 |
-
update_user_meta($this->user_id, 'wp_statistics', $this->user_options);
|
526 |
}
|
527 |
|
528 |
/**
|
@@ -560,7 +560,7 @@ class WP_Statistics {
|
|
560 |
* Saves the current options array to the database.
|
561 |
*/
|
562 |
public function save_options() {
|
563 |
-
update_option('wp_statistics', $this->options);
|
564 |
}
|
565 |
|
566 |
/**
|
@@ -573,7 +573,7 @@ class WP_Statistics {
|
|
573 |
return false;
|
574 |
}
|
575 |
|
576 |
-
update_user_meta($this->user_id, 'wp_statistics', $this->user_options);
|
577 |
}
|
578 |
|
579 |
/**
|
@@ -584,11 +584,11 @@ class WP_Statistics {
|
|
584 |
* @return bool
|
585 |
*/
|
586 |
public function isset_option( $option ) {
|
587 |
-
if ( ! is_array($this->options) ) {
|
588 |
return false;
|
589 |
}
|
590 |
|
591 |
-
return array_key_exists($option, $this->options);
|
592 |
}
|
593 |
|
594 |
/**
|
@@ -602,11 +602,11 @@ class WP_Statistics {
|
|
602 |
if ( $this->user_id == 0 ) {
|
603 |
return false;
|
604 |
}
|
605 |
-
if ( ! is_array($this->user_options) ) {
|
606 |
return false;
|
607 |
}
|
608 |
|
609 |
-
return array_key_exists($option, $this->user_options);
|
610 |
}
|
611 |
|
612 |
/**
|
@@ -617,7 +617,7 @@ class WP_Statistics {
|
|
617 |
public function Primary_Values() {
|
618 |
global $wpdb;
|
619 |
|
620 |
-
$this->result = $wpdb->query("SELECT * FROM {$wpdb->prefix}statistics_useronline");
|
621 |
|
622 |
if ( ! $this->result ) {
|
623 |
|
@@ -625,7 +625,7 @@ class WP_Statistics {
|
|
625 |
$wpdb->prefix . "statistics_useronline",
|
626 |
array(
|
627 |
'ip' => $this->get_IP(),
|
628 |
-
'timestamp' => $this->Current_Date('U'),
|
629 |
'date' => $this->Current_Date(),
|
630 |
'referred' => $this->get_Referred(),
|
631 |
'agent' => $this->agent['browser'],
|
@@ -635,7 +635,7 @@ class WP_Statistics {
|
|
635 |
);
|
636 |
}
|
637 |
|
638 |
-
$this->result = $wpdb->query("SELECT * FROM {$wpdb->prefix}statistics_visit");
|
639 |
|
640 |
if ( ! $this->result ) {
|
641 |
|
@@ -643,20 +643,20 @@ class WP_Statistics {
|
|
643 |
$wpdb->prefix . "statistics_visit",
|
644 |
array(
|
645 |
'last_visit' => $this->Current_Date(),
|
646 |
-
'last_counter' => $this->Current_date('Y-m-d'),
|
647 |
'visit' => 1,
|
648 |
)
|
649 |
);
|
650 |
}
|
651 |
|
652 |
-
$this->result = $wpdb->query("SELECT * FROM {$wpdb->prefix}statistics_visitor");
|
653 |
|
654 |
if ( ! $this->result ) {
|
655 |
|
656 |
$wpdb->insert(
|
657 |
$wpdb->prefix . "statistics_visitor",
|
658 |
array(
|
659 |
-
'last_counter' => $this->Current_date('Y-m-d'),
|
660 |
'referred' => $this->get_Referred(),
|
661 |
'agent' => $this->agent['browser'],
|
662 |
'platform' => $this->agent['platform'],
|
@@ -682,7 +682,7 @@ class WP_Statistics {
|
|
682 |
include( WP_Statistics::$reg['plugin-dir'] . 'includes/robotslist.php' );
|
683 |
}
|
684 |
|
685 |
-
$options['robotlist'] = trim($wps_robotslist);
|
686 |
|
687 |
// By default, on new installs, use the new search table.
|
688 |
$options['search_converted'] = 1;
|
@@ -724,31 +724,31 @@ class WP_Statistics {
|
|
724 |
*/
|
725 |
private function get_ip_value( $ip ) {
|
726 |
// Reject anything that's not a string.
|
727 |
-
if ( ! is_string($ip) ) {
|
728 |
return false;
|
729 |
}
|
730 |
|
731 |
// Trim off any spaces.
|
732 |
-
$ip = trim($ip);
|
733 |
|
734 |
// Process IPv4 and v6 addresses separately.
|
735 |
-
if ( $this->isValidIPv6($ip) ) {
|
736 |
// Reject any IPv6 addresses if IPv6 is not compiled in to this version of PHP.
|
737 |
-
if ( ! defined('AF_INET6') ) {
|
738 |
return false;
|
739 |
}
|
740 |
} else {
|
741 |
// Trim off any port values that exist.
|
742 |
-
if ( strstr($ip, ':') !== false ) {
|
743 |
-
$temp = explode(':', $ip);
|
744 |
$ip = $temp[0];
|
745 |
}
|
746 |
|
747 |
// Check to make sure the http header is actually an IP address and not some kind of SQL injection attack.
|
748 |
-
$long = ip2long($ip);
|
749 |
|
750 |
// ip2long returns either -1 or FALSE if it is not a valid IP address depending on the PHP version, so check for both.
|
751 |
-
if ( $long == -1 || $long === false ) {
|
752 |
return false;
|
753 |
}
|
754 |
}
|
@@ -776,8 +776,8 @@ class WP_Statistics {
|
|
776 |
}
|
777 |
|
778 |
// By default we use the remote address the server has.
|
779 |
-
if ( array_key_exists('REMOTE_ADDR', $_SERVER) ) {
|
780 |
-
$temp_ip = $this->get_ip_value($_SERVER['REMOTE_ADDR']);
|
781 |
} else {
|
782 |
$temp_ip = '127.0.0.1';
|
783 |
}
|
@@ -803,7 +803,7 @@ class WP_Statistics {
|
|
803 |
);
|
804 |
|
805 |
foreach ( $envs as $env ) {
|
806 |
-
$temp_ip = $this->get_ip_value(getenv($env));
|
807 |
|
808 |
if ( false !== $temp_ip ) {
|
809 |
$this->ip = $temp_ip;
|
@@ -828,7 +828,7 @@ class WP_Statistics {
|
|
828 |
* @return boolean - true/false
|
829 |
*/
|
830 |
private function isValidIPv6( $ip ) {
|
831 |
-
if ( false === filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) {
|
832 |
return false;
|
833 |
} else {
|
834 |
return true;
|
@@ -842,32 +842,32 @@ class WP_Statistics {
|
|
842 |
*/
|
843 |
public function get_UserAgent() {
|
844 |
|
845 |
-
// Parse the agent
|
846 |
try {
|
847 |
$agent = parse_user_agent();
|
848 |
} catch ( Exception $e ) {
|
849 |
$agent = array(
|
850 |
-
'browser' => _x('Unknown', 'Browser', 'wp-statistics'),
|
851 |
-
'platform' => _x('Unknown', 'Platform', 'wp-statistics'),
|
852 |
-
'version' => _x('Unknown', 'Version', 'wp-statistics'),
|
853 |
);
|
854 |
}
|
855 |
|
856 |
// null isn't a very good default, so set it to Unknown instead.
|
857 |
if ( $agent['browser'] == null ) {
|
858 |
-
$agent['browser'] = _x('Unknown', 'Browser', 'wp-statistics');
|
859 |
}
|
860 |
if ( $agent['platform'] == null ) {
|
861 |
-
$agent['platform'] = _x('Unknown', 'Platform', 'wp-statistics');
|
862 |
}
|
863 |
if ( $agent['version'] == null ) {
|
864 |
-
$agent['version'] = _x('Unknown', 'Version', 'wp-statistics');
|
865 |
}
|
866 |
|
867 |
// Uncommon browsers often have some extra cruft, like brackets, http:// and other strings that we can strip out.
|
868 |
$strip_strings = array( '"', "'", '(', ')', ';', ':', '/', '[', ']', '{', '}', 'http' );
|
869 |
foreach ( $agent as $key => $value ) {
|
870 |
-
$agent[ $key ] = str_replace($strip_strings, '', $agent[ $key ]);
|
871 |
}
|
872 |
|
873 |
return $agent;
|
@@ -894,29 +894,29 @@ class WP_Statistics {
|
|
894 |
$this->referrer = $default_referrer;
|
895 |
}
|
896 |
|
897 |
-
$this->referrer = esc_sql(strip_tags($this->referrer));
|
898 |
|
899 |
if ( ! $this->referrer ) {
|
900 |
-
$this->referrer = get_bloginfo('url');
|
901 |
}
|
902 |
|
903 |
-
if ( $this->get_option('addsearchwords', false) ) {
|
904 |
// Check to see if this is a search engine referrer
|
905 |
-
$SEInfo = $this->Search_Engine_Info($this->referrer);
|
906 |
|
907 |
-
if ( is_array($SEInfo) ) {
|
908 |
// If we're a known SE, check the query string
|
909 |
if ( $SEInfo['tag'] != '' ) {
|
910 |
-
$result = $this->Search_Engine_QueryString($this->referrer);
|
911 |
|
912 |
// If there were no search words, let's add the page title
|
913 |
if ( $result == '' || $result == 'No search query found!' ) {
|
914 |
-
$result =
|
915 |
if ( $result != '' ) {
|
916 |
$this->referrer = esc_url(
|
917 |
add_query_arg(
|
918 |
$SEInfo['querykey'],
|
919 |
-
urlencode('~"' . $result . '"'),
|
920 |
$this->referrer
|
921 |
)
|
922 |
);
|
@@ -938,14 +938,15 @@ class WP_Statistics {
|
|
938 |
* @return bool|string
|
939 |
*/
|
940 |
public function Local_Date( $format, $timestamp ) {
|
941 |
-
return date($format, $timestamp + $this->tz_offset);
|
942 |
}
|
943 |
|
944 |
// Returns a date string in the desired format.
|
|
|
945 |
/**
|
946 |
* @param string $format
|
947 |
-
* @param null
|
948 |
-
* @param null
|
949 |
*
|
950 |
* @return bool|string
|
951 |
*/
|
@@ -953,12 +954,12 @@ class WP_Statistics {
|
|
953 |
|
954 |
if ( $strtotime ) {
|
955 |
if ( $relative ) {
|
956 |
-
return date($format, strtotime("{$strtotime} day", $relative) + $this->tz_offset);
|
957 |
} else {
|
958 |
-
return date($format, strtotime("{$strtotime} day") + $this->tz_offset);
|
959 |
}
|
960 |
} else {
|
961 |
-
return date($format, time() + $this->tz_offset);
|
962 |
}
|
963 |
}
|
964 |
|
@@ -966,8 +967,8 @@ class WP_Statistics {
|
|
966 |
* Returns a date string in the desired format.
|
967 |
*
|
968 |
* @param string $format
|
969 |
-
* @param null
|
970 |
-
* @param null
|
971 |
*
|
972 |
* @return bool|string
|
973 |
*/
|
@@ -975,12 +976,12 @@ class WP_Statistics {
|
|
975 |
|
976 |
if ( $strtotime ) {
|
977 |
if ( $relative ) {
|
978 |
-
return date($format, strtotime("{$strtotime} day", $relative));
|
979 |
} else {
|
980 |
-
return date($format, strtotime("{$strtotime} day"));
|
981 |
}
|
982 |
} else {
|
983 |
-
return date($format, time());
|
984 |
}
|
985 |
}
|
986 |
|
@@ -988,7 +989,7 @@ class WP_Statistics {
|
|
988 |
* Returns an internationalized date string in the desired format.
|
989 |
*
|
990 |
* @param string $format
|
991 |
-
* @param null
|
992 |
* @param string $day
|
993 |
*
|
994 |
* @return string
|
@@ -996,9 +997,9 @@ class WP_Statistics {
|
|
996 |
public function Current_Date_i18n( $format = 'Y-m-d H:i:s', $strtotime = null, $day = ' day' ) {
|
997 |
|
998 |
if ( $strtotime ) {
|
999 |
-
return date_i18n($format, strtotime("{$strtotime}{$day}") + $this->tz_offset);
|
1000 |
} else {
|
1001 |
-
return date_i18n($format, time() + $this->tz_offset);
|
1002 |
}
|
1003 |
}
|
1004 |
|
@@ -1010,7 +1011,7 @@ class WP_Statistics {
|
|
1010 |
* @return int
|
1011 |
*/
|
1012 |
public function strtotimetz( $timestring ) {
|
1013 |
-
return strtotime($timestring) + $this->tz_offset;
|
1014 |
}
|
1015 |
|
1016 |
/**
|
@@ -1032,7 +1033,7 @@ class WP_Statistics {
|
|
1032 |
*/
|
1033 |
public function Check_Search_Engines( $search_engine_name, $search_engine = null ) {
|
1034 |
|
1035 |
-
if ( strstr($search_engine, $search_engine_name) ) {
|
1036 |
return 1;
|
1037 |
}
|
1038 |
}
|
@@ -1059,16 +1060,16 @@ class WP_Statistics {
|
|
1059 |
}
|
1060 |
|
1061 |
// Parse the URL in to it's component parts.
|
1062 |
-
$parts = parse_url($url);
|
1063 |
|
1064 |
// Get the list of search engines we currently support.
|
1065 |
$search_engines = wp_statistics_searchengine_list();
|
1066 |
|
1067 |
// Loop through the SE list until we find which search engine matches.
|
1068 |
foreach ( $search_engines as $key => $value ) {
|
1069 |
-
$search_regex = wp_statistics_searchengine_regex($key);
|
1070 |
|
1071 |
-
preg_match('/' . $search_regex . '/', $parts['host'], $matches);
|
1072 |
|
1073 |
if ( isset( $matches[1] ) ) {
|
1074 |
// Return the first matched SE.
|
@@ -1078,7 +1079,7 @@ class WP_Statistics {
|
|
1078 |
|
1079 |
// If no SE matched, return some defaults.
|
1080 |
return array(
|
1081 |
-
'name' => _x('Unknown', 'Search Engine', 'wp-statistics'),
|
1082 |
'tag' => '',
|
1083 |
'sqlpattern' => '',
|
1084 |
'regexpattern' => '',
|
@@ -1106,13 +1107,13 @@ class WP_Statistics {
|
|
1106 |
// Get the list of search engines we currently support.
|
1107 |
$search_engines = wp_statistics_searchengine_list();
|
1108 |
|
1109 |
-
if ( array_key_exists($engine, $search_engines) ) {
|
1110 |
return $search_engines[ $engine ];
|
1111 |
}
|
1112 |
|
1113 |
// If no SE matched, return some defaults.
|
1114 |
return array(
|
1115 |
-
'name' => _x('Unknown', 'Search Engine', 'wp-statistics'),
|
1116 |
'tag' => '',
|
1117 |
'sqlpattern' => '',
|
1118 |
'regexpattern' => '',
|
@@ -1141,12 +1142,12 @@ class WP_Statistics {
|
|
1141 |
}
|
1142 |
|
1143 |
// Parse the URL in to it's component parts.
|
1144 |
-
$parts = parse_url($url);
|
1145 |
|
1146 |
// Check to see if there is a query component in the URL (everything after the ?). If there isn't one
|
1147 |
// set an empty array so we don't get errors later.
|
1148 |
-
if ( array_key_exists('query', $parts) ) {
|
1149 |
-
parse_str($parts['query'], $query);
|
1150 |
} else {
|
1151 |
$query = array();
|
1152 |
}
|
@@ -1156,14 +1157,14 @@ class WP_Statistics {
|
|
1156 |
|
1157 |
// Loop through the SE list until we find which search engine matches.
|
1158 |
foreach ( $search_engines as $key => $value ) {
|
1159 |
-
$search_regex = wp_statistics_searchengine_regex($key);
|
1160 |
|
1161 |
-
preg_match('/' . $search_regex . '/', $parts['host'], $matches);
|
1162 |
|
1163 |
if ( isset( $matches[1] ) ) {
|
1164 |
// Check to see if the query key the SE uses exists in the query part of the URL.
|
1165 |
-
if ( array_key_exists($search_engines[ $key ]['querykey'], $query) ) {
|
1166 |
-
$words = strip_tags($query[ $search_engines[ $key ]['querykey'] ]);
|
1167 |
} else {
|
1168 |
$words = '';
|
1169 |
}
|
@@ -1197,7 +1198,7 @@ class WP_Statistics {
|
|
1197 |
|
1198 |
switch ( $type ) {
|
1199 |
case 'visitors':
|
1200 |
-
if ( array_key_exists('visitors', $this->historical) ) {
|
1201 |
return $this->historical['visitors'];
|
1202 |
} else {
|
1203 |
$result
|
@@ -1210,9 +1211,9 @@ class WP_Statistics {
|
|
1210 |
$this->historical['visitors'] = $count;
|
1211 |
}
|
1212 |
|
1213 |
-
|
1214 |
case 'visits':
|
1215 |
-
if ( array_key_exists('visits', $this->historical) ) {
|
1216 |
return $this->historical['visits'];
|
1217 |
} else {
|
1218 |
$result
|
@@ -1225,9 +1226,9 @@ class WP_Statistics {
|
|
1225 |
$this->historical['visits'] = $count;
|
1226 |
}
|
1227 |
|
1228 |
-
|
1229 |
case 'uri':
|
1230 |
-
if ( array_key_exists($id, $this->historical) ) {
|
1231 |
return $this->historical[ $id ];
|
1232 |
} else {
|
1233 |
$result
|
@@ -1243,9 +1244,9 @@ class WP_Statistics {
|
|
1243 |
$this->historical[ $id ] = $count;
|
1244 |
}
|
1245 |
|
1246 |
-
|
1247 |
case 'page':
|
1248 |
-
if ( array_key_exists($id, $this->historical) ) {
|
1249 |
return $this->historical[ $id ];
|
1250 |
} else {
|
1251 |
$result
|
@@ -1261,7 +1262,7 @@ class WP_Statistics {
|
|
1261 |
$this->historical[ $id ] = $count;
|
1262 |
}
|
1263 |
|
1264 |
-
|
1265 |
}
|
1266 |
|
1267 |
return $count;
|
@@ -1293,7 +1294,7 @@ class WP_Statistics {
|
|
1293 |
$site_list = array();
|
1294 |
|
1295 |
// wp_get_sites() is deprecated in 4.6 or above and replaced with get_sites().
|
1296 |
-
if ( version_compare($wp_version, '4.6', '>=') ) {
|
1297 |
$sites = get_sites();
|
1298 |
|
1299 |
foreach ( $sites as $site ) {
|
@@ -1318,22 +1319,22 @@ class WP_Statistics {
|
|
1318 |
*
|
1319 |
* @return string
|
1320 |
*/
|
1321 |
-
public function html_sanitize_referrer( $referrer, $length = -1 ) {
|
1322 |
-
$referrer = trim($referrer);
|
1323 |
|
1324 |
-
if ( 'data:' == strtolower(substr($referrer, 0, 5)) ) {
|
1325 |
$referrer = 'http://127.0.0.1';
|
1326 |
}
|
1327 |
|
1328 |
-
if ( 'javascript:' == strtolower(substr($referrer, 0, 11)) ) {
|
1329 |
$referrer = 'http://127.0.0.1';
|
1330 |
}
|
1331 |
|
1332 |
if ( $length > 0 ) {
|
1333 |
-
$referrer = substr($referrer, 0, $length);
|
1334 |
}
|
1335 |
|
1336 |
-
return htmlentities($referrer, ENT_QUOTES);
|
1337 |
}
|
1338 |
|
1339 |
/**
|
@@ -1344,22 +1345,23 @@ class WP_Statistics {
|
|
1344 |
*
|
1345 |
* @return string
|
1346 |
*/
|
1347 |
-
public function get_referrer_link( $referrer, $length = -1 ) {
|
1348 |
-
$html_referrer = $this->html_sanitize_referrer($referrer);
|
1349 |
-
if ( $length > 0 && strlen($referrer) > $length ) {
|
1350 |
-
$html_referrer_limited = $this->html_sanitize_referrer($referrer, $length);
|
1351 |
$eplises = '[...]';
|
1352 |
} else {
|
1353 |
$html_referrer_limited = $html_referrer;
|
1354 |
$eplises = '';
|
1355 |
}
|
1356 |
|
1357 |
-
if ( substr($html_referrer, 0, 7) !== 'http://' and substr($html_referrer, 0, 8) !== 'https://' ) {
|
1358 |
// relative address, use '//' to adapt both http and https
|
1359 |
$html_nr_referrer = '//' . $html_referrer;
|
1360 |
} else {
|
1361 |
$html_nr_referrer = $html_referrer;
|
1362 |
}
|
|
|
1363 |
return "<a href='{$html_nr_referrer}'><div class='dashicons dashicons-admin-links'></div>{$html_referrer_limited}{$eplises}</a>";
|
1364 |
}
|
1365 |
|
@@ -1374,18 +1376,18 @@ class WP_Statistics {
|
|
1374 |
return;
|
1375 |
}
|
1376 |
?>
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
'WP Statistics Disabled',
|
1381 |
'wp-statistics'
|
1382 |
); ?></b> <?php _e(
|
1383 |
'— You are running an unsupported version of PHP.',
|
1384 |
'wp-statistics'
|
1385 |
); ?>
|
1386 |
-
|
1387 |
|
1388 |
-
|
1389 |
|
1390 |
echo sprintf(
|
1391 |
__(
|
@@ -1401,7 +1403,7 @@ class WP_Statistics {
|
|
1401 |
'wp-statistics'
|
1402 |
);
|
1403 |
?></p>
|
1404 |
-
|
1405 |
|
1406 |
<?php
|
1407 |
}
|
@@ -1414,97 +1416,97 @@ class WP_Statistics {
|
|
1414 |
|
1415 |
// Find out if the user can read or manage statistics.
|
1416 |
$read = current_user_can(
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
)
|
1422 |
)
|
|
|
1423 |
);
|
1424 |
$manage = current_user_can(
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
)
|
1430 |
)
|
|
|
1431 |
);
|
1432 |
|
1433 |
if ( is_admin_bar_showing() && ( $read || $manage ) ) {
|
1434 |
|
1435 |
$AdminURL = get_admin_url();
|
1436 |
|
1437 |
-
if ( version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=') ) {
|
1438 |
$wp_admin_bar->add_menu(
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
);
|
1445 |
} else {
|
1446 |
$wp_admin_bar->add_menu(
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
);
|
1453 |
}
|
1454 |
|
1455 |
$wp_admin_bar->add_menu(
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
);
|
1466 |
|
1467 |
$wp_admin_bar->add_menu(
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
);
|
1474 |
|
1475 |
$wp_admin_bar->add_menu(
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
);
|
1482 |
|
1483 |
$wp_admin_bar->add_menu(
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
);
|
1492 |
|
1493 |
$wp_admin_bar->add_menu(
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
);
|
1500 |
|
1501 |
$wp_admin_bar->add_menu(
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
);
|
1509 |
}
|
1510 |
}
|
131 |
/**
|
132 |
* Plugin URL
|
133 |
*/
|
134 |
+
WP_Statistics::$reg['plugin-url'] = plugin_dir_url( WP_STATISTICS_MAIN_FILE );
|
135 |
//define('WP_STATISTICS_PLUGIN_URL', plugin_dir_url(WP_STATISTICS_MAIN_FILE));
|
136 |
/**
|
137 |
* Plugin DIR
|
138 |
*/
|
139 |
+
WP_Statistics::$reg['plugin-dir'] = plugin_dir_path( WP_STATISTICS_MAIN_FILE );
|
140 |
//define('WP_STATISTICS_PLUGIN_DIR', plugin_dir_path(WP_STATISTICS_MAIN_FILE));
|
141 |
/**
|
142 |
* Plugin Main File
|
145 |
/**
|
146 |
* WP Statistics Version
|
147 |
*/
|
148 |
+
if ( ! function_exists( 'get_plugin_data' ) ) {
|
149 |
require( ABSPATH . 'wp-admin/includes/plugin.php' );
|
150 |
}
|
151 |
+
WP_Statistics::$reg['plugin-data'] = get_plugin_data( WP_STATISTICS_MAIN_FILE );
|
152 |
WP_Statistics::$reg['version'] = WP_Statistics::$reg['plugin-data']['Version'];
|
153 |
//define('WP_STATISTICS_VERSION', '12.1.3');
|
154 |
}
|
168 |
|
169 |
// Check the PHP version,
|
170 |
// if we don't meet the minimum version to run WP Statistics return so we don't cause a critical error.
|
171 |
+
if ( ! version_compare( phpversion(), WP_Statistics::$reg['required-php-version'], ">=" ) ) {
|
172 |
+
add_action( 'admin_notices', 'WP_Statistics::unsupported_version_admin_notice', 10, 2 );
|
173 |
|
174 |
return;
|
175 |
}
|
184 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/vendor/autoload.php' );
|
185 |
|
186 |
// define an autoload method to automatically load classes in /includes/classes
|
187 |
+
spl_autoload_register( array( $this, 'autoload' ) );
|
188 |
|
189 |
// Add init actions.
|
190 |
// For the main init we're going to set our priority to 9 to execute before most plugins
|
191 |
// so we can export data before and set the headers without
|
192 |
// worrying about bugs in other plugins that output text and don't allow us to set the headers.
|
193 |
+
add_action( 'init', array( $this, 'init' ), 9 );
|
194 |
|
195 |
// Load the rest of the required files for our global functions,
|
196 |
// online user tracking and hit tracking.
|
197 |
+
if ( ! function_exists( 'wp_statistics_useronline' ) ) {
|
198 |
include WP_Statistics::$reg['plugin-dir'] . 'includes/functions/functions.php';
|
199 |
}
|
200 |
|
201 |
+
$this->agent = $this->get_UserAgent();
|
202 |
$WP_Statistics = $this;
|
203 |
|
204 |
if ( is_admin() ) {
|
209 |
new WP_Statistics_Frontend;
|
210 |
}
|
211 |
|
212 |
+
if ( $WP_Statistics->get_option( 'menu_bar' ) ) {
|
213 |
+
add_action( 'admin_bar_menu', 'WP_Statistics::menubar', 20 );
|
214 |
}
|
215 |
|
216 |
+
add_action( 'widgets_init', 'WP_Statistics::widget' );
|
217 |
+
add_shortcode( 'wpstatistics', 'WP_Statistics_Shortcode::shortcodes' );
|
218 |
}
|
219 |
|
220 |
/**
|
223 |
* @param string $class Class name
|
224 |
*/
|
225 |
public function autoload( $class ) {
|
226 |
+
if ( ! class_exists( $class ) && // This check is for performance of loading plugin classes
|
227 |
+
substr( $class, 0, 14 ) === 'WP_Statistics_'
|
228 |
) {
|
229 |
+
$lower_class_name = str_replace( '_', '-', strtolower( $class ) );
|
230 |
$class_full_path = WP_Statistics::$reg['plugin-dir'] .
|
231 |
'includes/classes/class-' .
|
232 |
$lower_class_name .
|
233 |
'.php';
|
234 |
+
if ( file_exists( $class_full_path ) ) {
|
235 |
require $class_full_path;
|
236 |
}
|
237 |
}
|
241 |
* Loads the init code.
|
242 |
*/
|
243 |
public function init() {
|
244 |
+
load_plugin_textdomain( 'wp-statistics', false, WP_Statistics::$reg['plugin-dir'] . 'languages' );
|
245 |
}
|
246 |
|
247 |
/**
|
248 |
* Set Time Zone
|
249 |
*/
|
250 |
+
public function set_timezone() {
|
251 |
+
if ( get_option( 'timezone_string' ) ) {
|
252 |
$this->tz_offset = timezone_offset_get(
|
253 |
+
timezone_open( get_option( 'timezone_string' ) ),
|
254 |
+
new DateTime()
|
255 |
);
|
256 |
+
} elseif ( get_option( 'gmt_offset' ) ) {
|
257 |
+
$this->tz_offset = get_option( 'gmt_offset' ) * 60 * 60;
|
258 |
}
|
259 |
}
|
260 |
|
369 |
/**
|
370 |
* Set Coefficient
|
371 |
*/
|
372 |
+
public function set_coefficient() {
|
373 |
// Set the default co-efficient.
|
374 |
+
$this->coefficient = $this->get_option( 'coefficient', 1 );
|
375 |
// Double check the co-efficient setting to make sure it's not been set to 0.
|
376 |
if ( $this->coefficient <= 0 ) {
|
377 |
$this->coefficient = 1;
|
381 |
/**
|
382 |
* Set IP Hash
|
383 |
*/
|
384 |
+
public function set_ip_hash() {
|
385 |
+
if ( $this->get_option( 'hash_ips' ) == true ) {
|
386 |
+
$this->ip_hash = '#hash#' . sha1( $this->ip . $_SERVER['HTTP_USER_AGENT'] );
|
387 |
}
|
388 |
}
|
389 |
|
391 |
* loads the options from WordPress,
|
392 |
*/
|
393 |
public function load_options() {
|
394 |
+
$this->options = get_option( 'wp_statistics' );
|
395 |
|
396 |
+
if ( ! is_array( $this->options ) ) {
|
397 |
$this->user_options = array();
|
398 |
}
|
399 |
}
|
402 |
* Registers Widget
|
403 |
*/
|
404 |
static function widget() {
|
405 |
+
register_widget( 'WP_Statistics_Widget' );
|
406 |
}
|
407 |
|
408 |
/**
|
421 |
}
|
422 |
|
423 |
// Not sure why, but get_user_meta() is returning an array or array's unless $single is set to true.
|
424 |
+
$this->user_options = get_user_meta( $this->user_id, 'wp_statistics', true );
|
425 |
|
426 |
+
if ( ! is_array( $this->user_options ) ) {
|
427 |
$this->user_options = array();
|
428 |
}
|
429 |
|
440 |
*/
|
441 |
public function get_option( $option, $default = null ) {
|
442 |
// If no options array exists, return FALSE.
|
443 |
+
if ( ! is_array( $this->options ) ) {
|
444 |
return false;
|
445 |
}
|
446 |
|
447 |
// if the option isn't set yet, return the $default if it exists, otherwise FALSE.
|
448 |
+
if ( ! array_key_exists( $option, $this->options ) ) {
|
449 |
if ( isset( $default ) ) {
|
450 |
return $default;
|
451 |
} else {
|
471 |
if ( $this->user_id == 0 ) {
|
472 |
return false;
|
473 |
}
|
474 |
+
if ( ! is_array( $this->user_options ) ) {
|
475 |
return false;
|
476 |
}
|
477 |
|
478 |
// if the option isn't set yet, return the $default if it exists, otherwise FALSE.
|
479 |
+
if ( ! array_key_exists( $option, $this->user_options ) ) {
|
480 |
if ( isset( $default ) ) {
|
481 |
return $default;
|
482 |
} else {
|
500 |
$this->options[ $option ] = $value;
|
501 |
|
502 |
// Write the array to the database.
|
503 |
+
update_option( 'wp_statistics', $this->options );
|
504 |
}
|
505 |
|
506 |
/**
|
522 |
$this->user_options[ $option ] = $value;
|
523 |
|
524 |
// Write the array to the database.
|
525 |
+
update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
|
526 |
}
|
527 |
|
528 |
/**
|
560 |
* Saves the current options array to the database.
|
561 |
*/
|
562 |
public function save_options() {
|
563 |
+
update_option( 'wp_statistics', $this->options );
|
564 |
}
|
565 |
|
566 |
/**
|
573 |
return false;
|
574 |
}
|
575 |
|
576 |
+
update_user_meta( $this->user_id, 'wp_statistics', $this->user_options );
|
577 |
}
|
578 |
|
579 |
/**
|
584 |
* @return bool
|
585 |
*/
|
586 |
public function isset_option( $option ) {
|
587 |
+
if ( ! is_array( $this->options ) ) {
|
588 |
return false;
|
589 |
}
|
590 |
|
591 |
+
return array_key_exists( $option, $this->options );
|
592 |
}
|
593 |
|
594 |
/**
|
602 |
if ( $this->user_id == 0 ) {
|
603 |
return false;
|
604 |
}
|
605 |
+
if ( ! is_array( $this->user_options ) ) {
|
606 |
return false;
|
607 |
}
|
608 |
|
609 |
+
return array_key_exists( $option, $this->user_options );
|
610 |
}
|
611 |
|
612 |
/**
|
617 |
public function Primary_Values() {
|
618 |
global $wpdb;
|
619 |
|
620 |
+
$this->result = $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_useronline" );
|
621 |
|
622 |
if ( ! $this->result ) {
|
623 |
|
625 |
$wpdb->prefix . "statistics_useronline",
|
626 |
array(
|
627 |
'ip' => $this->get_IP(),
|
628 |
+
'timestamp' => $this->Current_Date( 'U' ),
|
629 |
'date' => $this->Current_Date(),
|
630 |
'referred' => $this->get_Referred(),
|
631 |
'agent' => $this->agent['browser'],
|
635 |
);
|
636 |
}
|
637 |
|
638 |
+
$this->result = $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_visit" );
|
639 |
|
640 |
if ( ! $this->result ) {
|
641 |
|
643 |
$wpdb->prefix . "statistics_visit",
|
644 |
array(
|
645 |
'last_visit' => $this->Current_Date(),
|
646 |
+
'last_counter' => $this->Current_date( 'Y-m-d' ),
|
647 |
'visit' => 1,
|
648 |
)
|
649 |
);
|
650 |
}
|
651 |
|
652 |
+
$this->result = $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_visitor" );
|
653 |
|
654 |
if ( ! $this->result ) {
|
655 |
|
656 |
$wpdb->insert(
|
657 |
$wpdb->prefix . "statistics_visitor",
|
658 |
array(
|
659 |
+
'last_counter' => $this->Current_date( 'Y-m-d' ),
|
660 |
'referred' => $this->get_Referred(),
|
661 |
'agent' => $this->agent['browser'],
|
662 |
'platform' => $this->agent['platform'],
|
682 |
include( WP_Statistics::$reg['plugin-dir'] . 'includes/robotslist.php' );
|
683 |
}
|
684 |
|
685 |
+
$options['robotlist'] = trim( $wps_robotslist );
|
686 |
|
687 |
// By default, on new installs, use the new search table.
|
688 |
$options['search_converted'] = 1;
|
724 |
*/
|
725 |
private function get_ip_value( $ip ) {
|
726 |
// Reject anything that's not a string.
|
727 |
+
if ( ! is_string( $ip ) ) {
|
728 |
return false;
|
729 |
}
|
730 |
|
731 |
// Trim off any spaces.
|
732 |
+
$ip = trim( $ip );
|
733 |
|
734 |
// Process IPv4 and v6 addresses separately.
|
735 |
+
if ( $this->isValidIPv6( $ip ) ) {
|
736 |
// Reject any IPv6 addresses if IPv6 is not compiled in to this version of PHP.
|
737 |
+
if ( ! defined( 'AF_INET6' ) ) {
|
738 |
return false;
|
739 |
}
|
740 |
} else {
|
741 |
// Trim off any port values that exist.
|
742 |
+
if ( strstr( $ip, ':' ) !== false ) {
|
743 |
+
$temp = explode( ':', $ip );
|
744 |
$ip = $temp[0];
|
745 |
}
|
746 |
|
747 |
// Check to make sure the http header is actually an IP address and not some kind of SQL injection attack.
|
748 |
+
$long = ip2long( $ip );
|
749 |
|
750 |
// ip2long returns either -1 or FALSE if it is not a valid IP address depending on the PHP version, so check for both.
|
751 |
+
if ( $long == - 1 || $long === false ) {
|
752 |
return false;
|
753 |
}
|
754 |
}
|
776 |
}
|
777 |
|
778 |
// By default we use the remote address the server has.
|
779 |
+
if ( array_key_exists( 'REMOTE_ADDR', $_SERVER ) ) {
|
780 |
+
$temp_ip = $this->get_ip_value( $_SERVER['REMOTE_ADDR'] );
|
781 |
} else {
|
782 |
$temp_ip = '127.0.0.1';
|
783 |
}
|
803 |
);
|
804 |
|
805 |
foreach ( $envs as $env ) {
|
806 |
+
$temp_ip = $this->get_ip_value( getenv( $env ) );
|
807 |
|
808 |
if ( false !== $temp_ip ) {
|
809 |
$this->ip = $temp_ip;
|
828 |
* @return boolean - true/false
|
829 |
*/
|
830 |
private function isValidIPv6( $ip ) {
|
831 |
+
if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
|
832 |
return false;
|
833 |
} else {
|
834 |
return true;
|
842 |
*/
|
843 |
public function get_UserAgent() {
|
844 |
|
845 |
+
// Parse the agent string.
|
846 |
try {
|
847 |
$agent = parse_user_agent();
|
848 |
} catch ( Exception $e ) {
|
849 |
$agent = array(
|
850 |
+
'browser' => _x( 'Unknown', 'Browser', 'wp-statistics' ),
|
851 |
+
'platform' => _x( 'Unknown', 'Platform', 'wp-statistics' ),
|
852 |
+
'version' => _x( 'Unknown', 'Version', 'wp-statistics' ),
|
853 |
);
|
854 |
}
|
855 |
|
856 |
// null isn't a very good default, so set it to Unknown instead.
|
857 |
if ( $agent['browser'] == null ) {
|
858 |
+
$agent['browser'] = _x( 'Unknown', 'Browser', 'wp-statistics' );
|
859 |
}
|
860 |
if ( $agent['platform'] == null ) {
|
861 |
+
$agent['platform'] = _x( 'Unknown', 'Platform', 'wp-statistics' );
|
862 |
}
|
863 |
if ( $agent['version'] == null ) {
|
864 |
+
$agent['version'] = _x( 'Unknown', 'Version', 'wp-statistics' );
|
865 |
}
|
866 |
|
867 |
// Uncommon browsers often have some extra cruft, like brackets, http:// and other strings that we can strip out.
|
868 |
$strip_strings = array( '"', "'", '(', ')', ';', ':', '/', '[', ']', '{', '}', 'http' );
|
869 |
foreach ( $agent as $key => $value ) {
|
870 |
+
$agent[ $key ] = str_replace( $strip_strings, '', $agent[ $key ] );
|
871 |
}
|
872 |
|
873 |
return $agent;
|
894 |
$this->referrer = $default_referrer;
|
895 |
}
|
896 |
|
897 |
+
$this->referrer = esc_sql( strip_tags( $this->referrer ) );
|
898 |
|
899 |
if ( ! $this->referrer ) {
|
900 |
+
$this->referrer = get_bloginfo( 'url' );
|
901 |
}
|
902 |
|
903 |
+
if ( $this->get_option( 'addsearchwords', false ) ) {
|
904 |
// Check to see if this is a search engine referrer
|
905 |
+
$SEInfo = $this->Search_Engine_Info( $this->referrer );
|
906 |
|
907 |
+
if ( is_array( $SEInfo ) ) {
|
908 |
// If we're a known SE, check the query string
|
909 |
if ( $SEInfo['tag'] != '' ) {
|
910 |
+
$result = $this->Search_Engine_QueryString( $this->referrer );
|
911 |
|
912 |
// If there were no search words, let's add the page title
|
913 |
if ( $result == '' || $result == 'No search query found!' ) {
|
914 |
+
$result = wp_title( '', false );
|
915 |
if ( $result != '' ) {
|
916 |
$this->referrer = esc_url(
|
917 |
add_query_arg(
|
918 |
$SEInfo['querykey'],
|
919 |
+
urlencode( '~"' . $result . '"' ),
|
920 |
$this->referrer
|
921 |
)
|
922 |
);
|
938 |
* @return bool|string
|
939 |
*/
|
940 |
public function Local_Date( $format, $timestamp ) {
|
941 |
+
return date( $format, $timestamp + $this->tz_offset );
|
942 |
}
|
943 |
|
944 |
// Returns a date string in the desired format.
|
945 |
+
|
946 |
/**
|
947 |
* @param string $format
|
948 |
+
* @param null $strtotime
|
949 |
+
* @param null $relative
|
950 |
*
|
951 |
* @return bool|string
|
952 |
*/
|
954 |
|
955 |
if ( $strtotime ) {
|
956 |
if ( $relative ) {
|
957 |
+
return date( $format, strtotime( "{$strtotime} day", $relative ) + $this->tz_offset );
|
958 |
} else {
|
959 |
+
return date( $format, strtotime( "{$strtotime} day" ) + $this->tz_offset );
|
960 |
}
|
961 |
} else {
|
962 |
+
return date( $format, time() + $this->tz_offset );
|
963 |
}
|
964 |
}
|
965 |
|
967 |
* Returns a date string in the desired format.
|
968 |
*
|
969 |
* @param string $format
|
970 |
+
* @param null $strtotime
|
971 |
+
* @param null $relative
|
972 |
*
|
973 |
* @return bool|string
|
974 |
*/
|
976 |
|
977 |
if ( $strtotime ) {
|
978 |
if ( $relative ) {
|
979 |
+
return date( $format, strtotime( "{$strtotime} day", $relative ) );
|
980 |
} else {
|
981 |
+
return date( $format, strtotime( "{$strtotime} day" ) );
|
982 |
}
|
983 |
} else {
|
984 |
+
return date( $format, time() );
|
985 |
}
|
986 |
}
|
987 |
|
989 |
* Returns an internationalized date string in the desired format.
|
990 |
*
|
991 |
* @param string $format
|
992 |
+
* @param null $strtotime
|
993 |
* @param string $day
|
994 |
*
|
995 |
* @return string
|
997 |
public function Current_Date_i18n( $format = 'Y-m-d H:i:s', $strtotime = null, $day = ' day' ) {
|
998 |
|
999 |
if ( $strtotime ) {
|
1000 |
+
return date_i18n( $format, strtotime( "{$strtotime}{$day}" ) + $this->tz_offset );
|
1001 |
} else {
|
1002 |
+
return date_i18n( $format, time() + $this->tz_offset );
|
1003 |
}
|
1004 |
}
|
1005 |
|
1011 |
* @return int
|
1012 |
*/
|
1013 |
public function strtotimetz( $timestring ) {
|
1014 |
+
return strtotime( $timestring ) + $this->tz_offset;
|
1015 |
}
|
1016 |
|
1017 |
/**
|
1033 |
*/
|
1034 |
public function Check_Search_Engines( $search_engine_name, $search_engine = null ) {
|
1035 |
|
1036 |
+
if ( strstr( $search_engine, $search_engine_name ) ) {
|
1037 |
return 1;
|
1038 |
}
|
1039 |
}
|
1060 |
}
|
1061 |
|
1062 |
// Parse the URL in to it's component parts.
|
1063 |
+
$parts = parse_url( $url );
|
1064 |
|
1065 |
// Get the list of search engines we currently support.
|
1066 |
$search_engines = wp_statistics_searchengine_list();
|
1067 |
|
1068 |
// Loop through the SE list until we find which search engine matches.
|
1069 |
foreach ( $search_engines as $key => $value ) {
|
1070 |
+
$search_regex = wp_statistics_searchengine_regex( $key );
|
1071 |
|
1072 |
+
preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
|
1073 |
|
1074 |
if ( isset( $matches[1] ) ) {
|
1075 |
// Return the first matched SE.
|
1079 |
|
1080 |
// If no SE matched, return some defaults.
|
1081 |
return array(
|
1082 |
+
'name' => _x( 'Unknown', 'Search Engine', 'wp-statistics' ),
|
1083 |
'tag' => '',
|
1084 |
'sqlpattern' => '',
|
1085 |
'regexpattern' => '',
|
1107 |
// Get the list of search engines we currently support.
|
1108 |
$search_engines = wp_statistics_searchengine_list();
|
1109 |
|
1110 |
+
if ( array_key_exists( $engine, $search_engines ) ) {
|
1111 |
return $search_engines[ $engine ];
|
1112 |
}
|
1113 |
|
1114 |
// If no SE matched, return some defaults.
|
1115 |
return array(
|
1116 |
+
'name' => _x( 'Unknown', 'Search Engine', 'wp-statistics' ),
|
1117 |
'tag' => '',
|
1118 |
'sqlpattern' => '',
|
1119 |
'regexpattern' => '',
|
1142 |
}
|
1143 |
|
1144 |
// Parse the URL in to it's component parts.
|
1145 |
+
$parts = parse_url( $url );
|
1146 |
|
1147 |
// Check to see if there is a query component in the URL (everything after the ?). If there isn't one
|
1148 |
// set an empty array so we don't get errors later.
|
1149 |
+
if ( array_key_exists( 'query', $parts ) ) {
|
1150 |
+
parse_str( $parts['query'], $query );
|
1151 |
} else {
|
1152 |
$query = array();
|
1153 |
}
|
1157 |
|
1158 |
// Loop through the SE list until we find which search engine matches.
|
1159 |
foreach ( $search_engines as $key => $value ) {
|
1160 |
+
$search_regex = wp_statistics_searchengine_regex( $key );
|
1161 |
|
1162 |
+
preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
|
1163 |
|
1164 |
if ( isset( $matches[1] ) ) {
|
1165 |
// Check to see if the query key the SE uses exists in the query part of the URL.
|
1166 |
+
if ( array_key_exists( $search_engines[ $key ]['querykey'], $query ) ) {
|
1167 |
+
$words = strip_tags( $query[ $search_engines[ $key ]['querykey'] ] );
|
1168 |
} else {
|
1169 |
$words = '';
|
1170 |
}
|
1198 |
|
1199 |
switch ( $type ) {
|
1200 |
case 'visitors':
|
1201 |
+
if ( array_key_exists( 'visitors', $this->historical ) ) {
|
1202 |
return $this->historical['visitors'];
|
1203 |
} else {
|
1204 |
$result
|
1211 |
$this->historical['visitors'] = $count;
|
1212 |
}
|
1213 |
|
1214 |
+
break;
|
1215 |
case 'visits':
|
1216 |
+
if ( array_key_exists( 'visits', $this->historical ) ) {
|
1217 |
return $this->historical['visits'];
|
1218 |
} else {
|
1219 |
$result
|
1226 |
$this->historical['visits'] = $count;
|
1227 |
}
|
1228 |
|
1229 |
+
break;
|
1230 |
case 'uri':
|
1231 |
+
if ( array_key_exists( $id, $this->historical ) ) {
|
1232 |
return $this->historical[ $id ];
|
1233 |
} else {
|
1234 |
$result
|
1244 |
$this->historical[ $id ] = $count;
|
1245 |
}
|
1246 |
|
1247 |
+
break;
|
1248 |
case 'page':
|
1249 |
+
if ( array_key_exists( $id, $this->historical ) ) {
|
1250 |
return $this->historical[ $id ];
|
1251 |
} else {
|
1252 |
$result
|
1262 |
$this->historical[ $id ] = $count;
|
1263 |
}
|
1264 |
|
1265 |
+
break;
|
1266 |
}
|
1267 |
|
1268 |
return $count;
|
1294 |
$site_list = array();
|
1295 |
|
1296 |
// wp_get_sites() is deprecated in 4.6 or above and replaced with get_sites().
|
1297 |
+
if ( version_compare( $wp_version, '4.6', '>=' ) ) {
|
1298 |
$sites = get_sites();
|
1299 |
|
1300 |
foreach ( $sites as $site ) {
|
1319 |
*
|
1320 |
* @return string
|
1321 |
*/
|
1322 |
+
public function html_sanitize_referrer( $referrer, $length = - 1 ) {
|
1323 |
+
$referrer = trim( $referrer );
|
1324 |
|
1325 |
+
if ( 'data:' == strtolower( substr( $referrer, 0, 5 ) ) ) {
|
1326 |
$referrer = 'http://127.0.0.1';
|
1327 |
}
|
1328 |
|
1329 |
+
if ( 'javascript:' == strtolower( substr( $referrer, 0, 11 ) ) ) {
|
1330 |
$referrer = 'http://127.0.0.1';
|
1331 |
}
|
1332 |
|
1333 |
if ( $length > 0 ) {
|
1334 |
+
$referrer = substr( $referrer, 0, $length );
|
1335 |
}
|
1336 |
|
1337 |
+
return htmlentities( $referrer, ENT_QUOTES );
|
1338 |
}
|
1339 |
|
1340 |
/**
|
1345 |
*
|
1346 |
* @return string
|
1347 |
*/
|
1348 |
+
public function get_referrer_link( $referrer, $length = - 1 ) {
|
1349 |
+
$html_referrer = $this->html_sanitize_referrer( $referrer );
|
1350 |
+
if ( $length > 0 && strlen( $referrer ) > $length ) {
|
1351 |
+
$html_referrer_limited = $this->html_sanitize_referrer( $referrer, $length );
|
1352 |
$eplises = '[...]';
|
1353 |
} else {
|
1354 |
$html_referrer_limited = $html_referrer;
|
1355 |
$eplises = '';
|
1356 |
}
|
1357 |
|
1358 |
+
if ( substr( $html_referrer, 0, 7 ) !== 'http://' and substr( $html_referrer, 0, 8 ) !== 'https://' ) {
|
1359 |
// relative address, use '//' to adapt both http and https
|
1360 |
$html_nr_referrer = '//' . $html_referrer;
|
1361 |
} else {
|
1362 |
$html_nr_referrer = $html_referrer;
|
1363 |
}
|
1364 |
+
|
1365 |
return "<a href='{$html_nr_referrer}'><div class='dashicons dashicons-admin-links'></div>{$html_referrer_limited}{$eplises}</a>";
|
1366 |
}
|
1367 |
|
1376 |
return;
|
1377 |
}
|
1378 |
?>
|
1379 |
+
<div class="error">
|
1380 |
+
<p style="max-width:800px;">
|
1381 |
+
<b><?php _e(
|
1382 |
'WP Statistics Disabled',
|
1383 |
'wp-statistics'
|
1384 |
); ?></b> <?php _e(
|
1385 |
'— You are running an unsupported version of PHP.',
|
1386 |
'wp-statistics'
|
1387 |
); ?>
|
1388 |
+
</p>
|
1389 |
|
1390 |
+
<p style="max-width:800px;"><?php
|
1391 |
|
1392 |
echo sprintf(
|
1393 |
__(
|
1403 |
'wp-statistics'
|
1404 |
);
|
1405 |
?></p>
|
1406 |
+
</div>
|
1407 |
|
1408 |
<?php
|
1409 |
}
|
1416 |
|
1417 |
// Find out if the user can read or manage statistics.
|
1418 |
$read = current_user_can(
|
1419 |
+
wp_statistics_validate_capability(
|
1420 |
+
$WP_Statistics->get_option(
|
1421 |
+
'read_capability',
|
1422 |
+
'manage_options'
|
|
|
1423 |
)
|
1424 |
+
)
|
1425 |
);
|
1426 |
$manage = current_user_can(
|
1427 |
+
wp_statistics_validate_capability(
|
1428 |
+
$WP_Statistics->get_option(
|
1429 |
+
'manage_capability',
|
1430 |
+
'manage_options'
|
|
|
1431 |
)
|
1432 |
+
)
|
1433 |
);
|
1434 |
|
1435 |
if ( is_admin_bar_showing() && ( $read || $manage ) ) {
|
1436 |
|
1437 |
$AdminURL = get_admin_url();
|
1438 |
|
1439 |
+
if ( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) {
|
1440 |
$wp_admin_bar->add_menu(
|
1441 |
+
array(
|
1442 |
+
'id' => 'wp-statistic-menu',
|
1443 |
+
'title' => '<span class="ab-icon"></span>',
|
1444 |
+
'href' => $AdminURL . 'admin.php?page=' . WP_Statistics::$page['overview'],
|
1445 |
+
)
|
1446 |
);
|
1447 |
} else {
|
1448 |
$wp_admin_bar->add_menu(
|
1449 |
+
array(
|
1450 |
+
'id' => 'wp-statistic-menu',
|
1451 |
+
'title' => '<img src="' . WP_Statistics::$reg['plugin-url'] . 'assets/images/icon.png"/>',
|
1452 |
+
'href' => $AdminURL . 'admin.php?page=' . WP_Statistics::$page['overview'],
|
1453 |
+
)
|
1454 |
);
|
1455 |
}
|
1456 |
|
1457 |
$wp_admin_bar->add_menu(
|
1458 |
+
array(
|
1459 |
+
'id' => 'wp-statistics-menu-useronline',
|
1460 |
+
'parent' => 'wp-statistic-menu',
|
1461 |
+
'title' => __(
|
1462 |
+
'Online User',
|
1463 |
+
'wp-statistics'
|
1464 |
+
) . ": " . wp_statistics_useronline(),
|
1465 |
+
'href' => $AdminURL . 'admin.php?page=' . WP_Statistics::$page['online'],
|
1466 |
+
)
|
1467 |
);
|
1468 |
|
1469 |
$wp_admin_bar->add_menu(
|
1470 |
+
array(
|
1471 |
+
'id' => 'wp-statistics-menu-todayvisitor',
|
1472 |
+
'parent' => 'wp-statistic-menu',
|
1473 |
+
'title' => __( 'Today\'s Visitors', 'wp-statistics' ) . ": " . wp_statistics_visitor( 'today' ),
|
1474 |
+
)
|
1475 |
);
|
1476 |
|
1477 |
$wp_admin_bar->add_menu(
|
1478 |
+
array(
|
1479 |
+
'id' => 'wp-statistics-menu-todayvisit',
|
1480 |
+
'parent' => 'wp-statistic-menu',
|
1481 |
+
'title' => __( 'Today\'s Visits', 'wp-statistics' ) . ": " . wp_statistics_visit( 'today' ),
|
1482 |
+
)
|
1483 |
);
|
1484 |
|
1485 |
$wp_admin_bar->add_menu(
|
1486 |
+
array(
|
1487 |
+
'id' => 'wp-statistics-menu-yesterdayvisitor',
|
1488 |
+
'parent' => 'wp-statistic-menu',
|
1489 |
+
'title' => __( 'Yesterday\'s Visitors', 'wp-statistics' ) . ": " . wp_statistics_visitor(
|
1490 |
+
'yesterday'
|
1491 |
+
),
|
1492 |
+
)
|
1493 |
);
|
1494 |
|
1495 |
$wp_admin_bar->add_menu(
|
1496 |
+
array(
|
1497 |
+
'id' => 'wp-statistics-menu-yesterdayvisit',
|
1498 |
+
'parent' => 'wp-statistic-menu',
|
1499 |
+
'title' => __( 'Yesterday\'s Visits', 'wp-statistics' ) . ": " . wp_statistics_visit( 'yesterday' ),
|
1500 |
+
)
|
1501 |
);
|
1502 |
|
1503 |
$wp_admin_bar->add_menu(
|
1504 |
+
array(
|
1505 |
+
'id' => 'wp-statistics-menu-viewstats',
|
1506 |
+
'parent' => 'wp-statistic-menu',
|
1507 |
+
'title' => __( 'View Stats', 'wp-statistics' ),
|
1508 |
+
'href' => $AdminURL . 'admin.php?page=' . WP_Statistics::$page['overview'],
|
1509 |
+
)
|
1510 |
);
|
1511 |
}
|
1512 |
}
|
includes/functions/country-codes.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
It is used in several places in the plugin and is therefore centralized here for ease of update.
|
6 |
*/
|
7 |
-
$ISOCountryCode['000'] = _x('Unknown', 'Country', 'wp-statistics');
|
8 |
$ISOCountryCode['AF'] = "Afghanistan";
|
9 |
$ISOCountryCode['AX'] = "Åland Islands";
|
10 |
$ISOCountryCode['AL'] = "Albania";
|
4 |
|
5 |
It is used in several places in the plugin and is therefore centralized here for ease of update.
|
6 |
*/
|
7 |
+
$ISOCountryCode['000'] = _x( 'Unknown', 'Country', 'wp-statistics' );
|
8 |
$ISOCountryCode['AF'] = "Afghanistan";
|
9 |
$ISOCountryCode['AX'] = "Åland Islands";
|
10 |
$ISOCountryCode['AL'] = "Albania";
|
includes/functions/export.php
CHANGED
@@ -13,7 +13,7 @@ function wp_statistics_export_data() {
|
|
13 |
)
|
14 |
);
|
15 |
|
16 |
-
if ( current_user_can($manage_cap) ) {
|
17 |
$table = $_POST['table-to-export'];
|
18 |
$type = $_POST['export-file-type'];
|
19 |
|
@@ -35,19 +35,19 @@ function wp_statistics_export_data() {
|
|
35 |
|
36 |
if ( $table && $type ) {
|
37 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/github/elidickinson/php-export-data/php-export-data.class.php' );
|
38 |
-
|
39 |
-
$file_name = 'wp-statistics' . '-' . $WP_Statistics->Current_Date('Y-m-d-H-i');
|
40 |
|
41 |
switch ( $type ) {
|
42 |
case 'xml':
|
43 |
-
$exporter = new ExportDataExcel('browser', "{$file_name}.xml");
|
44 |
-
|
45 |
case 'csv':
|
46 |
-
$exporter = new ExportDataCSV('browser', "{$file_name}.csv");
|
47 |
-
|
48 |
case 'tsv':
|
49 |
-
$exporter = new ExportDataTSV('browser', "{$file_name}.tsv");
|
50 |
-
|
51 |
}
|
52 |
|
53 |
$exporter->initialize();
|
@@ -58,10 +58,10 @@ function wp_statistics_export_data() {
|
|
58 |
|
59 |
$i = 1;
|
60 |
$more_results = true;
|
61 |
-
$result = $wpdb->get_results($query, ARRAY_A);
|
62 |
|
63 |
// If we didn't get any rows, don't output anything.
|
64 |
-
if ( count($result) < 1 ) {
|
65 |
echo "No data in table!";
|
66 |
exit;
|
67 |
}
|
@@ -70,12 +70,12 @@ function wp_statistics_export_data() {
|
|
70 |
foreach ( $result[0] as $key => $col ) {
|
71 |
$columns[] = $key;
|
72 |
}
|
73 |
-
$exporter->addRow($columns);
|
74 |
}
|
75 |
|
76 |
while ( $more_results ) {
|
77 |
foreach ( $result as $row ) {
|
78 |
-
$exporter->addRow($row);
|
79 |
|
80 |
// Make sure we've flushed the output buffer so we don't run out of memory on large exports.
|
81 |
ob_flush();
|
@@ -86,13 +86,13 @@ function wp_statistics_export_data() {
|
|
86 |
$wpdb->flush();
|
87 |
|
88 |
$query = $query_base . ' LIMIT ' . ( $i * 1000 ) . ',1000';
|
89 |
-
$result = $wpdb->get_results($query, ARRAY_A);
|
90 |
|
91 |
-
if ( count($result) == 0 ) {
|
92 |
$more_results = false;
|
93 |
}
|
94 |
|
95 |
-
$i++;
|
96 |
}
|
97 |
|
98 |
$exporter->finalize();
|
13 |
)
|
14 |
);
|
15 |
|
16 |
+
if ( current_user_can( $manage_cap ) ) {
|
17 |
$table = $_POST['table-to-export'];
|
18 |
$type = $_POST['export-file-type'];
|
19 |
|
35 |
|
36 |
if ( $table && $type ) {
|
37 |
require( WP_Statistics::$reg['plugin-dir'] . 'includes/github/elidickinson/php-export-data/php-export-data.class.php' );
|
38 |
+
|
39 |
+
$file_name = 'wp-statistics' . '-' . $WP_Statistics->Current_Date( 'Y-m-d-H-i' );
|
40 |
|
41 |
switch ( $type ) {
|
42 |
case 'xml':
|
43 |
+
$exporter = new ExportDataExcel( 'browser', "{$file_name}.xml" );
|
44 |
+
break;
|
45 |
case 'csv':
|
46 |
+
$exporter = new ExportDataCSV( 'browser', "{$file_name}.csv" );
|
47 |
+
break;
|
48 |
case 'tsv':
|
49 |
+
$exporter = new ExportDataTSV( 'browser', "{$file_name}.tsv" );
|
50 |
+
break;
|
51 |
}
|
52 |
|
53 |
$exporter->initialize();
|
58 |
|
59 |
$i = 1;
|
60 |
$more_results = true;
|
61 |
+
$result = $wpdb->get_results( $query, ARRAY_A );
|
62 |
|
63 |
// If we didn't get any rows, don't output anything.
|
64 |
+
if ( count( $result ) < 1 ) {
|
65 |
echo "No data in table!";
|
66 |
exit;
|
67 |
}
|
70 |
foreach ( $result[0] as $key => $col ) {
|
71 |
$columns[] = $key;
|
72 |
}
|
73 |
+
$exporter->addRow( $columns );
|
74 |
}
|
75 |
|
76 |
while ( $more_results ) {
|
77 |
foreach ( $result as $row ) {
|
78 |
+
$exporter->addRow( $row );
|
79 |
|
80 |
// Make sure we've flushed the output buffer so we don't run out of memory on large exports.
|
81 |
ob_flush();
|
86 |
$wpdb->flush();
|
87 |
|
88 |
$query = $query_base . ' LIMIT ' . ( $i * 1000 ) . ',1000';
|
89 |
+
$result = $wpdb->get_results( $query, ARRAY_A );
|
90 |
|
91 |
+
if ( count( $result ) == 0 ) {
|
92 |
$more_results = false;
|
93 |
}
|
94 |
|
95 |
+
$i ++;
|
96 |
}
|
97 |
|
98 |
$exporter->finalize();
|
includes/functions/functions.php
CHANGED
@@ -11,7 +11,7 @@ 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.
|
@@ -45,42 +45,42 @@ function wp_statistics_visit( $time, $daily = null ) {
|
|
45 |
$result = $wpdb->get_var(
|
46 |
"SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'"
|
47 |
);
|
48 |
-
|
49 |
|
50 |
case 'yesterday':
|
51 |
$result = $wpdb->get_var(
|
52 |
"SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'"
|
53 |
);
|
54 |
-
|
55 |
|
56 |
case 'week':
|
57 |
$result = $wpdb->get_var(
|
58 |
"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' )}'"
|
59 |
);
|
60 |
-
|
61 |
|
62 |
case 'month':
|
63 |
$result = $wpdb->get_var(
|
64 |
"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' )}'"
|
65 |
);
|
66 |
-
|
67 |
|
68 |
case 'year':
|
69 |
$result = $wpdb->get_var(
|
70 |
"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' )}'"
|
71 |
);
|
72 |
-
|
73 |
|
74 |
case 'total':
|
75 |
-
$result = $wpdb->get_var("SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit");
|
76 |
-
$result += $WP_Statistics->Get_Historical_Data('visits');
|
77 |
-
|
78 |
|
79 |
default:
|
80 |
$result = $wpdb->get_var(
|
81 |
"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' )}'"
|
82 |
);
|
83 |
-
|
84 |
}
|
85 |
}
|
86 |
|
@@ -125,53 +125,53 @@ function wp_statistics_visitor( $time, $daily = null, $countonly = false ) {
|
|
125 |
case 'today':
|
126 |
$sqlstatement
|
127 |
= "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
|
128 |
-
|
129 |
|
130 |
case 'yesterday':
|
131 |
$sqlstatement
|
132 |
= "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'";
|
133 |
-
|
134 |
|
135 |
case 'week':
|
136 |
$sqlstatement
|
137 |
= "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' )}'";
|
138 |
-
|
139 |
|
140 |
case 'month':
|
141 |
$sqlstatement
|
142 |
= "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' )}'";
|
143 |
-
|
144 |
|
145 |
case 'year':
|
146 |
$sqlstatement
|
147 |
= "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' )}'";
|
148 |
-
|
149 |
|
150 |
case 'total':
|
151 |
$sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor";
|
152 |
-
$history = $WP_Statistics->Get_Historical_Data('visitors');
|
153 |
-
|
154 |
|
155 |
default:
|
156 |
$sqlstatement
|
157 |
= "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' )}'";
|
158 |
-
|
159 |
}
|
160 |
}
|
161 |
|
162 |
// Execute the SQL call, if we're only counting we can use get_var(), otherwise we use query().
|
163 |
if ( $countonly == true ) {
|
164 |
-
$result = $wpdb->get_var($sqlstatement);
|
165 |
$result += $history;
|
166 |
} else {
|
167 |
-
$result = $wpdb->query($sqlstatement);
|
168 |
}
|
169 |
|
170 |
return $result;
|
171 |
}
|
172 |
|
173 |
// This function returns the statistics for a given page.
|
174 |
-
function wp_statistics_pages( $time, $page_uri = '', $id = -1, $rangestartdate = null, $rangeenddate = null ) {
|
175 |
|
176 |
// We need database and the global $WP_Statistics object access.
|
177 |
global $wpdb, $WP_Statistics;
|
@@ -184,14 +184,14 @@ function wp_statistics_pages( $time, $page_uri = '', $id = -1, $rangestartdate =
|
|
184 |
$page_uri = wp_statistics_get_uri();
|
185 |
}
|
186 |
|
187 |
-
$page_uri_sql = esc_sql($page_uri);
|
188 |
|
189 |
// If a page/post ID has been passed, use it to select the rows, otherwise use the URI.
|
190 |
// Note that a single page/post ID can have multiple URI's associated with it.
|
191 |
-
if ( $id != -1 ) {
|
192 |
-
$page_sql = '`id` = ' . absint($id);
|
193 |
$history_key = 'page';
|
194 |
-
$history_id = absint($id);
|
195 |
} else {
|
196 |
$page_sql = "`URI` = '{$page_uri_sql}'";
|
197 |
$history_key = 'uri';
|
@@ -204,48 +204,48 @@ function wp_statistics_pages( $time, $page_uri = '', $id = -1, $rangestartdate =
|
|
204 |
case 'today':
|
205 |
$sqlstatement
|
206 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
|
207 |
-
|
208 |
|
209 |
case 'yesterday':
|
210 |
$sqlstatement
|
211 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$page_sql}";
|
212 |
-
|
213 |
|
214 |
case 'week':
|
215 |
$sqlstatement
|
216 |
= "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}";
|
217 |
-
|
218 |
|
219 |
case 'month':
|
220 |
$sqlstatement
|
221 |
= "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}";
|
222 |
-
|
223 |
|
224 |
case 'year':
|
225 |
$sqlstatement
|
226 |
= "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}";
|
227 |
-
|
228 |
|
229 |
case 'total':
|
230 |
$sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE {$page_sql}";
|
231 |
-
$history = $WP_Statistics->Get_Historical_Data($history_key, $history_id);
|
232 |
-
|
233 |
case 'range':
|
234 |
$sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '" .
|
235 |
-
$WP_Statistics->Current_Date('Y-m-d', '-0', strtotime($rangestartdate)) .
|
236 |
"' AND '" .
|
237 |
-
$WP_Statistics->Current_Date('Y-m-d', '-0', strtotime($rangeenddate)) .
|
238 |
"' AND {$page_sql}";
|
239 |
|
240 |
-
|
241 |
default:
|
242 |
$sqlstatement
|
243 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$page_sql}";
|
244 |
-
|
245 |
}
|
246 |
|
247 |
// Since this function only every returns a count, just use get_var().
|
248 |
-
$result = $wpdb->get_var($sqlstatement);
|
249 |
$result += $history;
|
250 |
|
251 |
// If we have an empty result, return 0 instead of a blank.
|
@@ -268,7 +268,7 @@ function wp_statistics_uri_to_id( $uri ) {
|
|
268 |
);
|
269 |
|
270 |
// Execute the query.
|
271 |
-
$result = $wpdb->get_var($sqlstatement);
|
272 |
|
273 |
// If we returned a false or some other 0 equivalent value, make sure $result is set to an integer 0.
|
274 |
if ( $result == 0 ) {
|
@@ -298,7 +298,7 @@ function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = nu
|
|
298 |
ARRAY_N
|
299 |
);
|
300 |
} else {
|
301 |
-
$result = $wpdb->get_results("SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N);
|
302 |
}
|
303 |
|
304 |
$total = 0;
|
@@ -307,15 +307,15 @@ function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = nu
|
|
307 |
// Now get the total page visit count for each unique URI.
|
308 |
foreach ( $result as $out ) {
|
309 |
// Increment the total number of results.
|
310 |
-
$total++;
|
311 |
|
312 |
// Retreive the post ID for the URI.
|
313 |
-
$id = wp_statistics_uri_to_id($out[0]);
|
314 |
|
315 |
// Lookup the post title.
|
316 |
-
$post = get_post($id);
|
317 |
|
318 |
-
if ( is_object($post) ) {
|
319 |
$title = $post->post_title;
|
320 |
} else {
|
321 |
if ( $out[0] == '/' ) {
|
@@ -329,19 +329,19 @@ function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = nu
|
|
329 |
if ( $rangestartdate != null && $rangeenddate != null ) {
|
330 |
$uris[] = array(
|
331 |
$out[0],
|
332 |
-
wp_statistics_pages('range', $out[0], -1, $rangestartdate, $rangeenddate),
|
333 |
$id,
|
334 |
$title,
|
335 |
);
|
336 |
} else {
|
337 |
-
$uris[] = array( $out[0], wp_statistics_pages('total', $out[0]), $id, $title );
|
338 |
}
|
339 |
}
|
340 |
|
341 |
// If we have more than one result, let's sort them using usort.
|
342 |
-
if ( count($uris) > 1 ) {
|
343 |
// Sort the URI's based on their hit count.
|
344 |
-
usort($uris, 'wp_stats_compare_uri_hits');
|
345 |
}
|
346 |
|
347 |
return array( $total, $uris );
|
@@ -350,12 +350,12 @@ function wp_statistics_get_top_pages( $rangestartdate = null, $rangeenddate = nu
|
|
350 |
// This function gets the current page URI.
|
351 |
function wp_statistics_get_uri() {
|
352 |
// Get the site's path from the URL.
|
353 |
-
$site_uri = parse_url(site_url(), PHP_URL_PATH);
|
354 |
-
$site_uri_len = strlen($site_uri);
|
355 |
|
356 |
// Get the site's path from the URL.
|
357 |
-
$home_uri = parse_url(home_url(), PHP_URL_PATH);
|
358 |
-
$home_uri_len = strlen($home_uri);
|
359 |
|
360 |
// Get the current page URI.
|
361 |
$page_uri = $_SERVER["REQUEST_URI"];
|
@@ -369,20 +369,20 @@ function wp_statistics_get_uri() {
|
|
369 |
* we check for "/site", but in the reverse case, we need to swap the order of the check.
|
370 |
*/
|
371 |
if ( $site_uri_len > $home_uri_len ) {
|
372 |
-
if ( substr($page_uri, 0, $site_uri_len) == $site_uri ) {
|
373 |
-
$page_uri = substr($page_uri, $site_uri_len);
|
374 |
}
|
375 |
|
376 |
-
if ( substr($page_uri, 0, $home_uri_len) == $home_uri ) {
|
377 |
-
$page_uri = substr($page_uri, $home_uri_len);
|
378 |
}
|
379 |
} else {
|
380 |
-
if ( substr($page_uri, 0, $home_uri_len) == $home_uri ) {
|
381 |
-
$page_uri = substr($page_uri, $home_uri_len);
|
382 |
}
|
383 |
|
384 |
-
if ( substr($page_uri, 0, $site_uri_len) == $site_uri ) {
|
385 |
-
$page_uri = substr($page_uri, $site_uri_len);
|
386 |
}
|
387 |
}
|
388 |
|
@@ -409,7 +409,7 @@ function wp_statistics_ua_list( $rangestartdate = null, $rangeenddate = null ) {
|
|
409 |
ARRAY_N
|
410 |
);
|
411 |
} else {
|
412 |
-
$result = $wpdb->get_results("SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor", ARRAY_N);
|
413 |
}
|
414 |
|
415 |
$Browers = array();
|
@@ -437,7 +437,7 @@ function wp_statistics_useragent( $agent, $rangestartdate = null, $rangeenddate
|
|
437 |
);
|
438 |
} else {
|
439 |
$result = $wpdb->get_var(
|
440 |
-
$wpdb->prepare("SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent)
|
441 |
);
|
442 |
}
|
443 |
|
@@ -459,7 +459,7 @@ function wp_statistics_platform_list( $rangestartdate = null, $rangeenddate = nu
|
|
459 |
ARRAY_N
|
460 |
);
|
461 |
} else {
|
462 |
-
$result = $wpdb->get_results("SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor", ARRAY_N);
|
463 |
}
|
464 |
|
465 |
$Platforms = array();
|
@@ -514,7 +514,7 @@ function wp_statistics_agent_version_list( $agent, $rangestartdate = null, $rang
|
|
514 |
);
|
515 |
} else {
|
516 |
$result = $wpdb->get_results(
|
517 |
-
$wpdb->prepare("SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s", $agent),
|
518 |
ARRAY_N
|
519 |
);
|
520 |
}
|
@@ -575,7 +575,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
575 |
$default = $engines = array(
|
576 |
'ask' => array(
|
577 |
'name' => 'Ask.com',
|
578 |
-
'translated' => __('Ask.com', 'wp-statistics'),
|
579 |
'tag' => 'ask',
|
580 |
'sqlpattern' => '%ask.com%',
|
581 |
'regexpattern' => 'ask\.com',
|
@@ -584,7 +584,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
584 |
),
|
585 |
'baidu' => array(
|
586 |
'name' => 'Baidu',
|
587 |
-
'translated' => __('Baidu', 'wp-statistics'),
|
588 |
'tag' => 'baidu',
|
589 |
'sqlpattern' => '%baidu.com%',
|
590 |
'regexpattern' => 'baidu\.com',
|
@@ -593,7 +593,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
593 |
),
|
594 |
'bing' => array(
|
595 |
'name' => 'Bing',
|
596 |
-
'translated' => __('Bing', 'wp-statistics'),
|
597 |
'tag' => 'bing',
|
598 |
'sqlpattern' => '%bing.com%',
|
599 |
'regexpattern' => 'bing\.com',
|
@@ -602,7 +602,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
602 |
),
|
603 |
'clearch' => array(
|
604 |
'name' => 'clearch.org',
|
605 |
-
'translated' => __('clearch.org', 'wp-statistics'),
|
606 |
'tag' => 'clearch',
|
607 |
'sqlpattern' => '%clearch.org%',
|
608 |
'regexpattern' => 'clearch\.org',
|
@@ -611,7 +611,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
611 |
),
|
612 |
'duckduckgo' => array(
|
613 |
'name' => 'DuckDuckGo',
|
614 |
-
'translated' => __('DuckDuckGo', 'wp-statistics'),
|
615 |
'tag' => 'duckduckgo',
|
616 |
'sqlpattern' => array( '%duckduckgo.com%', '%ddg.gg%' ),
|
617 |
'regexpattern' => array( 'duckduckgo\.com', 'ddg\.gg' ),
|
@@ -620,7 +620,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
620 |
),
|
621 |
'google' => array(
|
622 |
'name' => 'Google',
|
623 |
-
'translated' => __('Google', 'wp-statistics'),
|
624 |
'tag' => 'google',
|
625 |
'sqlpattern' => '%google.%',
|
626 |
'regexpattern' => 'google\.',
|
@@ -629,7 +629,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
629 |
),
|
630 |
'yahoo' => array(
|
631 |
'name' => 'Yahoo!',
|
632 |
-
'translated' => __('Yahoo!', 'wp-statistics'),
|
633 |
'tag' => 'yahoo',
|
634 |
'sqlpattern' => '%yahoo.com%',
|
635 |
'regexpattern' => 'yahoo\.com',
|
@@ -638,7 +638,7 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
638 |
),
|
639 |
'yandex' => array(
|
640 |
'name' => 'Yandex',
|
641 |
-
'translated' => __('Yandex', 'wp-statistics'),
|
642 |
'tag' => 'yandex',
|
643 |
'sqlpattern' => '%yandex.ru%',
|
644 |
'regexpattern' => 'yandex\.ru',
|
@@ -649,13 +649,13 @@ function wp_statistics_searchengine_list( $all = false ) {
|
|
649 |
|
650 |
if ( $all == false ) {
|
651 |
foreach ( $engines as $key => $engine ) {
|
652 |
-
if ( $WP_Statistics->get_option('disable_se_' . $engine['tag']) ) {
|
653 |
unset( $engines[ $key ] );
|
654 |
}
|
655 |
}
|
656 |
|
657 |
// If we've disabled all the search engines, reset the list back to default.
|
658 |
-
if ( count($engines) == 0 ) {
|
659 |
$engines = $default;
|
660 |
}
|
661 |
}
|
@@ -671,27 +671,27 @@ function wp_statistics_searchword_query( $search_engine = 'all' ) {
|
|
671 |
$searchengine_list = wp_statistics_searchengine_list();
|
672 |
$search_query = '';
|
673 |
|
674 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
675 |
// Are we getting results for all search engines or a specific one?
|
676 |
-
if ( strtolower($search_engine) == 'all' ) {
|
677 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
678 |
foreach ( $searchengine_list as $key => $se ) {
|
679 |
$search_query .= "( `engine` = '{$key}' AND `words` <> '' ) OR ";
|
680 |
}
|
681 |
|
682 |
// Trim off the last ' OR ' for the loop above.
|
683 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
684 |
} else {
|
685 |
$search_query .= "`engine` = '{$search_engine}' AND `words` <> ''";
|
686 |
}
|
687 |
} else {
|
688 |
// Are we getting results for all search engines or a specific one?
|
689 |
-
if ( strtolower($search_engine) == 'all' ) {
|
690 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
691 |
// NOTE: This SQL query can be *VERY* long.
|
692 |
foreach ( $searchengine_list as $se ) {
|
693 |
// 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.
|
694 |
-
if ( is_array($se['sqlpattern']) ) {
|
695 |
foreach ( $se['sqlpattern'] as $subse ) {
|
696 |
$search_query .= "(`referred` LIKE '{$subse}{$se['querykey']}=%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=') OR ";
|
697 |
}
|
@@ -701,16 +701,16 @@ function wp_statistics_searchword_query( $search_engine = 'all' ) {
|
|
701 |
}
|
702 |
|
703 |
// Trim off the last ' OR ' for the loop above.
|
704 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
705 |
} else {
|
706 |
// 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.
|
707 |
-
if ( is_array($searchengine_list[ $search_engine ]['sqlpattern']) ) {
|
708 |
foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
|
709 |
$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 ";
|
710 |
}
|
711 |
|
712 |
// Trim off the last ' OR ' for the loop above.
|
713 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
714 |
} else {
|
715 |
$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']}=')";
|
716 |
}
|
@@ -728,56 +728,56 @@ function wp_statistics_searchengine_query( $search_engine = 'all' ) {
|
|
728 |
$searchengine_list = wp_statistics_searchengine_list();
|
729 |
$search_query = '';
|
730 |
|
731 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
732 |
// Are we getting results for all search engines or a specific one?
|
733 |
-
if ( strtolower($search_engine) == 'all' ) {
|
734 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
735 |
foreach ( $searchengine_list as $key => $se ) {
|
736 |
-
$key
|
737 |
$search_query .= "`engine` = '{$key}' OR ";
|
738 |
}
|
739 |
|
740 |
// Trim off the last ' OR ' for the loop above.
|
741 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
742 |
} else {
|
743 |
-
$search_engine = esc_sql($search_engine);
|
744 |
-
$search_query
|
745 |
}
|
746 |
} else {
|
747 |
// Are we getting results for all search engines or a specific one?
|
748 |
-
if ( strtolower($search_engine) == 'all' ) {
|
749 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
750 |
// NOTE: This SQL query can be long.
|
751 |
foreach ( $searchengine_list as $se ) {
|
752 |
// 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.
|
753 |
-
if ( is_array($se['sqlpattern']) ) {
|
754 |
foreach ( $se['sqlpattern'] as $subse ) {
|
755 |
-
$subse
|
756 |
$search_query .= "`referred` LIKE '{$subse}' OR ";
|
757 |
}
|
758 |
} else {
|
759 |
-
$se['sqlpattern'] = esc_sql($se['sqlpattern']);
|
760 |
-
$search_query
|
761 |
}
|
762 |
}
|
763 |
|
764 |
// Trim off the last ' OR ' for the loop above.
|
765 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
766 |
} else {
|
767 |
// 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.
|
768 |
-
if ( is_array($searchengine_list[ $search_engine ]['sqlpattern']) ) {
|
769 |
foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
|
770 |
-
$se
|
771 |
$search_query .= "`referred` LIKE '{$se}' OR ";
|
772 |
}
|
773 |
|
774 |
// Trim off the last ' OR ' for the loop above.
|
775 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 4);
|
776 |
} else {
|
777 |
$searchengine_list[ $search_engine ]['sqlpattern'] = esc_sql(
|
778 |
$searchengine_list[ $search_engine ]['sqlpattern']
|
779 |
);
|
780 |
-
$search_query
|
781 |
}
|
782 |
}
|
783 |
}
|
@@ -793,10 +793,10 @@ function wp_statistics_searchengine_regex( $search_engine = 'all' ) {
|
|
793 |
$search_query = '';
|
794 |
|
795 |
// Are we getting results for all search engines or a specific one?
|
796 |
-
if ( strtolower($search_engine) == 'all' ) {
|
797 |
foreach ( $searchengine_list as $se ) {
|
798 |
// 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.
|
799 |
-
if ( is_array($se['regexpattern']) ) {
|
800 |
foreach ( $se['regexpattern'] as $subse ) {
|
801 |
$search_query .= "{$subse}|";
|
802 |
}
|
@@ -806,16 +806,16 @@ function wp_statistics_searchengine_regex( $search_engine = 'all' ) {
|
|
806 |
}
|
807 |
|
808 |
// Trim off the last '|' for the loop above.
|
809 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 1);
|
810 |
} else {
|
811 |
// 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.
|
812 |
-
if ( is_array($searchengine_list[ $search_engine ]['regexpattern']) ) {
|
813 |
foreach ( $searchengine_list[ $search_engine ]['regexpattern'] as $se ) {
|
814 |
$search_query .= "{$se}|";
|
815 |
}
|
816 |
|
817 |
// Trim off the last '|' for the loop above.
|
818 |
-
$search_query = substr($search_query, 0, strlen($search_query) - 1);
|
819 |
} else {
|
820 |
$search_query .= $searchengine_list[ $search_engine ]['regexpattern'];
|
821 |
}
|
@@ -833,14 +833,14 @@ function wp_statistics_searchengine( $search_engine = 'all', $time = 'total' ) {
|
|
833 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
834 |
$tablename = $wpdb->prefix . 'statistics_';
|
835 |
|
836 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
837 |
$tablename .= 'search';
|
838 |
} else {
|
839 |
$tablename .= 'visitor';
|
840 |
}
|
841 |
|
842 |
// Get a complete list of search engines
|
843 |
-
$search_query = wp_statistics_searchengine_query($search_engine);
|
844 |
|
845 |
// This function accepts several options for time parameter, each one has a unique SQL query string.
|
846 |
// They're pretty self explanatory.
|
@@ -849,47 +849,47 @@ function wp_statistics_searchengine( $search_engine = 'all', $time = 'total' ) {
|
|
849 |
$result = $wpdb->query(
|
850 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}"
|
851 |
);
|
852 |
-
|
853 |
|
854 |
case 'yesterday':
|
855 |
$result = $wpdb->query(
|
856 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}"
|
857 |
);
|
858 |
|
859 |
-
|
860 |
|
861 |
case 'week':
|
862 |
$result = $wpdb->query(
|
863 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}"
|
864 |
);
|
865 |
|
866 |
-
|
867 |
|
868 |
case 'month':
|
869 |
$result = $wpdb->query(
|
870 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}"
|
871 |
);
|
872 |
|
873 |
-
|
874 |
|
875 |
case 'year':
|
876 |
$result = $wpdb->query(
|
877 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}"
|
878 |
);
|
879 |
|
880 |
-
|
881 |
|
882 |
case 'total':
|
883 |
-
$result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE {$search_query}");
|
884 |
|
885 |
-
|
886 |
|
887 |
default:
|
888 |
$result = $wpdb->query(
|
889 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time)}' AND {$search_query}"
|
890 |
);
|
891 |
|
892 |
-
|
893 |
}
|
894 |
|
895 |
return $result;
|
@@ -903,14 +903,14 @@ function wp_statistics_searchword( $search_engine = 'all', $time = 'total' ) {
|
|
903 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
904 |
$tablename = $wpdb->prefix . 'statistics_';
|
905 |
|
906 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
907 |
$tablename .= 'search';
|
908 |
} else {
|
909 |
$tablename .= 'visitor';
|
910 |
}
|
911 |
|
912 |
// Get a complete list of search engines
|
913 |
-
$search_query = wp_statistics_searchword_query($search_engine);
|
914 |
|
915 |
// This function accepts several options for time parameter, each one has a unique SQL query string.
|
916 |
// They're pretty self explanatory.
|
@@ -919,47 +919,47 @@ function wp_statistics_searchword( $search_engine = 'all', $time = 'total' ) {
|
|
919 |
$result = $wpdb->query(
|
920 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}"
|
921 |
);
|
922 |
-
|
923 |
|
924 |
case 'yesterday':
|
925 |
$result = $wpdb->query(
|
926 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}"
|
927 |
);
|
928 |
|
929 |
-
|
930 |
|
931 |
case 'week':
|
932 |
$result = $wpdb->query(
|
933 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}"
|
934 |
);
|
935 |
|
936 |
-
|
937 |
|
938 |
case 'month':
|
939 |
$result = $wpdb->query(
|
940 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}"
|
941 |
);
|
942 |
|
943 |
-
|
944 |
|
945 |
case 'year':
|
946 |
$result = $wpdb->query(
|
947 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}"
|
948 |
);
|
949 |
|
950 |
-
|
951 |
|
952 |
case 'total':
|
953 |
-
$result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE {$search_query}");
|
954 |
|
955 |
-
|
956 |
|
957 |
default:
|
958 |
$result = $wpdb->query(
|
959 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$search_query}"
|
960 |
);
|
961 |
|
962 |
-
|
963 |
}
|
964 |
|
965 |
return $result;
|
@@ -968,11 +968,11 @@ function wp_statistics_searchword( $search_engine = 'all', $time = 'total' ) {
|
|
968 |
// This function will return the total number of posts in WordPress.
|
969 |
function wp_statistics_countposts() {
|
970 |
|
971 |
-
$count_posts = wp_count_posts('post');
|
972 |
|
973 |
$ret = 0;
|
974 |
|
975 |
-
if ( is_object($count_posts) ) {
|
976 |
$ret = $count_posts->publish;
|
977 |
}
|
978 |
|
@@ -982,11 +982,11 @@ function wp_statistics_countposts() {
|
|
982 |
// This function will return the total number of pages in WordPress.
|
983 |
function wp_statistics_countpages() {
|
984 |
|
985 |
-
$count_pages = wp_count_posts('page');
|
986 |
|
987 |
$ret = 0;
|
988 |
|
989 |
-
if ( is_object($count_pages) ) {
|
990 |
$ret = $count_pages->publish;
|
991 |
}
|
992 |
|
@@ -998,7 +998,7 @@ function wp_statistics_countcomment() {
|
|
998 |
|
999 |
global $wpdb;
|
1000 |
|
1001 |
-
$countcomms = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'");
|
1002 |
|
1003 |
return $countcomms;
|
1004 |
}
|
@@ -1006,7 +1006,7 @@ function wp_statistics_countcomment() {
|
|
1006 |
// This function will return the total number of spam comments *IF* akismet is installed.
|
1007 |
function wp_statistics_countspam() {
|
1008 |
|
1009 |
-
return number_format_i18n(get_option('akismet_spam_count'));
|
1010 |
}
|
1011 |
|
1012 |
// This function will return the total number of users in WordPress.
|
@@ -1026,9 +1026,9 @@ function wp_statistics_lastpostdate() {
|
|
1026 |
"SELECT post_date FROM {$wpdb->posts} WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1"
|
1027 |
);
|
1028 |
|
1029 |
-
$date_format = get_option('date_format');
|
1030 |
|
1031 |
-
return $WP_Statistics->Current_Date_i18n($date_format, $db_date, false);
|
1032 |
}
|
1033 |
|
1034 |
// This function will return the average number of posts per day that are published on your site.
|
@@ -1045,7 +1045,7 @@ function wp_statistics_average_post( $days = false ) {
|
|
1045 |
);
|
1046 |
|
1047 |
$days_spend = intval(
|
1048 |
-
( time() - strtotime($get_first_post) ) / 86400
|
1049 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1050 |
|
1051 |
if ( $days == true ) {
|
@@ -1053,13 +1053,13 @@ function wp_statistics_average_post( $days = false ) {
|
|
1053 |
$get_total_post = 1;
|
1054 |
} // Avoid divide by zero errors.
|
1055 |
|
1056 |
-
return round($days_spend / $get_total_post, 0);
|
1057 |
} else {
|
1058 |
if ( $days_spend == 0 ) {
|
1059 |
$days_spend = 1;
|
1060 |
} // Avoid divide by zero errors.
|
1061 |
|
1062 |
-
return round($get_total_post / $days_spend, 2);
|
1063 |
}
|
1064 |
}
|
1065 |
|
@@ -1069,11 +1069,11 @@ function wp_statistics_average_comment( $days = false ) {
|
|
1069 |
|
1070 |
global $wpdb;
|
1071 |
|
1072 |
-
$get_first_comment = $wpdb->get_var("SELECT comment_date FROM {$wpdb->comments} ORDER BY comment_date LIMIT 1");
|
1073 |
-
$get_total_comment = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'");
|
1074 |
|
1075 |
$days_spend = intval(
|
1076 |
-
( time() - strtotime($get_first_comment) ) / 86400
|
1077 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1078 |
|
1079 |
if ( $days == true ) {
|
@@ -1081,13 +1081,13 @@ function wp_statistics_average_comment( $days = false ) {
|
|
1081 |
$get_total_comment = 1;
|
1082 |
} // Avoid divide by zero errors.
|
1083 |
|
1084 |
-
return round($days_spend / $get_total_comment, 0);
|
1085 |
} else {
|
1086 |
if ( $days_spend == 0 ) {
|
1087 |
$days_spend = 1;
|
1088 |
} // Avoid divide by zero errors.
|
1089 |
|
1090 |
-
return round($get_total_comment / $days_spend, 2);
|
1091 |
}
|
1092 |
}
|
1093 |
|
@@ -1097,11 +1097,11 @@ function wp_statistics_average_registeruser( $days = false ) {
|
|
1097 |
|
1098 |
global $wpdb;
|
1099 |
|
1100 |
-
$get_first_user = $wpdb->get_var("SELECT user_registered FROM {$wpdb->users} ORDER BY user_registered LIMIT 1");
|
1101 |
-
$get_total_user = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->users}");
|
1102 |
|
1103 |
$days_spend = intval(
|
1104 |
-
( time() - strtotime($get_first_user) ) / 86400
|
1105 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1106 |
|
1107 |
if ( $days == true ) {
|
@@ -1109,13 +1109,13 @@ function wp_statistics_average_registeruser( $days = false ) {
|
|
1109 |
$get_total_user = 1;
|
1110 |
} // Avoid divide by zero errors.
|
1111 |
|
1112 |
-
return round($days_spend / $get_total_user, 0);
|
1113 |
} else {
|
1114 |
if ( $days_spend == 0 ) {
|
1115 |
$days_spend = 1;
|
1116 |
} // Avoid divide by zero errors.
|
1117 |
|
1118 |
-
return round($get_total_user / $days_spend, 2);
|
1119 |
}
|
1120 |
}
|
1121 |
|
@@ -1129,10 +1129,10 @@ function wp_statistics_icons( $dashicons, $icon_name = null ) {
|
|
1129 |
}
|
1130 |
|
1131 |
// Since versions of WordPress before 3.8 didn't have dashicons, don't use them in those versions.
|
1132 |
-
if ( version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=') ) {
|
1133 |
return '<span class="dashicons ' . $dashicons . '"></span>';
|
1134 |
} else {
|
1135 |
-
return '<img src="' . plugins_url('wp-statistics/assets/images/') . $icon_name . '.png"/>';
|
1136 |
}
|
1137 |
}
|
1138 |
|
@@ -1142,14 +1142,14 @@ function wp_statistics_geoip_supported() {
|
|
1142 |
$enabled = true;
|
1143 |
|
1144 |
// PHP's cURL extension installed
|
1145 |
-
if ( ! function_exists('curl_init') ) {
|
1146 |
$enabled = false;
|
1147 |
}
|
1148 |
|
1149 |
// PHP NOT running in safe mode
|
1150 |
-
if ( ini_get('safe_mode') ) {
|
1151 |
// Double check php version, 5.4 and above don't support safe mode but the ini value may still be set after an upgrade.
|
1152 |
-
if ( ! version_compare(phpversion(), '5.4', '<') ) {
|
1153 |
$enabled = false;
|
1154 |
}
|
1155 |
}
|
@@ -1169,72 +1169,72 @@ function wp_statistics_date_range_selector(
|
|
1169 |
) {
|
1170 |
GLOBAL $WP_Statistics;
|
1171 |
|
1172 |
-
wp_enqueue_script('jquery-ui-datepicker');
|
1173 |
wp_register_style(
|
1174 |
'jquery-ui-smoothness-css',
|
1175 |
WP_Statistics::$reg['plugin-url'] . 'assets/css/jquery-ui-smoothness.min.css'
|
1176 |
);
|
1177 |
-
wp_enqueue_style('jquery-ui-smoothness-css');
|
1178 |
|
1179 |
-
if ( count($range) == 0 ) {
|
1180 |
$range = array( 10, 20, 30, 60, 90, 180, 270, 365 );
|
1181 |
$desc = array(
|
1182 |
-
__('10 Days', 'wp-statistics'),
|
1183 |
-
__('20 Days', 'wp-statistics'),
|
1184 |
-
__('30 Days', 'wp-statistics'),
|
1185 |
-
__('2 Months', 'wp-statistics'),
|
1186 |
-
__('3 Months', 'wp-statistics'),
|
1187 |
-
__('6 Months', 'wp-statistics'),
|
1188 |
-
__('9 Months', 'wp-statistics'),
|
1189 |
-
__('1 Year', 'wp-statistics'),
|
1190 |
);
|
1191 |
}
|
1192 |
|
1193 |
-
if ( count($desc) == 0 ) {
|
1194 |
$desc = $range;
|
1195 |
}
|
1196 |
|
1197 |
-
$rcount = count($range);
|
1198 |
|
1199 |
$bold = true;
|
1200 |
|
1201 |
// Check to see if there's a range in the URL, if so set it, otherwise use the default.
|
1202 |
-
if ( array_key_exists('rangestart', $_GET) ) {
|
1203 |
$rangestart = $_GET['rangestart'];
|
1204 |
} else {
|
1205 |
-
$rangestart = $WP_Statistics->Current_Date('m/d/Y', '-' . $current);
|
1206 |
}
|
1207 |
-
if ( array_key_exists('rangeend', $_GET) ) {
|
1208 |
$rangeend = $_GET['rangeend'];
|
1209 |
} else {
|
1210 |
-
$rangeend = $WP_Statistics->Current_Date('m/d/Y');
|
1211 |
}
|
1212 |
|
1213 |
// Convert the text dates to unix timestamps and do some basic sanity checking.
|
1214 |
-
$rangestart_utime = $WP_Statistics->strtotimetz($rangestart);
|
1215 |
if ( false === $rangestart_utime ) {
|
1216 |
$rangestart_utime = time();
|
1217 |
}
|
1218 |
-
$rangeend_utime = $WP_Statistics->strtotimetz($rangeend);
|
1219 |
if ( false === $rangeend_utime || $rangeend_utime < $rangestart_utime ) {
|
1220 |
$rangeend_utime = time();
|
1221 |
}
|
1222 |
|
1223 |
// Now get the number of days in the range.
|
1224 |
$daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
|
1225 |
-
$today = $WP_Statistics->Current_Date('m/d/Y');
|
1226 |
|
1227 |
// 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.
|
1228 |
-
$rangestart = $WP_Statistics->Local_Date('m/d/Y', $rangestart_utime);
|
1229 |
-
$rangeend = $WP_Statistics->Local_Date('m/d/Y', $rangeend_utime);
|
1230 |
|
1231 |
// 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.
|
1232 |
-
if ( $rangeend != $today || ( $rangeend == $today && ! in_array($current, $range) ) ) {
|
1233 |
-
$current = -1;
|
1234 |
} else {
|
1235 |
// If on the other hand we are a standard range, let's reset the custom range selector to match it.
|
1236 |
-
$rangestart = $WP_Statistics->Current_Date('m/d/Y', '-' . $current);
|
1237 |
-
$rangeend = $WP_Statistics->Current_Date('m/d/Y');
|
1238 |
}
|
1239 |
|
1240 |
echo '<form method="get"><ul class="subsubsub wp-statistics-sub-fullwidth">' . "\r\n";
|
@@ -1242,7 +1242,7 @@ function wp_statistics_date_range_selector(
|
|
1242 |
// Output any extra HTML we've been passed after the form element but before the date selector.
|
1243 |
echo $pre_extra;
|
1244 |
|
1245 |
-
for ( $i = 0; $i < $rcount; $i++ ) {
|
1246 |
echo ' <li class="all"><a ';
|
1247 |
|
1248 |
if ( $current == $range[ $i ] ) {
|
@@ -1255,7 +1255,7 @@ function wp_statistics_date_range_selector(
|
|
1255 |
$page .
|
1256 |
'&hitdays=' .
|
1257 |
$range[ $i ] .
|
1258 |
-
esc_html($extrafields) .
|
1259 |
'">' .
|
1260 |
$desc[ $i ] .
|
1261 |
'</a></li>';
|
@@ -1271,30 +1271,30 @@ function wp_statistics_date_range_selector(
|
|
1271 |
|
1272 |
echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $page . '">';
|
1273 |
|
1274 |
-
parse_str($extrafields, $parse);
|
1275 |
|
1276 |
foreach ( $parse as $key => $value ) {
|
1277 |
-
echo '<input type="hidden" name="' . $key . '" value="' . esc_sql($value) . '">';
|
1278 |
}
|
1279 |
|
1280 |
if ( $bold ) {
|
1281 |
-
echo ' <b>' . __('Time Frame', 'wp-statistics') . ':</b> ';
|
1282 |
} else {
|
1283 |
-
echo ' ' . __('Time Frame', 'wp-statistics') . ': ';
|
1284 |
}
|
1285 |
|
1286 |
echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' .
|
1287 |
$rangestart .
|
1288 |
'" placeholder="' .
|
1289 |
-
__('MM/DD/YYYY', 'wp-statistics') .
|
1290 |
'"> ' .
|
1291 |
-
__('to', 'wp-statistics') .
|
1292 |
' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' .
|
1293 |
$rangeend .
|
1294 |
'" placeholder="' .
|
1295 |
-
__('MM/DD/YYYY', 'wp-statistics') .
|
1296 |
'"> <input type="submit" value="' .
|
1297 |
-
__('Go', 'wp-statistics') .
|
1298 |
'" class="button-primary">' .
|
1299 |
"\r\n";
|
1300 |
|
@@ -1315,9 +1315,9 @@ function wp_statistics_date_range_calculator( $days, $start, $end ) {
|
|
1315 |
$rangestart = $start;
|
1316 |
$rangeend = $end;
|
1317 |
|
1318 |
-
if ( $daysToDisplay == -1 ) {
|
1319 |
-
$rangestart_utime = $WP_Statistics->strtotimetz($rangestart);
|
1320 |
-
$rangeend_utime = $WP_Statistics->strtotimetz($rangeend);
|
1321 |
$daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
|
1322 |
|
1323 |
if ( $rangestart_utime == false || $rangeend_utime == false ) {
|
@@ -1338,30 +1338,30 @@ function wp_statitiscs_empty_table( $table_name = false ) {
|
|
1338 |
global $wpdb;
|
1339 |
|
1340 |
if ( $table_name ) {
|
1341 |
-
$result = $wpdb->query('DELETE FROM ' . $table_name);
|
1342 |
|
1343 |
if ( $result ) {
|
1344 |
return sprintf(
|
1345 |
-
__('%s table data deleted successfully.', 'wp-statistics'),
|
1346 |
'<code>' . $table_name . '</code>'
|
1347 |
);
|
1348 |
}
|
1349 |
}
|
1350 |
|
1351 |
-
return sprintf(__('Error, %s not emptied!', 'wp-statistics'), $table_name);
|
1352 |
}
|
1353 |
|
1354 |
// This function creates a small JavaScript snipit that will load the contents of a overview or dashboard widget.
|
1355 |
function wp_statistics_generate_widget_load_javascript( $widget, $container_id = null ) {
|
1356 |
if ( null == $container_id ) {
|
1357 |
-
$container_id = str_replace('.', '_', $widget . '_postbox');
|
1358 |
}
|
1359 |
?>
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
<?php
|
1366 |
}
|
1367 |
|
@@ -1374,13 +1374,13 @@ function wp_statistics_generate_widget_load_javascript( $widget, $container_id =
|
|
1374 |
* @return string
|
1375 |
*/
|
1376 |
function wp_statistics_generate_rgba_color( $num, $opacity = '1' ) {
|
1377 |
-
$hash = md5('color' . $num);
|
1378 |
|
1379 |
return sprintf(
|
1380 |
"'rgba(%s, %s, %s, %s)'",
|
1381 |
-
hexdec(substr($hash, 0, 2)),
|
1382 |
-
hexdec(substr($hash, 2, 2)),
|
1383 |
-
hexdec(substr($hash, 4, 2)),
|
1384 |
$opacity
|
1385 |
);
|
1386 |
}
|
@@ -1399,7 +1399,7 @@ function wp_statistics_validate_capability( $capability ) {
|
|
1399 |
|
1400 |
$role_list = $wp_roles->get_names();
|
1401 |
|
1402 |
-
if ( ! is_object($wp_roles) || ! is_array($wp_roles->roles) ) {
|
1403 |
return 'manage_options';
|
1404 |
}
|
1405 |
|
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.
|
45 |
$result = $wpdb->get_var(
|
46 |
"SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'"
|
47 |
);
|
48 |
+
break;
|
49 |
|
50 |
case 'yesterday':
|
51 |
$result = $wpdb->get_var(
|
52 |
"SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'"
|
53 |
);
|
54 |
+
break;
|
55 |
|
56 |
case 'week':
|
57 |
$result = $wpdb->get_var(
|
58 |
"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' )}'"
|
59 |
);
|
60 |
+
break;
|
61 |
|
62 |
case 'month':
|
63 |
$result = $wpdb->get_var(
|
64 |
"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' )}'"
|
65 |
);
|
66 |
+
break;
|
67 |
|
68 |
case 'year':
|
69 |
$result = $wpdb->get_var(
|
70 |
"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' )}'"
|
71 |
);
|
72 |
+
break;
|
73 |
|
74 |
case 'total':
|
75 |
+
$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit" );
|
76 |
+
$result += $WP_Statistics->Get_Historical_Data( 'visits' );
|
77 |
+
break;
|
78 |
|
79 |
default:
|
80 |
$result = $wpdb->get_var(
|
81 |
"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' )}'"
|
82 |
);
|
83 |
+
break;
|
84 |
}
|
85 |
}
|
86 |
|
125 |
case 'today':
|
126 |
$sqlstatement
|
127 |
= "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'";
|
128 |
+
break;
|
129 |
|
130 |
case 'yesterday':
|
131 |
$sqlstatement
|
132 |
= "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'";
|
133 |
+
break;
|
134 |
|
135 |
case 'week':
|
136 |
$sqlstatement
|
137 |
= "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' )}'";
|
138 |
+
break;
|
139 |
|
140 |
case 'month':
|
141 |
$sqlstatement
|
142 |
= "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' )}'";
|
143 |
+
break;
|
144 |
|
145 |
case 'year':
|
146 |
$sqlstatement
|
147 |
= "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' )}'";
|
148 |
+
break;
|
149 |
|
150 |
case 'total':
|
151 |
$sqlstatement = "SELECT {$select} FROM {$wpdb->prefix}statistics_visitor";
|
152 |
+
$history = $WP_Statistics->Get_Historical_Data( 'visitors' );
|
153 |
+
break;
|
154 |
|
155 |
default:
|
156 |
$sqlstatement
|
157 |
= "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' )}'";
|
158 |
+
break;
|
159 |
}
|
160 |
}
|
161 |
|
162 |
// Execute the SQL call, if we're only counting we can use get_var(), otherwise we use query().
|
163 |
if ( $countonly == true ) {
|
164 |
+
$result = $wpdb->get_var( $sqlstatement );
|
165 |
$result += $history;
|
166 |
} else {
|
167 |
+
$result = $wpdb->query( $sqlstatement );
|
168 |
}
|
169 |
|
170 |
return $result;
|
171 |
}
|
172 |
|
173 |
// This function returns the statistics for a given page.
|
174 |
+
function wp_statistics_pages( $time, $page_uri = '', $id = - 1, $rangestartdate = null, $rangeenddate = null ) {
|
175 |
|
176 |
// We need database and the global $WP_Statistics object access.
|
177 |
global $wpdb, $WP_Statistics;
|
184 |
$page_uri = wp_statistics_get_uri();
|
185 |
}
|
186 |
|
187 |
+
$page_uri_sql = esc_sql( $page_uri );
|
188 |
|
189 |
// If a page/post ID has been passed, use it to select the rows, otherwise use the URI.
|
190 |
// Note that a single page/post ID can have multiple URI's associated with it.
|
191 |
+
if ( $id != - 1 ) {
|
192 |
+
$page_sql = '`id` = ' . absint( $id );
|
193 |
$history_key = 'page';
|
194 |
+
$history_id = absint( $id );
|
195 |
} else {
|
196 |
$page_sql = "`URI` = '{$page_uri_sql}'";
|
197 |
$history_key = 'uri';
|
204 |
case 'today':
|
205 |
$sqlstatement
|
206 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$page_sql}";
|
207 |
+
break;
|
208 |
|
209 |
case 'yesterday':
|
210 |
$sqlstatement
|
211 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$page_sql}";
|
212 |
+
break;
|
213 |
|
214 |
case 'week':
|
215 |
$sqlstatement
|
216 |
= "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}";
|
217 |
+
break;
|
218 |
|
219 |
case 'month':
|
220 |
$sqlstatement
|
221 |
= "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}";
|
222 |
+
break;
|
223 |
|
224 |
case 'year':
|
225 |
$sqlstatement
|
226 |
= "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}";
|
227 |
+
break;
|
228 |
|
229 |
case 'total':
|
230 |
$sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE {$page_sql}";
|
231 |
+
$history = $WP_Statistics->Get_Historical_Data( $history_key, $history_id );
|
232 |
+
break;
|
233 |
case 'range':
|
234 |
$sqlstatement = "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` BETWEEN '" .
|
235 |
+
$WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangestartdate ) ) .
|
236 |
"' AND '" .
|
237 |
+
$WP_Statistics->Current_Date( 'Y-m-d', '-0', strtotime( $rangeenddate ) ) .
|
238 |
"' AND {$page_sql}";
|
239 |
|
240 |
+
break;
|
241 |
default:
|
242 |
$sqlstatement
|
243 |
= "SELECT SUM(count) FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$page_sql}";
|
244 |
+
break;
|
245 |
}
|
246 |
|
247 |
// Since this function only every returns a count, just use get_var().
|
248 |
+
$result = $wpdb->get_var( $sqlstatement );
|
249 |
$result += $history;
|
250 |
|
251 |
// If we have an empty result, return 0 instead of a blank.
|
268 |
);
|
269 |
|
270 |
// Execute the query.
|
271 |
+
$result = $wpdb->get_var( $sqlstatement );
|
272 |
|
273 |
// If we returned a false or some other 0 equivalent value, make sure $result is set to an integer 0.
|
274 |
if ( $result == 0 ) {
|
298 |
ARRAY_N
|
299 |
);
|
300 |
} else {
|
301 |
+
$result = $wpdb->get_results( "SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N );
|
302 |
}
|
303 |
|
304 |
$total = 0;
|
307 |
// Now get the total page visit count for each unique URI.
|
308 |
foreach ( $result as $out ) {
|
309 |
// Increment the total number of results.
|
310 |
+
$total ++;
|
311 |
|
312 |
// Retreive the post ID for the URI.
|
313 |
+
$id = wp_statistics_uri_to_id( $out[0] );
|
314 |
|
315 |
// Lookup the post title.
|
316 |
+
$post = get_post( $id );
|
317 |
|
318 |
+
if ( is_object( $post ) ) {
|
319 |
$title = $post->post_title;
|
320 |
} else {
|
321 |
if ( $out[0] == '/' ) {
|
329 |
if ( $rangestartdate != null && $rangeenddate != null ) {
|
330 |
$uris[] = array(
|
331 |
$out[0],
|
332 |
+
wp_statistics_pages( 'range', $out[0], - 1, $rangestartdate, $rangeenddate ),
|
333 |
$id,
|
334 |
$title,
|
335 |
);
|
336 |
} else {
|
337 |
+
$uris[] = array( $out[0], wp_statistics_pages( 'total', $out[0] ), $id, $title );
|
338 |
}
|
339 |
}
|
340 |
|
341 |
// If we have more than one result, let's sort them using usort.
|
342 |
+
if ( count( $uris ) > 1 ) {
|
343 |
// Sort the URI's based on their hit count.
|
344 |
+
usort( $uris, 'wp_stats_compare_uri_hits' );
|
345 |
}
|
346 |
|
347 |
return array( $total, $uris );
|
350 |
// This function gets the current page URI.
|
351 |
function wp_statistics_get_uri() {
|
352 |
// Get the site's path from the URL.
|
353 |
+
$site_uri = parse_url( site_url(), PHP_URL_PATH );
|
354 |
+
$site_uri_len = strlen( $site_uri );
|
355 |
|
356 |
// Get the site's path from the URL.
|
357 |
+
$home_uri = parse_url( home_url(), PHP_URL_PATH );
|
358 |
+
$home_uri_len = strlen( $home_uri );
|
359 |
|
360 |
// Get the current page URI.
|
361 |
$page_uri = $_SERVER["REQUEST_URI"];
|
369 |
* we check for "/site", but in the reverse case, we need to swap the order of the check.
|
370 |
*/
|
371 |
if ( $site_uri_len > $home_uri_len ) {
|
372 |
+
if ( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
|
373 |
+
$page_uri = substr( $page_uri, $site_uri_len );
|
374 |
}
|
375 |
|
376 |
+
if ( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
|
377 |
+
$page_uri = substr( $page_uri, $home_uri_len );
|
378 |
}
|
379 |
} else {
|
380 |
+
if ( substr( $page_uri, 0, $home_uri_len ) == $home_uri ) {
|
381 |
+
$page_uri = substr( $page_uri, $home_uri_len );
|
382 |
}
|
383 |
|
384 |
+
if ( substr( $page_uri, 0, $site_uri_len ) == $site_uri ) {
|
385 |
+
$page_uri = substr( $page_uri, $site_uri_len );
|
386 |
}
|
387 |
}
|
388 |
|
409 |
ARRAY_N
|
410 |
);
|
411 |
} else {
|
412 |
+
$result = $wpdb->get_results( "SELECT DISTINCT agent FROM {$wpdb->prefix}statistics_visitor", ARRAY_N );
|
413 |
}
|
414 |
|
415 |
$Browers = array();
|
437 |
);
|
438 |
} else {
|
439 |
$result = $wpdb->get_var(
|
440 |
+
$wpdb->prepare( "SELECT COUNT(agent) FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent )
|
441 |
);
|
442 |
}
|
443 |
|
459 |
ARRAY_N
|
460 |
);
|
461 |
} else {
|
462 |
+
$result = $wpdb->get_results( "SELECT DISTINCT platform FROM {$wpdb->prefix}statistics_visitor", ARRAY_N );
|
463 |
}
|
464 |
|
465 |
$Platforms = array();
|
514 |
);
|
515 |
} else {
|
516 |
$result = $wpdb->get_results(
|
517 |
+
$wpdb->prepare( "SELECT DISTINCT version FROM {$wpdb->prefix}statistics_visitor WHERE agent = %s", $agent ),
|
518 |
ARRAY_N
|
519 |
);
|
520 |
}
|
575 |
$default = $engines = array(
|
576 |
'ask' => array(
|
577 |
'name' => 'Ask.com',
|
578 |
+
'translated' => __( 'Ask.com', 'wp-statistics' ),
|
579 |
'tag' => 'ask',
|
580 |
'sqlpattern' => '%ask.com%',
|
581 |
'regexpattern' => 'ask\.com',
|
584 |
),
|
585 |
'baidu' => array(
|
586 |
'name' => 'Baidu',
|
587 |
+
'translated' => __( 'Baidu', 'wp-statistics' ),
|
588 |
'tag' => 'baidu',
|
589 |
'sqlpattern' => '%baidu.com%',
|
590 |
'regexpattern' => 'baidu\.com',
|
593 |
),
|
594 |
'bing' => array(
|
595 |
'name' => 'Bing',
|
596 |
+
'translated' => __( 'Bing', 'wp-statistics' ),
|
597 |
'tag' => 'bing',
|
598 |
'sqlpattern' => '%bing.com%',
|
599 |
'regexpattern' => 'bing\.com',
|
602 |
),
|
603 |
'clearch' => array(
|
604 |
'name' => 'clearch.org',
|
605 |
+
'translated' => __( 'clearch.org', 'wp-statistics' ),
|
606 |
'tag' => 'clearch',
|
607 |
'sqlpattern' => '%clearch.org%',
|
608 |
'regexpattern' => 'clearch\.org',
|
611 |
),
|
612 |
'duckduckgo' => array(
|
613 |
'name' => 'DuckDuckGo',
|
614 |
+
'translated' => __( 'DuckDuckGo', 'wp-statistics' ),
|
615 |
'tag' => 'duckduckgo',
|
616 |
'sqlpattern' => array( '%duckduckgo.com%', '%ddg.gg%' ),
|
617 |
'regexpattern' => array( 'duckduckgo\.com', 'ddg\.gg' ),
|
620 |
),
|
621 |
'google' => array(
|
622 |
'name' => 'Google',
|
623 |
+
'translated' => __( 'Google', 'wp-statistics' ),
|
624 |
'tag' => 'google',
|
625 |
'sqlpattern' => '%google.%',
|
626 |
'regexpattern' => 'google\.',
|
629 |
),
|
630 |
'yahoo' => array(
|
631 |
'name' => 'Yahoo!',
|
632 |
+
'translated' => __( 'Yahoo!', 'wp-statistics' ),
|
633 |
'tag' => 'yahoo',
|
634 |
'sqlpattern' => '%yahoo.com%',
|
635 |
'regexpattern' => 'yahoo\.com',
|
638 |
),
|
639 |
'yandex' => array(
|
640 |
'name' => 'Yandex',
|
641 |
+
'translated' => __( 'Yandex', 'wp-statistics' ),
|
642 |
'tag' => 'yandex',
|
643 |
'sqlpattern' => '%yandex.ru%',
|
644 |
'regexpattern' => 'yandex\.ru',
|
649 |
|
650 |
if ( $all == false ) {
|
651 |
foreach ( $engines as $key => $engine ) {
|
652 |
+
if ( $WP_Statistics->get_option( 'disable_se_' . $engine['tag'] ) ) {
|
653 |
unset( $engines[ $key ] );
|
654 |
}
|
655 |
}
|
656 |
|
657 |
// If we've disabled all the search engines, reset the list back to default.
|
658 |
+
if ( count( $engines ) == 0 ) {
|
659 |
$engines = $default;
|
660 |
}
|
661 |
}
|
671 |
$searchengine_list = wp_statistics_searchengine_list();
|
672 |
$search_query = '';
|
673 |
|
674 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
675 |
// Are we getting results for all search engines or a specific one?
|
676 |
+
if ( strtolower( $search_engine ) == 'all' ) {
|
677 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
678 |
foreach ( $searchengine_list as $key => $se ) {
|
679 |
$search_query .= "( `engine` = '{$key}' AND `words` <> '' ) OR ";
|
680 |
}
|
681 |
|
682 |
// Trim off the last ' OR ' for the loop above.
|
683 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
684 |
} else {
|
685 |
$search_query .= "`engine` = '{$search_engine}' AND `words` <> ''";
|
686 |
}
|
687 |
} else {
|
688 |
// Are we getting results for all search engines or a specific one?
|
689 |
+
if ( strtolower( $search_engine ) == 'all' ) {
|
690 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
691 |
// NOTE: This SQL query can be *VERY* long.
|
692 |
foreach ( $searchengine_list as $se ) {
|
693 |
// 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.
|
694 |
+
if ( is_array( $se['sqlpattern'] ) ) {
|
695 |
foreach ( $se['sqlpattern'] as $subse ) {
|
696 |
$search_query .= "(`referred` LIKE '{$subse}{$se['querykey']}=%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=&%' AND `referred` NOT LIKE '{$subse}{$se['querykey']}=') OR ";
|
697 |
}
|
701 |
}
|
702 |
|
703 |
// Trim off the last ' OR ' for the loop above.
|
704 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
705 |
} else {
|
706 |
// 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.
|
707 |
+
if ( is_array( $searchengine_list[ $search_engine ]['sqlpattern'] ) ) {
|
708 |
foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
|
709 |
$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 ";
|
710 |
}
|
711 |
|
712 |
// Trim off the last ' OR ' for the loop above.
|
713 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
714 |
} else {
|
715 |
$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']}=')";
|
716 |
}
|
728 |
$searchengine_list = wp_statistics_searchengine_list();
|
729 |
$search_query = '';
|
730 |
|
731 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
732 |
// Are we getting results for all search engines or a specific one?
|
733 |
+
if ( strtolower( $search_engine ) == 'all' ) {
|
734 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
735 |
foreach ( $searchengine_list as $key => $se ) {
|
736 |
+
$key = esc_sql( $key );
|
737 |
$search_query .= "`engine` = '{$key}' OR ";
|
738 |
}
|
739 |
|
740 |
// Trim off the last ' OR ' for the loop above.
|
741 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
742 |
} else {
|
743 |
+
$search_engine = esc_sql( $search_engine );
|
744 |
+
$search_query .= "`engine` = '{$search_engine}'";
|
745 |
}
|
746 |
} else {
|
747 |
// Are we getting results for all search engines or a specific one?
|
748 |
+
if ( strtolower( $search_engine ) == 'all' ) {
|
749 |
// For all of them? Ok, look through the search engine list and create a SQL query string to get them all from the database.
|
750 |
// NOTE: This SQL query can be long.
|
751 |
foreach ( $searchengine_list as $se ) {
|
752 |
// 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.
|
753 |
+
if ( is_array( $se['sqlpattern'] ) ) {
|
754 |
foreach ( $se['sqlpattern'] as $subse ) {
|
755 |
+
$subse = esc_sql( $subse );
|
756 |
$search_query .= "`referred` LIKE '{$subse}' OR ";
|
757 |
}
|
758 |
} else {
|
759 |
+
$se['sqlpattern'] = esc_sql( $se['sqlpattern'] );
|
760 |
+
$search_query .= "`referred` LIKE '{$se['sqlpattern']}' OR ";
|
761 |
}
|
762 |
}
|
763 |
|
764 |
// Trim off the last ' OR ' for the loop above.
|
765 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
766 |
} else {
|
767 |
// 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.
|
768 |
+
if ( is_array( $searchengine_list[ $search_engine ]['sqlpattern'] ) ) {
|
769 |
foreach ( $searchengine_list[ $search_engine ]['sqlpattern'] as $se ) {
|
770 |
+
$se = esc_sql( $se );
|
771 |
$search_query .= "`referred` LIKE '{$se}' OR ";
|
772 |
}
|
773 |
|
774 |
// Trim off the last ' OR ' for the loop above.
|
775 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 4 );
|
776 |
} else {
|
777 |
$searchengine_list[ $search_engine ]['sqlpattern'] = esc_sql(
|
778 |
$searchengine_list[ $search_engine ]['sqlpattern']
|
779 |
);
|
780 |
+
$search_query .= "`referred` LIKE '{$searchengine_list[$search_engine]['sqlpattern']}'";
|
781 |
}
|
782 |
}
|
783 |
}
|
793 |
$search_query = '';
|
794 |
|
795 |
// Are we getting results for all search engines or a specific one?
|
796 |
+
if ( strtolower( $search_engine ) == 'all' ) {
|
797 |
foreach ( $searchengine_list as $se ) {
|
798 |
// 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.
|
799 |
+
if ( is_array( $se['regexpattern'] ) ) {
|
800 |
foreach ( $se['regexpattern'] as $subse ) {
|
801 |
$search_query .= "{$subse}|";
|
802 |
}
|
806 |
}
|
807 |
|
808 |
// Trim off the last '|' for the loop above.
|
809 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
|
810 |
} else {
|
811 |
// 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.
|
812 |
+
if ( is_array( $searchengine_list[ $search_engine ]['regexpattern'] ) ) {
|
813 |
foreach ( $searchengine_list[ $search_engine ]['regexpattern'] as $se ) {
|
814 |
$search_query .= "{$se}|";
|
815 |
}
|
816 |
|
817 |
// Trim off the last '|' for the loop above.
|
818 |
+
$search_query = substr( $search_query, 0, strlen( $search_query ) - 1 );
|
819 |
} else {
|
820 |
$search_query .= $searchengine_list[ $search_engine ]['regexpattern'];
|
821 |
}
|
833 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
834 |
$tablename = $wpdb->prefix . 'statistics_';
|
835 |
|
836 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
837 |
$tablename .= 'search';
|
838 |
} else {
|
839 |
$tablename .= 'visitor';
|
840 |
}
|
841 |
|
842 |
// Get a complete list of search engines
|
843 |
+
$search_query = wp_statistics_searchengine_query( $search_engine );
|
844 |
|
845 |
// This function accepts several options for time parameter, each one has a unique SQL query string.
|
846 |
// They're pretty self explanatory.
|
849 |
$result = $wpdb->query(
|
850 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}"
|
851 |
);
|
852 |
+
break;
|
853 |
|
854 |
case 'yesterday':
|
855 |
$result = $wpdb->query(
|
856 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}"
|
857 |
);
|
858 |
|
859 |
+
break;
|
860 |
|
861 |
case 'week':
|
862 |
$result = $wpdb->query(
|
863 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}"
|
864 |
);
|
865 |
|
866 |
+
break;
|
867 |
|
868 |
case 'month':
|
869 |
$result = $wpdb->query(
|
870 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}"
|
871 |
);
|
872 |
|
873 |
+
break;
|
874 |
|
875 |
case 'year':
|
876 |
$result = $wpdb->query(
|
877 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}"
|
878 |
);
|
879 |
|
880 |
+
break;
|
881 |
|
882 |
case 'total':
|
883 |
+
$result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}" );
|
884 |
|
885 |
+
break;
|
886 |
|
887 |
default:
|
888 |
$result = $wpdb->query(
|
889 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time)}' AND {$search_query}"
|
890 |
);
|
891 |
|
892 |
+
break;
|
893 |
}
|
894 |
|
895 |
return $result;
|
903 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
904 |
$tablename = $wpdb->prefix . 'statistics_';
|
905 |
|
906 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
907 |
$tablename .= 'search';
|
908 |
} else {
|
909 |
$tablename .= 'visitor';
|
910 |
}
|
911 |
|
912 |
// Get a complete list of search engines
|
913 |
+
$search_query = wp_statistics_searchword_query( $search_engine );
|
914 |
|
915 |
// This function accepts several options for time parameter, each one has a unique SQL query string.
|
916 |
// They're pretty self explanatory.
|
919 |
$result = $wpdb->query(
|
920 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND {$search_query}"
|
921 |
);
|
922 |
+
break;
|
923 |
|
924 |
case 'yesterday':
|
925 |
$result = $wpdb->query(
|
926 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}' AND {$search_query}"
|
927 |
);
|
928 |
|
929 |
+
break;
|
930 |
|
931 |
case 'week':
|
932 |
$result = $wpdb->query(
|
933 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND {$search_query}"
|
934 |
);
|
935 |
|
936 |
+
break;
|
937 |
|
938 |
case 'month':
|
939 |
$result = $wpdb->query(
|
940 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND {$search_query}"
|
941 |
);
|
942 |
|
943 |
+
break;
|
944 |
|
945 |
case 'year':
|
946 |
$result = $wpdb->query(
|
947 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND {$search_query}"
|
948 |
);
|
949 |
|
950 |
+
break;
|
951 |
|
952 |
case 'total':
|
953 |
+
$result = $wpdb->query( "SELECT * FROM `{$tablename}` WHERE {$search_query}" );
|
954 |
|
955 |
+
break;
|
956 |
|
957 |
default:
|
958 |
$result = $wpdb->query(
|
959 |
"SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND {$search_query}"
|
960 |
);
|
961 |
|
962 |
+
break;
|
963 |
}
|
964 |
|
965 |
return $result;
|
968 |
// This function will return the total number of posts in WordPress.
|
969 |
function wp_statistics_countposts() {
|
970 |
|
971 |
+
$count_posts = wp_count_posts( 'post' );
|
972 |
|
973 |
$ret = 0;
|
974 |
|
975 |
+
if ( is_object( $count_posts ) ) {
|
976 |
$ret = $count_posts->publish;
|
977 |
}
|
978 |
|
982 |
// This function will return the total number of pages in WordPress.
|
983 |
function wp_statistics_countpages() {
|
984 |
|
985 |
+
$count_pages = wp_count_posts( 'page' );
|
986 |
|
987 |
$ret = 0;
|
988 |
|
989 |
+
if ( is_object( $count_pages ) ) {
|
990 |
$ret = $count_pages->publish;
|
991 |
}
|
992 |
|
998 |
|
999 |
global $wpdb;
|
1000 |
|
1001 |
+
$countcomms = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
|
1002 |
|
1003 |
return $countcomms;
|
1004 |
}
|
1006 |
// This function will return the total number of spam comments *IF* akismet is installed.
|
1007 |
function wp_statistics_countspam() {
|
1008 |
|
1009 |
+
return number_format_i18n( get_option( 'akismet_spam_count' ) );
|
1010 |
}
|
1011 |
|
1012 |
// This function will return the total number of users in WordPress.
|
1026 |
"SELECT post_date FROM {$wpdb->posts} WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 1"
|
1027 |
);
|
1028 |
|
1029 |
+
$date_format = get_option( 'date_format' );
|
1030 |
|
1031 |
+
return $WP_Statistics->Current_Date_i18n( $date_format, $db_date, false );
|
1032 |
}
|
1033 |
|
1034 |
// This function will return the average number of posts per day that are published on your site.
|
1045 |
);
|
1046 |
|
1047 |
$days_spend = intval(
|
1048 |
+
( time() - strtotime( $get_first_post ) ) / 86400
|
1049 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1050 |
|
1051 |
if ( $days == true ) {
|
1053 |
$get_total_post = 1;
|
1054 |
} // Avoid divide by zero errors.
|
1055 |
|
1056 |
+
return round( $days_spend / $get_total_post, 0 );
|
1057 |
} else {
|
1058 |
if ( $days_spend == 0 ) {
|
1059 |
$days_spend = 1;
|
1060 |
} // Avoid divide by zero errors.
|
1061 |
|
1062 |
+
return round( $get_total_post / $days_spend, 2 );
|
1063 |
}
|
1064 |
}
|
1065 |
|
1069 |
|
1070 |
global $wpdb;
|
1071 |
|
1072 |
+
$get_first_comment = $wpdb->get_var( "SELECT comment_date FROM {$wpdb->comments} ORDER BY comment_date LIMIT 1" );
|
1073 |
+
$get_total_comment = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_approved = '1'" );
|
1074 |
|
1075 |
$days_spend = intval(
|
1076 |
+
( time() - strtotime( $get_first_comment ) ) / 86400
|
1077 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1078 |
|
1079 |
if ( $days == true ) {
|
1081 |
$get_total_comment = 1;
|
1082 |
} // Avoid divide by zero errors.
|
1083 |
|
1084 |
+
return round( $days_spend / $get_total_comment, 0 );
|
1085 |
} else {
|
1086 |
if ( $days_spend == 0 ) {
|
1087 |
$days_spend = 1;
|
1088 |
} // Avoid divide by zero errors.
|
1089 |
|
1090 |
+
return round( $get_total_comment / $days_spend, 2 );
|
1091 |
}
|
1092 |
}
|
1093 |
|
1097 |
|
1098 |
global $wpdb;
|
1099 |
|
1100 |
+
$get_first_user = $wpdb->get_var( "SELECT user_registered FROM {$wpdb->users} ORDER BY user_registered LIMIT 1" );
|
1101 |
+
$get_total_user = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}" );
|
1102 |
|
1103 |
$days_spend = intval(
|
1104 |
+
( time() - strtotime( $get_first_user ) ) / 86400
|
1105 |
); // 86400 = 60 * 60 * 24 = number of seconds in a day
|
1106 |
|
1107 |
if ( $days == true ) {
|
1109 |
$get_total_user = 1;
|
1110 |
} // Avoid divide by zero errors.
|
1111 |
|
1112 |
+
return round( $days_spend / $get_total_user, 0 );
|
1113 |
} else {
|
1114 |
if ( $days_spend == 0 ) {
|
1115 |
$days_spend = 1;
|
1116 |
} // Avoid divide by zero errors.
|
1117 |
|
1118 |
+
return round( $get_total_user / $days_spend, 2 );
|
1119 |
}
|
1120 |
}
|
1121 |
|
1129 |
}
|
1130 |
|
1131 |
// Since versions of WordPress before 3.8 didn't have dashicons, don't use them in those versions.
|
1132 |
+
if ( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) {
|
1133 |
return '<span class="dashicons ' . $dashicons . '"></span>';
|
1134 |
} else {
|
1135 |
+
return '<img src="' . plugins_url( 'wp-statistics/assets/images/' ) . $icon_name . '.png"/>';
|
1136 |
}
|
1137 |
}
|
1138 |
|
1142 |
$enabled = true;
|
1143 |
|
1144 |
// PHP's cURL extension installed
|
1145 |
+
if ( ! function_exists( 'curl_init' ) ) {
|
1146 |
$enabled = false;
|
1147 |
}
|
1148 |
|
1149 |
// PHP NOT running in safe mode
|
1150 |
+
if ( ini_get( 'safe_mode' ) ) {
|
1151 |
// Double check php version, 5.4 and above don't support safe mode but the ini value may still be set after an upgrade.
|
1152 |
+
if ( ! version_compare( phpversion(), '5.4', '<' ) ) {
|
1153 |
$enabled = false;
|
1154 |
}
|
1155 |
}
|
1169 |
) {
|
1170 |
GLOBAL $WP_Statistics;
|
1171 |
|
1172 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
1173 |
wp_register_style(
|
1174 |
'jquery-ui-smoothness-css',
|
1175 |
WP_Statistics::$reg['plugin-url'] . 'assets/css/jquery-ui-smoothness.min.css'
|
1176 |
);
|
1177 |
+
wp_enqueue_style( 'jquery-ui-smoothness-css' );
|
1178 |
|
1179 |
+
if ( count( $range ) == 0 ) {
|
1180 |
$range = array( 10, 20, 30, 60, 90, 180, 270, 365 );
|
1181 |
$desc = array(
|
1182 |
+
__( '10 Days', 'wp-statistics' ),
|
1183 |
+
__( '20 Days', 'wp-statistics' ),
|
1184 |
+
__( '30 Days', 'wp-statistics' ),
|
1185 |
+
__( '2 Months', 'wp-statistics' ),
|
1186 |
+
__( '3 Months', 'wp-statistics' ),
|
1187 |
+
__( '6 Months', 'wp-statistics' ),
|
1188 |
+
__( '9 Months', 'wp-statistics' ),
|
1189 |
+
__( '1 Year', 'wp-statistics' ),
|
1190 |
);
|
1191 |
}
|
1192 |
|
1193 |
+
if ( count( $desc ) == 0 ) {
|
1194 |
$desc = $range;
|
1195 |
}
|
1196 |
|
1197 |
+
$rcount = count( $range );
|
1198 |
|
1199 |
$bold = true;
|
1200 |
|
1201 |
// Check to see if there's a range in the URL, if so set it, otherwise use the default.
|
1202 |
+
if ( array_key_exists( 'rangestart', $_GET ) ) {
|
1203 |
$rangestart = $_GET['rangestart'];
|
1204 |
} else {
|
1205 |
+
$rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
|
1206 |
}
|
1207 |
+
if ( array_key_exists( 'rangeend', $_GET ) ) {
|
1208 |
$rangeend = $_GET['rangeend'];
|
1209 |
} else {
|
1210 |
+
$rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
|
1211 |
}
|
1212 |
|
1213 |
// Convert the text dates to unix timestamps and do some basic sanity checking.
|
1214 |
+
$rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
|
1215 |
if ( false === $rangestart_utime ) {
|
1216 |
$rangestart_utime = time();
|
1217 |
}
|
1218 |
+
$rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
|
1219 |
if ( false === $rangeend_utime || $rangeend_utime < $rangestart_utime ) {
|
1220 |
$rangeend_utime = time();
|
1221 |
}
|
1222 |
|
1223 |
// Now get the number of days in the range.
|
1224 |
$daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
|
1225 |
+
$today = $WP_Statistics->Current_Date( 'm/d/Y' );
|
1226 |
|
1227 |
// 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.
|
1228 |
+
$rangestart = $WP_Statistics->Local_Date( 'm/d/Y', $rangestart_utime );
|
1229 |
+
$rangeend = $WP_Statistics->Local_Date( 'm/d/Y', $rangeend_utime );
|
1230 |
|
1231 |
// 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.
|
1232 |
+
if ( $rangeend != $today || ( $rangeend == $today && ! in_array( $current, $range ) ) ) {
|
1233 |
+
$current = - 1;
|
1234 |
} else {
|
1235 |
// If on the other hand we are a standard range, let's reset the custom range selector to match it.
|
1236 |
+
$rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
|
1237 |
+
$rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
|
1238 |
}
|
1239 |
|
1240 |
echo '<form method="get"><ul class="subsubsub wp-statistics-sub-fullwidth">' . "\r\n";
|
1242 |
// Output any extra HTML we've been passed after the form element but before the date selector.
|
1243 |
echo $pre_extra;
|
1244 |
|
1245 |
+
for ( $i = 0; $i < $rcount; $i ++ ) {
|
1246 |
echo ' <li class="all"><a ';
|
1247 |
|
1248 |
if ( $current == $range[ $i ] ) {
|
1255 |
$page .
|
1256 |
'&hitdays=' .
|
1257 |
$range[ $i ] .
|
1258 |
+
esc_html( $extrafields ) .
|
1259 |
'">' .
|
1260 |
$desc[ $i ] .
|
1261 |
'</a></li>';
|
1271 |
|
1272 |
echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $page . '">';
|
1273 |
|
1274 |
+
parse_str( $extrafields, $parse );
|
1275 |
|
1276 |
foreach ( $parse as $key => $value ) {
|
1277 |
+
echo '<input type="hidden" name="' . $key . '" value="' . esc_sql( $value ) . '">';
|
1278 |
}
|
1279 |
|
1280 |
if ( $bold ) {
|
1281 |
+
echo ' <b>' . __( 'Time Frame', 'wp-statistics' ) . ':</b> ';
|
1282 |
} else {
|
1283 |
+
echo ' ' . __( 'Time Frame', 'wp-statistics' ) . ': ';
|
1284 |
}
|
1285 |
|
1286 |
echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' .
|
1287 |
$rangestart .
|
1288 |
'" placeholder="' .
|
1289 |
+
__( 'MM/DD/YYYY', 'wp-statistics' ) .
|
1290 |
'"> ' .
|
1291 |
+
__( 'to', 'wp-statistics' ) .
|
1292 |
' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' .
|
1293 |
$rangeend .
|
1294 |
'" placeholder="' .
|
1295 |
+
__( 'MM/DD/YYYY', 'wp-statistics' ) .
|
1296 |
'"> <input type="submit" value="' .
|
1297 |
+
__( 'Go', 'wp-statistics' ) .
|
1298 |
'" class="button-primary">' .
|
1299 |
"\r\n";
|
1300 |
|
1315 |
$rangestart = $start;
|
1316 |
$rangeend = $end;
|
1317 |
|
1318 |
+
if ( $daysToDisplay == - 1 ) {
|
1319 |
+
$rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
|
1320 |
+
$rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
|
1321 |
$daysToDisplay = (int) ( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
|
1322 |
|
1323 |
if ( $rangestart_utime == false || $rangeend_utime == false ) {
|
1338 |
global $wpdb;
|
1339 |
|
1340 |
if ( $table_name ) {
|
1341 |
+
$result = $wpdb->query( 'DELETE FROM ' . $table_name );
|
1342 |
|
1343 |
if ( $result ) {
|
1344 |
return sprintf(
|
1345 |
+
__( '%s table data deleted successfully.', 'wp-statistics' ),
|
1346 |
'<code>' . $table_name . '</code>'
|
1347 |
);
|
1348 |
}
|
1349 |
}
|
1350 |
|
1351 |
+
return sprintf( __( 'Error, %s not emptied!', 'wp-statistics' ), $table_name );
|
1352 |
}
|
1353 |
|
1354 |
// This function creates a small JavaScript snipit that will load the contents of a overview or dashboard widget.
|
1355 |
function wp_statistics_generate_widget_load_javascript( $widget, $container_id = null ) {
|
1356 |
if ( null == $container_id ) {
|
1357 |
+
$container_id = str_replace( '.', '_', $widget . '_postbox' );
|
1358 |
}
|
1359 |
?>
|
1360 |
+
<script type="text/javascript">
|
1361 |
+
jQuery(document).ready(function () {
|
1362 |
+
wp_statistics_get_widget_contents('<?php echo $widget; ?>', '<?php echo $container_id; ?>');
|
1363 |
+
});
|
1364 |
+
</script>
|
1365 |
<?php
|
1366 |
}
|
1367 |
|
1374 |
* @return string
|
1375 |
*/
|
1376 |
function wp_statistics_generate_rgba_color( $num, $opacity = '1' ) {
|
1377 |
+
$hash = md5( 'color' . $num );
|
1378 |
|
1379 |
return sprintf(
|
1380 |
"'rgba(%s, %s, %s, %s)'",
|
1381 |
+
hexdec( substr( $hash, 0, 2 ) ),
|
1382 |
+
hexdec( substr( $hash, 2, 2 ) ),
|
1383 |
+
hexdec( substr( $hash, 4, 2 ) ),
|
1384 |
$opacity
|
1385 |
);
|
1386 |
}
|
1399 |
|
1400 |
$role_list = $wp_roles->get_names();
|
1401 |
|
1402 |
+
if ( ! is_object( $wp_roles ) || ! is_array( $wp_roles->roles ) ) {
|
1403 |
return 'manage_options';
|
1404 |
}
|
1405 |
|
includes/functions/purge-hits.php
CHANGED
@@ -6,7 +6,7 @@ function wp_statistics_purge_visitor_hits( $purge_hits ) {
|
|
6 |
if ( $purge_hits > 9 ) {
|
7 |
// Purge the visitor's with more than the defined hits.
|
8 |
$result = $wpdb->get_results(
|
9 |
-
$wpdb->prepare("SELECT * FROM {$wpdb->prefix}statistics_visitor WHERE `hits` > %s", $purge_hits)
|
10 |
);
|
11 |
|
12 |
$to_delete = array();
|
@@ -16,7 +16,7 @@ function wp_statistics_purge_visitor_hits( $purge_hits ) {
|
|
16 |
foreach ( $result as $row ) {
|
17 |
$to_delete[] = array( $row->ID, $row->last_counter, $row->hits );
|
18 |
}
|
19 |
-
if ( count($to_delete) > 0 ) {
|
20 |
foreach ( $to_delete as $item ) {
|
21 |
// First update the daily hit count.
|
22 |
$wpdb->query(
|
@@ -28,36 +28,36 @@ function wp_statistics_purge_visitor_hits( $purge_hits ) {
|
|
28 |
);
|
29 |
// Next remove the visitor. Note we can't do both in a single query, looks like $wpdb doesn't like executing them together.
|
30 |
$wpdb->query(
|
31 |
-
$wpdb->prepare("DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `id` = %s;", $item[0])
|
32 |
);
|
33 |
}
|
34 |
|
35 |
$result_string = sprintf(
|
36 |
-
__('%s records purged successfully.', 'wp-statistics'),
|
37 |
-
'<code>' . count($to_delete) . '</code>'
|
38 |
);
|
39 |
} else {
|
40 |
-
$result_string = __('No visitors found to purge.', 'wp-statistics');
|
41 |
}
|
42 |
} else {
|
43 |
-
$result_string = __('Number of hits must be greater than or equal to 10!', 'wp-statistics');
|
44 |
}
|
45 |
|
46 |
-
if ( $WP_Statistics->get_option('prune_report') == true ) {
|
47 |
-
$blogname
|
48 |
-
$blogemail = get_bloginfo('admin_email');
|
49 |
|
50 |
$headers[] = "From: $blogname <$blogemail>";
|
51 |
$headers[] = "MIME-Version: 1.0";
|
52 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
53 |
|
54 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
55 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
56 |
}
|
57 |
|
58 |
wp_mail(
|
59 |
-
$WP_Statistics->get_option('email_list'),
|
60 |
-
__('Database pruned on', 'wp-statistics') . ' ' . $blogname,
|
61 |
$result_string,
|
62 |
$headers
|
63 |
);
|
6 |
if ( $purge_hits > 9 ) {
|
7 |
// Purge the visitor's with more than the defined hits.
|
8 |
$result = $wpdb->get_results(
|
9 |
+
$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}statistics_visitor WHERE `hits` > %s", $purge_hits )
|
10 |
);
|
11 |
|
12 |
$to_delete = array();
|
16 |
foreach ( $result as $row ) {
|
17 |
$to_delete[] = array( $row->ID, $row->last_counter, $row->hits );
|
18 |
}
|
19 |
+
if ( count( $to_delete ) > 0 ) {
|
20 |
foreach ( $to_delete as $item ) {
|
21 |
// First update the daily hit count.
|
22 |
$wpdb->query(
|
28 |
);
|
29 |
// Next remove the visitor. Note we can't do both in a single query, looks like $wpdb doesn't like executing them together.
|
30 |
$wpdb->query(
|
31 |
+
$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `id` = %s;", $item[0] )
|
32 |
);
|
33 |
}
|
34 |
|
35 |
$result_string = sprintf(
|
36 |
+
__( '%s records purged successfully.', 'wp-statistics' ),
|
37 |
+
'<code>' . count( $to_delete ) . '</code>'
|
38 |
);
|
39 |
} else {
|
40 |
+
$result_string = __( 'No visitors found to purge.', 'wp-statistics' );
|
41 |
}
|
42 |
} else {
|
43 |
+
$result_string = __( 'Number of hits must be greater than or equal to 10!', 'wp-statistics' );
|
44 |
}
|
45 |
|
46 |
+
if ( $WP_Statistics->get_option( 'prune_report' ) == true ) {
|
47 |
+
$blogname = get_bloginfo( 'name' );
|
48 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
49 |
|
50 |
$headers[] = "From: $blogname <$blogemail>";
|
51 |
$headers[] = "MIME-Version: 1.0";
|
52 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
53 |
|
54 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
55 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
56 |
}
|
57 |
|
58 |
wp_mail(
|
59 |
+
$WP_Statistics->get_option( 'email_list' ),
|
60 |
+
__( 'Database pruned on', 'wp-statistics' ) . ' ' . $blogname,
|
61 |
$result_string,
|
62 |
$headers
|
63 |
);
|
includes/functions/purge.php
CHANGED
@@ -6,9 +6,9 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
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.
|
@@ -25,20 +25,20 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
25 |
array(
|
26 |
'value' => $result,
|
27 |
'category' => 'visits',
|
28 |
-
'page_id' => -2,
|
29 |
'uri' => '-2',
|
30 |
)
|
31 |
);
|
32 |
}
|
33 |
|
34 |
$result_string = sprintf(
|
35 |
-
__('%s data older than %s days purged successfully.', 'wp-statistics'),
|
36 |
'<code>' . $table_name . '</code>',
|
37 |
'<code>' . $purge_days . '</code>'
|
38 |
);
|
39 |
} else {
|
40 |
$result_string = sprintf(
|
41 |
-
__('No records found to purge from %s!', 'wp-statistics'),
|
42 |
'<code>' . $table_name . '</code>'
|
43 |
);
|
44 |
}
|
@@ -46,7 +46,7 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
46 |
// Purge the visitors data.
|
47 |
$table_name = $wpdb->prefix . 'statistics_visitor';
|
48 |
|
49 |
-
$result = $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string));
|
50 |
|
51 |
if ( $result ) {
|
52 |
// Update the historical count with what we purged.
|
@@ -63,7 +63,7 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
63 |
array(
|
64 |
'value' => $result,
|
65 |
'category' => 'visitors',
|
66 |
-
'page_id' => -1,
|
67 |
'uri' => '-1',
|
68 |
)
|
69 |
);
|
@@ -71,14 +71,14 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
71 |
|
72 |
$result_string .= '<br>' .
|
73 |
sprintf(
|
74 |
-
__('%s data older than %s days purged successfully.', 'wp-statistics'),
|
75 |
'<code>' . $table_name . '</code>',
|
76 |
'<code>' . $purge_days . '</code>'
|
77 |
);
|
78 |
} else {
|
79 |
$result_string .= '<br>' .
|
80 |
sprintf(
|
81 |
-
__('No records found to purge from %s!', 'wp-statistics'),
|
82 |
'<code>' . $table_name . '</code>'
|
83 |
);
|
84 |
}
|
@@ -86,19 +86,19 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
86 |
// Purge the exclusions data.
|
87 |
$table_name = $wpdb->prefix . 'statistics_exclusions';
|
88 |
|
89 |
-
$result = $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE `date` < %s", $date_string));
|
90 |
|
91 |
if ( $result ) {
|
92 |
$result_string .= '<br>' .
|
93 |
sprintf(
|
94 |
-
__('%s data older than %s days purged successfully.', 'wp-statistics'),
|
95 |
'<code>' . $table_name . '</code>',
|
96 |
'<code>' . $purge_days . '</code>'
|
97 |
);
|
98 |
} else {
|
99 |
$result_string .= '<br>' .
|
100 |
sprintf(
|
101 |
-
__('No records found to purge from %s!', 'wp-statistics'),
|
102 |
'<code>' . $table_name . '</code>'
|
103 |
);
|
104 |
}
|
@@ -106,19 +106,19 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
106 |
// Purge the search data.
|
107 |
$table_name = $wpdb->prefix . 'statistics_search';
|
108 |
|
109 |
-
$result = $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string));
|
110 |
|
111 |
if ( $result ) {
|
112 |
$result_string .= '<br>' .
|
113 |
sprintf(
|
114 |
-
__('%s data older than %s days purged successfully.', 'wp-statistics'),
|
115 |
'<code>' . $table_name . '</code>',
|
116 |
'<code>' . $purge_days . '</code>'
|
117 |
);
|
118 |
} else {
|
119 |
$result_string .= '<br>' .
|
120 |
sprintf(
|
121 |
-
__('No records found to purge from %s!', 'wp-statistics'),
|
122 |
'<code>' . $table_name . '</code>'
|
123 |
);
|
124 |
}
|
@@ -129,7 +129,7 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
129 |
|
130 |
// The first thing we need to do is update the historical data by finding all the unique pages.
|
131 |
$result = $wpdb->get_results(
|
132 |
-
$wpdb->prepare("SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string)
|
133 |
);
|
134 |
|
135 |
// If we have a result, let's store the historical data.
|
@@ -163,7 +163,7 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
163 |
'value' => $historical,
|
164 |
'category' => 'uri',
|
165 |
'uri' => $row->uri,
|
166 |
-
'page_id' => wp_statistics_uri_to_id($row->uri),
|
167 |
)
|
168 |
);
|
169 |
}
|
@@ -171,38 +171,38 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
171 |
}
|
172 |
|
173 |
// Now that we've done all of the required historical data storage, we can actually delete the data from the database.
|
174 |
-
$result = $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE `date` < %s", $date_string));
|
175 |
|
176 |
if ( $result ) {
|
177 |
$result_string .= '<br>' .
|
178 |
sprintf(
|
179 |
-
__('%s data older than %s days purged successfully.', 'wp-statistics'),
|
180 |
'<code>' . $table_name . '</code>',
|
181 |
'<code>' . $purge_days . '</code>'
|
182 |
);
|
183 |
} else {
|
184 |
$result_string .= '<br>' .
|
185 |
sprintf(
|
186 |
-
__('No records found to purge from %s!', 'wp-statistics'),
|
187 |
'<code>' . $table_name . '</code>'
|
188 |
);
|
189 |
}
|
190 |
|
191 |
-
if ( $WP_Statistics->get_option('prune_report') == true ) {
|
192 |
-
$blogname = get_bloginfo('name');
|
193 |
-
$blogemail = get_bloginfo('admin_email');
|
194 |
|
195 |
$headers[] = "From: $blogname <$blogemail>";
|
196 |
$headers[] = "MIME-Version: 1.0";
|
197 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
198 |
|
199 |
-
if ( $WP_Statistics->get_option('email_list') == '' ) {
|
200 |
-
$WP_Statistics->update_option('email_list', $blogemail);
|
201 |
}
|
202 |
|
203 |
wp_mail(
|
204 |
-
$WP_Statistics->get_option('email_list'),
|
205 |
-
__('Database pruned on', 'wp-statistics') . ' ' . $blogname,
|
206 |
$result_string,
|
207 |
$headers
|
208 |
);
|
@@ -210,6 +210,6 @@ function wp_statistics_purge_data( $purge_days ) {
|
|
210 |
|
211 |
return $result_string;
|
212 |
} else {
|
213 |
-
return __('Please select a value over 30 days.', 'wp-statistics');
|
214 |
}
|
215 |
}
|
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.
|
25 |
array(
|
26 |
'value' => $result,
|
27 |
'category' => 'visits',
|
28 |
+
'page_id' => - 2,
|
29 |
'uri' => '-2',
|
30 |
)
|
31 |
);
|
32 |
}
|
33 |
|
34 |
$result_string = sprintf(
|
35 |
+
__( '%s data older than %s days purged successfully.', 'wp-statistics' ),
|
36 |
'<code>' . $table_name . '</code>',
|
37 |
'<code>' . $purge_days . '</code>'
|
38 |
);
|
39 |
} else {
|
40 |
$result_string = sprintf(
|
41 |
+
__( 'No records found to purge from %s!', 'wp-statistics' ),
|
42 |
'<code>' . $table_name . '</code>'
|
43 |
);
|
44 |
}
|
46 |
// Purge the visitors data.
|
47 |
$table_name = $wpdb->prefix . 'statistics_visitor';
|
48 |
|
49 |
+
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
|
50 |
|
51 |
if ( $result ) {
|
52 |
// Update the historical count with what we purged.
|
63 |
array(
|
64 |
'value' => $result,
|
65 |
'category' => 'visitors',
|
66 |
+
'page_id' => - 1,
|
67 |
'uri' => '-1',
|
68 |
)
|
69 |
);
|
71 |
|
72 |
$result_string .= '<br>' .
|
73 |
sprintf(
|
74 |
+
__( '%s data older than %s days purged successfully.', 'wp-statistics' ),
|
75 |
'<code>' . $table_name . '</code>',
|
76 |
'<code>' . $purge_days . '</code>'
|
77 |
);
|
78 |
} else {
|
79 |
$result_string .= '<br>' .
|
80 |
sprintf(
|
81 |
+
__( 'No records found to purge from %s!', 'wp-statistics' ),
|
82 |
'<code>' . $table_name . '</code>'
|
83 |
);
|
84 |
}
|
86 |
// Purge the exclusions data.
|
87 |
$table_name = $wpdb->prefix . 'statistics_exclusions';
|
88 |
|
89 |
+
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
|
90 |
|
91 |
if ( $result ) {
|
92 |
$result_string .= '<br>' .
|
93 |
sprintf(
|
94 |
+
__( '%s data older than %s days purged successfully.', 'wp-statistics' ),
|
95 |
'<code>' . $table_name . '</code>',
|
96 |
'<code>' . $purge_days . '</code>'
|
97 |
);
|
98 |
} else {
|
99 |
$result_string .= '<br>' .
|
100 |
sprintf(
|
101 |
+
__( 'No records found to purge from %s!', 'wp-statistics' ),
|
102 |
'<code>' . $table_name . '</code>'
|
103 |
);
|
104 |
}
|
106 |
// Purge the search data.
|
107 |
$table_name = $wpdb->prefix . 'statistics_search';
|
108 |
|
109 |
+
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
|
110 |
|
111 |
if ( $result ) {
|
112 |
$result_string .= '<br>' .
|
113 |
sprintf(
|
114 |
+
__( '%s data older than %s days purged successfully.', 'wp-statistics' ),
|
115 |
'<code>' . $table_name . '</code>',
|
116 |
'<code>' . $purge_days . '</code>'
|
117 |
);
|
118 |
} else {
|
119 |
$result_string .= '<br>' .
|
120 |
sprintf(
|
121 |
+
__( 'No records found to purge from %s!', 'wp-statistics' ),
|
122 |
'<code>' . $table_name . '</code>'
|
123 |
);
|
124 |
}
|
129 |
|
130 |
// The first thing we need to do is update the historical data by finding all the unique pages.
|
131 |
$result = $wpdb->get_results(
|
132 |
+
$wpdb->prepare( "SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string )
|
133 |
);
|
134 |
|
135 |
// If we have a result, let's store the historical data.
|
163 |
'value' => $historical,
|
164 |
'category' => 'uri',
|
165 |
'uri' => $row->uri,
|
166 |
+
'page_id' => wp_statistics_uri_to_id( $row->uri ),
|
167 |
)
|
168 |
);
|
169 |
}
|
171 |
}
|
172 |
|
173 |
// Now that we've done all of the required historical data storage, we can actually delete the data from the database.
|
174 |
+
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
|
175 |
|
176 |
if ( $result ) {
|
177 |
$result_string .= '<br>' .
|
178 |
sprintf(
|
179 |
+
__( '%s data older than %s days purged successfully.', 'wp-statistics' ),
|
180 |
'<code>' . $table_name . '</code>',
|
181 |
'<code>' . $purge_days . '</code>'
|
182 |
);
|
183 |
} else {
|
184 |
$result_string .= '<br>' .
|
185 |
sprintf(
|
186 |
+
__( 'No records found to purge from %s!', 'wp-statistics' ),
|
187 |
'<code>' . $table_name . '</code>'
|
188 |
);
|
189 |
}
|
190 |
|
191 |
+
if ( $WP_Statistics->get_option( 'prune_report' ) == true ) {
|
192 |
+
$blogname = get_bloginfo( 'name' );
|
193 |
+
$blogemail = get_bloginfo( 'admin_email' );
|
194 |
|
195 |
$headers[] = "From: $blogname <$blogemail>";
|
196 |
$headers[] = "MIME-Version: 1.0";
|
197 |
$headers[] = "Content-type: text/html; charset=utf-8";
|
198 |
|
199 |
+
if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
200 |
+
$WP_Statistics->update_option( 'email_list', $blogemail );
|
201 |
}
|
202 |
|
203 |
wp_mail(
|
204 |
+
$WP_Statistics->get_option( 'email_list' ),
|
205 |
+
__( 'Database pruned on', 'wp-statistics' ) . ' ' . $blogname,
|
206 |
$result_string,
|
207 |
$headers
|
208 |
);
|
210 |
|
211 |
return $result_string;
|
212 |
} else {
|
213 |
+
return __( 'Please select a value over 30 days.', 'wp-statistics' );
|
214 |
}
|
215 |
}
|
includes/log/all-browsers.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
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 = '';
|
@@ -26,19 +26,19 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
26 |
$rangeend
|
27 |
);
|
28 |
|
29 |
-
$rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime);
|
30 |
-
$rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime);
|
31 |
|
32 |
// Browsers
|
33 |
$Browsers = wp_statistics_ua_list();
|
34 |
-
if ( ! is_array($Browsers) ) {
|
35 |
$Browsers = array();
|
36 |
}
|
37 |
|
38 |
-
natcasesort($Browsers);
|
39 |
$BrowserVisits = array();
|
40 |
foreach ( $Browsers as $Browser ) {
|
41 |
-
$BrowserVisits[ $Browser ] = wp_statistics_useragent($Browser, $rangestartdate, $rangeenddate);
|
42 |
}
|
43 |
|
44 |
$browser_name = array();
|
@@ -48,267 +48,267 @@ $browser_color = array();
|
|
48 |
|
49 |
foreach ( $BrowserVisits as $key => $value ) {
|
50 |
if ( $value > 10 and $key ) {
|
51 |
-
$i++;
|
52 |
$browser_name[] = "'" . $key . "'";
|
53 |
$browser_value[] = $value;
|
54 |
-
$browser_color[] = wp_statistics_generate_rgba_color($i, '0.4');
|
55 |
}
|
56 |
}
|
57 |
|
58 |
// Platforms
|
59 |
-
$Platforms = wp_statistics_platform_list(null, $rangestartdate, $rangeenddate);
|
60 |
-
if ( ! is_array($Platforms) ) {
|
61 |
$Platforms = array();
|
62 |
}
|
63 |
|
64 |
-
natcasesort($Platforms);
|
65 |
$PlatformVisits = array();
|
66 |
foreach ( $Platforms as $Platform ) {
|
67 |
-
$PlatformVisits[ $Platform ] = wp_statistics_platform($Platform);
|
68 |
}
|
69 |
|
70 |
$i = 0;
|
71 |
foreach ( $PlatformVisits as $key => $value ) {
|
72 |
-
$i++;
|
73 |
$platform_name[] = "'" . $key . "'";
|
74 |
$platform_value[] = $value;
|
75 |
-
$platform_color[] = wp_statistics_generate_rgba_color($i, '0.4');
|
76 |
}
|
77 |
?>
|
78 |
<div class="wrap">
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<?php $paneltitle = __('Browsers', 'wp-statistics'); ?>
|
87 |
-
|
88 |
<span class="screen-reader-text"><?php printf(
|
89 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
90 |
$paneltitle
|
91 |
); ?></span>
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
<?php $paneltitle = __('Platform', 'wp-statistics'); ?>
|
142 |
-
|
143 |
<span class="screen-reader-text"><?php printf(
|
144 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
145 |
$paneltitle
|
146 |
); ?></span>
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
<?php
|
200 |
-
for ( $BrowserCount = 0; $BrowserCount < count($Browsers); $BrowserCount++ ) {
|
201 |
if ( $BrowserCount % 3 == 0 ) {
|
202 |
-
wp_statistics_browser_version_stats($Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate);
|
203 |
}
|
204 |
}
|
205 |
?>
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
<?php
|
214 |
-
for ( $BrowserCount = 0; $BrowserCount < count($Browsers); $BrowserCount++ ) {
|
215 |
if ( $BrowserCount % 3 == 1 ) {
|
216 |
-
wp_statistics_browser_version_stats($Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate);
|
217 |
}
|
218 |
}
|
219 |
?>
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
<?php
|
228 |
-
for ( $BrowserCount = 0; $BrowserCount < count($Browsers); $BrowserCount++ ) {
|
229 |
if ( $BrowserCount % 3 == 2 ) {
|
230 |
-
wp_statistics_browser_version_stats($Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate);
|
231 |
}
|
232 |
}
|
233 |
?>
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
</div>
|
238 |
|
239 |
<?php
|
240 |
function wp_statistics_browser_version_stats( $Browser, $rangestartdate, $rangeenddate ) {
|
241 |
$id = 'browser-stats-' . $Browser;
|
242 |
-
$browser_tag = strtolower(preg_replace('/[^a-zA-Z]/', '', $Browser));
|
243 |
-
$versions = wp_statistics_agent_version_list($Browser, $rangestartdate, $rangeenddate);
|
244 |
$version_name = array();
|
245 |
$version_value = array();
|
246 |
$browser_color = array();
|
247 |
$i = 0;
|
248 |
|
249 |
-
if ( count($versions) < 10 ) {
|
250 |
return;
|
251 |
}
|
252 |
|
253 |
foreach ( $versions as $key => $value ) {
|
254 |
-
$i++;
|
255 |
-
$version_value[ $value ] = wp_statistics_agent_version($Browser, $value, $rangestartdate, $rangeenddate);
|
256 |
-
$version_color[] = wp_statistics_generate_rgba_color($i, '0.4');
|
257 |
}
|
258 |
|
259 |
-
natcasesort($version_value);
|
260 |
-
$version_value = array_slice($version_value, -20);
|
261 |
|
262 |
foreach ( $version_value as $key => $value ) {
|
263 |
$version_name[] = "'" . $key . "'";
|
264 |
}
|
265 |
?>
|
266 |
-
|
267 |
-
<?php $paneltitle = sprintf(__('%s Version', 'wp-statistics'), $Browser); ?>
|
268 |
-
|
269 |
<span class="screen-reader-text"><?php printf(
|
270 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
271 |
$paneltitle
|
272 |
); ?></span>
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
<?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 = '';
|
26 |
$rangeend
|
27 |
);
|
28 |
|
29 |
+
$rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
|
30 |
+
$rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
|
31 |
|
32 |
// Browsers
|
33 |
$Browsers = wp_statistics_ua_list();
|
34 |
+
if ( ! is_array( $Browsers ) ) {
|
35 |
$Browsers = array();
|
36 |
}
|
37 |
|
38 |
+
natcasesort( $Browsers );
|
39 |
$BrowserVisits = array();
|
40 |
foreach ( $Browsers as $Browser ) {
|
41 |
+
$BrowserVisits[ $Browser ] = wp_statistics_useragent( $Browser, $rangestartdate, $rangeenddate );
|
42 |
}
|
43 |
|
44 |
$browser_name = array();
|
48 |
|
49 |
foreach ( $BrowserVisits as $key => $value ) {
|
50 |
if ( $value > 10 and $key ) {
|
51 |
+
$i ++;
|
52 |
$browser_name[] = "'" . $key . "'";
|
53 |
$browser_value[] = $value;
|
54 |
+
$browser_color[] = wp_statistics_generate_rgba_color( $i, '0.4' );
|
55 |
}
|
56 |
}
|
57 |
|
58 |
// Platforms
|
59 |
+
$Platforms = wp_statistics_platform_list( null, $rangestartdate, $rangeenddate );
|
60 |
+
if ( ! is_array( $Platforms ) ) {
|
61 |
$Platforms = array();
|
62 |
}
|
63 |
|
64 |
+
natcasesort( $Platforms );
|
65 |
$PlatformVisits = array();
|
66 |
foreach ( $Platforms as $Platform ) {
|
67 |
+
$PlatformVisits[ $Platform ] = wp_statistics_platform( $Platform );
|
68 |
}
|
69 |
|
70 |
$i = 0;
|
71 |
foreach ( $PlatformVisits as $key => $value ) {
|
72 |
+
$i ++;
|
73 |
$platform_name[] = "'" . $key . "'";
|
74 |
$platform_value[] = $value;
|
75 |
+
$platform_color[] = wp_statistics_generate_rgba_color( $i, '0.4' );
|
76 |
}
|
77 |
?>
|
78 |
<div class="wrap">
|
79 |
+
<h2><?php _e( 'Browser Statistics', 'wp-statistics' ); ?></h2>
|
80 |
|
81 |
+
<div><?php wp_statistics_date_range_selector( WP_Statistics::$page['browser'], $daysToDisplay ); ?></div>
|
82 |
+
<div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
|
83 |
+
<div class="metabox-holder">
|
84 |
+
<div class="meta-box-sortables">
|
85 |
+
<div class="postbox">
|
86 |
+
<?php $paneltitle = __( 'Browsers', 'wp-statistics' ); ?>
|
87 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
88 |
<span class="screen-reader-text"><?php printf(
|
89 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
90 |
$paneltitle
|
91 |
); ?></span>
|
92 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
93 |
+
</button>
|
94 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
95 |
|
96 |
+
<div class="inside">
|
97 |
+
<canvas id="browsers-log" height="200"></canvas>
|
98 |
+
<script>
|
99 |
+
var ctx = document.getElementById("browsers-log").getContext('2d');
|
100 |
+
var ChartJs = new Chart(ctx, {
|
101 |
+
type: 'pie',
|
102 |
+
data: {
|
103 |
+
labels: [<?php echo implode( ', ', $browser_name ); ?>],
|
104 |
+
datasets: [{
|
105 |
+
label: '<?php _e( 'Browsers', 'wp-statistics' ); ?>',
|
106 |
+
data: [<?php echo implode( ', ', $browser_value ); ?>],
|
107 |
+
backgroundColor: [<?php echo implode( ', ', $browser_color ); ?>],
|
108 |
+
}]
|
109 |
+
},
|
110 |
+
options: {
|
111 |
+
responsive: true,
|
112 |
+
legend: {
|
113 |
+
position: 'bottom',
|
114 |
+
},
|
115 |
+
tooltips: {
|
116 |
+
callbacks: {
|
117 |
+
label: function (tooltipItem, data) {
|
118 |
+
var dataset = data.datasets[tooltipItem.datasetIndex];
|
119 |
+
var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) {
|
120 |
+
return previousValue + currentValue;
|
121 |
+
});
|
122 |
+
var currentValue = dataset.data[tooltipItem.index];
|
123 |
+
var precentage = Math.floor(((currentValue / total) * 100) + 0.5);
|
124 |
+
return precentage + "% - " + data.labels[tooltipItem.index];
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
});
|
130 |
+
</script>
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
|
137 |
+
<div class="postbox-container" style="width: 48%; float: left; margin-right:20px">
|
138 |
+
<div class="metabox-holder">
|
139 |
+
<div class="meta-box-sortables">
|
140 |
+
<div class="postbox">
|
141 |
+
<?php $paneltitle = __( 'Platform', 'wp-statistics' ); ?>
|
142 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
143 |
<span class="screen-reader-text"><?php printf(
|
144 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
145 |
$paneltitle
|
146 |
); ?></span>
|
147 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
148 |
+
</button>
|
149 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
150 |
|
151 |
+
<div class="inside">
|
152 |
+
<canvas id="platforms-log" height="200"></canvas>
|
153 |
+
<script>
|
154 |
+
var ctx = document.getElementById("platforms-log").getContext('2d');
|
155 |
+
var ChartJs = new Chart(ctx, {
|
156 |
+
type: 'pie',
|
157 |
+
data: {
|
158 |
+
labels: [<?php echo implode( ', ', $platform_name ); ?>],
|
159 |
+
datasets: [{
|
160 |
+
label: '<?php _e( 'Platforms', 'wp-statistics' ); ?>',
|
161 |
+
data: [<?php echo implode( ', ', $platform_value ); ?>],
|
162 |
+
backgroundColor: [<?php echo implode( ', ', $platform_color ); ?>],
|
163 |
+
}]
|
164 |
+
},
|
165 |
+
options: {
|
166 |
+
responsive: true,
|
167 |
+
legend: {
|
168 |
+
position: 'bottom',
|
169 |
+
},
|
170 |
+
tooltips: {
|
171 |
+
callbacks: {
|
172 |
+
label: function (tooltipItem, data) {
|
173 |
+
var dataset = data.datasets[tooltipItem.datasetIndex];
|
174 |
+
var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) {
|
175 |
+
return previousValue + currentValue;
|
176 |
+
});
|
177 |
+
var currentValue = dataset.data[tooltipItem.index];
|
178 |
+
var precentage = Math.floor(((currentValue / total) * 100) + 0.5);
|
179 |
+
return precentage + "% - " + data.labels[tooltipItem.index];
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
});
|
185 |
+
</script>
|
186 |
+
</div>
|
187 |
+
</div>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
|
192 |
+
<div style="width: 100%; clear: both;">
|
193 |
+
<hr/>
|
194 |
+
</div>
|
195 |
|
196 |
+
<div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
|
197 |
+
<div class="metabox-holder">
|
198 |
+
<div class="meta-box-sortables">
|
199 |
<?php
|
200 |
+
for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
|
201 |
if ( $BrowserCount % 3 == 0 ) {
|
202 |
+
wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate );
|
203 |
}
|
204 |
}
|
205 |
?>
|
206 |
+
</div>
|
207 |
+
</div>
|
208 |
+
</div>
|
209 |
|
210 |
+
<div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;">
|
211 |
+
<div class="metabox-holder">
|
212 |
+
<div class="meta-box-sortables">
|
213 |
<?php
|
214 |
+
for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
|
215 |
if ( $BrowserCount % 3 == 1 ) {
|
216 |
+
wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate );
|
217 |
}
|
218 |
}
|
219 |
?>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
|
224 |
+
<div class="postbox-container" style="width: 30%; float: left">
|
225 |
+
<div class="metabox-holder">
|
226 |
+
<div class="meta-box-sortables">
|
227 |
<?php
|
228 |
+
for ( $BrowserCount = 0; $BrowserCount < count( $Browsers ); $BrowserCount ++ ) {
|
229 |
if ( $BrowserCount % 3 == 2 ) {
|
230 |
+
wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate );
|
231 |
}
|
232 |
}
|
233 |
?>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
</div>
|
238 |
|
239 |
<?php
|
240 |
function wp_statistics_browser_version_stats( $Browser, $rangestartdate, $rangeenddate ) {
|
241 |
$id = 'browser-stats-' . $Browser;
|
242 |
+
$browser_tag = strtolower( preg_replace( '/[^a-zA-Z]/', '', $Browser ) );
|
243 |
+
$versions = wp_statistics_agent_version_list( $Browser, $rangestartdate, $rangeenddate );
|
244 |
$version_name = array();
|
245 |
$version_value = array();
|
246 |
$browser_color = array();
|
247 |
$i = 0;
|
248 |
|
249 |
+
if ( count( $versions ) < 10 ) {
|
250 |
return;
|
251 |
}
|
252 |
|
253 |
foreach ( $versions as $key => $value ) {
|
254 |
+
$i ++;
|
255 |
+
$version_value[ $value ] = wp_statistics_agent_version( $Browser, $value, $rangestartdate, $rangeenddate );
|
256 |
+
$version_color[] = wp_statistics_generate_rgba_color( $i, '0.4' );
|
257 |
}
|
258 |
|
259 |
+
natcasesort( $version_value );
|
260 |
+
$version_value = array_slice( $version_value, - 20 );
|
261 |
|
262 |
foreach ( $version_value as $key => $value ) {
|
263 |
$version_name[] = "'" . $key . "'";
|
264 |
}
|
265 |
?>
|
266 |
+
<div class="postbox">
|
267 |
+
<?php $paneltitle = sprintf( __( '%s Version', 'wp-statistics' ), $Browser ); ?>
|
268 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
269 |
<span class="screen-reader-text"><?php printf(
|
270 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
271 |
$paneltitle
|
272 |
); ?></span>
|
273 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
274 |
+
</button>
|
275 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
276 |
|
277 |
+
<div class="inside">
|
278 |
+
<canvas id="<?php echo $id; ?>" height="250"></canvas>
|
279 |
+
<script>
|
280 |
+
var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d');
|
281 |
+
var ChartJs = new Chart(ctx, {
|
282 |
+
type: 'doughnut',
|
283 |
+
data: {
|
284 |
+
labels: [<?php echo implode( ', ', $version_name ); ?>],
|
285 |
+
datasets: [{
|
286 |
+
label: '<?php _e( 'Platforms', 'wp-statistics' ); ?>',
|
287 |
+
data: [<?php echo implode( ', ', $version_value ); ?>],
|
288 |
+
backgroundColor: [<?php echo implode( ', ', $version_color ); ?>],
|
289 |
+
}]
|
290 |
+
},
|
291 |
+
options: {
|
292 |
+
responsive: true,
|
293 |
+
legend: {
|
294 |
+
display: false,
|
295 |
+
},
|
296 |
+
tooltips: {
|
297 |
+
callbacks: {
|
298 |
+
label: function (tooltipItem, data) {
|
299 |
+
var dataset = data.datasets[tooltipItem.datasetIndex];
|
300 |
+
var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) {
|
301 |
+
return previousValue + currentValue;
|
302 |
+
});
|
303 |
+
var currentValue = dataset.data[tooltipItem.index];
|
304 |
+
var precentage = Math.floor(((currentValue / total) * 100) + 0.5);
|
305 |
+
return precentage + "% - " + data.labels[tooltipItem.index];
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
});
|
311 |
+
</script>
|
312 |
+
</div>
|
313 |
+
</div>
|
314 |
<?php }
|
includes/log/authors.php
CHANGED
@@ -1,47 +1,47 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<div class="wrap">
|
7 |
-
|
8 |
<?php
|
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 |
-
if ( array_key_exists('author', $_GET) ) {
|
25 |
-
$author = intval($_GET['author']);
|
26 |
} else {
|
27 |
-
if ( array_key_exists('preauthor', $_GET) ) {
|
28 |
-
$author = intval($_GET['preauthor']);
|
29 |
} else {
|
30 |
$author = 0;
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
$html = __('Select Author', 'wp-statistics') . ': ';
|
35 |
$html .= '<select name="author" id="author">';
|
36 |
|
37 |
$authors_list = wp_list_authors(
|
38 |
'html=0&style=none&echo=0&exclude_admin=0&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC'
|
39 |
);
|
40 |
|
41 |
-
$authors_array = explode(',', $authors_list);
|
42 |
|
43 |
foreach ( $authors_array as $value ) {
|
44 |
-
$author_obj = get_user_by('slug', $value);
|
45 |
|
46 |
if ( $author_obj !== false ) {
|
47 |
// Check to see if this tag is the one that is currently selected.
|
@@ -57,7 +57,7 @@
|
|
57 |
|
58 |
$html .= '</select>';
|
59 |
|
60 |
-
$html .= ' <input type="submit" value="' . __('Select', 'wp-statistics') . '" class="button-primary">';
|
61 |
$html .= '<br>';
|
62 |
|
63 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
@@ -79,171 +79,171 @@
|
|
79 |
'author' => $author,
|
80 |
);
|
81 |
|
82 |
-
$posts = get_posts($args);
|
83 |
|
84 |
-
$visit_total
|
85 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
86 |
-
$posts_stats
|
87 |
-
$visits
|
88 |
|
89 |
// Setup the array, otherwise PHP may throw an error.
|
90 |
foreach ( $posts as $post ) {
|
91 |
$posts_stats[ $post->ID ] = 0;
|
92 |
}
|
93 |
|
94 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
95 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
96 |
|
97 |
$stat = 0;
|
98 |
foreach ( $posts as $post ) {
|
99 |
-
$temp_stat
|
100 |
$posts_stats[ $post->ID ] += $temp_stat;
|
101 |
-
$stat
|
102 |
}
|
103 |
|
104 |
-
$visits[]
|
105 |
$visit_total += $stat;
|
106 |
}
|
107 |
?>
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
<?php $paneltitle = __('Author Statistics Chart', 'wp-statistics'); ?>
|
113 |
-
|
114 |
<span class="screen-reader-text"><?php printf(
|
115 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
116 |
$paneltitle
|
117 |
); ?></span>
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
<?php $paneltitle = __('Author Statistics Summary', 'wp-statistics'); ?>
|
175 |
-
|
176 |
<span class="screen-reader-text"><?php printf(
|
177 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
178 |
$paneltitle
|
179 |
); ?></span>
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
208 |
$stat = 0;
|
209 |
foreach ( $posts as $post ) {
|
210 |
-
$stat += wp_statistics_pages('total', null, $post->ID);
|
211 |
}
|
212 |
|
213 |
-
echo number_format_i18n($stat); ?></span></th>
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
<?php $paneltitle = __('Author Posts Sorted by Hits', 'wp-statistics'); ?>
|
228 |
-
|
229 |
<span class="screen-reader-text"><?php printf(
|
230 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
231 |
$paneltitle
|
232 |
); ?></span>
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
|
245 |
<?php
|
246 |
-
arsort($posts_stats);
|
247 |
|
248 |
$posts_by_id = array();
|
249 |
|
@@ -255,24 +255,24 @@
|
|
255 |
$post_obj = $posts_by_id[ $post_id ];
|
256 |
|
257 |
?>
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
$post_obj
|
262 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
<?php
|
268 |
}
|
269 |
?>
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
|
278 |
</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 |
+
<h2><?php _e( 'Author Statistics', 'wp-statistics' ); ?></h2>
|
8 |
<?php
|
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 |
+
if ( array_key_exists( 'author', $_GET ) ) {
|
25 |
+
$author = intval( $_GET['author'] );
|
26 |
} else {
|
27 |
+
if ( array_key_exists( 'preauthor', $_GET ) ) {
|
28 |
+
$author = intval( $_GET['preauthor'] );
|
29 |
} else {
|
30 |
$author = 0;
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
$html = __( 'Select Author', 'wp-statistics' ) . ': ';
|
35 |
$html .= '<select name="author" id="author">';
|
36 |
|
37 |
$authors_list = wp_list_authors(
|
38 |
'html=0&style=none&echo=0&exclude_admin=0&optioncount=0&show_fullname=1&hide_empty=1&orderby=name&order=ASC'
|
39 |
);
|
40 |
|
41 |
+
$authors_array = explode( ',', $authors_list );
|
42 |
|
43 |
foreach ( $authors_array as $value ) {
|
44 |
+
$author_obj = get_user_by( 'slug', $value );
|
45 |
|
46 |
if ( $author_obj !== false ) {
|
47 |
// Check to see if this tag is the one that is currently selected.
|
57 |
|
58 |
$html .= '</select>';
|
59 |
|
60 |
+
$html .= ' <input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">';
|
61 |
$html .= '<br>';
|
62 |
|
63 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
79 |
'author' => $author,
|
80 |
);
|
81 |
|
82 |
+
$posts = get_posts( $args );
|
83 |
|
84 |
+
$visit_total = 0;
|
85 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
86 |
+
$posts_stats = array();
|
87 |
+
$visits = array();
|
88 |
|
89 |
// Setup the array, otherwise PHP may throw an error.
|
90 |
foreach ( $posts as $post ) {
|
91 |
$posts_stats[ $post->ID ] = 0;
|
92 |
}
|
93 |
|
94 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
95 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
96 |
|
97 |
$stat = 0;
|
98 |
foreach ( $posts as $post ) {
|
99 |
+
$temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
|
100 |
$posts_stats[ $post->ID ] += $temp_stat;
|
101 |
+
$stat = $temp_stat;
|
102 |
}
|
103 |
|
104 |
+
$visits[] = $stat;
|
105 |
$visit_total += $stat;
|
106 |
}
|
107 |
?>
|
108 |
+
<div class="postbox-container" id="last-log">
|
109 |
+
<div class="metabox-holder">
|
110 |
+
<div class="meta-box-sortables">
|
111 |
+
<div class="postbox">
|
112 |
+
<?php $paneltitle = __( 'Author Statistics Chart', 'wp-statistics' ); ?>
|
113 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
114 |
<span class="screen-reader-text"><?php printf(
|
115 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
116 |
$paneltitle
|
117 |
); ?></span>
|
118 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
119 |
+
</button>
|
120 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
121 |
+
|
122 |
+
<div class="inside">
|
123 |
+
<canvas id="hit-stats" height="80"></canvas>
|
124 |
+
<script>
|
125 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
126 |
+
var ChartJs = new Chart(ctx, {
|
127 |
+
type: 'line',
|
128 |
+
data: {
|
129 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
130 |
+
datasets: [
|
131 |
+
{
|
132 |
+
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
|
133 |
+
data: [<?php echo implode( ',', $visits ); ?>],
|
134 |
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
135 |
+
borderColor: 'rgba(54, 162, 235, 1)',
|
136 |
+
borderWidth: 1,
|
137 |
+
fill: true,
|
138 |
+
},
|
139 |
+
]
|
140 |
+
},
|
141 |
+
options: {
|
142 |
+
responsive: true,
|
143 |
+
legend: {
|
144 |
+
position: 'bottom',
|
145 |
+
},
|
146 |
+
title: {
|
147 |
+
display: true,
|
148 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
149 |
+
},
|
150 |
+
tooltips: {
|
151 |
+
mode: 'index',
|
152 |
+
intersect: false,
|
153 |
+
},
|
154 |
+
scales: {
|
155 |
+
yAxes: [{
|
156 |
+
ticks: {
|
157 |
+
beginAtZero: true
|
158 |
+
}
|
159 |
+
}]
|
160 |
+
}
|
161 |
+
}
|
162 |
+
});
|
163 |
+
</script>
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
171 |
+
<div class="metabox-holder">
|
172 |
+
<div class="meta-box-sortables">
|
173 |
+
<div class="postbox">
|
174 |
+
<?php $paneltitle = __( 'Author Statistics Summary', 'wp-statistics' ); ?>
|
175 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
176 |
<span class="screen-reader-text"><?php printf(
|
177 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
178 |
$paneltitle
|
179 |
); ?></span>
|
180 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
181 |
+
</button>
|
182 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
183 |
+
|
184 |
+
<div class="inside">
|
185 |
+
<table width="auto" class="widefat table-stats" id="summary-stats">
|
186 |
+
<tbody>
|
187 |
+
<tr>
|
188 |
+
<th></th>
|
189 |
+
<th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th>
|
190 |
+
</tr>
|
191 |
+
|
192 |
+
<tr>
|
193 |
+
<th><?php _e( 'Number of posts by author', 'wp-statistics' ); ?>:</th>
|
194 |
+
<th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
|
195 |
+
</th>
|
196 |
+
</tr>
|
197 |
+
|
198 |
+
<tr>
|
199 |
+
<th><?php _e( 'Chart Visits Total', 'wp-statistics' ); ?>:</th>
|
200 |
+
<th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
|
201 |
+
</th>
|
202 |
+
</tr>
|
203 |
+
|
204 |
+
<tr>
|
205 |
+
<th><?php _e( 'All Time Visits Total', 'wp-statistics' ); ?>:</th>
|
206 |
+
<th class="th-center"><span><?php
|
207 |
|
208 |
$stat = 0;
|
209 |
foreach ( $posts as $post ) {
|
210 |
+
$stat += wp_statistics_pages( 'total', null, $post->ID );
|
211 |
}
|
212 |
|
213 |
+
echo number_format_i18n( $stat ); ?></span></th>
|
214 |
+
</tr>
|
215 |
+
</tbody>
|
216 |
+
</table>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
|
223 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
224 |
+
<div class="metabox-holder">
|
225 |
+
<div class="meta-box-sortables">
|
226 |
+
<div class="postbox">
|
227 |
+
<?php $paneltitle = __( 'Author Posts Sorted by Hits', 'wp-statistics' ); ?>
|
228 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
229 |
<span class="screen-reader-text"><?php printf(
|
230 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
231 |
$paneltitle
|
232 |
); ?></span>
|
233 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
234 |
+
</button>
|
235 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
236 |
+
|
237 |
+
<div class="inside">
|
238 |
+
<table width="auto" class="widefat table-stats" id="post-stats">
|
239 |
+
<tbody>
|
240 |
+
<tr>
|
241 |
+
<th><?php _e( 'Post Title', 'wp-statistics' ); ?></th>
|
242 |
+
<th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th>
|
243 |
+
</tr>
|
244 |
|
245 |
<?php
|
246 |
+
arsort( $posts_stats );
|
247 |
|
248 |
$posts_by_id = array();
|
249 |
|
255 |
$post_obj = $posts_by_id[ $post_id ];
|
256 |
|
257 |
?>
|
258 |
+
<tr>
|
259 |
+
<th>
|
260 |
+
<a href="<?php echo get_permalink(
|
261 |
$post_obj
|
262 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
263 |
+
</th>
|
264 |
+
<th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
|
265 |
+
</th>
|
266 |
+
</tr>
|
267 |
<?php
|
268 |
}
|
269 |
?>
|
270 |
+
</tbody>
|
271 |
+
</table>
|
272 |
+
</div>
|
273 |
+
</div>
|
274 |
+
</div>
|
275 |
+
</div>
|
276 |
+
</div>
|
277 |
|
278 |
</div>
|
includes/log/categories.php
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<div class="wrap">
|
7 |
-
|
8 |
|
9 |
<?php
|
10 |
$daysToDisplay = 20;
|
11 |
-
if ( array_key_exists('hitdays', $_GET) ) {
|
12 |
-
$daysToDisplay = intval($_GET['hitdays']);
|
13 |
}
|
14 |
|
15 |
-
if ( array_key_exists('rangestart', $_GET) ) {
|
16 |
$rangestart = $_GET['rangestart'];
|
17 |
} else {
|
18 |
$rangestart = '';
|
19 |
}
|
20 |
|
21 |
-
if ( array_key_exists('rangeend', $_GET) ) {
|
22 |
$rangeend = $_GET['rangeend'];
|
23 |
} else {
|
24 |
$rangeend = '';
|
25 |
}
|
26 |
|
27 |
-
if ( array_key_exists('cat', $_GET) ) {
|
28 |
-
$category = intval($_GET['cat']);
|
29 |
} else {
|
30 |
-
if ( array_key_exists('precat', $_GET) ) {
|
31 |
-
$category = intval($_GET['precat']);
|
32 |
} else {
|
33 |
$category = 0;
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
$html = __('Select Category', 'wp-statistics') . ': ';
|
38 |
|
39 |
$args = array(
|
40 |
'selected' => $category,
|
41 |
'echo' => 0,
|
42 |
);
|
43 |
|
44 |
-
$html .= wp_dropdown_categories($args);
|
45 |
-
$html .= '<input type="submit" value="' . __('Select', 'wp-statistics') . '" class="button-primary">';
|
46 |
$html .= '<br>';
|
47 |
|
48 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
@@ -64,171 +64,171 @@
|
|
64 |
'category' => $category,
|
65 |
);
|
66 |
|
67 |
-
$posts = get_posts($args);
|
68 |
|
69 |
-
$visit_total
|
70 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
71 |
-
$posts_stats
|
72 |
-
$visits
|
73 |
|
74 |
// Setup the array, otherwise PHP may throw an error.
|
75 |
foreach ( $posts as $post ) {
|
76 |
$posts_stats[ $post->ID ] = 0;
|
77 |
}
|
78 |
|
79 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
80 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
81 |
|
82 |
$stat = 0;
|
83 |
foreach ( $posts as $post ) {
|
84 |
-
$temp_stat
|
85 |
$posts_stats[ $post->ID ] += $temp_stat;
|
86 |
-
$stat
|
87 |
}
|
88 |
|
89 |
-
$visits[]
|
90 |
$visit_total += $stat;
|
91 |
}
|
92 |
?>
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
<?php $paneltitle = __('Category Statistics Chart', 'wp-statistics'); ?>
|
98 |
-
|
99 |
<span class="screen-reader-text"><?php printf(
|
100 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
101 |
$paneltitle
|
102 |
); ?></span>
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
<?php $paneltitle = __('Category Statistics Summary', 'wp-statistics'); ?>
|
160 |
-
|
161 |
<span class="screen-reader-text"><?php printf(
|
162 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
163 |
$paneltitle
|
164 |
); ?></span>
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
|
193 |
$stat = 0;
|
194 |
foreach ( $posts as $post ) {
|
195 |
-
$stat += wp_statistics_pages('total', null, $post->ID);
|
196 |
}
|
197 |
|
198 |
-
echo number_format_i18n($stat); ?></span></th>
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
<?php $paneltitle = __('Category Posts Sorted by Hits', 'wp-statistics'); ?>
|
213 |
-
|
214 |
<span class="screen-reader-text"><?php printf(
|
215 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
216 |
$paneltitle
|
217 |
); ?></span>
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
|
230 |
<?php
|
231 |
-
arsort($posts_stats);
|
232 |
|
233 |
$posts_by_id = array();
|
234 |
|
@@ -240,24 +240,24 @@
|
|
240 |
$post_obj = $posts_by_id[ $post_id ];
|
241 |
|
242 |
?>
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
$post_obj
|
247 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
<?php
|
253 |
}
|
254 |
?>
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
</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 |
+
<h2><?php _e( 'Category Statistics', 'wp-statistics' ); ?></h2>
|
8 |
|
9 |
<?php
|
10 |
$daysToDisplay = 20;
|
11 |
+
if ( array_key_exists( 'hitdays', $_GET ) ) {
|
12 |
+
$daysToDisplay = intval( $_GET['hitdays'] );
|
13 |
}
|
14 |
|
15 |
+
if ( array_key_exists( 'rangestart', $_GET ) ) {
|
16 |
$rangestart = $_GET['rangestart'];
|
17 |
} else {
|
18 |
$rangestart = '';
|
19 |
}
|
20 |
|
21 |
+
if ( array_key_exists( 'rangeend', $_GET ) ) {
|
22 |
$rangeend = $_GET['rangeend'];
|
23 |
} else {
|
24 |
$rangeend = '';
|
25 |
}
|
26 |
|
27 |
+
if ( array_key_exists( 'cat', $_GET ) ) {
|
28 |
+
$category = intval( $_GET['cat'] );
|
29 |
} else {
|
30 |
+
if ( array_key_exists( 'precat', $_GET ) ) {
|
31 |
+
$category = intval( $_GET['precat'] );
|
32 |
} else {
|
33 |
$category = 0;
|
34 |
}
|
35 |
}
|
36 |
|
37 |
+
$html = __( 'Select Category', 'wp-statistics' ) . ': ';
|
38 |
|
39 |
$args = array(
|
40 |
'selected' => $category,
|
41 |
'echo' => 0,
|
42 |
);
|
43 |
|
44 |
+
$html .= wp_dropdown_categories( $args );
|
45 |
+
$html .= '<input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">';
|
46 |
$html .= '<br>';
|
47 |
|
48 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
64 |
'category' => $category,
|
65 |
);
|
66 |
|
67 |
+
$posts = get_posts( $args );
|
68 |
|
69 |
+
$visit_total = 0;
|
70 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
71 |
+
$posts_stats = array();
|
72 |
+
$visits = array();
|
73 |
|
74 |
// Setup the array, otherwise PHP may throw an error.
|
75 |
foreach ( $posts as $post ) {
|
76 |
$posts_stats[ $post->ID ] = 0;
|
77 |
}
|
78 |
|
79 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
80 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
81 |
|
82 |
$stat = 0;
|
83 |
foreach ( $posts as $post ) {
|
84 |
+
$temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
|
85 |
$posts_stats[ $post->ID ] += $temp_stat;
|
86 |
+
$stat = $temp_stat;
|
87 |
}
|
88 |
|
89 |
+
$visits[] = $stat;
|
90 |
$visit_total += $stat;
|
91 |
}
|
92 |
?>
|
93 |
+
<div class="postbox-container" id="last-log">
|
94 |
+
<div class="metabox-holder">
|
95 |
+
<div class="meta-box-sortables">
|
96 |
+
<div class="postbox">
|
97 |
+
<?php $paneltitle = __( 'Category Statistics Chart', 'wp-statistics' ); ?>
|
98 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
99 |
<span class="screen-reader-text"><?php printf(
|
100 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
101 |
$paneltitle
|
102 |
); ?></span>
|
103 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
104 |
+
</button>
|
105 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
106 |
+
|
107 |
+
<div class="inside">
|
108 |
+
<canvas id="hit-stats" height="80"></canvas>
|
109 |
+
<script>
|
110 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
111 |
+
var ChartJs = new Chart(ctx, {
|
112 |
+
type: 'line',
|
113 |
+
data: {
|
114 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
115 |
+
datasets: [
|
116 |
+
{
|
117 |
+
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
|
118 |
+
data: [<?php echo implode( ',', $visits ); ?>],
|
119 |
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
120 |
+
borderColor: 'rgba(54, 162, 235, 1)',
|
121 |
+
borderWidth: 1,
|
122 |
+
fill: true,
|
123 |
+
},
|
124 |
+
]
|
125 |
+
},
|
126 |
+
options: {
|
127 |
+
responsive: true,
|
128 |
+
legend: {
|
129 |
+
position: 'bottom',
|
130 |
+
},
|
131 |
+
title: {
|
132 |
+
display: true,
|
133 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
134 |
+
},
|
135 |
+
tooltips: {
|
136 |
+
mode: 'index',
|
137 |
+
intersect: false,
|
138 |
+
},
|
139 |
+
scales: {
|
140 |
+
yAxes: [{
|
141 |
+
ticks: {
|
142 |
+
beginAtZero: true
|
143 |
+
}
|
144 |
+
}]
|
145 |
+
}
|
146 |
+
}
|
147 |
+
});
|
148 |
+
</script>
|
149 |
+
</div>
|
150 |
+
</div>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
</div>
|
154 |
+
|
155 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
156 |
+
<div class="metabox-holder">
|
157 |
+
<div class="meta-box-sortables">
|
158 |
+
<div class="postbox">
|
159 |
+
<?php $paneltitle = __( 'Category Statistics Summary', 'wp-statistics' ); ?>
|
160 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
161 |
<span class="screen-reader-text"><?php printf(
|
162 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
163 |
$paneltitle
|
164 |
); ?></span>
|
165 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
166 |
+
</button>
|
167 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
168 |
+
|
169 |
+
<div class="inside">
|
170 |
+
<table width="auto" class="widefat table-stats" id="summary-stats">
|
171 |
+
<tbody>
|
172 |
+
<tr>
|
173 |
+
<th></th>
|
174 |
+
<th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th>
|
175 |
+
</tr>
|
176 |
+
|
177 |
+
<tr>
|
178 |
+
<th><?php _e( 'Number of posts in category', 'wp-statistics' ); ?>:</th>
|
179 |
+
<th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
|
180 |
+
</th>
|
181 |
+
</tr>
|
182 |
+
|
183 |
+
<tr>
|
184 |
+
<th><?php _e( 'Chart Visits Total', 'wp-statistics' ); ?>:</th>
|
185 |
+
<th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
|
186 |
+
</th>
|
187 |
+
</tr>
|
188 |
+
|
189 |
+
<tr>
|
190 |
+
<th><?php _e( 'All Time Visits Total', 'wp-statistics' ); ?>:</th>
|
191 |
+
<th class="th-center"><span><?php
|
192 |
|
193 |
$stat = 0;
|
194 |
foreach ( $posts as $post ) {
|
195 |
+
$stat += wp_statistics_pages( 'total', null, $post->ID );
|
196 |
}
|
197 |
|
198 |
+
echo number_format_i18n( $stat ); ?></span></th>
|
199 |
+
</tr>
|
200 |
+
</tbody>
|
201 |
+
</table>
|
202 |
+
</div>
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
|
208 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
209 |
+
<div class="metabox-holder">
|
210 |
+
<div class="meta-box-sortables">
|
211 |
+
<div class="postbox">
|
212 |
+
<?php $paneltitle = __( 'Category Posts Sorted by Hits', 'wp-statistics' ); ?>
|
213 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
214 |
<span class="screen-reader-text"><?php printf(
|
215 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
216 |
$paneltitle
|
217 |
); ?></span>
|
218 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
219 |
+
</button>
|
220 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
221 |
+
|
222 |
+
<div class="inside">
|
223 |
+
<table width="auto" class="widefat table-stats" id="post-stats">
|
224 |
+
<tbody>
|
225 |
+
<tr>
|
226 |
+
<th><?php _e( 'Post Title', 'wp-statistics' ); ?></th>
|
227 |
+
<th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th>
|
228 |
+
</tr>
|
229 |
|
230 |
<?php
|
231 |
+
arsort( $posts_stats );
|
232 |
|
233 |
$posts_by_id = array();
|
234 |
|
240 |
$post_obj = $posts_by_id[ $post_id ];
|
241 |
|
242 |
?>
|
243 |
+
<tr>
|
244 |
+
<th>
|
245 |
+
<a href="<?php echo get_permalink(
|
246 |
$post_obj
|
247 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
248 |
+
</th>
|
249 |
+
<th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
|
250 |
+
</th>
|
251 |
+
</tr>
|
252 |
<?php
|
253 |
}
|
254 |
?>
|
255 |
+
</tbody>
|
256 |
+
</table>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
</div>
|
260 |
+
</div>
|
261 |
+
</div>
|
262 |
|
263 |
</div>
|
includes/log/exclusions.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<?php
|
7 |
-
if ( $WP_Statistics->get_option('record_exclusions') != 1 ) {
|
8 |
echo "<div class='updated settings-error'><p><strong>" .
|
9 |
__(
|
10 |
'Attention: Exclusion are not currently set to be recorded, the results below may not reflect current statistics!',
|
@@ -14,16 +14,16 @@ if ( $WP_Statistics->get_option('record_exclusions') != 1 ) {
|
|
14 |
}
|
15 |
|
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 = '';
|
@@ -34,7 +34,7 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
34 |
$rangestart,
|
35 |
$rangeend
|
36 |
);
|
37 |
-
$total_stats = $WP_Statistics->get_option('chart_totals');
|
38 |
|
39 |
$excluded_reasons = array(
|
40 |
'Robot',
|
@@ -93,23 +93,23 @@ $excluded_reason_db = array(
|
|
93 |
'CronJob' => 'cronjob',
|
94 |
);
|
95 |
$excluded_reason_translate = array(
|
96 |
-
'Robot' => json_encode(__('Robot', 'wp-statistics')),
|
97 |
-
'Browscap' => json_encode(__('Browscap', 'wp-statistics')),
|
98 |
-
'IP Match' => json_encode(__('IP Match', 'wp-statistics')),
|
99 |
-
'Self Referral' => json_encode(__('Self Referral', 'wp-statistics')),
|
100 |
-
'Login Page' => json_encode(__('Login Page', 'wp-statistics')),
|
101 |
-
'User Role' => json_encode(__('User Role', 'wp-statistics')),
|
102 |
-
'Total' => json_encode(__('Total', 'wp-statistics')),
|
103 |
-
'GeoIP' => json_encode(__('GeoIP', 'wp-statistics')),
|
104 |
-
'Hostname' => json_encode(__('Hostname', 'wp-statistics')),
|
105 |
-
'Robot Threshold' => json_encode(__('Robot Threshold', 'wp-statistics')),
|
106 |
-
'Honey Pot' => json_encode(__('Honey Pot', 'wp-statistics')),
|
107 |
-
'Feeds' => json_encode(__('Feeds', 'wp-statistics')),
|
108 |
-
'Excluded URL' => json_encode(__('Excluded URL', 'wp-statistics')),
|
109 |
-
'404 Pages' => json_encode(__('404 Pages', 'wp-statistics')),
|
110 |
-
'Referrer Spam' => json_encode(__('Referrer Spam', 'wp-statistics')),
|
111 |
-
'AJAX Request' => json_encode(__('AJAX Request', 'wp-statistics')),
|
112 |
-
'CronJob' => json_encode(__('CronJob', 'wp-statistics')),
|
113 |
);
|
114 |
$excluded_results = array( 'Total' => array() );
|
115 |
$excluded_total = 0;
|
@@ -119,10 +119,10 @@ foreach ( $excluded_reasons as $reason ) {
|
|
119 |
// is created with mixed case so it looks nice to the user. Therefore we have to convert it to lower case here.
|
120 |
$thisreason = $excluded_reason_db[ $reason ];
|
121 |
|
122 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
123 |
|
124 |
// We're looping through the days backwards, so let's fine out what date we want to look at.
|
125 |
-
$thisdate = $WP_Statistics->real_current_date('Y-m-d', '-' . $i, $rangeend_utime);
|
126 |
|
127 |
// Create the SQL query string to get the data.
|
128 |
$query = $wpdb->prepare(
|
@@ -132,7 +132,7 @@ foreach ( $excluded_reasons as $reason ) {
|
|
132 |
);
|
133 |
|
134 |
// Execute the query.
|
135 |
-
$excluded_results[ $reason ][ $i ] = $wpdb->get_var($query);
|
136 |
|
137 |
// If we're returned an error or a FALSE value, then let's make sure it's set to a numerical 0.
|
138 |
if ( $excluded_results[ $reason ][ $i ] < 1 ) {
|
@@ -140,144 +140,144 @@ foreach ( $excluded_reasons as $reason ) {
|
|
140 |
}
|
141 |
|
142 |
// Make sure to initialize the results so we don't get warnings when WP_DEBUG is enabled.
|
143 |
-
if ( ! array_key_exists($i, $excluded_results['Total']) ) {
|
144 |
$excluded_results['Total'][ $i ] = 0;
|
145 |
}
|
146 |
|
147 |
// We're totalling things up here for use later.
|
148 |
$excluded_results['Total'][ $i ] += $excluded_results[ $reason ][ $i ];
|
149 |
-
$excluded_total
|
150 |
}
|
151 |
}
|
152 |
|
153 |
-
$excuded_all_time = $wpdb->get_var("SELECT SUM(count) FROM {$wpdb->prefix}statistics_exclusions");
|
154 |
|
155 |
// If the chart totals is enabled, cheat a little and just add another reason category to the list so it gets generated later.
|
156 |
if ( $total_stats == 1 ) {
|
157 |
$excluded_reasons[] = 'Total';
|
158 |
}
|
159 |
|
160 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
161 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
162 |
}
|
163 |
|
164 |
$stats = array();
|
165 |
foreach ( $excluded_reasons as $reason ) {
|
166 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
167 |
$stats[ $reason ][] = $excluded_results[ $reason ][ $i ];
|
168 |
}
|
169 |
}
|
170 |
?>
|
171 |
<div class="wrap">
|
172 |
-
|
173 |
-
<?php wp_statistics_date_range_selector(WP_Statistics::$page['exclusions'], $daysToDisplay); ?>
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
<?php $paneltitle = __('Exclusions Statistical Chart', 'wp-statistics'); ?>
|
179 |
-
|
180 |
<span class="screen-reader-text"><?php printf(
|
181 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
182 |
$paneltitle
|
183 |
); ?></span>
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
<?php foreach ($stats as $key => $value) : $i ++; ?>
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
<?php endforeach; ?>
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
<?php $paneltitle = __('Hits Statistics Summary', 'wp-statistics'); ?>
|
247 |
-
|
248 |
<span class="screen-reader-text"><?php printf(
|
249 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
250 |
$paneltitle
|
251 |
); ?></span>
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
</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>" .
|
9 |
__(
|
10 |
'Attention: Exclusion are not currently set to be recorded, the results below may not reflect current statistics!',
|
14 |
}
|
15 |
|
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 = '';
|
34 |
$rangestart,
|
35 |
$rangeend
|
36 |
);
|
37 |
+
$total_stats = $WP_Statistics->get_option( 'chart_totals' );
|
38 |
|
39 |
$excluded_reasons = array(
|
40 |
'Robot',
|
93 |
'CronJob' => 'cronjob',
|
94 |
);
|
95 |
$excluded_reason_translate = array(
|
96 |
+
'Robot' => json_encode( __( 'Robot', 'wp-statistics' ) ),
|
97 |
+
'Browscap' => json_encode( __( 'Browscap', 'wp-statistics' ) ),
|
98 |
+
'IP Match' => json_encode( __( 'IP Match', 'wp-statistics' ) ),
|
99 |
+
'Self Referral' => json_encode( __( 'Self Referral', 'wp-statistics' ) ),
|
100 |
+
'Login Page' => json_encode( __( 'Login Page', 'wp-statistics' ) ),
|
101 |
+
'User Role' => json_encode( __( 'User Role', 'wp-statistics' ) ),
|
102 |
+
'Total' => json_encode( __( 'Total', 'wp-statistics' ) ),
|
103 |
+
'GeoIP' => json_encode( __( 'GeoIP', 'wp-statistics' ) ),
|
104 |
+
'Hostname' => json_encode( __( 'Hostname', 'wp-statistics' ) ),
|
105 |
+
'Robot Threshold' => json_encode( __( 'Robot Threshold', 'wp-statistics' ) ),
|
106 |
+
'Honey Pot' => json_encode( __( 'Honey Pot', 'wp-statistics' ) ),
|
107 |
+
'Feeds' => json_encode( __( 'Feeds', 'wp-statistics' ) ),
|
108 |
+
'Excluded URL' => json_encode( __( 'Excluded URL', 'wp-statistics' ) ),
|
109 |
+
'404 Pages' => json_encode( __( '404 Pages', 'wp-statistics' ) ),
|
110 |
+
'Referrer Spam' => json_encode( __( 'Referrer Spam', 'wp-statistics' ) ),
|
111 |
+
'AJAX Request' => json_encode( __( 'AJAX Request', 'wp-statistics' ) ),
|
112 |
+
'CronJob' => json_encode( __( 'CronJob', 'wp-statistics' ) ),
|
113 |
);
|
114 |
$excluded_results = array( 'Total' => array() );
|
115 |
$excluded_total = 0;
|
119 |
// is created with mixed case so it looks nice to the user. Therefore we have to convert it to lower case here.
|
120 |
$thisreason = $excluded_reason_db[ $reason ];
|
121 |
|
122 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
123 |
|
124 |
// We're looping through the days backwards, so let's fine out what date we want to look at.
|
125 |
+
$thisdate = $WP_Statistics->real_current_date( 'Y-m-d', '-' . $i, $rangeend_utime );
|
126 |
|
127 |
// Create the SQL query string to get the data.
|
128 |
$query = $wpdb->prepare(
|
132 |
);
|
133 |
|
134 |
// Execute the query.
|
135 |
+
$excluded_results[ $reason ][ $i ] = $wpdb->get_var( $query );
|
136 |
|
137 |
// If we're returned an error or a FALSE value, then let's make sure it's set to a numerical 0.
|
138 |
if ( $excluded_results[ $reason ][ $i ] < 1 ) {
|
140 |
}
|
141 |
|
142 |
// Make sure to initialize the results so we don't get warnings when WP_DEBUG is enabled.
|
143 |
+
if ( ! array_key_exists( $i, $excluded_results['Total'] ) ) {
|
144 |
$excluded_results['Total'][ $i ] = 0;
|
145 |
}
|
146 |
|
147 |
// We're totalling things up here for use later.
|
148 |
$excluded_results['Total'][ $i ] += $excluded_results[ $reason ][ $i ];
|
149 |
+
$excluded_total += $excluded_results[ $reason ][ $i ];
|
150 |
}
|
151 |
}
|
152 |
|
153 |
+
$excuded_all_time = $wpdb->get_var( "SELECT SUM(count) FROM {$wpdb->prefix}statistics_exclusions" );
|
154 |
|
155 |
// If the chart totals is enabled, cheat a little and just add another reason category to the list so it gets generated later.
|
156 |
if ( $total_stats == 1 ) {
|
157 |
$excluded_reasons[] = 'Total';
|
158 |
}
|
159 |
|
160 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
161 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
162 |
}
|
163 |
|
164 |
$stats = array();
|
165 |
foreach ( $excluded_reasons as $reason ) {
|
166 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
167 |
$stats[ $reason ][] = $excluded_results[ $reason ][ $i ];
|
168 |
}
|
169 |
}
|
170 |
?>
|
171 |
<div class="wrap">
|
172 |
+
<h2><?php _e( 'Exclusions Statistics', 'wp-statistics' ); ?></h2>
|
173 |
+
<?php wp_statistics_date_range_selector( WP_Statistics::$page['exclusions'], $daysToDisplay ); ?>
|
174 |
+
<div class="postbox-container" id="last-log">
|
175 |
+
<div class="metabox-holder">
|
176 |
+
<div class="meta-box-sortables">
|
177 |
+
<div class="postbox">
|
178 |
+
<?php $paneltitle = __( 'Exclusions Statistical Chart', 'wp-statistics' ); ?>
|
179 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
180 |
<span class="screen-reader-text"><?php printf(
|
181 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
182 |
$paneltitle
|
183 |
); ?></span>
|
184 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
185 |
+
</button>
|
186 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
187 |
|
188 |
+
<div class="inside">
|
189 |
+
<div class="inside">
|
190 |
+
<canvas id="hit-stats" height="80"></canvas>
|
191 |
+
<script type='text/javascript'
|
192 |
+
src='<?php echo WP_Statistics::$reg['plugin-url']; ?>assets/js/Chart.bundle.min.js'></script>
|
193 |
+
<script>
|
194 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
195 |
+
var ChartJs = new Chart(ctx, {
|
196 |
+
type: 'line',
|
197 |
+
data: {
|
198 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
199 |
+
datasets: [
|
200 |
<?php foreach ($stats as $key => $value) : $i ++; ?>
|
201 |
+
{
|
202 |
+
label: '<?php echo $key; ?>',
|
203 |
+
data: [<?php echo implode( ',', $value ); ?>],
|
204 |
+
backgroundColor: <?php echo wp_statistics_generate_rgba_color( $i, '0.2' ); ?>,
|
205 |
+
borderColor: <?php echo wp_statistics_generate_rgba_color( $i, '1' ); ?>,
|
206 |
+
borderWidth: 1,
|
207 |
+
fill: true,
|
208 |
+
},
|
209 |
<?php endforeach; ?>
|
210 |
+
]
|
211 |
+
},
|
212 |
+
options: {
|
213 |
+
responsive: true,
|
214 |
+
legend: {
|
215 |
+
position: 'bottom',
|
216 |
+
},
|
217 |
+
title: {
|
218 |
+
display: true,
|
219 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
220 |
+
},
|
221 |
+
tooltips: {
|
222 |
+
mode: 'index',
|
223 |
+
intersect: false,
|
224 |
+
},
|
225 |
+
scales: {
|
226 |
+
yAxes: [{
|
227 |
+
ticks: {
|
228 |
+
beginAtZero: true
|
229 |
+
}
|
230 |
+
}]
|
231 |
+
}
|
232 |
+
}
|
233 |
+
});
|
234 |
+
</script>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
</div>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
|
242 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
243 |
+
<div class="metabox-holder">
|
244 |
+
<div class="meta-box-sortables">
|
245 |
+
<div class="postbox">
|
246 |
+
<?php $paneltitle = __( 'Hits Statistics Summary', 'wp-statistics' ); ?>
|
247 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
248 |
<span class="screen-reader-text"><?php printf(
|
249 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
250 |
$paneltitle
|
251 |
); ?></span>
|
252 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
253 |
+
</button>
|
254 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
255 |
|
256 |
+
<div class="inside">
|
257 |
+
<table width="auto" class="widefat table-stats" id="summary-stats">
|
258 |
+
<tbody>
|
259 |
+
<tr>
|
260 |
+
<th></th>
|
261 |
+
<th class="th-center"><?php _e( 'Exclusions', 'wp-statistics' ); ?></th>
|
262 |
+
</tr>
|
263 |
|
264 |
+
<tr>
|
265 |
+
<th><?php _e( 'Chart Total', 'wp-statistics' ); ?>:</th>
|
266 |
+
<th class="th-center"><span><?php echo number_format_i18n( $excluded_total ); ?></span>
|
267 |
+
</th>
|
268 |
+
</tr>
|
269 |
|
270 |
+
<tr>
|
271 |
+
<th><?php _e( 'All Time Total', 'wp-statistics' ); ?>:</th>
|
272 |
+
<th class="th-center">
|
273 |
+
<span><?php echo number_format_i18n( $excuded_all_time ); ?></span>
|
274 |
+
</th>
|
275 |
+
</tr>
|
276 |
+
</tbody>
|
277 |
+
</table>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
</div>
|
282 |
+
</div>
|
283 |
</div>
|
includes/log/hit-statistics.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<div class="wrap">
|
7 |
-
|
8 |
<?php
|
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 = '';
|
@@ -28,152 +28,152 @@
|
|
28 |
$rangeend
|
29 |
);
|
30 |
|
31 |
-
wp_statistics_date_range_selector(WP_Statistics::$page['hits'], $daysToDisplay);
|
32 |
|
33 |
-
$visit_total
|
34 |
$visitor_total = 0;
|
35 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
36 |
-
$visitors
|
37 |
-
$visits
|
38 |
|
39 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
40 |
-
$stat
|
41 |
$visit_total += $stat;
|
42 |
-
$visits[]
|
43 |
}
|
44 |
|
45 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
46 |
-
$stat
|
47 |
$visitor_total += $stat;
|
48 |
-
$visitors[]
|
49 |
}
|
50 |
|
51 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
52 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
53 |
}
|
54 |
?>
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
<?php $paneltitle = __('Hits Statistics Chart', 'wp-statistics'); ?>
|
60 |
-
|
61 |
<span class="screen-reader-text"><?php printf(
|
62 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
63 |
$paneltitle
|
64 |
); ?></span>
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
<?php } ?>
|
88 |
<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?>
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
<?php } ?>
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
<?php $paneltitle = __('Hits Statistics Summary', 'wp-statistics'); ?>
|
134 |
-
|
135 |
<span class="screen-reader-text"><?php printf(
|
136 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
137 |
$paneltitle
|
138 |
); ?></span>
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
<span><?php echo number_format_i18n(
|
167 |
-
wp_statistics_visitor('total', null, true)
|
168 |
); ?></span>
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
</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 |
+
<h2><?php _e( 'Hit Statistics', 'wp-statistics' ); ?></h2>
|
8 |
<?php
|
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 = '';
|
28 |
$rangeend
|
29 |
);
|
30 |
|
31 |
+
wp_statistics_date_range_selector( WP_Statistics::$page['hits'], $daysToDisplay );
|
32 |
|
33 |
+
$visit_total = 0;
|
34 |
$visitor_total = 0;
|
35 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
36 |
+
$visitors = array();
|
37 |
+
$visits = array();
|
38 |
|
39 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
40 |
+
$stat = wp_statistics_visit( '-' . (int) ( $i + $daysInThePast ), true );
|
41 |
$visit_total += $stat;
|
42 |
+
$visits[] = $stat;
|
43 |
}
|
44 |
|
45 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
46 |
+
$stat = wp_statistics_visitor( '-' . (int) ( $i + $daysInThePast ), true );
|
47 |
$visitor_total += $stat;
|
48 |
+
$visitors[] = $stat;
|
49 |
}
|
50 |
|
51 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
52 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
53 |
}
|
54 |
?>
|
55 |
+
<div class="postbox-container" id="last-log">
|
56 |
+
<div class="metabox-holder">
|
57 |
+
<div class="meta-box-sortables">
|
58 |
+
<div class="postbox">
|
59 |
+
<?php $paneltitle = __( 'Hits Statistics Chart', 'wp-statistics' ); ?>
|
60 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
61 |
<span class="screen-reader-text"><?php printf(
|
62 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
63 |
$paneltitle
|
64 |
); ?></span>
|
65 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
66 |
+
</button>
|
67 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
68 |
|
69 |
+
<div class="inside">
|
70 |
+
<canvas id="hit-stats" height="80"></canvas>
|
71 |
+
<script>
|
72 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
73 |
+
var ChartJs = new Chart(ctx, {
|
74 |
+
type: 'line',
|
75 |
+
data: {
|
76 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
77 |
+
datasets: [
|
78 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
79 |
+
{
|
80 |
+
label: '<?php _e( 'Visitors', 'wp-statistics' ); ?>',
|
81 |
+
data: [<?php echo implode( ',', $visitors ); ?>],
|
82 |
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
83 |
+
borderColor: 'rgba(255, 99, 132, 1)',
|
84 |
+
borderWidth: 1,
|
85 |
+
fill: true,
|
86 |
+
},
|
87 |
<?php } ?>
|
88 |
<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?>
|
89 |
+
{
|
90 |
+
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
|
91 |
+
data: [<?php echo implode( ',', $visits ); ?>],
|
92 |
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
93 |
+
borderColor: 'rgba(54, 162, 235, 1)',
|
94 |
+
borderWidth: 1,
|
95 |
+
fill: true,
|
96 |
+
},
|
97 |
<?php } ?>
|
98 |
+
]
|
99 |
+
},
|
100 |
+
options: {
|
101 |
+
responsive: true,
|
102 |
+
legend: {
|
103 |
+
position: 'bottom',
|
104 |
+
},
|
105 |
+
title: {
|
106 |
+
display: true,
|
107 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
108 |
+
},
|
109 |
+
tooltips: {
|
110 |
+
mode: 'index',
|
111 |
+
intersect: false,
|
112 |
+
},
|
113 |
+
scales: {
|
114 |
+
yAxes: [{
|
115 |
+
ticks: {
|
116 |
+
beginAtZero: true
|
117 |
+
}
|
118 |
+
}]
|
119 |
+
}
|
120 |
+
}
|
121 |
+
});
|
122 |
+
</script>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
|
129 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
130 |
+
<div class="metabox-holder">
|
131 |
+
<div class="meta-box-sortables">
|
132 |
+
<div class="postbox">
|
133 |
+
<?php $paneltitle = __( 'Hits Statistics Summary', 'wp-statistics' ); ?>
|
134 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
135 |
<span class="screen-reader-text"><?php printf(
|
136 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
137 |
$paneltitle
|
138 |
); ?></span>
|
139 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
140 |
+
</button>
|
141 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
142 |
|
143 |
+
<div class="inside">
|
144 |
+
<table width="auto" class="widefat table-stats" id="summary-stats">
|
145 |
+
<tbody>
|
146 |
+
<tr>
|
147 |
+
<th></th>
|
148 |
+
<th class="th-center"><?php _e( 'Visits', 'wp-statistics' ); ?></th>
|
149 |
+
<th class="th-center"><?php _e( 'Visitors', 'wp-statistics' ); ?></th>
|
150 |
+
</tr>
|
151 |
|
152 |
+
<tr>
|
153 |
+
<th><?php _e( 'Chart Total', 'wp-statistics' ); ?>:</th>
|
154 |
+
<th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
|
155 |
+
</th>
|
156 |
+
<th class="th-center"><span><?php echo number_format_i18n( $visitor_total ); ?></span>
|
157 |
+
</th>
|
158 |
+
</tr>
|
159 |
|
160 |
+
<tr>
|
161 |
+
<th><?php _e( 'All Time Total', 'wp-statistics' ); ?>:</th>
|
162 |
+
<th class="th-center">
|
163 |
+
<span><?php echo number_format_i18n( wp_statistics_visit( 'total' ) ); ?></span>
|
164 |
+
</th>
|
165 |
+
<th class="th-center">
|
166 |
<span><?php echo number_format_i18n(
|
167 |
+
wp_statistics_visitor( 'total', null, true )
|
168 |
); ?></span>
|
169 |
+
</th>
|
170 |
+
</tr>
|
171 |
+
</tbody>
|
172 |
+
</table>
|
173 |
+
</div>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
|
179 |
</div>
|
includes/log/last-search.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
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 {
|
@@ -25,15 +25,15 @@ if ( array_key_exists('referred', $_GET) ) {
|
|
25 |
$total = $search_result[ $referred ];
|
26 |
?>
|
27 |
<div class="wrap">
|
28 |
-
|
29 |
-
|
30 |
<?php
|
31 |
-
$search_result_count = count($search_result);
|
32 |
$i = 0;
|
33 |
$separator = ' | ';
|
34 |
|
35 |
foreach ( $search_result as $key => $value ) {
|
36 |
-
$i++;
|
37 |
|
38 |
if ( $i == $search_result_count ) {
|
39 |
$separator = '';
|
@@ -42,7 +42,7 @@ $total = $search_result[ $referred ];
|
|
42 |
if ( $key == 'All' ) {
|
43 |
$tag = '';
|
44 |
$name = 'All';
|
45 |
-
$translate = __('All', 'wp-statistics');
|
46 |
} else {
|
47 |
$tag = $search_engines[ $key ]['tag'];
|
48 |
$name = $search_engines[ $key ]['name'];
|
@@ -56,23 +56,23 @@ $total = $search_result[ $referred ];
|
|
56 |
" <span class='count'>({$value})</span></a></li>{$separator}";
|
57 |
}
|
58 |
?>
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
<?php $paneltitle = __('Latest Search Word Statistics', 'wp-statistics'); ?>
|
65 |
-
|
66 |
<span class="screen-reader-text"><?php printf(
|
67 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
68 |
$paneltitle
|
69 |
); ?></span>
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
<?php
|
77 |
if ( $total > 0 ) {
|
78 |
// Instantiate pagination object with appropriate arguments
|
@@ -99,55 +99,55 @@ $total = $search_result[ $referred ];
|
|
99 |
|
100 |
// Retrieve MySQL data
|
101 |
if ( $referred && $referred != '' ) {
|
102 |
-
$search_query = wp_statistics_searchword_query($referred);
|
103 |
} else {
|
104 |
-
$search_query = wp_statistics_searchword_query('all');
|
105 |
}
|
106 |
|
107 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
108 |
$tablename = $wpdb->prefix . 'statistics_';
|
109 |
|
110 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
111 |
-
$tabletwo
|
112 |
$tablename .= 'search';
|
113 |
-
$result
|
114 |
"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}"
|
115 |
);
|
116 |
} else {
|
117 |
$tablename .= 'visitor';
|
118 |
-
$result
|
119 |
"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}"
|
120 |
);
|
121 |
}
|
122 |
|
123 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
124 |
|
125 |
-
$dash_icon = wp_statistics_icons('dashicons-location-alt', 'map');
|
126 |
|
127 |
foreach ( $result as $items ) {
|
128 |
-
if ( ! $WP_Statistics->Search_Engine_QueryString($items->referred) ) {
|
129 |
continue;
|
130 |
}
|
131 |
|
132 |
-
if ( substr($items->ip, 0, 6) == '#hash#' ) {
|
133 |
-
$ip_string = __('#hash#', 'wp-statistics');
|
134 |
$map_string = "";
|
135 |
} else {
|
136 |
$ip_string
|
137 |
= "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
|
138 |
$map_string
|
139 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
140 |
-
__('Map', 'wp-statistics') .
|
141 |
"'>{$dash_icon}</a>";
|
142 |
}
|
143 |
|
144 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
145 |
$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine(
|
146 |
$items->engine
|
147 |
);
|
148 |
$words = $items->words;
|
149 |
} else {
|
150 |
-
$this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
|
151 |
$words = $WP_Statistics->Search_Engine_QueryString(
|
152 |
$items->referred
|
153 |
);
|
@@ -156,13 +156,13 @@ $total = $search_result[ $referred ];
|
|
156 |
echo "<div class='log-item'>";
|
157 |
echo "<div class='log-referred'>" . $words . "</div>";
|
158 |
echo "<div class='log-ip'>" .
|
159 |
-
date(get_option('date_format'), strtotime($items->last_counter)) .
|
160 |
" - {$ip_string}</div>";
|
161 |
echo "<div class='clear'></div>";
|
162 |
echo "<div class='log-url'>";
|
163 |
echo $map_string;
|
164 |
|
165 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
166 |
echo "<img src='" .
|
167 |
plugins_url(
|
168 |
'wp-statistics/assets/images/flags/' . $items->location . '.png'
|
@@ -173,13 +173,13 @@ $total = $search_result[ $referred ];
|
|
173 |
echo "<a href='?page=" .
|
174 |
WP_Statistics::$page['overview'] .
|
175 |
"&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" .
|
176 |
-
plugins_url('wp-statistics/assets/images/' . $this_search_engine['image']) .
|
177 |
"' class='log-tools' title='" .
|
178 |
-
__($this_search_engine['name'], 'wp-statistics') .
|
179 |
"'/></a>";
|
180 |
|
181 |
if ( array_search(
|
182 |
-
strtolower($items->agent),
|
183 |
array(
|
184 |
"chrome",
|
185 |
"firefox",
|
@@ -190,18 +190,18 @@ $total = $search_result[ $referred ];
|
|
190 |
) !== false
|
191 |
) {
|
192 |
$agent = "<img src='" .
|
193 |
-
plugins_url('wp-statistics/assets/images/') .
|
194 |
$items->agent .
|
195 |
".png' class='log-tools' title='{$items->agent}'/>";
|
196 |
} else {
|
197 |
-
$agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
|
198 |
}
|
199 |
|
200 |
echo "<a href='?page=" .
|
201 |
WP_Statistics::$page['overview'] .
|
202 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
203 |
|
204 |
-
echo $WP_Statistics->get_referrer_link($items->referred);
|
205 |
|
206 |
echo "</div>";
|
207 |
echo "</div>";
|
@@ -210,20 +210,20 @@ $total = $search_result[ $referred ];
|
|
210 |
|
211 |
echo "</div>";
|
212 |
?>
|
213 |
-
|
214 |
-
|
215 |
|
216 |
-
|
217 |
<?php if ( $total > 0 ) {
|
218 |
echo $Pagination->display(); ?>
|
219 |
-
|
220 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
221 |
$Pagination->getCurrentPage(),
|
222 |
$Pagination->getTotalPages()
|
223 |
); ?></p>
|
224 |
<?php } ?>
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
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 {
|
25 |
$total = $search_result[ $referred ];
|
26 |
?>
|
27 |
<div class="wrap">
|
28 |
+
<h2><?php _e( 'Latest Search Words', 'wp-statistics' ); ?></h2>
|
29 |
+
<ul class="subsubsub">
|
30 |
<?php
|
31 |
+
$search_result_count = count( $search_result );
|
32 |
$i = 0;
|
33 |
$separator = ' | ';
|
34 |
|
35 |
foreach ( $search_result as $key => $value ) {
|
36 |
+
$i ++;
|
37 |
|
38 |
if ( $i == $search_result_count ) {
|
39 |
$separator = '';
|
42 |
if ( $key == 'All' ) {
|
43 |
$tag = '';
|
44 |
$name = 'All';
|
45 |
+
$translate = __( 'All', 'wp-statistics' );
|
46 |
} else {
|
47 |
$tag = $search_engines[ $key ]['tag'];
|
48 |
$name = $search_engines[ $key ]['name'];
|
56 |
" <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 |
+
<?php $paneltitle = __( 'Latest Search Word Statistics', 'wp-statistics' ); ?>
|
65 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
66 |
<span class="screen-reader-text"><?php printf(
|
67 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
68 |
$paneltitle
|
69 |
); ?></span>
|
70 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
71 |
+
</button>
|
72 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
73 |
|
74 |
+
<div class="inside">
|
75 |
+
<div class='log-latest'>
|
76 |
<?php
|
77 |
if ( $total > 0 ) {
|
78 |
// Instantiate pagination object with appropriate arguments
|
99 |
|
100 |
// Retrieve MySQL data
|
101 |
if ( $referred && $referred != '' ) {
|
102 |
+
$search_query = wp_statistics_searchword_query( $referred );
|
103 |
} else {
|
104 |
+
$search_query = wp_statistics_searchword_query( 'all' );
|
105 |
}
|
106 |
|
107 |
// Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
|
108 |
$tablename = $wpdb->prefix . 'statistics_';
|
109 |
|
110 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
111 |
+
$tabletwo = $tablename . 'visitor';
|
112 |
$tablename .= 'search';
|
113 |
+
$result = $wpdb->get_results(
|
114 |
"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}"
|
115 |
);
|
116 |
} else {
|
117 |
$tablename .= 'visitor';
|
118 |
+
$result = $wpdb->get_results(
|
119 |
"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT {$start}, {$end}"
|
120 |
);
|
121 |
}
|
122 |
|
123 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
124 |
|
125 |
+
$dash_icon = wp_statistics_icons( 'dashicons-location-alt', 'map' );
|
126 |
|
127 |
foreach ( $result as $items ) {
|
128 |
+
if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) {
|
129 |
continue;
|
130 |
}
|
131 |
|
132 |
+
if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
|
133 |
+
$ip_string = __( '#hash#', 'wp-statistics' );
|
134 |
$map_string = "";
|
135 |
} else {
|
136 |
$ip_string
|
137 |
= "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
|
138 |
$map_string
|
139 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
140 |
+
__( 'Map', 'wp-statistics' ) .
|
141 |
"'>{$dash_icon}</a>";
|
142 |
}
|
143 |
|
144 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
145 |
$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine(
|
146 |
$items->engine
|
147 |
);
|
148 |
$words = $items->words;
|
149 |
} else {
|
150 |
+
$this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
|
151 |
$words = $WP_Statistics->Search_Engine_QueryString(
|
152 |
$items->referred
|
153 |
);
|
156 |
echo "<div class='log-item'>";
|
157 |
echo "<div class='log-referred'>" . $words . "</div>";
|
158 |
echo "<div class='log-ip'>" .
|
159 |
+
date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) .
|
160 |
" - {$ip_string}</div>";
|
161 |
echo "<div class='clear'></div>";
|
162 |
echo "<div class='log-url'>";
|
163 |
echo $map_string;
|
164 |
|
165 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
166 |
echo "<img src='" .
|
167 |
plugins_url(
|
168 |
'wp-statistics/assets/images/flags/' . $items->location . '.png'
|
173 |
echo "<a href='?page=" .
|
174 |
WP_Statistics::$page['overview'] .
|
175 |
"&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" .
|
176 |
+
plugins_url( 'wp-statistics/assets/images/' . $this_search_engine['image'] ) .
|
177 |
"' class='log-tools' title='" .
|
178 |
+
__( $this_search_engine['name'], 'wp-statistics' ) .
|
179 |
"'/></a>";
|
180 |
|
181 |
if ( array_search(
|
182 |
+
strtolower( $items->agent ),
|
183 |
array(
|
184 |
"chrome",
|
185 |
"firefox",
|
190 |
) !== false
|
191 |
) {
|
192 |
$agent = "<img src='" .
|
193 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
194 |
$items->agent .
|
195 |
".png' class='log-tools' title='{$items->agent}'/>";
|
196 |
} else {
|
197 |
+
$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
|
198 |
}
|
199 |
|
200 |
echo "<a href='?page=" .
|
201 |
WP_Statistics::$page['overview'] .
|
202 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
203 |
|
204 |
+
echo $WP_Statistics->get_referrer_link( $items->referred );
|
205 |
|
206 |
echo "</div>";
|
207 |
echo "</div>";
|
210 |
|
211 |
echo "</div>";
|
212 |
?>
|
213 |
+
</div>
|
214 |
+
</div>
|
215 |
|
216 |
+
<div class="pagination-log">
|
217 |
<?php if ( $total > 0 ) {
|
218 |
echo $Pagination->display(); ?>
|
219 |
+
<p id="result-log"><?php printf(
|
220 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
221 |
$Pagination->getCurrentPage(),
|
222 |
$Pagination->getTotalPages()
|
223 |
); ?></p>
|
224 |
<?php } ?>
|
225 |
+
</div>
|
226 |
+
</div>
|
227 |
+
</div>
|
228 |
+
</div>
|
229 |
+
</div>
|
includes/log/last-visitor.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<?php
|
7 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
@@ -10,24 +10,24 @@ $_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 |
-
$_get = esc_attr($_get);
|
26 |
-
$total_visitor = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor`");
|
27 |
|
28 |
if ( $_get != '%' ) {
|
29 |
$total = $wpdb->get_var(
|
30 |
-
$wpdb->prepare("SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get)
|
31 |
);
|
32 |
} else {
|
33 |
$total = $total_visitor;
|
@@ -35,12 +35,12 @@ if ( $_get != '%' ) {
|
|
35 |
|
36 |
?>
|
37 |
<div class="wrap">
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
echo 'class="current"';
|
42 |
-
} ?>href="?page=<?php echo WP_Statistics::$page['visitors']; ?>"><?php _e('All', 'wp-statistics'); ?>
|
43 |
-
|
44 |
<?php
|
45 |
if ( isset( $_var ) ) {
|
46 |
$spacer = " | ";
|
@@ -48,14 +48,14 @@ if ( $_get != '%' ) {
|
|
48 |
if ( $_var == 'agent' ) {
|
49 |
$Browsers = wp_statistics_ua_list();
|
50 |
$i = 0;
|
51 |
-
$Total = count($Browsers);
|
52 |
|
53 |
foreach ( $Browsers as $Browser ) {
|
54 |
if ( $Browser == null ) {
|
55 |
continue;
|
56 |
}
|
57 |
|
58 |
-
$i++;
|
59 |
if ( $title == $Browser ) {
|
60 |
$current = 'class="current" ';
|
61 |
} else {
|
@@ -72,9 +72,9 @@ if ( $_get != '%' ) {
|
|
72 |
"&agent=" .
|
73 |
$Browser .
|
74 |
"'> " .
|
75 |
-
__($Browser, 'wp-statistics') .
|
76 |
" <span class='count'>(" .
|
77 |
-
number_format_i18n(wp_statistics_useragent($Browser)) .
|
78 |
")</span></a></li>";
|
79 |
}
|
80 |
} else {
|
@@ -90,25 +90,25 @@ if ( $_get != '%' ) {
|
|
90 |
}
|
91 |
}
|
92 |
?>
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
<?php $paneltitle = __('Recent Visitor Statistics', 'wp-statistics');
|
99 |
if ( $_get != '%' ) {
|
100 |
-
$paneltitle = $paneltitle . ' [' . __('Filtered by', 'wp-statistics') . ': ' . $title . ']';
|
101 |
} ?>
|
102 |
-
|
103 |
<span class="screen-reader-text"><?php printf(
|
104 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
105 |
$paneltitle
|
106 |
); ?></span>
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
|
111 |
-
|
112 |
<?php
|
113 |
// Instantiate pagination object with appropriate arguments
|
114 |
$pagesPerSection = 10;
|
@@ -147,15 +147,15 @@ if ( $_get != '%' ) {
|
|
147 |
}
|
148 |
|
149 |
// Check to see if User Agent logging is enabled.
|
150 |
-
$DisplayUA = $WP_Statistics->get_option("store_ua");
|
151 |
|
152 |
echo "<div class='log-latest'>";
|
153 |
|
154 |
-
$dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
|
155 |
|
156 |
foreach ( $result as $items ) {
|
157 |
-
if ( substr($items->ip, 0, 6) == '#hash#' ) {
|
158 |
-
$ip_string = __('#hash#', 'wp-statistics');
|
159 |
$map_string = "";
|
160 |
} else {
|
161 |
$ip_string = "<a href='?page=" .
|
@@ -163,29 +163,29 @@ if ( $_get != '%' ) {
|
|
163 |
"&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
164 |
$map_string
|
165 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
166 |
-
__('Map', 'wp-statistics') .
|
167 |
"'>" .
|
168 |
-
wp_statistics_icons('dashicons-location-alt', 'map') .
|
169 |
"</a>";
|
170 |
}
|
171 |
|
172 |
echo "<div class='log-item'>";
|
173 |
echo "<div class='log-referred'>{$ip_string}</div>";
|
174 |
echo "<div class='log-ip'>" .
|
175 |
-
date(get_option('date_format'), strtotime($items->last_counter)) .
|
176 |
"</div>";
|
177 |
echo "<div class='clear'></div>";
|
178 |
echo "<div class='log-url'>";
|
179 |
echo $map_string;
|
180 |
|
181 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
182 |
echo "<img src='" .
|
183 |
-
plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') .
|
184 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
185 |
}
|
186 |
|
187 |
if ( array_search(
|
188 |
-
strtolower($items->agent),
|
189 |
array(
|
190 |
"chrome",
|
191 |
"firefox",
|
@@ -196,18 +196,18 @@ if ( $_get != '%' ) {
|
|
196 |
) !== false
|
197 |
) {
|
198 |
$agent = "<img src='" .
|
199 |
-
plugins_url('wp-statistics/assets/images/') .
|
200 |
$items->agent .
|
201 |
".png' class='log-tools' title='{$items->agent}'/>";
|
202 |
} else {
|
203 |
-
$agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
|
204 |
}
|
205 |
|
206 |
echo "<a href='?page=" .
|
207 |
WP_Statistics::$page['visitors'] .
|
208 |
"&agent={$items->agent}'>{$agent}</a>";
|
209 |
|
210 |
-
echo $WP_Statistics->get_referrer_link($items->referred);
|
211 |
|
212 |
echo "</div>";
|
213 |
echo "</div>";
|
@@ -215,18 +215,18 @@ if ( $_get != '%' ) {
|
|
215 |
|
216 |
echo "</div>";
|
217 |
?>
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
<?php echo $Pagination->display(); ?>
|
223 |
-
|
224 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
225 |
$Pagination->getCurrentPage(),
|
226 |
$Pagination->getTotalPages()
|
227 |
); ?></p>
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
</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();
|
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 |
+
$_get = esc_attr( $_get );
|
26 |
+
$total_visitor = $wpdb->get_var( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor`" );
|
27 |
|
28 |
if ( $_get != '%' ) {
|
29 |
$total = $wpdb->get_var(
|
30 |
+
$wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get )
|
31 |
);
|
32 |
} else {
|
33 |
$total = $total_visitor;
|
35 |
|
36 |
?>
|
37 |
<div class="wrap">
|
38 |
+
<h2><?php _e( 'Recent Visitors', 'wp-statistics' ); ?></h2>
|
39 |
+
<ul class="subsubsub">
|
40 |
+
<li class="all"><a <?php if ( $_get == '%' ) {
|
41 |
echo 'class="current"';
|
42 |
+
} ?>href="?page=<?php echo WP_Statistics::$page['visitors']; ?>"><?php _e( 'All', 'wp-statistics' ); ?>
|
43 |
+
<span class="count">(<?php echo $total_visitor; ?>)</span></a></li>
|
44 |
<?php
|
45 |
if ( isset( $_var ) ) {
|
46 |
$spacer = " | ";
|
48 |
if ( $_var == 'agent' ) {
|
49 |
$Browsers = wp_statistics_ua_list();
|
50 |
$i = 0;
|
51 |
+
$Total = count( $Browsers );
|
52 |
|
53 |
foreach ( $Browsers as $Browser ) {
|
54 |
if ( $Browser == null ) {
|
55 |
continue;
|
56 |
}
|
57 |
|
58 |
+
$i ++;
|
59 |
if ( $title == $Browser ) {
|
60 |
$current = 'class="current" ';
|
61 |
} else {
|
72 |
"&agent=" .
|
73 |
$Browser .
|
74 |
"'> " .
|
75 |
+
__( $Browser, 'wp-statistics' ) .
|
76 |
" <span class='count'>(" .
|
77 |
+
number_format_i18n( wp_statistics_useragent( $Browser ) ) .
|
78 |
")</span></a></li>";
|
79 |
}
|
80 |
} else {
|
90 |
}
|
91 |
}
|
92 |
?>
|
93 |
+
</ul>
|
94 |
+
<div class="postbox-container" id="last-log">
|
95 |
+
<div class="metabox-holder">
|
96 |
+
<div class="meta-box-sortables">
|
97 |
+
<div class="postbox">
|
98 |
+
<?php $paneltitle = __( 'Recent Visitor Statistics', 'wp-statistics' );
|
99 |
if ( $_get != '%' ) {
|
100 |
+
$paneltitle = $paneltitle . ' [' . __( 'Filtered by', 'wp-statistics' ) . ': ' . $title . ']';
|
101 |
} ?>
|
102 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
103 |
<span class="screen-reader-text"><?php printf(
|
104 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
105 |
$paneltitle
|
106 |
); ?></span>
|
107 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
108 |
+
</button>
|
109 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
110 |
|
111 |
+
<div class="inside">
|
112 |
<?php
|
113 |
// Instantiate pagination object with appropriate arguments
|
114 |
$pagesPerSection = 10;
|
147 |
}
|
148 |
|
149 |
// Check to see if User Agent logging is enabled.
|
150 |
+
$DisplayUA = $WP_Statistics->get_option( "store_ua" );
|
151 |
|
152 |
echo "<div class='log-latest'>";
|
153 |
|
154 |
+
$dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
|
155 |
|
156 |
foreach ( $result as $items ) {
|
157 |
+
if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
|
158 |
+
$ip_string = __( '#hash#', 'wp-statistics' );
|
159 |
$map_string = "";
|
160 |
} else {
|
161 |
$ip_string = "<a href='?page=" .
|
163 |
"&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
164 |
$map_string
|
165 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
166 |
+
__( 'Map', 'wp-statistics' ) .
|
167 |
"'>" .
|
168 |
+
wp_statistics_icons( 'dashicons-location-alt', 'map' ) .
|
169 |
"</a>";
|
170 |
}
|
171 |
|
172 |
echo "<div class='log-item'>";
|
173 |
echo "<div class='log-referred'>{$ip_string}</div>";
|
174 |
echo "<div class='log-ip'>" .
|
175 |
+
date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) .
|
176 |
"</div>";
|
177 |
echo "<div class='clear'></div>";
|
178 |
echo "<div class='log-url'>";
|
179 |
echo $map_string;
|
180 |
|
181 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
182 |
echo "<img src='" .
|
183 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) .
|
184 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
185 |
}
|
186 |
|
187 |
if ( array_search(
|
188 |
+
strtolower( $items->agent ),
|
189 |
array(
|
190 |
"chrome",
|
191 |
"firefox",
|
196 |
) !== false
|
197 |
) {
|
198 |
$agent = "<img src='" .
|
199 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
200 |
$items->agent .
|
201 |
".png' class='log-tools' title='{$items->agent}'/>";
|
202 |
} else {
|
203 |
+
$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
|
204 |
}
|
205 |
|
206 |
echo "<a href='?page=" .
|
207 |
WP_Statistics::$page['visitors'] .
|
208 |
"&agent={$items->agent}'>{$agent}</a>";
|
209 |
|
210 |
+
echo $WP_Statistics->get_referrer_link( $items->referred );
|
211 |
|
212 |
echo "</div>";
|
213 |
echo "</div>";
|
215 |
|
216 |
echo "</div>";
|
217 |
?>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
|
221 |
+
<div class="pagination-log">
|
222 |
<?php echo $Pagination->display(); ?>
|
223 |
+
<p id="result-log"><?php printf(
|
224 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
225 |
$Pagination->getCurrentPage(),
|
226 |
$Pagination->getTotalPages()
|
227 |
); ?></p>
|
228 |
+
</div>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
</div>
|
232 |
</div>
|
includes/log/log.php
CHANGED
@@ -1,43 +1,44 @@
|
|
1 |
<?php
|
2 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
3 |
-
plugins_url('wp-statistics/assets/images/') .
|
4 |
'ajax-loading.gif" alt="' .
|
5 |
-
__('Reloading...', 'wp-statistics') .
|
6 |
'"></div>';
|
7 |
|
8 |
$nag_html = '';
|
9 |
-
if ( ! $WP_Statistics->get_option('geoip') ) {
|
10 |
-
$nag_html .=
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
}
|
19 |
|
20 |
-
if ( ! $WP_Statistics->get_option('disable_donation_nag', false) ) {
|
21 |
$nag_html .= '<div id="wps_nag" class="update-nag" style="width: 90%;"><div id="donate-text">' .
|
22 |
-
__('Have you thought about donating to WP Statistics?', 'wp-statistics') .
|
23 |
' <a href="http://wp-statistics.com/donate/" target="_blank">' .
|
24 |
-
__('Donate Now!', 'wp-statistics') .
|
25 |
'</a></div><div id="donate-button"><a class="button-primary" id="wps_close_nag">' .
|
26 |
-
__('Close', 'wp-statistics') .
|
27 |
'</a></div></div>';
|
28 |
}
|
29 |
|
30 |
// 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.
|
31 |
-
$widget_order = get_user_meta($WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page', true);
|
32 |
|
33 |
-
if ( is_array($widget_order) && count($widget_order) > 2 ) {
|
34 |
-
delete_user_meta($WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page');
|
35 |
}
|
36 |
|
37 |
// Add the about box here as metaboxes added on the actual page load cannot be closed.
|
38 |
add_meta_box(
|
39 |
'wps_about_postbox',
|
40 |
-
sprintf(__('About WP Statistics Version %s', 'wp-statistics'), WP_Statistics::$reg['version']),
|
41 |
'wp_statistics_generate_overview_postbox_contents',
|
42 |
$WP_Statistics->menu_slugs['overview'],
|
43 |
'side',
|
@@ -47,48 +48,48 @@ add_meta_box(
|
|
47 |
|
48 |
function wp_statistics_generate_overview_postbox_contents( $post, $args ) {
|
49 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
50 |
-
plugins_url('wp-statistics/assets/images/') .
|
51 |
'ajax-loading.gif" alt="' .
|
52 |
-
__('Loading...', 'wp-statistics') .
|
53 |
'"></div>';
|
54 |
$widget = $args['args']['widget'];
|
55 |
-
$container_id = str_replace('.', '_', $widget . '_postbox');
|
56 |
|
57 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
58 |
-
wp_statistics_generate_widget_load_javascript($widget, $container_id);
|
59 |
}
|
60 |
|
61 |
?>
|
62 |
<div class="wrap">
|
63 |
<?php echo $nag_html; ?>
|
64 |
-
|
65 |
-
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
|
66 |
-
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
<?php do_meta_boxes($WP_Statistics->menu_slugs['overview'], 'side', ''); ?>
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
<?php do_meta_boxes($WP_Statistics->menu_slugs['overview'], 'normal', ''); ?>
|
75 |
-
|
76 |
-
|
77 |
</div>
|
78 |
<?php
|
79 |
$new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
80 |
-
wp_statistics_icons('dashicons-update') .
|
81 |
'<span class="screen-reader-text">' .
|
82 |
-
__('Reload', 'wp-statistics') .
|
83 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
84 |
-
wp_statistics_icons('dashicons-migrate') .
|
85 |
'<span class="screen-reader-text">' .
|
86 |
-
__('More Details', 'wp-statistics') .
|
87 |
'</span></button>';
|
88 |
$new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
89 |
-
wp_statistics_icons('dashicons-update') .
|
90 |
'<span class="screen-reader-text">' .
|
91 |
-
__('Reload', 'wp-statistics') .
|
92 |
'</span></button>';
|
93 |
|
94 |
$admin_url = get_admin_url() . "admin.php?page=";
|
@@ -110,60 +111,60 @@ $page_urls['wps_recent_more_button'] = $admin_url . WP_Statistics::$pa
|
|
110 |
|
111 |
?>
|
112 |
<script type="text/javascript">
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
</script>
|
1 |
<?php
|
2 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
3 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
4 |
'ajax-loading.gif" alt="' .
|
5 |
+
__( 'Reloading...', 'wp-statistics' ) .
|
6 |
'"></div>';
|
7 |
|
8 |
$nag_html = '';
|
9 |
+
if ( ! $WP_Statistics->get_option( 'geoip' ) ) {
|
10 |
+
$nag_html .= '<div class="update-nag" style="width: 90%;">' .
|
11 |
+
sprintf(
|
12 |
+
__(
|
13 |
+
'GeoIP collection is not enabled. Please go to <a href="%s">setting page</a> to enable GeoIP for getting more information and location (country) from the visitor.',
|
14 |
+
'wp-statistics'
|
15 |
+
),
|
16 |
+
admin_url( 'admin.php?page=wps_settings_page&tab=externals-settings' )
|
17 |
+
) .
|
18 |
+
'</div>';
|
19 |
}
|
20 |
|
21 |
+
if ( ! $WP_Statistics->get_option( 'disable_donation_nag', false ) ) {
|
22 |
$nag_html .= '<div id="wps_nag" class="update-nag" style="width: 90%;"><div id="donate-text">' .
|
23 |
+
__( 'Have you thought about donating to WP Statistics?', 'wp-statistics' ) .
|
24 |
' <a href="http://wp-statistics.com/donate/" target="_blank">' .
|
25 |
+
__( 'Donate Now!', 'wp-statistics' ) .
|
26 |
'</a></div><div id="donate-button"><a class="button-primary" id="wps_close_nag">' .
|
27 |
+
__( 'Close', 'wp-statistics' ) .
|
28 |
'</a></div></div>';
|
29 |
}
|
30 |
|
31 |
// 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.
|
32 |
+
$widget_order = get_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page', true );
|
33 |
|
34 |
+
if ( is_array( $widget_order ) && count( $widget_order ) > 2 ) {
|
35 |
+
delete_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page' );
|
36 |
}
|
37 |
|
38 |
// Add the about box here as metaboxes added on the actual page load cannot be closed.
|
39 |
add_meta_box(
|
40 |
'wps_about_postbox',
|
41 |
+
sprintf( __( 'About WP Statistics Version %s', 'wp-statistics' ), WP_Statistics::$reg['version'] ),
|
42 |
'wp_statistics_generate_overview_postbox_contents',
|
43 |
$WP_Statistics->menu_slugs['overview'],
|
44 |
'side',
|
48 |
|
49 |
function wp_statistics_generate_overview_postbox_contents( $post, $args ) {
|
50 |
$loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
|
51 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
52 |
'ajax-loading.gif" alt="' .
|
53 |
+
__( 'Loading...', 'wp-statistics' ) .
|
54 |
'"></div>';
|
55 |
$widget = $args['args']['widget'];
|
56 |
+
$container_id = str_replace( '.', '_', $widget . '_postbox' );
|
57 |
|
58 |
echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
|
59 |
+
wp_statistics_generate_widget_load_javascript( $widget, $container_id );
|
60 |
}
|
61 |
|
62 |
?>
|
63 |
<div class="wrap">
|
64 |
<?php echo $nag_html; ?>
|
65 |
+
<h2><?php echo get_admin_page_title(); ?></h2>
|
66 |
+
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
67 |
+
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
|
68 |
+
|
69 |
+
<div class="metabox-holder" id="overview-widgets">
|
70 |
+
<div class="postbox-container" id="wps-postbox-container-1">
|
71 |
+
<?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'side', '' ); ?>
|
72 |
+
</div>
|
73 |
+
|
74 |
+
<div class="postbox-container" id="wps-postbox-container-2">
|
75 |
+
<?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'normal', '' ); ?>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
</div>
|
79 |
<?php
|
80 |
$new_buttons = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
81 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
82 |
'<span class="screen-reader-text">' .
|
83 |
+
__( 'Reload', 'wp-statistics' ) .
|
84 |
'</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
|
85 |
+
wp_statistics_icons( 'dashicons-migrate' ) .
|
86 |
'<span class="screen-reader-text">' .
|
87 |
+
__( 'More Details', 'wp-statistics' ) .
|
88 |
'</span></button>';
|
89 |
$new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
|
90 |
+
wp_statistics_icons( 'dashicons-update' ) .
|
91 |
'<span class="screen-reader-text">' .
|
92 |
+
__( 'Reload', 'wp-statistics' ) .
|
93 |
'</span></button>';
|
94 |
|
95 |
$admin_url = get_admin_url() . "admin.php?page=";
|
111 |
|
112 |
?>
|
113 |
<script type="text/javascript">
|
114 |
+
var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>;
|
115 |
+
var wp_statistics_loading_image = '<?php echo $loading_img; ?>'
|
116 |
+
|
117 |
+
jQuery(document).ready(function () {
|
118 |
+
|
119 |
+
// Add the "more" and "refresh" buttons.
|
120 |
+
jQuery('.postbox').each(function () {
|
121 |
+
var temp = jQuery(this);
|
122 |
+
var temp_id = temp.attr('id');
|
123 |
+
var temp_html = temp.html();
|
124 |
+
if (temp_id == 'wps_summary_postbox' || temp_id == 'wps_map_postbox' || temp_id == 'wps_about_postbox') {
|
125 |
+
if (temp_id != 'wps_about_postbox') {
|
126 |
+
new_text = '<?php echo $new_button;?>';
|
127 |
+
new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button'));
|
128 |
+
|
129 |
+
temp_html = temp_html.replace('</button>', new_text);
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
new_text = '<?php echo $new_buttons;?>';
|
133 |
+
new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button'));
|
134 |
+
new_text = new_text.replace('{{moreid}}', temp_id.replace('_postbox', '_more_button'));
|
135 |
+
|
136 |
+
temp_html = temp_html.replace('</button>', new_text);
|
137 |
+
}
|
138 |
+
|
139 |
+
temp.html(temp_html);
|
140 |
+
});
|
141 |
+
|
142 |
+
// close postboxes that should be closed
|
143 |
+
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
144 |
+
|
145 |
+
// postboxes setup
|
146 |
+
postboxes.add_postbox_toggles('<?php echo $WP_Statistics->menu_slugs['overview']; ?>');
|
147 |
+
|
148 |
+
jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
|
149 |
+
jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
|
150 |
+
|
151 |
+
jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
|
152 |
+
|
153 |
+
jQuery('#wps_close_nag').click(function () {
|
154 |
+
var data = {
|
155 |
+
'action': 'wp_statistics_close_donation_nag',
|
156 |
+
'query': '',
|
157 |
+
};
|
158 |
+
|
159 |
+
jQuery.ajax({
|
160 |
+
url: ajaxurl,
|
161 |
+
type: 'get',
|
162 |
+
data: data,
|
163 |
+
datatype: 'json',
|
164 |
+
});
|
165 |
+
|
166 |
+
jQuery('#wps_nag').hide();
|
167 |
+
});
|
168 |
+
|
169 |
+
});
|
170 |
</script>
|
includes/log/online.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<?php
|
7 |
|
8 |
?>
|
9 |
<div class="wrap">
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
<?php $paneltitle = __('Online Users', 'wp-statistics'); ?>
|
18 |
-
|
19 |
<span class="screen-reader-text"><?php printf(
|
20 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
21 |
$paneltitle
|
22 |
); ?></span>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
<?php
|
29 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
30 |
|
31 |
-
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}statistics_useronline;");
|
32 |
-
$total = count($result);
|
33 |
|
34 |
if ( $total > 0 ) {
|
35 |
// Instantiate pagination object with appropriate arguments
|
@@ -57,14 +57,14 @@
|
|
57 |
echo "<div class='log-latest'>";
|
58 |
$count = 0;
|
59 |
|
60 |
-
$dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
|
61 |
|
62 |
foreach ( $result as $items ) {
|
63 |
-
$count++;
|
64 |
|
65 |
if ( $count >= $start ) {
|
66 |
-
if ( substr($items->ip, 0, 6) == '#hash#' ) {
|
67 |
-
$ip_string = __('#hash#', 'wp-statistics');
|
68 |
$map_string = "";
|
69 |
} else {
|
70 |
$ip_string = "<a href='?page=" .
|
@@ -72,9 +72,9 @@
|
|
72 |
"&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
73 |
$map_string
|
74 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
75 |
-
__('Map', 'wp-statistics') .
|
76 |
"'>" .
|
77 |
-
wp_statistics_icons('dashicons-location-alt', 'map') .
|
78 |
"</a>";
|
79 |
}
|
80 |
|
@@ -82,7 +82,7 @@
|
|
82 |
echo "<div class='log-url'>";
|
83 |
echo $map_string;
|
84 |
|
85 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
86 |
echo "<img src='" .
|
87 |
plugins_url(
|
88 |
'wp-statistics/assets/images/flags/' . $items->location . '.png'
|
@@ -91,7 +91,7 @@
|
|
91 |
}
|
92 |
|
93 |
if ( array_search(
|
94 |
-
strtolower($items->agent),
|
95 |
array(
|
96 |
"chrome",
|
97 |
"firefox",
|
@@ -102,11 +102,11 @@
|
|
102 |
) !== false
|
103 |
) {
|
104 |
$agent = "<img src='" .
|
105 |
-
plugins_url('wp-statistics/assets/images/') .
|
106 |
$items->agent .
|
107 |
".png' class='log-tools' title='{$items->agent}'/>";
|
108 |
} else {
|
109 |
-
$agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
|
110 |
}
|
111 |
|
112 |
echo "<a href='?page=" .
|
@@ -117,14 +117,14 @@
|
|
117 |
$timediff = ( $items->timestamp - $items->created );
|
118 |
|
119 |
if ( $timediff > 3600 ) {
|
120 |
-
$onlinefor = date("H:i:s", ( $items->timestamp - $items->created ));
|
121 |
} else if ( $timediff > 60 ) {
|
122 |
-
$onlinefor = "00:" . date("i:s", ( $items->timestamp - $items->created ));
|
123 |
} else {
|
124 |
-
$onlinefor = "00:00:" . date("s", ( $items->timestamp - $items->created ));
|
125 |
}
|
126 |
|
127 |
-
echo sprintf(__('Online for %s (HH:MM:SS)', 'wp-statistics'), $onlinefor);
|
128 |
|
129 |
echo "</div>";
|
130 |
echo "</div>";
|
@@ -139,24 +139,24 @@
|
|
139 |
echo "</div>";
|
140 |
} else {
|
141 |
echo "<div class='wps-center'>" .
|
142 |
-
__('Currently there are no users online in the site.', 'wp-statistics') .
|
143 |
"</div>";
|
144 |
}
|
145 |
?>
|
146 |
-
|
147 |
-
|
148 |
|
149 |
<?php if ( $total > 0 ) { ?>
|
150 |
-
|
151 |
<?php echo $Pagination->display(); ?>
|
152 |
-
|
153 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
154 |
$Pagination->getCurrentPage(),
|
155 |
$Pagination->getTotalPages()
|
156 |
); ?></p>
|
157 |
-
|
158 |
<?php } ?>
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
</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 |
+
<h2><?php _e( 'Online Users', 'wp-statistics' ); ?></h2>
|
11 |
|
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 |
+
<?php $paneltitle = __( 'Online Users', 'wp-statistics' ); ?>
|
18 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
19 |
<span class="screen-reader-text"><?php printf(
|
20 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
21 |
$paneltitle
|
22 |
); ?></span>
|
23 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
24 |
+
</button>
|
25 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
26 |
|
27 |
+
<div class="inside">
|
28 |
<?php
|
29 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
30 |
|
31 |
+
$result = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}statistics_useronline;" );
|
32 |
+
$total = count( $result );
|
33 |
|
34 |
if ( $total > 0 ) {
|
35 |
// Instantiate pagination object with appropriate arguments
|
57 |
echo "<div class='log-latest'>";
|
58 |
$count = 0;
|
59 |
|
60 |
+
$dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
|
61 |
|
62 |
foreach ( $result as $items ) {
|
63 |
+
$count ++;
|
64 |
|
65 |
if ( $count >= $start ) {
|
66 |
+
if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
|
67 |
+
$ip_string = __( '#hash#', 'wp-statistics' );
|
68 |
$map_string = "";
|
69 |
} else {
|
70 |
$ip_string = "<a href='?page=" .
|
72 |
"&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
73 |
$map_string
|
74 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
75 |
+
__( 'Map', 'wp-statistics' ) .
|
76 |
"'>" .
|
77 |
+
wp_statistics_icons( 'dashicons-location-alt', 'map' ) .
|
78 |
"</a>";
|
79 |
}
|
80 |
|
82 |
echo "<div class='log-url'>";
|
83 |
echo $map_string;
|
84 |
|
85 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
86 |
echo "<img src='" .
|
87 |
plugins_url(
|
88 |
'wp-statistics/assets/images/flags/' . $items->location . '.png'
|
91 |
}
|
92 |
|
93 |
if ( array_search(
|
94 |
+
strtolower( $items->agent ),
|
95 |
array(
|
96 |
"chrome",
|
97 |
"firefox",
|
102 |
) !== false
|
103 |
) {
|
104 |
$agent = "<img src='" .
|
105 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
106 |
$items->agent .
|
107 |
".png' class='log-tools' title='{$items->agent}'/>";
|
108 |
} else {
|
109 |
+
$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
|
110 |
}
|
111 |
|
112 |
echo "<a href='?page=" .
|
117 |
$timediff = ( $items->timestamp - $items->created );
|
118 |
|
119 |
if ( $timediff > 3600 ) {
|
120 |
+
$onlinefor = date( "H:i:s", ( $items->timestamp - $items->created ) );
|
121 |
} else if ( $timediff > 60 ) {
|
122 |
+
$onlinefor = "00:" . date( "i:s", ( $items->timestamp - $items->created ) );
|
123 |
} else {
|
124 |
+
$onlinefor = "00:00:" . date( "s", ( $items->timestamp - $items->created ) );
|
125 |
}
|
126 |
|
127 |
+
echo sprintf( __( 'Online for %s (HH:MM:SS)', 'wp-statistics' ), $onlinefor );
|
128 |
|
129 |
echo "</div>";
|
130 |
echo "</div>";
|
139 |
echo "</div>";
|
140 |
} else {
|
141 |
echo "<div class='wps-center'>" .
|
142 |
+
__( 'Currently there are no users online in the site.', 'wp-statistics' ) .
|
143 |
"</div>";
|
144 |
}
|
145 |
?>
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
|
149 |
<?php if ( $total > 0 ) { ?>
|
150 |
+
<div class="pagination-log">
|
151 |
<?php echo $Pagination->display(); ?>
|
152 |
+
<p id="result-log"><?php printf(
|
153 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
154 |
$Pagination->getCurrentPage(),
|
155 |
$Pagination->getTotalPages()
|
156 |
); ?></p>
|
157 |
+
</div>
|
158 |
<?php } ?>
|
159 |
+
</div>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
</div>
|
includes/log/search-statistics.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
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 = '';
|
@@ -27,113 +27,113 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
27 |
$rangestart,
|
28 |
$rangeend
|
29 |
);
|
30 |
-
$daysInThePast = round(( time() - $rangeend_utime ) / 86400, 0);
|
31 |
|
32 |
-
$total_stats = $WP_Statistics->get_option('chart_totals');
|
33 |
$date = array();
|
34 |
$stats = array();
|
35 |
$total_daily = array();
|
36 |
|
37 |
foreach ( $search_engines as $se ) {
|
38 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
39 |
-
if ( ! array_key_exists($i, $total_daily) ) {
|
40 |
$total_daily[ $i ] = 0;
|
41 |
}
|
42 |
|
43 |
-
$stat
|
44 |
$stats[ $se['name'] ][] = $stat;
|
45 |
-
$total_daily[ $i ]
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
50 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
51 |
}
|
52 |
?>
|
53 |
<div class="wrap">
|
54 |
-
|
55 |
-
<?php wp_statistics_date_range_selector(WP_Statistics::$page['searches'], $daysToDisplay); ?>
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
<?php $paneltitle = __('Search Engine Referral Statistics', 'wp-statistics'); ?>
|
61 |
-
|
62 |
<span class="screen-reader-text"><?php printf(
|
63 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
64 |
$paneltitle
|
65 |
); ?></span>
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
<?php foreach ( $search_engines as $se ): ?>
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
<?php endforeach; ?>
|
99 |
<?php if ( $total_stats == 1 ) : ?>
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
<?php endif;?>
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
</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 = '';
|
27 |
$rangestart,
|
28 |
$rangeend
|
29 |
);
|
30 |
+
$daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
|
31 |
|
32 |
+
$total_stats = $WP_Statistics->get_option( 'chart_totals' );
|
33 |
$date = array();
|
34 |
$stats = array();
|
35 |
$total_daily = array();
|
36 |
|
37 |
foreach ( $search_engines as $se ) {
|
38 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
39 |
+
if ( ! array_key_exists( $i, $total_daily ) ) {
|
40 |
$total_daily[ $i ] = 0;
|
41 |
}
|
42 |
|
43 |
+
$stat = wp_statistics_searchengine( $se['tag'], '-' . ( $i + $daysInThePast ) );
|
44 |
$stats[ $se['name'] ][] = $stat;
|
45 |
+
$total_daily[ $i ] += $stat;
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
50 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
51 |
}
|
52 |
?>
|
53 |
<div class="wrap">
|
54 |
+
<h2><?php _e( 'Search Engine Referral Statistics', 'wp-statistics' ); ?></h2>
|
55 |
+
<?php wp_statistics_date_range_selector( WP_Statistics::$page['searches'], $daysToDisplay ); ?>
|
56 |
+
<div class="postbox-container" id="last-log">
|
57 |
+
<div class="metabox-holder">
|
58 |
+
<div class="meta-box-sortables">
|
59 |
+
<div class="postbox">
|
60 |
+
<?php $paneltitle = __( 'Search Engine Referral Statistics', 'wp-statistics' ); ?>
|
61 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
62 |
<span class="screen-reader-text"><?php printf(
|
63 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
64 |
$paneltitle
|
65 |
); ?></span>
|
66 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
67 |
+
</button>
|
68 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
69 |
|
70 |
+
<div class="inside">
|
71 |
+
<canvas id="search-stats" height="80"></canvas>
|
72 |
+
<script>
|
73 |
+
var colors = [];
|
74 |
+
colors['baidu'] = ['rgba(35, 25, 220, 0.2)', 'rgba(35, 25, 220, 1)'];
|
75 |
+
colors['bing'] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)'];
|
76 |
+
colors['duckduckgo'] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)'];
|
77 |
+
colors['google'] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)'];
|
78 |
+
colors['yahoo'] = ['rgba(64, 0, 144, 0.2)', 'rgba(64, 0, 144, 1)'];
|
79 |
+
colors['yandex'] = ['rgba(255, 219, 77, 0.2)', 'rgba(255, 219, 77, 1)'];
|
80 |
+
colors['ask'] = ['rgba(205, 0, 0, 0.2)', 'rgba(205, 0, 0, 1)'];
|
81 |
+
colors['clearch'] = ['rgba(13, 0, 76, 0.2)', 'rgba(13, 0, 76, 1)'];
|
82 |
|
83 |
+
var ctx = document.getElementById("search-stats").getContext('2d');
|
84 |
+
var ChartJs = new Chart(ctx, {
|
85 |
+
type: 'line',
|
86 |
+
data: {
|
87 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
88 |
+
datasets: [
|
89 |
<?php foreach ( $search_engines as $se ): ?>
|
90 |
+
{
|
91 |
+
label: '<?php echo $se['name']; ?>',
|
92 |
+
data: [<?php echo implode( ',', $stats[ $se['name'] ] ); ?>],
|
93 |
+
backgroundColor: colors['<?php echo $se['tag']; ?>'][0],
|
94 |
+
borderColor: colors['<?php echo $se['tag']; ?>'][1],
|
95 |
+
borderWidth: 1,
|
96 |
+
fill: true,
|
97 |
+
},
|
98 |
<?php endforeach; ?>
|
99 |
<?php if ( $total_stats == 1 ) : ?>
|
100 |
+
{
|
101 |
+
label: '<?php _e( 'Total', 'wp-statistics' ); ?>',
|
102 |
+
data: [<?php echo implode( ',', $total_daily ); ?>],
|
103 |
+
backgroundColor: 'rgba(180, 180, 180, 0.2)',
|
104 |
+
borderColor: 'rgba(180, 180, 180, 1)',
|
105 |
+
borderWidth: 1,
|
106 |
+
fill: false,
|
107 |
+
},
|
108 |
<?php endif;?>
|
109 |
+
]
|
110 |
+
},
|
111 |
+
options: {
|
112 |
+
responsive: true,
|
113 |
+
legend: {
|
114 |
+
position: 'bottom',
|
115 |
+
},
|
116 |
+
title: {
|
117 |
+
display: true,
|
118 |
+
text: '<?php echo sprintf( __( 'Search engine referrals in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
119 |
+
},
|
120 |
+
tooltips: {
|
121 |
+
mode: 'index',
|
122 |
+
intersect: false,
|
123 |
+
},
|
124 |
+
scales: {
|
125 |
+
yAxes: [{
|
126 |
+
ticks: {
|
127 |
+
beginAtZero: true
|
128 |
+
}
|
129 |
+
}]
|
130 |
+
}
|
131 |
+
}
|
132 |
+
});
|
133 |
+
</script>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
</div>
|
includes/log/searched-phrases.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
</script>
|
10 |
<?php
|
11 |
$date_args = '';
|
12 |
$daysToDisplay = 20;
|
13 |
-
if ( array_key_exists('hitdays', $_GET) ) {
|
14 |
-
$daysToDisplay = intval(esc_attr($_GET['hitdays']));
|
15 |
-
$date_args
|
16 |
}
|
17 |
|
18 |
-
if ( array_key_exists('rangestart', $_GET) ) {
|
19 |
-
$rangestart = esc_attr($_GET['rangestart']);
|
20 |
-
$date_args
|
21 |
} else {
|
22 |
$rangestart = '';
|
23 |
}
|
24 |
|
25 |
-
if ( array_key_exists('rangeend', $_GET) ) {
|
26 |
-
$rangeend
|
27 |
$date_args .= '&rangeend=' . $rangeend;
|
28 |
} else {
|
29 |
$rangeend = '';
|
@@ -35,10 +35,10 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
35 |
$rangeend
|
36 |
);
|
37 |
|
38 |
-
$rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime);
|
39 |
-
$rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime);
|
40 |
|
41 |
-
if ( array_key_exists('phrase', $_GET) ) {
|
42 |
$phrase = $_GET['phrase'];
|
43 |
$title = $_GET['phrase'];
|
44 |
$referr_field = '&phrase=' . $phrase;
|
@@ -57,23 +57,23 @@ if ( $phrase ) {
|
|
57 |
$rangestartdate,
|
58 |
$rangeenddate
|
59 |
);
|
60 |
-
$result = $wpdb->get_results($q_string);
|
61 |
-
$total = count($result);
|
62 |
} else {
|
63 |
$q_string = $wpdb->prepare(
|
64 |
"SELECT `words` , count(`words`) as `count` FROM `{$wpdb->prefix}statistics_search` WHERE `words` <> '' AND `last_counter` BETWEEN %s AND %s GROUP BY `words` order by `count` DESC",
|
65 |
$rangestartdate,
|
66 |
$rangeenddate
|
67 |
);
|
68 |
-
$result = $wpdb->get_results($q_string);
|
69 |
-
$total = count($result);
|
70 |
}
|
71 |
|
72 |
?>
|
73 |
<div class="wrap">
|
74 |
-
|
75 |
|
76 |
-
|
77 |
WP_Statistics::$page['searched-phrases'],
|
78 |
$daysToDisplay,
|
79 |
null,
|
@@ -81,56 +81,56 @@ if ( $phrase ) {
|
|
81 |
$phrase_field
|
82 |
); ?></div>
|
83 |
|
84 |
-
|
85 |
|
86 |
-
|
87 |
<?php if ( $phrase ) { ?>
|
88 |
-
|
89 |
echo 'class="current"';
|
90 |
} ?>href="?page=<?php echo WP_Statistics::$page['searched-phrases'] . $date_args; ?>"><?php _e(
|
91 |
'All',
|
92 |
'wp-statistics'
|
93 |
); ?></a>
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
$title,
|
101 |
ENT_QUOTES
|
102 |
); ?>
|
103 |
-
|
104 |
<?php } else { ?>
|
105 |
-
|
106 |
echo 'class="current"';
|
107 |
} ?>href="?page=<?php echo WP_Statistics::$page['searched-phrases'] . $date_args; ?>"><?php _e(
|
108 |
'All',
|
109 |
'wp-statistics'
|
110 |
); ?>
|
111 |
-
|
112 |
<?php } ?>
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
<?php if ( $phrase ) {
|
119 |
-
$paneltitle = sprintf(__('Searched Phrase: %s', 'wp-statistics'), esc_html($phrase));
|
120 |
} else {
|
121 |
-
$paneltitle = __('Top Searched Phrases', 'wp-statistics');
|
122 |
}; ?>
|
123 |
-
|
124 |
<span class="screen-reader-text"><?php printf(
|
125 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
126 |
$paneltitle
|
127 |
); ?></span>
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
-
|
134 |
<?php
|
135 |
|
136 |
if ( $total > 0 ) {
|
@@ -157,10 +157,10 @@ if ( $phrase ) {
|
|
157 |
$end = $Pagination->getEntryEnd();
|
158 |
|
159 |
if ( $result ) {
|
160 |
-
$result = array_slice($result, $start, $end);
|
161 |
$i = $start;
|
162 |
foreach ( $result as $item ) {
|
163 |
-
$i++;
|
164 |
echo "<div class='log-item'>";
|
165 |
echo "<div class='log-referred'>{$i} - {$item->words}</div>";
|
166 |
echo "<div class='clear'></div>";
|
@@ -171,21 +171,21 @@ if ( $phrase ) {
|
|
171 |
}
|
172 |
|
173 |
?>
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
<?php if ( $total > 0 ) {
|
180 |
echo $Pagination->display(); ?>
|
181 |
-
|
182 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
183 |
$Pagination->getCurrentPage(),
|
184 |
$Pagination->getTotalPages()
|
185 |
); ?></p>
|
186 |
<?php } ?>
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
</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( esc_attr( $_GET['hitdays'] ) );
|
15 |
+
$date_args .= '&hitdays=' . $daysToDisplay;
|
16 |
}
|
17 |
|
18 |
+
if ( array_key_exists( 'rangestart', $_GET ) ) {
|
19 |
+
$rangestart = esc_attr( $_GET['rangestart'] );
|
20 |
+
$date_args .= '&rangestart=' . $rangestart;
|
21 |
} else {
|
22 |
$rangestart = '';
|
23 |
}
|
24 |
|
25 |
+
if ( array_key_exists( 'rangeend', $_GET ) ) {
|
26 |
+
$rangeend = esc_attr( $_GET['rangeend'] );
|
27 |
$date_args .= '&rangeend=' . $rangeend;
|
28 |
} else {
|
29 |
$rangeend = '';
|
35 |
$rangeend
|
36 |
);
|
37 |
|
38 |
+
$rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
|
39 |
+
$rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
|
40 |
|
41 |
+
if ( array_key_exists( 'phrase', $_GET ) ) {
|
42 |
$phrase = $_GET['phrase'];
|
43 |
$title = $_GET['phrase'];
|
44 |
$referr_field = '&phrase=' . $phrase;
|
57 |
$rangestartdate,
|
58 |
$rangeenddate
|
59 |
);
|
60 |
+
$result = $wpdb->get_results( $q_string );
|
61 |
+
$total = count( $result );
|
62 |
} else {
|
63 |
$q_string = $wpdb->prepare(
|
64 |
"SELECT `words` , count(`words`) as `count` FROM `{$wpdb->prefix}statistics_search` WHERE `words` <> '' AND `last_counter` BETWEEN %s AND %s GROUP BY `words` order by `count` DESC",
|
65 |
$rangestartdate,
|
66 |
$rangeenddate
|
67 |
);
|
68 |
+
$result = $wpdb->get_results( $q_string );
|
69 |
+
$total = count( $result );
|
70 |
}
|
71 |
|
72 |
?>
|
73 |
<div class="wrap">
|
74 |
+
<h2><?php _e( 'Top Searched Phrases', 'wp-statistics' ); ?></h2>
|
75 |
|
76 |
+
<div><?php wp_statistics_date_range_selector(
|
77 |
WP_Statistics::$page['searched-phrases'],
|
78 |
$daysToDisplay,
|
79 |
null,
|
81 |
$phrase_field
|
82 |
); ?></div>
|
83 |
|
84 |
+
<div class="clear"/>
|
85 |
|
86 |
+
<ul class="subsubsub">
|
87 |
<?php if ( $phrase ) { ?>
|
88 |
+
<li class="all"><a <?php if ( ! $phrase ) {
|
89 |
echo 'class="current"';
|
90 |
} ?>href="?page=<?php echo WP_Statistics::$page['searched-phrases'] . $date_args; ?>"><?php _e(
|
91 |
'All',
|
92 |
'wp-statistics'
|
93 |
); ?></a>
|
94 |
+
</li>
|
95 |
+
|
|
96 |
+
<li>
|
97 |
+
<a class="current"
|
98 |
+
href="?page=<?php echo WP_Statistics::$page['searched-phrases']; ?>&referr=<?php echo esc_html( $phrase ) .
|
99 |
+
$date_args; ?>"> <?php echo htmlentities(
|
100 |
$title,
|
101 |
ENT_QUOTES
|
102 |
); ?>
|
103 |
+
<span class="count">(<?php echo $total; ?>)</span></a></li>
|
104 |
<?php } else { ?>
|
105 |
+
<li class="all"><a <?php if ( ! $phrase ) {
|
106 |
echo 'class="current"';
|
107 |
} ?>href="?page=<?php echo WP_Statistics::$page['searched-phrases'] . $date_args; ?>"><?php _e(
|
108 |
'All',
|
109 |
'wp-statistics'
|
110 |
); ?>
|
111 |
+
<span class="count">(<?php echo $total; ?>)</span></a></li>
|
112 |
<?php } ?>
|
113 |
+
</ul>
|
114 |
+
<div class="postbox-container" id="last-log">
|
115 |
+
<div class="metabox-holder">
|
116 |
+
<div class="meta-box-sortables">
|
117 |
+
<div class="postbox">
|
118 |
<?php if ( $phrase ) {
|
119 |
+
$paneltitle = sprintf( __( 'Searched Phrase: %s', 'wp-statistics' ), esc_html( $phrase ) );
|
120 |
} else {
|
121 |
+
$paneltitle = __( 'Top Searched Phrases', 'wp-statistics' );
|
122 |
}; ?>
|
123 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
124 |
<span class="screen-reader-text"><?php printf(
|
125 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
126 |
$paneltitle
|
127 |
); ?></span>
|
128 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
129 |
+
</button>
|
130 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
131 |
|
132 |
+
<div class="inside">
|
133 |
+
<div class="log-latest">
|
134 |
<?php
|
135 |
|
136 |
if ( $total > 0 ) {
|
157 |
$end = $Pagination->getEntryEnd();
|
158 |
|
159 |
if ( $result ) {
|
160 |
+
$result = array_slice( $result, $start, $end );
|
161 |
$i = $start;
|
162 |
foreach ( $result as $item ) {
|
163 |
+
$i ++;
|
164 |
echo "<div class='log-item'>";
|
165 |
echo "<div class='log-referred'>{$i} - {$item->words}</div>";
|
166 |
echo "<div class='clear'></div>";
|
171 |
}
|
172 |
|
173 |
?>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
|
178 |
+
<div class="pagination-log">
|
179 |
<?php if ( $total > 0 ) {
|
180 |
echo $Pagination->display(); ?>
|
181 |
+
<p id="result-log"><?php printf(
|
182 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
183 |
$Pagination->getCurrentPage(),
|
184 |
$Pagination->getTotalPages()
|
185 |
); ?></p>
|
186 |
<?php } ?>
|
187 |
+
</div>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
</div>
|
includes/log/tags.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<div class="wrap">
|
7 |
-
|
8 |
<?php
|
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 |
-
if ( array_key_exists('tag', $_GET) ) {
|
25 |
$tag = $_GET['tag'];
|
26 |
} else {
|
27 |
-
if ( array_key_exists('pretag', $_GET) ) {
|
28 |
$tag = $_GET['pretag'];
|
29 |
} else {
|
30 |
$tag = '';
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
$html = __('Select Tag', 'wp-statistics') . ': ';
|
35 |
|
36 |
$tags = get_tags();
|
37 |
|
@@ -54,7 +54,7 @@
|
|
54 |
}
|
55 |
|
56 |
$html .= '</select>';
|
57 |
-
$html .= ' <input type="submit" value="' . __('Select', 'wp-statistics') . '" class="button-primary">';
|
58 |
$html .= '<br>';
|
59 |
|
60 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
@@ -63,183 +63,183 @@
|
|
63 |
$rangeend
|
64 |
);
|
65 |
|
66 |
-
wp_statistics_date_range_selector(WP_Statistics::$page['tags'], $daysToDisplay, null, null, '&pretag=' . $tag, $html);
|
67 |
|
68 |
$args = array(
|
69 |
'tax_query' => array(
|
70 |
array(
|
71 |
'taxonomy' => 'post_tag',
|
72 |
'field' => 'slug',
|
73 |
-
'terms' => sanitize_title($tag),
|
74 |
),
|
75 |
),
|
76 |
);
|
77 |
|
78 |
-
$posts = get_posts($args);
|
79 |
|
80 |
-
$visit_total
|
81 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
82 |
-
$posts_stats
|
83 |
-
$visits
|
84 |
|
85 |
// Setup the array, otherwise PHP may throw an error.
|
86 |
foreach ( $posts as $post ) {
|
87 |
$posts_stats[ $post->ID ] = 0;
|
88 |
}
|
89 |
|
90 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
91 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
92 |
|
93 |
$stat = 0;
|
94 |
foreach ( $posts as $post ) {
|
95 |
-
$temp_stat
|
96 |
$posts_stats[ $post->ID ] += $temp_stat;
|
97 |
-
$stat
|
98 |
}
|
99 |
|
100 |
-
$visits[]
|
101 |
$visit_total += $stat;
|
102 |
}
|
103 |
?>
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
<?php $paneltitle = __('Tag Statistics Chart', 'wp-statistics'); ?>
|
109 |
-
|
110 |
<span class="screen-reader-text"><?php printf(
|
111 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
112 |
$paneltitle
|
113 |
); ?></span>
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
<?php $paneltitle = __('Tag Statistics Summary', 'wp-statistics'); ?>
|
171 |
-
|
172 |
<span class="screen-reader-text"><?php printf(
|
173 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
174 |
$paneltitle
|
175 |
); ?></span>
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
|
204 |
$stat = 0;
|
205 |
foreach ( $posts as $post ) {
|
206 |
-
$stat += wp_statistics_pages('total', null, $post->ID);
|
207 |
}
|
208 |
|
209 |
-
echo number_format_i18n($stat); ?></span></th>
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
<?php $paneltitle = __('Tag Posts Sorted by Hits', 'wp-statistics'); ?>
|
224 |
-
|
225 |
<span class="screen-reader-text"><?php printf(
|
226 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
227 |
$paneltitle
|
228 |
); ?></span>
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
|
241 |
<?php
|
242 |
-
arsort($posts_stats);
|
243 |
|
244 |
$posts_by_id = array();
|
245 |
|
@@ -251,24 +251,24 @@
|
|
251 |
$post_obj = $posts_by_id[ $post_id ];
|
252 |
|
253 |
?>
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
$post_obj
|
258 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
<?php
|
264 |
}
|
265 |
?>
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
|
274 |
</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 |
+
<h2><?php _e( 'Tag Statistics', 'wp-statistics' ); ?></h2>
|
8 |
<?php
|
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 |
+
if ( array_key_exists( 'tag', $_GET ) ) {
|
25 |
$tag = $_GET['tag'];
|
26 |
} else {
|
27 |
+
if ( array_key_exists( 'pretag', $_GET ) ) {
|
28 |
$tag = $_GET['pretag'];
|
29 |
} else {
|
30 |
$tag = '';
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
$html = __( 'Select Tag', 'wp-statistics' ) . ': ';
|
35 |
|
36 |
$tags = get_tags();
|
37 |
|
54 |
}
|
55 |
|
56 |
$html .= '</select>';
|
57 |
+
$html .= ' <input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">';
|
58 |
$html .= '<br>';
|
59 |
|
60 |
list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator(
|
63 |
$rangeend
|
64 |
);
|
65 |
|
66 |
+
wp_statistics_date_range_selector( WP_Statistics::$page['tags'], $daysToDisplay, null, null, '&pretag=' . $tag, $html );
|
67 |
|
68 |
$args = array(
|
69 |
'tax_query' => array(
|
70 |
array(
|
71 |
'taxonomy' => 'post_tag',
|
72 |
'field' => 'slug',
|
73 |
+
'terms' => sanitize_title( $tag ),
|
74 |
),
|
75 |
),
|
76 |
);
|
77 |
|
78 |
+
$posts = get_posts( $args );
|
79 |
|
80 |
+
$visit_total = 0;
|
81 |
$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 );
|
82 |
+
$posts_stats = array();
|
83 |
+
$visits = array();
|
84 |
|
85 |
// Setup the array, otherwise PHP may throw an error.
|
86 |
foreach ( $posts as $post ) {
|
87 |
$posts_stats[ $post->ID ] = 0;
|
88 |
}
|
89 |
|
90 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
91 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
92 |
|
93 |
$stat = 0;
|
94 |
foreach ( $posts as $post ) {
|
95 |
+
$temp_stat = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID );
|
96 |
$posts_stats[ $post->ID ] += $temp_stat;
|
97 |
+
$stat = $temp_stat;
|
98 |
}
|
99 |
|
100 |
+
$visits[] = $stat;
|
101 |
$visit_total += $stat;
|
102 |
}
|
103 |
?>
|
104 |
+
<div class="postbox-container" id="last-log">
|
105 |
+
<div class="metabox-holder">
|
106 |
+
<div class="meta-box-sortables">
|
107 |
+
<div class="postbox">
|
108 |
+
<?php $paneltitle = __( 'Tag Statistics Chart', 'wp-statistics' ); ?>
|
109 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
110 |
<span class="screen-reader-text"><?php printf(
|
111 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
112 |
$paneltitle
|
113 |
); ?></span>
|
114 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
115 |
+
</button>
|
116 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
117 |
+
|
118 |
+
<div class="inside">
|
119 |
+
<canvas id="hit-stats" height="80"></canvas>
|
120 |
+
<script>
|
121 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
122 |
+
var ChartJs = new Chart(ctx, {
|
123 |
+
type: 'line',
|
124 |
+
data: {
|
125 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
126 |
+
datasets: [
|
127 |
+
{
|
128 |
+
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
|
129 |
+
data: [<?php echo implode( ',', $visits ); ?>],
|
130 |
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
131 |
+
borderColor: 'rgba(54, 162, 235, 1)',
|
132 |
+
borderWidth: 1,
|
133 |
+
fill: true,
|
134 |
+
},
|
135 |
+
]
|
136 |
+
},
|
137 |
+
options: {
|
138 |
+
responsive: true,
|
139 |
+
legend: {
|
140 |
+
position: 'bottom',
|
141 |
+
},
|
142 |
+
title: {
|
143 |
+
display: true,
|
144 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>'
|
145 |
+
},
|
146 |
+
tooltips: {
|
147 |
+
mode: 'index',
|
148 |
+
intersect: false,
|
149 |
+
},
|
150 |
+
scales: {
|
151 |
+
yAxes: [{
|
152 |
+
ticks: {
|
153 |
+
beginAtZero: true
|
154 |
+
}
|
155 |
+
}]
|
156 |
+
}
|
157 |
+
}
|
158 |
+
});
|
159 |
+
</script>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
|
166 |
+
<div class="postbox-container" style="width: 100%; float: left; margin-right:20px">
|
167 |
+
<div class="metabox-holder">
|
168 |
+
<div class="meta-box-sortables">
|
169 |
+
<div class="postbox">
|
170 |
+
<?php $paneltitle = __( 'Tag Statistics Summary', 'wp-statistics' ); ?>
|
171 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
172 |
<span class="screen-reader-text"><?php printf(
|
173 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
174 |
$paneltitle
|
175 |
); ?></span>
|
176 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
177 |
+
</button>
|
178 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
179 |
+
|
180 |
+
<div class="inside">
|
181 |
+
<table width="auto" class="widefat table-stats" id="summary-stats">
|
182 |
+
<tbody>
|
183 |
+
<tr>
|
184 |
+
<th></th>
|
185 |
+
<th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th>
|
186 |
+
</tr>
|
187 |
+
|
188 |
+
<tr>
|
189 |
+
<th><?php _e( 'Number of posts in tag', 'wp-statistics' ); ?>:</th>
|
190 |
+
<th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span>
|
191 |
+
</th>
|
192 |
+
</tr>
|
193 |
+
|
194 |
+
<tr>
|
195 |
+
<th><?php _e( 'Chart Visits Total', 'wp-statistics' ); ?>:</th>
|
196 |
+
<th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span>
|
197 |
+
</th>
|
198 |
+
</tr>
|
199 |
+
|
200 |
+
<tr>
|
201 |
+
<th><?php _e( 'All Time Visits Total', 'wp-statistics' ); ?>:</th>
|
202 |
+
<th class="th-center"><span><?php
|
203 |
|
204 |
$stat = 0;
|
205 |
foreach ( $posts as $post ) {
|
206 |
+
$stat += wp_statistics_pages( 'total', null, $post->ID );
|
207 |
}
|
208 |
|
209 |
+
echo number_format_i18n( $stat ); ?></span></th>
|
210 |
+
</tr>
|
211 |
+
</tbody>
|
212 |
+
</table>
|
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 |
+
<?php $paneltitle = __( 'Tag Posts Sorted by Hits', 'wp-statistics' ); ?>
|
224 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
225 |
<span class="screen-reader-text"><?php printf(
|
226 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
227 |
$paneltitle
|
228 |
); ?></span>
|
229 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
230 |
+
</button>
|
231 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
232 |
+
|
233 |
+
<div class="inside">
|
234 |
+
<table width="auto" class="widefat table-stats" id="post-stats">
|
235 |
+
<tbody>
|
236 |
+
<tr>
|
237 |
+
<th><?php _e( 'Post Title', 'wp-statistics' ); ?></th>
|
238 |
+
<th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th>
|
239 |
+
</tr>
|
240 |
|
241 |
<?php
|
242 |
+
arsort( $posts_stats );
|
243 |
|
244 |
$posts_by_id = array();
|
245 |
|
251 |
$post_obj = $posts_by_id[ $post_id ];
|
252 |
|
253 |
?>
|
254 |
+
<tr>
|
255 |
+
<th>
|
256 |
+
<a href="<?php echo get_permalink(
|
257 |
$post_obj
|
258 |
); ?>"><?php echo $post_obj->post_title; ?></a>
|
259 |
+
</th>
|
260 |
+
<th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span>
|
261 |
+
</th>
|
262 |
+
</tr>
|
263 |
<?php
|
264 |
}
|
265 |
?>
|
266 |
+
</tbody>
|
267 |
+
</table>
|
268 |
+
</div>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
</div>
|
272 |
+
</div>
|
273 |
|
274 |
</div>
|
includes/log/top-countries.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
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 = '';
|
@@ -28,62 +28,62 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
28 |
|
29 |
?>
|
30 |
<div class="wrap">
|
31 |
-
|
32 |
-
<?php wp_statistics_date_range_selector(WP_Statistics::$page['countries'], $daysToDisplay); ?>
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
<?php $paneltitle = __('Top Countries', 'wp-statistics'); ?>
|
38 |
-
|
39 |
<span class="screen-reader-text"><?php printf(
|
40 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
41 |
$paneltitle
|
42 |
); ?></span>
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
<?php
|
57 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
58 |
-
$rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime);
|
59 |
-
$rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime);
|
60 |
|
61 |
$result = $wpdb->get_results(
|
62 |
-
sprintf("SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` BETWEEN '%s' AND '%s' GROUP BY `location` ORDER BY `count` DESC",
|
63 |
$rangestartdate,
|
64 |
$rangeenddate
|
65 |
-
|
66 |
-
|
67 |
-
$i
|
68 |
|
69 |
foreach ( $result as $item ) {
|
70 |
-
$i++;
|
71 |
-
$item->location = strtoupper($item->location);
|
72 |
|
73 |
echo "<tr>";
|
74 |
echo "<td>$i</td>";
|
75 |
echo "<td><img src='" .
|
76 |
-
plugins_url('wp-statistics/assets/images/flags/' . $item->location . '.png') .
|
77 |
"' title='{$ISOCountryCode[$item->location]}'/></td>";
|
78 |
echo "<td style='direction: ltr;'>{$ISOCountryCode[$item->location]}</td>";
|
79 |
-
echo "<td>" . number_format_i18n($item->count) . "</td>";
|
80 |
echo "</tr>";
|
81 |
}
|
82 |
?>
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
</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 = '';
|
28 |
|
29 |
?>
|
30 |
<div class="wrap">
|
31 |
+
<h2><?php _e( 'Top Countries', 'wp-statistics' ); ?></h2>
|
32 |
+
<?php wp_statistics_date_range_selector( WP_Statistics::$page['countries'], $daysToDisplay ); ?>
|
33 |
+
<div class="postbox-container" id="last-log">
|
34 |
+
<div class="metabox-holder">
|
35 |
+
<div class="meta-box-sortables">
|
36 |
+
<div class="postbox">
|
37 |
+
<?php $paneltitle = __( 'Top Countries', 'wp-statistics' ); ?>
|
38 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
39 |
<span class="screen-reader-text"><?php printf(
|
40 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
41 |
$paneltitle
|
42 |
); ?></span>
|
43 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
44 |
+
</button>
|
45 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
46 |
|
47 |
+
<div class="inside">
|
48 |
+
<table class="widefat table-stats" id="last-referrer" style="width: 100%;">
|
49 |
+
<tr>
|
50 |
+
<td><?php _e( 'Rank', 'wp-statistics' ); ?></td>
|
51 |
+
<td><?php _e( 'Flag', 'wp-statistics' ); ?></td>
|
52 |
+
<td><?php _e( 'Country', 'wp-statistics' ); ?></td>
|
53 |
+
<td><?php _e( 'Visitor Count', 'wp-statistics' ); ?></td>
|
54 |
+
</tr>
|
55 |
|
56 |
<?php
|
57 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
58 |
+
$rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
|
59 |
+
$rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
|
60 |
|
61 |
$result = $wpdb->get_results(
|
62 |
+
sprintf( "SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` BETWEEN '%s' AND '%s' GROUP BY `location` ORDER BY `count` DESC",
|
63 |
$rangestartdate,
|
64 |
$rangeenddate
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$i = 0;
|
68 |
|
69 |
foreach ( $result as $item ) {
|
70 |
+
$i ++;
|
71 |
+
$item->location = strtoupper( $item->location );
|
72 |
|
73 |
echo "<tr>";
|
74 |
echo "<td>$i</td>";
|
75 |
echo "<td><img src='" .
|
76 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $item->location . '.png' ) .
|
77 |
"' title='{$ISOCountryCode[$item->location]}'/></td>";
|
78 |
echo "<td style='direction: ltr;'>{$ISOCountryCode[$item->location]}</td>";
|
79 |
+
echo "<td>" . number_format_i18n( $item->count ) . "</td>";
|
80 |
echo "</tr>";
|
81 |
}
|
82 |
?>
|
83 |
+
</table>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
</div>
|
88 |
+
</div>
|
89 |
</div>
|
includes/log/top-pages.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
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 = '';
|
@@ -25,19 +25,19 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
25 |
$rangestart,
|
26 |
$rangeend
|
27 |
);
|
28 |
-
$daysInThePast = round(( time() - $rangeend_utime ) / 86400, 0);
|
29 |
|
30 |
list( $total, $uris ) = wp_statistics_get_top_pages(
|
31 |
-
$WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangestart_utime),
|
32 |
-
$WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangeend_utime)
|
33 |
);
|
34 |
$count = 0;
|
35 |
|
36 |
foreach ( $uris as $uri ) {
|
37 |
-
$count++;
|
38 |
|
39 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
40 |
-
$stats[ $uri[0] ][] = wp_statistics_pages('-' . ( $i + $daysInThePast ), $uri[0]);
|
41 |
}
|
42 |
|
43 |
if ( $count > 4 ) {
|
@@ -45,93 +45,93 @@ foreach ( $uris as $uri ) {
|
|
45 |
}
|
46 |
}
|
47 |
|
48 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
49 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
50 |
}
|
51 |
?>
|
52 |
<div class="wrap">
|
53 |
-
|
54 |
-
<?php wp_statistics_date_range_selector(WP_Statistics::$page['pages'], $daysToDisplay); ?>
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
<?php $paneltitle = __('Top 5 Pages Trends', 'wp-statistics'); ?>
|
60 |
-
|
61 |
<span class="screen-reader-text"><?php printf(
|
62 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
63 |
$paneltitle
|
64 |
); ?></span>
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
<?php foreach ($stats as $key => $value) : $i++; ?>
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
<?php endforeach; ?>
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
<?php $paneltitle = __('Top Pages', 'wp-statistics'); ?>
|
125 |
-
|
126 |
<span class="screen-reader-text"><?php printf(
|
127 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
128 |
$paneltitle
|
129 |
); ?></span>
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
<?php
|
136 |
if ( $total > 0 ) {
|
137 |
// Instantiate pagination object with appropriate arguments
|
@@ -162,31 +162,31 @@ for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
|
162 |
$count = 0;
|
163 |
|
164 |
foreach ( $uris as $uri ) {
|
165 |
-
$count++;
|
166 |
|
167 |
if ( $count >= $start ) {
|
168 |
echo "<div class='log-item'>";
|
169 |
|
170 |
if ( $uri[3] == '' ) {
|
171 |
$uri[3] = '[' .
|
172 |
-
htmlentities(__('No page title found', 'wp-statistics'), ENT_QUOTES) .
|
173 |
']';
|
174 |
}
|
175 |
|
176 |
echo "<div class='log-page-title'>{$count} - {$uri[3]}</div>";
|
177 |
echo "<div class='right-div'>" .
|
178 |
-
__('Visits', 'wp-statistics') .
|
179 |
": <a href='?page=" .
|
180 |
WP_Statistics::$page['pages'] .
|
181 |
'&page-uri=' .
|
182 |
-
htmlentities($uri[0], ENT_QUOTES) .
|
183 |
"'>" .
|
184 |
-
number_format_i18n($uri[1]) .
|
185 |
"</a></div>";
|
186 |
echo "<div class='left-div'><a dir='ltr' href='" .
|
187 |
-
htmlentities($site_url . $uri[0], ENT_QUOTES) .
|
188 |
"'>" .
|
189 |
-
htmlentities(urldecode($uri[0]), ENT_QUOTES) .
|
190 |
"</a></div>";
|
191 |
echo "</div>";
|
192 |
}
|
@@ -200,20 +200,20 @@ for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
|
200 |
echo "</div>";
|
201 |
}
|
202 |
?>
|
203 |
-
|
204 |
-
|
205 |
|
206 |
<?php if ( $total > 0 ) { ?>
|
207 |
-
|
208 |
<?php echo $Pagination->display(); ?>
|
209 |
-
|
210 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
211 |
$Pagination->getCurrentPage(),
|
212 |
$Pagination->getTotalPages()
|
213 |
); ?></p>
|
214 |
-
|
215 |
<?php } ?>
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
</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 = '';
|
25 |
$rangestart,
|
26 |
$rangeend
|
27 |
);
|
28 |
+
$daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
|
29 |
|
30 |
list( $total, $uris ) = wp_statistics_get_top_pages(
|
31 |
+
$WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangestart_utime ),
|
32 |
+
$WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime )
|
33 |
);
|
34 |
$count = 0;
|
35 |
|
36 |
foreach ( $uris as $uri ) {
|
37 |
+
$count ++;
|
38 |
|
39 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
40 |
+
$stats[ $uri[0] ][] = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $uri[0] );
|
41 |
}
|
42 |
|
43 |
if ( $count > 4 ) {
|
45 |
}
|
46 |
}
|
47 |
|
48 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
49 |
$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'";
|
50 |
}
|
51 |
?>
|
52 |
<div class="wrap">
|
53 |
+
<h2><?php _e( 'Top Pages', 'wp-statistics' ); ?></h2>
|
54 |
+
<?php wp_statistics_date_range_selector( WP_Statistics::$page['pages'], $daysToDisplay ); ?>
|
55 |
+
<div class="postbox-container" id="last-log">
|
56 |
+
<div class="metabox-holder">
|
57 |
+
<div class="meta-box-sortables">
|
58 |
+
<div class="postbox">
|
59 |
+
<?php $paneltitle = __( 'Top 5 Pages Trends', 'wp-statistics' ); ?>
|
60 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
61 |
<span class="screen-reader-text"><?php printf(
|
62 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
63 |
$paneltitle
|
64 |
); ?></span>
|
65 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
66 |
+
</button>
|
67 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
68 |
+
|
69 |
+
<div class="inside">
|
70 |
+
<canvas id="hit-stats" height="80"></canvas>
|
71 |
+
<script>
|
72 |
+
var colors = [];
|
73 |
+
colors[0] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)'];
|
74 |
+
colors[1] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)'];
|
75 |
+
colors[2] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)'];
|
76 |
+
colors[3] = ['rgba(255, 99, 132, 0.2)', 'rgba(255, 99, 132, 1)'];
|
77 |
+
colors[4] = ['rgba(54, 162, 235, 0.2)', 'rgba(54, 162, 235, 1)'];
|
78 |
+
|
79 |
+
var ctx = document.getElementById("hit-stats").getContext('2d');
|
80 |
+
var ChartJs = new Chart(ctx, {
|
81 |
+
type: 'line',
|
82 |
+
data: {
|
83 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
84 |
+
datasets: [
|
85 |
+
<?php foreach ($stats as $key => $value) : $i ++; ?>
|
86 |
+
{
|
87 |
+
label: '<?php echo $key; ?>',
|
88 |
+
data: [<?php echo implode( ',', $value ); ?>],
|
89 |
+
backgroundColor: colors[<?php echo $i; ?>][0],
|
90 |
+
borderColor: colors[<?php echo $i; ?>][1],
|
91 |
+
fill: true,
|
92 |
+
borderWidth: 1,
|
93 |
+
},
|
94 |
<?php endforeach; ?>
|
95 |
+
]
|
96 |
+
},
|
97 |
+
options: {
|
98 |
+
responsive: true,
|
99 |
+
legend: {
|
100 |
+
position: 'bottom',
|
101 |
+
},
|
102 |
+
title: {
|
103 |
+
display: true,
|
104 |
+
text: '<?php echo htmlentities( __( 'Top 5 Page Trending Stats', 'wp-statistics' ), ENT_QUOTES ); ?>'
|
105 |
+
},
|
106 |
+
tooltips: {
|
107 |
+
mode: 'index',
|
108 |
+
intersect: false,
|
109 |
+
},
|
110 |
+
scales: {
|
111 |
+
yAxes: [{
|
112 |
+
ticks: {
|
113 |
+
beginAtZero: true
|
114 |
+
}
|
115 |
+
}]
|
116 |
+
}
|
117 |
+
}
|
118 |
+
});
|
119 |
+
</script>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
|
123 |
+
<div class="postbox">
|
124 |
+
<?php $paneltitle = __( 'Top Pages', 'wp-statistics' ); ?>
|
125 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
126 |
<span class="screen-reader-text"><?php printf(
|
127 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
128 |
$paneltitle
|
129 |
); ?></span>
|
130 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
131 |
+
</button>
|
132 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
133 |
|
134 |
+
<div class="inside">
|
135 |
<?php
|
136 |
if ( $total > 0 ) {
|
137 |
// Instantiate pagination object with appropriate arguments
|
162 |
$count = 0;
|
163 |
|
164 |
foreach ( $uris as $uri ) {
|
165 |
+
$count ++;
|
166 |
|
167 |
if ( $count >= $start ) {
|
168 |
echo "<div class='log-item'>";
|
169 |
|
170 |
if ( $uri[3] == '' ) {
|
171 |
$uri[3] = '[' .
|
172 |
+
htmlentities( __( 'No page title found', 'wp-statistics' ), ENT_QUOTES ) .
|
173 |
']';
|
174 |
}
|
175 |
|
176 |
echo "<div class='log-page-title'>{$count} - {$uri[3]}</div>";
|
177 |
echo "<div class='right-div'>" .
|
178 |
+
__( 'Visits', 'wp-statistics' ) .
|
179 |
": <a href='?page=" .
|
180 |
WP_Statistics::$page['pages'] .
|
181 |
'&page-uri=' .
|
182 |
+
htmlentities( $uri[0], ENT_QUOTES ) .
|
183 |
"'>" .
|
184 |
+
number_format_i18n( $uri[1] ) .
|
185 |
"</a></div>";
|
186 |
echo "<div class='left-div'><a dir='ltr' href='" .
|
187 |
+
htmlentities( $site_url . $uri[0], ENT_QUOTES ) .
|
188 |
"'>" .
|
189 |
+
htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) .
|
190 |
"</a></div>";
|
191 |
echo "</div>";
|
192 |
}
|
200 |
echo "</div>";
|
201 |
}
|
202 |
?>
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
|
206 |
<?php if ( $total > 0 ) { ?>
|
207 |
+
<div class="pagination-log">
|
208 |
<?php echo $Pagination->display(); ?>
|
209 |
+
<p id="result-log"><?php printf(
|
210 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
211 |
$Pagination->getCurrentPage(),
|
212 |
$Pagination->getTotalPages()
|
213 |
); ?></p>
|
214 |
+
</div>
|
215 |
<?php } ?>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
</div>
|
includes/log/top-referring.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
</script>
|
10 |
<?php
|
11 |
$date_args = '';
|
12 |
$daysToDisplay = 20;
|
13 |
-
if ( array_key_exists('hitdays', $_GET) ) {
|
14 |
-
$daysToDisplay = intval(esc_attr($_GET['hitdays']));
|
15 |
-
$date_args
|
16 |
}
|
17 |
|
18 |
-
if ( array_key_exists('rangestart', $_GET) ) {
|
19 |
-
$rangestart = esc_attr($_GET['rangestart']);
|
20 |
-
$date_args
|
21 |
} else {
|
22 |
$rangestart = '';
|
23 |
}
|
24 |
|
25 |
-
if ( array_key_exists('rangeend', $_GET) ) {
|
26 |
-
$rangeend
|
27 |
$date_args .= '&rangeend=' . $rangeend;
|
28 |
} else {
|
29 |
$rangeend = '';
|
@@ -35,10 +35,10 @@ list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_
|
|
35 |
$rangeend
|
36 |
);
|
37 |
|
38 |
-
$rangestartdate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangestart_utime);
|
39 |
-
$rangeenddate = $WP_Statistics->real_current_date('Y-m-d', '-0', $rangeend_utime);
|
40 |
|
41 |
-
if ( array_key_exists('referr', $_GET) ) {
|
42 |
$referr = $_GET['referr'];
|
43 |
$title = $_GET['referr'];
|
44 |
$referr_field = '&referr=' . $referr;
|
@@ -60,7 +60,7 @@ if ( $referr ) {
|
|
60 |
)
|
61 |
);
|
62 |
|
63 |
-
$total = count($result);
|
64 |
} else {
|
65 |
$result = $wpdb->get_results(
|
66 |
$wpdb->prepare(
|
@@ -73,25 +73,25 @@ if ( $referr ) {
|
|
73 |
$urls = array();
|
74 |
foreach ( $result as $item ) {
|
75 |
|
76 |
-
$url = parse_url($item->referred);
|
77 |
|
78 |
-
if ( empty( $url['host'] ) || stristr(get_bloginfo('url'), $url['host']) ) {
|
79 |
continue;
|
80 |
}
|
81 |
|
82 |
$urls[] = $url['scheme'] . '://' . $url['host'];
|
83 |
}
|
84 |
|
85 |
-
$get_urls = array_count_values($urls);
|
86 |
|
87 |
-
$total = count($get_urls);
|
88 |
}
|
89 |
|
90 |
?>
|
91 |
<div class="wrap">
|
92 |
-
|
93 |
|
94 |
-
|
95 |
WP_Statistics::$page['referrers'],
|
96 |
$daysToDisplay,
|
97 |
null,
|
@@ -99,56 +99,56 @@ if ( $referr ) {
|
|
99 |
$referr_field
|
100 |
); ?></div>
|
101 |
|
102 |
-
|
103 |
|
104 |
-
|
105 |
<?php if ( $referr ) { ?>
|
106 |
-
|
107 |
echo 'class="current"';
|
108 |
} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e(
|
109 |
'All',
|
110 |
'wp-statistics'
|
111 |
); ?></a>
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
$referr
|
118 |
-
) . $date_args; ?>"> <?php echo htmlentities($title, ENT_QUOTES); ?>
|
119 |
-
|
120 |
<?php } else { ?>
|
121 |
-
|
122 |
echo 'class="current"';
|
123 |
} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e(
|
124 |
'All',
|
125 |
'wp-statistics'
|
126 |
); ?>
|
127 |
-
|
128 |
<?php } ?>
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
<?php if ( $referr ) {
|
135 |
$paneltitle = sprintf(
|
136 |
-
__('Referring site: %s', 'wp-statistics'),
|
137 |
-
$WP_Statistics->html_sanitize_referrer($referr)
|
138 |
);
|
139 |
} else {
|
140 |
-
$paneltitle = __('Top Referring Sites', 'wp-statistics');
|
141 |
}; ?>
|
142 |
-
|
143 |
<span class="screen-reader-text"><?php printf(
|
144 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
145 |
$paneltitle
|
146 |
); ?></span>
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
<?php
|
153 |
echo "<div class='log-latest'>";
|
154 |
|
@@ -176,7 +176,7 @@ if ( $referr ) {
|
|
176 |
$end = $Pagination->getEntryEnd();
|
177 |
|
178 |
if ( $referr ) {
|
179 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
180 |
$result = $wpdb->get_results(
|
181 |
$wpdb->prepare(
|
182 |
"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",
|
@@ -194,18 +194,18 @@ if ( $referr ) {
|
|
194 |
echo "<div class='log-referred'><a href='?page=" .
|
195 |
WP_Statistics::$page['overview'] .
|
196 |
"&type=last-all-visitor&ip={$item->ip}'>" .
|
197 |
-
wp_statistics_icons('dashicons-visibility', 'visibility') .
|
198 |
"{$item->ip}</a></div>";
|
199 |
echo "<div class='log-ip'>" .
|
200 |
-
date(get_option('date_format'), strtotime($item->last_counter)) .
|
201 |
" - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>";
|
202 |
echo "<div class='clear'></div>";
|
203 |
echo "<a class='show-map' title='" .
|
204 |
-
__('Map', 'wp-statistics') .
|
205 |
"'><div class='dashicons dashicons-location-alt'></div></a>";
|
206 |
|
207 |
if ( array_search(
|
208 |
-
strtolower($item->agent),
|
209 |
array(
|
210 |
'chrome',
|
211 |
'firefox',
|
@@ -216,7 +216,7 @@ if ( $referr ) {
|
|
216 |
) !== false
|
217 |
) {
|
218 |
$agent = "<img src='" .
|
219 |
-
plugins_url('wp-statistics/assets/images/') .
|
220 |
$item->agent .
|
221 |
".png' class='log-tools' title='{$item->agent}'/>";
|
222 |
} else {
|
@@ -226,18 +226,18 @@ if ( $referr ) {
|
|
226 |
echo "<div class='log-agent'><a href='?page=" .
|
227 |
WP_Statistics::$page['overview'] .
|
228 |
"&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>";
|
229 |
-
echo $WP_Statistics->get_referrer_link($item->referred, 100) . '</div>';
|
230 |
echo "</div>";
|
231 |
}
|
232 |
} else {
|
233 |
-
arsort($get_urls);
|
234 |
-
$get_urls = array_slice($get_urls, $start, $end);
|
235 |
|
236 |
$i = $start;
|
237 |
foreach ( $get_urls as $items => $value ) {
|
238 |
-
$i++;
|
239 |
-
$referrer_html = $WP_Statistics->html_sanitize_referrer($items);
|
240 |
-
$referrer_html = parse_url($referrer_html)['host'];
|
241 |
echo "<div class='log-item'>";
|
242 |
echo "<div class='log-referred'>{$i} - <a href='?page=" .
|
243 |
WP_Statistics::$page['referrers'] .
|
@@ -248,13 +248,13 @@ if ( $referr ) {
|
|
248 |
$referrer_html .
|
249 |
"</a></div>";
|
250 |
echo "<div class='log-ip'>" .
|
251 |
-
__('References', 'wp-statistics') .
|
252 |
': ' .
|
253 |
-
number_format_i18n($value) .
|
254 |
'</div>';
|
255 |
echo "<div class='clear'></div>";
|
256 |
echo "<div class='log-url'>" .
|
257 |
-
$WP_Statistics->get_referrer_link($items, 100) .
|
258 |
'</div>';
|
259 |
echo "</div>";
|
260 |
}
|
@@ -263,20 +263,20 @@ if ( $referr ) {
|
|
263 |
|
264 |
echo '</div>';
|
265 |
?>
|
266 |
-
|
267 |
-
|
268 |
|
269 |
-
|
270 |
<?php if ( $total > 0 ) {
|
271 |
echo $Pagination->display(); ?>
|
272 |
-
|
273 |
-
__('Page %1$s of %2$s', 'wp-statistics'),
|
274 |
$Pagination->getCurrentPage(),
|
275 |
$Pagination->getTotalPages()
|
276 |
); ?></p>
|
277 |
<?php } ?>
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
</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( esc_attr( $_GET['hitdays'] ) );
|
15 |
+
$date_args .= '&hitdays=' . $daysToDisplay;
|
16 |
}
|
17 |
|
18 |
+
if ( array_key_exists( 'rangestart', $_GET ) ) {
|
19 |
+
$rangestart = esc_attr( $_GET['rangestart'] );
|
20 |
+
$date_args .= '&rangestart=' . $rangestart;
|
21 |
} else {
|
22 |
$rangestart = '';
|
23 |
}
|
24 |
|
25 |
+
if ( array_key_exists( 'rangeend', $_GET ) ) {
|
26 |
+
$rangeend = esc_attr( $_GET['rangeend'] );
|
27 |
$date_args .= '&rangeend=' . $rangeend;
|
28 |
} else {
|
29 |
$rangeend = '';
|
35 |
$rangeend
|
36 |
);
|
37 |
|
38 |
+
$rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime );
|
39 |
+
$rangeenddate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime );
|
40 |
|
41 |
+
if ( array_key_exists( 'referr', $_GET ) ) {
|
42 |
$referr = $_GET['referr'];
|
43 |
$title = $_GET['referr'];
|
44 |
$referr_field = '&referr=' . $referr;
|
60 |
)
|
61 |
);
|
62 |
|
63 |
+
$total = count( $result );
|
64 |
} else {
|
65 |
$result = $wpdb->get_results(
|
66 |
$wpdb->prepare(
|
73 |
$urls = array();
|
74 |
foreach ( $result as $item ) {
|
75 |
|
76 |
+
$url = parse_url( $item->referred );
|
77 |
|
78 |
+
if ( empty( $url['host'] ) || stristr( get_bloginfo( 'url' ), $url['host'] ) ) {
|
79 |
continue;
|
80 |
}
|
81 |
|
82 |
$urls[] = $url['scheme'] . '://' . $url['host'];
|
83 |
}
|
84 |
|
85 |
+
$get_urls = array_count_values( $urls );
|
86 |
|
87 |
+
$total = count( $get_urls );
|
88 |
}
|
89 |
|
90 |
?>
|
91 |
<div class="wrap">
|
92 |
+
<h2><?php _e( 'Top Referring Sites', 'wp-statistics' ); ?></h2>
|
93 |
|
94 |
+
<div><?php wp_statistics_date_range_selector(
|
95 |
WP_Statistics::$page['referrers'],
|
96 |
$daysToDisplay,
|
97 |
null,
|
99 |
$referr_field
|
100 |
); ?></div>
|
101 |
|
102 |
+
<div class="clear"/>
|
103 |
|
104 |
+
<ul class="subsubsub">
|
105 |
<?php if ( $referr ) { ?>
|
106 |
+
<li class="all"><a <?php if ( ! $referr ) {
|
107 |
echo 'class="current"';
|
108 |
} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e(
|
109 |
'All',
|
110 |
'wp-statistics'
|
111 |
); ?></a>
|
112 |
+
</li>
|
113 |
+
|
|
114 |
+
<li>
|
115 |
+
<a class="current"
|
116 |
+
href="?page=<?php echo WP_Statistics::$page['referrers']; ?>&referr=<?php echo $WP_Statistics->html_sanitize_referrer(
|
117 |
$referr
|
118 |
+
) . $date_args; ?>"> <?php echo htmlentities( $title, ENT_QUOTES ); ?>
|
119 |
+
<span class="count">(<?php echo $total; ?>)</span></a></li>
|
120 |
<?php } else { ?>
|
121 |
+
<li class="all"><a <?php if ( ! $referr ) {
|
122 |
echo 'class="current"';
|
123 |
} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e(
|
124 |
'All',
|
125 |
'wp-statistics'
|
126 |
); ?>
|
127 |
+
<span class="count">(<?php echo $total; ?>)</span></a></li>
|
128 |
<?php } ?>
|
129 |
+
</ul>
|
130 |
+
<div class="postbox-container" id="last-log">
|
131 |
+
<div class="metabox-holder">
|
132 |
+
<div class="meta-box-sortables">
|
133 |
+
<div class="postbox">
|
134 |
<?php if ( $referr ) {
|
135 |
$paneltitle = sprintf(
|
136 |
+
__( 'Referring site: %s', 'wp-statistics' ),
|
137 |
+
$WP_Statistics->html_sanitize_referrer( $referr )
|
138 |
);
|
139 |
} else {
|
140 |
+
$paneltitle = __( 'Top Referring Sites', 'wp-statistics' );
|
141 |
}; ?>
|
142 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
143 |
<span class="screen-reader-text"><?php printf(
|
144 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
145 |
$paneltitle
|
146 |
); ?></span>
|
147 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
148 |
+
</button>
|
149 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
150 |
|
151 |
+
<div class="inside">
|
152 |
<?php
|
153 |
echo "<div class='log-latest'>";
|
154 |
|
176 |
$end = $Pagination->getEntryEnd();
|
177 |
|
178 |
if ( $referr ) {
|
179 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
180 |
$result = $wpdb->get_results(
|
181 |
$wpdb->prepare(
|
182 |
"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",
|
194 |
echo "<div class='log-referred'><a href='?page=" .
|
195 |
WP_Statistics::$page['overview'] .
|
196 |
"&type=last-all-visitor&ip={$item->ip}'>" .
|
197 |
+
wp_statistics_icons( 'dashicons-visibility', 'visibility' ) .
|
198 |
"{$item->ip}</a></div>";
|
199 |
echo "<div class='log-ip'>" .
|
200 |
+
date( get_option( 'date_format' ), strtotime( $item->last_counter ) ) .
|
201 |
" - <a href='http://www.geoiptool.com/en/?IP={$item->ip}' target='_blank'>{$item->ip}</a></div>";
|
202 |
echo "<div class='clear'></div>";
|
203 |
echo "<a class='show-map' title='" .
|
204 |
+
__( 'Map', 'wp-statistics' ) .
|
205 |
"'><div class='dashicons dashicons-location-alt'></div></a>";
|
206 |
|
207 |
if ( array_search(
|
208 |
+
strtolower( $item->agent ),
|
209 |
array(
|
210 |
'chrome',
|
211 |
'firefox',
|
216 |
) !== false
|
217 |
) {
|
218 |
$agent = "<img src='" .
|
219 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
220 |
$item->agent .
|
221 |
".png' class='log-tools' title='{$item->agent}'/>";
|
222 |
} else {
|
226 |
echo "<div class='log-agent'><a href='?page=" .
|
227 |
WP_Statistics::$page['overview'] .
|
228 |
"&type=last-all-visitor&agent={$item->agent}'>{$agent}</a>";
|
229 |
+
echo $WP_Statistics->get_referrer_link( $item->referred, 100 ) . '</div>';
|
230 |
echo "</div>";
|
231 |
}
|
232 |
} else {
|
233 |
+
arsort( $get_urls );
|
234 |
+
$get_urls = array_slice( $get_urls, $start, $end );
|
235 |
|
236 |
$i = $start;
|
237 |
foreach ( $get_urls as $items => $value ) {
|
238 |
+
$i ++;
|
239 |
+
$referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
|
240 |
+
$referrer_html = parse_url( $referrer_html )['host'];
|
241 |
echo "<div class='log-item'>";
|
242 |
echo "<div class='log-referred'>{$i} - <a href='?page=" .
|
243 |
WP_Statistics::$page['referrers'] .
|
248 |
$referrer_html .
|
249 |
"</a></div>";
|
250 |
echo "<div class='log-ip'>" .
|
251 |
+
__( 'References', 'wp-statistics' ) .
|
252 |
': ' .
|
253 |
+
number_format_i18n( $value ) .
|
254 |
'</div>';
|
255 |
echo "<div class='clear'></div>";
|
256 |
echo "<div class='log-url'>" .
|
257 |
+
$WP_Statistics->get_referrer_link( $items, 100 ) .
|
258 |
'</div>';
|
259 |
echo "</div>";
|
260 |
}
|
263 |
|
264 |
echo '</div>';
|
265 |
?>
|
266 |
+
</div>
|
267 |
+
</div>
|
268 |
|
269 |
+
<div class="pagination-log">
|
270 |
<?php if ( $total > 0 ) {
|
271 |
echo $Pagination->display(); ?>
|
272 |
+
<p id="result-log"><?php printf(
|
273 |
+
__( 'Page %1$s of %2$s', 'wp-statistics' ),
|
274 |
$Pagination->getCurrentPage(),
|
275 |
$Pagination->getTotalPages()
|
276 |
); ?></p>
|
277 |
<?php } ?>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
</div>
|
282 |
</div>
|
includes/log/top-visitors.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
</script>
|
6 |
<?php
|
7 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
8 |
include( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/top.visitors.php' );
|
9 |
?>
|
10 |
<div class="wrap">
|
11 |
-
|
12 |
<?php
|
13 |
-
wp_enqueue_script('jquery-ui-datepicker');
|
14 |
wp_register_style(
|
15 |
'jquery-ui-smoothness-css',
|
16 |
WP_Statistics::$reg['plugin-url'] . 'assets/css/jquery-ui-smoothness.min.css'
|
17 |
);
|
18 |
-
wp_enqueue_style('jquery-ui-smoothness-css');
|
19 |
|
20 |
$current = 0;
|
21 |
|
22 |
-
$statsdate = $WP_Statistics->Current_Date('m/d/Y', '-' . $current);
|
23 |
|
24 |
-
if ( array_key_exists('statsdate', $_GET) ) {
|
25 |
$statsdate = $_GET['statsdate'];
|
26 |
}
|
27 |
|
28 |
echo '<br><form method="get">' . "\r\n";
|
29 |
|
30 |
-
echo ' ' . __('Date', 'wp-statistics') . ': ';
|
31 |
|
32 |
echo '<input type="hidden" name="page" value="' . WP_Statistics::$page['top-visitors'] . '">' . "\r\n";
|
33 |
echo '<input type="text" size="10" name="statsdate" id="statsdate" value="' .
|
34 |
-
htmlentities($statsdate, ENT_QUOTES) .
|
35 |
'" placeholder="' .
|
36 |
-
__('MM/DD/YYYY', 'wp-statistics') .
|
37 |
'"> <input type="submit" value="' .
|
38 |
-
__('Go', 'wp-statistics') .
|
39 |
'" class="button-primary">' .
|
40 |
"\r\n";
|
41 |
|
@@ -44,21 +44,21 @@ include( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/top.visitors.
|
|
44 |
echo '<script>jQuery(function() { jQuery( "#statsdate" ).datepicker(); } );</script>' . "\r\n";
|
45 |
|
46 |
?>
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
<?php $paneltitle = __('Top Visitors', 'wp-statistics'); ?>
|
52 |
-
|
53 |
<span class="screen-reader-text"><?php printf(
|
54 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
55 |
$paneltitle
|
56 |
); ?></span>
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
|
63 |
<?php wp_statistics_generate_top_visitors_postbox_content(
|
64 |
$ISOCountryCode,
|
@@ -67,9 +67,9 @@ include( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/top.visitors.
|
|
67 |
false
|
68 |
); ?>
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
</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( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/top.visitors.php' );
|
9 |
?>
|
10 |
<div class="wrap">
|
11 |
+
<h2><?php _e( 'Top 100 Visitors Today', 'wp-statistics' ); ?></h2>
|
12 |
<?php
|
13 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
14 |
wp_register_style(
|
15 |
'jquery-ui-smoothness-css',
|
16 |
WP_Statistics::$reg['plugin-url'] . 'assets/css/jquery-ui-smoothness.min.css'
|
17 |
);
|
18 |
+
wp_enqueue_style( 'jquery-ui-smoothness-css' );
|
19 |
|
20 |
$current = 0;
|
21 |
|
22 |
+
$statsdate = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
|
23 |
|
24 |
+
if ( array_key_exists( 'statsdate', $_GET ) ) {
|
25 |
$statsdate = $_GET['statsdate'];
|
26 |
}
|
27 |
|
28 |
echo '<br><form method="get">' . "\r\n";
|
29 |
|
30 |
+
echo ' ' . __( 'Date', 'wp-statistics' ) . ': ';
|
31 |
|
32 |
echo '<input type="hidden" name="page" value="' . WP_Statistics::$page['top-visitors'] . '">' . "\r\n";
|
33 |
echo '<input type="text" size="10" name="statsdate" id="statsdate" value="' .
|
34 |
+
htmlentities( $statsdate, ENT_QUOTES ) .
|
35 |
'" placeholder="' .
|
36 |
+
__( 'MM/DD/YYYY', 'wp-statistics' ) .
|
37 |
'"> <input type="submit" value="' .
|
38 |
+
__( 'Go', 'wp-statistics' ) .
|
39 |
'" class="button-primary">' .
|
40 |
"\r\n";
|
41 |
|
44 |
echo '<script>jQuery(function() { jQuery( "#statsdate" ).datepicker(); } );</script>' . "\r\n";
|
45 |
|
46 |
?>
|
47 |
+
<div class="postbox-container" id="last-log" style="width: 100%;">
|
48 |
+
<div class="metabox-holder">
|
49 |
+
<div class="meta-box-sortables">
|
50 |
+
<div class="postbox">
|
51 |
+
<?php $paneltitle = __( 'Top Visitors', 'wp-statistics' ); ?>
|
52 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
53 |
<span class="screen-reader-text"><?php printf(
|
54 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
55 |
$paneltitle
|
56 |
); ?></span>
|
57 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
58 |
+
</button>
|
59 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></h2>
|
60 |
|
61 |
+
<div class="inside">
|
62 |
|
63 |
<?php wp_statistics_generate_top_visitors_postbox_content(
|
64 |
$ISOCountryCode,
|
67 |
false
|
68 |
); ?>
|
69 |
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
</div>
|
includes/log/widgets/about.php
CHANGED
@@ -3,34 +3,34 @@ function wp_statistics_generate_about_postbox_content() {
|
|
3 |
|
4 |
global $wpdb, $WP_Statistics;
|
5 |
?>
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
'Rate and Review',
|
16 |
'wp-statistics'
|
17 |
); ?></a>
|
18 |
-
|
19 |
<?php
|
20 |
if ( current_user_can(
|
21 |
-
wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'))
|
22 |
) ) {
|
23 |
?>
|
24 |
-
|
25 |
-
|
26 |
'More Information',
|
27 |
'wp-statistics'
|
28 |
); ?></a>
|
29 |
-
|
30 |
<?php
|
31 |
}
|
32 |
?>
|
33 |
-
|
34 |
<?php
|
35 |
}
|
36 |
|
3 |
|
4 |
global $wpdb, $WP_Statistics;
|
5 |
?>
|
6 |
+
<div style="text-align: center;">
|
7 |
+
<a href="http://wp-statistics.com" target="_blank"><img
|
8 |
+
src="<?php echo plugins_url( 'wp-statistics/assets/images/logo-250.png' ); ?>"></a>
|
9 |
+
</div>
|
10 |
|
11 |
+
<div id="about-links" style="text-align: center;">
|
12 |
+
<p><a href="http://wp-statistics.com" target="_blank"><?php _e( 'Website', 'wp-statistics' ); ?></a></p>
|
13 |
+
| <p>
|
14 |
+
<a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank"><?php _e(
|
15 |
'Rate and Review',
|
16 |
'wp-statistics'
|
17 |
); ?></a>
|
18 |
+
</p>
|
19 |
<?php
|
20 |
if ( current_user_can(
|
21 |
+
wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) )
|
22 |
) ) {
|
23 |
?>
|
24 |
+
| <p>
|
25 |
+
<a href="?page=<?php echo WP_Statistics::$page['settings']; ?>&tab=about"><?php _e(
|
26 |
'More Information',
|
27 |
'wp-statistics'
|
28 |
); ?></a>
|
29 |
+
</p>
|
30 |
<?php
|
31 |
}
|
32 |
?>
|
33 |
+
</div>
|
34 |
<?php
|
35 |
}
|
36 |
|
includes/log/widgets/browsers.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
function wp_statistics_generate_browsers_postbox_content() {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
-
$id = 'browser-stats-' . rand(111, 999);
|
5 |
$Browsers = wp_statistics_ua_list();
|
6 |
$BrowserVisits = array();
|
7 |
$total = 0;
|
@@ -11,66 +11,66 @@ function wp_statistics_generate_browsers_postbox_content() {
|
|
11 |
$topten_browser_value = array();
|
12 |
|
13 |
foreach ( $Browsers as $Browser ) {
|
14 |
-
$BrowserVisits[ $Browser ] = wp_statistics_useragent($Browser);
|
15 |
-
$total
|
16 |
}
|
17 |
|
18 |
-
arsort($BrowserVisits);
|
19 |
|
20 |
foreach ( $BrowserVisits as $key => $value ) {
|
21 |
$topten += $value;
|
22 |
-
$count++;
|
23 |
if ( $count > 9 ) {
|
24 |
break;
|
25 |
}
|
26 |
|
27 |
$topten_browser_name[] = "'" . $key . "'";
|
28 |
$topten_browser_value[] = $value;
|
29 |
-
$topten_browser_color[] = wp_statistics_generate_rgba_color($count, '0.4');
|
30 |
}
|
31 |
|
32 |
if ( $topten_browser_name and $topten_browser_value ) {
|
33 |
-
$topten_browser_name[] = "'" . __('Other', 'wp-statistics') . "'";
|
34 |
$topten_browser_value[] = ( $total - $topten );
|
35 |
-
$topten_browser_color[] = wp_statistics_generate_rgba_color(10, '0.4');
|
36 |
}
|
37 |
?>
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
<?php
|
76 |
}
|
1 |
<?php
|
2 |
function wp_statistics_generate_browsers_postbox_content() {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
+
$id = 'browser-stats-' . rand( 111, 999 );
|
5 |
$Browsers = wp_statistics_ua_list();
|
6 |
$BrowserVisits = array();
|
7 |
$total = 0;
|
11 |
$topten_browser_value = array();
|
12 |
|
13 |
foreach ( $Browsers as $Browser ) {
|
14 |
+
$BrowserVisits[ $Browser ] = wp_statistics_useragent( $Browser );
|
15 |
+
$total += $BrowserVisits[ $Browser ];
|
16 |
}
|
17 |
|
18 |
+
arsort( $BrowserVisits );
|
19 |
|
20 |
foreach ( $BrowserVisits as $key => $value ) {
|
21 |
$topten += $value;
|
22 |
+
$count ++;
|
23 |
if ( $count > 9 ) {
|
24 |
break;
|
25 |
}
|
26 |
|
27 |
$topten_browser_name[] = "'" . $key . "'";
|
28 |
$topten_browser_value[] = $value;
|
29 |
+
$topten_browser_color[] = wp_statistics_generate_rgba_color( $count, '0.4' );
|
30 |
}
|
31 |
|
32 |
if ( $topten_browser_name and $topten_browser_value ) {
|
33 |
+
$topten_browser_name[] = "'" . __( 'Other', 'wp-statistics' ) . "'";
|
34 |
$topten_browser_value[] = ( $total - $topten );
|
35 |
+
$topten_browser_color[] = wp_statistics_generate_rgba_color( 10, '0.4' );
|
36 |
}
|
37 |
?>
|
38 |
+
<canvas id="<?php echo $id; ?>" height="220"></canvas>
|
39 |
+
<script>
|
40 |
+
var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d');
|
41 |
+
var ChartJs = new Chart(ctx, {
|
42 |
+
type: 'pie',
|
43 |
+
data: {
|
44 |
+
labels: [<?php echo implode( ', ', $topten_browser_name ); ?>],
|
45 |
+
datasets: [{
|
46 |
+
label: '<?php _e( 'Browsers', 'wp-statistics' ); ?>',
|
47 |
+
data: [<?php echo implode( ', ', $topten_browser_value ); ?>],
|
48 |
+
backgroundColor: [<?php echo implode( ', ', $topten_browser_color ); ?>],
|
49 |
+
}]
|
50 |
+
},
|
51 |
+
options: {
|
52 |
+
responsive: true,
|
53 |
+
legend: {
|
54 |
+
position: 'bottom',
|
55 |
+
},
|
56 |
+
animation: {
|
57 |
+
duration: 0,
|
58 |
+
},
|
59 |
+
tooltips: {
|
60 |
+
callbacks: {
|
61 |
+
label: function (tooltipItem, data) {
|
62 |
+
var dataset = data.datasets[tooltipItem.datasetIndex];
|
63 |
+
var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) {
|
64 |
+
return previousValue + currentValue;
|
65 |
+
});
|
66 |
+
var currentValue = dataset.data[tooltipItem.index];
|
67 |
+
var precentage = Math.floor(((currentValue / total) * 100) + 0.5);
|
68 |
+
return precentage + "% - " + data.labels[tooltipItem.index];
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
});
|
74 |
+
</script>
|
75 |
<?php
|
76 |
}
|
includes/log/widgets/countries.php
CHANGED
@@ -3,29 +3,29 @@ function wp_statistics_generate_countries_postbox_content() {
|
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
5 |
?>
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
<?php
|
14 |
-
$result = $wpdb->get_results("SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` GROUP BY `location` ORDER BY `count` DESC LIMIT 10");
|
15 |
-
$i
|
16 |
foreach ( $result as $item ) {
|
17 |
-
$i++;
|
18 |
-
$item->location = strtoupper($item->location);
|
19 |
echo "<tr>";
|
20 |
echo "<td style='text-align: left'>$i</td>";
|
21 |
echo "<td style='text-align: left'><img src='" .
|
22 |
-
plugins_url('wp-statistics/assets/images/flags/' . $item->location . '.png') .
|
23 |
"' title='{$ISOCountryCode[$item->location]}'/></td>";
|
24 |
echo "<td style='text-align: left !important'>{$ISOCountryCode[$item->location]}</td>";
|
25 |
-
echo "<td style='text-align: left !important'>" . number_format_i18n($item->count) . "</td>";
|
26 |
echo "</tr>";
|
27 |
}
|
28 |
?>
|
29 |
-
|
30 |
<?php
|
31 |
}
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
$ISOCountryCode = $WP_Statistics->get_country_codes();
|
5 |
?>
|
6 |
+
<table width="100%" class="widefat table-stats" id="last-referrer">
|
7 |
+
<tr>
|
8 |
+
<td width="10%" style='text-align: left'><?php _e( 'Rank', 'wp-statistics' ); ?></td>
|
9 |
+
<td width="10%" style='text-align: left'><?php _e( 'Flag', 'wp-statistics' ); ?></td>
|
10 |
+
<td width="40%" style='text-align: left'><?php _e( 'Country', 'wp-statistics' ); ?></td>
|
11 |
+
<td width="40%" style='text-align: left'><?php _e( 'Visitor Count', 'wp-statistics' ); ?></td>
|
12 |
+
</tr>
|
13 |
<?php
|
14 |
+
$result = $wpdb->get_results( "SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` GROUP BY `location` ORDER BY `count` DESC LIMIT 10" );
|
15 |
+
$i = 0;
|
16 |
foreach ( $result as $item ) {
|
17 |
+
$i ++;
|
18 |
+
$item->location = strtoupper( $item->location );
|
19 |
echo "<tr>";
|
20 |
echo "<td style='text-align: left'>$i</td>";
|
21 |
echo "<td style='text-align: left'><img src='" .
|
22 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $item->location . '.png' ) .
|
23 |
"' title='{$ISOCountryCode[$item->location]}'/></td>";
|
24 |
echo "<td style='text-align: left !important'>{$ISOCountryCode[$item->location]}</td>";
|
25 |
+
echo "<td style='text-align: left !important'>" . number_format_i18n( $item->count ) . "</td>";
|
26 |
echo "</tr>";
|
27 |
}
|
28 |
?>
|
29 |
+
</table>
|
30 |
<?php
|
31 |
}
|
includes/log/widgets/hits.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
<?php
|
2 |
function wp_statistics_generate_hits_postbox_content( $size = '300', $days = 20 ) {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
-
$id = 'visits-stats-' . rand(111, 999);
|
5 |
$visitors = array();
|
6 |
$visits = array();
|
7 |
|
8 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
9 |
-
$date[] = "'" . $WP_Statistics->Current_Date('M j', '-' . $i) . "'";
|
10 |
}
|
11 |
|
12 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
13 |
-
$visitors[] = wp_statistics_visitor('-' . $i, true);
|
14 |
}
|
15 |
|
16 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
17 |
-
$visits[] = wp_statistics_visit('-' . $i, true);
|
18 |
}
|
19 |
?>
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
<?php } ?>
|
38 |
<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?>
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
<?php } ?>
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
<?php
|
77 |
}
|
1 |
<?php
|
2 |
function wp_statistics_generate_hits_postbox_content( $size = '300', $days = 20 ) {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
+
$id = 'visits-stats-' . rand( 111, 999 );
|
5 |
$visitors = array();
|
6 |
$visits = array();
|
7 |
|
8 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
9 |
+
$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'";
|
10 |
}
|
11 |
|
12 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
13 |
+
$visitors[] = wp_statistics_visitor( '-' . $i, true );
|
14 |
}
|
15 |
|
16 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
17 |
+
$visits[] = wp_statistics_visit( '-' . $i, true );
|
18 |
}
|
19 |
?>
|
20 |
+
<canvas id="<?php echo $id; ?>" height="<?php echo $size; ?>"></canvas>
|
21 |
+
<script>
|
22 |
+
var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d');
|
23 |
+
var ChartJs = new Chart(ctx, {
|
24 |
+
type: 'line',
|
25 |
+
data: {
|
26 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
27 |
+
datasets: [
|
28 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
29 |
+
{
|
30 |
+
label: '<?php _e( 'Visitors', 'wp-statistics' ); ?>',
|
31 |
+
data: [<?php echo implode( ',', $visitors ); ?>],
|
32 |
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
33 |
+
borderColor: 'rgba(255, 99, 132, 1)',
|
34 |
+
borderWidth: 1,
|
35 |
+
fill: true,
|
36 |
+
},
|
37 |
<?php } ?>
|
38 |
<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?>
|
39 |
+
{
|
40 |
+
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
|
41 |
+
data: [<?php echo implode( ',', $visits ); ?>],
|
42 |
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
43 |
+
borderColor: 'rgba(54, 162, 235, 1)',
|
44 |
+
borderWidth: 1,
|
45 |
+
fill: true,
|
46 |
+
},
|
47 |
<?php } ?>
|
48 |
+
]
|
49 |
+
},
|
50 |
+
options: {
|
51 |
+
responsive: true,
|
52 |
+
legend: {
|
53 |
+
position: 'bottom',
|
54 |
+
},
|
55 |
+
animation: {
|
56 |
+
duration: 0,
|
57 |
+
},
|
58 |
+
title: {
|
59 |
+
display: true,
|
60 |
+
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $days ); ?>'
|
61 |
+
},
|
62 |
+
tooltips: {
|
63 |
+
mode: 'index',
|
64 |
+
intersect: false,
|
65 |
+
},
|
66 |
+
scales: {
|
67 |
+
yAxes: [{
|
68 |
+
ticks: {
|
69 |
+
beginAtZero: true
|
70 |
+
}
|
71 |
+
}]
|
72 |
+
}
|
73 |
+
}
|
74 |
+
});
|
75 |
+
</script>
|
76 |
<?php
|
77 |
}
|
includes/log/widgets/jqv.map.php
CHANGED
@@ -3,17 +3,17 @@ 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 |
-
|
8 |
|
9 |
<?php $result = $wpdb->get_row(
|
10 |
"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'"
|
11 |
); ?>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
<?php
|
19 |
$result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" );
|
@@ -84,29 +84,29 @@ function wp_statistics_generate_map_postbox_content( $ISOCountryCode ) {
|
|
84 |
|
85 |
$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 ) );
|
86 |
?>
|
87 |
-
|
88 |
-
|
89 |
<?php
|
90 |
}
|
91 |
?>
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
<?php
|
111 |
}
|
112 |
}
|
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(
|
10 |
"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'"
|
11 |
); ?>
|
12 |
+
<script type="text/javascript">
|
13 |
+
var country_pin = Array();
|
14 |
+
var country_color = Array();
|
15 |
|
16 |
+
jQuery(document).ready(function () {
|
17 |
|
18 |
<?php
|
19 |
$result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" );
|
84 |
|
85 |
$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 ) );
|
86 |
?>
|
87 |
+
country_pin['<?php echo $markets['location'];?>'] = "<div class='map-html-marker'><?php echo $flag . $summary . '<hr />' . $last_five; ?></div>";
|
88 |
+
country_color['<?php echo $markets['location'];?>'] = "<?php echo $color;?>";
|
89 |
<?php
|
90 |
}
|
91 |
?>
|
92 |
+
var data_total = <?php echo $final_total;?>;
|
93 |
+
|
94 |
+
jQuery('#map_canvas').vectorMap({
|
95 |
+
map: 'world_en',
|
96 |
+
colors: country_color,
|
97 |
+
onLabelShow: function (element, label, code) {
|
98 |
+
if (country_pin[code] !== undefined) {
|
99 |
+
label.html(country_pin[code]);
|
100 |
+
}
|
101 |
+
else {
|
102 |
+
label.html(label.html() + ' [0]<hr />');
|
103 |
+
}
|
104 |
+
},
|
105 |
+
});
|
106 |
+
|
107 |
+
|
108 |
+
});
|
109 |
+
</script>
|
110 |
<?php
|
111 |
}
|
112 |
}
|
includes/log/widgets/page.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/**
|
3 |
* @param $pageuri
|
4 |
* @param $pageid
|
5 |
-
* @param int
|
6 |
-
* @param null
|
7 |
* @param string $rangestart
|
8 |
* @param string $rangeend
|
9 |
*/
|
@@ -17,21 +17,21 @@ function wp_statistics_generate_page_postbox_content(
|
|
17 |
) {
|
18 |
GLOBAL $WP_Statistics;
|
19 |
|
20 |
-
if ( ! $WP_Statistics->get_option('pages') ) {
|
21 |
return;
|
22 |
}
|
23 |
|
24 |
if ( $chart_title == null ) {
|
25 |
-
$chart_title = __('Page Trending Stats', 'wp-statistics');
|
26 |
}
|
27 |
|
28 |
if ( $pageuri && ! $pageid ) {
|
29 |
-
$pageid = wp_statistics_uri_to_id($pageuri);
|
30 |
}
|
31 |
|
32 |
-
$post = get_post($pageid);
|
33 |
-
if ( is_object($post) ) {
|
34 |
-
$title = esc_html($post->post_title);
|
35 |
} else {
|
36 |
$title = "";
|
37 |
}
|
@@ -46,58 +46,58 @@ function wp_statistics_generate_page_postbox_content(
|
|
46 |
$rangestart,
|
47 |
$rangeend
|
48 |
);
|
49 |
-
$daysInThePast = round(( time() - $rangeend_utime ) / 86400, 0);
|
50 |
|
51 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
52 |
-
$date[] = "'" . $WP_Statistics->Current_Date('M j', '-' . $i) . "'";
|
53 |
}
|
54 |
|
55 |
-
for ( $i = $daysToDisplay; $i >= 0; $i-- ) {
|
56 |
-
$stats[] = wp_statistics_pages('-' . ( $i + $daysInThePast ), $pageuri, $pageid);
|
57 |
}
|
58 |
?>
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
<?php } ?>
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
<?php
|
103 |
}
|
2 |
/**
|
3 |
* @param $pageuri
|
4 |
* @param $pageid
|
5 |
+
* @param int $days
|
6 |
+
* @param null $chart_title
|
7 |
* @param string $rangestart
|
8 |
* @param string $rangeend
|
9 |
*/
|
17 |
) {
|
18 |
GLOBAL $WP_Statistics;
|
19 |
|
20 |
+
if ( ! $WP_Statistics->get_option( 'pages' ) ) {
|
21 |
return;
|
22 |
}
|
23 |
|
24 |
if ( $chart_title == null ) {
|
25 |
+
$chart_title = __( 'Page Trending Stats', 'wp-statistics' );
|
26 |
}
|
27 |
|
28 |
if ( $pageuri && ! $pageid ) {
|
29 |
+
$pageid = wp_statistics_uri_to_id( $pageuri );
|
30 |
}
|
31 |
|
32 |
+
$post = get_post( $pageid );
|
33 |
+
if ( is_object( $post ) ) {
|
34 |
+
$title = esc_html( $post->post_title );
|
35 |
} else {
|
36 |
$title = "";
|
37 |
}
|
46 |
$rangestart,
|
47 |
$rangeend
|
48 |
);
|
49 |
+
$daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 );
|
50 |
|
51 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
52 |
+
$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'";
|
53 |
}
|
54 |
|
55 |
+
for ( $i = $daysToDisplay; $i >= 0; $i -- ) {
|
56 |
+
$stats[] = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $pageuri, $pageid );
|
57 |
}
|
58 |
?>
|
59 |
+
<canvas id="visits-stats" height="80"></canvas>
|
60 |
+
<script>
|
61 |
+
var ctx = document.getElementById("visits-stats").getContext('2d');
|
62 |
+
var ChartJs = new Chart(ctx, {
|
63 |
+
type: 'line',
|
64 |
+
data: {
|
65 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
66 |
+
datasets: [
|
67 |
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
|
68 |
+
{
|
69 |
+
label: '<?php echo $title; ?>',
|
70 |
+
data: [<?php echo implode( ',', $stats ); ?>],
|
71 |
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
72 |
+
borderColor: 'rgba(255, 99, 132, 1)',
|
73 |
+
borderWidth: 1,
|
74 |
+
fill: true,
|
75 |
+
},
|
76 |
<?php } ?>
|
77 |
+
]
|
78 |
+
},
|
79 |
+
options: {
|
80 |
+
responsive: true,
|
81 |
+
legend: {
|
82 |
+
position: 'bottom',
|
83 |
+
},
|
84 |
+
title: {
|
85 |
+
display: true,
|
86 |
+
text: '<?php _e( 'Number of Hits', 'wp-statistics' ); ?>'
|
87 |
+
},
|
88 |
+
tooltips: {
|
89 |
+
mode: 'index',
|
90 |
+
intersect: false,
|
91 |
+
},
|
92 |
+
scales: {
|
93 |
+
yAxes: [{
|
94 |
+
ticks: {
|
95 |
+
beginAtZero: true
|
96 |
+
}
|
97 |
+
}]
|
98 |
+
}
|
99 |
+
}
|
100 |
+
});
|
101 |
+
</script>
|
102 |
<?php
|
103 |
}
|
includes/log/widgets/pages.php
CHANGED
@@ -21,30 +21,30 @@ function wp_statistics_generate_pages_postbox_content() {
|
|
21 |
$counter += 1;
|
22 |
echo '<div class="log-item">';
|
23 |
// Lookup the post title.
|
24 |
-
$post = get_post($item->id);
|
25 |
-
if ( is_object($post) ) {
|
26 |
$title = $post->post_title;
|
27 |
} else {
|
28 |
if ( $item->uri == '/' ) {
|
29 |
$title = get_bloginfo();
|
30 |
} else {
|
31 |
-
$title = '[' . __('No page title found', 'wp-statistics') . ']';
|
32 |
}
|
33 |
}
|
34 |
echo "<div class=\"log-page-title\">{$counter} - {$title}</div>";
|
35 |
echo '<div class="right-div">' .
|
36 |
-
__('Visits', 'wp-statistics') .
|
37 |
': <a href="?page=' .
|
38 |
WP_Statistics::$page['pages'] .
|
39 |
'&page-uri=' .
|
40 |
-
htmlentities($item->uri, ENT_QUOTES) .
|
41 |
'">' .
|
42 |
-
number_format_i18n($item->count_sum) .
|
43 |
'</a></div>';
|
44 |
echo '<div><a href="' .
|
45 |
-
htmlentities($site_url . $item->uri, ENT_QUOTES) .
|
46 |
'">' .
|
47 |
-
htmlentities(urldecode($item->uri), ENT_QUOTES) .
|
48 |
'</a></div>';
|
49 |
echo '</div>';
|
50 |
|
21 |
$counter += 1;
|
22 |
echo '<div class="log-item">';
|
23 |
// Lookup the post title.
|
24 |
+
$post = get_post( $item->id );
|
25 |
+
if ( is_object( $post ) ) {
|
26 |
$title = $post->post_title;
|
27 |
} else {
|
28 |
if ( $item->uri == '/' ) {
|
29 |
$title = get_bloginfo();
|
30 |
} else {
|
31 |
+
$title = '[' . __( 'No page title found', 'wp-statistics' ) . ']';
|
32 |
}
|
33 |
}
|
34 |
echo "<div class=\"log-page-title\">{$counter} - {$title}</div>";
|
35 |
echo '<div class="right-div">' .
|
36 |
+
__( 'Visits', 'wp-statistics' ) .
|
37 |
': <a href="?page=' .
|
38 |
WP_Statistics::$page['pages'] .
|
39 |
'&page-uri=' .
|
40 |
+
htmlentities( $item->uri, ENT_QUOTES ) .
|
41 |
'">' .
|
42 |
+
number_format_i18n( $item->count_sum ) .
|
43 |
'</a></div>';
|
44 |
echo '<div><a href="' .
|
45 |
+
htmlentities( $site_url . $item->uri, ENT_QUOTES ) .
|
46 |
'">' .
|
47 |
+
htmlentities( urldecode( $item->uri ), ENT_QUOTES ) .
|
48 |
'</a></div>';
|
49 |
echo '</div>';
|
50 |
|
includes/log/widgets/quickstats.php
CHANGED
@@ -3,284 +3,283 @@ function wp_statistics_generate_quickstats_postbox_content( $search_engines, $se
|
|
3 |
|
4 |
global $wpdb, $WP_Statistics;
|
5 |
|
6 |
-
$show_visitors = $WP_Statistics->get_option('visitor');
|
7 |
?>
|
8 |
-
|
9 |
-
|
10 |
-
<?php if ( $WP_Statistics->get_option('useronline') ) { ?>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
<span><a
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
</tr>
|
19 |
<?php }
|
20 |
|
21 |
-
if ( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') ) {
|
22 |
?>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
_e('Visitors', 'wp-statistics');
|
27 |
} else {
|
28 |
echo '';
|
29 |
} ?></th>
|
30 |
-
|
31 |
-
_e('Visits', 'wp-statistics');
|
32 |
} else {
|
33 |
echo '';
|
34 |
} ?></th>
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
echo '<a href="admin.php?page=' .
|
41 |
WP_Statistics::$page['visitors'] .
|
42 |
'&hitdays=1"><span>' .
|
43 |
-
number_format_i18n(wp_statistics_visitor('today', null, true)) .
|
44 |
'</span></a>';
|
45 |
} else {
|
46 |
echo '';
|
47 |
} ?></th>
|
48 |
-
|
49 |
echo '<a href="admin.php?page=' .
|
50 |
WP_Statistics::$page['hits'] .
|
51 |
'&hitdays=1"><span>' .
|
52 |
-
number_format_i18n(wp_statistics_visit('today')) .
|
53 |
'</span></a>';
|
54 |
} else {
|
55 |
echo '';
|
56 |
} ?></th>
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
echo '<a href="admin.php?page=' .
|
63 |
WP_Statistics::$page['visitors'] .
|
64 |
'&hitdays=1"><span>' .
|
65 |
-
number_format_i18n(wp_statistics_visitor('yesterday', null, true)) .
|
66 |
'</span></a>';
|
67 |
} else {
|
68 |
echo '';
|
69 |
} ?></th>
|
70 |
-
|
71 |
echo '<a href="admin.php?page=' .
|
72 |
WP_Statistics::$page['hits'] .
|
73 |
'&hitdays=1"><span>' .
|
74 |
-
number_format_i18n(wp_statistics_visit('yesterday')) .
|
75 |
'</span></a>';
|
76 |
} else {
|
77 |
echo '';
|
78 |
} ?></th>
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
echo '<a href="admin.php?page=' .
|
85 |
WP_Statistics::$page['visitors'] .
|
86 |
'&hitdays=7"><span>' .
|
87 |
-
number_format_i18n(wp_statistics_visitor('week', null, true)) .
|
88 |
'</span></a>';
|
89 |
} else {
|
90 |
echo '';
|
91 |
} ?></th>
|
92 |
-
|
93 |
echo '<a href="admin.php?page=' .
|
94 |
WP_Statistics::$page['hits'] .
|
95 |
'&hitdays=7"><span>' .
|
96 |
-
number_format_i18n(wp_statistics_visit('week')) .
|
97 |
'</span></a>';
|
98 |
} else {
|
99 |
echo '';
|
100 |
} ?></th>
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
echo '<a href="admin.php?page=' .
|
107 |
WP_Statistics::$page['visitors'] .
|
108 |
'&hitdays=30"><span>' .
|
109 |
-
number_format_i18n(wp_statistics_visitor('month', null, true)) .
|
110 |
'</span></a>';
|
111 |
} else {
|
112 |
echo '';
|
113 |
} ?></th>
|
114 |
-
|
115 |
echo '<a href="admin.php?page=' .
|
116 |
WP_Statistics::$page['hits'] .
|
117 |
'&hitdays=30"><span>' .
|
118 |
-
number_format_i18n(wp_statistics_visit('month')) .
|
119 |
'</span></a>';
|
120 |
} else {
|
121 |
echo '';
|
122 |
} ?></th>
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
echo '<a href="admin.php?page=' .
|
129 |
WP_Statistics::$page['visitors'] .
|
130 |
'&hitdays=365"><span>' .
|
131 |
-
number_format_i18n(wp_statistics_visitor('year', null, true)) .
|
132 |
'</span></a>';
|
133 |
} else {
|
134 |
echo '';
|
135 |
} ?></th>
|
136 |
-
|
137 |
echo '<a href="admin.php?page=' .
|
138 |
WP_Statistics::$page['hits'] .
|
139 |
'&hitdays=365"><span>' .
|
140 |
-
number_format_i18n(wp_statistics_visit('year')) .
|
141 |
'</span></a>';
|
142 |
} else {
|
143 |
echo '';
|
144 |
} ?></th>
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
echo '<a href="admin.php?page=' .
|
151 |
WP_Statistics::$page['visitors'] .
|
152 |
'&hitdays=365"><span>' .
|
153 |
-
number_format_i18n(wp_statistics_visitor('total', null, true)) .
|
154 |
'</span></a>';
|
155 |
} else {
|
156 |
echo '';
|
157 |
} ?></th>
|
158 |
-
|
159 |
echo '<a href="admin.php?page=' .
|
160 |
WP_Statistics::$page['hits'] .
|
161 |
'&hitdays=365"><span>' .
|
162 |
-
number_format_i18n(wp_statistics_visit('total')) .
|
163 |
'</span></a>';
|
164 |
} else {
|
165 |
echo '';
|
166 |
} ?></th>
|
167 |
-
|
168 |
|
169 |
<?php
|
170 |
}
|
171 |
|
172 |
-
if ( $search == true && $WP_Statistics->get_option('visitors') ) {
|
173 |
|
174 |
-
if ( $WP_Statistics->get_option('visitors') ||
|
175 |
-
$WP_Statistics->get_option('visits') ||
|
176 |
-
$WP_Statistics->get_option('useronline')
|
177 |
) {
|
178 |
?>
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
<?php } ?>
|
185 |
-
|
186 |
-
|
187 |
'Search Engine Referrals',
|
188 |
'wp-statistics'
|
189 |
); ?></th>
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
|
198 |
<?php
|
199 |
-
$se_today_total
|
200 |
$se_yesterday_total = 0;
|
201 |
foreach ( $search_engines as $se ) {
|
202 |
?>
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
$se['name'],
|
207 |
'wp-statistics'
|
208 |
); ?>
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$se_today_total
|
213 |
-
echo number_format_i18n($se_temp); ?></span></th>
|
214 |
-
|
215 |
-
$se_yesterday_total
|
216 |
-
echo number_format_i18n($se_temp); ?></span></th>
|
217 |
-
|
218 |
|
219 |
<?php
|
220 |
}
|
221 |
?>
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
<?php
|
236 |
}
|
237 |
|
238 |
if ( $time == true ) {
|
239 |
?>
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
'(Adjustment)',
|
250 |
'wp-statistics'
|
251 |
); ?></a></span>
|
252 |
-
|
253 |
-
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
__('Date: %s', 'wp-statistics'),
|
258 |
'<code dir="ltr">' .
|
259 |
-
$WP_Statistics->Current_Date_i18n(get_option('date_format')) .
|
260 |
'</code>'
|
261 |
); ?></th>
|
262 |
-
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
__('Time: %s', 'wp-statistics'),
|
267 |
'<code dir="ltr">' .
|
268 |
-
$WP_Statistics->Current_Date_i18n(get_option('time_format')) .
|
269 |
'</code>'
|
270 |
); ?></th>
|
271 |
-
|
272 |
<?php } ?>
|
273 |
-
|
274 |
-
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
<?php
|
280 |
|
281 |
// 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.
|
282 |
include( WP_Statistics::$reg['plugin-dir'] . "includes/log/widgets/hits.php" );
|
283 |
|
284 |
-
wp_statistics_generate_hits_postbox_content("220px", 10);
|
285 |
}
|
286 |
|
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( 'Online Users', 'wp-statistics' ); ?>:</th>
|
13 |
+
<th colspan="2" id="th-colspan">
|
14 |
<span><a
|
15 |
+
href="admin.php?page=<?php echo WP_Statistics::$page['online']; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
|
16 |
+
</th>
|
17 |
+
</tr>
|
|
|
18 |
<?php }
|
19 |
|
20 |
+
if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) {
|
21 |
?>
|
22 |
+
<tr>
|
23 |
+
<th width="60%"></th>
|
24 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
25 |
+
_e( 'Visitors', 'wp-statistics' );
|
26 |
} else {
|
27 |
echo '';
|
28 |
} ?></th>
|
29 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
30 |
+
_e( 'Visits', 'wp-statistics' );
|
31 |
} else {
|
32 |
echo '';
|
33 |
} ?></th>
|
34 |
+
</tr>
|
35 |
|
36 |
+
<tr>
|
37 |
+
<th><?php _e( 'Today', 'wp-statistics' ); ?>:</th>
|
38 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
39 |
echo '<a href="admin.php?page=' .
|
40 |
WP_Statistics::$page['visitors'] .
|
41 |
'&hitdays=1"><span>' .
|
42 |
+
number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) .
|
43 |
'</span></a>';
|
44 |
} else {
|
45 |
echo '';
|
46 |
} ?></th>
|
47 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
48 |
echo '<a href="admin.php?page=' .
|
49 |
WP_Statistics::$page['hits'] .
|
50 |
'&hitdays=1"><span>' .
|
51 |
+
number_format_i18n( wp_statistics_visit( 'today' ) ) .
|
52 |
'</span></a>';
|
53 |
} else {
|
54 |
echo '';
|
55 |
} ?></th>
|
56 |
+
</tr>
|
57 |
|
58 |
+
<tr>
|
59 |
+
<th><?php _e( 'Yesterday', 'wp-statistics' ); ?>:</th>
|
60 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
61 |
echo '<a href="admin.php?page=' .
|
62 |
WP_Statistics::$page['visitors'] .
|
63 |
'&hitdays=1"><span>' .
|
64 |
+
number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) .
|
65 |
'</span></a>';
|
66 |
} else {
|
67 |
echo '';
|
68 |
} ?></th>
|
69 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
70 |
echo '<a href="admin.php?page=' .
|
71 |
WP_Statistics::$page['hits'] .
|
72 |
'&hitdays=1"><span>' .
|
73 |
+
number_format_i18n( wp_statistics_visit( 'yesterday' ) ) .
|
74 |
'</span></a>';
|
75 |
} else {
|
76 |
echo '';
|
77 |
} ?></th>
|
78 |
+
</tr>
|
79 |
|
80 |
+
<tr>
|
81 |
+
<th><?php _e( 'Last 7 Days (Week)', 'wp-statistics' ); ?>:</th>
|
82 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
83 |
echo '<a href="admin.php?page=' .
|
84 |
WP_Statistics::$page['visitors'] .
|
85 |
'&hitdays=7"><span>' .
|
86 |
+
number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) .
|
87 |
'</span></a>';
|
88 |
} else {
|
89 |
echo '';
|
90 |
} ?></th>
|
91 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
92 |
echo '<a href="admin.php?page=' .
|
93 |
WP_Statistics::$page['hits'] .
|
94 |
'&hitdays=7"><span>' .
|
95 |
+
number_format_i18n( wp_statistics_visit( 'week' ) ) .
|
96 |
'</span></a>';
|
97 |
} else {
|
98 |
echo '';
|
99 |
} ?></th>
|
100 |
+
</tr>
|
101 |
|
102 |
+
<tr>
|
103 |
+
<th><?php _e( 'Last 30 Days (Month)', 'wp-statistics' ); ?>:</th>
|
104 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
105 |
echo '<a href="admin.php?page=' .
|
106 |
WP_Statistics::$page['visitors'] .
|
107 |
'&hitdays=30"><span>' .
|
108 |
+
number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) .
|
109 |
'</span></a>';
|
110 |
} else {
|
111 |
echo '';
|
112 |
} ?></th>
|
113 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
114 |
echo '<a href="admin.php?page=' .
|
115 |
WP_Statistics::$page['hits'] .
|
116 |
'&hitdays=30"><span>' .
|
117 |
+
number_format_i18n( wp_statistics_visit( 'month' ) ) .
|
118 |
'</span></a>';
|
119 |
} else {
|
120 |
echo '';
|
121 |
} ?></th>
|
122 |
+
</tr>
|
123 |
|
124 |
+
<tr>
|
125 |
+
<th><?php _e( 'Last 365 Days (Year)', 'wp-statistics' ); ?>:</th>
|
126 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
127 |
echo '<a href="admin.php?page=' .
|
128 |
WP_Statistics::$page['visitors'] .
|
129 |
'&hitdays=365"><span>' .
|
130 |
+
number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) .
|
131 |
'</span></a>';
|
132 |
} else {
|
133 |
echo '';
|
134 |
} ?></th>
|
135 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
136 |
echo '<a href="admin.php?page=' .
|
137 |
WP_Statistics::$page['hits'] .
|
138 |
'&hitdays=365"><span>' .
|
139 |
+
number_format_i18n( wp_statistics_visit( 'year' ) ) .
|
140 |
'</span></a>';
|
141 |
} else {
|
142 |
echo '';
|
143 |
} ?></th>
|
144 |
+
</tr>
|
145 |
|
146 |
+
<tr>
|
147 |
+
<th><?php _e( 'Total', 'wp-statistics' ); ?>:</th>
|
148 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
149 |
echo '<a href="admin.php?page=' .
|
150 |
WP_Statistics::$page['visitors'] .
|
151 |
'&hitdays=365"><span>' .
|
152 |
+
number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) .
|
153 |
'</span></a>';
|
154 |
} else {
|
155 |
echo '';
|
156 |
} ?></th>
|
157 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
158 |
echo '<a href="admin.php?page=' .
|
159 |
WP_Statistics::$page['hits'] .
|
160 |
'&hitdays=365"><span>' .
|
161 |
+
number_format_i18n( wp_statistics_visit( 'total' ) ) .
|
162 |
'</span></a>';
|
163 |
} else {
|
164 |
echo '';
|
165 |
} ?></th>
|
166 |
+
</tr>
|
167 |
|
168 |
<?php
|
169 |
}
|
170 |
|
171 |
+
if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) {
|
172 |
|
173 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ||
|
174 |
+
$WP_Statistics->get_option( 'visits' ) ||
|
175 |
+
$WP_Statistics->get_option( 'useronline' )
|
176 |
) {
|
177 |
?>
|
178 |
+
<tr>
|
179 |
+
<th colspan="3"><br>
|
180 |
+
<hr>
|
181 |
+
</th>
|
182 |
+
</tr>
|
183 |
<?php } ?>
|
184 |
+
<tr>
|
185 |
+
<th colspan="3" style="text-align: center;"><?php _e(
|
186 |
'Search Engine Referrals',
|
187 |
'wp-statistics'
|
188 |
); ?></th>
|
189 |
+
</tr>
|
190 |
|
191 |
+
<tr>
|
192 |
+
<th width="60%"></th>
|
193 |
+
<th class="th-center"><?php _e( 'Today', 'wp-statistics' ); ?></th>
|
194 |
+
<th class="th-center"><?php _e( 'Yesterday', 'wp-statistics' ); ?></th>
|
195 |
+
</tr>
|
196 |
|
197 |
<?php
|
198 |
+
$se_today_total = 0;
|
199 |
$se_yesterday_total = 0;
|
200 |
foreach ( $search_engines as $se ) {
|
201 |
?>
|
202 |
+
<tr>
|
203 |
+
<th>
|
204 |
+
<img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e(
|
205 |
$se['name'],
|
206 |
'wp-statistics'
|
207 |
); ?>
|
208 |
+
:
|
209 |
+
</th>
|
210 |
+
<th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' );
|
211 |
+
$se_today_total += $se_temp;
|
212 |
+
echo number_format_i18n( $se_temp ); ?></span></th>
|
213 |
+
<th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' );
|
214 |
+
$se_yesterday_total += $se_temp;
|
215 |
+
echo number_format_i18n( $se_temp ); ?></span></th>
|
216 |
+
</tr>
|
217 |
|
218 |
<?php
|
219 |
}
|
220 |
?>
|
221 |
+
<tr>
|
222 |
+
<th><?php _e( 'Daily Total', 'wp-statistics' ); ?>:</th>
|
223 |
+
<td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span>
|
224 |
+
</td>
|
225 |
+
<td id="th-colspan" class="th-center">
|
226 |
+
<span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td>
|
227 |
+
</tr>
|
228 |
|
229 |
+
<tr>
|
230 |
+
<th><?php _e( 'Total', 'wp-statistics' ); ?>:</th>
|
231 |
+
<th colspan="2" id="th-colspan">
|
232 |
+
<span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th>
|
233 |
+
</tr>
|
234 |
<?php
|
235 |
}
|
236 |
|
237 |
if ( $time == true ) {
|
238 |
?>
|
239 |
+
<tr>
|
240 |
+
<th colspan="3"><br>
|
241 |
+
<hr>
|
242 |
+
</th>
|
243 |
+
</tr>
|
244 |
|
245 |
+
<tr>
|
246 |
+
<th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp-statistics' ); ?>
|
247 |
+
<span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e(
|
248 |
'(Adjustment)',
|
249 |
'wp-statistics'
|
250 |
); ?></a></span>
|
251 |
+
</th>
|
252 |
+
</tr>
|
253 |
|
254 |
+
<tr>
|
255 |
+
<th colspan="3"><?php echo sprintf(
|
256 |
+
__( 'Date: %s', 'wp-statistics' ),
|
257 |
'<code dir="ltr">' .
|
258 |
+
$WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) .
|
259 |
'</code>'
|
260 |
); ?></th>
|
261 |
+
</tr>
|
262 |
|
263 |
+
<tr>
|
264 |
+
<th colspan="3"><?php echo sprintf(
|
265 |
+
__( 'Time: %s', 'wp-statistics' ),
|
266 |
'<code dir="ltr">' .
|
267 |
+
$WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) .
|
268 |
'</code>'
|
269 |
); ?></th>
|
270 |
+
</tr>
|
271 |
<?php } ?>
|
272 |
+
</tbody>
|
273 |
+
</table>
|
274 |
|
275 |
+
<br>
|
276 |
+
<hr width="80%"/>
|
277 |
+
<br>
|
278 |
<?php
|
279 |
|
280 |
// 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.
|
281 |
include( WP_Statistics::$reg['plugin-dir'] . "includes/log/widgets/hits.php" );
|
282 |
|
283 |
+
wp_statistics_generate_hits_postbox_content( "220px", 10 );
|
284 |
}
|
285 |
|
includes/log/widgets/recent.php
CHANGED
@@ -8,11 +8,11 @@ function wp_statistics_generate_recent_postbox_content( $ISOCountryCode, $count
|
|
8 |
|
9 |
echo "<div class='log-latest'>";
|
10 |
|
11 |
-
$dash_icon = wp_statistics_icons('dashicons-visibility', 'visibility');
|
12 |
|
13 |
foreach ( $result as $items ) {
|
14 |
-
if ( substr($items->ip, 0, 6) == '#hash#' ) {
|
15 |
-
$ip_string = __('#hash#', 'wp-statistics');
|
16 |
$map_string = "";
|
17 |
} else {
|
18 |
$ip_string = "<a href='admin.php?page=" .
|
@@ -20,27 +20,27 @@ function wp_statistics_generate_recent_postbox_content( $ISOCountryCode, $count
|
|
20 |
"&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
21 |
$map_string
|
22 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
23 |
-
__('Map', 'wp-statistics') .
|
24 |
"'>" .
|
25 |
-
wp_statistics_icons('dashicons-location-alt', 'map') .
|
26 |
"</a>";
|
27 |
}
|
28 |
|
29 |
echo "<div class='log-item'>";
|
30 |
echo "<div class='log-referred'>{$ip_string}</div>";
|
31 |
-
echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . "</div>";
|
32 |
echo "<div class='clear'></div>";
|
33 |
echo "<div class='log-url'>";
|
34 |
echo $map_string;
|
35 |
|
36 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
37 |
echo "<img src='" .
|
38 |
-
plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') .
|
39 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
40 |
}
|
41 |
|
42 |
if ( array_search(
|
43 |
-
strtolower($items->agent),
|
44 |
array(
|
45 |
"chrome",
|
46 |
"firefox",
|
@@ -51,18 +51,18 @@ function wp_statistics_generate_recent_postbox_content( $ISOCountryCode, $count
|
|
51 |
) !== false
|
52 |
) {
|
53 |
$agent = "<img src='" .
|
54 |
-
plugins_url('wp-statistics/assets/images/') .
|
55 |
$items->agent .
|
56 |
".png' class='log-tools' title='{$items->agent}'/>";
|
57 |
} else {
|
58 |
-
$agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
|
59 |
}
|
60 |
|
61 |
echo "<a href='?page=" .
|
62 |
WP_Statistics::$page['overview'] .
|
63 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
64 |
|
65 |
-
echo $WP_Statistics->get_referrer_link($items->referred);
|
66 |
|
67 |
echo "</div>";
|
68 |
echo "</div>";
|
8 |
|
9 |
echo "<div class='log-latest'>";
|
10 |
|
11 |
+
$dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );
|
12 |
|
13 |
foreach ( $result as $items ) {
|
14 |
+
if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
|
15 |
+
$ip_string = __( '#hash#', 'wp-statistics' );
|
16 |
$map_string = "";
|
17 |
} else {
|
18 |
$ip_string = "<a href='admin.php?page=" .
|
20 |
"&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
|
21 |
$map_string
|
22 |
= "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
23 |
+
__( 'Map', 'wp-statistics' ) .
|
24 |
"'>" .
|
25 |
+
wp_statistics_icons( 'dashicons-location-alt', 'map' ) .
|
26 |
"</a>";
|
27 |
}
|
28 |
|
29 |
echo "<div class='log-item'>";
|
30 |
echo "<div class='log-referred'>{$ip_string}</div>";
|
31 |
+
echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . "</div>";
|
32 |
echo "<div class='clear'></div>";
|
33 |
echo "<div class='log-url'>";
|
34 |
echo $map_string;
|
35 |
|
36 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
37 |
echo "<img src='" .
|
38 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) .
|
39 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
40 |
}
|
41 |
|
42 |
if ( array_search(
|
43 |
+
strtolower( $items->agent ),
|
44 |
array(
|
45 |
"chrome",
|
46 |
"firefox",
|
51 |
) !== false
|
52 |
) {
|
53 |
$agent = "<img src='" .
|
54 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
55 |
$items->agent .
|
56 |
".png' class='log-tools' title='{$items->agent}'/>";
|
57 |
} else {
|
58 |
+
$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
|
59 |
}
|
60 |
|
61 |
echo "<a href='?page=" .
|
62 |
WP_Statistics::$page['overview'] .
|
63 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
64 |
|
65 |
+
echo $WP_Statistics->get_referrer_link( $items->referred );
|
66 |
|
67 |
echo "</div>";
|
68 |
echo "</div>";
|
includes/log/widgets/referring.php
CHANGED
@@ -30,22 +30,22 @@ function wp_statistics_generate_referring_postbox_content( $count = 10 ) {
|
|
30 |
?>
|
31 |
<table width="100%" class="widefat table-stats" id="last-referrer">
|
32 |
<tr>
|
33 |
-
<td width="10%"><?php _e('References', 'wp-statistics'); ?></td>
|
34 |
-
<td width="90%"><?php _e('Address', 'wp-statistics'); ?></td>
|
35 |
</tr>
|
36 |
|
37 |
<?php
|
38 |
foreach ( $get_urls as $items => $value ) {
|
39 |
-
$referrer_html = $WP_Statistics->html_sanitize_referrer($items);
|
40 |
echo "<tr>";
|
41 |
echo "<td><a href='?page=" .
|
42 |
WP_Statistics::$page['referrers'] .
|
43 |
"&referr=" .
|
44 |
$referrer_html .
|
45 |
"'>" .
|
46 |
-
number_format_i18n($value) .
|
47 |
"</a></td>";
|
48 |
-
echo "<td>" . $WP_Statistics->get_referrer_link($items) . "</td>";
|
49 |
echo "</tr>";
|
50 |
}
|
51 |
?>
|
30 |
?>
|
31 |
<table width="100%" class="widefat table-stats" id="last-referrer">
|
32 |
<tr>
|
33 |
+
<td width="10%"><?php _e( 'References', 'wp-statistics' ); ?></td>
|
34 |
+
<td width="90%"><?php _e( 'Address', 'wp-statistics' ); ?></td>
|
35 |
</tr>
|
36 |
|
37 |
<?php
|
38 |
foreach ( $get_urls as $items => $value ) {
|
39 |
+
$referrer_html = $WP_Statistics->html_sanitize_referrer( $items );
|
40 |
echo "<tr>";
|
41 |
echo "<td><a href='?page=" .
|
42 |
WP_Statistics::$page['referrers'] .
|
43 |
"&referr=" .
|
44 |
$referrer_html .
|
45 |
"'>" .
|
46 |
+
number_format_i18n( $value ) .
|
47 |
"</a></td>";
|
48 |
+
echo "<td>" . $WP_Statistics->get_referrer_link( $items ) . "</td>";
|
49 |
echo "</tr>";
|
50 |
}
|
51 |
?>
|
includes/log/widgets/search.php
CHANGED
@@ -1,94 +1,94 @@
|
|
1 |
<?php
|
2 |
function wp_statistics_generate_search_postbox_content( $search_engines, $size = "300", $days = 20 ) {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
-
$id = 'search-stats-' . rand(111, 999);
|
5 |
-
$total_stats = $WP_Statistics->get_option('chart_totals');
|
6 |
$date = array();
|
7 |
$stats = array();
|
8 |
$total_daily = array();
|
9 |
|
10 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
11 |
-
$date[] = "'" . $WP_Statistics->Current_Date('M j', '-' . $i) . "'";
|
12 |
}
|
13 |
|
14 |
foreach ( $search_engines as $se ) {
|
15 |
-
for ( $i = $days; $i >= 0; $i-- ) {
|
16 |
-
if ( ! array_key_exists($i, $total_daily) ) {
|
17 |
$total_daily[ $i ] = 0;
|
18 |
}
|
19 |
|
20 |
-
$stat = wp_statistics_searchengine($se['tag'], '-' . $i);
|
21 |
$stats[ $se['name'] ][] = $stat;
|
22 |
-
$total_daily[ $i ]
|
23 |
}
|
24 |
}
|
25 |
?>
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
<?php foreach ( $search_engines as $se ): ?>
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
<?php endforeach; ?>
|
54 |
<?php if ( $total_stats == 1 ) : ?>
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
<?php endif;?>
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
<?php
|
93 |
}
|
94 |
|
1 |
<?php
|
2 |
function wp_statistics_generate_search_postbox_content( $search_engines, $size = "300", $days = 20 ) {
|
3 |
global $wpdb, $WP_Statistics;
|
4 |
+
$id = 'search-stats-' . rand( 111, 999 );
|
5 |
+
$total_stats = $WP_Statistics->get_option( 'chart_totals' );
|
6 |
$date = array();
|
7 |
$stats = array();
|
8 |
$total_daily = array();
|
9 |
|
10 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
11 |
+
$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'";
|
12 |
}
|
13 |
|
14 |
foreach ( $search_engines as $se ) {
|
15 |
+
for ( $i = $days; $i >= 0; $i -- ) {
|
16 |
+
if ( ! array_key_exists( $i, $total_daily ) ) {
|
17 |
$total_daily[ $i ] = 0;
|
18 |
}
|
19 |
|
20 |
+
$stat = wp_statistics_searchengine( $se['tag'], '-' . $i );
|
21 |
$stats[ $se['name'] ][] = $stat;
|
22 |
+
$total_daily[ $i ] += $stat;
|
23 |
}
|
24 |
}
|
25 |
?>
|
26 |
+
<canvas id="<?php echo $id; ?>" height="<?php echo $size; ?>"></canvas>
|
27 |
+
<script>
|
28 |
+
var colors = [];
|
29 |
+
colors['baidu'] = ['rgba(35, 25, 220, 0.2)', 'rgba(35, 25, 220, 1)'];
|
30 |
+
colors['bing'] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)'];
|
31 |
+
colors['duckduckgo'] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)'];
|
32 |
+
colors['google'] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)'];
|
33 |
+
colors['yahoo'] = ['rgba(64, 0, 144, 0.2)', 'rgba(64, 0, 144, 1)'];
|
34 |
+
colors['yandex'] = ['rgba(255, 219, 77, 0.2)', 'rgba(255, 219, 77, 1)'];
|
35 |
+
colors['ask'] = ['rgba(205, 0, 0, 0.2)', 'rgba(205, 0, 0, 1)'];
|
36 |
+
colors['clearch'] = ['rgba(13, 0, 76, 0.2)', 'rgba(13, 0, 76, 1)'];
|
37 |
|
38 |
+
var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d');
|
39 |
+
var ChartJs = new Chart(ctx, {
|
40 |
+
type: 'line',
|
41 |
+
data: {
|
42 |
+
labels: [<?php echo implode( ', ', $date ); ?>],
|
43 |
+
datasets: [
|
44 |
<?php foreach ( $search_engines as $se ): ?>
|
45 |
+
{
|
46 |
+
label: '<?php echo $se['name']; ?>',
|
47 |
+
data: [<?php echo implode( ',', $stats[ $se['name'] ] ); ?>],
|
48 |
+
backgroundColor: colors['<?php echo $se['tag']; ?>'][0],
|
49 |
+
borderColor: colors['<?php echo $se['tag']; ?>'][1],
|
50 |
+
borderWidth: 1,
|
51 |
+
fill: true,
|
52 |
+
},
|
53 |
<?php endforeach; ?>
|
54 |
<?php if ( $total_stats == 1 ) : ?>
|
55 |
+
{
|
56 |
+
label: '<?php _e( 'Total', 'wp-statistics' ); ?>',
|
57 |
+
data: [<?php echo implode( ',', $total_daily ); ?>],
|
58 |
+
backgroundColor: 'rgba(180, 180, 180, 0.2)',
|
59 |
+
borderColor: 'rgba(180, 180, 180, 1)',
|
60 |
+
borderWidth: 1,
|
61 |
+
fill: false,
|
62 |
+
},
|
63 |
<?php endif;?>
|
64 |
+
]
|
65 |
+
},
|
66 |
+
options: {
|
67 |
+
responsive: true,
|
68 |
+
legend: {
|
69 |
+
position: 'bottom',
|
70 |
+
},
|
71 |
+
animation: {
|
72 |
+
duration: 0,
|
73 |
+
},
|
74 |
+
title: {
|
75 |
+
display: true,
|
76 |
+
text: '<?php echo sprintf( __( 'Search engine referrals in the last %s days', 'wp-statistics' ), $days ); ?>'
|
77 |
+
},
|
78 |
+
tooltips: {
|
79 |
+
mode: 'index',
|
80 |
+
intersect: false,
|
81 |
+
},
|
82 |
+
scales: {
|
83 |
+
yAxes: [{
|
84 |
+
ticks: {
|
85 |
+
beginAtZero: true
|
86 |
+
}
|
87 |
+
}]
|
88 |
+
}
|
89 |
+
}
|
90 |
+
});
|
91 |
+
</script>
|
92 |
<?php
|
93 |
}
|
94 |
|
includes/log/widgets/searched.phrases.php
CHANGED
@@ -8,11 +8,11 @@ function wp_statistics_generate_searched_phrases_postbox_content() {
|
|
8 |
);
|
9 |
|
10 |
?>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
<?php
|
18 |
|
@@ -24,6 +24,6 @@ function wp_statistics_generate_searched_phrases_postbox_content() {
|
|
24 |
echo "</tr>";
|
25 |
}
|
26 |
?>
|
27 |
-
|
28 |
<?php
|
29 |
}
|
8 |
);
|
9 |
|
10 |
?>
|
11 |
+
<table width="100%" class="widefat table-stats" id="searched-phrases">
|
12 |
+
<tr>
|
13 |
+
<td width="90%"><?php _e( 'Phrase', 'wp-statistics' ); ?></td>
|
14 |
+
<td width="10%"><?php _e( 'Count', 'wp-statistics' ); ?></td>
|
15 |
+
</tr>
|
16 |
|
17 |
<?php
|
18 |
|
24 |
echo "</tr>";
|
25 |
}
|
26 |
?>
|
27 |
+
</table>
|
28 |
<?php
|
29 |
}
|
includes/log/widgets/summary.php
CHANGED
@@ -3,275 +3,274 @@ function wp_statistics_generate_summary_postbox_content( $search_engines, $searc
|
|
3 |
|
4 |
global $wpdb, $WP_Statistics;
|
5 |
|
6 |
-
$show_visitors = $WP_Statistics->get_option('visitor');
|
7 |
?>
|
8 |
-
|
9 |
-
|
10 |
-
<?php if ( $WP_Statistics->get_option('useronline') ) { ?>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
<span><a
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
</tr>
|
19 |
<?php }
|
20 |
|
21 |
-
if ( $WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') ) {
|
22 |
?>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
_e('Visitors', 'wp-statistics');
|
27 |
} else {
|
28 |
echo '';
|
29 |
} ?></th>
|
30 |
-
|
31 |
-
_e('Visits', 'wp-statistics');
|
32 |
} else {
|
33 |
echo '';
|
34 |
} ?></th>
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
echo '<a href="admin.php?page=' .
|
41 |
WP_Statistics::$page['visitors'] .
|
42 |
'&hitdays=1"><span>' .
|
43 |
-
number_format_i18n(wp_statistics_visitor('today', null, true)) .
|
44 |
'</span></a>';
|
45 |
} else {
|
46 |
echo '';
|
47 |
} ?></th>
|
48 |
-
|
49 |
echo '<a href="admin.php?page=' .
|
50 |
WP_Statistics::$page['hits'] .
|
51 |
'&hitdays=1"><span>' .
|
52 |
-
number_format_i18n(wp_statistics_visit('today')) .
|
53 |
'</span></a>';
|
54 |
} else {
|
55 |
echo '';
|
56 |
} ?></th>
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
echo '<a href="admin.php?page=' .
|
63 |
WP_Statistics::$page['visitors'] .
|
64 |
'&hitdays=1"><span>' .
|
65 |
-
number_format_i18n(wp_statistics_visitor('yesterday', null, true)) .
|
66 |
'</span></a>';
|
67 |
} else {
|
68 |
echo '';
|
69 |
} ?></th>
|
70 |
-
|
71 |
echo '<a href="admin.php?page=' .
|
72 |
WP_Statistics::$page['hits'] .
|
73 |
'&hitdays=1"><span>' .
|
74 |
-
number_format_i18n(wp_statistics_visit('yesterday')) .
|
75 |
'</span></a>';
|
76 |
} else {
|
77 |
echo '';
|
78 |
} ?></th>
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
echo '<a href="admin.php?page=' .
|
85 |
WP_Statistics::$page['visitors'] .
|
86 |
'&hitdays=7"><span>' .
|
87 |
-
number_format_i18n(wp_statistics_visitor('week', null, true)) .
|
88 |
'</span></a>';
|
89 |
} else {
|
90 |
echo '';
|
91 |
} ?></th>
|
92 |
-
|
93 |
echo '<a href="admin.php?page=' .
|
94 |
WP_Statistics::$page['hits'] .
|
95 |
'&hitdays=7"><span>' .
|
96 |
-
number_format_i18n(wp_statistics_visit('week')) .
|
97 |
'</span></a>';
|
98 |
} else {
|
99 |
echo '';
|
100 |
} ?></th>
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
echo '<a href="admin.php?page=' .
|
107 |
WP_Statistics::$page['visitors'] .
|
108 |
'&hitdays=30"><span>' .
|
109 |
-
number_format_i18n(wp_statistics_visitor('month', null, true)) .
|
110 |
'</span></a>';
|
111 |
} else {
|
112 |
echo '';
|
113 |
} ?></th>
|
114 |
-
|
115 |
echo '<a href="admin.php?page=' .
|
116 |
WP_Statistics::$page['hits'] .
|
117 |
'&hitdays=30"><span>' .
|
118 |
-
number_format_i18n(wp_statistics_visit('month')) .
|
119 |
'</span></a>';
|
120 |
} else {
|
121 |
echo '';
|
122 |
} ?></th>
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
echo '<a href="admin.php?page=' .
|
129 |
WP_Statistics::$page['visitors'] .
|
130 |
'&hitdays=365"><span>' .
|
131 |
-
number_format_i18n(wp_statistics_visitor('year', null, true)) .
|
132 |
'</span></a>';
|
133 |
} else {
|
134 |
echo '';
|
135 |
} ?></th>
|
136 |
-
|
137 |
echo '<a href="admin.php?page=' .
|
138 |
WP_Statistics::$page['hits'] .
|
139 |
'&hitdays=365"><span>' .
|
140 |
-
number_format_i18n(wp_statistics_visit('year')) .
|
141 |
'</span></a>';
|
142 |
} else {
|
143 |
echo '';
|
144 |
} ?></th>
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
echo '<a href="admin.php?page=' .
|
151 |
WP_Statistics::$page['visitors'] .
|
152 |
'&hitdays=365"><span>' .
|
153 |
-
number_format_i18n(wp_statistics_visitor('total', null, true)) .
|
154 |
'</span></a>';
|
155 |
} else {
|
156 |
echo '';
|
157 |
} ?></th>
|
158 |
-
|
159 |
echo '<a href="admin.php?page=' .
|
160 |
WP_Statistics::$page['hits'] .
|
161 |
'&hitdays=365"><span>' .
|
162 |
-
number_format_i18n(wp_statistics_visit('total')) .
|
163 |
'</span></a>';
|
164 |
} else {
|
165 |
echo '';
|
166 |
} ?></th>
|
167 |
-
|
168 |
|
169 |
<?php
|
170 |
}
|
171 |
|
172 |
-
if ( $search == true && $WP_Statistics->get_option('visitors') ) {
|
173 |
|
174 |
-
if ( $WP_Statistics->get_option('visitors') ||
|
175 |
-
$WP_Statistics->get_option('visits') ||
|
176 |
-
$WP_Statistics->get_option('useronline')
|
177 |
) {
|
178 |
?>
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
<?php } ?>
|
185 |
-
|
186 |
-
|
187 |
'Search Engine Referrals',
|
188 |
'wp-statistics'
|
189 |
); ?></th>
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
|
198 |
<?php
|
199 |
-
$se_today_total
|
200 |
$se_yesterday_total = 0;
|
201 |
foreach ( $search_engines as $se ) {
|
202 |
?>
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
$se['name'],
|
207 |
'wp-statistics'
|
208 |
); ?>
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$se_today_total
|
213 |
-
echo number_format_i18n($se_temp); ?></span></th>
|
214 |
-
|
215 |
-
$se_yesterday_total
|
216 |
-
echo number_format_i18n($se_temp); ?></span></th>
|
217 |
-
|
218 |
|
219 |
<?php
|
220 |
}
|
221 |
?>
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
<?php
|
236 |
}
|
237 |
|
238 |
if ( $time == true ) {
|
239 |
?>
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
'(Adjustment)',
|
250 |
'wp-statistics'
|
251 |
); ?></a></span>
|
252 |
-
|
253 |
-
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
__('Date: %s', 'wp-statistics'),
|
258 |
'<code dir="ltr">' .
|
259 |
-
$WP_Statistics->Current_Date_i18n(get_option('date_format')) .
|
260 |
'</code>'
|
261 |
); ?></th>
|
262 |
-
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
__('Time: %s', 'wp-statistics'),
|
267 |
'<code dir="ltr">' .
|
268 |
-
$WP_Statistics->Current_Date_i18n(get_option('time_format')) .
|
269 |
'</code>'
|
270 |
); ?></th>
|
271 |
-
|
272 |
<?php } ?>
|
273 |
-
|
274 |
-
|
275 |
<?php
|
276 |
}
|
277 |
|
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( 'Online Users', 'wp-statistics' ); ?>:</th>
|
13 |
+
<th colspan="2" id="th-colspan">
|
14 |
<span><a
|
15 |
+
href="admin.php?page=<?php echo WP_Statistics::$page['online']; ?>"><?php echo wp_statistics_useronline(); ?></a></span>
|
16 |
+
</th>
|
17 |
+
</tr>
|
|
|
18 |
<?php }
|
19 |
|
20 |
+
if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) {
|
21 |
?>
|
22 |
+
<tr>
|
23 |
+
<th width="60%"></th>
|
24 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
25 |
+
_e( 'Visitors', 'wp-statistics' );
|
26 |
} else {
|
27 |
echo '';
|
28 |
} ?></th>
|
29 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
30 |
+
_e( 'Visits', 'wp-statistics' );
|
31 |
} else {
|
32 |
echo '';
|
33 |
} ?></th>
|
34 |
+
</tr>
|
35 |
|
36 |
+
<tr>
|
37 |
+
<th><?php _e( 'Today', 'wp-statistics' ); ?>:</th>
|
38 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
39 |
echo '<a href="admin.php?page=' .
|
40 |
WP_Statistics::$page['visitors'] .
|
41 |
'&hitdays=1"><span>' .
|
42 |
+
number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) .
|
43 |
'</span></a>';
|
44 |
} else {
|
45 |
echo '';
|
46 |
} ?></th>
|
47 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
48 |
echo '<a href="admin.php?page=' .
|
49 |
WP_Statistics::$page['hits'] .
|
50 |
'&hitdays=1"><span>' .
|
51 |
+
number_format_i18n( wp_statistics_visit( 'today' ) ) .
|
52 |
'</span></a>';
|
53 |
} else {
|
54 |
echo '';
|
55 |
} ?></th>
|
56 |
+
</tr>
|
57 |
|
58 |
+
<tr>
|
59 |
+
<th><?php _e( 'Yesterday', 'wp-statistics' ); ?>:</th>
|
60 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
61 |
echo '<a href="admin.php?page=' .
|
62 |
WP_Statistics::$page['visitors'] .
|
63 |
'&hitdays=1"><span>' .
|
64 |
+
number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) .
|
65 |
'</span></a>';
|
66 |
} else {
|
67 |
echo '';
|
68 |
} ?></th>
|
69 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
70 |
echo '<a href="admin.php?page=' .
|
71 |
WP_Statistics::$page['hits'] .
|
72 |
'&hitdays=1"><span>' .
|
73 |
+
number_format_i18n( wp_statistics_visit( 'yesterday' ) ) .
|
74 |
'</span></a>';
|
75 |
} else {
|
76 |
echo '';
|
77 |
} ?></th>
|
78 |
+
</tr>
|
79 |
|
80 |
+
<tr>
|
81 |
+
<th><?php _e( 'Last 7 Days', 'wp-statistics' ); ?>:</th>
|
82 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
83 |
echo '<a href="admin.php?page=' .
|
84 |
WP_Statistics::$page['visitors'] .
|
85 |
'&hitdays=7"><span>' .
|
86 |
+
number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) .
|
87 |
'</span></a>';
|
88 |
} else {
|
89 |
echo '';
|
90 |
} ?></th>
|
91 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
92 |
echo '<a href="admin.php?page=' .
|
93 |
WP_Statistics::$page['hits'] .
|
94 |
'&hitdays=7"><span>' .
|
95 |
+
number_format_i18n( wp_statistics_visit( 'week' ) ) .
|
96 |
'</span></a>';
|
97 |
} else {
|
98 |
echo '';
|
99 |
} ?></th>
|
100 |
+
</tr>
|
101 |
|
102 |
+
<tr>
|
103 |
+
<th><?php _e( 'Last 30 Days', 'wp-statistics' ); ?>:</th>
|
104 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
105 |
echo '<a href="admin.php?page=' .
|
106 |
WP_Statistics::$page['visitors'] .
|
107 |
'&hitdays=30"><span>' .
|
108 |
+
number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) .
|
109 |
'</span></a>';
|
110 |
} else {
|
111 |
echo '';
|
112 |
} ?></th>
|
113 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
114 |
echo '<a href="admin.php?page=' .
|
115 |
WP_Statistics::$page['hits'] .
|
116 |
'&hitdays=30"><span>' .
|
117 |
+
number_format_i18n( wp_statistics_visit( 'month' ) ) .
|
118 |
'</span></a>';
|
119 |
} else {
|
120 |
echo '';
|
121 |
} ?></th>
|
122 |
+
</tr>
|
123 |
|
124 |
+
<tr>
|
125 |
+
<th><?php _e( 'Last 365 Days', 'wp-statistics' ); ?>:</th>
|
126 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
127 |
echo '<a href="admin.php?page=' .
|
128 |
WP_Statistics::$page['visitors'] .
|
129 |
'&hitdays=365"><span>' .
|
130 |
+
number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) .
|
131 |
'</span></a>';
|
132 |
} else {
|
133 |
echo '';
|
134 |
} ?></th>
|
135 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
136 |
echo '<a href="admin.php?page=' .
|
137 |
WP_Statistics::$page['hits'] .
|
138 |
'&hitdays=365"><span>' .
|
139 |
+
number_format_i18n( wp_statistics_visit( 'year' ) ) .
|
140 |
'</span></a>';
|
141 |
} else {
|
142 |
echo '';
|
143 |
} ?></th>
|
144 |
+
</tr>
|
145 |
|
146 |
+
<tr>
|
147 |
+
<th><?php _e( 'Total', 'wp-statistics' ); ?>:</th>
|
148 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) {
|
149 |
echo '<a href="admin.php?page=' .
|
150 |
WP_Statistics::$page['visitors'] .
|
151 |
'&hitdays=365"><span>' .
|
152 |
+
number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) .
|
153 |
'</span></a>';
|
154 |
} else {
|
155 |
echo '';
|
156 |
} ?></th>
|
157 |
+
<th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) {
|
158 |
echo '<a href="admin.php?page=' .
|
159 |
WP_Statistics::$page['hits'] .
|
160 |
'&hitdays=365"><span>' .
|
161 |
+
number_format_i18n( wp_statistics_visit( 'total' ) ) .
|
162 |
'</span></a>';
|
163 |
} else {
|
164 |
echo '';
|
165 |
} ?></th>
|
166 |
+
</tr>
|
167 |
|
168 |
<?php
|
169 |
}
|
170 |
|
171 |
+
if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) {
|
172 |
|
173 |
+
if ( $WP_Statistics->get_option( 'visitors' ) ||
|
174 |
+
$WP_Statistics->get_option( 'visits' ) ||
|
175 |
+
$WP_Statistics->get_option( 'useronline' )
|
176 |
) {
|
177 |
?>
|
178 |
+
<tr>
|
179 |
+
<th colspan="3"><br>
|
180 |
+
<hr>
|
181 |
+
</th>
|
182 |
+
</tr>
|
183 |
<?php } ?>
|
184 |
+
<tr>
|
185 |
+
<th colspan="3" style="text-align: center;"><?php _e(
|
186 |
'Search Engine Referrals',
|
187 |
'wp-statistics'
|
188 |
); ?></th>
|
189 |
+
</tr>
|
190 |
|
191 |
+
<tr>
|
192 |
+
<th width="60%"></th>
|
193 |
+
<th class="th-center"><?php _e( 'Today', 'wp-statistics' ); ?></th>
|
194 |
+
<th class="th-center"><?php _e( 'Yesterday', 'wp-statistics' ); ?></th>
|
195 |
+
</tr>
|
196 |
|
197 |
<?php
|
198 |
+
$se_today_total = 0;
|
199 |
$se_yesterday_total = 0;
|
200 |
foreach ( $search_engines as $se ) {
|
201 |
?>
|
202 |
+
<tr>
|
203 |
+
<th>
|
204 |
+
<img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e(
|
205 |
$se['name'],
|
206 |
'wp-statistics'
|
207 |
); ?>
|
208 |
+
:
|
209 |
+
</th>
|
210 |
+
<th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' );
|
211 |
+
$se_today_total += $se_temp;
|
212 |
+
echo number_format_i18n( $se_temp ); ?></span></th>
|
213 |
+
<th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' );
|
214 |
+
$se_yesterday_total += $se_temp;
|
215 |
+
echo number_format_i18n( $se_temp ); ?></span></th>
|
216 |
+
</tr>
|
217 |
|
218 |
<?php
|
219 |
}
|
220 |
?>
|
221 |
+
<tr>
|
222 |
+
<th><?php _e( 'Daily Total', 'wp-statistics' ); ?>:</th>
|
223 |
+
<td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span>
|
224 |
+
</td>
|
225 |
+
<td id="th-colspan" class="th-center">
|
226 |
+
<span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td>
|
227 |
+
</tr>
|
228 |
|
229 |
+
<tr>
|
230 |
+
<th><?php _e( 'Total', 'wp-statistics' ); ?>:</th>
|
231 |
+
<th colspan="2" id="th-colspan">
|
232 |
+
<span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th>
|
233 |
+
</tr>
|
234 |
<?php
|
235 |
}
|
236 |
|
237 |
if ( $time == true ) {
|
238 |
?>
|
239 |
+
<tr>
|
240 |
+
<th colspan="3"><br>
|
241 |
+
<hr>
|
242 |
+
</th>
|
243 |
+
</tr>
|
244 |
|
245 |
+
<tr>
|
246 |
+
<th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp-statistics' ); ?>
|
247 |
+
<span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e(
|
248 |
'(Adjustment)',
|
249 |
'wp-statistics'
|
250 |
); ?></a></span>
|
251 |
+
</th>
|
252 |
+
</tr>
|
253 |
|
254 |
+
<tr>
|
255 |
+
<th colspan="3"><?php echo sprintf(
|
256 |
+
__( 'Date: %s', 'wp-statistics' ),
|
257 |
'<code dir="ltr">' .
|
258 |
+
$WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) .
|
259 |
'</code>'
|
260 |
); ?></th>
|
261 |
+
</tr>
|
262 |
|
263 |
+
<tr>
|
264 |
+
<th colspan="3"><?php echo sprintf(
|
265 |
+
__( 'Time: %s', 'wp-statistics' ),
|
266 |
'<code dir="ltr">' .
|
267 |
+
$WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) .
|
268 |
'</code>'
|
269 |
); ?></th>
|
270 |
+
</tr>
|
271 |
<?php } ?>
|
272 |
+
</tbody>
|
273 |
+
</table>
|
274 |
<?php
|
275 |
}
|
276 |
|
includes/log/widgets/top.visitors.php
CHANGED
@@ -9,25 +9,25 @@ function wp_statistics_generate_top_visitors_postbox_content(
|
|
9 |
global $wpdb, $WP_Statistics;
|
10 |
|
11 |
if ( $day == 'today' ) {
|
12 |
-
$sql_time = $WP_Statistics->Current_Date('Y-m-d');
|
13 |
} else {
|
14 |
-
$sql_time = date('Y-m-d', strtotime($day));
|
15 |
}
|
16 |
|
17 |
?>
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
<?php if ( $compact == false ) { ?>
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
<?php } ?>
|
30 |
-
|
31 |
|
32 |
<?php
|
33 |
$result = $wpdb->get_results(
|
@@ -37,15 +37,15 @@ function wp_statistics_generate_top_visitors_postbox_content(
|
|
37 |
$i = 0;
|
38 |
|
39 |
foreach ( $result as $visitor ) {
|
40 |
-
$i++;
|
41 |
|
42 |
-
$item = strtoupper($visitor->location);
|
43 |
|
44 |
echo "<tr>";
|
45 |
echo "<td>$i</td>";
|
46 |
echo "<td>" . (int) $visitor->hits . "</td>";
|
47 |
echo "<td><img src='" .
|
48 |
-
plugins_url('wp-statistics/assets/images/flags/' . $item . '.png') .
|
49 |
"' title='{$ISOCountryCode[$item]}'/></td>";
|
50 |
echo "<td>{$ISOCountryCode[$item]}</td>";
|
51 |
echo "<td>{$visitor->ip}</td>";
|
@@ -62,6 +62,6 @@ function wp_statistics_generate_top_visitors_postbox_content(
|
|
62 |
}
|
63 |
}
|
64 |
?>
|
65 |
-
|
66 |
<?php
|
67 |
}
|
9 |
global $wpdb, $WP_Statistics;
|
10 |
|
11 |
if ( $day == 'today' ) {
|
12 |
+
$sql_time = $WP_Statistics->Current_Date( 'Y-m-d' );
|
13 |
} else {
|
14 |
+
$sql_time = date( 'Y-m-d', strtotime( $day ) );
|
15 |
}
|
16 |
|
17 |
?>
|
18 |
+
<table width="100%" class="widefat table-stats" id="last-referrer">
|
19 |
+
<tr>
|
20 |
+
<td><?php _e( 'Rank', 'wp-statistics' ); ?></td>
|
21 |
+
<td><?php _e( 'Hits', 'wp-statistics' ); ?></td>
|
22 |
+
<td><?php _e( 'Flag', 'wp-statistics' ); ?></td>
|
23 |
+
<td><?php _e( 'Country', 'wp-statistics' ); ?></td>
|
24 |
+
<td><?php _e( 'IP', 'wp-statistics' ); ?></td>
|
25 |
<?php if ( $compact == false ) { ?>
|
26 |
+
<td><?php _e( 'Agent', 'wp-statistics' ); ?></td>
|
27 |
+
<td><?php _e( 'Platform', 'wp-statistics' ); ?></td>
|
28 |
+
<td><?php _e( 'Version', 'wp-statistics' ); ?></td>
|
29 |
<?php } ?>
|
30 |
+
</tr>
|
31 |
|
32 |
<?php
|
33 |
$result = $wpdb->get_results(
|
37 |
$i = 0;
|
38 |
|
39 |
foreach ( $result as $visitor ) {
|
40 |
+
$i ++;
|
41 |
|
42 |
+
$item = strtoupper( $visitor->location );
|
43 |
|
44 |
echo "<tr>";
|
45 |
echo "<td>$i</td>";
|
46 |
echo "<td>" . (int) $visitor->hits . "</td>";
|
47 |
echo "<td><img src='" .
|
48 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $item . '.png' ) .
|
49 |
"' title='{$ISOCountryCode[$item]}'/></td>";
|
50 |
echo "<td>{$ISOCountryCode[$item]}</td>";
|
51 |
echo "<td>{$visitor->ip}</td>";
|
62 |
}
|
63 |
}
|
64 |
?>
|
65 |
+
</table>
|
66 |
<?php
|
67 |
}
|
includes/log/widgets/words.php
CHANGED
@@ -4,76 +4,76 @@ function wp_statistics_generate_words_postbox_content( $ISOCountryCode, $count =
|
|
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
|
14 |
$tablename .= 'search';
|
15 |
-
$result
|
16 |
"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"
|
17 |
);
|
18 |
} else {
|
19 |
$tablename .= 'visitor';
|
20 |
-
$result
|
21 |
"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"
|
22 |
);
|
23 |
}
|
24 |
|
25 |
-
if ( sizeof($result) > 0 ) {
|
26 |
echo "<div class='log-latest'>";
|
27 |
|
28 |
foreach ( $result as $items ) {
|
29 |
-
if ( ! $WP_Statistics->Search_Engine_QueryString($items->referred) ) {
|
30 |
continue;
|
31 |
}
|
32 |
|
33 |
-
if ( substr($items->ip, 0, 6) == '#hash#' ) {
|
34 |
-
$ip_string = __('#hash#', 'wp-statistics');
|
35 |
} else {
|
36 |
$ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
|
37 |
}
|
38 |
|
39 |
-
if ( $WP_Statistics->get_option('search_converted') ) {
|
40 |
-
$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine($items->engine);
|
41 |
$words = $items->words;
|
42 |
} else {
|
43 |
-
$this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
|
44 |
-
$words = $WP_Statistics->Search_Engine_QueryString($items->referred);
|
45 |
}
|
46 |
|
47 |
echo "<div class='log-item'>";
|
48 |
echo "<div class='log-referred'>" . $words . "</div>";
|
49 |
echo "<div class='log-ip'>" .
|
50 |
-
date(get_option('date_format'), strtotime($items->last_counter)) .
|
51 |
" - {$ip_string}</div>";
|
52 |
echo "<div class='clear'></div>";
|
53 |
echo "<div class='log-url'>";
|
54 |
echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
55 |
-
__('Map', 'wp-statistics') .
|
56 |
"'>" .
|
57 |
-
wp_statistics_icons('dashicons-location-alt', 'map') .
|
58 |
"</a>";
|
59 |
|
60 |
-
if ( $WP_Statistics->get_option('geoip') ) {
|
61 |
echo "<img src='" .
|
62 |
-
plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') .
|
63 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
64 |
}
|
65 |
|
66 |
-
$this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
|
67 |
echo "<a href='?page=" .
|
68 |
WP_Statistics::$page['overview'] .
|
69 |
"&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" .
|
70 |
-
plugins_url('wp-statistics/assets/images/' . $this_search_engine['image']) .
|
71 |
"' class='log-tools' title='" .
|
72 |
$this_search_engine['translated'] .
|
73 |
"'/></a>";
|
74 |
|
75 |
if ( array_search(
|
76 |
-
strtolower($items->agent),
|
77 |
array(
|
78 |
"chrome",
|
79 |
"firefox",
|
@@ -84,25 +84,25 @@ function wp_statistics_generate_words_postbox_content( $ISOCountryCode, $count =
|
|
84 |
) !== false
|
85 |
) {
|
86 |
$agent = "<img src='" .
|
87 |
-
plugins_url('wp-statistics/assets/images/') .
|
88 |
$items->agent .
|
89 |
".png' class='log-tools' title='{$items->agent}'/>";
|
90 |
} else {
|
91 |
-
$agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
|
92 |
}
|
93 |
|
94 |
echo "<a href='?page=" .
|
95 |
WP_Statistics::$page['overview'] .
|
96 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
97 |
|
98 |
-
$referrer_html = $WP_Statistics->html_sanitize_referrer($items->referred);
|
99 |
|
100 |
echo "<a href='" .
|
101 |
$referrer_html .
|
102 |
"' title='" .
|
103 |
$referrer_html .
|
104 |
"'>" .
|
105 |
-
wp_statistics_icons('dashicons-admin-links', 'link') .
|
106 |
" " .
|
107 |
$referrer_html .
|
108 |
"</a></div>";
|
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(
|
16 |
"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"
|
17 |
);
|
18 |
} else {
|
19 |
$tablename .= 'visitor';
|
20 |
+
$result = $wpdb->get_results(
|
21 |
"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC LIMIT 0, {$count}"
|
22 |
);
|
23 |
}
|
24 |
|
25 |
+
if ( sizeof( $result ) > 0 ) {
|
26 |
echo "<div class='log-latest'>";
|
27 |
|
28 |
foreach ( $result as $items ) {
|
29 |
+
if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) {
|
30 |
continue;
|
31 |
}
|
32 |
|
33 |
+
if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
|
34 |
+
$ip_string = __( '#hash#', 'wp-statistics' );
|
35 |
} else {
|
36 |
$ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
|
37 |
}
|
38 |
|
39 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) ) {
|
40 |
+
$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine( $items->engine );
|
41 |
$words = $items->words;
|
42 |
} else {
|
43 |
+
$this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
|
44 |
+
$words = $WP_Statistics->Search_Engine_QueryString( $items->referred );
|
45 |
}
|
46 |
|
47 |
echo "<div class='log-item'>";
|
48 |
echo "<div class='log-referred'>" . $words . "</div>";
|
49 |
echo "<div class='log-ip'>" .
|
50 |
+
date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) .
|
51 |
" - {$ip_string}</div>";
|
52 |
echo "<div class='clear'></div>";
|
53 |
echo "<div class='log-url'>";
|
54 |
echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
|
55 |
+
__( 'Map', 'wp-statistics' ) .
|
56 |
"'>" .
|
57 |
+
wp_statistics_icons( 'dashicons-location-alt', 'map' ) .
|
58 |
"</a>";
|
59 |
|
60 |
+
if ( $WP_Statistics->get_option( 'geoip' ) ) {
|
61 |
echo "<img src='" .
|
62 |
+
plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) .
|
63 |
"' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
|
64 |
}
|
65 |
|
66 |
+
$this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred );
|
67 |
echo "<a href='?page=" .
|
68 |
WP_Statistics::$page['overview'] .
|
69 |
"&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" .
|
70 |
+
plugins_url( 'wp-statistics/assets/images/' . $this_search_engine['image'] ) .
|
71 |
"' class='log-tools' title='" .
|
72 |
$this_search_engine['translated'] .
|
73 |
"'/></a>";
|
74 |
|
75 |
if ( array_search(
|
76 |
+
strtolower( $items->agent ),
|
77 |
array(
|
78 |
"chrome",
|
79 |
"firefox",
|
84 |
) !== false
|
85 |
) {
|
86 |
$agent = "<img src='" .
|
87 |
+
plugins_url( 'wp-statistics/assets/images/' ) .
|
88 |
$items->agent .
|
89 |
".png' class='log-tools' title='{$items->agent}'/>";
|
90 |
} else {
|
91 |
+
$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' );
|
92 |
}
|
93 |
|
94 |
echo "<a href='?page=" .
|
95 |
WP_Statistics::$page['overview'] .
|
96 |
"&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
|
97 |
|
98 |
+
$referrer_html = $WP_Statistics->html_sanitize_referrer( $items->referred );
|
99 |
|
100 |
echo "<a href='" .
|
101 |
$referrer_html .
|
102 |
"' title='" .
|
103 |
$referrer_html .
|
104 |
"'>" .
|
105 |
+
wp_statistics_icons( 'dashicons-admin-links', 'link' ) .
|
106 |
" " .
|
107 |
$referrer_html .
|
108 |
"</a></div>";
|
includes/optimization/tabs/wps-optimization-database.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
<div class="wrap">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
'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.',
|
20 |
'wp-statistics'
|
21 |
); ?></p>
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
<?php
|
36 |
GLOBAL $wpdb, $WP_Statistics;
|
37 |
$wp_prefix = $wpdb->prefix;
|
38 |
|
39 |
-
$dbupdates = $WP_Statistics->get_option('pending_db_updates');
|
40 |
|
41 |
// 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
|
42 |
$result = $wpdb->query(
|
@@ -47,14 +47,14 @@
|
|
47 |
if ( $result != 5 ) {
|
48 |
$dbupdates['date_ip_agent'] = true;
|
49 |
?>
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
'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.',
|
55 |
'wp-statistics'
|
56 |
); ?></p>
|
57 |
-
|
58 |
'This operation could take a long time on installs with many rows in the visitors table.',
|
59 |
'wp-statistics'
|
60 |
); ?></p>
|
@@ -62,44 +62,44 @@
|
|
62 |
} else {
|
63 |
$dbupdates['date_ip_agent'] = false;
|
64 |
?>
|
65 |
-
|
66 |
'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.',
|
67 |
'wp-statistics'
|
68 |
); ?></p>
|
69 |
-
|
70 |
'Congratulations, your installation is already up to date, nothing to do.',
|
71 |
'wp-statistics'
|
72 |
); ?></p>
|
73 |
<?php
|
74 |
}
|
75 |
?>
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
<?php
|
85 |
GLOBAL $wpdb;
|
86 |
$wp_prefix = $wpdb->prefix;
|
87 |
|
88 |
// 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
|
89 |
-
$result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'");
|
90 |
|
91 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
92 |
if ( $result != 1 ) {
|
93 |
$dbupdates['unique_date'] = true;
|
94 |
?>
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
'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.',
|
100 |
'wp-statistics'
|
101 |
); ?></p>
|
102 |
-
|
103 |
'This operation could take a long time on installs with many rows in the visits table.',
|
104 |
'wp-statistics'
|
105 |
); ?></p>
|
@@ -107,65 +107,65 @@
|
|
107 |
} else {
|
108 |
$dbupdates['unique_date'] = false;
|
109 |
?>
|
110 |
-
|
111 |
'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.',
|
112 |
'wp-statistics'
|
113 |
); ?></p>
|
114 |
-
|
115 |
'Congratulations, your installation is already up to date, nothing to do.',
|
116 |
'wp-statistics'
|
117 |
); ?></p>
|
118 |
<?php
|
119 |
}
|
120 |
|
121 |
-
$WP_Statistics->update_option('pending_db_updates', $dbupdates);
|
122 |
?>
|
123 |
-
|
124 |
|
125 |
-
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
<?php
|
137 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
138 |
-
if ( $WP_Statistics->get_option('search_converted') != 1 ) {
|
139 |
?>
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
'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.',
|
145 |
'wp-statistics'
|
146 |
); ?></p>
|
147 |
-
|
148 |
'This operation could take a long time on installs with many rows in the visitors table.',
|
149 |
'wp-statistics'
|
150 |
); ?></p>
|
151 |
<?php
|
152 |
} else {
|
153 |
?>
|
154 |
-
|
155 |
'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.',
|
156 |
'wp-statistics'
|
157 |
); ?></p>
|
158 |
-
|
159 |
'Congratulations, your installation is already up to date, nothing to do.',
|
160 |
'wp-statistics'
|
161 |
); ?></p>
|
162 |
<?php
|
163 |
}
|
164 |
?>
|
165 |
-
|
166 |
|
167 |
-
|
168 |
|
169 |
-
|
170 |
-
|
171 |
</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"
|
15 |
+
value="<?php _e( 'Install Now!', 'wp-statistics' ); ?>" name="install-submit"
|
16 |
+
onclick="location.href=document.URL+'&install=1&tab=database'">
|
17 |
+
|
18 |
+
<p class="description"><?php _e(
|
19 |
'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.',
|
20 |
'wp-statistics'
|
21 |
); ?></p>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
|
25 |
+
<tr valign="top">
|
26 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Database Index', 'wp-statistics' ); ?></h3></th>
|
27 |
+
</tr>
|
28 |
|
29 |
+
<tr valign="top">
|
30 |
+
<th scope="row">
|
31 |
+
<label for="index-submit"><?php _e( 'Countries', 'wp-statistics' ); ?>:</label>
|
32 |
+
</th>
|
33 |
|
34 |
+
<td>
|
35 |
<?php
|
36 |
GLOBAL $wpdb, $WP_Statistics;
|
37 |
$wp_prefix = $wpdb->prefix;
|
38 |
|
39 |
+
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
40 |
|
41 |
// 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
|
42 |
$result = $wpdb->query(
|
47 |
if ( $result != 5 ) {
|
48 |
$dbupdates['date_ip_agent'] = true;
|
49 |
?>
|
50 |
+
<input id="index-submit" class="button button-primary" type="button"
|
51 |
+
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="index-submit"
|
52 |
+
onclick="location.href=document.URL+'&index=1&tab=database'">
|
53 |
+
<p class="description"><?php _e(
|
54 |
'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.',
|
55 |
'wp-statistics'
|
56 |
); ?></p>
|
57 |
+
<p class="description"><?php _e(
|
58 |
'This operation could take a long time on installs with many rows in the visitors table.',
|
59 |
'wp-statistics'
|
60 |
); ?></p>
|
62 |
} else {
|
63 |
$dbupdates['date_ip_agent'] = false;
|
64 |
?>
|
65 |
+
<p class="description"><?php _e(
|
66 |
'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.',
|
67 |
'wp-statistics'
|
68 |
); ?></p>
|
69 |
+
<p class="description"><?php _e(
|
70 |
'Congratulations, your installation is already up to date, nothing to do.',
|
71 |
'wp-statistics'
|
72 |
); ?></p>
|
73 |
<?php
|
74 |
}
|
75 |
?>
|
76 |
+
</td>
|
77 |
+
</tr>
|
78 |
+
|
79 |
+
<tr valign="top">
|
80 |
+
<th scope="row">
|
81 |
+
<label for="index-submit"><?php _e( 'Visits Table', 'wp-statistics' ); ?>:</label>
|
82 |
+
</th>
|
83 |
+
<td>
|
84 |
<?php
|
85 |
GLOBAL $wpdb;
|
86 |
$wp_prefix = $wpdb->prefix;
|
87 |
|
88 |
// 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
|
89 |
+
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
|
90 |
|
91 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
92 |
if ( $result != 1 ) {
|
93 |
$dbupdates['unique_date'] = true;
|
94 |
?>
|
95 |
+
<input id="visits-submit" class="button button-primary" type="button"
|
96 |
+
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="visit-submit"
|
97 |
+
onclick="location.href=document.URL+'&visits=1&tab=database'">
|
98 |
+
<p class="description"><?php _e(
|
99 |
'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.',
|
100 |
'wp-statistics'
|
101 |
); ?></p>
|
102 |
+
<p class="description"><?php _e(
|
103 |
'This operation could take a long time on installs with many rows in the visits table.',
|
104 |
'wp-statistics'
|
105 |
); ?></p>
|
107 |
} else {
|
108 |
$dbupdates['unique_date'] = false;
|
109 |
?>
|
110 |
+
<p class="description"><?php _e(
|
111 |
'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.',
|
112 |
'wp-statistics'
|
113 |
); ?></p>
|
114 |
+
<p class="description"><?php _e(
|
115 |
'Congratulations, your installation is already up to date, nothing to do.',
|
116 |
'wp-statistics'
|
117 |
); ?></p>
|
118 |
<?php
|
119 |
}
|
120 |
|
121 |
+
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
122 |
?>
|
123 |
+
</td>
|
124 |
|
125 |
+
</tr>
|
126 |
|
127 |
+
<tr valign="top">
|
128 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Search Table', 'wp-statistics' ); ?></h3></th>
|
129 |
+
</tr>
|
130 |
|
131 |
+
<tr valign="top">
|
132 |
+
<th scope="row">
|
133 |
+
<label for="index-submit"><?php _e( 'Convert', 'wp-statistics' ); ?>:</label>
|
134 |
+
</th>
|
135 |
+
<td>
|
136 |
<?php
|
137 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
138 |
+
if ( $WP_Statistics->get_option( 'search_converted' ) != 1 ) {
|
139 |
?>
|
140 |
+
<input id="visits-submit" class="button button-primary" type="button"
|
141 |
+
value="<?php _e( 'Convert Now!', 'wp-statistics' ); ?>" name="search-submit"
|
142 |
+
onclick="location.href=document.URL+'&search=1&tab=database'">
|
143 |
+
<p class="description"><?php _e(
|
144 |
'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.',
|
145 |
'wp-statistics'
|
146 |
); ?></p>
|
147 |
+
<p class="description"><?php _e(
|
148 |
'This operation could take a long time on installs with many rows in the visitors table.',
|
149 |
'wp-statistics'
|
150 |
); ?></p>
|
151 |
<?php
|
152 |
} else {
|
153 |
?>
|
154 |
+
<p class="description"><?php _e(
|
155 |
'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.',
|
156 |
'wp-statistics'
|
157 |
); ?></p>
|
158 |
+
<p class="description"><?php _e(
|
159 |
'Congratulations, your installation is already up to date, nothing to do.',
|
160 |
'wp-statistics'
|
161 |
); ?></p>
|
162 |
<?php
|
163 |
}
|
164 |
?>
|
165 |
+
</td>
|
166 |
|
167 |
+
</tr>
|
168 |
|
169 |
+
</tbody>
|
170 |
+
</table>
|
171 |
</div>
|
includes/optimization/tabs/wps-optimization-export.php
CHANGED
@@ -1,67 +1,67 @@
|
|
1 |
<div class="wrap">
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
'Include a header row as the first line of the exported file.',
|
58 |
'wp-statistics'
|
59 |
); ?></p>
|
60 |
-
<?php submit_button(__('Start Now!', 'wp-statistics'), 'primary', 'export-file-submit'); ?>
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
</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 dir="ltr" id="table-to-export" name="table-to-export" required>
|
18 |
+
<option value=""><?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 |
|
27 |
+
<p class="description"><?php _e( 'Select the table for the output file.', 'wp-statistics' ); ?></p>
|
28 |
+
</td>
|
29 |
+
</tr>
|
30 |
|
31 |
+
<tr valign="top">
|
32 |
+
<th scope="row">
|
33 |
+
<label for="export-file-type"><?php _e( 'Export To', 'wp-statistics' ); ?>:</label>
|
34 |
+
</th>
|
35 |
|
36 |
+
<td>
|
37 |
+
<select dir="ltr" id="export-file-type" name="export-file-type" required>
|
38 |
+
<option value=""><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
39 |
+
<option value="xml">XML</option>
|
40 |
+
<option value="csv">CSV</option>
|
41 |
+
<option value="tsv">TSV</option>
|
42 |
+
</select>
|
43 |
|
44 |
+
<p class="description"><?php _e( 'Select the output file type.', 'wp-statistics' ); ?></p>
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
|
48 |
+
<tr valign="top">
|
49 |
+
<th scope="row">
|
50 |
+
<label for="export-headers"><?php _e( 'Include Header Row', 'wp-statistics' ); ?>:</label>
|
51 |
+
</th>
|
52 |
|
53 |
+
<td>
|
54 |
+
<input id="export-headers" type="checkbox" value="1" name="export-headers">
|
55 |
|
56 |
+
<p class="description"><?php _e(
|
57 |
'Include a header row as the first line of the exported file.',
|
58 |
'wp-statistics'
|
59 |
); ?></p>
|
60 |
+
<?php submit_button( __( 'Start Now!', 'wp-statistics' ), 'primary', 'export-file-submit' ); ?>
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
|
64 |
+
</tbody>
|
65 |
+
</table>
|
66 |
+
</form>
|
67 |
</div>
|
includes/optimization/tabs/wps-optimization-historical.php
CHANGED
@@ -1,78 +1,78 @@
|
|
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 |
-
|
11 |
-
<?php wp_nonce_field('historical_form', 'wp-statistics-nonce'); ?>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
<?php _e(
|
21 |
'Note: As you have just purged the database you must reload this page for these numbers to be correct.',
|
22 |
'wp-statistics'
|
23 |
); ?>
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
<?php _e('Visitors', 'wp-statistics'); ?>:
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
__(
|
38 |
'Number of historical number of visitors to the site (current value is %s).',
|
39 |
'wp-statistics'
|
40 |
),
|
41 |
-
number_format_i18n($historical_visitors)
|
42 |
); ?></p>
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
<?php _e('Visits', 'wp-statistics'); ?>:
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
__(
|
57 |
'Number of historical number of visits to the site (current value is %s).',
|
58 |
'wp-statistics'
|
59 |
),
|
60 |
-
number_format_i18n($historical_visits)
|
61 |
); ?></p>
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
|
78 |
</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(
|
21 |
'Note: As you have just purged the database you must reload this page for these numbers to be correct.',
|
22 |
'wp-statistics'
|
23 |
); ?>
|
24 |
+
</th>
|
25 |
+
</tr>
|
26 |
|
27 |
+
<tr valign="top">
|
28 |
+
<th scope="row">
|
29 |
+
<?php _e( 'Visitors', 'wp-statistics' ); ?>:
|
30 |
+
</th>
|
31 |
|
32 |
+
<td>
|
33 |
+
<input type="text" size="10" value="<?php echo $historical_visitors; ?>"
|
34 |
+
id="wps_historical_visitors" name="wps_historical_visitors">
|
35 |
|
36 |
+
<p class="description"><?php echo sprintf(
|
37 |
__(
|
38 |
'Number of historical number of visitors to the site (current value is %s).',
|
39 |
'wp-statistics'
|
40 |
),
|
41 |
+
number_format_i18n( $historical_visitors )
|
42 |
); ?></p>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
|
46 |
+
<tr valign="top">
|
47 |
+
<th scope="row">
|
48 |
+
<?php _e( 'Visits', 'wp-statistics' ); ?>:
|
49 |
+
</th>
|
50 |
|
51 |
+
<td>
|
52 |
+
<input type="text" size="10" value="<?php echo $historical_visits; ?>" id="wps_historical_visits"
|
53 |
+
name="wps_historical_visits">
|
54 |
|
55 |
+
<p class="description"><?php echo sprintf(
|
56 |
__(
|
57 |
'Number of historical number of visits to the site (current value is %s).',
|
58 |
'wp-statistics'
|
59 |
),
|
60 |
+
number_format_i18n( $historical_visits )
|
61 |
); ?></p>
|
62 |
+
</td>
|
63 |
+
</tr>
|
64 |
|
65 |
+
<tr valign="top">
|
66 |
+
<td colspan=2>
|
67 |
+
<input id="historical-submit" class="button button-primary" type="submit"
|
68 |
+
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="historical-submit"/>
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
|
72 |
+
</tbody>
|
73 |
|
74 |
+
</table>
|
75 |
|
76 |
+
</form>
|
77 |
|
78 |
</div>
|
includes/optimization/tabs/wps-optimization-purging.php
CHANGED
@@ -1,322 +1,323 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
</script>
|
175 |
|
176 |
<div class="wrap">
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
'Delete user statistics data older than the selected number of days. Minimum value is 30 days.',
|
221 |
'wp-statistics'
|
222 |
); ?></p>
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
243 |
'Delete 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.',
|
244 |
'wp-statistics'
|
245 |
); ?></p>
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
<?php
|
268 |
$agents = wp_statistics_ua_list();
|
269 |
|
270 |
foreach ( $agents as $agent ) {
|
271 |
-
$aid = preg_replace("/[^a-zA-Z]/", "", $agent);
|
272 |
echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>";
|
273 |
}
|
274 |
?>
|
275 |
-
|
276 |
|
277 |
-
|
278 |
'All visitor data will be lost for this agent type.',
|
279 |
'wp-statistics'
|
280 |
); ?></p>
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
<?php
|
299 |
$platforms = wp_statistics_platform_list();
|
300 |
|
301 |
foreach ( $platforms as $platform ) {
|
302 |
-
$pid = preg_replace("/[^a-zA-Z]/", "", $platform);
|
303 |
echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>";
|
304 |
}
|
305 |
?>
|
306 |
-
|
307 |
|
308 |
-
|
309 |
'All visitor data will be lost for this platform type.',
|
310 |
'wp-statistics'
|
311 |
); ?></p>
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
</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 dir="ltr" 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 |
+
|
200 |
+
<p class="description"><?php _e( 'All data table will be lost.', 'wp-statistics' ); ?></p>
|
201 |
+
<input id="empty-table-submit" class="button button-primary" type="submit"
|
202 |
+
value="<?php _e( 'Clear now!', 'wp-statistics' ); ?>" name="empty-table-submit"
|
203 |
+
Onclick="return false;"/>
|
204 |
+
<span id="empty-status"></span>
|
205 |
+
|
206 |
+
<div id="empty-result"></div>
|
207 |
+
</td>
|
208 |
+
</tr>
|
209 |
+
|
210 |
+
<tr>
|
211 |
+
<th scope="row">
|
212 |
+
<label for="purge-data"><?php _e( 'Purge records older than', 'wp-statistics' ); ?>:</label>
|
213 |
+
</th>
|
214 |
+
|
215 |
+
<td>
|
216 |
+
<input type="text" class="small-text code" id="purge-data" name="wps_purge_data" value="365"/>
|
217 |
+
<label for="purge-data"><?php _e( 'Days', 'wp-statistics' ); ?></label>
|
218 |
+
|
219 |
+
<p class="description"><?php _e(
|
220 |
'Delete user statistics data older than the selected number of days. Minimum value is 30 days.',
|
221 |
'wp-statistics'
|
222 |
); ?></p>
|
223 |
+
<input id="purge-data-submit" class="button button-primary" type="submit"
|
224 |
+
value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-data-submit"
|
225 |
+
Onclick="return false;"/>
|
226 |
+
<span id="purge-data-status"></span>
|
227 |
+
|
228 |
+
<div id="purge-data-result"></div>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
|
232 |
+
<tr>
|
233 |
+
<th scope="row">
|
234 |
+
<label for="purge-visitor-hits"><?php _e( 'Purge visitors with more than', 'wp-statistics' ); ?>
|
235 |
+
:</label>
|
236 |
+
</th>
|
237 |
+
|
238 |
+
<td>
|
239 |
+
<input type="text" class="small-text code" id="purge-visitor-hits" name="wps_purge_visitor_hits"
|
240 |
+
value="10"/>
|
241 |
+
<label for="purge-visitor-hits"><?php _e( 'Hits', 'wp-statistics' ); ?></label>
|
242 |
+
|
243 |
+
<p class="description"><?php _e(
|
244 |
'Delete 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.',
|
245 |
'wp-statistics'
|
246 |
); ?></p>
|
247 |
+
<input id="purge-visitor-hits-submit" class="button button-primary" type="submit"
|
248 |
+
value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-visitor-hits-submit"
|
249 |
+
Onclick="return false;"/>
|
250 |
+
<span id="purge-visitor-hits-status"></span>
|
251 |
+
|
252 |
+
<div id="purge-visitor-hits-result"></div>
|
253 |
+
</td>
|
254 |
+
</tr>
|
255 |
+
|
256 |
+
<tr valign="top">
|
257 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Delete User Agent Types', 'wp-statistics' ); ?></h3></th>
|
258 |
+
</tr>
|
259 |
+
|
260 |
+
<tr valign="top">
|
261 |
+
<th scope="row">
|
262 |
+
<label for="delete-agent"><?php _e( 'Delete Agents', 'wp-statistics' ); ?>:</label>
|
263 |
+
</th>
|
264 |
+
|
265 |
+
<td>
|
266 |
+
<select dir="ltr" id="delete-agent" name="delete-agent">
|
267 |
+
<option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
268 |
<?php
|
269 |
$agents = wp_statistics_ua_list();
|
270 |
|
271 |
foreach ( $agents as $agent ) {
|
272 |
+
$aid = preg_replace( "/[^a-zA-Z]/", "", $agent );
|
273 |
echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>";
|
274 |
}
|
275 |
?>
|
276 |
+
</select>
|
277 |
|
278 |
+
<p class="description"><?php _e(
|
279 |
'All visitor data will be lost for this agent type.',
|
280 |
'wp-statistics'
|
281 |
); ?></p>
|
282 |
+
<input id="delete-agents-submit" class="button button-primary" type="submit"
|
283 |
+
value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-agents-submit"
|
284 |
+
Onclick="return false;">
|
285 |
+
<span id="delete-agents-status"></span>
|
286 |
+
|
287 |
+
<div id="delete-agents-result"></div>
|
288 |
+
</td>
|
289 |
+
</tr>
|
290 |
+
|
291 |
+
<tr valign="top">
|
292 |
+
<th scope="row">
|
293 |
+
<label for="delete-platform"><?php _e( 'Delete Platforms', 'wp-statistics' ); ?>:</label>
|
294 |
+
</th>
|
295 |
+
|
296 |
+
<td>
|
297 |
+
<select dir="ltr" id="delete-platform" name="delete-platform">
|
298 |
+
<option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
299 |
<?php
|
300 |
$platforms = wp_statistics_platform_list();
|
301 |
|
302 |
foreach ( $platforms as $platform ) {
|
303 |
+
$pid = preg_replace( "/[^a-zA-Z]/", "", $platform );
|
304 |
echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>";
|
305 |
}
|
306 |
?>
|
307 |
+
</select>
|
308 |
|
309 |
+
<p class="description"><?php _e(
|
310 |
'All visitor data will be lost for this platform type.',
|
311 |
'wp-statistics'
|
312 |
); ?></p>
|
313 |
+
<input id="delete-platforms-submit" class="button button-primary" type="submit"
|
314 |
+
value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-platforms-submit"
|
315 |
+
Onclick="return false;">
|
316 |
+
<span id="delete-platforms-status"></span>
|
317 |
+
|
318 |
+
<div id="delete-platforms-result"></div>
|
319 |
+
</td>
|
320 |
+
</tr>
|
321 |
+
</tbody>
|
322 |
+
</table>
|
323 |
</div>
|
includes/optimization/tabs/wps-optimization-resources.php
CHANGED
@@ -15,58 +15,58 @@ function formatSize( $size ) {
|
|
15 |
if ( $size == 0 ) {
|
16 |
return ( 'n/a' );
|
17 |
} else {
|
18 |
-
return ( round($size / pow(1024, ( $i = floor(log($size, 1024)) )), 2) . $sizes[ $i ] );
|
19 |
}
|
20 |
}
|
21 |
|
22 |
?>
|
23 |
<div class="wrap">
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
<?php _e('Memory usage in PHP', 'wp-statistics'); ?>:
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
'Bytes',
|
38 |
'wp-statistics'
|
39 |
); ?>
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
<?php _e('PHP Memory Limit', 'wp-statistics'); ?>:
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
'The memory limit a script is allowed to consume, set in php.ini.',
|
54 |
'wp-statistics'
|
55 |
); ?></p>
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
<?php echo sprintf(
|
62 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
63 |
'<code>' . $wpdb->prefix . 'statistics_' . 'useronline' . '</code>'
|
64 |
); ?>
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
'Row',
|
71 |
'Rows',
|
72 |
number_format_i18n(
|
@@ -74,21 +74,21 @@ function formatSize( $size ) {
|
|
74 |
),
|
75 |
'wp-statistics'
|
76 |
); ?>
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
<?php echo sprintf(
|
84 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
85 |
'<code>' . $wpdb->prefix . 'statistics_' . 'visit' . '</code>'
|
86 |
); ?>
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
'Row',
|
93 |
'Rows',
|
94 |
number_format_i18n(
|
@@ -96,21 +96,21 @@ function formatSize( $size ) {
|
|
96 |
),
|
97 |
'wp-statistics'
|
98 |
); ?>
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
<?php echo sprintf(
|
106 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
107 |
'<code>' . $wpdb->prefix . 'statistics_' . 'visitor' . '</code>'
|
108 |
); ?>
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
113 |
-
|
114 |
'Row',
|
115 |
'Rows',
|
116 |
number_format_i18n(
|
@@ -118,21 +118,21 @@ function formatSize( $size ) {
|
|
118 |
),
|
119 |
'wp-statistics'
|
120 |
); ?>
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
<?php echo sprintf(
|
128 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
129 |
'<code>' . $wpdb->prefix . 'statistics_' . 'exclusions' . '</code>'
|
130 |
); ?>
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
'Row',
|
137 |
'Rows',
|
138 |
number_format_i18n(
|
@@ -140,21 +140,21 @@ function formatSize( $size ) {
|
|
140 |
),
|
141 |
'wp-statistics'
|
142 |
); ?>
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
<?php echo sprintf(
|
150 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
151 |
'<code>' . $wpdb->prefix . 'statistics_' . 'pages' . '</code>'
|
152 |
); ?>
|
153 |
-
|
154 |
-
|
155 |
|
156 |
-
|
157 |
-
|
158 |
'Row',
|
159 |
'Rows',
|
160 |
number_format_i18n(
|
@@ -162,21 +162,21 @@ function formatSize( $size ) {
|
|
162 |
),
|
163 |
'wp-statistics'
|
164 |
); ?>
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
|
169 |
-
|
170 |
-
|
171 |
<?php echo sprintf(
|
172 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
173 |
'<code>' . $wpdb->prefix . 'statistics_' . 'historical' . '</code>'
|
174 |
); ?>
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
'Row',
|
181 |
'Rows',
|
182 |
number_format_i18n(
|
@@ -184,21 +184,21 @@ function formatSize( $size ) {
|
|
184 |
),
|
185 |
'wp-statistics'
|
186 |
); ?>
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
|
191 |
-
|
192 |
-
|
193 |
<?php echo sprintf(
|
194 |
-
__('Number of rows in the %s table', 'wp-statistics'),
|
195 |
'<code>' . $wpdb->prefix . 'statistics_' . 'search' . '</code>'
|
196 |
); ?>
|
197 |
-
|
198 |
-
|
199 |
|
200 |
-
|
201 |
-
|
202 |
'Row',
|
203 |
'Rows',
|
204 |
number_format_i18n(
|
@@ -206,318 +206,318 @@ function formatSize( $size ) {
|
|
206 |
),
|
207 |
'wp-statistics'
|
208 |
); ?>
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
<?php _e('WP Statistics Version', 'wp-statistics'); ?>:
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
<?php _e('PHP Version', 'wp-statistics'); ?>:
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
<?php _e('PHP Safe Mode', 'wp-statistics'); ?>:
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
_e('Yes', 'wp-statistics');
|
249 |
} else {
|
250 |
-
_e('No', 'wp-statistics');
|
251 |
} ?></strong>
|
252 |
|
253 |
-
|
254 |
'Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.',
|
255 |
'wp-statistics'
|
256 |
); ?></p>
|
257 |
-
|
258 |
-
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
<?php _e('PHP IPv6 Enabled', 'wp-statistics'); ?>:
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
_e('Yes', 'wp-statistics');
|
268 |
} else {
|
269 |
-
_e('No', 'wp-statistics');
|
270 |
} ?></strong>
|
271 |
|
272 |
-
|
273 |
'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.',
|
274 |
'wp-statistics'
|
275 |
); ?></p>
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
<?php _e('jQuery Version', 'wp-statistics'); ?>:
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
<?php _e('cURL Version', 'wp-statistics'); ?>:
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
$curl_ver = curl_version();
|
301 |
echo $curl_ver['version'];
|
302 |
} else {
|
303 |
-
_e('cURL not installed', 'wp-statistics');
|
304 |
} ?></strong>
|
305 |
|
306 |
-
|
307 |
'The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.',
|
308 |
'wp-statistics'
|
309 |
); ?></p>
|
310 |
-
|
311 |
-
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
<?php _e('Zlib gzopen()', 'wp-statistics'); ?>:
|
316 |
-
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
_e('Installed', 'wp-statistics');
|
321 |
} else {
|
322 |
-
_e('Not installed', 'wp-statistics');
|
323 |
} ?></strong>
|
324 |
|
325 |
-
|
326 |
'If the gzopen() function is installed. gzopen() is required for the GeoIP database to be downloaded successfully.',
|
327 |
'wp-statistics'
|
328 |
); ?></p>
|
329 |
-
|
330 |
-
|
331 |
|
332 |
-
|
333 |
-
|
334 |
-
<?php _e('GMP PHP extension', 'wp-statistics'); ?>:
|
335 |
-
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
_e('Installed', 'wp-statistics');
|
340 |
} else {
|
341 |
-
_e('Not installed', 'wp-statistics');
|
342 |
} ?></strong>
|
343 |
|
344 |
-
|
345 |
'If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.',
|
346 |
'wp-statistics'
|
347 |
); ?></p>
|
348 |
-
|
349 |
-
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
<?php _e('BCMath PHP extension', 'wp-statistics'); ?>:
|
354 |
-
|
355 |
|
356 |
-
|
357 |
-
|
358 |
-
_e('Installed', 'wp-statistics');
|
359 |
} else {
|
360 |
-
_e('Not installed', 'wp-statistics');
|
361 |
} ?></strong>
|
362 |
|
363 |
-
|
364 |
'If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
-
|
368 |
-
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
|
374 |
-
|
375 |
-
|
376 |
-
<?php _e('GeoIP Database', 'wp-statistics'); ?>:
|
377 |
-
|
378 |
|
379 |
-
|
380 |
-
|
381 |
$GeoIP_filename = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
|
382 |
-
$GeoIP_filedate = @filemtime($GeoIP_filename);
|
383 |
|
384 |
if ( $GeoIP_filedate === false ) {
|
385 |
-
_e('Database file does not exist.', 'wp-statistics');
|
386 |
} else {
|
387 |
-
echo formatSize(@filesize($GeoIP_filename)) .
|
388 |
-
__(', created on ', 'wp-statistics') .
|
389 |
-
date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $GeoIP_filedate);
|
390 |
} ?></strong>
|
391 |
|
392 |
-
|
393 |
'The file size and date of the GeoIP database.',
|
394 |
'wp-statistics'
|
395 |
); ?></p>
|
396 |
-
|
397 |
-
|
398 |
|
399 |
-
|
400 |
-
|
401 |
-
<?php _e('browscap.ini File', 'wp-statistics'); ?>:
|
402 |
-
|
403 |
|
404 |
-
|
405 |
-
|
406 |
$browscap_filename = $upload_dir['basedir'] . '/wp-statistics/browscap.ini';
|
407 |
-
$browscap_filedate = @filemtime($browscap_filename);
|
408 |
|
409 |
if ( $browscap_filedate === false ) {
|
410 |
-
_e('browscap.ini file does not exist.', 'wp-statistics');
|
411 |
} else {
|
412 |
-
echo formatSize(@filesize($browscap_filename)) .
|
413 |
-
__(', created on ', 'wp-statistics') .
|
414 |
date_i18n(
|
415 |
-
get_option('date_format') . ' @ ' . get_option('time_format'),
|
416 |
$browscap_filedate
|
417 |
);
|
418 |
} ?></strong>
|
419 |
|
420 |
-
|
421 |
'The file size and date of the browscap.ini file.',
|
422 |
'wp-statistics'
|
423 |
); ?></p>
|
424 |
-
|
425 |
-
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
<?php _e('browscap Cache File', 'wp-statistics'); ?>:
|
430 |
-
|
431 |
|
432 |
-
|
433 |
-
|
434 |
$browscap_filename = $upload_dir['basedir'] . '/wp-statistics/cache.php';
|
435 |
-
$browscap_filedate = @filemtime($browscap_filename);
|
436 |
|
437 |
if ( $browscap_filedate === false ) {
|
438 |
-
_e('browscap cache file does not exist.', 'wp-statistics');
|
439 |
} else {
|
440 |
-
echo formatSize(@filesize($browscap_filename)) .
|
441 |
-
__(', created on ', 'wp-statistics') .
|
442 |
date_i18n(
|
443 |
-
get_option('date_format') . ' @ ' . get_option('time_format'),
|
444 |
$browscap_filedate
|
445 |
);
|
446 |
} ?></strong>
|
447 |
|
448 |
-
|
449 |
'The file size and date of the browscap cache file.',
|
450 |
'wp-statistics'
|
451 |
); ?></p>
|
452 |
-
|
453 |
-
|
454 |
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
|
459 |
-
|
460 |
-
|
461 |
-
<?php _e('Client IP', 'wp-statistics'); ?>:
|
462 |
-
|
463 |
|
464 |
-
|
465 |
-
|
466 |
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
|
471 |
-
|
472 |
-
|
473 |
-
<?php _e('User Agent', 'wp-statistics'); ?>:
|
474 |
-
|
475 |
|
476 |
-
|
477 |
-
|
478 |
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
|
483 |
-
|
484 |
-
|
485 |
-
<?php _e('Browser', 'wp-statistics'); ?>:
|
486 |
-
|
487 |
|
488 |
-
|
489 |
-
|
490 |
echo $agent['browser'];
|
491 |
?></strong>
|
492 |
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
|
497 |
-
|
498 |
-
|
499 |
-
<?php _e('Version', 'wp-statistics'); ?>:
|
500 |
-
|
501 |
|
502 |
-
|
503 |
-
|
504 |
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
|
509 |
-
|
510 |
-
|
511 |
-
<?php _e('Platform', 'wp-statistics'); ?>:
|
512 |
-
|
513 |
|
514 |
-
|
515 |
-
|
516 |
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
|
521 |
-
|
522 |
-
|
523 |
</div>
|
15 |
if ( $size == 0 ) {
|
16 |
return ( 'n/a' );
|
17 |
} else {
|
18 |
+
return ( round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2 ) . $sizes[ $i ] );
|
19 |
}
|
20 |
}
|
21 |
|
22 |
?>
|
23 |
<div class="wrap">
|
24 |
+
<table class="form-table">
|
25 |
+
<tbody>
|
26 |
+
<tr valign="top">
|
27 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Resources', 'wp-statistics' ); ?></h3></th>
|
28 |
+
</tr>
|
29 |
+
|
30 |
+
<tr valign="top">
|
31 |
+
<th scope="row">
|
32 |
+
<?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?>:
|
33 |
+
</th>
|
34 |
+
|
35 |
+
<td>
|
36 |
+
<strong><?php echo number_format_i18n( memory_get_usage() ); ?></strong> <?php _e(
|
37 |
'Bytes',
|
38 |
'wp-statistics'
|
39 |
); ?>
|
40 |
+
<p class="description"><?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?></p>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
|
44 |
+
<tr valign="top">
|
45 |
+
<th scope="row">
|
46 |
+
<?php _e( 'PHP Memory Limit', 'wp-statistics' ); ?>:
|
47 |
+
</th>
|
48 |
|
49 |
+
<td>
|
50 |
+
<strong><?php echo ini_get( 'memory_limit' ); ?></strong>
|
51 |
|
52 |
+
<p class="description"><?php _e(
|
53 |
'The memory limit a script is allowed to consume, set in php.ini.',
|
54 |
'wp-statistics'
|
55 |
); ?></p>
|
56 |
+
</td>
|
57 |
+
</tr>
|
58 |
|
59 |
+
<tr valign="top">
|
60 |
+
<th scope="row">
|
61 |
<?php echo sprintf(
|
62 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
63 |
'<code>' . $wpdb->prefix . 'statistics_' . 'useronline' . '</code>'
|
64 |
); ?>
|
65 |
+
:
|
66 |
+
</th>
|
67 |
|
68 |
+
<td>
|
69 |
+
<strong><?php echo number_format_i18n( $result['useronline'] ); ?></strong> <?php echo _n(
|
70 |
'Row',
|
71 |
'Rows',
|
72 |
number_format_i18n(
|
74 |
),
|
75 |
'wp-statistics'
|
76 |
); ?>
|
77 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
|
81 |
+
<tr valign="top">
|
82 |
+
<th scope="row">
|
83 |
<?php echo sprintf(
|
84 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
85 |
'<code>' . $wpdb->prefix . 'statistics_' . 'visit' . '</code>'
|
86 |
); ?>
|
87 |
+
:
|
88 |
+
</th>
|
89 |
|
90 |
+
<td>
|
91 |
+
<strong><?php echo number_format_i18n( $result['visit'] ); ?></strong> <?php echo _n(
|
92 |
'Row',
|
93 |
'Rows',
|
94 |
number_format_i18n(
|
96 |
),
|
97 |
'wp-statistics'
|
98 |
); ?>
|
99 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
100 |
+
</td>
|
101 |
+
</tr>
|
102 |
|
103 |
+
<tr valign="top">
|
104 |
+
<th scope="row">
|
105 |
<?php echo sprintf(
|
106 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
107 |
'<code>' . $wpdb->prefix . 'statistics_' . 'visitor' . '</code>'
|
108 |
); ?>
|
109 |
+
:
|
110 |
+
</th>
|
111 |
|
112 |
+
<td>
|
113 |
+
<strong><?php echo number_format_i18n( $result['visitor'] ); ?></strong> <?php echo _n(
|
114 |
'Row',
|
115 |
'Rows',
|
116 |
number_format_i18n(
|
118 |
),
|
119 |
'wp-statistics'
|
120 |
); ?>
|
121 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
122 |
+
</td>
|
123 |
+
</tr>
|
124 |
|
125 |
+
<tr valign="top">
|
126 |
+
<th scope="row">
|
127 |
<?php echo sprintf(
|
128 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
129 |
'<code>' . $wpdb->prefix . 'statistics_' . 'exclusions' . '</code>'
|
130 |
); ?>
|
131 |
+
:
|
132 |
+
</th>
|
133 |
|
134 |
+
<td>
|
135 |
+
<strong><?php echo number_format_i18n( $result['exclusions'] ); ?></strong> <?php echo _n(
|
136 |
'Row',
|
137 |
'Rows',
|
138 |
number_format_i18n(
|
140 |
),
|
141 |
'wp-statistics'
|
142 |
); ?>
|
143 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
|
147 |
+
<tr valign="top">
|
148 |
+
<th scope="row">
|
149 |
<?php echo sprintf(
|
150 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
151 |
'<code>' . $wpdb->prefix . 'statistics_' . 'pages' . '</code>'
|
152 |
); ?>
|
153 |
+
:
|
154 |
+
</th>
|
155 |
|
156 |
+
<td>
|
157 |
+
<strong><?php echo number_format_i18n( $result['pages'] ); ?></strong> <?php echo _n(
|
158 |
'Row',
|
159 |
'Rows',
|
160 |
number_format_i18n(
|
162 |
),
|
163 |
'wp-statistics'
|
164 |
); ?>
|
165 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
166 |
+
</td>
|
167 |
+
</tr>
|
168 |
|
169 |
+
<tr valign="top">
|
170 |
+
<th scope="row">
|
171 |
<?php echo sprintf(
|
172 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
173 |
'<code>' . $wpdb->prefix . 'statistics_' . 'historical' . '</code>'
|
174 |
); ?>
|
175 |
+
:
|
176 |
+
</th>
|
177 |
|
178 |
+
<td>
|
179 |
+
<strong><?php echo number_format_i18n( $result['historical'] ); ?></strong> <?php echo _n(
|
180 |
'Row',
|
181 |
'Rows',
|
182 |
number_format_i18n(
|
184 |
),
|
185 |
'wp-statistics'
|
186 |
); ?>
|
187 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
188 |
+
</td>
|
189 |
+
</tr>
|
190 |
|
191 |
+
<tr valign="top">
|
192 |
+
<th scope="row">
|
193 |
<?php echo sprintf(
|
194 |
+
__( 'Number of rows in the %s table', 'wp-statistics' ),
|
195 |
'<code>' . $wpdb->prefix . 'statistics_' . 'search' . '</code>'
|
196 |
); ?>
|
197 |
+
:
|
198 |
+
</th>
|
199 |
|
200 |
+
<td>
|
201 |
+
<strong><?php echo number_format_i18n( $result['search'] ); ?></strong> <?php echo _n(
|
202 |
'Row',
|
203 |
'Rows',
|
204 |
number_format_i18n(
|
206 |
),
|
207 |
'wp-statistics'
|
208 |
); ?>
|
209 |
+
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
210 |
+
</td>
|
211 |
+
</tr>
|
212 |
+
|
213 |
+
<tr valign="top">
|
214 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Version Info', 'wp-statistics' ); ?></h3></th>
|
215 |
+
</tr>
|
216 |
+
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row">
|
219 |
+
<?php _e( 'WP Statistics Version', 'wp-statistics' ); ?>:
|
220 |
+
</th>
|
221 |
+
|
222 |
+
<td>
|
223 |
+
<strong><?php echo WP_Statistics::$reg['version']; ?></strong>
|
224 |
+
|
225 |
+
<p class="description"><?php _e( 'The WP Statistics version you are running.', 'wp-statistics' ); ?></p>
|
226 |
+
</td>
|
227 |
+
</tr>
|
228 |
+
|
229 |
+
<tr valign="top">
|
230 |
+
<th scope="row">
|
231 |
+
<?php _e( 'PHP Version', 'wp-statistics' ); ?>:
|
232 |
+
</th>
|
233 |
+
|
234 |
+
<td>
|
235 |
+
<strong><?php echo phpversion(); ?></strong>
|
236 |
+
|
237 |
+
<p class="description"><?php _e( 'The PHP version you are running.', 'wp-statistics' ); ?></p>
|
238 |
+
</td>
|
239 |
+
</tr>
|
240 |
+
|
241 |
+
<tr valign="top">
|
242 |
+
<th scope="row">
|
243 |
+
<?php _e( 'PHP Safe Mode', 'wp-statistics' ); ?>:
|
244 |
+
</th>
|
245 |
+
|
246 |
+
<td>
|
247 |
+
<strong><?php if ( ini_get( 'safe_mode' ) ) {
|
248 |
+
_e( 'Yes', 'wp-statistics' );
|
249 |
} else {
|
250 |
+
_e( 'No', 'wp-statistics' );
|
251 |
} ?></strong>
|
252 |
|
253 |
+
<p class="description"><?php _e(
|
254 |
'Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.',
|
255 |
'wp-statistics'
|
256 |
); ?></p>
|
257 |
+
</td>
|
258 |
+
</tr>
|
259 |
|
260 |
+
<tr valign="top">
|
261 |
+
<th scope="row">
|
262 |
+
<?php _e( 'PHP IPv6 Enabled', 'wp-statistics' ); ?>:
|
263 |
+
</th>
|
264 |
|
265 |
+
<td>
|
266 |
+
<strong><?php if ( defined( 'AF_INET6' ) ) {
|
267 |
+
_e( 'Yes', 'wp-statistics' );
|
268 |
} else {
|
269 |
+
_e( 'No', 'wp-statistics' );
|
270 |
} ?></strong>
|
271 |
|
272 |
+
<p class="description"><?php _e(
|
273 |
'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.',
|
274 |
'wp-statistics'
|
275 |
); ?></p>
|
276 |
+
</td>
|
277 |
+
</tr>
|
278 |
+
|
279 |
+
<tr valign="top">
|
280 |
+
<th scope="row">
|
281 |
+
<?php _e( 'jQuery Version', 'wp-statistics' ); ?>:
|
282 |
+
</th>
|
283 |
+
|
284 |
+
<td>
|
285 |
+
<strong>
|
286 |
+
<script type="text/javascript">document.write(jQuery().jquery);</script>
|
287 |
+
</strong>
|
288 |
+
|
289 |
+
<p class="description"><?php _e( 'The jQuery version you are running.', 'wp-statistics' ); ?></p>
|
290 |
+
</td>
|
291 |
+
</tr>
|
292 |
+
|
293 |
+
<tr valign="top">
|
294 |
+
<th scope="row">
|
295 |
+
<?php _e( 'cURL Version', 'wp-statistics' ); ?>:
|
296 |
+
</th>
|
297 |
+
|
298 |
+
<td>
|
299 |
+
<strong><?php if ( function_exists( 'curl_version' ) ) {
|
300 |
$curl_ver = curl_version();
|
301 |
echo $curl_ver['version'];
|
302 |
} else {
|
303 |
+
_e( 'cURL not installed', 'wp-statistics' );
|
304 |
} ?></strong>
|
305 |
|
306 |
+
<p class="description"><?php _e(
|
307 |
'The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.',
|
308 |
'wp-statistics'
|
309 |
); ?></p>
|
310 |
+
</td>
|
311 |
+
</tr>
|
312 |
|
313 |
+
<tr valign="top">
|
314 |
+
<th scope="row">
|
315 |
+
<?php _e( 'Zlib gzopen()', 'wp-statistics' ); ?>:
|
316 |
+
</th>
|
317 |
|
318 |
+
<td>
|
319 |
+
<strong><?php if ( function_exists( 'gzopen' ) ) {
|
320 |
+
_e( 'Installed', 'wp-statistics' );
|
321 |
} else {
|
322 |
+
_e( 'Not installed', 'wp-statistics' );
|
323 |
} ?></strong>
|
324 |
|
325 |
+
<p class="description"><?php _e(
|
326 |
'If the gzopen() function is installed. gzopen() is required for the GeoIP database to be downloaded successfully.',
|
327 |
'wp-statistics'
|
328 |
); ?></p>
|
329 |
+
</td>
|
330 |
+
</tr>
|
331 |
|
332 |
+
<tr valign="top">
|
333 |
+
<th scope="row">
|
334 |
+
<?php _e( 'GMP PHP extension', 'wp-statistics' ); ?>:
|
335 |
+
</th>
|
336 |
|
337 |
+
<td>
|
338 |
+
<strong><?php if ( extension_loaded( 'gmp' ) ) {
|
339 |
+
_e( 'Installed', 'wp-statistics' );
|
340 |
} else {
|
341 |
+
_e( 'Not installed', 'wp-statistics' );
|
342 |
} ?></strong>
|
343 |
|
344 |
+
<p class="description"><?php _e(
|
345 |
'If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.',
|
346 |
'wp-statistics'
|
347 |
); ?></p>
|
348 |
+
</td>
|
349 |
+
</tr>
|
350 |
|
351 |
+
<tr valign="top">
|
352 |
+
<th scope="row">
|
353 |
+
<?php _e( 'BCMath PHP extension', 'wp-statistics' ); ?>:
|
354 |
+
</th>
|
355 |
|
356 |
+
<td>
|
357 |
+
<strong><?php if ( extension_loaded( 'bcmath' ) ) {
|
358 |
+
_e( 'Installed', 'wp-statistics' );
|
359 |
} else {
|
360 |
+
_e( 'Not installed', 'wp-statistics' );
|
361 |
} ?></strong>
|
362 |
|
363 |
+
<p class="description"><?php _e(
|
364 |
'If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
|
370 |
+
<tr valign="top">
|
371 |
+
<th scope="row" colspan="2"><h3><?php _e( 'File Info', 'wp-statistics' ); ?></h3></th>
|
372 |
+
</tr>
|
373 |
|
374 |
+
<tr valign="top">
|
375 |
+
<th scope="row">
|
376 |
+
<?php _e( 'GeoIP Database', 'wp-statistics' ); ?>:
|
377 |
+
</th>
|
378 |
|
379 |
+
<td>
|
380 |
+
<strong><?php $upload_dir = wp_upload_dir();
|
381 |
$GeoIP_filename = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
|
382 |
+
$GeoIP_filedate = @filemtime( $GeoIP_filename );
|
383 |
|
384 |
if ( $GeoIP_filedate === false ) {
|
385 |
+
_e( 'Database file does not exist.', 'wp-statistics' );
|
386 |
} else {
|
387 |
+
echo formatSize( @filesize( $GeoIP_filename ) ) .
|
388 |
+
__( ', created on ', 'wp-statistics' ) .
|
389 |
+
date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $GeoIP_filedate );
|
390 |
} ?></strong>
|
391 |
|
392 |
+
<p class="description"><?php _e(
|
393 |
'The file size and date of the GeoIP database.',
|
394 |
'wp-statistics'
|
395 |
); ?></p>
|
396 |
+
</td>
|
397 |
+
</tr>
|
398 |
|
399 |
+
<tr valign="top">
|
400 |
+
<th scope="row">
|
401 |
+
<?php _e( 'browscap.ini File', 'wp-statistics' ); ?>:
|
402 |
+
</th>
|
403 |
|
404 |
+
<td>
|
405 |
+
<strong><?php
|
406 |
$browscap_filename = $upload_dir['basedir'] . '/wp-statistics/browscap.ini';
|
407 |
+
$browscap_filedate = @filemtime( $browscap_filename );
|
408 |
|
409 |
if ( $browscap_filedate === false ) {
|
410 |
+
_e( 'browscap.ini file does not exist.', 'wp-statistics' );
|
411 |
} else {
|
412 |
+
echo formatSize( @filesize( $browscap_filename ) ) .
|
413 |
+
__( ', created on ', 'wp-statistics' ) .
|
414 |
date_i18n(
|
415 |
+
get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ),
|
416 |
$browscap_filedate
|
417 |
);
|
418 |
} ?></strong>
|
419 |
|
420 |
+
<p class="description"><?php _e(
|
421 |
'The file size and date of the browscap.ini file.',
|
422 |
'wp-statistics'
|
423 |
); ?></p>
|
424 |
+
</td>
|
425 |
+
</tr>
|
426 |
|
427 |
+
<tr valign="top">
|
428 |
+
<th scope="row">
|
429 |
+
<?php _e( 'browscap Cache File', 'wp-statistics' ); ?>:
|
430 |
+
</th>
|
431 |
|
432 |
+
<td>
|
433 |
+
<strong><?php
|
434 |
$browscap_filename = $upload_dir['basedir'] . '/wp-statistics/cache.php';
|
435 |
+
$browscap_filedate = @filemtime( $browscap_filename );
|
436 |
|
437 |
if ( $browscap_filedate === false ) {
|
438 |
+
_e( 'browscap cache file does not exist.', 'wp-statistics' );
|
439 |
} else {
|
440 |
+
echo formatSize( @filesize( $browscap_filename ) ) .
|
441 |
+
__( ', created on ', 'wp-statistics' ) .
|
442 |
date_i18n(
|
443 |
+
get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ),
|
444 |
$browscap_filedate
|
445 |
);
|
446 |
} ?></strong>
|
447 |
|
448 |
+
<p class="description"><?php _e(
|
449 |
'The file size and date of the browscap cache file.',
|
450 |
'wp-statistics'
|
451 |
); ?></p>
|
452 |
+
</td>
|
453 |
+
</tr>
|
454 |
|
455 |
+
<tr valign="top">
|
456 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Client Info', 'wp-statistics' ); ?></h3></th>
|
457 |
+
</tr>
|
458 |
|
459 |
+
<tr valign="top">
|
460 |
+
<th scope="row">
|
461 |
+
<?php _e( 'Client IP', 'wp-statistics' ); ?>:
|
462 |
+
</th>
|
463 |
|
464 |
+
<td>
|
465 |
+
<strong><?php echo $WP_Statistics->get_IP(); ?></strong>
|
466 |
|
467 |
+
<p class="description"><?php _e( 'The client IP address.', 'wp-statistics' ); ?></p>
|
468 |
+
</td>
|
469 |
+
</tr>
|
470 |
|
471 |
+
<tr valign="top">
|
472 |
+
<th scope="row">
|
473 |
+
<?php _e( 'User Agent', 'wp-statistics' ); ?>:
|
474 |
+
</th>
|
475 |
|
476 |
+
<td>
|
477 |
+
<strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong>
|
478 |
|
479 |
+
<p class="description"><?php _e( 'The client user agent string.', 'wp-statistics' ); ?></p>
|
480 |
+
</td>
|
481 |
+
</tr>
|
482 |
|
483 |
+
<tr valign="top">
|
484 |
+
<th scope="row">
|
485 |
+
<?php _e( 'Browser', 'wp-statistics' ); ?>:
|
486 |
+
</th>
|
487 |
|
488 |
+
<td>
|
489 |
+
<strong><?php $agent = $WP_Statistics->get_UserAgent();
|
490 |
echo $agent['browser'];
|
491 |
?></strong>
|
492 |
|
493 |
+
<p class="description"><?php _e( 'The detected client browser.', 'wp-statistics' ); ?></p>
|
494 |
+
</td>
|
495 |
+
</tr>
|
496 |
|
497 |
+
<tr valign="top">
|
498 |
+
<th scope="row">
|
499 |
+
<?php _e( 'Version', 'wp-statistics' ); ?>:
|
500 |
+
</th>
|
501 |
|
502 |
+
<td>
|
503 |
+
<strong><?php echo $agent['version']; ?></strong>
|
504 |
|
505 |
+
<p class="description"><?php _e( 'The detected client browser version.', 'wp-statistics' ); ?></p>
|
506 |
+
</td>
|
507 |
+
</tr>
|
508 |
|
509 |
+
<tr valign="top">
|
510 |
+
<th scope="row">
|
511 |
+
<?php _e( 'Platform', 'wp-statistics' ); ?>:
|
512 |
+
</th>
|
513 |
|
514 |
+
<td>
|
515 |
+
<strong><?php echo $agent['platform']; ?></strong>
|
516 |
|
517 |
+
<p class="description"><?php _e( 'The detected client platform.', 'wp-statistics' ); ?></p>
|
518 |
+
</td>
|
519 |
+
</tr>
|
520 |
|
521 |
+
</tbody>
|
522 |
+
</table>
|
523 |
</div>
|
includes/optimization/tabs/wps-optimization-updates.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
</script>
|
12 |
<div class="wrap">
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
'Updates any unknown location data in the database, this may take a while',
|
31 |
'wp-statistics'
|
32 |
); ?></p>
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
'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',
|
51 |
'wp-statistics'
|
52 |
); ?></p>
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
</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"
|
26 |
+
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="populate-submit"
|
27 |
+
onclick="location.href=document.URL+'&tab=updates&populate=1'">
|
28 |
+
|
29 |
+
<p class="description"><?php _e(
|
30 |
'Updates any unknown location data in the database, this may take a while',
|
31 |
'wp-statistics'
|
32 |
); ?></p>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
|
36 |
+
<tr valign="top">
|
37 |
+
<th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp-statistics' ); ?></h3></th>
|
38 |
+
</tr>
|
39 |
|
40 |
+
<tr valign="top">
|
41 |
+
<th scope="row">
|
42 |
+
<label for="populate-submit"><?php _e( 'Hash IP Addresses', 'wp-statistics' ); ?>:</label>
|
43 |
+
</th>
|
44 |
|
45 |
+
<td>
|
46 |
+
<input id="hash-ips-submit" class="button button-primary" type="button"
|
47 |
+
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="hash-ips-submit">
|
48 |
|
49 |
+
<p class="description"><?php _e(
|
50 |
'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',
|
51 |
'wp-statistics'
|
52 |
); ?></p>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
</div>
|
includes/optimization/wps-optimization.php
CHANGED
@@ -3,33 +3,33 @@ 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 |
echo WP_Statistics_Updates::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 |
-
if ( substr($row->ip, 0, 6) != '#hash#' ) {
|
29 |
$wpdb->update(
|
30 |
$wp_prefix . "statistics_visitor",
|
31 |
array(
|
32 |
-
'ip' => '#hash#' . sha1($row->ip . $randomString),
|
33 |
),
|
34 |
array(
|
35 |
'ip' => $row->ip,
|
@@ -39,25 +39,25 @@ if ( array_key_exists('hash-ips', $_GET) ) {
|
|
39 |
}
|
40 |
|
41 |
echo "<div class='updated settings-error'><p><strong>" .
|
42 |
-
__('IP Addresses replaced with hash values.', 'wp-statistics') .
|
43 |
"</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 |
-
new WP_Statistics_Install($WP_Statistics);
|
51 |
echo "<div class='updated settings-error'><p><strong>" .
|
52 |
-
__('Install routine complete.', 'wp-statistics') .
|
53 |
"</strong></p></div>";
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
if ( array_key_exists('index', $_GET) ) {
|
58 |
-
if ( intval($_GET['index']) == 1 ) {
|
59 |
// 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
|
60 |
-
$result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'");
|
61 |
|
62 |
if ( $result != 5 ) {
|
63 |
// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
|
@@ -83,7 +83,7 @@ if ( array_key_exists('index', $_GET) ) {
|
|
83 |
|
84 |
// Now do the acutal deletions.
|
85 |
foreach ( $deleterows as $row ) {
|
86 |
-
$wpdb->delete($wp_prefix . 'statistics_visitor', array( 'ID' => $row ));
|
87 |
}
|
88 |
|
89 |
// The table should be ready to be updated now with the new index, so let's do it.
|
@@ -95,20 +95,20 @@ if ( array_key_exists('index', $_GET) ) {
|
|
95 |
);
|
96 |
|
97 |
// We might have an old index left over from 7.1-7.3 so lets make sure to delete it.
|
98 |
-
$wpdb->query("DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor");
|
99 |
|
100 |
// Record in the options that we've done this update.
|
101 |
-
$dbupdates = $WP_Statistics->get_option('pending_db_updates');
|
102 |
$dbupdates['date_ip_agent'] = false;
|
103 |
-
$WP_Statistics->update_option('pending_db_updates', $dbupdates);
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
|
108 |
-
if ( array_key_exists('visits', $_GET) ) {
|
109 |
-
if ( intval($_GET['visits']) == 1 ) {
|
110 |
// 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
|
111 |
-
$result = $wpdb->query("SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'");
|
112 |
|
113 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
114 |
if ( $result != 1 ) {
|
@@ -136,7 +136,7 @@ if ( array_key_exists('visits', $_GET) ) {
|
|
136 |
|
137 |
// Now do the acutal deletions.
|
138 |
foreach ( $deleterows as $row ) {
|
139 |
-
$wpdb->delete($wp_prefix . 'statistics_visit', array( 'ID' => $row ));
|
140 |
}
|
141 |
|
142 |
// The table should be ready to be updated now with the new index, so let's do it.
|
@@ -145,15 +145,15 @@ if ( array_key_exists('visits', $_GET) ) {
|
|
145 |
);
|
146 |
|
147 |
// Record in the options that we've done this update.
|
148 |
-
$dbupdates = $WP_Statistics->get_option('pending_db_updates');
|
149 |
$dbupdates['unique_date'] = false;
|
150 |
-
$WP_Statistics->update_option('pending_db_updates', $dbupdates);
|
151 |
}
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
if ( array_key_exists('historical-submit', $_POST) ) {
|
156 |
-
if ( array_key_exists('wps_historical_visitors', $_POST) ) {
|
157 |
$result = $wpdb->update(
|
158 |
$wp_prefix . "statistics_historical",
|
159 |
array( 'value' => $_POST['wps_historical_visitors'] ),
|
@@ -166,14 +166,14 @@ if ( array_key_exists('historical-submit', $_POST) ) {
|
|
166 |
array(
|
167 |
'value' => $_POST['wps_historical_visitors'],
|
168 |
'category' => 'visitors',
|
169 |
-
'page_id' => -1,
|
170 |
'uri' => '-1',
|
171 |
)
|
172 |
);
|
173 |
}
|
174 |
}
|
175 |
|
176 |
-
if ( array_key_exists('wps_historical_visits', $_POST) ) {
|
177 |
$result = $wpdb->update(
|
178 |
$wp_prefix . "statistics_historical",
|
179 |
array( 'value' => $_POST['wps_historical_visits'] ),
|
@@ -186,7 +186,7 @@ if ( array_key_exists('historical-submit', $_POST) ) {
|
|
186 |
array(
|
187 |
'value' => $_POST['wps_historical_visits'],
|
188 |
'category' => 'visits',
|
189 |
-
'page_id' => -2,
|
190 |
'uri' => '-2',
|
191 |
)
|
192 |
);
|
@@ -195,7 +195,7 @@ if ( array_key_exists('historical-submit', $_POST) ) {
|
|
195 |
|
196 |
}
|
197 |
|
198 |
-
if ( array_key_exists('search', $_GET) ) {
|
199 |
|
200 |
// Make sure we get all the search engines, even the ones the disabled ones.
|
201 |
$se_list = wp_statistics_searchengine_list();
|
@@ -203,8 +203,8 @@ if ( array_key_exists('search', $_GET) ) {
|
|
203 |
$limitsize = 10000;
|
204 |
|
205 |
foreach ( $se_list as $key => $se ) {
|
206 |
-
$sql = wp_statistics_searchengine_query($key);
|
207 |
-
$rowcount = $wpdb->get_var("SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}");
|
208 |
$offset = 0;
|
209 |
|
210 |
while ( $rowcount > 0 ) {
|
@@ -212,73 +212,73 @@ if ( array_key_exists('search', $_GET) ) {
|
|
212 |
"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}"
|
213 |
);
|
214 |
foreach ( $result as $row ) {
|
215 |
-
$parts = parse_url($row->referred);
|
216 |
$data['last_counter'] = $row->last_counter;
|
217 |
$data['engine'] = $key;
|
218 |
$data['host'] = $parts['host'];
|
219 |
-
$data['words'] = $WP_Statistics->Search_Engine_QueryString($row->referred);
|
220 |
$data['visitor'] = $row->ID;
|
221 |
|
222 |
if ( $data['words'] == 'No search query found!' ) {
|
223 |
$data['words'] = '';
|
224 |
}
|
225 |
|
226 |
-
$wpdb->insert($wpdb->prefix . 'statistics_search', $data);
|
227 |
-
$total++;
|
228 |
}
|
229 |
|
230 |
$rowcount -= $limitsize;
|
231 |
-
$offset
|
232 |
}
|
233 |
}
|
234 |
|
235 |
-
$WP_Statistics->update_option('search_converted', 1);
|
236 |
echo "<div class='updated settings-error'><p><strong>" .
|
237 |
-
sprintf(__('Search table conversion complete, %d rows added.', 'wp-statistics'), $total) .
|
238 |
"</strong></p></div>";
|
239 |
}
|
240 |
?>
|
241 |
<div class="wrap wp-statistics-settings">
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
'Resources/Information',
|
251 |
'wp-statistics'
|
252 |
); ?></li>
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-resources.php' ); ?>
|
262 |
-
|
263 |
-
|
264 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-export.php' ); ?>
|
265 |
-
|
266 |
-
|
267 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-purging.php' ); ?>
|
268 |
-
|
269 |
-
|
270 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-database.php' ); ?>
|
271 |
-
|
272 |
-
|
273 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-updates.php' ); ?>
|
274 |
-
|
275 |
-
|
276 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-historical.php' ); ?>
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
|
281 |
<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?>
|
282 |
-
|
283 |
-
|
284 |
</div>
|
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 |
echo WP_Statistics_Updates::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 |
+
if ( substr( $row->ip, 0, 6 ) != '#hash#' ) {
|
29 |
$wpdb->update(
|
30 |
$wp_prefix . "statistics_visitor",
|
31 |
array(
|
32 |
+
'ip' => '#hash#' . sha1( $row->ip . $randomString ),
|
33 |
),
|
34 |
array(
|
35 |
'ip' => $row->ip,
|
39 |
}
|
40 |
|
41 |
echo "<div class='updated settings-error'><p><strong>" .
|
42 |
+
__( 'IP Addresses replaced with hash values.', 'wp-statistics' ) .
|
43 |
"</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 |
+
new WP_Statistics_Install( $WP_Statistics );
|
51 |
echo "<div class='updated settings-error'><p><strong>" .
|
52 |
+
__( 'Install routine complete.', 'wp-statistics' ) .
|
53 |
"</strong></p></div>";
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
if ( array_key_exists( 'index', $_GET ) ) {
|
58 |
+
if ( intval( $_GET['index'] ) == 1 ) {
|
59 |
// 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
|
60 |
+
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'" );
|
61 |
|
62 |
if ( $result != 5 ) {
|
63 |
// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
|
83 |
|
84 |
// Now do the acutal deletions.
|
85 |
foreach ( $deleterows as $row ) {
|
86 |
+
$wpdb->delete( $wp_prefix . 'statistics_visitor', array( 'ID' => $row ) );
|
87 |
}
|
88 |
|
89 |
// The table should be ready to be updated now with the new index, so let's do it.
|
95 |
);
|
96 |
|
97 |
// We might have an old index left over from 7.1-7.3 so lets make sure to delete it.
|
98 |
+
$wpdb->query( "DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor" );
|
99 |
|
100 |
// Record in the options that we've done this update.
|
101 |
+
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
102 |
$dbupdates['date_ip_agent'] = false;
|
103 |
+
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
|
108 |
+
if ( array_key_exists( 'visits', $_GET ) ) {
|
109 |
+
if ( intval( $_GET['visits'] ) == 1 ) {
|
110 |
// 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
|
111 |
+
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
|
112 |
|
113 |
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
114 |
if ( $result != 1 ) {
|
136 |
|
137 |
// Now do the acutal deletions.
|
138 |
foreach ( $deleterows as $row ) {
|
139 |
+
$wpdb->delete( $wp_prefix . 'statistics_visit', array( 'ID' => $row ) );
|
140 |
}
|
141 |
|
142 |
// The table should be ready to be updated now with the new index, so let's do it.
|
145 |
);
|
146 |
|
147 |
// Record in the options that we've done this update.
|
148 |
+
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
149 |
$dbupdates['unique_date'] = false;
|
150 |
+
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
151 |
}
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
if ( array_key_exists( 'historical-submit', $_POST ) ) {
|
156 |
+
if ( array_key_exists( 'wps_historical_visitors', $_POST ) ) {
|
157 |
$result = $wpdb->update(
|
158 |
$wp_prefix . "statistics_historical",
|
159 |
array( 'value' => $_POST['wps_historical_visitors'] ),
|
166 |
array(
|
167 |
'value' => $_POST['wps_historical_visitors'],
|
168 |
'category' => 'visitors',
|
169 |
+
'page_id' => - 1,
|
170 |
'uri' => '-1',
|
171 |
)
|
172 |
);
|
173 |
}
|
174 |
}
|
175 |
|
176 |
+
if ( array_key_exists( 'wps_historical_visits', $_POST ) ) {
|
177 |
$result = $wpdb->update(
|
178 |
$wp_prefix . "statistics_historical",
|
179 |
array( 'value' => $_POST['wps_historical_visits'] ),
|
186 |
array(
|
187 |
'value' => $_POST['wps_historical_visits'],
|
188 |
'category' => 'visits',
|
189 |
+
'page_id' => - 2,
|
190 |
'uri' => '-2',
|
191 |
)
|
192 |
);
|
195 |
|
196 |
}
|
197 |
|
198 |
+
if ( array_key_exists( 'search', $_GET ) ) {
|
199 |
|
200 |
// Make sure we get all the search engines, even the ones the disabled ones.
|
201 |
$se_list = wp_statistics_searchengine_list();
|
203 |
$limitsize = 10000;
|
204 |
|
205 |
foreach ( $se_list as $key => $se ) {
|
206 |
+
$sql = wp_statistics_searchengine_query( $key );
|
207 |
+
$rowcount = $wpdb->get_var( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}" );
|
208 |
$offset = 0;
|
209 |
|
210 |
while ( $rowcount > 0 ) {
|
212 |
"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}"
|
213 |
);
|
214 |
foreach ( $result as $row ) {
|
215 |
+
$parts = parse_url( $row->referred );
|
216 |
$data['last_counter'] = $row->last_counter;
|
217 |
$data['engine'] = $key;
|
218 |
$data['host'] = $parts['host'];
|
219 |
+
$data['words'] = $WP_Statistics->Search_Engine_QueryString( $row->referred );
|
220 |
$data['visitor'] = $row->ID;
|
221 |
|
222 |
if ( $data['words'] == 'No search query found!' ) {
|
223 |
$data['words'] = '';
|
224 |
}
|
225 |
|
226 |
+
$wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
|
227 |
+
$total ++;
|
228 |
}
|
229 |
|
230 |
$rowcount -= $limitsize;
|
231 |
+
$offset += $limitsize;
|
232 |
}
|
233 |
}
|
234 |
|
235 |
+
$WP_Statistics->update_option( 'search_converted', 1 );
|
236 |
echo "<div class='updated settings-error'><p><strong>" .
|
237 |
+
sprintf( __( 'Search table conversion complete, %d rows added.', 'wp-statistics' ), $total ) .
|
238 |
"</strong></p></div>";
|
239 |
}
|
240 |
?>
|
241 |
<div class="wrap wp-statistics-settings">
|
242 |
+
<h2><?php _e( 'Optimization', 'wp-statistics' ); ?></h2>
|
243 |
+
|
244 |
+
<div id="poststuff">
|
245 |
+
<div id="post-body" class="metabox-holder columns-2">
|
246 |
+
<div class="wp-list-table widefat widefat">
|
247 |
+
<div class="wp-statistics-container">
|
248 |
+
<ul class="tabs">
|
249 |
+
<li class="tab-link current" data-tab="resources"><?php _e(
|
250 |
'Resources/Information',
|
251 |
'wp-statistics'
|
252 |
); ?></li>
|
253 |
+
<li class="tab-link" data-tab="export"><?php _e( 'Export', 'wp-statistics' ); ?></li>
|
254 |
+
<li class="tab-link" data-tab="purging"><?php _e( 'Purging', 'wp-statistics' ); ?></li>
|
255 |
+
<li class="tab-link" data-tab="database"><?php _e( 'Database', 'wp-statistics' ); ?></li>
|
256 |
+
<li class="tab-link" data-tab="updates"><?php _e( 'Updates', 'wp-statistics' ); ?></li>
|
257 |
+
<li class="tab-link" data-tab="historical"><?php _e( 'Historical', 'wp-statistics' ); ?></li>
|
258 |
+
</ul>
|
259 |
+
|
260 |
+
<div id="resources" class="tab-content current">
|
261 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-resources.php' ); ?>
|
262 |
+
</div>
|
263 |
+
<div id="export" class="tab-content">
|
264 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-export.php' ); ?>
|
265 |
+
</div>
|
266 |
+
<div id="purging" class="tab-content">
|
267 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-purging.php' ); ?>
|
268 |
+
</div>
|
269 |
+
<div id="database" class="tab-content">
|
270 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-database.php' ); ?>
|
271 |
+
</div>
|
272 |
+
<div id="updates" class="tab-content">
|
273 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-updates.php' ); ?>
|
274 |
+
</div>
|
275 |
+
<div id="historical" class="tab-content">
|
276 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-historical.php' ); ?>
|
277 |
+
</div>
|
278 |
+
</div><!-- container -->
|
279 |
+
</div>
|
280 |
|
281 |
<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?>
|
282 |
+
</div>
|
283 |
+
</div>
|
284 |
</div>
|
includes/settings/tabs/wps-about.php
CHANGED
@@ -1,36 +1,37 @@
|
|
1 |
<table class="form-table">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
15 |
<?php echo sprintf(
|
16 |
-
__('This product includes GeoLite2 data created by %s.', 'wp-statistics'),
|
17 |
'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>'
|
18 |
); ?>
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
__(
|
35 |
'Fell like showing us how much you enjoy WP Statistics? Drop by our %sdonation%s page and show us some love!',
|
36 |
'wp-statistics'
|
@@ -38,14 +39,14 @@
|
|
38 |
'<a href="http://wp-statistics.com/donate" target="_blank">',
|
39 |
'</a>'
|
40 |
); ?></td>
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
__(
|
50 |
'Come visit our great new %swebsite%s and keep up to date on the latest news about WP Statistics.',
|
51 |
'wp-statistics'
|
@@ -53,14 +54,14 @@
|
|
53 |
'<a href="http://wp-statistics.com" target="_blank">',
|
54 |
'</a>'
|
55 |
); ?></td>
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
__(
|
65 |
'Thanks for installing WP Statistics, we encourage you to submit a %srating and review%s over at WordPress.org. Your feedback is greatly appreciated!',
|
66 |
'wp-statistics'
|
@@ -68,15 +69,15 @@
|
|
68 |
'<a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank">',
|
69 |
'</a>'
|
70 |
); ?>
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
|
80 |
__(
|
81 |
'WP Statistics supports internationalization. Please visit %sWP Statistics translations page%s to help translation.',
|
82 |
'wp-statistics'
|
@@ -84,58 +85,58 @@
|
|
84 |
'<a href="https://wp-statistics.com/translations/" target="_blank">',
|
85 |
'</a>'
|
86 |
); ?></td>
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
"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:",
|
97 |
'wp-statistics'
|
98 |
); ?></p>
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
__('Have you read the %sFAQs%s?', 'wp-statistics'),
|
103 |
'<a title="' .
|
104 |
-
__('FAQs', 'wp-statistics') .
|
105 |
'" href="http://wp-statistics.com/category/faq/" target="_blank">',
|
106 |
'</a>'
|
107 |
); ?></li>
|
108 |
-
|
109 |
-
__('Have you read the %sdocumentation%s?', 'wp-statistics'),
|
110 |
'<a title="' .
|
111 |
-
__('Documentation', 'wp-statistics') .
|
112 |
'" href="http://wp-statistics.com/category/documentation/">',
|
113 |
'</a>'
|
114 |
); ?></li>
|
115 |
-
|
116 |
-
__('Have you search the %ssupport forum%s for a similar issue?', 'wp-statistics'),
|
117 |
'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">',
|
118 |
'</a>'
|
119 |
); ?></li>
|
120 |
-
|
121 |
'Have you search the Internet for any error messages you are receiving?',
|
122 |
'wp-statistics'
|
123 |
); ?></li>
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
'Have you tried disabling any other plugins you may have installed?',
|
133 |
'wp-statistics'
|
134 |
); ?></li>
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
'Are you getting a blank or incomplete page displayed in your browser?',
|
140 |
'wp-statistics'
|
141 |
) .
|
@@ -144,10 +145,10 @@
|
|
144 |
'Did you view the source for the page and check for any fatal errors?',
|
145 |
'wp-statistics'
|
146 |
); ?></li>
|
147 |
-
|
148 |
-
|
149 |
|
150 |
-
|
151 |
__(
|
152 |
'Then please open a new thread on the %sWordPress.org support forum%s and we\'ll respond as soon as possible.',
|
153 |
'wp-statistics'
|
@@ -155,8 +156,8 @@
|
|
155 |
'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">',
|
156 |
'</a>'
|
157 |
); ?></p>
|
158 |
-
|
159 |
-
|
160 |
|
161 |
-
|
162 |
</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::$reg['version'] ); ?></h2>
|
11 |
+
</td>
|
12 |
+
</tr>
|
13 |
+
|
14 |
+
<tr valign="top">
|
15 |
+
<td scope="row" align="center">
|
16 |
<?php echo sprintf(
|
17 |
+
__( 'This product includes GeoLite2 data created by %s.', 'wp-statistics' ),
|
18 |
'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>'
|
19 |
); ?>
|
20 |
+
</td>
|
21 |
+
</tr>
|
22 |
|
23 |
+
<tr valign="top">
|
24 |
+
<td scope="row" align="center">
|
25 |
+
<hr/>
|
26 |
+
</td>
|
27 |
+
</tr>
|
28 |
|
29 |
+
<tr valign="top">
|
30 |
+
<td scope="row" colspan="2"><h2><?php _e( 'Donate', 'wp-statistics' ); ?></h2></td>
|
31 |
+
</tr>
|
32 |
|
33 |
+
<tr valign="top">
|
34 |
+
<td scope="row" colspan="2"><?php echo sprintf(
|
35 |
__(
|
36 |
'Fell like showing us how much you enjoy WP Statistics? Drop by our %sdonation%s page and show us some love!',
|
37 |
'wp-statistics'
|
39 |
'<a href="http://wp-statistics.com/donate" target="_blank">',
|
40 |
'</a>'
|
41 |
); ?></td>
|
42 |
+
</tr>
|
43 |
|
44 |
+
<tr valign="top">
|
45 |
+
<td scope="row" colspan="2"><h2><?php _e( 'Visit Us Online', 'wp-statistics' ); ?></h2></td>
|
46 |
+
</tr>
|
47 |
|
48 |
+
<tr valign="top">
|
49 |
+
<td scope="row" colspan="2"><?php echo sprintf(
|
50 |
__(
|
51 |
'Come visit our great new %swebsite%s and keep up to date on the latest news about WP Statistics.',
|
52 |
'wp-statistics'
|
54 |
'<a href="http://wp-statistics.com" target="_blank">',
|
55 |
'</a>'
|
56 |
); ?></td>
|
57 |
+
</tr>
|
58 |
|
59 |
+
<tr valign="top">
|
60 |
+
<td scope="row" colspan="2"><h2><?php _e( 'Rate and Review at WordPress.org', 'wp-statistics' ); ?></h2></td>
|
61 |
+
</tr>
|
62 |
|
63 |
+
<tr valign="top">
|
64 |
+
<td scope="row" colspan="2"><?php printf(
|
65 |
__(
|
66 |
'Thanks for installing WP Statistics, we encourage you to submit a %srating and review%s over at WordPress.org. Your feedback is greatly appreciated!',
|
67 |
'wp-statistics'
|
69 |
'<a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank">',
|
70 |
'</a>'
|
71 |
); ?>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
|
75 |
+
<tr valign="top">
|
76 |
+
<td scope="row" colspan="2"><h2><?php _e( 'Translations', 'wp-statistics' ); ?></h2></td>
|
77 |
+
</tr>
|
78 |
|
79 |
+
<tr valign="top">
|
80 |
+
<td scope="row" colspan="2"><?php echo sprintf(
|
81 |
__(
|
82 |
'WP Statistics supports internationalization. Please visit %sWP Statistics translations page%s to help translation.',
|
83 |
'wp-statistics'
|
85 |
'<a href="https://wp-statistics.com/translations/" target="_blank">',
|
86 |
'</a>'
|
87 |
); ?></td>
|
88 |
+
</tr>
|
89 |
|
90 |
+
<tr valign="top">
|
91 |
+
<td scope="row" colspan="2"><h2><?php _e( 'Support', 'wp-statistics' ); ?></h2></td>
|
92 |
+
</tr>
|
93 |
|
94 |
+
<tr valign="top">
|
95 |
+
<td scope="row" colspan="2">
|
96 |
+
<p><?php _e(
|
97 |
"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:",
|
98 |
'wp-statistics'
|
99 |
); ?></p>
|
100 |
|
101 |
+
<ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
|
102 |
+
<li><?php echo sprintf(
|
103 |
+
__( 'Have you read the %sFAQs%s?', 'wp-statistics' ),
|
104 |
'<a title="' .
|
105 |
+
__( 'FAQs', 'wp-statistics' ) .
|
106 |
'" href="http://wp-statistics.com/category/faq/" target="_blank">',
|
107 |
'</a>'
|
108 |
); ?></li>
|
109 |
+
<li><?php echo sprintf(
|
110 |
+
__( 'Have you read the %sdocumentation%s?', 'wp-statistics' ),
|
111 |
'<a title="' .
|
112 |
+
__( 'Documentation', 'wp-statistics' ) .
|
113 |
'" href="http://wp-statistics.com/category/documentation/">',
|
114 |
'</a>'
|
115 |
); ?></li>
|
116 |
+
<li><?php echo sprintf(
|
117 |
+
__( 'Have you search the %ssupport forum%s for a similar issue?', 'wp-statistics' ),
|
118 |
'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">',
|
119 |
'</a>'
|
120 |
); ?></li>
|
121 |
+
<li><?php _e(
|
122 |
'Have you search the Internet for any error messages you are receiving?',
|
123 |
'wp-statistics'
|
124 |
); ?></li>
|
125 |
+
<li><?php _e( 'Make sure you have access to your PHP error logs.', 'wp-statistics' ); ?></li>
|
126 |
+
</ul>
|
127 |
|
128 |
+
<p><?php _e( 'And a few things to double-check:', 'wp-statistics' ); ?></p>
|
129 |
|
130 |
+
<ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;">
|
131 |
+
<li><?php _e( 'How\'s your memory_limit in php.ini?', 'wp-statistics' ); ?></li>
|
132 |
+
<li><?php _e(
|
133 |
'Have you tried disabling any other plugins you may have installed?',
|
134 |
'wp-statistics'
|
135 |
); ?></li>
|
136 |
+
<li><?php _e( 'Have you tried using the default WordPress theme?', 'wp-statistics' ); ?></li>
|
137 |
+
<li><?php _e( 'Have you double checked the plugin settings?', 'wp-statistics' ); ?></li>
|
138 |
+
<li><?php _e( 'Do you have all the required PHP extensions installed?', 'wp-statistics' ); ?></li>
|
139 |
+
<li><?php echo __(
|
140 |
'Are you getting a blank or incomplete page displayed in your browser?',
|
141 |
'wp-statistics'
|
142 |
) .
|
145 |
'Did you view the source for the page and check for any fatal errors?',
|
146 |
'wp-statistics'
|
147 |
); ?></li>
|
148 |
+
<li><?php _e( 'Have you checked your PHP and web server error logs?', 'wp-statistics' ); ?></li>
|
149 |
+
</ul>
|
150 |
|
151 |
+
<p><?php _e( 'Still not having any luck?', 'wp-statistics' ); ?><?php echo sprintf(
|
152 |
__(
|
153 |
'Then please open a new thread on the %sWordPress.org support forum%s and we\'ll respond as soon as possible.',
|
154 |
'wp-statistics'
|
156 |
'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">',
|
157 |
'</a>'
|
158 |
); ?></p>
|
159 |
+
</td>
|
160 |
+
</tr>
|
161 |
|
162 |
+
</tbody>
|
163 |
</table>
|
includes/settings/tabs/wps-access-level.php
CHANGED
@@ -5,27 +5,27 @@ $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 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
<?php
|
30 |
global $wp_roles;
|
31 |
|
@@ -36,15 +36,15 @@ if ( $wps_nonce_valid ) {
|
|
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
|
48 |
$option_list = '';
|
49 |
|
50 |
foreach ( $all_caps as $key => $cap ) {
|
@@ -56,20 +56,20 @@ if ( $wps_nonce_valid ) {
|
|
56 |
$option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
|
57 |
}
|
58 |
?>
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
'Required user level to view WP Statistics',
|
63 |
'wp-statistics'
|
64 |
) ?>:</label>
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
<?php
|
72 |
-
$manage_cap = $WP_Statistics->get_option('manage_capability', 'manage_options');
|
73 |
|
74 |
foreach ( $all_caps as $key => $cap ) {
|
75 |
if ( $key == $manage_cap ) {
|
@@ -80,21 +80,21 @@ if ( $wps_nonce_valid ) {
|
|
80 |
$option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
|
81 |
}
|
82 |
?>
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
'Required user level to manage WP Statistics',
|
87 |
'wp-statistics'
|
88 |
) ?>:</label>
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
__(
|
99 |
'See the %sWordPress Roles and Capabilities page%s for details on capability levels.',
|
100 |
'wp-statistics'
|
@@ -103,27 +103,27 @@ if ( $wps_nonce_valid ) {
|
|
103 |
'</a>'
|
104 |
); ?></p>
|
105 |
|
106 |
-
|
107 |
'Hint: manage_network = Super Admin Network, manage_options = Administrator, edit_others_posts = Editor, publish_posts = Author, edit_posts = Contributor, read = Everyone.',
|
108 |
'wp-statistics'
|
109 |
); ?></p>
|
110 |
|
111 |
-
|
112 |
'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.',
|
113 |
'wp-statistics'
|
114 |
); ?></p>
|
115 |
|
116 |
-
|
117 |
__(
|
118 |
'If you need a more robust solution to delegate access you might want to look at %s in the WordPress plugin directory.',
|
119 |
'wp-statistics'
|
120 |
),
|
121 |
'<a href="http://wordpress.org/plugins/capability-manager-enhanced/" target=_blank>Capability Manager Enhanced</a>'
|
122 |
); ?></p>
|
123 |
-
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit');
|
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 |
|
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 ) {
|
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(
|
62 |
'Required user level to view WP Statistics',
|
63 |
'wp-statistics'
|
64 |
) ?>:</label>
|
65 |
+
</th>
|
66 |
+
<td>
|
67 |
+
<select dir="ltr" id="wps_read_capability" name="wps_read_capability"><?php echo $option_list; ?></select>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
|
71 |
<?php
|
72 |
+
$manage_cap = $WP_Statistics->get_option( 'manage_capability', 'manage_options' );
|
73 |
|
74 |
foreach ( $all_caps as $key => $cap ) {
|
75 |
if ( $key == $manage_cap ) {
|
80 |
$option_list .= "<option value='{$key}'{$selected}>{$key}</option>";
|
81 |
}
|
82 |
?>
|
83 |
+
<tr valign="top">
|
84 |
+
<th scope="row">
|
85 |
+
<label for="wps_manage_capability"><?php _e(
|
86 |
'Required user level to manage WP Statistics',
|
87 |
'wp-statistics'
|
88 |
) ?>:</label>
|
89 |
+
</th>
|
90 |
+
<td>
|
91 |
+
<select dir="ltr" id="wps_manage_capability" name="wps_manage_capability"><?php echo $option_list; ?></select>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
|
95 |
+
<tr valign="top">
|
96 |
+
<th scope="row" colspan="2">
|
97 |
+
<p class="description"><?php echo sprintf(
|
98 |
__(
|
99 |
'See the %sWordPress Roles and Capabilities page%s for details on capability levels.',
|
100 |
'wp-statistics'
|
103 |
'</a>'
|
104 |
); ?></p>
|
105 |
|
106 |
+
<p class="description"><?php echo __(
|
107 |
'Hint: manage_network = Super Admin Network, manage_options = Administrator, edit_others_posts = Editor, publish_posts = Author, edit_posts = Contributor, read = Everyone.',
|
108 |
'wp-statistics'
|
109 |
); ?></p>
|
110 |
|
111 |
+
<p class="description"><?php echo __(
|
112 |
'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.',
|
113 |
'wp-statistics'
|
114 |
); ?></p>
|
115 |
|
116 |
+
<p class="description"><?php echo sprintf(
|
117 |
__(
|
118 |
'If you need a more robust solution to delegate access you might want to look at %s in the WordPress plugin directory.',
|
119 |
'wp-statistics'
|
120 |
),
|
121 |
'<a href="http://wordpress.org/plugins/capability-manager-enhanced/" target=_blank>Capability Manager Enhanced</a>'
|
122 |
); ?></p>
|
123 |
+
</th>
|
124 |
+
</tr>
|
125 |
|
126 |
+
</tbody>
|
127 |
+
</table>
|
128 |
|
129 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-exclusions.php
CHANGED
@@ -6,32 +6,32 @@ $role_list = $wp_roles->get_names();
|
|
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') .
|
26 |
' [' .
|
27 |
$WP_Statistics->Current_Date() .
|
28 |
']',
|
29 |
-
'post_content' => __('This is the honey pot for WP Statistics to use, do not delete.', 'wp-statistics'),
|
30 |
'post_status' => 'publish',
|
31 |
'post_author' => 1,
|
32 |
);
|
33 |
|
34 |
-
$_POST['wps_honeypot_postid'] = wp_insert_post($my_post);
|
35 |
}
|
36 |
|
37 |
$wps_option_list = array_merge(
|
@@ -57,386 +57,386 @@ if ( $wps_nonce_valid ) {
|
|
57 |
);
|
58 |
|
59 |
foreach ( $wps_option_list as $option ) {
|
60 |
-
$new_option = str_replace("wps_", "", $option);
|
61 |
|
62 |
-
if ( array_key_exists($option, $_POST) ) {
|
63 |
$value = $_POST[ $option ];
|
64 |
} else {
|
65 |
$value = '';
|
66 |
}
|
67 |
-
$WP_Statistics->store_option($new_option, $value);
|
68 |
}
|
69 |
}
|
70 |
|
71 |
?>
|
72 |
|
73 |
-
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
? "checked='checked'" : ''; ?>><label for="wps-exclusions"><?php _e(
|
87 |
'Enable',
|
88 |
'wp-statistics'
|
89 |
); ?></label>
|
90 |
|
91 |
-
|
92 |
'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.',
|
93 |
'wp-statistics'
|
94 |
); ?></p>
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
<?php
|
102 |
$role_option_list = '';
|
103 |
|
104 |
foreach ( $role_list as $role ) {
|
105 |
-
$store_name
|
106 |
-
$option_name
|
107 |
$role_option_list .= $option_name . ',';
|
108 |
|
109 |
-
$translated_role_name = translate_user_role($role);
|
110 |
?>
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e(
|
119 |
'Exclude',
|
120 |
'wp-statistics'
|
121 |
); ?></label>
|
122 |
|
123 |
-
|
124 |
-
__('Exclude %s role from data collection.', 'wp-statistics'),
|
125 |
$translated_role_name
|
126 |
); ?></p>
|
127 |
-
|
128 |
-
|
129 |
<?php } ?>
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
<textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php
|
139 |
-
$robotlist = $WP_Statistics->get_option('robotlist');
|
140 |
|
141 |
-
if(!isset($wps_robotarray)){
|
142 |
include( WP_Statistics::$reg['plugin-dir'] . 'includes/robotslist.php' );
|
143 |
}
|
144 |
|
145 |
if ( $robotlist == '' ) {
|
146 |
-
$robotlist = implode("\n", $wps_robotarray);
|
147 |
-
update_option('wps_robotlist', $robotlist);
|
148 |
}
|
149 |
|
150 |
-
echo htmlentities($robotlist, ENT_QUOTES); ?></textarea>
|
151 |
|
152 |
-
|
153 |
'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.',
|
154 |
'wp-statistics'
|
155 |
); ?></p>
|
156 |
-
|
157 |
'\n',
|
158 |
$wps_robotarray
|
159 |
-
); ?>';" class="button"><?php _e('Reset to Default', 'wp-statistics'); ?></a>
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
? "checked='checked'" : ''; ?>><label for="force_robot_update"><?php _e(
|
172 |
'Enable',
|
173 |
'wp-statistics'
|
174 |
); ?></label>
|
175 |
|
176 |
-
|
177 |
__(
|
178 |
'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.',
|
179 |
'wp-statistics'
|
180 |
),
|
181 |
$role
|
182 |
); ?></p>
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
'Treat visitors with more than this number of visits per day as robots. 0 = disabled.',
|
196 |
'wp-statistics'
|
197 |
); ?></p>
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
<textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code"
|
205 |
-
|
206 |
-
$WP_Statistics->get_option('exclude_ip'),
|
207 |
ENT_QUOTES
|
208 |
); ?></textarea>
|
209 |
|
210 |
-
|
211 |
'A list of IP addresses and subnet masks (one per line) to exclude from statistics collection.',
|
212 |
'wp-statistics'
|
213 |
); ?></p>
|
214 |
|
215 |
-
|
216 |
'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.',
|
217 |
'wp-statistics'
|
218 |
); ?></p>
|
219 |
|
220 |
-
|
221 |
'For IPv6 addresses use the fc00::/7 format.',
|
222 |
'wp-statistics'
|
223 |
); ?></p>
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
? "checked='checked'" : ''; ?>><label for="wps_use_honeypot"><?php _e(
|
241 |
'Enable',
|
242 |
'wp-statistics'
|
243 |
); ?></label>
|
244 |
|
245 |
-
|
246 |
'Use a honey pot page to identify robots.',
|
247 |
'wp-statistics'
|
248 |
); ?></p>
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
'The post id to use for the honeypot page.',
|
262 |
'wp-statistics'
|
263 |
); ?></p>
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
true ? "checked='checked'" : ''; ?>><label
|
278 |
-
|
279 |
|
280 |
-
|
281 |
'Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.',
|
282 |
'wp-statistics'
|
283 |
); ?></p>
|
284 |
-
|
285 |
-
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
<textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code"
|
295 |
-
|
296 |
-
$WP_Statistics->get_option('excluded_countries'),
|
297 |
ENT_QUOTES
|
298 |
); ?></textarea>
|
299 |
|
300 |
-
|
301 |
'A list of country codes (one per line, two letters each) to exclude from statistics collection. Use "000" (three zeros) to exclude unknown countries.',
|
302 |
'wp-statistics'
|
303 |
); ?></p>
|
304 |
-
|
305 |
-
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
<textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code"
|
311 |
-
|
312 |
-
$WP_Statistics->get_option('included_countries'),
|
313 |
ENT_QUOTES
|
314 |
); ?></textarea>
|
315 |
|
316 |
-
|
317 |
'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.',
|
318 |
'wp-statistics'
|
319 |
); ?></p>
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
<textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code"
|
331 |
-
|
332 |
-
$WP_Statistics->get_option('excluded_hosts'),
|
333 |
ENT_QUOTES
|
334 |
); ?></textarea>
|
335 |
|
336 |
-
|
337 |
'A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.',
|
338 |
'wp-statistics'
|
339 |
); ?></p>
|
340 |
-
|
341 |
|
342 |
-
|
343 |
'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.',
|
344 |
'wp-statistics'
|
345 |
); ?></p>
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-loginpage"><?php _e(
|
359 |
'Exclude',
|
360 |
'wp-statistics'
|
361 |
); ?></label>
|
362 |
|
363 |
-
|
364 |
'Exclude the login page for registering as a hit.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-feeds"><?php _e(
|
375 |
'Exclude',
|
376 |
'wp-statistics'
|
377 |
); ?></label>
|
378 |
|
379 |
-
|
380 |
'Exclude the RSS feeds for registering as a hit.',
|
381 |
'wp-statistics'
|
382 |
); ?></p>
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-404s"><?php _e(
|
391 |
'Exclude',
|
392 |
'wp-statistics'
|
393 |
); ?></label>
|
394 |
|
395 |
-
|
396 |
'Exclude any URL that returns a "404 - Not Found" message.',
|
397 |
'wp-statistics'
|
398 |
); ?></p>
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-ajax"><?php _e(
|
407 |
'Exclude',
|
408 |
'wp-statistics'
|
409 |
); ?></label>
|
410 |
|
411 |
-
|
412 |
'Exclude any call to the WordPress AJAX system.',
|
413 |
'wp-statistics'
|
414 |
); ?></p>
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
<textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code"
|
421 |
-
|
422 |
-
$WP_Statistics->get_option('excluded_urls'),
|
423 |
ENT_QUOTES
|
424 |
); ?></textarea>
|
425 |
|
426 |
-
|
427 |
'A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.',
|
428 |
'wp-statistics'
|
429 |
); ?></p>
|
430 |
-
|
431 |
|
432 |
-
|
433 |
'Note: this option will NOT handle url parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.',
|
434 |
'wp-statistics'
|
435 |
); ?></p>
|
436 |
-
|
437 |
-
|
438 |
|
439 |
-
|
440 |
-
|
441 |
|
442 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit');
|
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' ) .
|
26 |
' [' .
|
27 |
$WP_Statistics->Current_Date() .
|
28 |
']',
|
29 |
+
'post_content' => __( 'This is the honey pot for WP Statistics to use, do not delete.', 'wp-statistics' ),
|
30 |
'post_status' => 'publish',
|
31 |
'post_author' => 1,
|
32 |
);
|
33 |
|
34 |
+
$_POST['wps_honeypot_postid'] = wp_insert_post( $my_post );
|
35 |
}
|
36 |
|
37 |
$wps_option_list = array_merge(
|
57 |
);
|
58 |
|
59 |
foreach ( $wps_option_list as $option ) {
|
60 |
+
$new_option = str_replace( "wps_", "", $option );
|
61 |
|
62 |
+
if ( array_key_exists( $option, $_POST ) ) {
|
63 |
$value = $_POST[ $option ];
|
64 |
} else {
|
65 |
$value = '';
|
66 |
}
|
67 |
+
$WP_Statistics->store_option( $new_option, $value );
|
68 |
}
|
69 |
}
|
70 |
|
71 |
?>
|
72 |
|
73 |
+
<table class="form-table">
|
74 |
+
<tbody>
|
75 |
|
76 |
+
<tr valign="top">
|
77 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Exclusions', 'wp-statistics' ); ?></h3></th>
|
78 |
+
</tr>
|
79 |
|
80 |
+
<tr valign="top">
|
81 |
+
<th scope="row"><label for="wps-exclusions"><?php _e( 'Record exclusions', 'wp-statistics' ); ?></label>:
|
82 |
+
</th>
|
83 |
+
<td>
|
84 |
+
<input id="wps-exclusions" type="checkbox" value="1"
|
85 |
+
name="wps_record_exclusions" <?php echo $WP_Statistics->get_option( 'record_exclusions' ) == true
|
86 |
? "checked='checked'" : ''; ?>><label for="wps-exclusions"><?php _e(
|
87 |
'Enable',
|
88 |
'wp-statistics'
|
89 |
); ?></label>
|
90 |
|
91 |
+
<p class="description"><?php _e(
|
92 |
'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.',
|
93 |
'wp-statistics'
|
94 |
); ?></p>
|
95 |
+
</td>
|
96 |
+
</tr>
|
97 |
|
98 |
+
<tr valign="top">
|
99 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Exclude User Roles', 'wp-statistics' ); ?></h3></th>
|
100 |
+
</tr>
|
101 |
<?php
|
102 |
$role_option_list = '';
|
103 |
|
104 |
foreach ( $role_list as $role ) {
|
105 |
+
$store_name = 'exclude_' . str_replace( " ", "_", strtolower( $role ) );
|
106 |
+
$option_name = 'wps_' . $store_name;
|
107 |
$role_option_list .= $option_name . ',';
|
108 |
|
109 |
+
$translated_role_name = translate_user_role( $role );
|
110 |
?>
|
111 |
|
112 |
+
<tr valign="top">
|
113 |
+
<th scope="row"><label for="<?php echo $option_name; ?>"><?php echo $translated_role_name; ?>:</label>
|
114 |
+
</th>
|
115 |
+
<td>
|
116 |
+
<input id="<?php echo $option_name; ?>" type="checkbox" value="1"
|
117 |
+
name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true
|
118 |
? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e(
|
119 |
'Exclude',
|
120 |
'wp-statistics'
|
121 |
); ?></label>
|
122 |
|
123 |
+
<p class="description"><?php echo sprintf(
|
124 |
+
__( 'Exclude %s role from data collection.', 'wp-statistics' ),
|
125 |
$translated_role_name
|
126 |
); ?></p>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
<?php } ?>
|
130 |
|
131 |
+
<tr valign="top">
|
132 |
+
<th scope="row" colspan="2"><h3><?php _e( 'IP/Robot Exclusions', 'wp-statistics' ); ?></h3></th>
|
133 |
+
</tr>
|
134 |
|
135 |
+
<tr valign="top">
|
136 |
+
<th scope="row"><?php _e( 'Robot list', 'wp-statistics' ); ?>:</th>
|
137 |
+
<td>
|
138 |
<textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php
|
139 |
+
$robotlist = $WP_Statistics->get_option( 'robotlist' );
|
140 |
|
141 |
+
if ( ! isset( $wps_robotarray ) ) {
|
142 |
include( WP_Statistics::$reg['plugin-dir'] . 'includes/robotslist.php' );
|
143 |
}
|
144 |
|
145 |
if ( $robotlist == '' ) {
|
146 |
+
$robotlist = implode( "\n", $wps_robotarray );
|
147 |
+
update_option( 'wps_robotlist', $robotlist );
|
148 |
}
|
149 |
|
150 |
+
echo htmlentities( $robotlist, ENT_QUOTES ); ?></textarea>
|
151 |
|
152 |
+
<p class="description"><?php echo __(
|
153 |
'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.',
|
154 |
'wp-statistics'
|
155 |
); ?></p>
|
156 |
+
<a onclick="var wps_robotlist = getElementById('wps_robotlist'); wps_robotlist.value = '<?php echo implode(
|
157 |
'\n',
|
158 |
$wps_robotarray
|
159 |
+
); ?>';" class="button"><?php _e( 'Reset to Default', 'wp-statistics' ); ?></a>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
|
163 |
+
<tr valign="top">
|
164 |
+
<th scope="row">
|
165 |
+
<label for="force_robot_update"><?php _e( 'Force robot list update after upgrades', 'wp-statistics' ); ?>
|
166 |
+
:</label>
|
167 |
+
</th>
|
168 |
+
<td>
|
169 |
+
<input id="force_robot_update" type="checkbox" value="1"
|
170 |
+
name="wps_force_robot_update" <?php echo $WP_Statistics->get_option( 'force_robot_update' ) == true
|
171 |
? "checked='checked'" : ''; ?>><label for="force_robot_update"><?php _e(
|
172 |
'Enable',
|
173 |
'wp-statistics'
|
174 |
); ?></label>
|
175 |
|
176 |
+
<p class="description"><?php echo sprintf(
|
177 |
__(
|
178 |
'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.',
|
179 |
'wp-statistics'
|
180 |
),
|
181 |
$role
|
182 |
); ?></p>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
|
186 |
+
<tr valign="top">
|
187 |
+
<th scope="row"><label for="wps_robot_threshold"><?php _e( 'Robot visit threshold', 'wp-statistics' ); ?>
|
188 |
+
:</label>
|
189 |
+
</th>
|
190 |
+
<td>
|
191 |
+
<input id="wps_robot_threshold" type="text" size="5" name="wps_robot_threshold"
|
192 |
+
value="<?php echo $WP_Statistics->get_option( 'robot_threshold' ); ?>">
|
193 |
+
|
194 |
+
<p class="description"><?php echo __(
|
195 |
'Treat visitors with more than this number of visits per day as robots. 0 = disabled.',
|
196 |
'wp-statistics'
|
197 |
); ?></p>
|
198 |
+
</td>
|
199 |
+
</tr>
|
200 |
|
201 |
+
<tr valign="top">
|
202 |
+
<th scope="row"><?php _e( 'Excluded IP address list', 'wp-statistics' ); ?>:</th>
|
203 |
+
<td>
|
204 |
<textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code"
|
205 |
+
dir="ltr"><?php echo htmlentities(
|
206 |
+
$WP_Statistics->get_option( 'exclude_ip' ),
|
207 |
ENT_QUOTES
|
208 |
); ?></textarea>
|
209 |
|
210 |
+
<p class="description"><?php echo __(
|
211 |
'A list of IP addresses and subnet masks (one per line) to exclude from statistics collection.',
|
212 |
'wp-statistics'
|
213 |
); ?></p>
|
214 |
|
215 |
+
<p class="description"><?php echo __(
|
216 |
'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.',
|
217 |
'wp-statistics'
|
218 |
); ?></p>
|
219 |
|
220 |
+
<p class="description"><?php echo __(
|
221 |
'For IPv6 addresses use the fc00::/7 format.',
|
222 |
'wp-statistics'
|
223 |
); ?></p>
|
224 |
+
<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' ); }"
|
225 |
+
class="button"><?php _e( 'Add 10.0.0.0', 'wp-statistics' ); ?></a>
|
226 |
+
<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' ); }"
|
227 |
+
class="button"><?php _e( 'Add 172.16.0.0', 'wp-statistics' ); ?></a>
|
228 |
+
<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' ); }"
|
229 |
+
class="button"><?php _e( 'Add 192.168.0.0', 'wp-statistics' ); ?></a>
|
230 |
+
<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' ); }"
|
231 |
+
class="button"><?php _e( 'Add fc00::/7', 'wp-statistics' ); ?></a>
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
+
|
235 |
+
<tr valign="top">
|
236 |
+
<th scope="row"><?php _e( 'Use honey pot', 'wp-statistics' ); ?>:</th>
|
237 |
+
<td>
|
238 |
+
<input id="use_honeypot" type="checkbox" value="1"
|
239 |
+
name="wps_use_honeypot" <?php echo $WP_Statistics->get_option( 'use_honeypot' ) == true
|
240 |
? "checked='checked'" : ''; ?>><label for="wps_use_honeypot"><?php _e(
|
241 |
'Enable',
|
242 |
'wp-statistics'
|
243 |
); ?></label>
|
244 |
|
245 |
+
<p class="description"><?php echo __(
|
246 |
'Use a honey pot page to identify robots.',
|
247 |
'wp-statistics'
|
248 |
); ?></p>
|
249 |
+
</td>
|
250 |
+
</tr>
|
251 |
+
|
252 |
+
<tr valign="top">
|
253 |
+
<th scope="row"><label for="honeypot_postid"><?php _e( 'Honey pot post id', 'wp-statistics' ); ?>:</label>
|
254 |
+
</th>
|
255 |
+
<td>
|
256 |
+
<input id="honeypot_postid" type="text"
|
257 |
+
value="<?php echo htmlentities( $WP_Statistics->get_option( 'honeypot_postid' ), ENT_QUOTES ); ?>"
|
258 |
+
size="5" name="wps_honeypot_postid">
|
259 |
+
|
260 |
+
<p class="description"><?php echo __(
|
261 |
'The post id to use for the honeypot page.',
|
262 |
'wp-statistics'
|
263 |
); ?></p>
|
264 |
+
<input id="wps_create_honeypot" type="checkbox" value="1" name="wps_create_honeypot"><label
|
265 |
+
for="wps_create_honeypot"><?php _e( 'Create a new honey pot page', 'wp-statistics' ); ?></label>
|
266 |
+
</td>
|
267 |
+
</tr>
|
268 |
+
|
269 |
+
<tr valign="top">
|
270 |
+
<th scope="row">
|
271 |
+
<label for="corrupt_browser_info"><?php _e( 'Treat corrupt browser info as a bot', 'wp-statistics' ); ?>
|
272 |
+
:</label>
|
273 |
+
</th>
|
274 |
+
<td>
|
275 |
+
<input id="corrupt_browser_info" type="checkbox" value="1"
|
276 |
+
name="wps_corrupt_browser_info" <?php echo $WP_Statistics->get_option( 'corrupt_browser_info' ) ==
|
277 |
true ? "checked='checked'" : ''; ?>><label
|
278 |
+
for="wps_corrupt_browser_info"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
279 |
|
280 |
+
<p class="description"><?php echo __(
|
281 |
'Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.',
|
282 |
'wp-statistics'
|
283 |
); ?></p>
|
284 |
+
</td>
|
285 |
+
</tr>
|
286 |
|
287 |
+
<tr valign="top">
|
288 |
+
<th scope="row" colspan="2"><h3><?php _e( 'GeoIP Exclusions', 'wp-statistics' ); ?></h3></th>
|
289 |
+
</tr>
|
290 |
|
291 |
+
<tr valign="top">
|
292 |
+
<th scope="row"><?php _e( 'Excluded countries list', 'wp-statistics' ); ?>:</th>
|
293 |
+
<td>
|
294 |
<textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code"
|
295 |
+
dir="ltr"><?php echo htmlentities(
|
296 |
+
$WP_Statistics->get_option( 'excluded_countries' ),
|
297 |
ENT_QUOTES
|
298 |
); ?></textarea>
|
299 |
|
300 |
+
<p class="description"><?php echo __(
|
301 |
'A list of country codes (one per line, two letters each) to exclude from statistics collection. Use "000" (three zeros) to exclude unknown countries.',
|
302 |
'wp-statistics'
|
303 |
); ?></p>
|
304 |
+
</td>
|
305 |
+
</tr>
|
306 |
|
307 |
+
<tr valign="top">
|
308 |
+
<th scope="row"><?php _e( 'Included countries list', 'wp-statistics' ); ?>:</th>
|
309 |
+
<td>
|
310 |
<textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code"
|
311 |
+
dir="ltr"><?php echo htmlentities(
|
312 |
+
$WP_Statistics->get_option( 'included_countries' ),
|
313 |
ENT_QUOTES
|
314 |
); ?></textarea>
|
315 |
|
316 |
+
<p class="description"><?php echo __(
|
317 |
'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.',
|
318 |
'wp-statistics'
|
319 |
); ?></p>
|
320 |
+
</td>
|
321 |
+
</tr>
|
322 |
|
323 |
+
<tr valign="top">
|
324 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Host Exclusions', 'wp-statistics' ); ?></h3></th>
|
325 |
+
</tr>
|
326 |
|
327 |
+
<tr valign="top">
|
328 |
+
<th scope="row"><?php _e( 'Excluded hosts list', 'wp-statistics' ); ?>:</th>
|
329 |
+
<td>
|
330 |
<textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code"
|
331 |
+
dir="ltr"><?php echo htmlentities(
|
332 |
+
$WP_Statistics->get_option( 'excluded_hosts' ),
|
333 |
ENT_QUOTES
|
334 |
); ?></textarea>
|
335 |
|
336 |
+
<p class="description"><?php echo __(
|
337 |
'A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.',
|
338 |
'wp-statistics'
|
339 |
); ?></p>
|
340 |
+
<br>
|
341 |
|
342 |
+
<p class="description"><?php echo __(
|
343 |
'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.',
|
344 |
'wp-statistics'
|
345 |
); ?></p>
|
346 |
+
</td>
|
347 |
+
</tr>
|
348 |
+
|
349 |
+
<tr valign="top">
|
350 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Site URL Exclusions', 'wp-statistics' ); ?></h3></th>
|
351 |
+
</tr>
|
352 |
+
|
353 |
+
<tr valign="top">
|
354 |
+
<th scope="row"><?php _e( 'Excluded login page', 'wp-statistics' ); ?>:</th>
|
355 |
+
<td>
|
356 |
+
<input id="wps-exclude-loginpage" type="checkbox" value="1"
|
357 |
+
name="wps_exclude_loginpage" <?php echo $WP_Statistics->get_option( 'exclude_loginpage' ) == true
|
358 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-loginpage"><?php _e(
|
359 |
'Exclude',
|
360 |
'wp-statistics'
|
361 |
); ?></label>
|
362 |
|
363 |
+
<p class="description"><?php _e(
|
364 |
'Exclude the login page for registering as a hit.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
+
<tr valign="top">
|
370 |
+
<th scope="row"><?php _e( 'Excluded RSS feeds', 'wp-statistics' ); ?>:</th>
|
371 |
+
<td>
|
372 |
+
<input id="wps-exclude-feeds" type="checkbox" value="1"
|
373 |
+
name="wps_exclude_feeds" <?php echo $WP_Statistics->get_option( 'exclude_feeds' ) == true
|
374 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-feeds"><?php _e(
|
375 |
'Exclude',
|
376 |
'wp-statistics'
|
377 |
); ?></label>
|
378 |
|
379 |
+
<p class="description"><?php _e(
|
380 |
'Exclude the RSS feeds for registering as a hit.',
|
381 |
'wp-statistics'
|
382 |
); ?></p>
|
383 |
+
</td>
|
384 |
+
</tr>
|
385 |
+
<tr valign="top">
|
386 |
+
<th scope="row"><?php _e( 'Excluded 404 pages', 'wp-statistics' ); ?>:</th>
|
387 |
+
<td>
|
388 |
+
<input id="wps-exclude-404s" type="checkbox" value="1"
|
389 |
+
name="wps_exclude_404s" <?php echo $WP_Statistics->get_option( 'exclude_404s' ) == true
|
390 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-404s"><?php _e(
|
391 |
'Exclude',
|
392 |
'wp-statistics'
|
393 |
); ?></label>
|
394 |
|
395 |
+
<p class="description"><?php _e(
|
396 |
'Exclude any URL that returns a "404 - Not Found" message.',
|
397 |
'wp-statistics'
|
398 |
); ?></p>
|
399 |
+
</td>
|
400 |
+
</tr>
|
401 |
+
<tr valign="top">
|
402 |
+
<th scope="row"><?php _e( 'Excluded AJAX calls', 'wp-statistics' ); ?>:</th>
|
403 |
+
<td>
|
404 |
+
<input id="wps-exclude-ajax" type="checkbox" value="1"
|
405 |
+
name="wps_exclude_ajax" <?php echo $WP_Statistics->get_option( 'exclude_ajax' ) == true
|
406 |
? "checked='checked'" : ''; ?>><label for="wps-exclude-ajax"><?php _e(
|
407 |
'Exclude',
|
408 |
'wp-statistics'
|
409 |
); ?></label>
|
410 |
|
411 |
+
<p class="description"><?php _e(
|
412 |
'Exclude any call to the WordPress AJAX system.',
|
413 |
'wp-statistics'
|
414 |
); ?></p>
|
415 |
+
</td>
|
416 |
+
</tr>
|
417 |
+
<tr valign="top">
|
418 |
+
<th scope="row"><?php _e( 'Excluded URLs list', 'wp-statistics' ); ?>:</th>
|
419 |
+
<td>
|
420 |
<textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code"
|
421 |
+
dir="ltr"><?php echo htmlentities(
|
422 |
+
$WP_Statistics->get_option( 'excluded_urls' ),
|
423 |
ENT_QUOTES
|
424 |
); ?></textarea>
|
425 |
|
426 |
+
<p class="description"><?php echo __(
|
427 |
'A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.',
|
428 |
'wp-statistics'
|
429 |
); ?></p>
|
430 |
+
<br>
|
431 |
|
432 |
+
<p class="description"><?php echo __(
|
433 |
'Note: this option will NOT handle url parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.',
|
434 |
'wp-statistics'
|
435 |
); ?></p>
|
436 |
+
</td>
|
437 |
+
</tr>
|
438 |
|
439 |
+
</tbody>
|
440 |
+
</table>
|
441 |
|
442 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-externals.php
CHANGED
@@ -16,8 +16,8 @@ if ( $wps_nonce_valid ) {
|
|
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 |
}
|
@@ -27,177 +27,177 @@ if ( $wps_nonce_valid ) {
|
|
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 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
<?php echo sprintf(
|
55 |
-
__('IP location services provided by data created by %s.', 'wp-statistics'),
|
56 |
'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>'
|
57 |
); ?>
|
58 |
-
|
59 |
-
|
60 |
|
61 |
<?php
|
62 |
if ( wp_statistics_geoip_supported() ) {
|
63 |
?>
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
'geoip'
|
72 |
) == true ? "checked='checked'" : ''; ?>>
|
73 |
-
|
74 |
|
75 |
-
|
76 |
'For get more information and location (country) from visitor, enable this feature.',
|
77 |
'wp-statistics'
|
78 |
); ?></p>
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
? "checked='checked'" : ''; ?>>
|
91 |
-
|
92 |
|
93 |
-
|
94 |
'Save changes on this page to download the update.',
|
95 |
'wp-statistics'
|
96 |
); ?></p>
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
? "checked='checked'" : ''; ?>>
|
110 |
-
|
111 |
<?php
|
112 |
-
if ( $WP_Statistics->get_option('schedule_geoip') ) {
|
113 |
-
echo '<p class="description">' . __('Next update will be', 'wp-statistics') . ': <code>';
|
114 |
-
$last_update = $WP_Statistics->get_option('last_geoip_dl');
|
115 |
-
$this_month = strtotime(__('First Tuesday of this month', 'wp-statistics'));
|
116 |
|
117 |
if ( $last_update > $this_month ) {
|
118 |
-
$next_update = strtotime(__('First Tuesday of next month', 'wp-statistics')) +
|
119 |
( 86400 * 2 );
|
120 |
} else {
|
121 |
$next_update = $this_month + ( 86400 * 2 );
|
122 |
}
|
123 |
|
124 |
-
$next_schedule = wp_next_scheduled('wp_statistics_geoip_hook');
|
125 |
|
126 |
if ( $next_schedule ) {
|
127 |
-
echo $WP_Statistics->Local_Date(get_option('date_format'), $next_update) .
|
128 |
' @ ' .
|
129 |
-
$WP_Statistics->Local_Date(get_option('time_format'), $next_schedule);
|
130 |
} else {
|
131 |
-
echo $WP_Statistics->Local_Date(get_option('date_format'), $next_update) .
|
132 |
' @ ' .
|
133 |
-
$WP_Statistics->Local_Date(get_option('time_format'), time());
|
134 |
}
|
135 |
|
136 |
echo '</code></p>';
|
137 |
}
|
138 |
?>
|
139 |
-
|
140 |
'Download of the GeoIP database will be scheduled for 2 days after the first Tuesday of the month.',
|
141 |
'wp-statistics'
|
142 |
); ?></p>
|
143 |
|
144 |
-
|
145 |
'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).',
|
146 |
'wp-statistics'
|
147 |
); ?></p>
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
'Populate missing GeoIP after update of GeoIP DB',
|
155 |
'wp-statistics'
|
156 |
); ?>
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
? "checked='checked'" : ''; ?>>
|
164 |
-
|
165 |
|
166 |
-
|
167 |
'Update any missing GeoIP data after downloading a new database.',
|
168 |
'wp-statistics'
|
169 |
); ?></p>
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$WP_Statistics->get_option('private_country_code', '000'),
|
183 |
ENT_QUOTES
|
184 |
); ?>">
|
185 |
|
186 |
-
|
187 |
'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.',
|
188 |
'wp-statistics'
|
189 |
); ?></p>
|
190 |
-
|
191 |
-
|
192 |
<?php
|
193 |
} else {
|
194 |
?>
|
195 |
-
|
196 |
-
|
197 |
<?php
|
198 |
-
echo __('GeoIP collection is disabled due to the following reasons:', 'wp-statistics') . '<br><br>';
|
199 |
|
200 |
-
if ( ! function_exists('curl_init') ) {
|
201 |
echo '<br> * ';
|
202 |
_e(
|
203 |
'GeoIP collection requires the cURL PHP extension and it is not loaded on your version of PHP!',
|
@@ -206,7 +206,7 @@ if ( $wps_nonce_valid ) {
|
|
206 |
echo '<br>';
|
207 |
}
|
208 |
|
209 |
-
if ( ! function_exists('bcadd') ) {
|
210 |
echo '<br> * ';
|
211 |
_e(
|
212 |
'GeoIP collection requires the BC Math PHP extension and it is not loaded on your version of PHP!',
|
@@ -215,7 +215,7 @@ if ( $wps_nonce_valid ) {
|
|
215 |
echo '<br>';
|
216 |
}
|
217 |
|
218 |
-
if ( ini_get('safe_mode') ) {
|
219 |
echo '<br> * ';
|
220 |
_e(
|
221 |
'PHP safe mode detected! GeoIP collection is not supported with PHP\'s safe mode enabled!',
|
@@ -224,196 +224,196 @@ if ( $wps_nonce_valid ) {
|
|
224 |
echo '<br>';
|
225 |
}
|
226 |
?>
|
227 |
-
|
228 |
-
|
229 |
<?php
|
230 |
} ?>
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
|
241 |
-
|
242 |
-
|
243 |
'browscap'
|
244 |
) == true ? "checked='checked'" : ''; ?>>
|
245 |
-
|
246 |
|
247 |
-
|
248 |
'The browscap database will be downloaded and used to detect robots.',
|
249 |
'wp-statistics'
|
250 |
); ?></p>
|
251 |
-
|
252 |
-
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
? "checked='checked'" : ''; ?>>
|
263 |
-
|
264 |
|
265 |
-
|
266 |
'Save changes on this page to download the update.',
|
267 |
'wp-statistics'
|
268 |
); ?></p>
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
? "checked='checked'" : ''; ?>>
|
282 |
-
|
283 |
<?php
|
284 |
-
if ( $WP_Statistics->get_option('schedule_browscap') ) {
|
285 |
-
echo '<p class="description">' . __('Next update will be', 'wp-statistics') . ': <code>';
|
286 |
-
$last_update = $WP_Statistics->get_option('last_browscap_dl');
|
287 |
if ( $last_update == 0 ) {
|
288 |
$last_update = time();
|
289 |
}
|
290 |
$next_update = $last_update + ( 86400 * 7 );
|
291 |
|
292 |
-
$next_schedule = wp_next_scheduled('wp_statistics_browscap_hook');
|
293 |
|
294 |
if ( $next_schedule ) {
|
295 |
-
echo date(get_option('date_format'), $next_schedule) .
|
296 |
' @ ' .
|
297 |
-
date(get_option('time_format'), $next_schedule);
|
298 |
} else {
|
299 |
-
echo date(get_option('date_format'), $next_update) .
|
300 |
' @ ' .
|
301 |
-
date(get_option('time_format'), time());
|
302 |
}
|
303 |
|
304 |
echo '</code></p>';
|
305 |
}
|
306 |
?>
|
307 |
-
|
308 |
'Download of the browscap database will be scheduled for once a week.',
|
309 |
'wp-statistics'
|
310 |
); ?></p>
|
311 |
-
|
312 |
-
|
313 |
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
|
320 |
-
|
321 |
-
|
322 |
<?php echo sprintf(
|
323 |
-
__('Referrer spam blacklist is provided by Piwik, available from %s.', 'wp-statistics'),
|
324 |
'<a href="https://github.com/piwik/referrer-spam-blacklist" target=_blank>https://github.com/piwik/referrer-spam-blacklist</a>'
|
325 |
); ?>
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
? "checked='checked'" : ''; ?>>
|
339 |
-
|
340 |
|
341 |
-
|
342 |
'The Piwik Referrer Spam Blacklist database will be downloaded and used to detect referrer spam.',
|
343 |
'wp-statistics'
|
344 |
); ?></p>
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
true ? "checked='checked'" : ''; ?>>
|
358 |
-
|
359 |
'Download Piwik Referrer Spam Blacklist Database',
|
360 |
'wp-statistics'
|
361 |
); ?></label>
|
362 |
|
363 |
-
|
364 |
'Save changes on this page to download the update.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
-
|
368 |
-
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
'Schedule weekly update of Piwik Referrer Spam Blacklist DB',
|
374 |
'wp-statistics'
|
375 |
); ?>
|
376 |
-
|
377 |
-
|
378 |
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
'schedule_referrerspam'
|
383 |
) == true ? "checked='checked'" : ''; ?>>
|
384 |
-
|
385 |
<?php
|
386 |
-
if ( $WP_Statistics->get_option('schedule_referrerspam') ) {
|
387 |
-
echo '<p class="description">' . __('Next update will be', 'wp-statistics') . ': <code>';
|
388 |
-
$last_update = $WP_Statistics->get_option('schedule_referrerspam');
|
389 |
if ( $last_update == 0 ) {
|
390 |
$last_update = time();
|
391 |
}
|
392 |
$next_update = $last_update + ( 86400 * 7 );
|
393 |
|
394 |
-
$next_schedule = wp_next_scheduled('wp_statistics_referrerspam_hook');
|
395 |
|
396 |
if ( $next_schedule ) {
|
397 |
-
echo date(get_option('date_format'), $next_schedule) .
|
398 |
' @ ' .
|
399 |
-
date(get_option('time_format'), $next_schedule);
|
400 |
} else {
|
401 |
-
echo date(get_option('date_format'), $next_update) .
|
402 |
' @ ' .
|
403 |
-
date(get_option('time_format'), time());
|
404 |
}
|
405 |
|
406 |
echo '</code></p>';
|
407 |
}
|
408 |
?>
|
409 |
-
|
410 |
'Download of the Piwik Referrer Spam Blacklist database will be scheduled for once a week.',
|
411 |
'wp-statistics'
|
412 |
); ?></p>
|
413 |
-
|
414 |
-
|
415 |
|
416 |
-
|
417 |
-
|
418 |
|
419 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit');
|
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 |
}
|
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(
|
55 |
+
__( 'IP location services provided by data created by %s.', 'wp-statistics' ),
|
56 |
'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>'
|
57 |
); ?>
|
58 |
+
</th>
|
59 |
+
</tr>
|
60 |
|
61 |
<?php
|
62 |
if ( wp_statistics_geoip_supported() ) {
|
63 |
?>
|
64 |
+
<tr valign="top">
|
65 |
+
<th scope="row">
|
66 |
+
<label for="geoip-enable"><?php _e( 'GeoIP collection', 'wp-statistics' ); ?>:</label>
|
67 |
+
</th>
|
68 |
|
69 |
+
<td>
|
70 |
+
<input id="geoip-enable" type="checkbox" name="wps_geoip" <?php echo $WP_Statistics->get_option(
|
71 |
'geoip'
|
72 |
) == true ? "checked='checked'" : ''; ?>>
|
73 |
+
<label for="geoip-enable"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
74 |
|
75 |
+
<p class="description"><?php _e(
|
76 |
'For get more information and location (country) from visitor, enable this feature.',
|
77 |
'wp-statistics'
|
78 |
); ?></p>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
|
82 |
+
<tr valign="top">
|
83 |
+
<th scope="row">
|
84 |
+
<label for="geoip-update"><?php _e( 'Update GeoIP Info', 'wp-statistics' ); ?>:</label>
|
85 |
+
</th>
|
86 |
|
87 |
+
<td>
|
88 |
+
<input id="geoip-update" type="checkbox"
|
89 |
+
name="wps_update_geoip" <?php echo $WP_Statistics->get_option( 'update_geoip' ) == true
|
90 |
? "checked='checked'" : ''; ?>>
|
91 |
+
<label for="geoip-update"><?php _e( 'Download GeoIP Database', 'wp-statistics' ); ?></label>
|
92 |
|
93 |
+
<p class="description"><?php _e(
|
94 |
'Save changes on this page to download the update.',
|
95 |
'wp-statistics'
|
96 |
); ?></p>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
|
100 |
+
<tr valign="top">
|
101 |
+
<th scope="row">
|
102 |
+
<label for="geoip-schedule"><?php _e( 'Schedule monthly update of GeoIP DB', 'wp-statistics' ); ?>
|
103 |
+
:</label>
|
104 |
+
</th>
|
105 |
+
|
106 |
+
<td>
|
107 |
+
<input id="geoip-schedule" type="checkbox"
|
108 |
+
name="wps_schedule_geoip" <?php echo $WP_Statistics->get_option( 'schedule_geoip' ) == true
|
109 |
? "checked='checked'" : ''; ?>>
|
110 |
+
<label for="geoip-schedule"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
111 |
<?php
|
112 |
+
if ( $WP_Statistics->get_option( 'schedule_geoip' ) ) {
|
113 |
+
echo '<p class="description">' . __( 'Next update will be', 'wp-statistics' ) . ': <code>';
|
114 |
+
$last_update = $WP_Statistics->get_option( 'last_geoip_dl' );
|
115 |
+
$this_month = strtotime( __( 'First Tuesday of this month', 'wp-statistics' ) );
|
116 |
|
117 |
if ( $last_update > $this_month ) {
|
118 |
+
$next_update = strtotime( __( 'First Tuesday of next month', 'wp-statistics' ) ) +
|
119 |
( 86400 * 2 );
|
120 |
} else {
|
121 |
$next_update = $this_month + ( 86400 * 2 );
|
122 |
}
|
123 |
|
124 |
+
$next_schedule = wp_next_scheduled( 'wp_statistics_geoip_hook' );
|
125 |
|
126 |
if ( $next_schedule ) {
|
127 |
+
echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) .
|
128 |
' @ ' .
|
129 |
+
$WP_Statistics->Local_Date( get_option( 'time_format' ), $next_schedule );
|
130 |
} else {
|
131 |
+
echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) .
|
132 |
' @ ' .
|
133 |
+
$WP_Statistics->Local_Date( get_option( 'time_format' ), time() );
|
134 |
}
|
135 |
|
136 |
echo '</code></p>';
|
137 |
}
|
138 |
?>
|
139 |
+
<p class="description"><?php _e(
|
140 |
'Download of the GeoIP database will be scheduled for 2 days after the first Tuesday of the month.',
|
141 |
'wp-statistics'
|
142 |
); ?></p>
|
143 |
|
144 |
+
<p class="description"><?php _e(
|
145 |
'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).',
|
146 |
'wp-statistics'
|
147 |
); ?></p>
|
148 |
+
</td>
|
149 |
+
</tr>
|
150 |
|
151 |
+
<tr valign="top">
|
152 |
+
<th scope="row">
|
153 |
+
<label for="geoip-schedule"><?php _e(
|
154 |
'Populate missing GeoIP after update of GeoIP DB',
|
155 |
'wp-statistics'
|
156 |
); ?>
|
157 |
+
:</label>
|
158 |
+
</th>
|
159 |
|
160 |
+
<td>
|
161 |
+
<input id="geoip-auto-pop" type="checkbox"
|
162 |
+
name="wps_auto_pop" <?php echo $WP_Statistics->get_option( 'auto_pop' ) == true
|
163 |
? "checked='checked'" : ''; ?>>
|
164 |
+
<label for="geoip-auto-pop"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
165 |
|
166 |
+
<p class="description"><?php _e(
|
167 |
'Update any missing GeoIP data after downloading a new database.',
|
168 |
'wp-statistics'
|
169 |
); ?></p>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
|
173 |
+
<tr valign="top">
|
174 |
+
<th scope="row">
|
175 |
+
<label for="geoip-schedule"><?php _e( 'Country code for private IP addresses', 'wp-statistics' ); ?>
|
176 |
+
:</label>
|
177 |
+
</th>
|
178 |
+
|
179 |
+
<td>
|
180 |
+
<input type="text" size="3" id="geoip-private-country-code" name="wps_private_country_code"
|
181 |
+
value="<?php echo htmlentities(
|
182 |
+
$WP_Statistics->get_option( 'private_country_code', '000' ),
|
183 |
ENT_QUOTES
|
184 |
); ?>">
|
185 |
|
186 |
+
<p class="description"><?php _e(
|
187 |
'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.',
|
188 |
'wp-statistics'
|
189 |
); ?></p>
|
190 |
+
</td>
|
191 |
+
</tr>
|
192 |
<?php
|
193 |
} else {
|
194 |
?>
|
195 |
+
<tr valign="top">
|
196 |
+
<th scope="row" colspan="2">
|
197 |
<?php
|
198 |
+
echo __( 'GeoIP collection is disabled due to the following reasons:', 'wp-statistics' ) . '<br><br>';
|
199 |
|
200 |
+
if ( ! function_exists( 'curl_init' ) ) {
|
201 |
echo '<br> * ';
|
202 |
_e(
|
203 |
'GeoIP collection requires the cURL PHP extension and it is not loaded on your version of PHP!',
|
206 |
echo '<br>';
|
207 |
}
|
208 |
|
209 |
+
if ( ! function_exists( 'bcadd' ) ) {
|
210 |
echo '<br> * ';
|
211 |
_e(
|
212 |
'GeoIP collection requires the BC Math PHP extension and it is not loaded on your version of PHP!',
|
215 |
echo '<br>';
|
216 |
}
|
217 |
|
218 |
+
if ( ini_get( 'safe_mode' ) ) {
|
219 |
echo '<br> * ';
|
220 |
_e(
|
221 |
'PHP safe mode detected! GeoIP collection is not supported with PHP\'s safe mode enabled!',
|
224 |
echo '<br>';
|
225 |
}
|
226 |
?>
|
227 |
+
</th>
|
228 |
+
</tr>
|
229 |
<?php
|
230 |
} ?>
|
231 |
|
232 |
+
<tr valign="top">
|
233 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Browscap settings', 'wp-statistics' ); ?></h3></th>
|
234 |
+
</tr>
|
235 |
|
236 |
+
<tr valign="top">
|
237 |
+
<th scope="row">
|
238 |
+
<label for="browscap-enable"><?php _e( 'browscap usage', 'wp-statistics' ); ?>:</label>
|
239 |
+
</th>
|
240 |
|
241 |
+
<td>
|
242 |
+
<input id="browscap-enable" type="checkbox" name="wps_browscap" <?php echo $WP_Statistics->get_option(
|
243 |
'browscap'
|
244 |
) == true ? "checked='checked'" : ''; ?>>
|
245 |
+
<label for="browscap-enable"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
246 |
|
247 |
+
<p class="description"><?php _e(
|
248 |
'The browscap database will be downloaded and used to detect robots.',
|
249 |
'wp-statistics'
|
250 |
); ?></p>
|
251 |
+
</td>
|
252 |
+
</tr>
|
253 |
|
254 |
+
<tr valign="top">
|
255 |
+
<th scope="row">
|
256 |
+
<label for="browscap-update"><?php _e( 'Update browscap Info', 'wp-statistics' ); ?>:</label>
|
257 |
+
</th>
|
258 |
|
259 |
+
<td>
|
260 |
+
<input id="browscap-update" type="checkbox"
|
261 |
+
name="wps_update_browscap" <?php echo $WP_Statistics->get_option( 'update_browscap' ) == true
|
262 |
? "checked='checked'" : ''; ?>>
|
263 |
+
<label for="browscap-update"><?php _e( 'Download browscap Database', 'wp-statistics' ); ?></label>
|
264 |
|
265 |
+
<p class="description"><?php _e(
|
266 |
'Save changes on this page to download the update.',
|
267 |
'wp-statistics'
|
268 |
); ?></p>
|
269 |
+
</td>
|
270 |
+
</tr>
|
271 |
+
|
272 |
+
<tr valign="top">
|
273 |
+
<th scope="row">
|
274 |
+
<label for="browscap-schedule"><?php _e( 'Schedule weekly update of browscap DB', 'wp-statistics' ); ?>
|
275 |
+
:</label>
|
276 |
+
</th>
|
277 |
+
|
278 |
+
<td>
|
279 |
+
<input id="browscap-schedule" type="checkbox"
|
280 |
+
name="wps_schedule_browscap" <?php echo $WP_Statistics->get_option( 'schedule_browscap' ) == true
|
281 |
? "checked='checked'" : ''; ?>>
|
282 |
+
<label for="browscap-schedule"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
283 |
<?php
|
284 |
+
if ( $WP_Statistics->get_option( 'schedule_browscap' ) ) {
|
285 |
+
echo '<p class="description">' . __( 'Next update will be', 'wp-statistics' ) . ': <code>';
|
286 |
+
$last_update = $WP_Statistics->get_option( 'last_browscap_dl' );
|
287 |
if ( $last_update == 0 ) {
|
288 |
$last_update = time();
|
289 |
}
|
290 |
$next_update = $last_update + ( 86400 * 7 );
|
291 |
|
292 |
+
$next_schedule = wp_next_scheduled( 'wp_statistics_browscap_hook' );
|
293 |
|
294 |
if ( $next_schedule ) {
|
295 |
+
echo date( get_option( 'date_format' ), $next_schedule ) .
|
296 |
' @ ' .
|
297 |
+
date( get_option( 'time_format' ), $next_schedule );
|
298 |
} else {
|
299 |
+
echo date( get_option( 'date_format' ), $next_update ) .
|
300 |
' @ ' .
|
301 |
+
date( get_option( 'time_format' ), time() );
|
302 |
}
|
303 |
|
304 |
echo '</code></p>';
|
305 |
}
|
306 |
?>
|
307 |
+
<p class="description"><?php _e(
|
308 |
'Download of the browscap database will be scheduled for once a week.',
|
309 |
'wp-statistics'
|
310 |
); ?></p>
|
311 |
+
</td>
|
312 |
+
</tr>
|
313 |
|
314 |
+
<tr valign="top">
|
315 |
+
<th scope="row" colspan="2">
|
316 |
+
<h3><?php _e( 'Piwik Referrer Spam Blacklist settings', 'wp-statistics' ); ?></h3>
|
317 |
+
</th>
|
318 |
+
</tr>
|
319 |
|
320 |
+
<tr valign="top">
|
321 |
+
<th scope="row" colspan="2">
|
322 |
<?php echo sprintf(
|
323 |
+
__( 'Referrer spam blacklist is provided by Piwik, available from %s.', 'wp-statistics' ),
|
324 |
'<a href="https://github.com/piwik/referrer-spam-blacklist" target=_blank>https://github.com/piwik/referrer-spam-blacklist</a>'
|
325 |
); ?>
|
326 |
+
</th>
|
327 |
+
</tr>
|
328 |
+
|
329 |
+
<tr valign="top">
|
330 |
+
<th scope="row">
|
331 |
+
<label for="referrerspam-enable"><?php _e( 'Piwik Referrer Spam Blacklist usage', 'wp-statistics' ); ?>
|
332 |
+
:</label>
|
333 |
+
</th>
|
334 |
+
|
335 |
+
<td>
|
336 |
+
<input id="referrerspam-enable" type="checkbox"
|
337 |
+
name="wps_referrerspam" <?php echo $WP_Statistics->get_option( 'referrerspam' ) == true
|
338 |
? "checked='checked'" : ''; ?>>
|
339 |
+
<label for="referrerspam-enable"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
340 |
|
341 |
+
<p class="description"><?php _e(
|
342 |
'The Piwik Referrer Spam Blacklist database will be downloaded and used to detect referrer spam.',
|
343 |
'wp-statistics'
|
344 |
); ?></p>
|
345 |
+
</td>
|
346 |
+
</tr>
|
347 |
+
|
348 |
+
<tr valign="top">
|
349 |
+
<th scope="row">
|
350 |
+
<label for="geoip-update"><?php _e( 'Update Piwik Referrer Spam Blacklist Info', 'wp-statistics' ); ?>
|
351 |
+
:</label>
|
352 |
+
</th>
|
353 |
+
|
354 |
+
<td>
|
355 |
+
<input id="referrerspam-update" type="checkbox"
|
356 |
+
name="wps_update_referrerspam" <?php echo $WP_Statistics->get_option( 'update_referrerspam' ) ==
|
357 |
true ? "checked='checked'" : ''; ?>>
|
358 |
+
<label for="referrerspam-update"><?php _e(
|
359 |
'Download Piwik Referrer Spam Blacklist Database',
|
360 |
'wp-statistics'
|
361 |
); ?></label>
|
362 |
|
363 |
+
<p class="description"><?php _e(
|
364 |
'Save changes on this page to download the update.',
|
365 |
'wp-statistics'
|
366 |
); ?></p>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
|
370 |
+
<tr valign="top">
|
371 |
+
<th scope="row">
|
372 |
+
<label for="referrerspam-schedule"><?php _e(
|
373 |
'Schedule weekly update of Piwik Referrer Spam Blacklist DB',
|
374 |
'wp-statistics'
|
375 |
); ?>
|
376 |
+
:</label>
|
377 |
+
</th>
|
378 |
|
379 |
+
<td>
|
380 |
+
<input id="referrerspam-schedule" type="checkbox"
|
381 |
+
name="wps_schedule_referrerspam" <?php echo $WP_Statistics->get_option(
|
382 |
'schedule_referrerspam'
|
383 |
) == true ? "checked='checked'" : ''; ?>>
|
384 |
+
<label for="referrerspam-schedule"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
385 |
<?php
|
386 |
+
if ( $WP_Statistics->get_option( 'schedule_referrerspam' ) ) {
|
387 |
+
echo '<p class="description">' . __( 'Next update will be', 'wp-statistics' ) . ': <code>';
|
388 |
+
$last_update = $WP_Statistics->get_option( 'schedule_referrerspam' );
|
389 |
if ( $last_update == 0 ) {
|
390 |
$last_update = time();
|
391 |
}
|
392 |
$next_update = $last_update + ( 86400 * 7 );
|
393 |
|
394 |
+
$next_schedule = wp_next_scheduled( 'wp_statistics_referrerspam_hook' );
|
395 |
|
396 |
if ( $next_schedule ) {
|
397 |
+
echo date( get_option( 'date_format' ), $next_schedule ) .
|
398 |
' @ ' .
|
399 |
+
date( get_option( 'time_format' ), $next_schedule );
|
400 |
} else {
|
401 |
+
echo date( get_option( 'date_format' ), $next_update ) .
|
402 |
' @ ' .
|
403 |
+
date( get_option( 'time_format' ), time() );
|
404 |
}
|
405 |
|
406 |
echo '</code></p>';
|
407 |
}
|
408 |
?>
|
409 |
+
<p class="description"><?php _e(
|
410 |
'Download of the Piwik Referrer Spam Blacklist database will be scheduled for once a week.',
|
411 |
'wp-statistics'
|
412 |
); ?></p>
|
413 |
+
</td>
|
414 |
+
</tr>
|
415 |
|
416 |
+
</tbody>
|
417 |
+
</table>
|
418 |
|
419 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-general.php
CHANGED
@@ -1,9 +1,9 @@
|
|
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 |
|
@@ -11,13 +11,13 @@ 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(
|
@@ -42,7 +42,7 @@ if ( $wps_nonce_valid ) {
|
|
42 |
);
|
43 |
|
44 |
// If the IP hash's are enabled, disable storing the complete user agent.
|
45 |
-
if ( array_key_exists('wps_hash_ips', $_POST) ) {
|
46 |
$_POST['wps_store_ua'] = '';
|
47 |
}
|
48 |
|
@@ -52,416 +52,419 @@ if ( $wps_nonce_valid ) {
|
|
52 |
}
|
53 |
|
54 |
foreach ( $wps_option_list as $option ) {
|
55 |
-
if ( array_key_exists($option, $_POST) ) {
|
56 |
$value = $_POST[ $option ];
|
57 |
} else {
|
58 |
$value = '';
|
59 |
}
|
60 |
-
$new_option = str_replace("wps_", "", $option);
|
61 |
-
$WP_Statistics->store_option($new_option, $value);
|
62 |
}
|
63 |
}
|
64 |
?>
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
? "checked='checked'" : ''; ?>>
|
86 |
-
|
87 |
|
88 |
-
|
89 |
'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.',
|
90 |
'wp-statistics'
|
91 |
); ?></p>
|
92 |
-
|
93 |
-
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
? "checked='checked'" : ''; ?>>
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
<?php _e('Seconds', 'wp-statistics'); ?>
|
123 |
-
|
124 |
-
__('Time for the check accurate online user in the site. Now: %s Seconds', 'wp-statistics'),
|
125 |
-
$WP_Statistics->get_option('check_online')
|
126 |
); ?></p>
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
? "checked='checked'" : ''; ?>>
|
139 |
-
|
140 |
|
141 |
-
|
142 |
'Ignores the exclusion settings and records all users that are online (including self referrals and robots). Should only be used for troubleshooting.',
|
143 |
'wp-statistics'
|
144 |
); ?></p>
|
145 |
-
|
146 |
-
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
159 |
'visits'
|
160 |
) == true ? "checked='checked'" : ''; ?>>
|
161 |
-
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
? "checked='checked'" : ''; ?>>
|
180 |
-
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
? "checked='checked'" : ''; ?>>
|
195 |
-
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
|
210 |
-
|
211 |
-
__('For each visit to account for several hits. Currently %s.', 'wp-statistics'),
|
212 |
-
$WP_Statistics->get_option('coefficient')
|
213 |
); ?></p>
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
|
226 |
-
|
227 |
-
|
228 |
'pages'
|
229 |
) == true ? "checked='checked'" : ''; ?>>
|
230 |
-
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
? "checked='checked'" : ''; ?>>
|
245 |
-
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
|
251 |
<?php
|
252 |
if ( ! $disable_strip_uri_parameters ) {
|
253 |
?>
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
262 |
'strip_uri_parameters'
|
263 |
) == true ? "checked='checked'" : ''; ?>>
|
264 |
-
|
265 |
|
266 |
-
|
267 |
'This will remove anything after the ? in a URL.',
|
268 |
'wp-statistics'
|
269 |
); ?></p>
|
270 |
-
|
271 |
-
|
272 |
<?php
|
273 |
}
|
274 |
?>
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
283 |
? "checked='checked'" : ''; ?>>
|
284 |
-
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
|
290 |
<tr valign="top">
|
291 |
<th scope="row">
|
292 |
-
<label for="show_hits"><?php _e('Show hits in posts/pages in the site', 'wp-statistics'); ?>:</label>
|
293 |
</th>
|
294 |
|
295 |
<td>
|
296 |
<input id="show_hits" type="checkbox" value="1"
|
297 |
-
name="wps_show_hits" <?php echo $WP_Statistics->get_option('show_hits') == true
|
298 |
? "checked='checked'" : ''; ?> onClick='ToggleShowHitsOptions();'>
|
299 |
-
<label for="show_hits"><?php _e('Enable', 'wp-statistics'); ?></label>
|
300 |
|
301 |
-
<p class="description"><?php _e('Enable or disable show hits
|
302 |
</td>
|
303 |
</tr>
|
304 |
|
305 |
-
<?php if ( $WP_Statistics->get_option('show_hits') ) {
|
306 |
$hidden = "";
|
307 |
} else {
|
308 |
$hidden = " style='display: none;'";
|
309 |
} ?>
|
310 |
<tr valign="top"<?php echo $hidden; ?> id='wps_show_hits_option'>
|
311 |
<td scope="row" style="vertical-align: top;">
|
312 |
-
<label for="display_hits_position"><?php _e('Display position', 'wp-statistics'); ?>:</label>
|
313 |
</td>
|
314 |
|
315 |
<td>
|
316 |
<select name="wps_display_hits_position" id="display_hits_position">
|
317 |
-
<option value="0" <?php selected($WP_Statistics->get_option('display_hits_position'), '0'); ?>><?php _e(
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
<option value="before_content" <?php selected($WP_Statistics->get_option('display_hits_position'), 'before_content'); ?>><?php _e(
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
<option value="after_content" <?php selected($WP_Statistics->get_option('display_hits_position'), 'after_content'); ?>><?php _e(
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
</select>
|
331 |
|
332 |
<p class="description"><?php _e(
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
</td>
|
337 |
</tr>
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
'No',
|
352 |
'wp-statistics'
|
353 |
); ?></option>
|
354 |
-
|
355 |
'Yes',
|
356 |
'wp-statistics'
|
357 |
); ?></option>
|
358 |
-
|
359 |
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
? "checked='checked'" : ''; ?>>
|
374 |
-
|
375 |
|
376 |
-
|
377 |
'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.',
|
378 |
'wp-statistics'
|
379 |
); ?></p>
|
380 |
-
|
381 |
-
|
382 |
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
391 |
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
? "checked='checked'" : ''; ?>>
|
396 |
-
|
397 |
|
398 |
-
|
399 |
'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.',
|
400 |
'wp-statistics'
|
401 |
); ?></p>
|
402 |
-
|
403 |
-
|
404 |
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
'Disabling all search engines is not allowed, doing so will result in all search engines being active.',
|
409 |
'wp-statistics'
|
410 |
); ?></p>
|
411 |
-
|
412 |
-
|
413 |
<?php
|
414 |
$se_option_list = '';
|
415 |
|
416 |
foreach ( $selist as $se ) {
|
417 |
-
$option_name
|
418 |
-
$store_name
|
419 |
$se_option_list .= $option_name . ',';
|
420 |
?>
|
421 |
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e(
|
430 |
'Disable',
|
431 |
'wp-statistics'
|
432 |
); ?></label>
|
433 |
|
434 |
-
|
435 |
-
__('Disable %s from data collection and reporting.', 'wp-statistics'),
|
436 |
$se['name']
|
437 |
); ?></p>
|
438 |
-
|
439 |
-
|
440 |
<?php } ?>
|
441 |
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
? "checked='checked'" : ''; ?>>
|
455 |
-
|
456 |
|
457 |
-
|
458 |
'Add a total line to charts with multiple values, like the search engine referrals',
|
459 |
'wp-statistics'
|
460 |
); ?></p>
|
461 |
-
|
462 |
-
|
463 |
|
464 |
-
|
465 |
-
|
466 |
|
467 |
-
<?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 |
|
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(
|
42 |
);
|
43 |
|
44 |
// If the IP hash's are enabled, disable storing the complete user agent.
|
45 |
+
if ( array_key_exists( 'wps_hash_ips', $_POST ) ) {
|
46 |
$_POST['wps_store_ua'] = '';
|
47 |
}
|
48 |
|
52 |
}
|
53 |
|
54 |
foreach ( $wps_option_list as $option ) {
|
55 |
+
if ( array_key_exists( $option, $_POST ) ) {
|
56 |
$value = $_POST[ $option ];
|
57 |
} else {
|
58 |
$value = '';
|
59 |
}
|
60 |
+
$new_option = str_replace( "wps_", "", $option );
|
61 |
+
$WP_Statistics->store_option( $new_option, $value );
|
62 |
}
|
63 |
}
|
64 |
?>
|
65 |
+
<script type="text/javascript">
|
66 |
+
function ToggleShowHitsOptions() {
|
67 |
+
jQuery('[id^="wps_show_hits_option"]').fadeToggle();
|
68 |
+
}
|
69 |
+
</script>
|
70 |
+
|
71 |
+
<table class="form-table">
|
72 |
+
<tbody>
|
73 |
+
<tr valign="top">
|
74 |
+
<th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp-statistics' ); ?></h3></th>
|
75 |
+
</tr>
|
76 |
+
|
77 |
+
<tr valign="top">
|
78 |
+
<th scope="row">
|
79 |
+
<label for="useronline"><?php _e( 'Hash IP Addresses', 'wp-statistics' ); ?>:</label>
|
80 |
+
</th>
|
81 |
+
|
82 |
+
<td>
|
83 |
+
<input id="hash_ips" type="checkbox" value="1"
|
84 |
+
name="wps_hash_ips" <?php echo $WP_Statistics->get_option( 'hash_ips' ) == true
|
85 |
? "checked='checked'" : ''; ?>>
|
86 |
+
<label for="hash_ips"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
87 |
|
88 |
+
<p class="description"><?php _e(
|
89 |
'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.',
|
90 |
'wp-statistics'
|
91 |
); ?></p>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
|
95 |
+
<tr valign="top">
|
96 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Online Users', 'wp-statistics' ); ?></h3></th>
|
97 |
+
</tr>
|
98 |
|
99 |
+
<tr valign="top">
|
100 |
+
<th scope="row">
|
101 |
+
<label for="useronline"><?php _e( 'Online User', 'wp-statistics' ); ?>:</label>
|
102 |
+
</th>
|
103 |
|
104 |
+
<td>
|
105 |
+
<input id="useronline" type="checkbox" value="1"
|
106 |
+
name="wps_useronline" <?php echo $WP_Statistics->get_option( 'useronline' ) == true
|
107 |
? "checked='checked'" : ''; ?>>
|
108 |
+
<label for="useronline"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
109 |
+
|
110 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
111 |
+
</td>
|
112 |
+
</tr>
|
113 |
+
|
114 |
+
<tr valign="top">
|
115 |
+
<th scope="row">
|
116 |
+
<label for="check_online"><?php _e( 'Check for online users every', 'wp-statistics' ); ?>:</label>
|
117 |
+
</th>
|
118 |
+
|
119 |
+
<td>
|
120 |
+
<input type="text" class="small-text code" id="check_online" name="wps_check_online"
|
121 |
+
value="<?php echo htmlentities( $WP_Statistics->get_option( 'check_online' ), ENT_QUOTES ); ?>"/>
|
122 |
+
<?php _e( 'Seconds', 'wp-statistics' ); ?>
|
123 |
+
<p class="description"><?php echo sprintf(
|
124 |
+
__( 'Time for the check accurate online user in the site. Now: %s Seconds', 'wp-statistics' ),
|
125 |
+
$WP_Statistics->get_option( 'check_online' )
|
126 |
); ?></p>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
|
130 |
+
<tr valign="top">
|
131 |
+
<th scope="row">
|
132 |
+
<label for="useronline"><?php _e( 'Record all user', 'wp-statistics' ); ?>:</label>
|
133 |
+
</th>
|
134 |
|
135 |
+
<td>
|
136 |
+
<input id="allonline" type="checkbox" value="1"
|
137 |
+
name="wps_all_online" <?php echo $WP_Statistics->get_option( 'all_online' ) == true
|
138 |
? "checked='checked'" : ''; ?>>
|
139 |
+
<label for="allonline"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
140 |
|
141 |
+
<p class="description"><?php _e(
|
142 |
'Ignores the exclusion settings and records all users that are online (including self referrals and robots). Should only be used for troubleshooting.',
|
143 |
'wp-statistics'
|
144 |
); ?></p>
|
145 |
+
</td>
|
146 |
+
</tr>
|
147 |
|
148 |
+
<tr valign="top">
|
149 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Visits', 'wp-statistics' ); ?></h3></th>
|
150 |
+
</tr>
|
151 |
|
152 |
+
<tr valign="top">
|
153 |
+
<th scope="row">
|
154 |
+
<label for="visits"><?php _e( 'Visits', 'wp-statistics' ); ?>:</label>
|
155 |
+
</th>
|
156 |
|
157 |
+
<td>
|
158 |
+
<input id="visits" type="checkbox" value="1" name="wps_visits" <?php echo $WP_Statistics->get_option(
|
159 |
'visits'
|
160 |
) == true ? "checked='checked'" : ''; ?>>
|
161 |
+
<label for="visits"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
162 |
|
163 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
164 |
+
</td>
|
165 |
+
</tr>
|
166 |
|
167 |
+
<tr valign="top">
|
168 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Visitors', 'wp-statistics' ); ?></h3></th>
|
169 |
+
</tr>
|
170 |
|
171 |
+
<tr valign="top">
|
172 |
+
<th scope="row">
|
173 |
+
<label for="visitors"><?php _e( 'Visitors', 'wp-statistics' ); ?>:</label>
|
174 |
+
</th>
|
175 |
|
176 |
+
<td>
|
177 |
+
<input id="visitors" type="checkbox" value="1"
|
178 |
+
name="wps_visitors" <?php echo $WP_Statistics->get_option( 'visitors' ) == true
|
179 |
? "checked='checked'" : ''; ?>>
|
180 |
+
<label for="visitors"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
181 |
|
182 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
|
186 |
+
<tr valign="top">
|
187 |
+
<th scope="row">
|
188 |
+
<label for="visitors"><?php _e( 'Store entire user agent string', 'wp-statistics' ); ?>:</label>
|
189 |
+
</th>
|
190 |
|
191 |
+
<td>
|
192 |
+
<input id="store_ua" type="checkbox" value="1"
|
193 |
+
name="wps_store_ua" <?php echo $WP_Statistics->get_option( 'store_ua' ) == true
|
194 |
? "checked='checked'" : ''; ?>>
|
195 |
+
<label for="store_ua"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
196 |
|
197 |
+
<p class="description"><?php _e( 'Only enabled for debugging', 'wp-statistics' ); ?></p>
|
198 |
+
</td>
|
199 |
+
</tr>
|
200 |
|
201 |
+
<tr valign="top">
|
202 |
+
<th scope="row">
|
203 |
+
<label for="coefficient"><?php _e( 'Coefficient per visitor', 'wp-statistics' ); ?>:</label>
|
204 |
+
</th>
|
205 |
|
206 |
+
<td>
|
207 |
+
<input type="text" class="small-text code" id="coefficient" name="wps_coefficient"
|
208 |
+
value="<?php echo htmlentities( $WP_Statistics->get_option( 'coefficient' ), ENT_QUOTES ); ?>"/>
|
209 |
|
210 |
+
<p class="description"><?php echo sprintf(
|
211 |
+
__( 'For each visit to account for several hits. Currently %s.', 'wp-statistics' ),
|
212 |
+
$WP_Statistics->get_option( 'coefficient' )
|
213 |
); ?></p>
|
214 |
+
</td>
|
215 |
+
</tr>
|
216 |
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Pages and Posts', 'wp-statistics' ); ?></h3></th>
|
219 |
+
</tr>
|
220 |
|
221 |
+
<tr valign="top">
|
222 |
+
<th scope="row">
|
223 |
+
<label for="pages"><?php _e( 'Pages', 'wp-statistics' ); ?>:</label>
|
224 |
+
</th>
|
225 |
|
226 |
+
<td>
|
227 |
+
<input id="pages" type="checkbox" value="1" name="wps_pages" <?php echo $WP_Statistics->get_option(
|
228 |
'pages'
|
229 |
) == true ? "checked='checked'" : ''; ?>>
|
230 |
+
<label for="pages"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
231 |
|
232 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
233 |
+
</td>
|
234 |
+
</tr>
|
235 |
|
236 |
+
<tr valign="top">
|
237 |
+
<th scope="row">
|
238 |
+
<label for="all_pages"><?php _e( 'Track all pages', 'wp-statistics' ); ?>:</label>
|
239 |
+
</th>
|
240 |
|
241 |
+
<td>
|
242 |
+
<input id="all_pages" type="checkbox" value="1"
|
243 |
+
name="wps_track_all_pages" <?php echo $WP_Statistics->get_option( 'track_all_pages' ) == true
|
244 |
? "checked='checked'" : ''; ?>>
|
245 |
+
<label for="all_pages"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
246 |
|
247 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
248 |
+
</td>
|
249 |
+
</tr>
|
250 |
|
251 |
<?php
|
252 |
if ( ! $disable_strip_uri_parameters ) {
|
253 |
?>
|
254 |
+
<tr valign="top">
|
255 |
+
<th scope="row">
|
256 |
+
<label for="strip_uri_parameters"><?php _e( 'Strip parameters from URI', 'wp-statistics' ); ?>
|
257 |
+
:</label>
|
258 |
+
</th>
|
259 |
+
|
260 |
+
<td>
|
261 |
+
<input id="strip_uri_parameters" type="checkbox" value="1"
|
262 |
+
name="wps_strip_uri_parameters" <?php echo $WP_Statistics->get_option(
|
263 |
'strip_uri_parameters'
|
264 |
) == true ? "checked='checked'" : ''; ?>>
|
265 |
+
<label for="strip_uri_parameters"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
266 |
|
267 |
+
<p class="description"><?php _e(
|
268 |
'This will remove anything after the ? in a URL.',
|
269 |
'wp-statistics'
|
270 |
); ?></p>
|
271 |
+
</td>
|
272 |
+
</tr>
|
273 |
<?php
|
274 |
}
|
275 |
?>
|
276 |
+
<tr valign="top">
|
277 |
+
<th scope="row">
|
278 |
+
<label for="disable_column"><?php _e( 'Disable hits column in post/pages list', 'wp-statistics' ); ?>
|
279 |
+
:</label>
|
280 |
+
</th>
|
281 |
+
|
282 |
+
<td>
|
283 |
+
<input id="disable_column" type="checkbox" value="1"
|
284 |
+
name="wps_disable_column" <?php echo $WP_Statistics->get_option( 'disable_column' ) == true
|
285 |
? "checked='checked'" : ''; ?>>
|
286 |
+
<label for="disable_column"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
287 |
|
288 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
289 |
+
</td>
|
290 |
+
</tr>
|
291 |
|
292 |
<tr valign="top">
|
293 |
<th scope="row">
|
294 |
+
<label for="show_hits"><?php _e( 'Show hits in posts/pages in the site', 'wp-statistics' ); ?>:</label>
|
295 |
</th>
|
296 |
|
297 |
<td>
|
298 |
<input id="show_hits" type="checkbox" value="1"
|
299 |
+
name="wps_show_hits" <?php echo $WP_Statistics->get_option( 'show_hits' ) == true
|
300 |
? "checked='checked'" : ''; ?> onClick='ToggleShowHitsOptions();'>
|
301 |
+
<label for="show_hits"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
302 |
|
303 |
+
<p class="description"><?php _e( 'Enable or disable show hits in content', 'wp-statistics' ); ?></p>
|
304 |
</td>
|
305 |
</tr>
|
306 |
|
307 |
+
<?php if ( $WP_Statistics->get_option( 'show_hits' ) ) {
|
308 |
$hidden = "";
|
309 |
} else {
|
310 |
$hidden = " style='display: none;'";
|
311 |
} ?>
|
312 |
<tr valign="top"<?php echo $hidden; ?> id='wps_show_hits_option'>
|
313 |
<td scope="row" style="vertical-align: top;">
|
314 |
+
<label for="display_hits_position"><?php _e( 'Display position', 'wp-statistics' ); ?>:</label>
|
315 |
</td>
|
316 |
|
317 |
<td>
|
318 |
<select name="wps_display_hits_position" id="display_hits_position">
|
319 |
+
<option value="0" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), '0' ); ?>><?php _e(
|
320 |
+
'Please select',
|
321 |
+
'wp-statistics'
|
322 |
+
); ?></option>
|
323 |
+
<option value="before_content" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), 'before_content' ); ?>><?php _e(
|
324 |
+
'Before Content',
|
325 |
+
'wp-statistics'
|
326 |
+
); ?></option>
|
327 |
+
|
328 |
+
<option value="after_content" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), 'after_content' ); ?>><?php _e(
|
329 |
+
'After Content',
|
330 |
+
'wp-statistics'
|
331 |
+
); ?></option>
|
332 |
</select>
|
333 |
|
334 |
<p class="description"><?php _e(
|
335 |
+
'Choose the position to show Hits.',
|
336 |
+
'wp-statistics'
|
337 |
+
); ?></p>
|
338 |
</td>
|
339 |
</tr>
|
340 |
|
341 |
+
<tr valign="top">
|
342 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Miscellaneous', 'wp-statistics' ); ?></h3></th>
|
343 |
+
</tr>
|
344 |
|
345 |
+
<tr valign="top">
|
346 |
+
<th scope="row">
|
347 |
+
<label for="menu-bar"><?php _e( 'Show stats in menu bar', 'wp-statistics' ); ?>:</label>
|
348 |
+
</th>
|
349 |
|
350 |
+
<td>
|
351 |
+
<select name="wps_menu_bar" id="menu-bar">
|
352 |
+
<option value="0" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '0' ); ?>><?php _e(
|
353 |
'No',
|
354 |
'wp-statistics'
|
355 |
); ?></option>
|
356 |
+
<option value="1" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '1' ); ?>><?php _e(
|
357 |
'Yes',
|
358 |
'wp-statistics'
|
359 |
); ?></option>
|
360 |
+
</select>
|
361 |
|
362 |
+
<p class="description"><?php _e( 'Show stats in admin menu bar', 'wp-statistics' ); ?></p>
|
363 |
+
</td>
|
364 |
+
</tr>
|
365 |
|
366 |
+
<tr valign="top">
|
367 |
+
<th scope="row">
|
368 |
+
<label for="hide_notices"><?php _e( 'Hide admin notices about non active features', 'wp-statistics' ); ?>
|
369 |
+
:</label>
|
370 |
+
</th>
|
371 |
|
372 |
+
<td>
|
373 |
+
<input id="hide_notices" type="checkbox" value="1"
|
374 |
+
name="wps_hide_notices" <?php echo $WP_Statistics->get_option( 'hide_notices' ) == true
|
375 |
? "checked='checked'" : ''; ?>>
|
376 |
+
<label for="store_ua"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
377 |
|
378 |
+
<p class="description"><?php _e(
|
379 |
'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.',
|
380 |
'wp-statistics'
|
381 |
); ?></p>
|
382 |
+
</td>
|
383 |
+
</tr>
|
384 |
|
385 |
+
<tr valign="top">
|
386 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Search Engines', 'wp-statistics' ); ?></h3></th>
|
387 |
+
</tr>
|
388 |
|
389 |
+
<tr valign="top">
|
390 |
+
<th scope="row">
|
391 |
+
<label for="hide_notices"><?php _e( 'Add page title to empty search words', 'wp-statistics' ); ?>
|
392 |
+
:</label>
|
393 |
+
</th>
|
394 |
|
395 |
+
<td>
|
396 |
+
<input id="addsearchwords" type="checkbox" value="1"
|
397 |
+
name="wps_addsearchwords" <?php echo $WP_Statistics->get_option( 'addsearchwords' ) == true
|
398 |
? "checked='checked'" : ''; ?>>
|
399 |
+
<label for="addsearchwords"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
400 |
|
401 |
+
<p class="description"><?php _e(
|
402 |
'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.',
|
403 |
'wp-statistics'
|
404 |
); ?></p>
|
405 |
+
</td>
|
406 |
+
</tr>
|
407 |
|
408 |
+
<tr valign="top">
|
409 |
+
<th scope="row" colspan="2">
|
410 |
+
<p class="description"><?php _e(
|
411 |
'Disabling all search engines is not allowed, doing so will result in all search engines being active.',
|
412 |
'wp-statistics'
|
413 |
); ?></p>
|
414 |
+
</th>
|
415 |
+
</tr>
|
416 |
<?php
|
417 |
$se_option_list = '';
|
418 |
|
419 |
foreach ( $selist as $se ) {
|
420 |
+
$option_name = 'wps_disable_se_' . $se['tag'];
|
421 |
+
$store_name = 'disable_se_' . $se['tag'];
|
422 |
$se_option_list .= $option_name . ',';
|
423 |
?>
|
424 |
|
425 |
+
<tr valign="top">
|
426 |
+
<th scope="row">
|
427 |
+
<label for="<?php echo $option_name; ?>"><?php _e( $se['name'], 'wp-statistics' ); ?>:</label>
|
428 |
+
</th>
|
429 |
+
<td>
|
430 |
+
<input id="<?php echo $option_name; ?>" type="checkbox" value="1"
|
431 |
+
name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true
|
432 |
? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e(
|
433 |
'Disable',
|
434 |
'wp-statistics'
|
435 |
); ?></label>
|
436 |
|
437 |
+
<p class="description"><?php echo sprintf(
|
438 |
+
__( 'Disable %s from data collection and reporting.', 'wp-statistics' ),
|
439 |
$se['name']
|
440 |
); ?></p>
|
441 |
+
</td>
|
442 |
+
</tr>
|
443 |
<?php } ?>
|
444 |
|
445 |
+
<tr valign="top">
|
446 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Charts', 'wp-statistics' ); ?></h3></th>
|
447 |
+
</tr>
|
448 |
|
449 |
+
<tr valign="top">
|
450 |
+
<th scope="row">
|
451 |
+
<label for="chart-totals"><?php _e( 'Include totals', 'wp-statistics' ); ?>:</label>
|
452 |
+
</th>
|
453 |
|
454 |
+
<td>
|
455 |
+
<input id="chart-totals" type="checkbox" value="1"
|
456 |
+
name="wps_chart_totals" <?php echo $WP_Statistics->get_option( 'chart_totals' ) == true
|
457 |
? "checked='checked'" : ''; ?>>
|
458 |
+
<label for="chart-totals"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
459 |
|
460 |
+
<p class="description"><?php _e(
|
461 |
'Add a total line to charts with multiple values, like the search engine referrals',
|
462 |
'wp-statistics'
|
463 |
); ?></p>
|
464 |
+
</td>
|
465 |
+
</tr>
|
466 |
|
467 |
+
</tbody>
|
468 |
+
</table>
|
469 |
|
470 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-maintenance.php
CHANGED
@@ -9,119 +9,119 @@ if ( $wps_nonce_valid ) {
|
|
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 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
|
50 |
-
|
51 |
|
52 |
-
|
53 |
'A WP Cron job will be run daily to purge any data older than a set number of days.',
|
54 |
'wp-statistics'
|
55 |
); ?></p>
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
$WP_Statistics->get_option('schedule_dbmaint_days', "365"),
|
68 |
ENT_QUOTES
|
69 |
); ?>"/>
|
70 |
-
<?php _e('Days', 'wp-statistics'); ?>
|
71 |
-
|
72 |
'The number of days to keep statistics for. Minimum value is 30 days. Invalid values will disable the daily maintenance.',
|
73 |
'wp-statistics'
|
74 |
); ?></p>
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
'schedule_dbmaint_visitor'
|
92 |
) == true ? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
|
93 |
-
|
94 |
|
95 |
-
|
96 |
'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).',
|
97 |
'wp-statistics'
|
98 |
); ?></p>
|
99 |
-
|
100 |
-
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
'Purge visitors with more than',
|
106 |
'wp-statistics'
|
107 |
); ?>:</label>
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
$WP_Statistics->get_option('schedule_dbmaint_visitor_hits', '50'),
|
114 |
ENT_QUOTES
|
115 |
); ?>"/>
|
116 |
-
<?php _e('Hits', 'wp-statistics'); ?>
|
117 |
-
|
118 |
'The number of hits required to delete the visitor. Minimum value is 10 hits. Invalid values will disable the daily maintenance.',
|
119 |
'wp-statistics'
|
120 |
); ?></p>
|
121 |
-
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit');
|
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"
|
48 |
+
name="wps_schedule_dbmaint" <?php echo $WP_Statistics->get_option( 'schedule_dbmaint' ) == true
|
49 |
? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
|
50 |
+
<label for="wps_schedule_dbmaint"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
51 |
|
52 |
+
<p class="description"><?php _e(
|
53 |
'A WP Cron job will be run daily to purge any data older than a set number of days.',
|
54 |
'wp-statistics'
|
55 |
); ?></p>
|
56 |
+
</td>
|
57 |
+
</tr>
|
58 |
+
|
59 |
+
<tr valign="top">
|
60 |
+
<th scope="row">
|
61 |
+
<label for="wps_schedule_dbmaint_days"><?php _e( 'Purge data older than', 'wp-statistics' ); ?>:</label>
|
62 |
+
</th>
|
63 |
+
|
64 |
+
<td>
|
65 |
+
<input type="text" class="small-text code" id="wps_schedule_dbmaint_days"
|
66 |
+
name="wps_schedule_dbmaint_days" value="<?php echo htmlentities(
|
67 |
+
$WP_Statistics->get_option( 'schedule_dbmaint_days', "365" ),
|
68 |
ENT_QUOTES
|
69 |
); ?>"/>
|
70 |
+
<?php _e( 'Days', 'wp-statistics' ); ?>
|
71 |
+
<p class="description"><?php echo __(
|
72 |
'The number of days to keep statistics for. Minimum value is 30 days. Invalid values will disable the daily maintenance.',
|
73 |
'wp-statistics'
|
74 |
); ?></p>
|
75 |
+
</td>
|
76 |
+
</tr>
|
77 |
+
|
78 |
+
<tr valign="top">
|
79 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Purge High Hit Count Visitors Daily', 'wp-statistics' ); ?></h3>
|
80 |
+
</th>
|
81 |
+
</tr>
|
82 |
+
|
83 |
+
<tr valign="top">
|
84 |
+
<th scope="row">
|
85 |
+
<label for="wps_schedule_dbmaint_visitor"><?php _e( 'Enabled', 'wp-statistics' ); ?>:</label>
|
86 |
+
</th>
|
87 |
+
|
88 |
+
<td>
|
89 |
+
<input id="wps_schedule_dbmaint_visitor" type="checkbox"
|
90 |
+
name="wps_schedule_dbmaint_visitor" <?php echo $WP_Statistics->get_option(
|
91 |
'schedule_dbmaint_visitor'
|
92 |
) == true ? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'>
|
93 |
+
<label for="wps_schedule_dbmaint_visitor"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
94 |
|
95 |
+
<p class="description"><?php _e(
|
96 |
'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).',
|
97 |
'wp-statistics'
|
98 |
); ?></p>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
|
102 |
+
<tr valign="top">
|
103 |
+
<th scope="row">
|
104 |
+
<label for="wps_schedule_dbmaint_visitor_hits"><?php _e(
|
105 |
'Purge visitors with more than',
|
106 |
'wp-statistics'
|
107 |
); ?>:</label>
|
108 |
+
</th>
|
109 |
|
110 |
+
<td>
|
111 |
+
<input type="text" class="small-text code" id="wps_schedule_dbmaint_visitor_hits"
|
112 |
+
name="wps_schedule_dbmaint_visitor_hits" value="<?php echo htmlentities(
|
113 |
+
$WP_Statistics->get_option( 'schedule_dbmaint_visitor_hits', '50' ),
|
114 |
ENT_QUOTES
|
115 |
); ?>"/>
|
116 |
+
<?php _e( 'Hits', 'wp-statistics' ); ?>
|
117 |
+
<p class="description"><?php echo __(
|
118 |
'The number of hits required to delete the visitor. Minimum value is 10 hits. Invalid values will disable the daily maintenance.',
|
119 |
'wp-statistics'
|
120 |
); ?></p>
|
121 |
+
</td>
|
122 |
+
</tr>
|
123 |
|
124 |
+
</tbody>
|
125 |
+
</table>
|
126 |
|
127 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-notifications.php
CHANGED
@@ -1,20 +1,20 @@
|
|
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 |
|
@@ -31,160 +31,160 @@ if ( $wps_nonce_valid ) {
|
|
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 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$WP_Statistics->store_option('email_list', get_bloginfo('admin_email'));
|
70 |
}
|
71 |
-
echo htmlentities($WP_Statistics->get_option('email_list'), ENT_QUOTES); ?>"/>
|
72 |
|
73 |
-
|
74 |
'A comma separated list of e-mail addresses to send reports to.',
|
75 |
'wp-statistics'
|
76 |
); ?></p>
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
? "checked='checked'" : ''; ?>>
|
93 |
-
|
94 |
|
95 |
-
|
96 |
'Send a report whenever the browscap.ini is updated.',
|
97 |
'wp-statistics'
|
98 |
); ?></p>
|
99 |
-
|
100 |
-
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
? "checked='checked'" : ''; ?>>
|
111 |
-
|
112 |
|
113 |
-
|
114 |
'Send a report whenever the GeoIP database is updated.',
|
115 |
'wp-statistics'
|
116 |
); ?></p>
|
117 |
-
|
118 |
-
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
? "checked='checked'" : ''; ?>>
|
129 |
-
|
130 |
|
131 |
-
|
132 |
'Send a report whenever the pruning of database is run.',
|
133 |
'wp-statistics'
|
134 |
); ?></p>
|
135 |
-
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
? "checked='checked'" : ''; ?>>
|
147 |
-
|
148 |
|
149 |
-
|
150 |
'Send a report whenever the plugin is upgraded.',
|
151 |
'wp-statistics'
|
152 |
); ?></p>
|
153 |
-
|
154 |
-
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
? "checked='checked'" : ''; ?> onClick='ToggleStatOptions();'>
|
169 |
-
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
-
<?php if ( $WP_Statistics->get_option('stats_report') ) {
|
176 |
$hidden = "";
|
177 |
} else {
|
178 |
$hidden = " style='display: none;'";
|
179 |
} ?>
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
'Please select',
|
189 |
'wp-statistics'
|
190 |
); ?></option>
|
@@ -194,79 +194,79 @@ if ( $wps_nonce_valid ) {
|
|
194 |
return 0;
|
195 |
}
|
196 |
|
197 |
-
return ( $a['interval'] < $b['interval'] ) ? -1 : 1;
|
198 |
}
|
199 |
|
200 |
$schedules = wp_get_schedules();
|
201 |
|
202 |
-
uasort($schedules, 'wp_statistics_schedule_sort');
|
203 |
|
204 |
foreach ( $schedules as $key => $value ) {
|
205 |
echo ' <option value="' .
|
206 |
$key .
|
207 |
'" ' .
|
208 |
-
selected($WP_Statistics->get_option('time_report'), $key) .
|
209 |
'>' .
|
210 |
$value['display'] .
|
211 |
'</option>';
|
212 |
}
|
213 |
?>
|
214 |
-
|
215 |
|
216 |
-
|
217 |
'Select how often to receive statistical report.',
|
218 |
'wp-statistics'
|
219 |
); ?></p>
|
220 |
-
|
221 |
-
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
'Please select',
|
232 |
'wp-statistics'
|
233 |
); ?></option>
|
234 |
-
|
235 |
'Email',
|
236 |
'wp-statistics'
|
237 |
); ?></option>
|
238 |
-
<?php if ( is_plugin_active('wp-sms/wp-sms.php') || is_plugin_active('wp-sms-pro/wp-sms.php') ) { ?>
|
239 |
-
|
240 |
-
$WP_Statistics->get_option('send_report'),
|
241 |
'sms'
|
242 |
-
); ?>><?php _e('SMS', 'wp-statistics'); ?></option>
|
243 |
<?php } ?>
|
244 |
-
|
245 |
|
246 |
-
|
247 |
'Select delivery method for statistical report.',
|
248 |
'wp-statistics'
|
249 |
); ?></p>
|
250 |
|
251 |
-
<?php if ( ! is_plugin_active('wp-sms/wp-sms.php') ) { ?>
|
252 |
-
|
253 |
-
__('Note: To send SMS text messages please install the %s plugin.', 'wp-statistics'),
|
254 |
'<a href="http://wordpress.org/extend/plugins/wp-sms/" target="_blank">' .
|
255 |
-
__('WordPress SMS', 'wp-statistics') .
|
256 |
'</a>'
|
257 |
); ?></p>
|
258 |
<?php } ?>
|
259 |
-
|
260 |
-
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
|
268 |
<?php wp_editor(
|
269 |
-
$WP_Statistics->get_option('content_report'),
|
270 |
'content-report',
|
271 |
array(
|
272 |
'media_buttons' => false,
|
@@ -274,32 +274,32 @@ if ( $wps_nonce_valid ) {
|
|
274 |
'textarea_rows' => 5,
|
275 |
)
|
276 |
); ?>
|
277 |
-
|
278 |
|
279 |
-
|
280 |
<?php _e(
|
281 |
'Any shortcode supported by your installation of WordPress, include all shortcodes for WP Statistics (see the documentation for a list of codes available) are supported in the body of the message. Here are some examples:',
|
282 |
'wp-statistics'
|
283 |
); ?>
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit'); ?>
|
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 |
|
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 dir="ltr" type="text" id="email_list" name="wps_email_list" size="30"
|
68 |
+
value="<?php if ( $WP_Statistics->get_option( 'email_list' ) == '' ) {
|
69 |
+
$WP_Statistics->store_option( 'email_list', get_bloginfo( 'admin_email' ) );
|
70 |
}
|
71 |
+
echo htmlentities( $WP_Statistics->get_option( 'email_list' ), ENT_QUOTES ); ?>"/>
|
72 |
|
73 |
+
<p class="description"><?php _e(
|
74 |
'A comma separated list of e-mail addresses to send reports to.',
|
75 |
'wp-statistics'
|
76 |
); ?></p>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
|
80 |
+
<tr valign="top">
|
81 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Update Reports', 'wp-statistics' ); ?></h3></th>
|
82 |
+
</tr>
|
83 |
|
84 |
+
<tr valign="top">
|
85 |
+
<td scope="row">
|
86 |
+
<label for="browscap-report"><?php _e( 'Browscap', 'wp-statistics' ); ?>:</label>
|
87 |
+
</td>
|
88 |
|
89 |
+
<td>
|
90 |
+
<input id="browscap-report" type="checkbox" value="1"
|
91 |
+
name="wps_browscap_report" <?php echo $WP_Statistics->get_option( 'browscap_report' ) == true
|
92 |
? "checked='checked'" : ''; ?>>
|
93 |
+
<label for="browscap-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
94 |
|
95 |
+
<p class="description"><?php _e(
|
96 |
'Send a report whenever the browscap.ini is updated.',
|
97 |
'wp-statistics'
|
98 |
); ?></p>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
|
102 |
+
<tr valign="top">
|
103 |
+
<td scope="row">
|
104 |
+
<label for="geoip-report"><?php _e( 'GeoIP', 'wp-statistics' ); ?>:</label>
|
105 |
+
</td>
|
106 |
|
107 |
+
<td>
|
108 |
+
<input id="geoip-report" type="checkbox" value="1"
|
109 |
+
name="wps_geoip_report" <?php echo $WP_Statistics->get_option( 'geoip_report' ) == true
|
110 |
? "checked='checked'" : ''; ?>>
|
111 |
+
<label for="geoip-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
112 |
|
113 |
+
<p class="description"><?php _e(
|
114 |
'Send a report whenever the GeoIP database is updated.',
|
115 |
'wp-statistics'
|
116 |
); ?></p>
|
117 |
+
</td>
|
118 |
+
</tr>
|
119 |
|
120 |
+
<tr valign="top">
|
121 |
+
<td scope="row">
|
122 |
+
<label for="prune-report"><?php _e( 'Pruning', 'wp-statistics' ); ?>:</label>
|
123 |
+
</td>
|
124 |
|
125 |
+
<td>
|
126 |
+
<input id="prune-report" type="checkbox" value="1"
|
127 |
+
name="wps_prune_report" <?php echo $WP_Statistics->get_option( 'prune_report' ) == true
|
128 |
? "checked='checked'" : ''; ?>>
|
129 |
+
<label for="prune-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
130 |
|
131 |
+
<p class="description"><?php _e(
|
132 |
'Send a report whenever the pruning of database is run.',
|
133 |
'wp-statistics'
|
134 |
); ?></p>
|
135 |
+
</td>
|
136 |
+
</tr>
|
137 |
|
138 |
+
<tr valign="top">
|
139 |
+
<td scope="row">
|
140 |
+
<label for="upgrade-report"><?php _e( 'Upgrade', 'wp-statistics' ); ?>:</label>
|
141 |
+
</td>
|
142 |
|
143 |
+
<td>
|
144 |
+
<input id="upgrade-report" type="checkbox" value="1"
|
145 |
+
name="wps_upgrade_report" <?php echo $WP_Statistics->get_option( 'upgrade_report' ) == true
|
146 |
? "checked='checked'" : ''; ?>>
|
147 |
+
<label for="upgrade-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
148 |
|
149 |
+
<p class="description"><?php _e(
|
150 |
'Send a report whenever the plugin is upgraded.',
|
151 |
'wp-statistics'
|
152 |
); ?></p>
|
153 |
+
</td>
|
154 |
+
</tr>
|
155 |
|
156 |
+
<tr valign="top">
|
157 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Statistical reporting', 'wp-statistics' ); ?></h3></th>
|
158 |
+
</tr>
|
159 |
|
160 |
+
<tr valign="top">
|
161 |
+
<th scope="row">
|
162 |
+
<label for="stats-report"><?php _e( 'Statistical reporting', 'wp-statistics' ); ?>:</label>
|
163 |
+
</th>
|
164 |
|
165 |
+
<td>
|
166 |
+
<input id="stats-report" type="checkbox" value="1"
|
167 |
+
name="wps_stats_report" <?php echo $WP_Statistics->get_option( 'stats_report' ) == true
|
168 |
? "checked='checked'" : ''; ?> onClick='ToggleStatOptions();'>
|
169 |
+
<label for="stats-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
170 |
|
171 |
+
<p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p>
|
172 |
+
</td>
|
173 |
+
</tr>
|
174 |
|
175 |
+
<?php if ( $WP_Statistics->get_option( 'stats_report' ) ) {
|
176 |
$hidden = "";
|
177 |
} else {
|
178 |
$hidden = " style='display: none;'";
|
179 |
} ?>
|
180 |
+
<tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'>
|
181 |
+
<td scope="row" style="vertical-align: top;">
|
182 |
+
<label for="time-report"><?php _e( 'Schedule', 'wp-statistics' ); ?>:</label>
|
183 |
+
</td>
|
184 |
+
|
185 |
+
<td>
|
186 |
+
<select name="wps_time_report" id="time-report">
|
187 |
+
<option value="0" <?php selected( $WP_Statistics->get_option( 'time_report' ), '0' ); ?>><?php _e(
|
188 |
'Please select',
|
189 |
'wp-statistics'
|
190 |
); ?></option>
|
194 |
return 0;
|
195 |
}
|
196 |
|
197 |
+
return ( $a['interval'] < $b['interval'] ) ? - 1 : 1;
|
198 |
}
|
199 |
|
200 |
$schedules = wp_get_schedules();
|
201 |
|
202 |
+
uasort( $schedules, 'wp_statistics_schedule_sort' );
|
203 |
|
204 |
foreach ( $schedules as $key => $value ) {
|
205 |
echo ' <option value="' .
|
206 |
$key .
|
207 |
'" ' .
|
208 |
+
selected( $WP_Statistics->get_option( 'time_report' ), $key ) .
|
209 |
'>' .
|
210 |
$value['display'] .
|
211 |
'</option>';
|
212 |
}
|
213 |
?>
|
214 |
+
</select>
|
215 |
|
216 |
+
<p class="description"><?php _e(
|
217 |
'Select how often to receive statistical report.',
|
218 |
'wp-statistics'
|
219 |
); ?></p>
|
220 |
+
</td>
|
221 |
+
</tr>
|
222 |
|
223 |
+
<tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'>
|
224 |
+
<td scope="row" style="vertical-align: top;">
|
225 |
+
<label for="send-report"><?php _e( 'Send reports via', 'wp-statistics' ); ?>:</label>
|
226 |
+
</td>
|
227 |
|
228 |
+
<td>
|
229 |
+
<select name="wps_send_report" id="send-report">
|
230 |
+
<option value="0" <?php selected( $WP_Statistics->get_option( 'send_report' ), '0' ); ?>><?php _e(
|
231 |
'Please select',
|
232 |
'wp-statistics'
|
233 |
); ?></option>
|
234 |
+
<option value="mail" <?php selected( $WP_Statistics->get_option( 'send_report' ), 'mail' ); ?>><?php _e(
|
235 |
'Email',
|
236 |
'wp-statistics'
|
237 |
); ?></option>
|
238 |
+
<?php if ( is_plugin_active( 'wp-sms/wp-sms.php' ) || is_plugin_active( 'wp-sms-pro/wp-sms.php' ) ) { ?>
|
239 |
+
<option value="sms" <?php selected(
|
240 |
+
$WP_Statistics->get_option( 'send_report' ),
|
241 |
'sms'
|
242 |
+
); ?>><?php _e( 'SMS', 'wp-statistics' ); ?></option>
|
243 |
<?php } ?>
|
244 |
+
</select>
|
245 |
|
246 |
+
<p class="description"><?php _e(
|
247 |
'Select delivery method for statistical report.',
|
248 |
'wp-statistics'
|
249 |
); ?></p>
|
250 |
|
251 |
+
<?php if ( ! is_plugin_active( 'wp-sms/wp-sms.php' ) ) { ?>
|
252 |
+
<p class="description note"><?php echo sprintf(
|
253 |
+
__( 'Note: To send SMS text messages please install the %s plugin.', 'wp-statistics' ),
|
254 |
'<a href="http://wordpress.org/extend/plugins/wp-sms/" target="_blank">' .
|
255 |
+
__( 'WordPress SMS', 'wp-statistics' ) .
|
256 |
'</a>'
|
257 |
); ?></p>
|
258 |
<?php } ?>
|
259 |
+
</td>
|
260 |
+
</tr>
|
261 |
|
262 |
+
<tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'>
|
263 |
+
<td scope="row" style="vertical-align: top;">
|
264 |
+
<label for="content-report"><?php _e( 'Report body', 'wp-statistics' ); ?>:</label>
|
265 |
+
</td>
|
266 |
|
267 |
+
<td>
|
268 |
<?php wp_editor(
|
269 |
+
$WP_Statistics->get_option( 'content_report' ),
|
270 |
'content-report',
|
271 |
array(
|
272 |
'media_buttons' => false,
|
274 |
'textarea_rows' => 5,
|
275 |
)
|
276 |
); ?>
|
277 |
+
<p class="description"><?php _e( 'Enter the contents of the report.', 'wp-statistics' ); ?></p>
|
278 |
|
279 |
+
<p class="description data">
|
280 |
<?php _e(
|
281 |
'Any shortcode supported by your installation of WordPress, include all shortcodes for WP Statistics (see the documentation for a list of codes available) are supported in the body of the message. Here are some examples:',
|
282 |
'wp-statistics'
|
283 |
); ?>
|
284 |
+
<br><br>
|
285 |
+
<?php _e( 'Online User', 'wp-statistics' ); ?>: <code>[wpstatistics
|
286 |
+
stat=usersonline]</code><br>
|
287 |
+
<?php _e( 'Today\'s Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics
|
288 |
+
stat=visitors time=today]</code><br>
|
289 |
+
<?php _e( 'Today\'s Visits', 'wp-statistics' ); ?>: <code>[wpstatistics
|
290 |
+
stat=visits time=today]</code><br>
|
291 |
+
<?php _e( 'Yesterday\'s Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics
|
292 |
+
stat=visitors time=yesterday]</code><br>
|
293 |
+
<?php _e( 'Yesterday\'s Visits', 'wp-statistics' ); ?>: <code>[wpstatistics
|
294 |
+
stat=visits time=yesterday]</code><br>
|
295 |
+
<?php _e( 'Total Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics
|
296 |
+
stat=visitors time=total]</code><br>
|
297 |
+
<?php _e( 'Total Visits', 'wp-statistics' ); ?>: <code>[wpstatistics
|
298 |
+
stat=visits time=total]</code><br>
|
299 |
+
</p>
|
300 |
+
</td>
|
301 |
+
</tr>
|
302 |
+
</tbody>
|
303 |
+
</table>
|
304 |
+
|
305 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); ?>
|
includes/settings/tabs/wps-overview-display.php
CHANGED
@@ -3,104 +3,104 @@ if ( $wps_nonce_valid ) {
|
|
3 |
$wps_option_list = array( 'wps_disable_map', 'wps_disable_dashboard', 'wps_disable_editor' );
|
4 |
|
5 |
foreach ( $wps_option_list as $option ) {
|
6 |
-
$new_option = str_replace('wps_', '', $option);
|
7 |
|
8 |
-
if ( array_key_exists($option, $_POST) ) {
|
9 |
$value = $_POST[ $option ];
|
10 |
} else {
|
11 |
$value = '';
|
12 |
}
|
13 |
|
14 |
-
$WP_Statistics->store_option($new_option, $value);
|
15 |
}
|
16 |
}
|
17 |
|
18 |
// Only display the global options if the user is an administrator.
|
19 |
if ( $wps_admin ) {
|
20 |
?>
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
'The following items are global to all users.',
|
30 |
'wp-statistics'
|
31 |
); ?></td>
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
? "checked='checked'" : ''; ?>>
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
'The following items are global to all users.',
|
56 |
'wp-statistics'
|
57 |
); ?></td>
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
? "checked='checked'" : ''; ?>>
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
-
|
81 |
'The following items are global to all users.',
|
82 |
'wp-statistics'
|
83 |
); ?></td>
|
84 |
-
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
? "checked='checked'" : ''; ?>>
|
95 |
-
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
<?php
|
104 |
}
|
105 |
|
106 |
-
submit_button(__('Update', 'wp-statistics'), 'primary', 'submit');
|
3 |
$wps_option_list = array( 'wps_disable_map', 'wps_disable_dashboard', 'wps_disable_editor' );
|
4 |
|
5 |
foreach ( $wps_option_list as $option ) {
|
6 |
+
$new_option = str_replace( 'wps_', '', $option );
|
7 |
|
8 |
+
if ( array_key_exists( $option, $_POST ) ) {
|
9 |
$value = $_POST[ $option ];
|
10 |
} else {
|
11 |
$value = '';
|
12 |
}
|
13 |
|
14 |
+
$WP_Statistics->store_option( $new_option, $value );
|
15 |
}
|
16 |
}
|
17 |
|
18 |
// Only display the global options if the user is an administrator.
|
19 |
if ( $wps_admin ) {
|
20 |
?>
|
21 |
+
<table class="form-table">
|
22 |
+
<tbody>
|
23 |
+
<tr valign="top">
|
24 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Dashboard', 'wp-statistics' ); ?></h3></th>
|
25 |
+
</tr>
|
26 |
+
|
27 |
+
<tr valign="top">
|
28 |
+
<td scope="row" colspan="2"><?php _e(
|
29 |
'The following items are global to all users.',
|
30 |
'wp-statistics'
|
31 |
); ?></td>
|
32 |
+
</tr>
|
33 |
|
34 |
+
<tr valign="top">
|
35 |
+
<th scope="row">
|
36 |
+
<label for="disable-map"><?php _e( 'Disable dashboard widgets', 'wp-statistics' ); ?>:</label>
|
37 |
+
</th>
|
38 |
|
39 |
+
<td>
|
40 |
+
<input id="disable-dashboard" type="checkbox" value="1"
|
41 |
+
name="wps_disable_dashboard" <?php echo $WP_Statistics->get_option( 'disable_dashboard' ) == true
|
42 |
? "checked='checked'" : ''; ?>>
|
43 |
+
<label for="disable-dashboard"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
44 |
|
45 |
+
<p class="description"><?php _e( 'Disable the dashboard widgets.', 'wp-statistics' ); ?></p>
|
46 |
+
</td>
|
47 |
+
</tr>
|
48 |
|
49 |
+
<tr valign="top">
|
50 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Page/Post Editor', 'wp-statistics' ); ?></h3></th>
|
51 |
+
</tr>
|
52 |
|
53 |
+
<tr valign="top">
|
54 |
+
<td scope="row" colspan="2"><?php _e(
|
55 |
'The following items are global to all users.',
|
56 |
'wp-statistics'
|
57 |
); ?></td>
|
58 |
+
</tr>
|
59 |
|
60 |
+
<tr valign="top">
|
61 |
+
<th scope="row">
|
62 |
+
<label for="disable-map"><?php _e( 'Disable post/page editor widget', 'wp-statistics' ); ?>:</label>
|
63 |
+
</th>
|
64 |
|
65 |
+
<td>
|
66 |
+
<input id="disable-editor" type="checkbox" value="1"
|
67 |
+
name="wps_disable_editor" <?php echo $WP_Statistics->get_option( 'disable_editor' ) == true
|
68 |
? "checked='checked'" : ''; ?>>
|
69 |
+
<label for="disable-editor"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
70 |
|
71 |
+
<p class="description"><?php _e( 'Disable the page/post editor widget.', 'wp-statistics' ); ?></p>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
|
75 |
+
<tr valign="top">
|
76 |
+
<th scope="row" colspan="2"><h3><?php _e( 'Map', 'wp-statistics' ); ?></h3></th>
|
77 |
+
</tr>
|
78 |
|
79 |
+
<tr valign="top">
|
80 |
+
<td scope="row" colspan="2"><?php _e(
|
81 |
'The following items are global to all users.',
|
82 |
'wp-statistics'
|
83 |
); ?></td>
|
84 |
+
</tr>
|
85 |
|
86 |
+
<tr valign="top">
|
87 |
+
<th scope="row">
|
88 |
+
<label for="disable-map"><?php _e( 'Disable map', 'wp-statistics' ); ?>:</label>
|
89 |
+
</th>
|
90 |
|
91 |
+
<td>
|
92 |
+
<input id="disable-map" type="checkbox" value="1"
|
93 |
+
name="wps_disable_map" <?php echo $WP_Statistics->get_option( 'disable_map' ) == true
|
94 |
? "checked='checked'" : ''; ?>>
|
95 |
+
<label for="disable-map"><?php _e( 'Enable', 'wp-statistics' ); ?></label>
|
96 |
|
97 |
+
<p class="description"><?php _e( 'Disable the map display', 'wp-statistics' ); ?></p>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
|
101 |
+
</tbody>
|
102 |
+
</table>
|
103 |
<?php
|
104 |
}
|
105 |
|
106 |
+
submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' );
|
includes/settings/tabs/wps-removal.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
if ( $wps_nonce_valid ) {
|
3 |
|
4 |
-
if ( array_key_exists('wps_remove_plugin', $_POST) ) {
|
5 |
if ( is_super_admin() ) {
|
6 |
-
update_option('wp_statistics_removal', 'true');
|
7 |
|
8 |
// We need to reload the page after we reset the options but it's too late to do it through a HTTP redirect so do a
|
9 |
// JavaScript redirect instead.
|
@@ -11,11 +11,11 @@ if ( $wps_nonce_valid ) {
|
|
11 |
}
|
12 |
}
|
13 |
|
14 |
-
if ( array_key_exists('wps_reset_plugin', $_POST) ) {
|
15 |
if ( is_super_admin() ) {
|
16 |
GLOBAL $wpdb, $WP_Statistics;
|
17 |
|
18 |
-
$default_options
|
19 |
$excluded_defaults = array( 'force_robot_update', 'robot_list' );
|
20 |
|
21 |
// Handle multi site implementations
|
@@ -24,19 +24,19 @@ if ( $wps_nonce_valid ) {
|
|
24 |
$sites = $WP_Statistics->get_wp_sites_list();
|
25 |
foreach ( $sites as $blog_id ) {
|
26 |
|
27 |
-
switch_to_blog($blog_id);
|
28 |
|
29 |
// Delete the wp_statistics option.
|
30 |
-
update_option('wp_statistics', array());
|
31 |
// Delete the user options.
|
32 |
-
$wpdb->query("DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'");
|
33 |
|
34 |
$WP_Statistics->load_options();
|
35 |
|
36 |
// Set some intelligent defaults.
|
37 |
foreach ( $default_options as $key => $value ) {
|
38 |
-
if ( ! in_array($key, $excluded_defaults) && false === $WP_Statistics->get_option($key) ) {
|
39 |
-
$WP_Statistics->store_option($key, $value);
|
40 |
}
|
41 |
}
|
42 |
|
@@ -46,16 +46,16 @@ if ( $wps_nonce_valid ) {
|
|
46 |
restore_current_blog();
|
47 |
} else {
|
48 |
// Delete the wp_statistics option.
|
49 |
-
update_option('wp_statistics', array());
|
50 |
// Delete the user options.
|
51 |
-
$wpdb->query("DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'");
|
52 |
|
53 |
$WP_Statistics->load_options();
|
54 |
|
55 |
// Set some intelligent defaults.
|
56 |
foreach ( $default_options as $key => $value ) {
|
57 |
-
if ( ! in_array($key, $excluded_defaults) && false === $WP_Statistics->get_option($key) ) {
|
58 |
-
$WP_Statistics->store_option($key, $value);
|
59 |
}
|
60 |
}
|
61 |
|
@@ -72,60 +72,60 @@ if ( $wps_nonce_valid ) {
|
|
72 |
}
|
73 |
|
74 |
?>
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
<?php _e(
|
84 |
'Uninstalling WP Statistics will not remove the data and settings, you can use this option to remove the WP Statistics data from your install before uninstalling the plugin.',
|
85 |
'wp-statistics'
|
86 |
); ?>
|
87 |
-
|
88 |
-
|
89 |
<?php _e(
|
90 |
'Once you submit this form the settings will be deleted during the page load, however WP Statistics will still show up in your Admin menu until another page load is executed.',
|
91 |
'wp-statistics'
|
92 |
); ?>
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
|
106 |
-
'Reset the plugin options to the defaults.
|
107 |
'wp-statistics'
|
108 |
); ?></p>
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
|
122 |
'Remove data and settings, this action cannot be undone.',
|
123 |
'wp-statistics'
|
124 |
); ?></p>
|
125 |
-
|
126 |
-
|
127 |
|
128 |
-
|
129 |
-
|
130 |
|
131 |
-
<?php submit_button(__('Update', 'wp-statistics'), 'primary', 'submit'); ?>
|
1 |
<?php
|
2 |
if ( $wps_nonce_valid ) {
|
3 |
|
4 |
+
if ( array_key_exists( 'wps_remove_plugin', $_POST ) ) {
|
5 |
if ( is_super_admin() ) {
|
6 |
+
update_option( 'wp_statistics_removal', 'true' );
|
7 |
|
8 |
// We need to reload the page after we reset the options but it's too late to do it through a HTTP redirect so do a
|
9 |
// JavaScript redirect instead.
|
11 |
}
|
12 |
}
|
13 |
|
14 |
+
if ( array_key_exists( 'wps_reset_plugin', $_POST ) ) {
|
15 |
if ( is_super_admin() ) {
|
16 |
GLOBAL $wpdb, $WP_Statistics;
|
17 |
|
18 |
+
$default_options = $WP_Statistics->Default_Options();
|
19 |
$excluded_defaults = array( 'force_robot_update', 'robot_list' );
|
20 |
|
21 |
// Handle multi site implementations
|
24 |
$sites = $WP_Statistics->get_wp_sites_list();
|
25 |
foreach ( $sites as $blog_id ) {
|
26 |
|
27 |
+
switch_to_blog( $blog_id );
|
28 |
|
29 |
// Delete the wp_statistics option.
|
30 |
+
update_option( 'wp_statistics', array() );
|
31 |
// Delete the user options.
|
32 |
+
$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" );
|
33 |
|
34 |
$WP_Statistics->load_options();
|
35 |
|
36 |
// Set some intelligent defaults.
|
37 |
foreach ( $default_options as $key => $value ) {
|
38 |
+
if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) {
|
39 |
+
$WP_Statistics->store_option( $key, $value );
|
40 |
}
|
41 |
}
|
42 |
|
46 |
restore_current_blog();
|
47 |
} else {
|
48 |
// Delete the wp_statistics option.
|
49 |
+
update_option( 'wp_statistics', array() );
|
50 |
// Delete the user options.
|
51 |
+
$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" );
|
52 |
|
53 |
$WP_Statistics->load_options();
|
54 |
|
55 |
// Set some intelligent defaults.
|
56 |
foreach ( $default_options as $key => $value ) {
|
57 |
+
if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) {
|
58 |
+
$WP_Statistics->store_option( $key, $value );
|
59 |
}
|
60 |
}
|
61 |
|
72 |
}
|
73 |
|
74 |
?>
|
75 |
+
<table class="form-table">
|
76 |
+
<tbody>
|
77 |
+
<tr valign="top">
|
78 |
+
<th scope="row" colspan="2"><h3><?php _e( 'WP Statisitcs Removal', 'wp-statistics' ); ?></h3></th>
|
79 |
+
</tr>
|
80 |
+
|
81 |
+
<tr valign="top">
|
82 |
+
<th scope="row" colspan="2">
|
83 |
<?php _e(
|
84 |
'Uninstalling WP Statistics will not remove the data and settings, you can use this option to remove the WP Statistics data from your install before uninstalling the plugin.',
|
85 |
'wp-statistics'
|
86 |
); ?>
|
87 |
+
<br>
|
88 |
+
<br>
|
89 |
<?php _e(
|
90 |
'Once you submit this form the settings will be deleted during the page load, however WP Statistics will still show up in your Admin menu until another page load is executed.',
|
91 |
'wp-statistics'
|
92 |
); ?>
|
93 |
+
</th>
|
94 |
+
</tr>
|
95 |
|
96 |
+
<tr valign="top">
|
97 |
+
<th scope="row">
|
98 |
+
<label for="reset-plugin"><?php _e( 'Reset options', 'wp-statistics' ); ?>:</label>
|
99 |
+
</th>
|
100 |
|
101 |
+
<td>
|
102 |
+
<input id="reset-plugin" type="checkbox" name="wps_reset_plugin">
|
103 |
+
<label for="reset-plugin"><?php _e( 'Reset', 'wp-statistics' ); ?></label>
|
104 |
|
105 |
+
<p class="description"><?php _e(
|
106 |
+
'Reset the plugin options to the defaults. This will remove all user and global settings but will keep all other data. This action cannot be undone. Note: For multisite installs this will reset all sites to the defaults.',
|
107 |
'wp-statistics'
|
108 |
); ?></p>
|
109 |
+
</td>
|
110 |
+
</tr>
|
111 |
|
112 |
+
<tr valign="top">
|
113 |
+
<th scope="row">
|
114 |
+
<label for="remove-plugin"><?php _e( 'Remove data and settings', 'wp-statistics' ); ?>:</label>
|
115 |
+
</th>
|
116 |
|
117 |
+
<td>
|
118 |
+
<input id="remove-plugin" type="checkbox" name="wps_remove_plugin">
|
119 |
+
<label for="remove-plugin"><?php _e( 'Remove', 'wp-statistics' ); ?></label>
|
120 |
|
121 |
+
<p class="description"><?php _e(
|
122 |
'Remove data and settings, this action cannot be undone.',
|
123 |
'wp-statistics'
|
124 |
); ?></p>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
|
128 |
+
</tbody>
|
129 |
+
</table>
|
130 |
|
131 |
+
<?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); ?>
|
includes/settings/wps-settings.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
$wps_nonce_valid = false;
|
3 |
|
4 |
-
if ( array_key_exists('wp-statistics-nonce', $_POST) ) {
|
5 |
-
if ( wp_verify_nonce($_POST['wp-statistics-nonce'], 'update-options') ) {
|
6 |
$wps_nonce_valid = true;
|
7 |
}
|
8 |
}
|
@@ -10,7 +10,7 @@ if ( array_key_exists('wp-statistics-nonce', $_POST) ) {
|
|
10 |
$wps_admin = false;
|
11 |
|
12 |
if ( current_user_can(
|
13 |
-
wp_statistics_validate_capability($WP_Statistics->get_option('manage_capability', 'manage_options'))
|
14 |
) ) {
|
15 |
$wps_admin = true;
|
16 |
}
|
@@ -19,89 +19,89 @@ if ( $wps_admin === false ) {
|
|
19 |
$wps_admin = 0;
|
20 |
}
|
21 |
?>
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
<?php wp_nonce_field('update-options', 'wp-statistics-nonce'); ?>
|
30 |
-
|
31 |
-
|
32 |
<?php if ( $wps_admin ) { ?>
|
33 |
-
|
34 |
'General',
|
35 |
'wp-statistics'
|
36 |
); ?></li>
|
37 |
-
|
38 |
'Notifications',
|
39 |
'wp-statistics'
|
40 |
); ?></li>
|
41 |
-
|
42 |
'Dashboard/Overview',
|
43 |
'wp-statistics'
|
44 |
); ?></li>
|
45 |
-
|
46 |
'Access Levels',
|
47 |
'wp-statistics'
|
48 |
); ?></li>
|
49 |
-
|
50 |
'Exclusions',
|
51 |
'wp-statistics'
|
52 |
); ?></li>
|
53 |
-
|
54 |
'Externals',
|
55 |
'wp-statistics'
|
56 |
); ?></li>
|
57 |
-
|
58 |
'Maintenance',
|
59 |
'wp-statistics'
|
60 |
); ?></li>
|
61 |
-
|
62 |
'Removal',
|
63 |
'wp-statistics'
|
64 |
); ?></li>
|
65 |
<?php } ?>
|
66 |
-
|
67 |
-
|
68 |
|
69 |
<?php if ( $wps_admin ) { ?>
|
70 |
-
|
71 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-general.php' ); ?>
|
72 |
-
|
73 |
-
|
74 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-notifications.php' ); ?>
|
75 |
-
|
76 |
-
|
77 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-overview-display.php' ); ?>
|
78 |
-
|
79 |
-
|
80 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-access-level.php' ); ?>
|
81 |
-
|
82 |
-
|
83 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-exclusions.php' ); ?>
|
84 |
-
|
85 |
-
|
86 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-externals.php' ); ?>
|
87 |
-
|
88 |
-
|
89 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-maintenance.php' ); ?>
|
90 |
-
|
91 |
-
|
92 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-removal.php' ); ?>
|
93 |
-
|
94 |
<?php } ?>
|
95 |
-
|
96 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-about.php' ); ?>
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?>
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
<?php
|
107 |
if ( $wps_nonce_valid ) {
|
1 |
<?php
|
2 |
$wps_nonce_valid = false;
|
3 |
|
4 |
+
if ( array_key_exists( 'wp-statistics-nonce', $_POST ) ) {
|
5 |
+
if ( wp_verify_nonce( $_POST['wp-statistics-nonce'], 'update-options' ) ) {
|
6 |
$wps_nonce_valid = true;
|
7 |
}
|
8 |
}
|
10 |
$wps_admin = false;
|
11 |
|
12 |
if ( current_user_can(
|
13 |
+
wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) )
|
14 |
) ) {
|
15 |
$wps_admin = true;
|
16 |
}
|
19 |
$wps_admin = 0;
|
20 |
}
|
21 |
?>
|
22 |
+
<div class="wrap wp-statistics-settings">
|
23 |
+
<h2><?php _e( 'Settings', 'wp-statistics' ); ?></h2>
|
24 |
|
25 |
+
<div id="poststuff">
|
26 |
+
<div id="post-body" class="metabox-holder columns-2">
|
27 |
+
<div class="wp-list-table widefat widefat">
|
28 |
+
<form id="wp-statistics-settings-form" method="post">
|
29 |
+
<?php wp_nonce_field( 'update-options', 'wp-statistics-nonce' ); ?>
|
30 |
+
<div class="wp-statistics-container">
|
31 |
+
<ul class="tabs">
|
32 |
<?php if ( $wps_admin ) { ?>
|
33 |
+
<li class="tab-link current" data-tab="general-settings"><?php _e(
|
34 |
'General',
|
35 |
'wp-statistics'
|
36 |
); ?></li>
|
37 |
+
<li class="tab-link" data-tab="notifications-settings"><?php _e(
|
38 |
'Notifications',
|
39 |
'wp-statistics'
|
40 |
); ?></li>
|
41 |
+
<li class="tab-link" data-tab="overview-display-settings"><?php _e(
|
42 |
'Dashboard/Overview',
|
43 |
'wp-statistics'
|
44 |
); ?></li>
|
45 |
+
<li class="tab-link" data-tab="access-settings"><?php _e(
|
46 |
'Access Levels',
|
47 |
'wp-statistics'
|
48 |
); ?></li>
|
49 |
+
<li class="tab-link" data-tab="exclusions-settings"><?php _e(
|
50 |
'Exclusions',
|
51 |
'wp-statistics'
|
52 |
); ?></li>
|
53 |
+
<li class="tab-link" data-tab="externals-settings"><?php _e(
|
54 |
'Externals',
|
55 |
'wp-statistics'
|
56 |
); ?></li>
|
57 |
+
<li class="tab-link" data-tab="maintenance-settings"><?php _e(
|
58 |
'Maintenance',
|
59 |
'wp-statistics'
|
60 |
); ?></li>
|
61 |
+
<li class="tab-link" data-tab="removal-settings"><?php _e(
|
62 |
'Removal',
|
63 |
'wp-statistics'
|
64 |
); ?></li>
|
65 |
<?php } ?>
|
66 |
+
<li class="tab-link" data-tab="about"><?php _e( 'About', 'wp-statistics' ); ?></li>
|
67 |
+
</ul>
|
68 |
|
69 |
<?php if ( $wps_admin ) { ?>
|
70 |
+
<div id="general-settings" class="tab-content current">
|
71 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-general.php' ); ?>
|
72 |
+
</div>
|
73 |
+
<div id="notifications-settings" class="tab-content">
|
74 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-notifications.php' ); ?>
|
75 |
+
</div>
|
76 |
+
<div id="overview-display-settings" class="tab-content">
|
77 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-overview-display.php' ); ?>
|
78 |
+
</div>
|
79 |
+
<div id="access-settings" class="tab-content">
|
80 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-access-level.php' ); ?>
|
81 |
+
</div>
|
82 |
+
<div id="exclusions-settings" class="tab-content">
|
83 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-exclusions.php' ); ?>
|
84 |
+
</div>
|
85 |
+
<div id="externals-settings" class="tab-content">
|
86 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-externals.php' ); ?>
|
87 |
+
</div>
|
88 |
+
<div id="maintenance-settings" class="tab-content">
|
89 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-maintenance.php' ); ?>
|
90 |
+
</div>
|
91 |
+
<div id="removal-settings" class="tab-content">
|
92 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-removal.php' ); ?>
|
93 |
+
</div>
|
94 |
<?php } ?>
|
95 |
+
<div id="about" class="tab-content">
|
96 |
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-about.php' ); ?>
|
97 |
+
</div>
|
98 |
+
</div><!-- container -->
|
99 |
+
</form>
|
100 |
+
</div>
|
101 |
<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?>
|
102 |
+
</div>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
|
106 |
<?php
|
107 |
if ( $wps_nonce_valid ) {
|
includes/templates/plugins.php
CHANGED
@@ -1,105 +1,105 @@
|
|
1 |
<div class="wrap">
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
<?php foreach ( $plugins->items as $plugin ) : ?>
|
12 |
-
|
13 |
<?php if ( $plugin->is_feature and $plugin->featured_label ) : ?>
|
14 |
<div class="cover-ribbon">
|
15 |
<div class="cover-ribbon-inside"><?php echo $plugin->featured_label; ?></div>
|
16 |
</div>
|
17 |
<?php endif; ?>
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
<?php echo $plugin->name; ?>
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
<?php
|
40 |
-
if ( is_plugin_active($plugin->slug . '/' . $plugin->slug . '.php') ) {
|
41 |
-
_e('Active', 'wp-statistics');
|
42 |
} else if ( file_exists(
|
43 |
WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php'
|
44 |
) ) {
|
45 |
-
_e('Inactive', 'wp-statistics');
|
46 |
} else {
|
47 |
-
_e('Not installed', 'wp-statistics');
|
48 |
}
|
49 |
?>
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
<?php if ( is_plugin_active($plugin->slug . '/' . $plugin->slug . '.php') ) { ?>
|
54 |
-
|
55 |
-
|
56 |
<?php } else { ?>
|
57 |
<?php if ( file_exists(
|
58 |
WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php'
|
59 |
) ) { ?>
|
60 |
-
|
61 |
-
|
62 |
<?php } else { ?>
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
<?php } ?>
|
69 |
<?php } ?>
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
<?php endforeach; ?>
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
<?php $paneltitle = __('Join to Market!', 'wp-statistics'); ?>
|
81 |
-
|
82 |
<span class="screen-reader-text"><?php printf(
|
83 |
-
__('Toggle panel: %s', 'wp-statistics'),
|
84 |
$paneltitle
|
85 |
); ?></span>
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
'We welcome practical extensions for the WP-Statistics plugin. In case you\'re a WordPress programmer and developer and plan to sell extension in this page, please contact us through the following link.',
|
93 |
'wp-statistics'
|
94 |
); ?></p>
|
95 |
-
|
96 |
'Submit Add-on',
|
97 |
'wp-statistics'
|
98 |
); ?></a>
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
</div>
|
1 |
<div class="wrap">
|
2 |
+
<h2><?php esc_html_e( 'Extensions for WP-Statistics', 'wp-statistics' ); ?></h2>
|
3 |
|
4 |
+
<div id="poststuff" class="wp-statistics-plugins">
|
5 |
+
<div id="post-body"
|
6 |
+
class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
7 |
+
<p><?php _e( 'These extensions add functionality to your WP-Statistics.', 'wp-statistics' ); ?></p>
|
8 |
|
9 |
+
<div class="wp-list-table widefat widefat plugin-install">
|
10 |
+
<div id="the-list">
|
11 |
<?php foreach ( $plugins->items as $plugin ) : ?>
|
12 |
+
<div class="plugin-card">
|
13 |
<?php if ( $plugin->is_feature and $plugin->featured_label ) : ?>
|
14 |
<div class="cover-ribbon">
|
15 |
<div class="cover-ribbon-inside"><?php echo $plugin->featured_label; ?></div>
|
16 |
</div>
|
17 |
<?php endif; ?>
|
18 |
|
19 |
+
<div class="plugin-card-top">
|
20 |
+
<div class="name column-name">
|
21 |
+
<h3>
|
22 |
+
<a target="_blank" href="<?php echo $plugin->url; ?>"
|
23 |
+
class="thickbox open-plugin-details-modal">
|
24 |
<?php echo $plugin->name; ?>
|
25 |
+
<img src="<?php echo $plugin->icon; ?>" class="plugin-icon" alt="">
|
26 |
+
</a>
|
27 |
+
</h3>
|
28 |
+
</div>
|
29 |
|
30 |
+
<div class="desc column-description">
|
31 |
+
<p><?php echo wp_trim_words( $plugin->description, 20 ); ?></p>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
<div class="plugin-card-bottom">
|
35 |
+
<div class="column-downloaded">
|
36 |
+
<strong><?php _e( 'Version:', 'wp-statistics' ); ?></strong><?php echo ' ' .
|
37 |
+
$plugin->version; ?>
|
38 |
+
<p><strong><?php _e( 'Status:', 'wp-statistics' ); ?></strong>
|
39 |
<?php
|
40 |
+
if ( is_plugin_active( $plugin->slug . '/' . $plugin->slug . '.php' ) ) {
|
41 |
+
_e( 'Active', 'wp-statistics' );
|
42 |
} else if ( file_exists(
|
43 |
WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php'
|
44 |
) ) {
|
45 |
+
_e( 'Inactive', 'wp-statistics' );
|
46 |
} else {
|
47 |
+
_e( 'Not installed', 'wp-statistics' );
|
48 |
}
|
49 |
?>
|
50 |
+
</p>
|
51 |
+
</div>
|
52 |
+
<div class="column-compatibility">
|
53 |
+
<?php if ( is_plugin_active( $plugin->slug . '/' . $plugin->slug . '.php' ) ) { ?>
|
54 |
+
<a href="admin.php?page=wps_plugins_page&action=deactivate&plugin=<?php echo $plugin->slug; ?>"
|
55 |
+
class="button"><?php _e( 'Deactivate Add-On', 'wp-statistics' ); ?></a>
|
56 |
<?php } else { ?>
|
57 |
<?php if ( file_exists(
|
58 |
WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php'
|
59 |
) ) { ?>
|
60 |
+
<a href="admin.php?page=wps_plugins_page&action=activate&plugin=<?php echo $plugin->slug; ?>"
|
61 |
+
class="button"><?php _e( 'Activate Add-On', 'wp-statistics' ); ?></a>
|
62 |
<?php } else { ?>
|
63 |
+
<div class="column-price">
|
64 |
+
<strong>$<?php echo $plugin->price; ?></strong>
|
65 |
+
</div>
|
66 |
+
<a target="_blank" href="<?php echo $plugin->url; ?>"
|
67 |
+
class="button-primary"><?php _e( 'Buy Add-On', 'wp-statistics' ); ?></a>
|
68 |
<?php } ?>
|
69 |
<?php } ?>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
<?php endforeach; ?>
|
74 |
+
</div>
|
75 |
+
</div>
|
76 |
|
77 |
+
<div id="postbox-container-1" class="postbox-container">
|
78 |
+
<div class="meta-box-sortables ui-sortable">
|
79 |
+
<div id="wps-plugins-support" class="postbox">
|
80 |
+
<?php $paneltitle = __( 'Join to Market!', 'wp-statistics' ); ?>
|
81 |
+
<button class="handlediv" type="button" aria-expanded="true">
|
82 |
<span class="screen-reader-text"><?php printf(
|
83 |
+
__( 'Toggle panel: %s', 'wp-statistics' ),
|
84 |
$paneltitle
|
85 |
); ?></span>
|
86 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
87 |
+
</button>
|
88 |
+
<h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2>
|
89 |
|
90 |
+
<div class="inside">
|
91 |
+
<p><?php _e(
|
92 |
'We welcome practical extensions for the WP-Statistics plugin. In case you\'re a WordPress programmer and developer and plan to sell extension in this page, please contact us through the following link.',
|
93 |
'wp-statistics'
|
94 |
); ?></p>
|
95 |
+
<a href="http://wp-statistics.com/add-ons/submit" target="_blank" class="button"><?php _e(
|
96 |
'Submit Add-on',
|
97 |
'wp-statistics'
|
98 |
); ?></a>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
</div>
|
includes/templates/postbox.php
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
<div id="postbox-container-1" class="postbox-container">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
'Subscribe to our mailing list for get any news of the WP-Statistics',
|
12 |
'wp-statistics'
|
13 |
); ?></p>
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
<?php
|
24 |
-
$response
|
25 |
-
$response_code = wp_remote_retrieve_response_code($response);
|
26 |
|
27 |
-
if ( ! is_wp_error($response) and $response_code == '200' ) :
|
28 |
-
$result = json_decode($response['body']);
|
29 |
foreach ( $result->items as $item ) : ?>
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
endforeach;
|
39 |
endif;
|
40 |
?>
|
1 |
<div id="postbox-container-1" class="postbox-container">
|
2 |
+
<div class="meta-box-sortables">
|
3 |
+
<div id="wps-plugins-support" class="postbox">
|
4 |
+
<h2 class="hndle"><span><?php _e( 'Subscribe to Newsletter', 'wp-statistics' ); ?></span></h2>
|
5 |
|
6 |
+
<div class="inside">
|
7 |
+
<form
|
8 |
+
action="//veronalabs.us7.list-manage.com/subscribe/post?u=628dc1468c7c7db0ba42f0137&id=ea320ea877"
|
9 |
+
method="post" name="mc-embedded-subscribe-form" target="_blank" novalidate>
|
10 |
+
<p><?php _e(
|
11 |
'Subscribe to our mailing list for get any news of the WP-Statistics',
|
12 |
'wp-statistics'
|
13 |
); ?></p>
|
14 |
+
<input name="EMAIL" type="email" class="ltr" value="<?php bloginfo( 'admin_email' ); ?>">
|
15 |
+
<input type="hidden" name="b_628dc1468c7c7db0ba42f0137_ea320ea877" tabindex="-1" value="">
|
16 |
+
<input type="submit" value="<?php _e( 'Subscribe', 'wp-statistics' ); ?>" name="subscribe"
|
17 |
+
class="button">
|
18 |
+
</form>
|
19 |
+
</div>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
|
23 |
<?php
|
24 |
+
$response = wp_remote_get( 'https://wp-statistics.com/wp-json/plugin/postbox' );
|
25 |
+
$response_code = wp_remote_retrieve_response_code( $response );
|
26 |
|
27 |
+
if ( ! is_wp_error( $response ) and $response_code == '200' ) :
|
28 |
+
$result = json_decode( $response['body'] );
|
29 |
foreach ( $result->items as $item ) : ?>
|
30 |
+
<div class="meta-box-sortables">
|
31 |
+
<div id="wps-plugins-support" class="postbox">
|
32 |
+
<h2 class="hndle"><span><?php echo $item->title; ?></span></h2>
|
33 |
|
34 |
+
<div class="inside"><?php echo $item->content; ?></div>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
<?php
|
38 |
endforeach;
|
39 |
endif;
|
40 |
?>
|
includes/templates/{welcome.php → welcomes/last-version.php}
RENAMED
@@ -7,7 +7,7 @@
|
|
7 |
|
8 |
<h2 class="nav-tab-wrapper wp-clearfix">
|
9 |
<a href="#" class="nav-tab nav-tab-active"
|
10 |
-
data-tab="whats-news"><?php _e( 'What
|
11 |
<a href="#" class="nav-tab" data-tab="credit"><?php _e( 'Credits', 'wp-statistics' ); ?></a>
|
12 |
<a href="#" class="nav-tab" data-tab="changelog"><?php _e( 'Changelog', 'wp-statistics' ); ?></a>
|
13 |
</h2>
|
@@ -18,6 +18,23 @@
|
|
18 |
<h4><?php _e( 'You can see the new changes of WP-Statistics on this page.', 'wp-statistics' ); ?></h4>
|
19 |
</section>
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<section class="normal-section">
|
22 |
<div class="left">
|
23 |
<div class="content-padding">
|
@@ -27,7 +44,7 @@
|
|
27 |
</div>
|
28 |
|
29 |
<div class="right text-center">
|
30 |
-
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/
|
31 |
</div>
|
32 |
</section>
|
33 |
|
@@ -40,7 +57,7 @@
|
|
40 |
</div>
|
41 |
|
42 |
<div class="left text-center">
|
43 |
-
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/
|
44 |
</div>
|
45 |
</section>
|
46 |
|
@@ -65,6 +82,10 @@
|
|
65 |
<div class="content-padding">
|
66 |
<h2><?php _e( 'And the following issues have been solved in this version:', 'wp-statistics' ); ?></h2>
|
67 |
<ul>
|
|
|
|
|
|
|
|
|
68 |
<li><?php _e( 'Fixed Issue to create the object of the main class.', 'wp-statistics' ); ?></li>
|
69 |
<li><?php _e( 'Fixed Issue to get page title in empty search words option.', 'wp-statistics' ); ?></li>
|
70 |
<li><?php _e( 'Fixed Issue to show date range in the charts.', 'wp-statistics' ); ?></li>
|
@@ -81,13 +102,13 @@
|
|
81 |
|
82 |
<section class="center-section">
|
83 |
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-love.png' ); ?>"/>
|
84 |
-
<h4><?php echo sprintf( __( 'To help us, you can make <a href="%s" target="_blank">donate</a> or <a href="%s" target="_blank">purchase</a> Add-Ons.', 'wp-statistics' ), 'https://wp-statistics.com/donate/', 'https://wp-statistics.com/add-ons/' ); ?></h4>
|
85 |
</section>
|
86 |
</div>
|
87 |
|
88 |
<div data-content="credit" class="tab-content">
|
89 |
<div class="about-wrap-content">
|
90 |
-
<p class="about-description"><?php echo sprintf( __( 'WP-Statistics is created by some
|
91 |
<h3 class="wp-people-group"><?php _e( 'Project Leaders', 'wp-statistics' ); ?></h3>
|
92 |
<ul class="wp-people-group ">
|
93 |
<li class="wp-person">
|
@@ -115,12 +136,12 @@
|
|
115 |
</li>
|
116 |
</ul>
|
117 |
|
118 |
-
<p class="clear"><?php echo sprintf( __( 'WP-Statistics is being developed on GitHub,
|
119 |
<h3 class="wp-people-group"><?php _e( 'External Libraries', 'wp-statistics' ); ?></h3>
|
120 |
<p class="wp-credits-list">
|
121 |
-
<a href="http://www.maxmind.com/"
|
122 |
<a href="https://browscap.org/">Browscap</a>,
|
123 |
-
<a href="http://www.chartjs.org/"
|
124 |
</div>
|
125 |
</div>
|
126 |
|
@@ -131,7 +152,7 @@
|
|
131 |
<hr>
|
132 |
|
133 |
<div class="return-to-dashboard">
|
134 |
-
<a href="<?php echo admin_url( 'admin.php?page=wps_overview_page' ); ?>"><?php _e( 'Go to
|
135 |
</div>
|
136 |
</div>
|
137 |
</div>
|
7 |
|
8 |
<h2 class="nav-tab-wrapper wp-clearfix">
|
9 |
<a href="#" class="nav-tab nav-tab-active"
|
10 |
+
data-tab="whats-news"><?php _e( 'What’s New', 'wp-statistics' ); ?></a>
|
11 |
<a href="#" class="nav-tab" data-tab="credit"><?php _e( 'Credits', 'wp-statistics' ); ?></a>
|
12 |
<a href="#" class="nav-tab" data-tab="changelog"><?php _e( 'Changelog', 'wp-statistics' ); ?></a>
|
13 |
</h2>
|
18 |
<h4><?php _e( 'You can see the new changes of WP-Statistics on this page.', 'wp-statistics' ); ?></h4>
|
19 |
</section>
|
20 |
|
21 |
+
<section class="normal-section">
|
22 |
+
<div class="right">
|
23 |
+
<div class="content-padding">
|
24 |
+
<h2><?php _e( 'GeoIP & Browscap improvements', 'wp-statistics' ); ?></h2>
|
25 |
+
<h4><?php _e( 'Recent issue about GeoIP update database resolved and the Browscap improvements.', 'wp-statistics' ); ?></h4>
|
26 |
+
</div>
|
27 |
+
</div>
|
28 |
+
|
29 |
+
<div class="left text-center">
|
30 |
+
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/screenshot-maxmind-geoip.png' ); ?>"/>
|
31 |
+
</div>
|
32 |
+
</section>
|
33 |
+
|
34 |
+
<section class="center-section">
|
35 |
+
<h2><?php _e( 'And recent changes', 'wp-statistics' ); ?></h2>
|
36 |
+
</section>
|
37 |
+
|
38 |
<section class="normal-section">
|
39 |
<div class="left">
|
40 |
<div class="content-padding">
|
44 |
</div>
|
45 |
|
46 |
<div class="right text-center">
|
47 |
+
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/screenshot-hits.png' ); ?>"/>
|
48 |
</div>
|
49 |
</section>
|
50 |
|
57 |
</div>
|
58 |
|
59 |
<div class="left text-center">
|
60 |
+
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/screenshot-page-dropdown.png' ); ?>"/>
|
61 |
</div>
|
62 |
</section>
|
63 |
|
82 |
<div class="content-padding">
|
83 |
<h2><?php _e( 'And the following issues have been solved in this version:', 'wp-statistics' ); ?></h2>
|
84 |
<ul>
|
85 |
+
<li><?php _e( 'Updated Browscap to v3.1.0 and fixed some issues.', 'wp-statistics' ); ?></li>
|
86 |
+
<li><?php _e( 'Improvement Memory usage in the plugin when the Browscap is enabled.', 'wp-statistics' ); ?></li>
|
87 |
+
<li><?php _e( 'Improvement Cache system and update Browscap database.', 'wp-statistics' ); ?></li>
|
88 |
+
|
89 |
<li><?php _e( 'Fixed Issue to create the object of the main class.', 'wp-statistics' ); ?></li>
|
90 |
<li><?php _e( 'Fixed Issue to get page title in empty search words option.', 'wp-statistics' ); ?></li>
|
91 |
<li><?php _e( 'Fixed Issue to show date range in the charts.', 'wp-statistics' ); ?></li>
|
102 |
|
103 |
<section class="center-section">
|
104 |
<img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-love.png' ); ?>"/>
|
105 |
+
<h4><?php echo sprintf( __( 'To help us, you can make <a href="%s" target="_blank">donate</a> or <a href="%s" target="_blank">purchase</a> Add-Ons. 😊', 'wp-statistics' ), 'https://wp-statistics.com/donate/', 'https://wp-statistics.com/add-ons/' ); ?></h4>
|
106 |
</section>
|
107 |
</div>
|
108 |
|
109 |
<div data-content="credit" class="tab-content">
|
110 |
<div class="about-wrap-content">
|
111 |
+
<p class="about-description"><?php echo sprintf( __( 'WP-Statistics is created by some people and is one of the <a href="%s" target="_blank">VeronaLabs.com</a> projects.', 'wp-statistics' ), 'http://veronalabs.com' ); ?></p>
|
112 |
<h3 class="wp-people-group"><?php _e( 'Project Leaders', 'wp-statistics' ); ?></h3>
|
113 |
<ul class="wp-people-group ">
|
114 |
<li class="wp-person">
|
136 |
</li>
|
137 |
</ul>
|
138 |
|
139 |
+
<p class="clear"><?php echo sprintf( __( 'WP-Statistics is being developed on GitHub, if you’re interested in contributing to the plugin, please look at the <a href="%s" target="_blank">GitHub page</a>.', 'wp-statistics' ), 'https://github.com/wp-statistics/wp-statistics' ); ?></p>
|
140 |
<h3 class="wp-people-group"><?php _e( 'External Libraries', 'wp-statistics' ); ?></h3>
|
141 |
<p class="wp-credits-list">
|
142 |
+
<a href="http://www.maxmind.com/">MaxMind</a>,
|
143 |
<a href="https://browscap.org/">Browscap</a>,
|
144 |
+
<a href="http://www.chartjs.org/">Chart.js</a>.</p>
|
145 |
</div>
|
146 |
</div>
|
147 |
|
152 |
<hr>
|
153 |
|
154 |
<div class="return-to-dashboard">
|
155 |
+
<a href="<?php echo admin_url( 'admin.php?page=wps_overview_page' ); ?>"><?php _e( 'Go to Statistics → Overview', 'wp-statistics' ); ?></a>
|
156 |
</div>
|
157 |
</div>
|
158 |
</div>
|
includes/vendor/bin/browscap-php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env sh
|
2 |
+
|
3 |
+
dir=$(d=${0%[/\\]*}; cd "$d" > /dev/null; cd "../browscap/browscap-php/bin" && pwd)
|
4 |
+
|
5 |
+
# See if we are running in Cygwin by checking for cygpath program
|
6 |
+
if command -v 'cygpath' >/dev/null 2>&1; then
|
7 |
+
# Cygwin paths start with /cygdrive/ which will break windows PHP,
|
8 |
+
# so we need to translate the dir path to windows format. However
|
9 |
+
# we could be using cygwin PHP which does not require this, so we
|
10 |
+
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
|
11 |
+
if [[ $(which php) == /cygdrive/* ]]; then
|
12 |
+
dir=$(cygpath -m "$dir");
|
13 |
+
fi
|
14 |
+
fi
|
15 |
+
|
16 |
+
dir=$(echo $dir | sed 's/ /\ /g')
|
17 |
+
"${dir}/browscap-php" "$@"
|
includes/vendor/bin/browscap-php.bat
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
@ECHO OFF
|
2 |
+
setlocal DISABLEDELAYEDEXPANSION
|
3 |
+
SET BIN_TARGET=%~dp0/../browscap/browscap-php/bin/browscap-php
|
4 |
+
php "%BIN_TARGET%" %*
|
includes/vendor/browscap/browscap-php/.gitattributes
CHANGED
@@ -9,7 +9,5 @@
|
|
9 |
*.yml text eol=lf
|
10 |
*.xml text eol=lf
|
11 |
*.dist text eol=lf
|
12 |
-
*.txt text eol=lf
|
13 |
-
*.ini text eol=lf
|
14 |
.gitattributes text eol=lf
|
15 |
-
.gitignore text eol=lf
|
9 |
*.yml text eol=lf
|
10 |
*.xml text eol=lf
|
11 |
*.dist text eol=lf
|
|
|
|
|
12 |
.gitattributes text eol=lf
|
13 |
+
.gitignore text eol=lf
|
includes/vendor/browscap/browscap-php/.gitignore
CHANGED
@@ -5,9 +5,9 @@ vendor/
|
|
5 |
.project
|
6 |
composer.phar
|
7 |
composer.lock
|
8 |
-
resources
|
|
|
9 |
PHP_BrowscapINI
|
10 |
ergebnis.txt
|
11 |
tests/data/*
|
12 |
-
!tests/data
|
13 |
-
!tests/data/buildCache/
|
5 |
.project
|
6 |
composer.phar
|
7 |
composer.lock
|
8 |
+
resources/*
|
9 |
+
!resources/.gitkeep
|
10 |
PHP_BrowscapINI
|
11 |
ergebnis.txt
|
12 |
tests/data/*
|
13 |
+
!tests/data/.gitkeep
|
|
includes/vendor/browscap/browscap-php/.php_cs
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
3 |
+
->files()
|
4 |
+
->name('*.php')
|
5 |
+
->in(__DIR__ . '/src')
|
6 |
+
->in(__DIR__ . '/tests')
|
7 |
+
;
|
8 |
+
|
9 |
+
ini_set('memory_limit', '-1');
|
10 |
+
|
11 |
+
return Symfony\CS\Config\Config::create()
|
12 |
+
->level(\Symfony\CS\FixerInterface::PSR2_LEVEL)
|
13 |
+
->fixers(
|
14 |
+
array(
|
15 |
+
'unalign_double_arrow',
|
16 |
+
'double_arrow_multiline_whitespaces',
|
17 |
+
'align_equals',
|
18 |
+
'braces',
|
19 |
+
'concat_with_spaces',
|
20 |
+
'duplicate_semicolon',
|
21 |
+
'elseif',
|
22 |
+
'encoding',
|
23 |
+
'eof_ending',
|
24 |
+
'extra_empty_lines',
|
25 |
+
'function_call_space',
|
26 |
+
'function_declaration',
|
27 |
+
'indentation',
|
28 |
+
'join_function',
|
29 |
+
'line_after_namespace',
|
30 |
+
'linefeed',
|
31 |
+
'list_commas',
|
32 |
+
'lowercase_constants',
|
33 |
+
'lowercase_keywords',
|
34 |
+
'method_argument_space',
|
35 |
+
'multiple_use',
|
36 |
+
'namespace_no_leading_whitespace',
|
37 |
+
'no_blank_lines_after_class_opening',
|
38 |
+
'parenthesis',
|
39 |
+
'php_closing_tag',
|
40 |
+
'phpdoc_indent',
|
41 |
+
'phpdoc_no_access',
|
42 |
+
'phpdoc_no_empty_return',
|
43 |
+
'phpdoc_no_package',
|
44 |
+
'phpdoc_params',
|
45 |
+
'phpdoc_scalar',
|
46 |
+
'phpdoc_trim',
|
47 |
+
'phpdoc_types',
|
48 |
+
'phpdoc_var_without_name',
|
49 |
+
'remove_lines_between_uses',
|
50 |
+
'return',
|
51 |
+
'self_accessor',
|
52 |
+
'short_array_syntax',
|
53 |
+
'short_tag',
|
54 |
+
'single_line_after_imports',
|
55 |
+
'single_quote',
|
56 |
+
'spaces_before_semicolon',
|
57 |
+
'spaces_cast',
|
58 |
+
'ternary_spaces',
|
59 |
+
'trailing_spaces',
|
60 |
+
'trim_array_spaces',
|
61 |
+
'unused_use',
|
62 |
+
'visibility',
|
63 |
+
'whitespacy_lines',
|
64 |
+
'psr0',
|
65 |
+
'array_element_no_space_before_comma',
|
66 |
+
'array_element_white_space_after_comma',
|
67 |
+
'blankline_after_open_tag',
|
68 |
+
'function_typehint_space',
|
69 |
+
'include',
|
70 |
+
'multiline_array_trailing_comma',
|
71 |
+
'new_with_braces',
|
72 |
+
'object_operator',
|
73 |
+
'operators_spaces',
|
74 |
+
'phpdoc_inline_tag',
|
75 |
+
'pre_increment',
|
76 |
+
'print_to_echo',
|
77 |
+
'remove_leading_slash_use',
|
78 |
+
'short_bool_cast',
|
79 |
+
'single_array_no_trailing_comma',
|
80 |
+
'single_blank_line_before_namespace',
|
81 |
+
'standardize_not_equal',
|
82 |
+
'ereg_to_preg',
|
83 |
+
'multiline_spaces_before_semicolon',
|
84 |
+
'newline_after_open_tag',
|
85 |
+
'ordered_use',
|
86 |
+
'phpdoc_order',
|
87 |
+
'short_echo_tag',
|
88 |
+
'strict',
|
89 |
+
)
|
90 |
+
)
|
91 |
+
->finder($finder);
|
includes/vendor/browscap/browscap-php/.scrutinizer.yml
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
inherit: true
|
2 |
|
3 |
tools:
|
4 |
-
external_code_coverage:
|
|
|
|
|
|
1 |
inherit: true
|
2 |
|
3 |
tools:
|
4 |
+
external_code_coverage:
|
5 |
+
enabled: true
|
6 |
+
timeout: 1800 # 30 minutes
|
7 |
+
runs: 1
|
includes/vendor/browscap/browscap-php/.travis.yml
CHANGED
@@ -2,31 +2,51 @@ language: php
|
|
2 |
sudo: false
|
3 |
|
4 |
php:
|
5 |
-
- 5.3
|
6 |
-
- 5.4
|
7 |
-
- 5.5
|
8 |
- 5.6
|
9 |
- 7.0
|
|
|
10 |
- nightly
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
cache:
|
14 |
directories:
|
15 |
-
|
|
|
16 |
|
17 |
-
|
18 |
- .travis-scripts/cache-browscap.sh
|
|
|
|
|
|
|
19 |
- travis_retry composer self-update
|
20 |
-
|
|
|
|
|
21 |
|
22 |
script:
|
23 |
-
|
24 |
-
- if [
|
25 |
-
- if [
|
26 |
-
- php -d
|
|
|
27 |
|
28 |
after_script:
|
29 |
-
|
30 |
-
- if [ "`phpenv version-name`" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
|
31 |
-
- if [ "`phpenv version-name`" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
|
32 |
|
2 |
sudo: false
|
3 |
|
4 |
php:
|
|
|
|
|
|
|
5 |
- 5.6
|
6 |
- 7.0
|
7 |
+
- 7.1
|
8 |
- nightly
|
9 |
+
|
10 |
+
os:
|
11 |
+
- linux
|
12 |
+
|
13 |
+
env:
|
14 |
+
- COMPOSER_FLAGS="--prefer-lowest"
|
15 |
+
- COMPOSER_FLAGS=""
|
16 |
+
|
17 |
+
matrix:
|
18 |
+
include:
|
19 |
+
- php: 7.0
|
20 |
+
env: COVERAGE=yes
|
21 |
+
- php: 7.0
|
22 |
+
env: EXECUTE_CS_CHECK=yes
|
23 |
+
- php: 7.1
|
24 |
+
env: COMPARE=yes
|
25 |
+
allow_failures:
|
26 |
+
- php: nightly
|
27 |
|
28 |
cache:
|
29 |
directories:
|
30 |
+
- $TRAVIS_BUILD_DIR/resources
|
31 |
+
- $HOME/.composer/cache
|
32 |
|
33 |
+
before_install:
|
34 |
- .travis-scripts/cache-browscap.sh
|
35 |
+
- if [[ $TRAVIS_PHP_VERSION != nightly && $COVERAGE != yes ]]; then phpenv config-rm xdebug.ini; fi
|
36 |
+
- echo 'opcache.enable=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
37 |
+
- echo 'opcache.enable_cli=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
38 |
- travis_retry composer self-update
|
39 |
+
|
40 |
+
install:
|
41 |
+
- travis_retry composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv $COMPOSER_FLAGS
|
42 |
|
43 |
script:
|
44 |
+
- if [[ $COVERAGE == yes ]]; then php -d browscap=$TRAVIS_BUILD_DIR/resources/browscap.ini vendor/bin/phpunit --exclude-group compare --coverage-text --coverage-clover=coverage.clover; fi
|
45 |
+
- if [[ $COVERAGE != yes && $COMPARE != yes ]]; then php -d browscap=$TRAVIS_BUILD_DIR/resources/browscap.ini vendor/bin/phpunit --no-coverage --exclude-group compare; fi
|
46 |
+
- if [[ $COMPARE == yes ]]; then php -d browscap=$TRAVIS_BUILD_DIR/resources/browscap.ini vendor/bin/phpunit --no-coverage --group compare; fi
|
47 |
+
- if [[ $EXECUTE_CS_CHECK == yes ]]; then php -n -d memory_limit=768M vendor/bin/phpcs; fi
|
48 |
+
- if [[ $EXECUTE_CS_CHECK == yes ]]; then php -n -d memory_limit=768M vendor/bin/php-cs-fixer fix --dry-run -vv; fi
|
49 |
|
50 |
after_script:
|
51 |
+
- if [[ $COVERAGE = yes ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
|
|
|
|
|
52 |
|
includes/vendor/browscap/browscap-php/CHANGELOG.md
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
Changelog
|
2 |
-
-------
|
3 |
-
|
4 |
-
### Version 2.0.0 - June 23, 2014
|
5 |
-
- #25 for caching error
|
6 |
-
- #14 reducing memory consumption slightly
|
7 |
-
- #22 use the "normal" version instead of "full" version
|
8 |
-
- #15 general improvements
|
9 |
-
- #13 code formatting improvements
|
10 |
-
- #12 allow proxy settings via fsockopen with context
|
11 |
-
- #9 default timeout settings fix
|
12 |
-
- #11, #27 improved tests
|
13 |
-
|
14 |
-
### Version 2.0.0-beta - August 25, 2013
|
15 |
-
- Added a new method to retrieve the source file version `$browscap->getSourceVersion()`.
|
16 |
-
- Added a safety feature to regenerate the cache file always when `Browscap::CACHE_FILE_VERSION` changes.
|
17 |
-
- Updated source file download URLs to new temporary URLs.
|
18 |
-
- Added new lines `\n` to the cache files for readability.
|
19 |
-
- Default download URL is changed so it will get and parse the full file instead of 'standard'.
|
20 |
-
[ua-speed-tests](https://github.com/quentin389/ua-speed-tests) shows that there is only a small performance difference between
|
21 |
-
using those two versions.
|
22 |
-
- Performance upgrades (see [ua-speed-tests](https://github.com/quentin389/ua-speed-tests) for performance tests):
|
23 |
-
* **5 times faster** for real user agents, with opcache on
|
24 |
-
* **11 times faster** for user agents that do not match anything, with opcache on
|
25 |
-
* **3 times faster** for real user agents, without using opcache
|
26 |
-
* **5 times faster** for user agents that do not match anything, without using opcache
|
27 |
-
* Regular expression pattern matches are being grouped by version numbers. The matches are performed
|
28 |
-
in two stages. 1 - standard regular expression match with numbers that differ across source file
|
29 |
-
patterns replaced with single character wildcard match. 2 - a check is performed on found numeric
|
30 |
-
values to see if any of the grouped values are an exact match. If not, then the searching process resumes.
|
31 |
-
This is the main source of the speed optimization. It greatly reduces the source file size and
|
32 |
-
greatly increases matching performance.
|
33 |
-
* Data that is not required to perform matches or return results was removed from the cache files.
|
34 |
-
That includes the source file match strings, which can be recreated from the regex ones, and a large set
|
35 |
-
of browser name entries which were never used because they had parents. Decreasing the cache file size
|
36 |
-
is very important for when you don't use any PHP opcache, because loading large data structures into
|
37 |
-
PHP takes a very long time.
|
38 |
-
* Arrays that are not used in `foreach` loops were serialized in the cache file. This also decreases the time
|
39 |
-
it takes to load the cache file when not using opcache. It's generally a very bad idea to load large arrays
|
40 |
-
with subarrays into PHP. Serializing does a great job when optimizing performance.
|
41 |
-
* The above changes address performance issues brought up in https://github.com/GaretJax/phpbrowscap/issues/26
|
42 |
-
- Bug fixes:
|
43 |
-
* Fixed https://github.com/GaretJax/phpbrowscap/issues/35
|
44 |
-
* Fixed https://github.com/GaretJax/phpbrowscap/issues/34
|
45 |
-
* Fixed https://github.com/GaretJax/phpbrowscap/issues/33
|
46 |
-
* Fixed https://github.com/GaretJax/phpbrowscap/issues/32
|
47 |
-
* Bug https://github.com/GaretJax/phpbrowscap/issues/17 is resolved, although that was fixed even before.
|
48 |
-
* Merged https://github.com/GaretJax/phpbrowscap/pull/25 - those are mainly comment changes but there are also two fixes
|
49 |
-
for `$browscap->clearProxySettings()` method, which did not work properly when an optional `$wrapper` parameter was passed.
|
50 |
-
- Added a new testing class that compares result of `Browscap` to `get_browser()` for as many browsers as possible
|
51 |
-
and checks if there are any differences in parsing. It also compares the parsing speed (in a simplistic way,
|
52 |
-
more advanced tests are available at https://github.com/quentin389/ua-speed-tests).
|
53 |
-
|
54 |
-
### Version 1.0.0 - July 22, 2012
|
55 |
-
- Initial version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/browscap/browscap-php/LICENSE
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
Copyright (c)
|
|
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
of this software and associated documentation files (the "Software"), to deal
|
@@ -16,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
1 |
+
Copyright (c) 1998-2015 Browser Capabilities Project
|
2 |
+
Copyright (c) 2007-2014 Jonathan Stoppani <jonathan.stoppani@gmail.com>
|
3 |
|
4 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
of this software and associated documentation files (the "Software"), to deal
|
17 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20 |
+
THE SOFTWARE.
|
includes/vendor/browscap/browscap-php/README.md
CHANGED
@@ -3,9 +3,9 @@ Browser Capabilities PHP Project
|
|
3 |
|
4 |
This is a userland replacement for PHP's native `get_browser()` function, which is _officially supported_ by the Browser Capabilities Project.
|
5 |
|
6 |
-
|
7 |
|
8 |
-
[![Build Status](https://secure.travis-ci.org/browscap/browscap-php.png?branch=
|
9 |
|
10 |
Installation
|
11 |
------------
|
@@ -13,13 +13,13 @@ Installation
|
|
13 |
Run the command below to install via Composer
|
14 |
|
15 |
```shell
|
16 |
-
composer require browscap/browscap-php
|
17 |
```
|
18 |
|
19 |
-
Then you may identify the current user agent
|
20 |
|
21 |
```php
|
22 |
-
use
|
23 |
|
24 |
$browscap = new Browscap();
|
25 |
$info = $browscap->getBrowser();
|
@@ -28,23 +28,269 @@ $info = $browscap->getBrowser();
|
|
28 |
Recommended Setup
|
29 |
-----------------
|
30 |
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
```php
|
34 |
-
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
```
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
```php
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
```
|
49 |
|
50 |
Issues and feature requests
|
3 |
|
4 |
This is a userland replacement for PHP's native `get_browser()` function, which is _officially supported_ by the Browser Capabilities Project.
|
5 |
|
6 |
+
**Note that you are currently viewing the 3.x series. If you're looking for any 2.x version, please read the documentation for that branch [here](https://github.com/browscap/browscap-php/tree/2.x).**
|
7 |
|
8 |
+
[![Build Status](https://secure.travis-ci.org/browscap/browscap-php.png?branch=master)](http://travis-ci.org/browscap/browscap-php) [![Code Coverage](https://scrutinizer-ci.com/g/browscap/browscap-php/badges/coverage.png?s=61cb32ca83d2053ed9b140690b6e18dfa00e4639)](https://scrutinizer-ci.com/g/browscap/browscap-php/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/browscap/browscap-php/badges/quality-score.png?s=db1cc1699b1cb6ac6ae46754ef9612217eba5526)](https://scrutinizer-ci.com/g/browscap/browscap-php/)
|
9 |
|
10 |
Installation
|
11 |
------------
|
13 |
Run the command below to install via Composer
|
14 |
|
15 |
```shell
|
16 |
+
composer require browscap/browscap-php
|
17 |
```
|
18 |
|
19 |
+
Then you may identify the current user agent this way:
|
20 |
|
21 |
```php
|
22 |
+
use BrowscapPHP\Browscap;
|
23 |
|
24 |
$browscap = new Browscap();
|
25 |
$info = $browscap->getBrowser();
|
28 |
Recommended Setup
|
29 |
-----------------
|
30 |
|
31 |
+
Before you can start, you have to download the browscap.ini file and convert it into a cache. There are two ways.
|
32 |
+
|
33 |
+
a. Download the file and convert it in two steps. The downloaded file will be stored in a local file, but there is no check
|
34 |
+
if the remote file has changed. If your cache gets corrupted you only need to rerun the `convert` command.
|
35 |
|
36 |
```php
|
37 |
+
vendor/bin/browscap-php browscap:fetch
|
38 |
+
vendor/bin/browscap-php browscap:convert
|
39 |
+
```
|
40 |
|
41 |
+
b. Download the file and convert it in one step. The downloaded file will not be stored in a local file, but there is a check
|
42 |
+
if the remote file has changed. If your cache gets corrupted you have clean the cache and restart the process.
|
43 |
+
|
44 |
+
```php
|
45 |
+
vendor/bin/browscap-php browscap:update
|
46 |
+
```
|
47 |
+
|
48 |
+
If you want to autoupdate the used cache, we recommend a separate cron job that calls the command listed above.
|
49 |
+
|
50 |
+
What's changed in version 3.x
|
51 |
+
-----------------------------
|
52 |
+
|
53 |
+
## Changes
|
54 |
+
|
55 |
+
* the namespace was changed to `BrowscapPHP`
|
56 |
+
* the `Browscap` class was split into pieces
|
57 |
+
* for caching the [WurflCache](https://github.com/mimmi20/WurflCache) package is used
|
58 |
+
* for downloading the browscap.ini the [Guzzle HTTP](https://github.com/guzzle/guzzle) package is used
|
59 |
+
|
60 |
+
## Removed features
|
61 |
+
|
62 |
+
* the autoupdate function was removed
|
63 |
+
* all public properties were removed
|
64 |
+
|
65 |
+
## New features
|
66 |
+
|
67 |
+
* now it is possible to use other caches than the file cache (see the [WurflCache](https://github.com/mimmi20/WurflCache) package formore information)
|
68 |
+
* now it is possible to write your own formatter to change the output format
|
69 |
+
* now it is possbile to set a PSR-3 compatible logger
|
70 |
+
|
71 |
+
Setup Examples
|
72 |
+
--------------
|
73 |
+
|
74 |
+
## Update your setup to version 3.x
|
75 |
+
|
76 |
+
This is the base setup in version 2.x.
|
77 |
+
```php
|
78 |
+
// setup in version 2.x
|
79 |
+
$bc = new \phpbrowscap\Browscap($cacheDir);
|
80 |
+
$result = $bc->getBrowser();
|
81 |
+
```
|
82 |
+
|
83 |
+
Change this to the base setup for version 3.x. to use the v2 cache directory
|
84 |
+
```php
|
85 |
+
$bc = new \BrowscapPHP\Browscap();
|
86 |
+
$adapter = new \WurflCache\Adapter\File([\WurflCache\Adapter\File::DIR => $cacheDir]);
|
87 |
+
$bc->setCache($adapter);
|
88 |
+
$result = $bc->getBrowser();
|
89 |
+
```
|
90 |
+
|
91 |
+
Note: In version 2.x a cache directory was required, but version 3.x has a default directory.
|
92 |
+
If you don't require a specific cache directory, the setup becomes more simple.
|
93 |
+
```php
|
94 |
+
$result = (new \BrowscapPHP\Browscap())->getBrowser();
|
95 |
+
```
|
96 |
+
|
97 |
+
## Setting up a logger
|
98 |
+
|
99 |
+
If you want to log something that happens with the detector you may set an logger.
|
100 |
+
This logger has to implement the PSR3 logger interface from [Psr\Log](https://github.com/php-fig/log)
|
101 |
+
|
102 |
+
```php
|
103 |
+
$bc = new \BrowscapPHP\Browscap();
|
104 |
+
$logger = new \Monolog\Logger('name');
|
105 |
+
$bc->setLogger($logger);
|
106 |
+
```
|
107 |
+
|
108 |
+
## Setting up a Memcache
|
109 |
+
|
110 |
+
If you don't want to use a file cache, you may change the cache adapter.
|
111 |
+
This cache adapter has to implement the adapter interface from WurflCache\Adapter\AdapterInterface
|
112 |
+
```php
|
113 |
+
$memcacheConfiguration = [
|
114 |
+
'host' => '127.0.0.1', // optional, defaults to '127.0.0.1'
|
115 |
+
'port' => 11211, // optional, defaults to 11211
|
116 |
+
'namespace' => 'wurfl', // optional, defaults to 'wurfl'
|
117 |
+
'cacheExpiration' => 0, // optional, defaults to 0 (cache does not expire), expiration time in seconds
|
118 |
+
'cacheVersion' => '1234', // optional, default value may change in external library
|
119 |
+
];
|
120 |
+
$adapter = new \WurflCache\Adapter\Memcached($memcacheConfiguration);
|
121 |
+
$bc = new \BrowscapPHP\Browscap();
|
122 |
+
$bc->setCache($adapter);
|
123 |
+
```
|
124 |
+
|
125 |
+
NOTE: Please look into the [WurflCache](https://github.com/mimmi20/WurflCache) package for infomation about the other cache adapters.
|
126 |
+
|
127 |
+
## Using the full browscap.ini file
|
128 |
+
|
129 |
+
```php
|
130 |
+
$bc = new \BrowscapPHP\BrowscapUpdater();
|
131 |
+
$bc->update(\BrowscapPHP\Helper\IniLoader::PHP_INI_FULL);
|
132 |
+
```
|
133 |
+
|
134 |
+
## Setting up a proxy configuration
|
135 |
+
|
136 |
+
If you are behind a proxy or need a spcific configuration, you have to set up a client instance.
|
137 |
+
See into the [Guzzle documentation](http://docs.guzzlephp.org/en/latest/) for more information about this.
|
138 |
+
|
139 |
+
```php
|
140 |
+
$proxyConfig = [
|
141 |
+
'proxy' => [
|
142 |
+
'http' => 'tcp://localhost:8125',
|
143 |
+
'https' => 'tcp://localhost:8124',
|
144 |
+
],
|
145 |
+
];
|
146 |
+
$client = new \GuzzleHttp\Client($proxyConfig);
|
147 |
+
$bcu = new BrowscapUpdater();
|
148 |
+
$bcu->setClient($client);
|
149 |
+
```
|
150 |
+
|
151 |
+
Usage Examples
|
152 |
+
--------------
|
153 |
+
|
154 |
+
## Taking the user agent from the global $_SERVER variable
|
155 |
+
|
156 |
+
```php
|
157 |
+
$bc = new \BrowscapPHP\Browscap();
|
158 |
+
$current_browser = $bc->getBrowser();
|
159 |
+
```
|
160 |
+
|
161 |
+
## Using a sample useragent
|
162 |
+
|
163 |
+
```php
|
164 |
+
$bc = new \BrowscapPHP\Browscap();
|
165 |
+
$current_browser = $bc->getBrowser($the_user_agent);
|
166 |
+
```
|
167 |
+
|
168 |
+
the CLI commands
|
169 |
+
----------------
|
170 |
+
|
171 |
+
In version 3 some CLI commands were added.
|
172 |
+
|
173 |
+
NOTE: If you don't want to use a file cache, you could not use the CLI commands. It is not possible to use other caches there at the moment.
|
174 |
+
NOTE: Each operation (fetch, update, check-update) which fetches data from the remote host browscap.org may run into the
|
175 |
+
rate limit of that site. If this happens an Exception is thrown.
|
176 |
+
|
177 |
+
## check-update
|
178 |
+
|
179 |
+
If you only want to check if a new version of the browscap.ini is available, you can use the `check-update` command.
|
180 |
+
|
181 |
+
```php
|
182 |
+
vendor/bin/browscap-php browscap:check-update
|
183 |
+
```
|
184 |
+
|
185 |
+
###options
|
186 |
+
|
187 |
+
- `debug` (optional) if set more messages are printed to the console
|
188 |
+
- `cache` (optional) the relative path to your cache directory
|
189 |
+
|
190 |
+
## fetch
|
191 |
+
|
192 |
+
The `fetch` command downloads an ini file from browscap.org.
|
193 |
+
|
194 |
+
```php
|
195 |
+
vendor/bin/browscap-php browscap:fetch
|
196 |
+
```
|
197 |
+
|
198 |
+
###options
|
199 |
+
|
200 |
+
- `debug` (optional) if set more messages are printed to the console
|
201 |
+
- `remote-file` (optional) only required if you dont want to download the standerd file, possible values are
|
202 |
+
- `PHP_BrowscapINI` downloads the standard file (default)
|
203 |
+
- `Lite_PHP_BrowscapINI` downloads the lite file
|
204 |
+
- `Full_PHP_BrowscapINI` downloads the full file
|
205 |
+
- `file` (optional) the relative path to the local file where the remote content is stored
|
206 |
+
|
207 |
+
## convert
|
208 |
+
|
209 |
+
The `convert` command reads a local stored browscap.ini file and writes the contents into a cache.
|
210 |
+
|
211 |
+
```php
|
212 |
+
vendor/bin/browscap-php browscap:convert
|
213 |
+
```
|
214 |
+
|
215 |
+
###options
|
216 |
+
|
217 |
+
- `file` (optional) the relative path to the local file where the remote content is stored, this should be the same file as in the fetch command
|
218 |
+
- `debug` (optional) if set more messages are printed to the console
|
219 |
+
- `cache` (optional) the relative path to your cache directory
|
220 |
+
|
221 |
+
## update
|
222 |
+
|
223 |
+
The `update` command downloads an ini file from browscap.org and writes the contents into a cache. No local files are created.
|
224 |
+
|
225 |
+
```php
|
226 |
+
vendor/bin/browscap-php browscap:update
|
227 |
+
```
|
228 |
+
|
229 |
+
###options
|
230 |
+
|
231 |
+
- `debug` (optional) if set more messages are printed to the console
|
232 |
+
- `remote-file`(optional) only required if you dont want to download the standerd file, possible values are
|
233 |
+
- `PHP_BrowscapINI` downloads the standard file (default)
|
234 |
+
- `Lite_PHP_BrowscapINI` downloads the lite file
|
235 |
+
- `Full_PHP_BrowscapINI` downloads the full file
|
236 |
+
- `cache` (optional) the relative path to your cache directory
|
237 |
+
|
238 |
+
## parse
|
239 |
+
|
240 |
+
The `parse` command parses a given user agent and writes the result to the console.
|
241 |
+
|
242 |
+
```php
|
243 |
+
vendor/bin/browscap-php browscap:parse
|
244 |
+
```
|
245 |
+
|
246 |
+
###options
|
247 |
+
|
248 |
+
- `user-agent` (required) the user agent which should be parsed
|
249 |
+
- `debug` (optional) if set more messages are printed to the console
|
250 |
+
- `cache` (optional) the relative path to your cache directory
|
251 |
+
|
252 |
+
## log
|
253 |
+
|
254 |
+
The `log` command parses a single access log file or a directory with access log files and writes the results into an output file.
|
255 |
+
|
256 |
+
```php
|
257 |
+
vendor/bin/browscap-php browscap:log
|
258 |
```
|
259 |
|
260 |
+
###options
|
261 |
+
|
262 |
+
- `output` (required) the path to a log file where the results are stored
|
263 |
+
- `debug` (optional) if set more messages are printed to the console
|
264 |
+
- `cache` (optional) the relative path to your cache directory
|
265 |
+
- `log-file` (optional) the relative path to an access log file
|
266 |
+
- `log-dir` (optional) the relative path to directory with the log files
|
267 |
+
- `include` (optional) a glob compatible list of files which should be included, only used in comination with the `log-dir` option
|
268 |
+
- `exclude` (optional) a glob compatible list of files which should be excluded from parsing, only used in comination with the `log-dir` option
|
269 |
+
|
270 |
+
NOTE: One of both options `log-file` and `log-dir` is required.
|
271 |
+
NOTE: At the moment only Apache access logs are supported.
|
272 |
+
|
273 |
+
CLI Examples
|
274 |
+
------------
|
275 |
+
|
276 |
+
## Updating the cache using the full browscap.ini file
|
277 |
+
|
278 |
+
Note: Both ways to create/update the cache will use the `standard` mode file as default.
|
279 |
+
If you want more detailed information you may change this with the `remote-file` option.
|
280 |
+
Please use the help function this parameter.
|
281 |
|
282 |
```php
|
283 |
+
vendor/bin/browscap-php browscap:update --remote-file Full_PHP_BrowscapINI
|
284 |
+
```
|
285 |
|
286 |
+
## Updating a custom cache dir
|
287 |
+
|
288 |
+
Each operation expect fetch uses a cache inside the `resources` directory inside the project. If you update this library with
|
289 |
+
composer, the cache is cleared also. If you want to avoid this and want to set your own cache folder,
|
290 |
+
you can use the `cache` option. If you do this, you have to set a Cache Instance for this this path.
|
291 |
+
|
292 |
+
```php
|
293 |
+
vendor/bin/browscap-php browscap:update --cache ./browscap-cache
|
294 |
```
|
295 |
|
296 |
Issues and feature requests
|
includes/vendor/browscap/browscap-php/bin/browscap-php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env php
|
2 |
+
<?php
|
3 |
+
|
4 |
+
$baseDir = dirname(__DIR__);
|
5 |
+
|
6 |
+
$autoloadPaths = array(
|
7 |
+
$baseDir . '/vendor/autoload.php',
|
8 |
+
$baseDir . '/../../autoload.php',
|
9 |
+
);
|
10 |
+
|
11 |
+
$foundVendorAutoload = false;
|
12 |
+
foreach ($autoloadPaths as $path) {
|
13 |
+
if (file_exists($path)) {
|
14 |
+
require $path;
|
15 |
+
$foundVendorAutoload = true;
|
16 |
+
break;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
if (!$foundVendorAutoload) {
|
21 |
+
throw new \Exception('Could not find autoload path in any of the searched locations');
|
22 |
+
}
|
23 |
+
|
24 |
+
use BrowscapPHP\Exception;
|
25 |
+
use Symfony\Component\Console\Application;
|
26 |
+
use BrowscapPHP\Command;
|
27 |
+
|
28 |
+
$cacheDirectory = $baseDir . '/resources/';
|
29 |
+
$defaultIniFile = $baseDir . '/resources/browscap.ini';
|
30 |
+
|
31 |
+
$application = new Application('browscap.php');
|
32 |
+
$application->add(new Command\ConvertCommand($cacheDirectory, $defaultIniFile));
|
33 |
+
$application->add(new Command\UpdateCommand($cacheDirectory));
|
34 |
+
$application->add(new Command\ParserCommand($cacheDirectory));
|
35 |
+
$application->add(new Command\LogfileCommand($cacheDirectory));
|
36 |
+
$application->add(new Command\FetchCommand($defaultIniFile));
|
37 |
+
$application->add(new Command\CheckUpdateCommand($cacheDirectory));
|
38 |
+
|
39 |
+
ini_set('memory_limit', '512M');
|
40 |
+
|
41 |
+
$application->run();
|
includes/vendor/browscap/browscap-php/composer.json
CHANGED
@@ -1,47 +1,55 @@
|
|
1 |
{
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
"
|
7 |
-
"
|
8 |
-
"
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
},
|
18 |
-
{
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
},
|
22 |
-
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
"
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
"autoload-dev": {
|
43 |
-
"psr-0": {
|
44 |
-
"phpbrowscapTest\\": "tests/"
|
45 |
-
}
|
46 |
-
}
|
47 |
}
|
1 |
{
|
2 |
+
"name": "browscap/browscap-php",
|
3 |
+
"type": "library",
|
4 |
+
"description": "Standalone replacement for php's native get_browser() function",
|
5 |
+
"keywords": ["get_browser", "browser", "capabilities", "user agent"],
|
6 |
+
"homepage": "https://github.com/browscap/browscap-php",
|
7 |
+
"license": "MIT",
|
8 |
+
"authors": [
|
9 |
+
{
|
10 |
+
"name": "Jonathan Stoppani",
|
11 |
+
"email": "jonathan.stoppani@gmail.com"
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "James Titcumb",
|
15 |
+
"email": "james@asgrim.com"
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"name": "Thomas Mueller",
|
19 |
+
"email": "t_mueller_stolzenhain@yahoo.de"
|
20 |
+
}
|
21 |
+
],
|
22 |
+
"support": {
|
23 |
+
"issues": "https://github.com/browscap/browscap-php/issues",
|
24 |
+
"source": "https://github.com/browscap/browscap-php"
|
25 |
},
|
26 |
+
"require": {
|
27 |
+
"php": "^5.6 || ^7.0",
|
28 |
+
"mimmi20/wurflcache": "^1.3",
|
29 |
+
"guzzlehttp/guzzle": "^6.2",
|
30 |
+
"symfony/filesystem": "^2.6 || ^3.0",
|
31 |
+
"symfony/finder": "^2.6 || ^3.0",
|
32 |
+
"symfony/console": "^2.6 || ^3.0",
|
33 |
+
"monolog/monolog": "^1.7"
|
34 |
},
|
35 |
+
"require-dev": {
|
36 |
+
"phpunit/phpunit": "^5.3",
|
37 |
+
"mikey179/vfsStream": "^1.6",
|
38 |
+
"squizlabs/php_codesniffer": "^2.5",
|
39 |
+
"friendsofphp/php-cs-fixer": "^1.11"
|
40 |
+
},
|
41 |
+
"suggest": {
|
42 |
+
"ext-curl": "to use curl requests to get the ini file"
|
43 |
+
},
|
44 |
+
"autoload": {
|
45 |
+
"psr-4": {
|
46 |
+
"BrowscapPHP\\": "src/"
|
47 |
+
}
|
48 |
+
},
|
49 |
+
"autoload-dev": {
|
50 |
+
"psr-4": {
|
51 |
+
"BrowscapPHPTest\\": "tests/"
|
52 |
+
}
|
53 |
+
},
|
54 |
+
"bin": ["bin/browscap-php"]
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
includes/vendor/browscap/browscap-php/phpcs.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<ruleset name="PHP_CodeSniffer">
|
3 |
+
<description>browscap-php</description>
|
4 |
+
|
5 |
+
<file>src</file>
|
6 |
+
<file>tests</file>
|
7 |
+
|
8 |
+
<exclude-pattern>*/temp/*</exclude-pattern>
|
9 |
+
|
10 |
+
<arg name="report" value="full" />
|
11 |
+
<arg value="np" />
|
12 |
+
|
13 |
+
<rule ref="PSR2" />
|
14 |
+
</ruleset>
|
includes/vendor/browscap/browscap-php/phpunit.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
<phpunit bootstrap="tests/bootstrap.php" colors="true">
|
4 |
-
<testsuites>
|
5 |
-
<testsuite name="phpbrowscap Test Suite">
|
6 |
-
<directory>tests/phpbrowscapTest/</directory>
|
7 |
-
</testsuite>
|
8 |
-
</testsuites>
|
9 |
-
|
10 |
-
<filter>
|
11 |
-
<whitelist>
|
12 |
-
<directory suffix=".php">src/phpbrowscap/</directory>
|
13 |
-
</whitelist>
|
14 |
-
</filter>
|
15 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/browscap/browscap-php/phpunit.xml.dist
CHANGED
@@ -1,15 +1,30 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
|
3 |
-
<phpunit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
<testsuites>
|
5 |
-
<testsuite name="
|
6 |
-
<directory>tests
|
7 |
</testsuite>
|
8 |
</testsuites>
|
9 |
|
10 |
<filter>
|
11 |
-
<whitelist>
|
12 |
-
<directory suffix=".php">src
|
13 |
</whitelist>
|
14 |
</filter>
|
15 |
</phpunit>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
|
3 |
+
<phpunit
|
4 |
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5 |
+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.3/phpunit.xsd"
|
6 |
+
beStrictAboutOutputDuringTests="true"
|
7 |
+
beStrictAboutTestsThatDoNotTestAnything="true"
|
8 |
+
beStrictAboutTodoAnnotatedTests="true"
|
9 |
+
verbose="true"
|
10 |
+
colors="auto"
|
11 |
+
bootstrap="vendor/autoload.php"
|
12 |
+
>
|
13 |
+
<php>
|
14 |
+
<ini name="error_reporting" value="-1"/>
|
15 |
+
<ini name="memory_limit" value="-1"/>
|
16 |
+
<ini name="date.timezone" value="UTC"/>
|
17 |
+
</php>
|
18 |
+
|
19 |
<testsuites>
|
20 |
+
<testsuite name="BrowscapPHP Test Suite">
|
21 |
+
<directory>tests/</directory>
|
22 |
</testsuite>
|
23 |
</testsuites>
|
24 |
|
25 |
<filter>
|
26 |
+
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
|
27 |
+
<directory suffix=".php">src/</directory>
|
28 |
</whitelist>
|
29 |
</filter>
|
30 |
</phpunit>
|
includes/vendor/browscap/browscap-php/{tests/data/buildCache → resources}/.gitkeep
RENAMED
File without changes
|
includes/vendor/browscap/browscap-php/src/Browscap.php
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
*/
|
28 |
+
|
29 |
+
namespace BrowscapPHP;
|
30 |
+
|
31 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
32 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
33 |
+
use BrowscapPHP\Helper\Quoter;
|
34 |
+
use BrowscapPHP\Parser\ParserInterface;
|
35 |
+
use Psr\Log\LoggerInterface;
|
36 |
+
use Psr\Log\NullLogger;
|
37 |
+
use WurflCache\Adapter\AdapterInterface;
|
38 |
+
use WurflCache\Adapter\File;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Browscap.ini parsing class with caching and update capabilities
|
42 |
+
*
|
43 |
+
* @category Browscap-PHP
|
44 |
+
* @author Jonathan Stoppani <jonathan@stoppani.name>
|
45 |
+
* @author Vítor Brandão <noisebleed@noiselabs.org>
|
46 |
+
* @author Mikołaj Misiurewicz <quentin389+phpb@gmail.com>
|
47 |
+
* @author Christoph Ziegenberg <christoph@ziegenberg.com>
|
48 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
49 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
50 |
+
* @version 3.0
|
51 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
52 |
+
* @link https://github.com/browscap/browscap-php/
|
53 |
+
*/
|
54 |
+
class Browscap
|
55 |
+
{
|
56 |
+
/**
|
57 |
+
* Parser to use
|
58 |
+
*
|
59 |
+
* @var \BrowscapPHP\Parser\ParserInterface
|
60 |
+
*/
|
61 |
+
private $parser = null;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Formatter to use
|
65 |
+
*
|
66 |
+
* @var \BrowscapPHP\Formatter\FormatterInterface
|
67 |
+
*/
|
68 |
+
private $formatter = null;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* The cache instance
|
72 |
+
*
|
73 |
+
* @var \BrowscapPHP\Cache\BrowscapCacheInterface
|
74 |
+
*/
|
75 |
+
private $cache = null;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @var @var \Psr\Log\LoggerInterface
|
79 |
+
*/
|
80 |
+
private $logger = null;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Set theformatter instance to use for the getBrowser() result
|
84 |
+
*
|
85 |
+
* @param \BrowscapPHP\Formatter\FormatterInterface $formatter
|
86 |
+
*
|
87 |
+
* @return \BrowscapPHP\Browscap
|
88 |
+
*/
|
89 |
+
public function setFormatter(Formatter\FormatterInterface $formatter)
|
90 |
+
{
|
91 |
+
$this->formatter = $formatter;
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @return \BrowscapPHP\Formatter\FormatterInterface
|
98 |
+
*/
|
99 |
+
public function getFormatter()
|
100 |
+
{
|
101 |
+
if (null === $this->formatter) {
|
102 |
+
$this->setFormatter(new Formatter\PhpGetBrowser());
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this->formatter;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Gets a cache instance
|
110 |
+
*
|
111 |
+
* @return \BrowscapPHP\Cache\BrowscapCacheInterface
|
112 |
+
*/
|
113 |
+
public function getCache()
|
114 |
+
{
|
115 |
+
if (null === $this->cache) {
|
116 |
+
$cacheDirectory = __DIR__ . '/../resources/';
|
117 |
+
|
118 |
+
$cacheAdapter = new File(
|
119 |
+
[File::DIR => $cacheDirectory]
|
120 |
+
);
|
121 |
+
|
122 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this->cache;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Sets a cache instance
|
130 |
+
*
|
131 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface|\WurflCache\Adapter\AdapterInterface $cache
|
132 |
+
*
|
133 |
+
* @throws \BrowscapPHP\Exception
|
134 |
+
* @return \BrowscapPHP\Browscap
|
135 |
+
*/
|
136 |
+
public function setCache($cache)
|
137 |
+
{
|
138 |
+
if ($cache instanceof BrowscapCacheInterface) {
|
139 |
+
$this->cache = $cache;
|
140 |
+
} elseif ($cache instanceof AdapterInterface) {
|
141 |
+
$this->cache = new BrowscapCache($cache);
|
142 |
+
} else {
|
143 |
+
throw new Exception(
|
144 |
+
'the cache has to be an instance of \BrowscapPHP\Cache\BrowscapCacheInterface or '
|
145 |
+
. 'an instanceof of \WurflCache\Adapter\AdapterInterface',
|
146 |
+
Exception::CACHE_INCOMPATIBLE
|
147 |
+
);
|
148 |
+
}
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Sets the parser instance to use
|
155 |
+
*
|
156 |
+
* @param \BrowscapPHP\Parser\ParserInterface $parser
|
157 |
+
*
|
158 |
+
* @return \BrowscapPHP\Browscap
|
159 |
+
*/
|
160 |
+
public function setParser(ParserInterface $parser)
|
161 |
+
{
|
162 |
+
$this->parser = $parser;
|
163 |
+
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* returns an instance of the used parser class
|
169 |
+
*
|
170 |
+
* @return \BrowscapPHP\Parser\ParserInterface
|
171 |
+
*/
|
172 |
+
public function getParser()
|
173 |
+
{
|
174 |
+
if (null === $this->parser) {
|
175 |
+
$cache = $this->getCache();
|
176 |
+
$logger = $this->getLogger();
|
177 |
+
$quoter = new Quoter();
|
178 |
+
|
179 |
+
$patternHelper = new Parser\Helper\GetPattern($cache, $logger);
|
180 |
+
$dataHelper = new Parser\Helper\GetData($cache, $logger, $quoter);
|
181 |
+
|
182 |
+
$this->parser = new Parser\Ini($patternHelper, $dataHelper, $this->getFormatter());
|
183 |
+
}
|
184 |
+
|
185 |
+
return $this->parser;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Sets a logger instance
|
190 |
+
*
|
191 |
+
* @param \Psr\Log\LoggerInterface $logger
|
192 |
+
*
|
193 |
+
* @return \BrowscapPHP\Browscap
|
194 |
+
*/
|
195 |
+
public function setLogger(LoggerInterface $logger)
|
196 |
+
{
|
197 |
+
$this->logger = $logger;
|
198 |
+
|
199 |
+
return $this;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* returns a logger instance
|
204 |
+
*
|
205 |
+
* @return \Psr\Log\LoggerInterface
|
206 |
+
*/
|
207 |
+
public function getLogger()
|
208 |
+
{
|
209 |
+
if (null === $this->logger) {
|
210 |
+
$this->logger = new NullLogger();
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this->logger;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* parses the given user agent to get the information about the browser
|
218 |
+
*
|
219 |
+
* if no user agent is given, it uses {@see \BrowscapPHP\Helper\Support} to get it
|
220 |
+
*
|
221 |
+
* @param string $userAgent the user agent string
|
222 |
+
*
|
223 |
+
* @throws \BrowscapPHP\Exception
|
224 |
+
* @return \stdClass the object containing the browsers details. Array if
|
225 |
+
* $return_array is set to true.
|
226 |
+
*/
|
227 |
+
public function getBrowser($userAgent = null)
|
228 |
+
{
|
229 |
+
if (null === $this->getCache()->getVersion()) {
|
230 |
+
// there is no active/warm cache available
|
231 |
+
throw new Exception('there is no active cache available, please run the update command');
|
232 |
+
}
|
233 |
+
|
234 |
+
// Automatically detect the useragent
|
235 |
+
if (!isset($userAgent)) {
|
236 |
+
$support = new Helper\Support($_SERVER);
|
237 |
+
$userAgent = $support->getUserAgent();
|
238 |
+
}
|
239 |
+
|
240 |
+
// try to get browser data
|
241 |
+
$formatter = $this->getParser()->getBrowser($userAgent);
|
242 |
+
|
243 |
+
// if return is still NULL, updates are disabled... in this
|
244 |
+
// case we return an empty formatter instance
|
245 |
+
if ($formatter === null) {
|
246 |
+
return $this->getFormatter()->getData();
|
247 |
+
}
|
248 |
+
|
249 |
+
return $formatter->getData();
|
250 |
+
}
|
251 |
+
}
|
includes/vendor/browscap/browscap-php/src/BrowscapUpdater.php
ADDED
@@ -0,0 +1,431 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
*/
|
28 |
+
|
29 |
+
namespace BrowscapPHP;
|
30 |
+
|
31 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
32 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
33 |
+
use BrowscapPHP\Exception\FetcherException;
|
34 |
+
use BrowscapPHP\Helper\Converter;
|
35 |
+
use BrowscapPHP\Helper\Filesystem;
|
36 |
+
use BrowscapPHP\Helper\IniLoader;
|
37 |
+
use GuzzleHttp\Client;
|
38 |
+
use Psr\Log\LoggerInterface;
|
39 |
+
use Psr\Log\NullLogger;
|
40 |
+
use WurflCache\Adapter\AdapterInterface;
|
41 |
+
use WurflCache\Adapter\File;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Browscap.ini parsing class with caching and update capabilities
|
45 |
+
*
|
46 |
+
* @category Browscap-PHP
|
47 |
+
* @author Jonathan Stoppani <jonathan@stoppani.name>
|
48 |
+
* @author Vítor Brandão <noisebleed@noiselabs.org>
|
49 |
+
* @author Mikołaj Misiurewicz <quentin389+phpb@gmail.com>
|
50 |
+
* @author Christoph Ziegenberg <christoph@ziegenberg.com>
|
51 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
52 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
53 |
+
* @version 3.0
|
54 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
55 |
+
* @link https://github.com/browscap/browscap-php/
|
56 |
+
*/
|
57 |
+
class BrowscapUpdater
|
58 |
+
{
|
59 |
+
/**
|
60 |
+
* The cache instance
|
61 |
+
*
|
62 |
+
* @var \BrowscapPHP\Cache\BrowscapCacheInterface
|
63 |
+
*/
|
64 |
+
private $cache = null;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @var @var \Psr\Log\LoggerInterface
|
68 |
+
*/
|
69 |
+
private $logger = null;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @var \GuzzleHttp\Client
|
73 |
+
*/
|
74 |
+
private $client = null;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Curl connect timeout in seconds
|
78 |
+
*
|
79 |
+
* @var int
|
80 |
+
*/
|
81 |
+
private $connectTimeout = 5;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Gets a cache instance
|
85 |
+
*
|
86 |
+
* @return \BrowscapPHP\Cache\BrowscapCacheInterface
|
87 |
+
*/
|
88 |
+
public function getCache()
|
89 |
+
{
|
90 |
+
if (null === $this->cache) {
|
91 |
+
$cacheDirectory = __DIR__ . '/../resources/';
|
92 |
+
|
93 |
+
$cacheAdapter = new File(
|
94 |
+
[File::DIR => $cacheDirectory]
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this->cache;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Sets a cache instance
|
105 |
+
*
|
106 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface|\WurflCache\Adapter\AdapterInterface $cache
|
107 |
+
*
|
108 |
+
* @throws \BrowscapPHP\Exception
|
109 |
+
*
|
110 |
+
* @return self
|
111 |
+
*/
|
112 |
+
public function setCache($cache)
|
113 |
+
{
|
114 |
+
if ($cache instanceof BrowscapCacheInterface) {
|
115 |
+
$this->cache = $cache;
|
116 |
+
} elseif ($cache instanceof AdapterInterface) {
|
117 |
+
$this->cache = new BrowscapCache($cache);
|
118 |
+
} else {
|
119 |
+
throw new Exception(
|
120 |
+
'the cache has to be an instance of \BrowscapPHP\Cache\BrowscapCacheInterface or '
|
121 |
+
. 'an instanceof of \WurflCache\Adapter\AdapterInterface',
|
122 |
+
Exception::CACHE_INCOMPATIBLE
|
123 |
+
);
|
124 |
+
}
|
125 |
+
|
126 |
+
return $this;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Sets a logger instance
|
131 |
+
*
|
132 |
+
* @param \Psr\Log\LoggerInterface $logger
|
133 |
+
*
|
134 |
+
* @return self
|
135 |
+
*/
|
136 |
+
public function setLogger(LoggerInterface $logger)
|
137 |
+
{
|
138 |
+
$this->logger = $logger;
|
139 |
+
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* returns a logger instance
|
145 |
+
*
|
146 |
+
* @return \Psr\Log\LoggerInterface
|
147 |
+
*/
|
148 |
+
public function getLogger()
|
149 |
+
{
|
150 |
+
if (null === $this->logger) {
|
151 |
+
$this->logger = new NullLogger();
|
152 |
+
}
|
153 |
+
|
154 |
+
return $this->logger;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Sets the Connection Timeout
|
159 |
+
*
|
160 |
+
* @param int $connectTimeout
|
161 |
+
*/
|
162 |
+
public function setConnectTimeout($connectTimeout)
|
163 |
+
{
|
164 |
+
$this->connectTimeout = (int) $connectTimeout;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @return \GuzzleHttp\Client
|
169 |
+
*/
|
170 |
+
public function getClient()
|
171 |
+
{
|
172 |
+
if (null === $this->client) {
|
173 |
+
$this->client = new Client();
|
174 |
+
}
|
175 |
+
|
176 |
+
return $this->client;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @param \GuzzleHttp\Client $client
|
181 |
+
*/
|
182 |
+
public function setClient(Client $client)
|
183 |
+
{
|
184 |
+
$this->client = $client;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* reads and parses an ini file and writes the results into the cache
|
189 |
+
*
|
190 |
+
* @param string $iniFile
|
191 |
+
*
|
192 |
+
* @throws \BrowscapPHP\Exception
|
193 |
+
*/
|
194 |
+
public function convertFile($iniFile)
|
195 |
+
{
|
196 |
+
if (empty($iniFile)) {
|
197 |
+
throw new Exception('the file name can not be empty');
|
198 |
+
}
|
199 |
+
|
200 |
+
if (!is_readable($iniFile)) {
|
201 |
+
throw new Exception('it was not possible to read the local file ' . $iniFile);
|
202 |
+
}
|
203 |
+
|
204 |
+
try {
|
205 |
+
$iniString = file_get_contents($iniFile);
|
206 |
+
} catch (Helper\Exception $e) {
|
207 |
+
throw new Exception('an error occured while converting the local file into the cache', 0, $e);
|
208 |
+
}
|
209 |
+
|
210 |
+
$this->convertString($iniString);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* reads and parses an ini string and writes the results into the cache
|
215 |
+
*
|
216 |
+
* @param string $iniString
|
217 |
+
*/
|
218 |
+
public function convertString($iniString)
|
219 |
+
{
|
220 |
+
$cachedVersion = $this->getCache()->getItem('browscap.version', false, $success);
|
221 |
+
$converter = new Converter($this->getLogger(), $this->getCache());
|
222 |
+
|
223 |
+
$this->storeContent($converter, $iniString, $cachedVersion);
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* fetches a remote file and stores it into a local folder
|
228 |
+
*
|
229 |
+
* @param string $file The name of the file where to store the remote content
|
230 |
+
* @param string $remoteFile The code for the remote file to load
|
231 |
+
*
|
232 |
+
* @throws \BrowscapPHP\Exception\FetcherException
|
233 |
+
* @throws \BrowscapPHP\Helper\Exception
|
234 |
+
*/
|
235 |
+
public function fetch($file, $remoteFile = IniLoader::PHP_INI)
|
236 |
+
{
|
237 |
+
if (null === ($cachedVersion = $this->checkUpdate())) {
|
238 |
+
// no newer version available
|
239 |
+
return;
|
240 |
+
}
|
241 |
+
|
242 |
+
$this->getLogger()->debug('started fetching remote file');
|
243 |
+
|
244 |
+
$uri = (new IniLoader())->setRemoteFilename($remoteFile)->getRemoteIniUrl();
|
245 |
+
|
246 |
+
/** @var \Psr\Http\Message\ResponseInterface $response */
|
247 |
+
$response = $this->getClient()->get($uri, ['connect_timeout' => $this->connectTimeout]);
|
248 |
+
|
249 |
+
if ($response->getStatusCode() !== 200) {
|
250 |
+
throw new FetcherException(
|
251 |
+
'an error occured while fetching remote data from URI ' . $uri . ': StatusCode was '
|
252 |
+
. $response->getStatusCode()
|
253 |
+
);
|
254 |
+
}
|
255 |
+
|
256 |
+
try {
|
257 |
+
$content = $response->getBody()->getContents();
|
258 |
+
} catch (\Exception $e) {
|
259 |
+
throw new FetcherException('an error occured while fetching remote data', 0, $e);
|
260 |
+
}
|
261 |
+
|
262 |
+
if (empty($content)) {
|
263 |
+
$error = error_get_last();
|
264 |
+
throw FetcherException::httpError($uri, $error['message']);
|
265 |
+
}
|
266 |
+
|
267 |
+
$this->getLogger()->debug('finished fetching remote file');
|
268 |
+
$this->getLogger()->debug('started storing remote file into local file');
|
269 |
+
|
270 |
+
$content = $this->sanitizeContent($content);
|
271 |
+
|
272 |
+
$converter = new Converter($this->getLogger(), $this->getCache());
|
273 |
+
$iniVersion = $converter->getIniVersion($content);
|
274 |
+
|
275 |
+
if ($iniVersion > $cachedVersion) {
|
276 |
+
$fs = new Filesystem();
|
277 |
+
$fs->dumpFile($file, $content);
|
278 |
+
}
|
279 |
+
|
280 |
+
$this->getLogger()->debug('finished storing remote file into local file');
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* fetches a remote file, parses it and writes the result into the cache
|
285 |
+
*
|
286 |
+
* if the local stored information are in the same version as the remote data no actions are
|
287 |
+
* taken
|
288 |
+
*
|
289 |
+
* @param string $remoteFile The code for the remote file to load
|
290 |
+
*
|
291 |
+
* @throws \BrowscapPHP\Exception\FileNotFoundException
|
292 |
+
* @throws \BrowscapPHP\Helper\Exception
|
293 |
+
* @throws \BrowscapPHP\Exception\FetcherException
|
294 |
+
*/
|
295 |
+
public function update($remoteFile = IniLoader::PHP_INI)
|
296 |
+
{
|
297 |
+
$this->getLogger()->debug('started fetching remote file');
|
298 |
+
|
299 |
+
if (null === ($cachedVersion = $this->checkUpdate())) {
|
300 |
+
// no newer version available
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
|
304 |
+
$uri = (new IniLoader())->setRemoteFilename($remoteFile)->getRemoteIniUrl();
|
305 |
+
|
306 |
+
/** @var \Psr\Http\Message\ResponseInterface $response */
|
307 |
+
$response = $this->getClient()->get($uri, ['connect_timeout' => $this->connectTimeout]);
|
308 |
+
|
309 |
+
if ($response->getStatusCode() !== 200) {
|
310 |
+
throw new FetcherException(
|
311 |
+
'an error occured while fetching remote data from URI ' . $uri . ': StatusCode was '
|
312 |
+
. $response->getStatusCode()
|
313 |
+
);
|
314 |
+
}
|
315 |
+
|
316 |
+
try {
|
317 |
+
$content = $response->getBody()->getContents();
|
318 |
+
} catch (\Exception $e) {
|
319 |
+
throw new FetcherException('an error occured while fetching remote data', 0, $e);
|
320 |
+
}
|
321 |
+
|
322 |
+
if (empty($content)) {
|
323 |
+
$error = error_get_last();
|
324 |
+
|
325 |
+
throw FetcherException::httpError($uri, $error['message']);
|
326 |
+
}
|
327 |
+
|
328 |
+
$this->getLogger()->debug('finished fetching remote file');
|
329 |
+
|
330 |
+
$converter = new Converter($this->getLogger(), $this->getCache());
|
331 |
+
|
332 |
+
$this->storeContent($converter, $content, $cachedVersion);
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* checks if an update on a remote location for the local file or the cache
|
337 |
+
*
|
338 |
+
* @throws \BrowscapPHP\Helper\Exception
|
339 |
+
* @throws \BrowscapPHP\Exception\FetcherException
|
340 |
+
* @return int|null The actual cached version if a newer version is available, null otherwise
|
341 |
+
* @return int|null The actual cached version if a newer version is available, null otherwise
|
342 |
+
*/
|
343 |
+
public function checkUpdate()
|
344 |
+
{
|
345 |
+
$success = null;
|
346 |
+
$cachedVersion = $this->getCache()->getItem('browscap.version', false, $success);
|
347 |
+
|
348 |
+
if (!$cachedVersion) {
|
349 |
+
// could not load version from cache
|
350 |
+
$this->getLogger()->info('there is no cached version available, please update from remote');
|
351 |
+
|
352 |
+
return 0;
|
353 |
+
}
|
354 |
+
|
355 |
+
$uri = (new IniLoader())->getRemoteVersionUrl();
|
356 |
+
|
357 |
+
/** @var \Psr\Http\Message\ResponseInterface $response */
|
358 |
+
$response = $this->getClient()->get($uri, ['connect_timeout' => $this->connectTimeout]);
|
359 |
+
|
360 |
+
if ($response->getStatusCode() !== 200) {
|
361 |
+
throw new FetcherException(
|
362 |
+
'an error occured while fetching version data from URI ' . $uri . ': StatusCode was '
|
363 |
+
. $response->getStatusCode()
|
364 |
+
);
|
365 |
+
}
|
366 |
+
|
367 |
+
try {
|
368 |
+
$remoteVersion = $response->getBody()->getContents();
|
369 |
+
} catch (\Exception $e) {
|
370 |
+
throw new FetcherException(
|
371 |
+
'an error occured while fetching version data from URI ' . $uri . ': StatusCode was '
|
372 |
+
. $response->getStatusCode(),
|
373 |
+
0,
|
374 |
+
$e
|
375 |
+
);
|
376 |
+
}
|
377 |
+
|
378 |
+
if (!$remoteVersion) {
|
379 |
+
// could not load remote version
|
380 |
+
$this->getLogger()->info('could not load version from remote location');
|
381 |
+
|
382 |
+
return 0;
|
383 |
+
}
|
384 |
+
|
385 |
+
if ($cachedVersion && $remoteVersion && $remoteVersion <= $cachedVersion) {
|
386 |
+
// no newer version available
|
387 |
+
$this->getLogger()->info('there is no newer version available');
|
388 |
+
|
389 |
+
return null;
|
390 |
+
}
|
391 |
+
|
392 |
+
$this->getLogger()->info(
|
393 |
+
'a newer version is available, local version: ' . $cachedVersion . ', remote version: ' . $remoteVersion
|
394 |
+
);
|
395 |
+
|
396 |
+
return (int) $cachedVersion;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* @param string $content
|
401 |
+
*
|
402 |
+
* @return mixed
|
403 |
+
*/
|
404 |
+
private function sanitizeContent($content)
|
405 |
+
{
|
406 |
+
// replace everything between opening and closing php and asp tags
|
407 |
+
$content = preg_replace('/<[?%].*[?%]>/', '', $content);
|
408 |
+
|
409 |
+
// replace opening and closing php and asp tags
|
410 |
+
return str_replace(['<?', '<%', '?>', '%>'], '', $content);
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* reads and parses an ini string and writes the results into the cache
|
415 |
+
*
|
416 |
+
* @param \BrowscapPHP\Helper\Converter $converter
|
417 |
+
* @param string $content
|
418 |
+
* @param int|null $cachedVersion
|
419 |
+
*/
|
420 |
+
private function storeContent(Converter $converter, $content, $cachedVersion)
|
421 |
+
{
|
422 |
+
$iniString = $this->sanitizeContent($content);
|
423 |
+
$iniVersion = $converter->getIniVersion($iniString);
|
424 |
+
|
425 |
+
if (!$cachedVersion || $iniVersion > $cachedVersion) {
|
426 |
+
$converter
|
427 |
+
->storeVersion()
|
428 |
+
->convertString($iniString);
|
429 |
+
}
|
430 |
+
}
|
431 |
+
}
|
includes/vendor/browscap/browscap-php/src/Cache/BrowscapCache.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Cache;
|
31 |
+
|
32 |
+
use WurflCache\Adapter\AdapterInterface;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* a cache proxy to be able to use the cache adapters provided by the WurflCache package
|
36 |
+
*
|
37 |
+
* @category Browscap-PHP
|
38 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
39 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
40 |
+
* @version 3.0
|
41 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
42 |
+
* @link https://github.com/browscap/browscap-php/
|
43 |
+
*/
|
44 |
+
class BrowscapCache implements BrowscapCacheInterface
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* Path to the cache directory
|
48 |
+
*
|
49 |
+
* @var \WurflCache\Adapter\AdapterInterface
|
50 |
+
*/
|
51 |
+
private $cache = null;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Detected browscap version (read from INI file)
|
55 |
+
*
|
56 |
+
* @var int
|
57 |
+
*/
|
58 |
+
private $version = null;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Release date of the Browscap data (read from INI file)
|
62 |
+
*
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
private $releaseDate;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Type of the Browscap data (read from INI file)
|
69 |
+
*
|
70 |
+
* @var string
|
71 |
+
*/
|
72 |
+
private $type;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Constructor class, checks for the existence of (and loads) the cache and
|
76 |
+
* if needed updated the definitions
|
77 |
+
*
|
78 |
+
* @param \WurflCache\Adapter\AdapterInterface $adapter
|
79 |
+
*/
|
80 |
+
public function __construct(AdapterInterface $adapter)
|
81 |
+
{
|
82 |
+
$this->cache = $adapter;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Gets the version of the Browscap data
|
87 |
+
*
|
88 |
+
* @return int
|
89 |
+
*/
|
90 |
+
public function getVersion()
|
91 |
+
{
|
92 |
+
if ($this->version === null) {
|
93 |
+
$success = true;
|
94 |
+
|
95 |
+
$version = $this->getItem('browscap.version', false, $success);
|
96 |
+
|
97 |
+
if ($version !== null && $success) {
|
98 |
+
$this->version = (int) $version;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return $this->version;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Gets the release date of the Browscap data
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
public function getReleaseDate()
|
111 |
+
{
|
112 |
+
if ($this->releaseDate === null) {
|
113 |
+
$success = true;
|
114 |
+
|
115 |
+
$releaseDate = $this->getItem('browscap.releaseDate', false, $success);
|
116 |
+
|
117 |
+
if ($releaseDate !== null && $success) {
|
118 |
+
$this->releaseDate = $releaseDate;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
return $this->releaseDate;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Gets the type of the Browscap data
|
127 |
+
*
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
public function getType()
|
131 |
+
{
|
132 |
+
if ($this->type === null) {
|
133 |
+
$success = true;
|
134 |
+
|
135 |
+
$type = $this->getItem('browscap.type', false, $success);
|
136 |
+
|
137 |
+
if ($type !== null && $success) {
|
138 |
+
$this->type = $type;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
return $this->type;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Get an item.
|
147 |
+
*
|
148 |
+
* @param string $cacheId
|
149 |
+
* @param bool $withVersion
|
150 |
+
* @param bool $success
|
151 |
+
*
|
152 |
+
* @return mixed Data on success, null on failure
|
153 |
+
*/
|
154 |
+
public function getItem($cacheId, $withVersion = true, & $success = null)
|
155 |
+
{
|
156 |
+
if ($withVersion) {
|
157 |
+
$cacheId .= '.' . $this->getVersion();
|
158 |
+
}
|
159 |
+
|
160 |
+
if (!$this->cache->hasItem($cacheId)) {
|
161 |
+
$success = false;
|
162 |
+
|
163 |
+
return null;
|
164 |
+
}
|
165 |
+
|
166 |
+
$success = null;
|
167 |
+
$data = $this->cache->getItem($cacheId, $success);
|
168 |
+
|
169 |
+
if (!$success) {
|
170 |
+
$success = false;
|
171 |
+
|
172 |
+
return null;
|
173 |
+
}
|
174 |
+
|
175 |
+
if (!isset($data['content'])) {
|
176 |
+
$success = false;
|
177 |
+
|
178 |
+
return null;
|
179 |
+
}
|
180 |
+
|
181 |
+
$success = true;
|
182 |
+
|
183 |
+
return unserialize($data['content']);
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* save the content into an php file
|
188 |
+
*
|
189 |
+
* @param string $cacheId The cache id
|
190 |
+
* @param mixed $content The content to store
|
191 |
+
* @param bool $withVersion
|
192 |
+
*
|
193 |
+
* @return bool whether the file was correctly written to the disk
|
194 |
+
*/
|
195 |
+
public function setItem($cacheId, $content, $withVersion = true)
|
196 |
+
{
|
197 |
+
// Get the whole PHP code
|
198 |
+
$data = [
|
199 |
+
'content' => serialize($content),
|
200 |
+
];
|
201 |
+
|
202 |
+
if ($withVersion) {
|
203 |
+
$cacheId .= '.' . $this->getVersion();
|
204 |
+
}
|
205 |
+
|
206 |
+
// Save and return
|
207 |
+
return $this->cache->setItem($cacheId, $data);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Test if an item exists.
|
212 |
+
*
|
213 |
+
* @param string $cacheId
|
214 |
+
* @param bool $withVersion
|
215 |
+
*
|
216 |
+
* @return bool
|
217 |
+
*/
|
218 |
+
public function hasItem($cacheId, $withVersion = true)
|
219 |
+
{
|
220 |
+
if ($withVersion) {
|
221 |
+
$cacheId .= '.' . $this->getVersion();
|
222 |
+
}
|
223 |
+
|
224 |
+
return $this->cache->hasItem($cacheId);
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Remove an item.
|
229 |
+
*
|
230 |
+
* @param string $cacheId
|
231 |
+
* @param bool $withVersion
|
232 |
+
*
|
233 |
+
* @return bool
|
234 |
+
*/
|
235 |
+
public function removeItem($cacheId, $withVersion = true)
|
236 |
+
{
|
237 |
+
if ($withVersion) {
|
238 |
+
$cacheId .= '.' . $this->getVersion();
|
239 |
+
}
|
240 |
+
|
241 |
+
return $this->cache->removeItem($cacheId);
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Flush the whole storage
|
246 |
+
*
|
247 |
+
* @return bool
|
248 |
+
*/
|
249 |
+
public function flush()
|
250 |
+
{
|
251 |
+
return $this->cache->flush();
|
252 |
+
}
|
253 |
+
}
|
includes/vendor/browscap/browscap-php/src/Cache/BrowscapCacheInterface.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Cache;
|
31 |
+
|
32 |
+
use WurflCache\Adapter\AdapterInterface;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* a cache proxy to be able to use the cache adapters provided by the WurflCache package
|
36 |
+
*
|
37 |
+
* @category Browscap-PHP
|
38 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
39 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
40 |
+
* @version 3.0
|
41 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
42 |
+
* @link https://github.com/browscap/browscap-php/
|
43 |
+
*/
|
44 |
+
interface BrowscapCacheInterface
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* The cache livetime in seconds.
|
48 |
+
*
|
49 |
+
* @var int
|
50 |
+
*/
|
51 |
+
const CACHE_LIVETIME = 315360000; // ~10 years (60 * 60 * 24 * 365 * 10)
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Constructor class, checks for the existence of (and loads) the cache and
|
55 |
+
* if needed updated the definitions
|
56 |
+
*
|
57 |
+
* @param \WurflCache\Adapter\AdapterInterface $adapter
|
58 |
+
*/
|
59 |
+
public function __construct(AdapterInterface $adapter);
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Gets the version of the Browscap data
|
63 |
+
*
|
64 |
+
* @return int
|
65 |
+
*/
|
66 |
+
public function getVersion();
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Gets the release date of the Browscap data
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getReleaseDate();
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Gets the type of the Browscap data
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getType();
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get an item.
|
84 |
+
*
|
85 |
+
* @param string $cacheId
|
86 |
+
* @param bool $withVersion
|
87 |
+
* @param bool $success
|
88 |
+
*
|
89 |
+
* @return mixed Data on success, null on failure
|
90 |
+
*/
|
91 |
+
public function getItem($cacheId, $withVersion = true, & $success = null);
|
92 |
+
|
93 |
+
/**
|
94 |
+
* save the content into an php file
|
95 |
+
*
|
96 |
+
* @param string $cacheId The cache id
|
97 |
+
* @param mixed $content The content to store
|
98 |
+
* @param bool $withVersion
|
99 |
+
*
|
100 |
+
* @return bool whether the file was correctly written to the disk
|
101 |
+
*/
|
102 |
+
public function setItem($cacheId, $content, $withVersion = true);
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Test if an item exists.
|
106 |
+
*
|
107 |
+
* @param string $cacheId
|
108 |
+
* @param bool $withVersion
|
109 |
+
*
|
110 |
+
* @return bool
|
111 |
+
*/
|
112 |
+
public function hasItem($cacheId, $withVersion = true);
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Remove an item.
|
116 |
+
*
|
117 |
+
* @param string $cacheId
|
118 |
+
* @param bool $withVersion
|
119 |
+
*
|
120 |
+
* @return bool
|
121 |
+
*/
|
122 |
+
public function removeItem($cacheId, $withVersion = true);
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Flush the whole storage
|
126 |
+
*
|
127 |
+
* @return bool
|
128 |
+
*/
|
129 |
+
public function flush();
|
130 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/CheckUpdateCommand.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\BrowscapUpdater;
|
33 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
34 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
35 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
36 |
+
use Symfony\Component\Console\Command\Command;
|
37 |
+
use Symfony\Component\Console\Input\InputInterface;
|
38 |
+
use Symfony\Component\Console\Input\InputOption;
|
39 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
40 |
+
use WurflCache\Adapter\File;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* command to fetch a browscap ini file from the remote host, convert it into an array and store the content in a local
|
44 |
+
* file
|
45 |
+
*
|
46 |
+
* @category Browscap-PHP
|
47 |
+
* @author Dave Olsen, http://dmolsen.com
|
48 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
49 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
50 |
+
* @version 3.0
|
51 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
52 |
+
* @link https://github.com/browscap/browscap-php/
|
53 |
+
*/
|
54 |
+
class CheckUpdateCommand extends Command
|
55 |
+
{
|
56 |
+
/**
|
57 |
+
* @var BrowscapCacheInterface
|
58 |
+
*/
|
59 |
+
private $cache = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
private $defaultCacheFolder;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param string $defaultCacheFolder
|
68 |
+
*/
|
69 |
+
public function __construct($defaultCacheFolder)
|
70 |
+
{
|
71 |
+
$this->defaultCacheFolder = $defaultCacheFolder;
|
72 |
+
|
73 |
+
parent::__construct();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface $cache
|
78 |
+
*
|
79 |
+
* @return $this
|
80 |
+
*/
|
81 |
+
public function setCache(BrowscapCacheInterface $cache)
|
82 |
+
{
|
83 |
+
$this->cache = $cache;
|
84 |
+
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Configures the current command.
|
90 |
+
*/
|
91 |
+
protected function configure()
|
92 |
+
{
|
93 |
+
$this
|
94 |
+
->setName('browscap:check-update')
|
95 |
+
->setDescription('Checks if an updated INI file is available.')
|
96 |
+
->addOption(
|
97 |
+
'debug',
|
98 |
+
'd',
|
99 |
+
InputOption::VALUE_NONE,
|
100 |
+
'Should the debug mode entered?'
|
101 |
+
)
|
102 |
+
->addOption(
|
103 |
+
'cache',
|
104 |
+
'c',
|
105 |
+
InputOption::VALUE_OPTIONAL,
|
106 |
+
'Where the cache files are located',
|
107 |
+
$this->defaultCacheFolder
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @param InputInterface $input
|
113 |
+
* @param OutputInterface $output
|
114 |
+
*
|
115 |
+
* @return int|null|void
|
116 |
+
*/
|
117 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
118 |
+
{
|
119 |
+
$loggerHelper = new LoggerHelper();
|
120 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
121 |
+
|
122 |
+
$logger->debug('started checking for new version of remote file');
|
123 |
+
|
124 |
+
$browscap = new BrowscapUpdater();
|
125 |
+
|
126 |
+
$browscap->setLogger($logger);
|
127 |
+
$browscap->setCache($this->getCache($input));
|
128 |
+
$browscap->checkUpdate();
|
129 |
+
|
130 |
+
$logger->debug('finished checking for new version of remote file');
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param InputInterface $input
|
135 |
+
*
|
136 |
+
* @return BrowscapCacheInterface
|
137 |
+
*/
|
138 |
+
private function getCache(InputInterface $input)
|
139 |
+
{
|
140 |
+
if (null === $this->cache) {
|
141 |
+
$cacheAdapter = new File([File::DIR => $input->getOption('cache')]);
|
142 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
143 |
+
}
|
144 |
+
|
145 |
+
return $this->cache;
|
146 |
+
}
|
147 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/ConvertCommand.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\BrowscapUpdater;
|
33 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
34 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
35 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
36 |
+
use Symfony\Component\Console\Command\Command;
|
37 |
+
use Symfony\Component\Console\Input\InputArgument;
|
38 |
+
use Symfony\Component\Console\Input\InputInterface;
|
39 |
+
use Symfony\Component\Console\Input\InputOption;
|
40 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
41 |
+
use WurflCache\Adapter\File;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* command to convert a downloaded Browscap ini file and write it to the cache
|
45 |
+
*
|
46 |
+
* @category Browscap-PHP
|
47 |
+
* @author Dave Olsen, http://dmolsen.com
|
48 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
49 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
50 |
+
* @version 3.0
|
51 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
52 |
+
* @link https://github.com/browscap/browscap-php/
|
53 |
+
*/
|
54 |
+
class ConvertCommand extends Command
|
55 |
+
{
|
56 |
+
/**
|
57 |
+
* @var BrowscapCacheInterface
|
58 |
+
*/
|
59 |
+
private $cache = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
private $defaultIniFile;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @var string
|
68 |
+
*/
|
69 |
+
private $defaultCacheFolder;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @param string $defaultCacheFolder
|
73 |
+
* @param string $defaultIniFile
|
74 |
+
*/
|
75 |
+
public function __construct($defaultCacheFolder, $defaultIniFile)
|
76 |
+
{
|
77 |
+
$this->defaultCacheFolder = $defaultCacheFolder;
|
78 |
+
$this->defaultIniFile = $defaultIniFile;
|
79 |
+
|
80 |
+
parent::__construct();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface $cache
|
85 |
+
*
|
86 |
+
* @return $this
|
87 |
+
*/
|
88 |
+
public function setCache(BrowscapCacheInterface $cache)
|
89 |
+
{
|
90 |
+
$this->cache = $cache;
|
91 |
+
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Configures the current command.
|
97 |
+
*/
|
98 |
+
protected function configure()
|
99 |
+
{
|
100 |
+
$this
|
101 |
+
->setName('browscap:convert')
|
102 |
+
->setDescription('Converts an existing browscap.ini file to a cache.php file.')
|
103 |
+
->addArgument(
|
104 |
+
'file',
|
105 |
+
InputArgument::OPTIONAL,
|
106 |
+
'Path to the browscap.ini file',
|
107 |
+
$this->defaultIniFile
|
108 |
+
)
|
109 |
+
->addOption(
|
110 |
+
'debug',
|
111 |
+
'd',
|
112 |
+
InputOption::VALUE_NONE,
|
113 |
+
'Should the debug mode entered?'
|
114 |
+
)
|
115 |
+
->addOption(
|
116 |
+
'cache',
|
117 |
+
'c',
|
118 |
+
InputOption::VALUE_OPTIONAL,
|
119 |
+
'Where the cache files are located',
|
120 |
+
$this->defaultCacheFolder
|
121 |
+
);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param InputInterface $input
|
126 |
+
* @param OutputInterface $output
|
127 |
+
*
|
128 |
+
* @return int|null|void
|
129 |
+
*/
|
130 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
131 |
+
{
|
132 |
+
$loggerHelper = new LoggerHelper();
|
133 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
134 |
+
|
135 |
+
$logger->info('initializing converting process');
|
136 |
+
|
137 |
+
$browscap = new BrowscapUpdater();
|
138 |
+
|
139 |
+
$browscap->setLogger($logger);
|
140 |
+
$browscap->setCache($this->getCache($input));
|
141 |
+
|
142 |
+
$logger->info('started converting local file');
|
143 |
+
|
144 |
+
$file = ($input->getArgument('file') ? $input->getArgument('file') : ($this->defaultIniFile));
|
145 |
+
|
146 |
+
$browscap->convertFile($file);
|
147 |
+
|
148 |
+
$logger->info('finished converting local file');
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* @param InputInterface $input
|
153 |
+
*
|
154 |
+
* @return BrowscapCacheInterface
|
155 |
+
*/
|
156 |
+
private function getCache(InputInterface $input)
|
157 |
+
{
|
158 |
+
if (null === $this->cache) {
|
159 |
+
$cacheAdapter = new File([File::DIR => $input->getOption('cache')]);
|
160 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
161 |
+
}
|
162 |
+
|
163 |
+
return $this->cache;
|
164 |
+
}
|
165 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/FetchCommand.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\BrowscapUpdater;
|
33 |
+
use BrowscapPHP\Helper\IniLoader;
|
34 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
35 |
+
use Symfony\Component\Console\Command\Command;
|
36 |
+
use Symfony\Component\Console\Input\InputArgument;
|
37 |
+
use Symfony\Component\Console\Input\InputInterface;
|
38 |
+
use Symfony\Component\Console\Input\InputOption;
|
39 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* command to fetch a browscap ini file from the remote host and store the content in a local file
|
43 |
+
*
|
44 |
+
* @category Browscap-PHP
|
45 |
+
* @author Dave Olsen, http://dmolsen.com
|
46 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
47 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
48 |
+
* @version 3.0
|
49 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
50 |
+
* @link https://github.com/browscap/browscap-php/
|
51 |
+
*/
|
52 |
+
class FetchCommand extends Command
|
53 |
+
{
|
54 |
+
/**
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
private $defaultIniFile;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param string $defaultIniFile
|
61 |
+
*/
|
62 |
+
public function __construct($defaultIniFile)
|
63 |
+
{
|
64 |
+
$this->defaultIniFile = $defaultIniFile;
|
65 |
+
|
66 |
+
parent::__construct();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Configures the current command.
|
71 |
+
*/
|
72 |
+
protected function configure()
|
73 |
+
{
|
74 |
+
$this
|
75 |
+
->setName('browscap:fetch')
|
76 |
+
->setDescription('Fetches an updated INI file for Browscap.')
|
77 |
+
->addArgument(
|
78 |
+
'file',
|
79 |
+
InputArgument::OPTIONAL,
|
80 |
+
'browscap.ini file',
|
81 |
+
$this->defaultIniFile
|
82 |
+
)
|
83 |
+
->addOption(
|
84 |
+
'remote-file',
|
85 |
+
'r',
|
86 |
+
InputOption::VALUE_OPTIONAL,
|
87 |
+
'browscap.ini file to download from remote location (possible values are: ' . IniLoader::PHP_INI_LITE
|
88 |
+
. ', ' . IniLoader::PHP_INI . ', ' . IniLoader::PHP_INI_FULL . ')',
|
89 |
+
IniLoader::PHP_INI
|
90 |
+
)
|
91 |
+
->addOption(
|
92 |
+
'debug',
|
93 |
+
'd',
|
94 |
+
InputOption::VALUE_NONE,
|
95 |
+
'Should the debug mode entered?'
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @param InputInterface $input
|
101 |
+
* @param OutputInterface $output
|
102 |
+
*
|
103 |
+
* @return int|null|void
|
104 |
+
*/
|
105 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
106 |
+
{
|
107 |
+
$loggerHelper = new LoggerHelper();
|
108 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
109 |
+
|
110 |
+
$file = $input->getArgument('file');
|
111 |
+
if (!$file) {
|
112 |
+
$file = $this->defaultIniFile;
|
113 |
+
}
|
114 |
+
|
115 |
+
$logger->info('started fetching remote file');
|
116 |
+
|
117 |
+
$browscap = new BrowscapUpdater();
|
118 |
+
|
119 |
+
$browscap->setLogger($logger);
|
120 |
+
$browscap->fetch($file, $input->getOption('remote-file'));
|
121 |
+
|
122 |
+
$logger->info('finished fetching remote file');
|
123 |
+
}
|
124 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/LogfileCommand.php
ADDED
@@ -0,0 +1,527 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\Browscap;
|
33 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
34 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
35 |
+
use BrowscapPHP\Exception\InvalidArgumentException;
|
36 |
+
use BrowscapPHP\Exception\ReaderException;
|
37 |
+
use BrowscapPHP\Exception\UnknownBrowserException;
|
38 |
+
use BrowscapPHP\Exception\UnknownBrowserTypeException;
|
39 |
+
use BrowscapPHP\Exception\UnknownDeviceException;
|
40 |
+
use BrowscapPHP\Exception\UnknownEngineException;
|
41 |
+
use BrowscapPHP\Exception\UnknownPlatformException;
|
42 |
+
use BrowscapPHP\Helper\Filesystem;
|
43 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
44 |
+
use BrowscapPHP\Util\Logfile\ReaderCollection;
|
45 |
+
use BrowscapPHP\Util\Logfile\ReaderFactory;
|
46 |
+
use Symfony\Component\Console\Command\Command;
|
47 |
+
use Symfony\Component\Console\Input\InputArgument;
|
48 |
+
use Symfony\Component\Console\Input\InputInterface;
|
49 |
+
use Symfony\Component\Console\Input\InputOption;
|
50 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
51 |
+
use Symfony\Component\Filesystem\Exception\IOException;
|
52 |
+
use Symfony\Component\Finder\Finder;
|
53 |
+
use Symfony\Component\Finder\SplFileInfo;
|
54 |
+
use WurflCache\Adapter\File;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* commands to parse a log file and parse the useragents in it
|
58 |
+
*
|
59 |
+
* @category Browscap-PHP
|
60 |
+
* @author Dave Olsen, http://dmolsen.com
|
61 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
62 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
63 |
+
* @version 3.0
|
64 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
65 |
+
* @link https://github.com/browscap/browscap-php/
|
66 |
+
*/
|
67 |
+
class LogfileCommand extends Command
|
68 |
+
{
|
69 |
+
/**
|
70 |
+
* @var array
|
71 |
+
*/
|
72 |
+
private $undefinedClients = [];
|
73 |
+
|
74 |
+
private $uas = [];
|
75 |
+
private $uasWithType = [];
|
76 |
+
|
77 |
+
private $countOk = 0;
|
78 |
+
private $countNok = 0;
|
79 |
+
private $totalCount = 0;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var BrowscapCacheInterface
|
83 |
+
*/
|
84 |
+
private $cache = null;
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @var string
|
88 |
+
*/
|
89 |
+
private $defaultCacheFolder;
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @param string $defaultCacheFolder
|
93 |
+
*/
|
94 |
+
public function __construct($defaultCacheFolder)
|
95 |
+
{
|
96 |
+
$this->defaultCacheFolder = $defaultCacheFolder;
|
97 |
+
|
98 |
+
parent::__construct();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface $cache
|
103 |
+
*
|
104 |
+
* @return $this
|
105 |
+
*/
|
106 |
+
public function setCache(BrowscapCacheInterface $cache)
|
107 |
+
{
|
108 |
+
$this->cache = $cache;
|
109 |
+
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Configures the current command.
|
115 |
+
*/
|
116 |
+
protected function configure()
|
117 |
+
{
|
118 |
+
$this
|
119 |
+
->setName('browscap:log')
|
120 |
+
->setDescription('Parses the supplied webserver log file.')
|
121 |
+
->addArgument(
|
122 |
+
'output',
|
123 |
+
InputArgument::REQUIRED,
|
124 |
+
'Path to output log file',
|
125 |
+
null
|
126 |
+
)
|
127 |
+
->addOption(
|
128 |
+
'log-file',
|
129 |
+
'f',
|
130 |
+
InputOption::VALUE_REQUIRED,
|
131 |
+
'Path to a webserver log file'
|
132 |
+
)
|
133 |
+
->addOption(
|
134 |
+
'log-dir',
|
135 |
+
'd',
|
136 |
+
InputOption::VALUE_REQUIRED,
|
137 |
+
'Path to webserver log directory'
|
138 |
+
)
|
139 |
+
->addOption(
|
140 |
+
'include',
|
141 |
+
'i',
|
142 |
+
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
|
143 |
+
'Include glob expressions for log files in the log directory',
|
144 |
+
['*.log', '*.log*.gz', '*.log*.bz2']
|
145 |
+
)
|
146 |
+
->addOption(
|
147 |
+
'exclude',
|
148 |
+
'e',
|
149 |
+
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
|
150 |
+
'Exclude glob expressions for log files in the log directory',
|
151 |
+
['*error*']
|
152 |
+
)
|
153 |
+
->addOption(
|
154 |
+
'debug',
|
155 |
+
null,
|
156 |
+
InputOption::VALUE_NONE,
|
157 |
+
'Should the debug mode entered?'
|
158 |
+
)
|
159 |
+
->addOption(
|
160 |
+
'cache',
|
161 |
+
'c',
|
162 |
+
InputOption::VALUE_OPTIONAL,
|
163 |
+
'Where the cache files are located',
|
164 |
+
$this->defaultCacheFolder
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @param InputInterface $input
|
170 |
+
* @param OutputInterface $output
|
171 |
+
*
|
172 |
+
* @throws \UnexpectedValueException
|
173 |
+
* @throws \BrowscapPHP\Exception\InvalidArgumentException
|
174 |
+
* @return int|null|void
|
175 |
+
*/
|
176 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
177 |
+
{
|
178 |
+
if (!$input->getOption('log-file') && !$input->getOption('log-dir')) {
|
179 |
+
throw InvalidArgumentException::oneOfCommandArguments('log-file', 'log-dir');
|
180 |
+
}
|
181 |
+
|
182 |
+
$loggerHelper = new LoggerHelper();
|
183 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
184 |
+
|
185 |
+
$browscap = new Browscap();
|
186 |
+
$collection = ReaderFactory::factory();
|
187 |
+
$fs = new Filesystem();
|
188 |
+
|
189 |
+
$browscap
|
190 |
+
->setLogger($logger)
|
191 |
+
->setCache($this->getCache($input));
|
192 |
+
|
193 |
+
/** @var $file \Symfony\Component\Finder\SplFileInfo */
|
194 |
+
foreach ($this->getFiles($input) as $file) {
|
195 |
+
$this->uas = [];
|
196 |
+
$path = $this->getPath($file);
|
197 |
+
|
198 |
+
$this->countOk = 0;
|
199 |
+
$this->countNok = 0;
|
200 |
+
|
201 |
+
$logger->info('Analyzing file "' . $file->getPathname() . '"');
|
202 |
+
|
203 |
+
$lines = file($path);
|
204 |
+
|
205 |
+
if (empty($lines)) {
|
206 |
+
$logger->info('Skipping empty file "' . $file->getPathname() . '"');
|
207 |
+
continue;
|
208 |
+
}
|
209 |
+
|
210 |
+
$this->totalCount = count($lines);
|
211 |
+
|
212 |
+
foreach ($lines as $line) {
|
213 |
+
$this->handleLine(
|
214 |
+
$output,
|
215 |
+
$collection,
|
216 |
+
$browscap,
|
217 |
+
$line
|
218 |
+
);
|
219 |
+
}
|
220 |
+
|
221 |
+
$this->outputProgress($output, '', true);
|
222 |
+
|
223 |
+
arsort($this->uas, SORT_NUMERIC);
|
224 |
+
|
225 |
+
try {
|
226 |
+
$fs->dumpFile(
|
227 |
+
$input->getArgument('output') . '/output.txt',
|
228 |
+
implode(PHP_EOL, array_unique($this->undefinedClients))
|
229 |
+
);
|
230 |
+
} catch (IOException $e) {
|
231 |
+
// do nothing
|
232 |
+
}
|
233 |
+
|
234 |
+
try {
|
235 |
+
$fs->dumpFile(
|
236 |
+
$input->getArgument('output') . '/output-with-amount.txt',
|
237 |
+
$this->createAmountContent()
|
238 |
+
);
|
239 |
+
} catch (IOException $e) {
|
240 |
+
// do nothing
|
241 |
+
}
|
242 |
+
|
243 |
+
try {
|
244 |
+
$fs->dumpFile(
|
245 |
+
$input->getArgument('output') . '/output-with-amount-and-type.txt',
|
246 |
+
$this->createAmountTypeContent()
|
247 |
+
);
|
248 |
+
} catch (IOException $e) {
|
249 |
+
// do nothing
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
$outputFile = $input->getArgument('output') . '/output.txt';
|
254 |
+
|
255 |
+
try {
|
256 |
+
$fs->dumpFile(
|
257 |
+
$outputFile,
|
258 |
+
implode(PHP_EOL, array_unique($this->undefinedClients))
|
259 |
+
);
|
260 |
+
} catch (IOException $e) {
|
261 |
+
throw new \UnexpectedValueException('writing to file "' . $outputFile . '" failed', 0, $e);
|
262 |
+
}
|
263 |
+
|
264 |
+
try {
|
265 |
+
$fs->dumpFile(
|
266 |
+
$input->getArgument('output') . '/output-with-amount.txt',
|
267 |
+
$this->createAmountContent()
|
268 |
+
);
|
269 |
+
} catch (IOException $e) {
|
270 |
+
// do nothing
|
271 |
+
}
|
272 |
+
|
273 |
+
try {
|
274 |
+
$fs->dumpFile(
|
275 |
+
$input->getArgument('output') . '/output-with-amount-and-type.txt',
|
276 |
+
$this->createAmountTypeContent()
|
277 |
+
);
|
278 |
+
} catch (IOException $e) {
|
279 |
+
// do nothing
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
private function createAmountContent()
|
284 |
+
{
|
285 |
+
$counts = [];
|
286 |
+
|
287 |
+
foreach ($this->uasWithType as $uas) {
|
288 |
+
foreach ($uas as $userAgentString => $count) {
|
289 |
+
if (isset($counts[$userAgentString])) {
|
290 |
+
$counts[$userAgentString] += $count;
|
291 |
+
} else {
|
292 |
+
$counts[$userAgentString] = $count;
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
$content = '';
|
298 |
+
|
299 |
+
arsort($counts, SORT_NUMERIC);
|
300 |
+
|
301 |
+
foreach ($counts as $agentOfLine => $count) {
|
302 |
+
$content .= "$count\t$agentOfLine\n";
|
303 |
+
}
|
304 |
+
|
305 |
+
return $content;
|
306 |
+
}
|
307 |
+
|
308 |
+
private function createAmountTypeContent()
|
309 |
+
{
|
310 |
+
$content = '';
|
311 |
+
$types = ['B', 'T', 'P', 'D', 'N', 'U'];
|
312 |
+
|
313 |
+
foreach ($types as $type) {
|
314 |
+
if (!isset($this->uasWithType[$type])) {
|
315 |
+
continue;
|
316 |
+
}
|
317 |
+
|
318 |
+
arsort($this->uasWithType[$type], SORT_NUMERIC);
|
319 |
+
|
320 |
+
foreach ($this->uasWithType[$type] as $agentOfLine => $count) {
|
321 |
+
$content .= "$type\t$count\t$agentOfLine\n";
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
return $content;
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* @param \Symfony\Component\Console\Output\OutputInterface $output
|
330 |
+
* @param \BrowscapPHP\Util\Logfile\ReaderCollection $collection
|
331 |
+
* @param \BrowscapPHP\Browscap $browscap
|
332 |
+
* @param int $line
|
333 |
+
*
|
334 |
+
* @throws UnknownBrowserException
|
335 |
+
* @throws UnknownBrowserTypeException
|
336 |
+
* @throws UnknownDeviceException
|
337 |
+
* @throws UnknownEngineException
|
338 |
+
* @throws UnknownPlatformException
|
339 |
+
* @throws \Exception
|
340 |
+
*/
|
341 |
+
private function handleLine(OutputInterface $output, ReaderCollection $collection, Browscap $browscap, $line)
|
342 |
+
{
|
343 |
+
$userAgentString = '';
|
344 |
+
|
345 |
+
try {
|
346 |
+
$userAgentString = $collection->read($line);
|
347 |
+
|
348 |
+
try {
|
349 |
+
$this->getResult($browscap->getBrowser($userAgentString));
|
350 |
+
} catch (\Exception $e) {
|
351 |
+
$this->undefinedClients[] = $userAgentString;
|
352 |
+
|
353 |
+
throw $e;
|
354 |
+
}
|
355 |
+
|
356 |
+
$type = '.';
|
357 |
+
++$this->countOk;
|
358 |
+
} catch (ReaderException $e) {
|
359 |
+
$type = 'E';
|
360 |
+
++$this->countNok;
|
361 |
+
} catch (UnknownBrowserTypeException $e) {
|
362 |
+
$type = 'T';
|
363 |
+
++$this->countNok;
|
364 |
+
} catch (UnknownBrowserException $e) {
|
365 |
+
$type = 'B';
|
366 |
+
++$this->countNok;
|
367 |
+
} catch (UnknownPlatformException $e) {
|
368 |
+
$type = 'P';
|
369 |
+
++$this->countNok;
|
370 |
+
} catch (UnknownDeviceException $e) {
|
371 |
+
$type = 'D';
|
372 |
+
++$this->countNok;
|
373 |
+
} catch (UnknownEngineException $e) {
|
374 |
+
$type = 'N';
|
375 |
+
++$this->countNok;
|
376 |
+
} catch (\Exception $e) {
|
377 |
+
$type = 'U';
|
378 |
+
++$this->countNok;
|
379 |
+
}
|
380 |
+
|
381 |
+
$this->outputProgress($output, $type);
|
382 |
+
|
383 |
+
// count all useragents
|
384 |
+
if (isset($this->uas[$userAgentString])) {
|
385 |
+
++$this->uas[$userAgentString];
|
386 |
+
} else {
|
387 |
+
$this->uas[$userAgentString] = 1;
|
388 |
+
}
|
389 |
+
|
390 |
+
if ('.' !== $type && 'E' !== $type) {
|
391 |
+
// count all undetected useragents grouped by detection error
|
392 |
+
if (!isset($this->uasWithType[$type])) {
|
393 |
+
$this->uasWithType[$type] = [];
|
394 |
+
}
|
395 |
+
|
396 |
+
if (isset($this->uasWithType[$type][$userAgentString])) {
|
397 |
+
++$this->uasWithType[$type][$userAgentString];
|
398 |
+
} else {
|
399 |
+
$this->uasWithType[$type][$userAgentString] = 1;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* @param \Symfony\Component\Console\Output\OutputInterface $output
|
406 |
+
* @param string $result
|
407 |
+
* @param bool $end
|
408 |
+
*
|
409 |
+
* @return int
|
410 |
+
*/
|
411 |
+
private function outputProgress(OutputInterface $output, $result, $end = false)
|
412 |
+
{
|
413 |
+
if (($this->totalCount % 70) === 0 || $end) {
|
414 |
+
$formatString = ' %' . strlen($this->countOk) . 'd OK, %' . strlen($this->countNok) . 'd NOK, Summary %'
|
415 |
+
. strlen($this->totalCount) . 'd';
|
416 |
+
|
417 |
+
if ($end) {
|
418 |
+
$result = str_pad($result, 70 - ($this->totalCount % 70), ' ', STR_PAD_RIGHT);
|
419 |
+
}
|
420 |
+
|
421 |
+
$endString = sprintf($formatString, $this->countOk, $this->countNok, $this->totalCount);
|
422 |
+
|
423 |
+
$output->writeln($result . $endString);
|
424 |
+
|
425 |
+
return;
|
426 |
+
}
|
427 |
+
|
428 |
+
$output->write($result);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* @param \stdClass $result
|
433 |
+
*
|
434 |
+
* @return string
|
435 |
+
*/
|
436 |
+
private function getResult(\stdClass $result)
|
437 |
+
{
|
438 |
+
if ('Default Browser' === $result->browser) {
|
439 |
+
throw new UnknownBrowserException('unknwon browser found');
|
440 |
+
}
|
441 |
+
|
442 |
+
if ('unknown' === $result->browser_type) {
|
443 |
+
throw new UnknownBrowserTypeException('unknwon browser type found');
|
444 |
+
}
|
445 |
+
|
446 |
+
if (in_array($result->browser_type, ['Bot/Crawler', 'Library'])) {
|
447 |
+
return '.';
|
448 |
+
}
|
449 |
+
|
450 |
+
if ('unknown' === $result->platform) {
|
451 |
+
throw new UnknownPlatformException('unknown platform found');
|
452 |
+
}
|
453 |
+
|
454 |
+
if ('unknown' === $result->device_type) {
|
455 |
+
throw new UnknownDeviceException('unknwon device type found');
|
456 |
+
}
|
457 |
+
|
458 |
+
if ('unknown' === $result->renderingengine_name) {
|
459 |
+
throw new UnknownEngineException('unknown rendering engine found');
|
460 |
+
}
|
461 |
+
|
462 |
+
return '.';
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* @param \Symfony\Component\Console\Input\InputInterface $input
|
467 |
+
*
|
468 |
+
* @return \Symfony\Component\Finder\Finder
|
469 |
+
*/
|
470 |
+
private function getFiles(InputInterface $input)
|
471 |
+
{
|
472 |
+
$finder = Finder::create();
|
473 |
+
|
474 |
+
if ($input->getOption('log-file')) {
|
475 |
+
$file = $input->getOption('log-file');
|
476 |
+
$finder->append(Finder::create()->in(dirname($file))->name(basename($file)));
|
477 |
+
}
|
478 |
+
|
479 |
+
if ($input->getOption('log-dir')) {
|
480 |
+
$dirFinder = Finder::create()
|
481 |
+
->in($input->getOption('log-dir'));
|
482 |
+
array_map([$dirFinder, 'name'], $input->getOption('include'));
|
483 |
+
array_map([$dirFinder, 'notName'], $input->getOption('exclude'));
|
484 |
+
|
485 |
+
$finder->append($dirFinder);
|
486 |
+
}
|
487 |
+
|
488 |
+
return $finder;
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* @param \Symfony\Component\Finder\SplFileInfo $file
|
493 |
+
*
|
494 |
+
* @return string
|
495 |
+
*/
|
496 |
+
private function getPath(SplFileInfo $file)
|
497 |
+
{
|
498 |
+
switch ($file->getExtension()) {
|
499 |
+
case 'gz':
|
500 |
+
$path = 'compress.zlib://' . $file->getPathname();
|
501 |
+
break;
|
502 |
+
case 'bz2':
|
503 |
+
$path = 'compress.bzip2://' . $file->getPathname();
|
504 |
+
break;
|
505 |
+
default:
|
506 |
+
$path = $file->getPathname();
|
507 |
+
break;
|
508 |
+
}
|
509 |
+
|
510 |
+
return $path;
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* @param InputInterface $input
|
515 |
+
*
|
516 |
+
* @return BrowscapCacheInterface
|
517 |
+
*/
|
518 |
+
private function getCache(InputInterface $input)
|
519 |
+
{
|
520 |
+
if (null === $this->cache) {
|
521 |
+
$cacheAdapter = new File([File::DIR => $input->getOption('cache')]);
|
522 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
523 |
+
}
|
524 |
+
|
525 |
+
return $this->cache;
|
526 |
+
}
|
527 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/ParserCommand.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\Browscap;
|
33 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
34 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
35 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
36 |
+
use Symfony\Component\Console\Command\Command;
|
37 |
+
use Symfony\Component\Console\Input\InputArgument;
|
38 |
+
use Symfony\Component\Console\Input\InputInterface;
|
39 |
+
use Symfony\Component\Console\Input\InputOption;
|
40 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
41 |
+
use WurflCache\Adapter\File;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* commands to parse a given useragent
|
45 |
+
*
|
46 |
+
* @category Browscap-PHP
|
47 |
+
* @author Dave Olsen, http://dmolsen.com
|
48 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
49 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
50 |
+
* @version 3.0
|
51 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
52 |
+
* @link https://github.com/browscap/browscap-php/
|
53 |
+
*/
|
54 |
+
class ParserCommand extends Command
|
55 |
+
{
|
56 |
+
/**
|
57 |
+
* @var BrowscapCacheInterface
|
58 |
+
*/
|
59 |
+
private $cache = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
private $defaultCacheFolder;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param string $defaultCacheFolder
|
68 |
+
*/
|
69 |
+
public function __construct($defaultCacheFolder)
|
70 |
+
{
|
71 |
+
$this->defaultCacheFolder = $defaultCacheFolder;
|
72 |
+
|
73 |
+
parent::__construct();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface $cache
|
78 |
+
*
|
79 |
+
* @return $this
|
80 |
+
*/
|
81 |
+
public function setCache(BrowscapCacheInterface $cache)
|
82 |
+
{
|
83 |
+
$this->cache = $cache;
|
84 |
+
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Configures the current command.
|
90 |
+
*/
|
91 |
+
protected function configure()
|
92 |
+
{
|
93 |
+
$this
|
94 |
+
->setName('browscap:parse')
|
95 |
+
->setDescription('Parses a user agent string and dumps the results.')
|
96 |
+
->addArgument(
|
97 |
+
'user-agent',
|
98 |
+
InputArgument::REQUIRED,
|
99 |
+
'User agent string to analyze',
|
100 |
+
null
|
101 |
+
)
|
102 |
+
->addOption(
|
103 |
+
'debug',
|
104 |
+
'd',
|
105 |
+
InputOption::VALUE_NONE,
|
106 |
+
'Should the debug mode entered?'
|
107 |
+
)
|
108 |
+
->addOption(
|
109 |
+
'cache',
|
110 |
+
'c',
|
111 |
+
InputOption::VALUE_OPTIONAL,
|
112 |
+
'Where the cache files are located',
|
113 |
+
$this->defaultCacheFolder
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @param InputInterface $input
|
119 |
+
* @param OutputInterface $output
|
120 |
+
*
|
121 |
+
* @return int|null|void
|
122 |
+
*/
|
123 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
124 |
+
{
|
125 |
+
$loggerHelper = new LoggerHelper();
|
126 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
127 |
+
|
128 |
+
$browscap = new Browscap();
|
129 |
+
|
130 |
+
$browscap
|
131 |
+
->setLogger($logger)
|
132 |
+
->setCache($this->getCache($input));
|
133 |
+
|
134 |
+
$result = $browscap->getBrowser($input->getArgument('user-agent'));
|
135 |
+
|
136 |
+
if (!defined('JSON_PRETTY_PRINT')) {
|
137 |
+
// not defined in PHP 5.3
|
138 |
+
define('JSON_PRETTY_PRINT', 128);
|
139 |
+
}
|
140 |
+
|
141 |
+
$output->writeln(json_encode($result, JSON_PRETTY_PRINT));
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @param InputInterface $input
|
146 |
+
*
|
147 |
+
* @return BrowscapCacheInterface
|
148 |
+
*/
|
149 |
+
private function getCache(InputInterface $input)
|
150 |
+
{
|
151 |
+
if (null === $this->cache) {
|
152 |
+
$cacheAdapter = new File([File::DIR => $input->getOption('cache')]);
|
153 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
154 |
+
}
|
155 |
+
|
156 |
+
return $this->cache;
|
157 |
+
}
|
158 |
+
}
|
includes/vendor/browscap/browscap-php/src/Command/UpdateCommand.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Command;
|
31 |
+
|
32 |
+
use BrowscapPHP\BrowscapUpdater;
|
33 |
+
use BrowscapPHP\Cache\BrowscapCache;
|
34 |
+
use BrowscapPHP\Cache\BrowscapCacheInterface;
|
35 |
+
use BrowscapPHP\Helper\IniLoader;
|
36 |
+
use BrowscapPHP\Helper\LoggerHelper;
|
37 |
+
use Symfony\Component\Console\Command\Command;
|
38 |
+
use Symfony\Component\Console\Input\InputInterface;
|
39 |
+
use Symfony\Component\Console\Input\InputOption;
|
40 |
+
use Symfony\Component\Console\Output\OutputInterface;
|
41 |
+
use WurflCache\Adapter\File;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* command to fetch a browscap ini file from the remote host, convert it into an array and store the content in a local
|
45 |
+
* file
|
46 |
+
*
|
47 |
+
* @category Browscap-PHP
|
48 |
+
* @author Dave Olsen, http://dmolsen.com
|
49 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
50 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
51 |
+
* @version 3.0
|
52 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
53 |
+
* @link https://github.com/browscap/browscap-php/
|
54 |
+
*/
|
55 |
+
class UpdateCommand extends Command
|
56 |
+
{
|
57 |
+
/**
|
58 |
+
* @var BrowscapCacheInterface
|
59 |
+
*/
|
60 |
+
private $cache = null;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
private $defaultCacheFolder;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param string $defaultCacheFolder
|
69 |
+
*/
|
70 |
+
public function __construct($defaultCacheFolder)
|
71 |
+
{
|
72 |
+
$this->defaultCacheFolder = $defaultCacheFolder;
|
73 |
+
|
74 |
+
parent::__construct();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param \BrowscapPHP\Cache\BrowscapCacheInterface $cache
|
79 |
+
*
|
80 |
+
* @return $this
|
81 |
+
*/
|
82 |
+
public function setCache(BrowscapCacheInterface $cache)
|
83 |
+
{
|
84 |
+
$this->cache = $cache;
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Configures the current command.
|
91 |
+
*/
|
92 |
+
protected function configure()
|
93 |
+
{
|
94 |
+
$this
|
95 |
+
->setName('browscap:update')
|
96 |
+
->setDescription('Fetches an updated INI file for Browscap and overwrites the current PHP file.')
|
97 |
+
->addOption(
|
98 |
+
'remote-file',
|
99 |
+
'r',
|
100 |
+
InputOption::VALUE_OPTIONAL,
|
101 |
+
'browscap.ini file to download from remote location (possible values are: ' . IniLoader::PHP_INI_LITE
|
102 |
+
. ', ' . IniLoader::PHP_INI . ', ' . IniLoader::PHP_INI_FULL . ')',
|
103 |
+
IniLoader::PHP_INI
|
104 |
+
)
|
105 |
+
->addOption(
|
106 |
+
'no-backup',
|
107 |
+
null,
|
108 |
+
InputOption::VALUE_NONE,
|
109 |
+
'Do not backup the previously existing file'
|
110 |
+
)
|
111 |
+
->addOption(
|
112 |
+
'debug',
|
113 |
+
'd',
|
114 |
+
InputOption::VALUE_NONE,
|
115 |
+
'Should the debug mode entered?'
|
116 |
+
)
|
117 |
+
->addOption(
|
118 |
+
'cache',
|
119 |
+
'c',
|
120 |
+
InputOption::VALUE_OPTIONAL,
|
121 |
+
'Where the cache files are located',
|
122 |
+
$this->defaultCacheFolder
|
123 |
+
);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* @param InputInterface $input
|
128 |
+
* @param OutputInterface $output
|
129 |
+
*
|
130 |
+
* @return int|null|void
|
131 |
+
*/
|
132 |
+
protected function execute(InputInterface $input, OutputInterface $output)
|
133 |
+
{
|
134 |
+
$loggerHelper = new LoggerHelper();
|
135 |
+
$logger = $loggerHelper->create($input->getOption('debug'));
|
136 |
+
|
137 |
+
$logger->info('started updating cache with remote file');
|
138 |
+
|
139 |
+
$browscap = new BrowscapUpdater();
|
140 |
+
|
141 |
+
$browscap->setLogger($logger);
|
142 |
+
$browscap->setCache($this->getCache($input));
|
143 |
+
$browscap->update($input->getOption('remote-file'));
|
144 |
+
|
145 |
+
$logger->info('finished updating cache with remote file');
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @param InputInterface $input
|
150 |
+
*
|
151 |
+
* @return BrowscapCacheInterface
|
152 |
+
*/
|
153 |
+
private function getCache(InputInterface $input)
|
154 |
+
{
|
155 |
+
if (null === $this->cache) {
|
156 |
+
$cacheAdapter = new File([File::DIR => $input->getOption('cache')]);
|
157 |
+
$this->cache = new BrowscapCache($cacheAdapter);
|
158 |
+
}
|
159 |
+
|
160 |
+
return $this->cache;
|
161 |
+
}
|
162 |
+
}
|
includes/vendor/browscap/browscap-php/src/Data/PropertyFormatter.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Data;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Ini parser class (compatible with PHP 5.3+)
|
34 |
+
*
|
35 |
+
* @category Browscap-PHP
|
36 |
+
* @author Christoph Ziegenberg <christoph@ziegenberg.com>
|
37 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
38 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
39 |
+
* @version 3.0
|
40 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
41 |
+
* @link https://github.com/browscap/browscap-php/
|
42 |
+
*/
|
43 |
+
class PropertyFormatter
|
44 |
+
{
|
45 |
+
/**
|
46 |
+
* @var PropertyHolder
|
47 |
+
*/
|
48 |
+
private $propertyHolder = null;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* class constructor
|
52 |
+
*
|
53 |
+
* @param PropertyHolder $propertyHolder
|
54 |
+
*/
|
55 |
+
public function __construct(PropertyHolder $propertyHolder)
|
56 |
+
{
|
57 |
+
$this->propertyHolder = $propertyHolder;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* formats the name of a property
|
62 |
+
*
|
63 |
+
* @param string $value
|
64 |
+
* @param string $property
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function formatPropertyValue($value, $property)
|
69 |
+
{
|
70 |
+
$valueOutput = $value;
|
71 |
+
|
72 |
+
switch ($this->propertyHolder->getPropertyType($property)) {
|
73 |
+
case PropertyHolder::TYPE_BOOLEAN:
|
74 |
+
if (true === $value || $value === 'true' || $value === '1') {
|
75 |
+
$valueOutput = true;
|
76 |
+
} elseif (false === $value || $value === 'false' || $value === '') {
|
77 |
+
$valueOutput = false;
|
78 |
+
} else {
|
79 |
+
$valueOutput = '';
|
80 |
+
}
|
81 |
+
break;
|
82 |
+
case PropertyHolder::TYPE_IN_ARRAY:
|
83 |
+
try {
|
84 |
+
$valueOutput = $this->propertyHolder->checkValueInArray($property, $value);
|
85 |
+
} catch (\InvalidArgumentException $ex) {
|
86 |
+
$valueOutput = '';
|
87 |
+
}
|
88 |
+
break;
|
89 |
+
default:
|
90 |
+
// nothing t do here
|
91 |
+
break;
|
92 |
+
}
|
93 |
+
|
94 |
+
return $valueOutput;
|
95 |
+
}
|
96 |
+
}
|
includes/vendor/browscap/browscap-php/src/Data/PropertyHolder.php
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project.
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
*
|
25 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
26 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
27 |
+
*
|
28 |
+
* @link https://github.com/browscap/browscap-php/
|
29 |
+
* @since added with version 3.0
|
30 |
+
*/
|
31 |
+
|
32 |
+
namespace BrowscapPHP\Data;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Class PropertyHolder.
|
36 |
+
*
|
37 |
+
* @category Browscap
|
38 |
+
*
|
39 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
40 |
+
*/
|
41 |
+
class PropertyHolder
|
42 |
+
{
|
43 |
+
const TYPE_STRING = 'string';
|
44 |
+
const TYPE_GENERIC = 'generic';
|
45 |
+
const TYPE_NUMBER = 'number';
|
46 |
+
const TYPE_BOOLEAN = 'boolean';
|
47 |
+
const TYPE_IN_ARRAY = 'in_array';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get the type of a property.
|
51 |
+
*
|
52 |
+
* @param string $propertyName
|
53 |
+
*
|
54 |
+
* @throws \Exception
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function getPropertyType($propertyName)
|
59 |
+
{
|
60 |
+
$stringProperties = [
|
61 |
+
'Comment' => 1,
|
62 |
+
'Browser' => 1,
|
63 |
+
'Browser_Maker' => 1,
|
64 |
+
'Browser_Modus' => 1,
|
65 |
+
'Platform' => 1,
|
66 |
+
'Platform_Name' => 1,
|
67 |
+
'Platform_Description' => 1,
|
68 |
+
'Device_Name' => 1,
|
69 |
+
'Platform_Maker' => 1,
|
70 |
+
'Device_Code_Name' => 1,
|
71 |
+
'Device_Maker' => 1,
|
72 |
+
'Device_Brand_Name' => 1,
|
73 |
+
'RenderingEngine_Name' => 1,
|
74 |
+
'RenderingEngine_Description' => 1,
|
75 |
+
'RenderingEngine_Maker' => 1,
|
76 |
+
'Parent' => 1,
|
77 |
+
'PropertyName' => 1,
|
78 |
+
'CDF' => 1,
|
79 |
+
'PatternId' => 1,
|
80 |
+
];
|
81 |
+
|
82 |
+
if (array_key_exists($propertyName, $stringProperties)) {
|
83 |
+
return self::TYPE_STRING;
|
84 |
+
}
|
85 |
+
|
86 |
+
$arrayProperties = [
|
87 |
+
'Browser_Type' => 1,
|
88 |
+
'Device_Type' => 1,
|
89 |
+
'Device_Pointing_Method' => 1,
|
90 |
+
'Browser_Bits' => 1,
|
91 |
+
'Platform_Bits' => 1,
|
92 |
+
];
|
93 |
+
|
94 |
+
if (array_key_exists($propertyName, $arrayProperties)) {
|
95 |
+
return self::TYPE_IN_ARRAY;
|
96 |
+
}
|
97 |
+
|
98 |
+
$genericProperties = [
|
99 |
+
'Platform_Version' => 1,
|
100 |
+
'RenderingEngine_Version' => 1,
|
101 |
+
'Released' => 1,
|
102 |
+
'Format' => 1,
|
103 |
+
'Type' => 1,
|
104 |
+
];
|
105 |
+
|
106 |
+
if (array_key_exists($propertyName, $genericProperties)) {
|
107 |
+
return self::TYPE_GENERIC;
|
108 |
+
}
|
109 |
+
|
110 |
+
$numericProperties = [
|
111 |
+
'Version' => 1,
|
112 |
+
'CssVersion' => 1,
|
113 |
+
'AolVersion' => 1,
|
114 |
+
'MajorVer' => 1,
|
115 |
+
'MinorVer' => 1,
|
116 |
+
'aolVersion' => 1,
|
117 |
+
];
|
118 |
+
|
119 |
+
if (array_key_exists($propertyName, $numericProperties)) {
|
120 |
+
return self::TYPE_NUMBER;
|
121 |
+
}
|
122 |
+
|
123 |
+
$booleanProperties = [
|
124 |
+
'Alpha' => 1,
|
125 |
+
'Beta' => 1,
|
126 |
+
'Win16' => 1,
|
127 |
+
'Win32' => 1,
|
128 |
+
'Win64' => 1,
|
129 |
+
'Frames' => 1,
|
130 |
+
'IFrames' => 1,
|
131 |
+
'Tables' => 1,
|
132 |
+
'Cookies' => 1,
|
133 |
+
'BackgroundSounds' => 1,
|
134 |
+
'JavaScript' => 1,
|
135 |
+
'VBScript' => 1,
|
136 |
+
'JavaApplets' => 1,
|
137 |
+
'ActiveXControls' => 1,
|
138 |
+
'isMobileDevice' => 1,
|
139 |
+
'isTablet' => 1,
|
140 |
+
'isSyndicationReader' => 1,
|
141 |
+
'Crawler' => 1,
|
142 |
+
'MasterParent' => 1,
|
143 |
+
'LiteMode' => 1,
|
144 |
+
'isFake' => 1,
|
145 |
+
'isAnonymized' => 1,
|
146 |
+
'isModified' => 1,
|
147 |
+
'isBanned' => 1,
|
148 |
+
'supportsCSS' => 1,
|
149 |
+
'AOL' => 1,
|
150 |
+
];
|
151 |
+
|
152 |
+
if (array_key_exists($propertyName, $booleanProperties)) {
|
153 |
+
return self::TYPE_BOOLEAN;
|
154 |
+
}
|
155 |
+
|
156 |
+
throw new \InvalidArgumentException("Property {$propertyName} did not have a defined property type");
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @param string $property
|
161 |
+
* @param string $value
|
162 |
+
*
|
163 |
+
* @throws \InvalidArgumentException
|
164 |
+
*
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
public function checkValueInArray($property, $value)
|
168 |
+
{
|
169 |
+
switch ($property) {
|
170 |
+
case 'Browser_Type':
|
171 |
+
$allowedValues = [
|
172 |
+
'Useragent Anonymizer' => 1,
|
173 |
+
'Browser' => 1,
|
174 |
+
'Offline Browser' => 1,
|
175 |
+
'Multimedia Player' => 1,
|
176 |
+
'Library' => 1,
|
177 |
+
'Feed Reader' => 1,
|
178 |
+
'Email Client' => 1,
|
179 |
+
'Bot/Crawler' => 1,
|
180 |
+
'Application' => 1,
|
181 |
+
'Tool' => 1,
|
182 |
+
'unknown' => 1,
|
183 |
+
];
|
184 |
+
break;
|
185 |
+
case 'Device_Type':
|
186 |
+
$allowedValues = [
|
187 |
+
'Console' => 1,
|
188 |
+
'TV Device' => 1,
|
189 |
+
'Tablet' => 1,
|
190 |
+
'Mobile Phone' => 1,
|
191 |
+
'Smartphone' => 1, // actual mobile phone with touchscreen
|
192 |
+
'Feature Phone' => 1, // older mobile phone
|
193 |
+
'Mobile Device' => 1,
|
194 |
+
'FonePad' => 1, // Tablet sized device with the capability to make phone calls
|
195 |
+
'Desktop' => 1,
|
196 |
+
'Ebook Reader' => 1,
|
197 |
+
'Car Entertainment System' => 1,
|
198 |
+
'Digital Camera' => 1,
|
199 |
+
'unknown' => 1,
|
200 |
+
];
|
201 |
+
break;
|
202 |
+
case 'Device_Pointing_Method':
|
203 |
+
// This property is taken from http://www.scientiamobile.com/wurflCapability
|
204 |
+
$allowedValues = [
|
205 |
+
'joystick' => 1,
|
206 |
+
'stylus' => 1,
|
207 |
+
'touchscreen' => 1,
|
208 |
+
'clickwheel' => 1,
|
209 |
+
'trackpad' => 1,
|
210 |
+
'trackball' => 1,
|
211 |
+
'mouse' => 1,
|
212 |
+
'unknown' => 1,
|
213 |
+
];
|
214 |
+
break;
|
215 |
+
case 'Browser_Bits':
|
216 |
+
case 'Platform_Bits':
|
217 |
+
$allowedValues = [
|
218 |
+
'0' => 1,
|
219 |
+
'8' => 1,
|
220 |
+
'16' => 1,
|
221 |
+
'32' => 1,
|
222 |
+
'64' => 1,
|
223 |
+
];
|
224 |
+
break;
|
225 |
+
default:
|
226 |
+
throw new \InvalidArgumentException('Property "' . $property . '" is not defined to be validated');
|
227 |
+
break;
|
228 |
+
}
|
229 |
+
|
230 |
+
if (array_key_exists($value, $allowedValues)) {
|
231 |
+
return $value;
|
232 |
+
}
|
233 |
+
|
234 |
+
throw new \InvalidArgumentException(
|
235 |
+
'invalid value given for Property "' . $property . '": given value "' . (string) $value . '", allowed: '
|
236 |
+
. json_encode($allowedValues)
|
237 |
+
);
|
238 |
+
}
|
239 |
+
}
|
includes/vendor/browscap/browscap-php/src/Exception.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Browscap.ini parsing class base exception
|
34 |
+
*
|
35 |
+
* @category Browscap-PHP
|
36 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
37 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
38 |
+
* @version 3.0
|
39 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
40 |
+
* @link https://github.com/browscap/browscap-php/
|
41 |
+
*/
|
42 |
+
class Exception extends \Exception
|
43 |
+
{
|
44 |
+
const LOCAL_FILE_MISSING = 100;
|
45 |
+
const NO_RESULT_CLASS_RETURNED = 200;
|
46 |
+
const STRING_VALUE_EXPECTED = 300;
|
47 |
+
const CACHE_DIR_MISSING = 400;
|
48 |
+
const CACHE_DIR_INVALID = 401;
|
49 |
+
const CACHE_DIR_NOT_READABLE = 402;
|
50 |
+
const CACHE_DIR_NOT_WRITABLE = 403;
|
51 |
+
const CACHE_INCOMPATIBLE = 500;
|
52 |
+
const INVALID_DATETIME = 600;
|
53 |
+
const LOCAL_FILE_NOT_READABLE = 700;
|
54 |
+
const REMOTE_UPDATE_NOT_POSSIBLE = 800;
|
55 |
+
const INI_FILE_MISSING = 900;
|
56 |
+
}
|
includes/vendor/browscap/browscap-php/src/Exception/DomainException.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Exception;
|
31 |
+
|
32 |
+
use DomainException as BaseDomainException;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* TBD
|
36 |
+
*
|
37 |
+
* @category Browscap-PHP
|
38 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
39 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
40 |
+
* @version 3.0
|
41 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
42 |
+
* @link https://github.com/browscap/browscap-php/
|
43 |
+
*/
|
44 |
+
class DomainException extends BaseDomainException
|
45 |
+
{
|
46 |
+
// nothing to do here
|
47 |
+
}
|
includes/vendor/browscap/browscap-php/src/Exception/FetcherException.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Exception;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Exception to handle errors while fetching a remote file
|
34 |
+
*
|
35 |
+
* @category Browscap-PHP
|
36 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
37 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
38 |
+
* @version 3.0
|
39 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
40 |
+
* @link https://github.com/browscap/browscap-php/
|
41 |
+
*/
|
42 |
+
class FetcherException extends DomainException
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* @param string $resource
|
46 |
+
* @param string $error
|
47 |
+
*
|
48 |
+
* @return FetcherException
|
49 |
+
*/
|
50 |
+
public static function httpError($resource, $error)
|
51 |
+
{
|
52 |
+
return new static(
|
53 |
+
sprintf('Could not fetch HTTP resource "%s": %s', $resource, $error)
|
54 |
+
);
|
55 |
+
}
|
56 |
+
}
|
includes/vendor/browscap/browscap-php/src/Exception/FileNotFoundException.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or substantial portions of the Software.
|
14 |
+
*
|
15 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
* THE SOFTWARE.
|
22 |
+
*
|
23 |
+
* @category Browscap-PHP
|
24 |
+
* @copyright 1998-2015 Browser Capabilities Project
|
25 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
26 |
+
* @link https://github.com/browscap/browscap-php/
|
27 |
+
* @since added with version 3.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
namespace BrowscapPHP\Exception;
|
31 |
+
|
32 |
+
use Exception;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Exception to handle errors because a file does not exist
|
36 |
+
*
|
37 |
+
* @category Browscap-PHP
|
38 |
+
* @author Thomas Müller <t_mueller_stolzenhain@yahoo.de>
|
39 |
+
* @copyright Copyright (c) 1998-2015 Browser Capabilities Project
|
40 |
+
* @version 3.0
|
41 |
+
* @license http://www.opensource.org/licenses/MIT MIT License
|
42 |
+
* @link https://github.com/browscap/browscap-php/
|
43 |
+
*/
|
44 |
+
class FileNotFoundException extends Exception
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* @param string $file
|
48 |
+
*
|
49 |
+
* @return FileNotFoundException
|
50 |
+
*/
|
51 |
+
public static function fileNotFound($file)
|
52 |
+
{
|
53 |
+
return new static(sprintf('File "%s" does not exist', $file));
|
54 |
+
}
|
55 |
+
}
|
includes/vendor/browscap/browscap-php/src/Exception/InvalidArgumentException.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 1998-2015 Browser Capabilities Project
|
4 |
+
*
|
5 |
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
6 |
+
* copy of this software and associated documentation files (the "Software"),
|
7 |
+
* to deal in the Software without restriction, including without limitation
|
8 |
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 |
+
* and/or sell copies of the Software, and to permit persons to whom the
|
10 |
+
* Software is furnished to do so, subject to the following conditions:
|
11 |
+
*
|
12 |
+
* The above copyright notice and this permission notice shall be included
|
13 |
+
* in all copies or su
|