Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 268 |
|
0.00% |
0 / 13 |
CRAP | |
0.00% |
0 / 4 |
phpbb_questionnaire_data_collector | |
0.00% |
0 / 11 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
add_data_provider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_data_raw | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
get_data_for_form | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
collect | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
phpbb_questionnaire_php_data_provider | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
get_identifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_data | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
6 | |||
phpbb_questionnaire_system_data_provider | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
210 | |
0.00% |
0 / 1 |
get_identifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_data | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
is_private_ip | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
156 | |||
phpbb_questionnaire_phpbb_data_provider | |
0.00% |
0 / 213 |
|
0.00% |
0 / 3 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
get_identifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_data | |
0.00% |
0 / 207 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | /** |
15 | * @ignore |
16 | */ |
17 | if (!defined('IN_PHPBB')) |
18 | { |
19 | exit; |
20 | } |
21 | |
22 | /** |
23 | * This class collects data which is used to create some usage statistics. |
24 | * |
25 | * The collected data is - after authorization of the administrator - submitted |
26 | * to a central server. For privacy reasons we try to collect only data which aren't private |
27 | * or don't give any information which might help to identify the user. |
28 | * |
29 | * @author Johannes Schlueter <johannes@php.net> |
30 | * @copyright (c) 2007-2008 Johannes Schlueter |
31 | */ |
32 | class phpbb_questionnaire_data_collector |
33 | { |
34 | var $providers; |
35 | var $data = null; |
36 | var $install_id = ''; |
37 | |
38 | /** |
39 | * Constructor. |
40 | * |
41 | * @param string $install_id |
42 | */ |
43 | function __construct($install_id) |
44 | { |
45 | $this->install_id = $install_id; |
46 | $this->providers = array(); |
47 | } |
48 | |
49 | function add_data_provider($provider) |
50 | { |
51 | $this->providers[] = $provider; |
52 | } |
53 | |
54 | /** |
55 | * Get data as an array. |
56 | * |
57 | * @return array All Data |
58 | */ |
59 | function get_data_raw() |
60 | { |
61 | if (!$this->data) |
62 | { |
63 | $this->collect(); |
64 | } |
65 | |
66 | return $this->data; |
67 | } |
68 | |
69 | function get_data_for_form() |
70 | { |
71 | return base64_encode(json_encode($this->get_data_raw())); |
72 | } |
73 | |
74 | /** |
75 | * Collect info into the data property. |
76 | * |
77 | * @return void |
78 | */ |
79 | function collect() |
80 | { |
81 | foreach (array_keys($this->providers) as $key) |
82 | { |
83 | $provider = $this->providers[$key]; |
84 | $this->data[$provider->get_identifier()] = $provider->get_data(); |
85 | } |
86 | $this->data['install_id'] = $this->install_id; |
87 | } |
88 | } |
89 | |
90 | /** interface: get_indentifier(), get_data() */ |
91 | |
92 | /** |
93 | * Questionnaire PHP data provider |
94 | */ |
95 | class phpbb_questionnaire_php_data_provider |
96 | { |
97 | function get_identifier() |
98 | { |
99 | return 'PHP'; |
100 | } |
101 | |
102 | /** |
103 | * Get data about the PHP runtime setup. |
104 | * |
105 | * @return array |
106 | */ |
107 | function get_data() |
108 | { |
109 | return array( |
110 | 'version' => PHP_VERSION, |
111 | 'sapi' => PHP_SAPI, |
112 | 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', |
113 | 'open_basedir' => (int) @ini_get('open_basedir'), |
114 | 'memory_limit' => @ini_get('memory_limit'), |
115 | 'allow_url_fopen' => (int) @ini_get('allow_url_fopen'), |
116 | 'allow_url_include' => (int) @ini_get('allow_url_include'), |
117 | 'file_uploads' => (int) @ini_get('file_uploads'), |
118 | 'upload_max_filesize' => @ini_get('upload_max_filesize'), |
119 | 'post_max_size' => @ini_get('post_max_size'), |
120 | 'disable_functions' => @ini_get('disable_functions'), |
121 | 'disable_classes' => @ini_get('disable_classes'), |
122 | 'enable_dl' => (int) @ini_get('enable_dl'), |
123 | 'filter.default' => @ini_get('filter.default'), |
124 | 'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'), |
125 | 'unicode.semantics' => (int) @ini_get('unicode.semantics'), |
126 | 'zend_thread_safty' => (int) function_exists('zend_thread_id'), |
127 | 'extensions' => implode(',', get_loaded_extensions()), |
128 | ); |
129 | } |
130 | } |
131 | |
132 | /** |
133 | * Questionnaire System data provider |
134 | */ |
135 | class phpbb_questionnaire_system_data_provider |
136 | { |
137 | function get_identifier() |
138 | { |
139 | return 'System'; |
140 | } |
141 | |
142 | /** |
143 | * Get data about the general system information, like OS or IP (shortened). |
144 | * |
145 | * @return array |
146 | */ |
147 | function get_data() |
148 | { |
149 | global $request; |
150 | |
151 | // Start discovering the IPV4 server address, if available |
152 | // Try apache, IIS, fall back to 0.0.0.0 |
153 | $server_address = html_entity_decode($request->server('SERVER_ADDR', $request->server('LOCAL_ADDR', '0.0.0.0')), ENT_COMPAT); |
154 | |
155 | return array( |
156 | 'os' => PHP_OS, |
157 | 'httpd' => html_entity_decode($request->server('SERVER_SOFTWARE'), ENT_COMPAT), |
158 | // we don't want the real IP address (for privacy policy reasons) but only |
159 | // a network address to see whether your installation is running on a private or public network. |
160 | 'private_ip' => $this->is_private_ip($server_address), |
161 | 'ipv6' => strpos($server_address, ':') !== false, |
162 | ); |
163 | } |
164 | |
165 | /** |
166 | * Checks whether the given IP is in a private network. |
167 | * |
168 | * @param string $ip IP in v4 dot-decimal or v6 hex format |
169 | * @return bool true if the IP is from a private network, else false |
170 | */ |
171 | function is_private_ip($ip) |
172 | { |
173 | // IPv4 |
174 | if (strpos($ip, ':') === false) |
175 | { |
176 | $ip_address_ary = explode('.', $ip); |
177 | |
178 | // build ip |
179 | if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1])) |
180 | { |
181 | $ip_address_ary = explode('.', '0.0.0.0'); |
182 | } |
183 | |
184 | // IANA reserved addresses for private networks (RFC 1918) are: |
185 | // - 10.0.0.0/8 |
186 | // - 172.16.0.0/12 |
187 | // - 192.168.0.0/16 |
188 | if ($ip_address_ary[0] == '10' || |
189 | ($ip_address_ary[0] == '172' && intval($ip_address_ary[1]) > 15 && intval($ip_address_ary[1]) < 32) || |
190 | ($ip_address_ary[0] == '192' && $ip_address_ary[1] == '168')) |
191 | { |
192 | return true; |
193 | } |
194 | } |
195 | // IPv6 |
196 | else |
197 | { |
198 | // unique local unicast |
199 | $prefix = substr($ip, 0, 2); |
200 | if ($prefix == 'fc' || $prefix == 'fd') |
201 | { |
202 | return true; |
203 | } |
204 | } |
205 | |
206 | return false; |
207 | } |
208 | } |
209 | |
210 | /** |
211 | * Questionnaire phpBB data provider |
212 | */ |
213 | class phpbb_questionnaire_phpbb_data_provider |
214 | { |
215 | var $config; |
216 | var $unique_id; |
217 | |
218 | /** |
219 | * Constructor. |
220 | * |
221 | * @param array $config |
222 | */ |
223 | function __construct($config) |
224 | { |
225 | // generate a unique id if necessary |
226 | if (empty($config['questionnaire_unique_id'])) |
227 | { |
228 | $this->unique_id = unique_id(); |
229 | $config->set('questionnaire_unique_id', $this->unique_id); |
230 | } |
231 | else |
232 | { |
233 | $this->unique_id = $config['questionnaire_unique_id']; |
234 | } |
235 | |
236 | $this->config = $config; |
237 | } |
238 | |
239 | /** |
240 | * Returns a string identifier for this data provider |
241 | * |
242 | * @return string "phpBB" |
243 | */ |
244 | function get_identifier() |
245 | { |
246 | return 'phpBB'; |
247 | } |
248 | |
249 | /** |
250 | * Get data about this phpBB installation. |
251 | * |
252 | * @return array Relevant anonymous config options |
253 | */ |
254 | function get_data() |
255 | { |
256 | global $phpbb_config_php_file; |
257 | |
258 | extract($phpbb_config_php_file->get_all()); |
259 | unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution |
260 | |
261 | $dbms = \phpbb\config_php_file::convert_30_dbms_to_31($dbms); |
262 | |
263 | // Only send certain config vars |
264 | $config_vars = array( |
265 | 'active_sessions' => true, |
266 | 'allow_attachments' => true, |
267 | 'allow_autologin' => true, |
268 | 'allow_avatar' => true, |
269 | 'allow_avatar_local' => true, |
270 | 'allow_avatar_upload' => true, |
271 | 'allow_bbcode' => true, |
272 | 'allow_birthdays' => true, |
273 | 'allow_bookmarks' => true, |
274 | 'allow_emailreuse' => true, |
275 | 'allow_forum_notify' => true, |
276 | 'allow_mass_pm' => true, |
277 | 'allow_name_chars' => true, |
278 | 'allow_namechange' => true, |
279 | 'allow_nocensors' => true, |
280 | 'allow_pm_attach' => true, |
281 | 'allow_pm_report' => true, |
282 | 'allow_post_links' => true, |
283 | 'allow_privmsg' => true, |
284 | 'allow_quick_reply' => true, |
285 | 'allow_sig' => true, |
286 | 'allow_sig_bbcode' => true, |
287 | 'allow_sig_img' => true, |
288 | 'allow_sig_links' => true, |
289 | 'allow_sig_pm' => true, |
290 | 'allow_sig_smilies' => true, |
291 | 'allow_smilies' => true, |
292 | 'allow_topic_notify' => true, |
293 | 'attachment_quota' => true, |
294 | 'auth_bbcode_pm' => true, |
295 | 'auth_img_pm' => true, |
296 | 'auth_method' => true, |
297 | 'auth_smilies_pm' => true, |
298 | 'avatar_filesize' => true, |
299 | 'avatar_max_height' => true, |
300 | 'avatar_max_width' => true, |
301 | 'avatar_min_height' => true, |
302 | 'avatar_min_width' => true, |
303 | 'board_email_form' => true, |
304 | 'board_hide_emails' => true, |
305 | 'board_timezone' => true, |
306 | 'browser_check' => true, |
307 | 'bump_interval' => true, |
308 | 'bump_type' => true, |
309 | 'cache_gc' => true, |
310 | 'captcha_plugin' => true, |
311 | 'captcha_gd' => true, |
312 | 'captcha_gd_foreground_noise' => true, |
313 | 'captcha_gd_x_grid' => true, |
314 | 'captcha_gd_y_grid' => true, |
315 | 'captcha_gd_wave' => true, |
316 | 'captcha_gd_3d_noise' => true, |
317 | 'captcha_gd_fonts' => true, |
318 | 'confirm_refresh' => true, |
319 | 'check_attachment_content' => true, |
320 | 'check_dnsbl' => true, |
321 | 'chg_passforce' => true, |
322 | 'cookie_secure' => true, |
323 | 'coppa_enable' => true, |
324 | 'database_gc' => true, |
325 | 'default_dateformat' => true, |
326 | 'default_lang' => true, |
327 | 'display_last_edited' => true, |
328 | 'display_order' => true, |
329 | 'edit_time' => true, |
330 | 'email_check_mx' => true, |
331 | 'email_enable' => true, |
332 | 'email_force_sender' => true, |
333 | 'email_package_size' => true, |
334 | 'enable_confirm' => true, |
335 | 'enable_pm_icons' => true, |
336 | 'enable_post_confirm' => true, |
337 | 'feed_enable' => true, |
338 | 'feed_http_auth' => true, |
339 | 'feed_limit_post' => true, |
340 | 'feed_limit_topic' => true, |
341 | 'feed_overall' => true, |
342 | 'feed_overall_forums' => true, |
343 | 'feed_forum' => true, |
344 | 'feed_topic' => true, |
345 | 'feed_topics_new' => true, |
346 | 'feed_topics_active' => true, |
347 | 'feed_item_statistics' => true, |
348 | 'flood_interval' => true, |
349 | 'force_server_vars' => true, |
350 | 'form_token_lifetime' => true, |
351 | 'form_token_mintime' => true, |
352 | 'form_token_sid_guests' => true, |
353 | 'forward_pm' => true, |
354 | 'forwarded_for_check' => true, |
355 | 'full_folder_action' => true, |
356 | 'fulltext_native_common_thres' => true, |
357 | 'fulltext_native_load_upd' => true, |
358 | 'fulltext_native_max_chars' => true, |
359 | 'fulltext_native_min_chars' => true, |
360 | 'gzip_compress' => true, |
361 | 'hot_threshold' => true, |
362 | 'img_create_thumbnail' => true, |
363 | 'img_display_inlined' => true, |
364 | 'img_max_height' => true, |
365 | 'img_max_thumb_width' => true, |
366 | 'img_max_width' => true, |
367 | 'img_min_thumb_filesize' => true, |
368 | 'ip_check' => true, |
369 | 'jab_enable' => true, |
370 | 'jab_package_size' => true, |
371 | 'jab_use_ssl' => true, |
372 | 'limit_load' => true, |
373 | 'limit_search_load' => true, |
374 | 'load_anon_lastread' => true, |
375 | 'load_birthdays' => true, |
376 | 'load_cpf_memberlist' => true, |
377 | 'load_cpf_viewprofile' => true, |
378 | 'load_cpf_viewtopic' => true, |
379 | 'load_db_lastread' => true, |
380 | 'load_db_track' => true, |
381 | 'load_jumpbox' => true, |
382 | 'load_moderators' => true, |
383 | 'load_online' => true, |
384 | 'load_online_guests' => true, |
385 | 'load_online_time' => true, |
386 | 'load_onlinetrack' => true, |
387 | 'load_search' => true, |
388 | 'load_tplcompile' => true, |
389 | 'load_user_activity' => true, |
390 | 'max_attachments' => true, |
391 | 'max_attachments_pm' => true, |
392 | 'max_autologin_time' => true, |
393 | 'max_filesize' => true, |
394 | 'max_filesize_pm' => true, |
395 | 'max_login_attempts' => true, |
396 | 'max_name_chars' => true, |
397 | 'max_num_search_keywords' => true, |
398 | 'max_poll_options' => true, |
399 | 'max_post_chars' => true, |
400 | 'max_post_font_size' => true, |
401 | 'max_post_smilies' => true, |
402 | 'max_post_urls' => true, |
403 | 'max_quote_depth' => true, |
404 | 'max_reg_attempts' => true, |
405 | 'max_sig_chars' => true, |
406 | 'max_sig_font_size' => true, |
407 | 'max_sig_smilies' => true, |
408 | 'max_sig_urls' => true, |
409 | 'min_name_chars' => true, |
410 | 'min_pass_chars' => true, |
411 | 'min_post_chars' => true, |
412 | 'min_search_author_chars' => true, |
413 | 'mime_triggers' => true, |
414 | 'new_member_post_limit' => true, |
415 | 'new_member_group_default' => true, |
416 | 'override_user_style' => true, |
417 | 'pass_complex' => true, |
418 | 'pm_edit_time' => true, |
419 | 'pm_max_boxes' => true, |
420 | 'pm_max_msgs' => true, |
421 | 'pm_max_recipients' => true, |
422 | 'posts_per_page' => true, |
423 | 'print_pm' => true, |
424 | 'queue_interval' => true, |
425 | 'require_activation' => true, |
426 | 'referer_validation' => true, |
427 | 'search_block_size' => true, |
428 | 'search_gc' => true, |
429 | 'search_interval' => true, |
430 | 'search_anonymous_interval' => true, |
431 | 'search_type' => true, |
432 | 'search_store_results' => true, |
433 | 'secure_allow_deny' => true, |
434 | 'secure_allow_empty_referer' => true, |
435 | 'secure_downloads' => true, |
436 | 'session_gc' => true, |
437 | 'session_length' => true, |
438 | 'smtp_auth_method' => true, |
439 | 'smtp_delivery' => true, |
440 | 'topics_per_page' => true, |
441 | 'version' => true, |
442 | 'warnings_expire_days' => true, |
443 | 'warnings_gc' => true, |
444 | |
445 | 'num_files' => true, |
446 | 'num_posts' => true, |
447 | 'num_topics' => true, |
448 | 'num_users' => true, |
449 | 'record_online_users' => true, |
450 | ); |
451 | |
452 | $result = array(); |
453 | foreach ($config_vars as $name => $void) |
454 | { |
455 | if (isset($this->config[$name])) |
456 | { |
457 | $result['config_' . $name] = $this->config[$name]; |
458 | } |
459 | } |
460 | |
461 | global $db, $request; |
462 | |
463 | $result['dbms'] = $dbms; |
464 | $result['acm_type'] = $acm_type; |
465 | $result['user_agent'] = 'Unknown'; |
466 | $result['dbms_version'] = $db->sql_server_info(true); |
467 | |
468 | // Try to get user agent vendor and version |
469 | $match = array(); |
470 | $user_agent = $request->header('User-Agent'); |
471 | $agents = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol'); |
472 | |
473 | // We check here 1 by 1 because some strings occur after others (for example Mozilla [...] Firefox/) |
474 | foreach ($agents as $agent) |
475 | { |
476 | if (preg_match('#(' . $agent . ')[/ ]?([0-9.]*)#i', $user_agent, $match)) |
477 | { |
478 | $result['user_agent'] = $match[1] . ' ' . $match[2]; |
479 | break; |
480 | } |
481 | } |
482 | |
483 | return $result; |
484 | } |
485 | } |