-
Notifications
You must be signed in to change notification settings - Fork 0
/
questionnaire.php
151 lines (136 loc) · 4.63 KB
/
questionnaire.php
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
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
<?php
interface Questionnaire_Data_Provider
{
public function getIdentifier();
public function getData();
}
class Questionnaire_PHP_Data_Provider implements Questionnaire_Data_Provider
{
public function getIdentifier()
{
return 'PHP';
}
/**
* Get data about the PHP runtime setup.
*
* @return array
*/
public function getData()
{
return array(
'version' => PHP_VERSION,
'sapi' => PHP_SAPI,
'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '',
'safe_mode' => (int)ini_get('safe_mode'),
'open_basedir' => (int)ini_get('open_basedir'),
'memory_limit' => ini_get('memory_limit'),
'allow_url_fopen' => (int)ini_get('allow_url_fopen'),
'allow_url_include' => (int)ini_get('allow_url_include'),
'file_uploads' => (int)ini_get('file_uploads'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'disable_functions' => ini_get('disable_functions'),
'disable_classes' => ini_get('disable_classes'),
'enable_dl' => (int)ini_get('enable_dl'),
'magic_quotes_gpc' => (int)ini_get('magic_quotes_gpc'),
'register_globals' => (int)ini_get('register_globals'),
'filter.default' => ini_get('filter.default'),
'zend.ze1_compatibility_mode' => (int)ini_get('zend.ze1_compatibility_mode'),
'unicode.semantics' => (int)ini_get('unicode.semantics'),
'zend_thread_safty' => (int)function_exists('zend_thread_id'),
'extensions' => get_loaded_extensions()
);
}
}
class Questionnaire_System_Data_Provider implements Questionnaire_Data_Provider
{
public function getIdentifier()
{
return 'System';
}
/**
* Get data about the general system information, like OS or IP (shortened).
*
* @return array
*/
public function getData()
{
// Start discovering the IPV4 server address, if available
$serverAddress = '0.0.0.0';
if (isset($_SERVER['SERVER_ADDR'])) {
$serverAddress = $_SERVER['SERVER_ADDR'];
}
// Running on IIS?
if (isset($_SERVER['LOCAL_ADDR'])) {
$serverAddress = $_SERVER['LOCAL_ADDR'];
}
$aIPAddress = explode('.', $serverAddress);
return array(
'os' => PHP_OS,
'httpd' => $_SERVER['SERVER_SOFTWARE'],
// we don't want the real IP address (for privacy policy reasons) but only
// a network address to see whether your phpMyFAQ is running on a private or public network.
// IANA reserved addresses for private networks (RFC 1918) are:
// - 10.0.0.0/8
// - 172.16.0.0/12
// - 192.168.0.0/16
'ip' => $aIPAddress[0].'.'.$aIPAddress[1].'.XXX.YYY'
);
}
}
/**
* This class collects data which is used to create some usage statistics.
*
* The collected data is - after authorization of the administrator - submitted
* to a central server. For privacy reasons we try to collect only data which aren't private
* or don't give any information which might help to identify the user.
*
* @author Johannes Schlueter <[email protected]>
* @copyright (c) 2007-2008 Johannes Schlueter
*/
class Questionnaire_Data_Collector
{
private $providers;
private $data = null;
/**
* Constructor.
*
* @param array
* @param string
*/
function __construct()
{
$this->providers = new SplObjectStorage();
}
public function addDataProvider(Questionnaire_Data_Provider $provider)
{
$this->providers->attach($provider);
}
/**
* Get data as an array.
*
* @return array All Data
*/
function getDataRaw()
{
if (!$this->data) {
$this->collect();
}
return $this->data;
}
function getDataForForm()
{
return base64_encode(serialize($this->getDataRaw()));
}
/**
* Collect info into the data property.
*
* @return void
*/
function collect()
{
foreach ($this->providers as $value) {
$this->data[$value->getIdentifier()] = $value->getData();
}
}
}