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