[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/includes/questionnaire/ -> questionnaire.php (source)

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


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1