1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WINNT System Class |
4
|
|
|
* |
5
|
|
|
* PHP version 5 |
6
|
|
|
* |
7
|
|
|
* @category PHP |
8
|
|
|
* @package PSI WINNT OS class |
9
|
|
|
* @author Michael Cramer <[email protected]> |
10
|
|
|
* @copyright 2009 phpSysInfo |
11
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
12
|
|
|
* @version SVN: $Id: class.WINNT.inc.php 699 2012-09-15 11:57:13Z namiltd $ |
13
|
|
|
* @link http://phpsysinfo.sourceforge.net |
14
|
|
|
*/ |
15
|
|
|
/** |
16
|
|
|
* WINNT sysinfo class |
17
|
|
|
* get all the required information from WINNT systems |
18
|
|
|
* information are retrieved through the WMI interface |
19
|
|
|
* |
20
|
|
|
* @category PHP |
21
|
|
|
* @package PSI WINNT OS class |
22
|
|
|
* @author Michael Cramer <[email protected]> |
23
|
|
|
* @copyright 2009 phpSysInfo |
24
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
25
|
|
|
* @version Release: 3.0 |
26
|
|
|
* @link http://phpsysinfo.sourceforge.net |
27
|
|
|
*/ |
28
|
|
|
class WINNT extends OS |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* holds the COM object that we pull all the WMI data from |
32
|
|
|
* |
33
|
|
|
* @var Object |
34
|
|
|
*/ |
35
|
|
|
private $_wmi = null; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* holds all devices, which are in the system |
39
|
|
|
* |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
private $_wmidevices; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* store language encoding of the system to convert some output to utf-8 |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $_codepage = null; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* store language of the system |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $_syslang = null; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* build the global Error object and create the WMI connection |
60
|
|
|
*/ |
61
|
|
|
public function __construct() |
62
|
|
|
{ |
63
|
|
|
parent::__construct(); |
64
|
|
|
// don't set this params for local connection, it will not work |
65
|
|
|
$strHostname = ''; |
66
|
|
|
$strUser = ''; |
67
|
|
|
$strPassword = ''; |
68
|
|
|
try { |
69
|
|
|
// initialize the wmi object |
70
|
|
|
$objLocator = new COM('WbemScripting.SWbemLocator'); |
|
|
|
|
71
|
|
|
if ($strHostname == "") { |
72
|
|
|
$this->_wmi = $objLocator->ConnectServer(); |
73
|
|
|
|
74
|
|
|
} else { |
75
|
|
|
$this->_wmi = $objLocator->ConnectServer($strHostname, 'root\CIMv2', $strHostname.'\\'.$strUser, $strPassword); |
76
|
|
|
} |
77
|
|
|
} catch (Exception $e) { |
78
|
|
|
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed."); |
79
|
|
|
} |
80
|
|
|
$this->_getCodeSet(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* store the codepage of the os for converting some strings to utf-8 |
85
|
|
|
* |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
|
|
private function _getCodeSet() |
89
|
|
|
{ |
90
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_OperatingSystem', array('CodeSet', 'OSLanguage')); |
91
|
|
|
if ($buffer) { |
|
|
|
|
92
|
|
|
$this->_codepage = 'windows-'.$buffer[0]['CodeSet']; |
93
|
|
|
$lang = ""; |
94
|
|
|
if (is_readable(APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(APP_ROOT.'/data/languages.ini', true))) { |
95
|
|
|
if (isset($langdata['WINNT'][$buffer[0]['OSLanguage']])) { |
96
|
|
|
$lang = $langdata['WINNT'][$buffer[0]['OSLanguage']]; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
if ($lang == "") { |
100
|
|
|
$lang = 'Unknown'; |
101
|
|
|
} |
102
|
|
|
$this->_syslang = $lang.' ('.$buffer[0]['OSLanguage'].')'; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* retrieve different device types from the system based on selector |
108
|
|
|
* |
109
|
|
|
* @param string $strType type of the devices that should be returned |
110
|
|
|
* |
111
|
|
|
* @return array list of devices of the specified type |
112
|
|
|
*/ |
113
|
|
|
private function _devicelist($strType) |
114
|
|
|
{ |
115
|
|
|
if (empty($this->_wmidevices)) { |
116
|
|
|
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID')); |
117
|
|
|
} |
118
|
|
|
$list = array(); |
119
|
|
|
foreach ($this->_wmidevices as $device) { |
120
|
|
|
if (substr($device['PNPDeviceID'], 0, strpos($device['PNPDeviceID'], "\\") + 1) == ($strType."\\")) { |
121
|
|
|
$list[] = $device['Name']; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
return $list; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Host Name |
130
|
|
|
* |
131
|
|
|
* @return void |
132
|
|
|
*/ |
133
|
|
|
private function _hostname() |
134
|
|
|
{ |
135
|
|
|
if (PSI_USE_VHOST === true) { |
136
|
|
|
if ($hnm = getenv('SERVER_NAME')) $this->sys->setHostname($hnm); |
137
|
|
|
} else { |
138
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name')); |
139
|
|
|
if ($buffer) { |
|
|
|
|
140
|
|
|
$result = $buffer[0]['Name']; |
141
|
|
|
$ip = gethostbyname($result); |
142
|
|
|
if ($ip != $result) { |
143
|
|
|
$long = ip2long($ip); |
144
|
|
|
if (($long >= 167772160 && $long <= 184549375) || |
145
|
|
|
($long >= -1408237568 && $long <= -1407188993) || |
146
|
|
|
($long >= -1062731776 && $long <= -1062666241) || |
147
|
|
|
($long >= 2130706432 && $long <= 2147483647) || $long == -1) { |
148
|
|
|
$this->sys->setHostname($result); //internal ip |
149
|
|
|
} else { |
150
|
|
|
$this->sys->setHostname(gethostbyaddr($ip)); |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
} else { |
154
|
|
|
if ($hnm = getenv('COMPUTERNAME')) $this->sys->setHostname($hnm); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* UpTime |
161
|
|
|
* time the system is running |
162
|
|
|
* |
163
|
|
|
* @return void |
164
|
|
|
*/ |
165
|
|
|
private function _uptime() |
166
|
|
|
{ |
167
|
|
|
$result = 0; |
|
|
|
|
168
|
|
|
date_default_timezone_set('UTC'); |
169
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_OperatingSystem', array('LastBootUpTime', 'LocalDateTime')); |
170
|
|
|
if ($buffer) { |
|
|
|
|
171
|
|
|
$byear = intval(substr($buffer[0]['LastBootUpTime'], 0, 4)); |
172
|
|
|
$bmonth = intval(substr($buffer[0]['LastBootUpTime'], 4, 2)); |
173
|
|
|
$bday = intval(substr($buffer[0]['LastBootUpTime'], 6, 2)); |
174
|
|
|
$bhour = intval(substr($buffer[0]['LastBootUpTime'], 8, 2)); |
175
|
|
|
$bminute = intval(substr($buffer[0]['LastBootUpTime'], 10, 2)); |
176
|
|
|
$bseconds = intval(substr($buffer[0]['LastBootUpTime'], 12, 2)); |
177
|
|
|
$lyear = intval(substr($buffer[0]['LocalDateTime'], 0, 4)); |
178
|
|
|
$lmonth = intval(substr($buffer[0]['LocalDateTime'], 4, 2)); |
179
|
|
|
$lday = intval(substr($buffer[0]['LocalDateTime'], 6, 2)); |
180
|
|
|
$lhour = intval(substr($buffer[0]['LocalDateTime'], 8, 2)); |
181
|
|
|
$lminute = intval(substr($buffer[0]['LocalDateTime'], 10, 2)); |
182
|
|
|
$lseconds = intval(substr($buffer[0]['LocalDateTime'], 12, 2)); |
183
|
|
|
$boottime = mktime($bhour, $bminute, $bseconds, $bmonth, $bday, $byear); |
184
|
|
|
$localtime = mktime($lhour, $lminute, $lseconds, $lmonth, $lday, $lyear); |
185
|
|
|
$result = $localtime - $boottime; |
186
|
|
|
$this->sys->setUptime($result); |
|
|
|
|
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Number of Users |
192
|
|
|
* |
193
|
|
|
* @return void |
194
|
|
|
*/ |
195
|
|
|
protected function _users() |
196
|
|
|
{ |
197
|
|
|
if (CommonFunctions::executeProgram("quser", "", $strBuf, false) && (strlen($strBuf) > 0)) { |
198
|
|
|
$lines = preg_split('/\n/', $strBuf); |
199
|
|
|
$users = count($lines)-1; |
200
|
|
|
} else { |
201
|
|
|
$users = 0; |
202
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption')); |
203
|
|
|
foreach ($buffer as $process) { |
204
|
|
|
if (strtoupper($process['Caption']) == strtoupper('explorer.exe')) { |
205
|
|
|
$users++; |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
} |
209
|
|
|
$this->sys->setUsers($users); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Distribution |
214
|
|
|
* |
215
|
|
|
* @return void |
216
|
|
|
*/ |
217
|
|
|
private function _distro() |
218
|
|
|
{ |
219
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_OperatingSystem', array('Version', 'ServicePackMajorVersion', 'Caption', 'OSArchitecture')); |
220
|
|
|
if ($buffer) { |
|
|
|
|
221
|
|
|
$kernel = $buffer[0]['Version']; |
222
|
|
|
if ($buffer[0]['ServicePackMajorVersion'] > 0) { |
223
|
|
|
$kernel .= ' SP'.$buffer[0]['ServicePackMajorVersion']; |
224
|
|
|
} |
225
|
|
|
if (isset($buffer[0]['OSArchitecture']) && preg_match("/^(\d+)/", $buffer[0]['OSArchitecture'], $bits)) { |
226
|
|
|
$this->sys->setKernel($kernel.' ('.$bits[1].'-bit)'); |
227
|
|
|
} elseif (($allCpus = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('AddressWidth'))) && isset($allCpus[0]['AddressWidth'])) { |
228
|
|
|
$this->sys->setKernel($kernel.' ('.$allCpus[0]['AddressWidth'].'-bit)'); |
229
|
|
|
} else { |
230
|
|
|
$this->sys->setKernel($kernel); |
231
|
|
|
} |
232
|
|
|
$this->sys->setDistribution($buffer[0]['Caption']); |
233
|
|
|
|
234
|
|
|
if ((($kernel[1] == ".") && ($kernel[0] <5)) || (substr($kernel, 0, 4) == "5.0.")) |
235
|
|
|
$icon = 'Win2000.png'; |
236
|
|
|
elseif ((substr($kernel, 0, 4) == "6.0.") || (substr($kernel, 0, 4) == "6.1.")) |
237
|
|
|
$icon = 'WinVista.png'; |
238
|
|
|
elseif ((substr($kernel, 0, 4) == "6.2.") || (substr($kernel, 0, 4) == "6.3.") || (substr($kernel, 0, 4) == "6.4.") || (substr($kernel, 0, 5) == "10.0.")) |
239
|
|
|
$icon = 'Win8.png'; |
240
|
|
|
else |
241
|
|
|
$icon = 'WinXP.png'; |
242
|
|
|
$this->sys->setDistributionIcon($icon); |
243
|
|
|
} elseif (CommonFunctions::executeProgram("cmd", "/c ver 2>nul", $ver_value, false)) { |
244
|
|
|
if (preg_match("/ReactOS\r?\nVersion\s+(.+)/", $ver_value, $ar_temp)) { |
245
|
|
|
$this->sys->setDistribution("ReactOS"); |
246
|
|
|
$this->sys->setKernel($ar_temp[1]); |
247
|
|
|
$this->sys->setDistributionIcon('ReactOS.png'); |
248
|
|
|
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*(.+)\]/", $ver_value, $ar_temp)) { |
249
|
|
|
$this->sys->setDistribution($ar_temp[1]); |
250
|
|
|
$this->sys->setKernel($ar_temp[2]); |
251
|
|
|
$this->sys->setDistributionIcon('Win2000.png'); |
252
|
|
|
} else { |
253
|
|
|
$this->sys->setDistribution("WinNT"); |
254
|
|
|
$this->sys->setDistributionIcon('Win2000.png'); |
255
|
|
|
} |
256
|
|
|
} else { |
257
|
|
|
$this->sys->setDistribution("WinNT"); |
258
|
|
|
$this->sys->setDistributionIcon('Win2000.png'); |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Processor Load |
264
|
|
|
* optionally create a loadbar |
265
|
|
|
* |
266
|
|
|
* @return void |
267
|
|
|
*/ |
268
|
|
|
private function _loadavg() |
269
|
|
|
{ |
270
|
|
|
$loadavg = ""; |
271
|
|
|
$sum = 0; |
272
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('LoadPercentage')); |
273
|
|
|
if ($buffer) { |
|
|
|
|
274
|
|
|
foreach ($buffer as $load) { |
275
|
|
|
$value = $load['LoadPercentage']; |
276
|
|
|
$loadavg .= $value.' '; |
277
|
|
|
$sum += $value; |
278
|
|
|
} |
279
|
|
|
$this->sys->setLoad(trim($loadavg)); |
280
|
|
|
if (PSI_LOAD_BAR) { |
281
|
|
|
$this->sys->setLoadPercent($sum / count($buffer)); |
282
|
|
|
} |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* CPU information |
288
|
|
|
* |
289
|
|
|
* @return void |
290
|
|
|
*/ |
291
|
|
|
private function _cpuinfo() |
292
|
|
|
{ |
293
|
|
|
$allCpus = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('Name', 'L2CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'MaxClockSpeed')); |
294
|
|
|
foreach ($allCpus as $oneCpu) { |
295
|
|
|
$coreCount = 1; |
296
|
|
|
if (isset($oneCpu['NumberOfCores'])) { |
297
|
|
|
$coreCount = $oneCpu['NumberOfCores']; |
298
|
|
|
} |
299
|
|
|
for ($i = 0; $i < $coreCount; $i++) { |
300
|
|
|
$cpu = new CpuDevice(); |
301
|
|
|
$cpu->setModel($oneCpu['Name']); |
302
|
|
|
$cpu->setCache($oneCpu['L2CacheSize'] * 1024); |
303
|
|
|
$cpu->setCpuSpeed($oneCpu['CurrentClockSpeed']); |
304
|
|
|
$cpu->setBusSpeed($oneCpu['ExtClock']); |
305
|
|
|
if ($oneCpu['CurrentClockSpeed'] < $oneCpu['MaxClockSpeed']) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']); |
306
|
|
|
$this->sys->setCpus($cpu); |
|
|
|
|
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Machine information |
313
|
|
|
* |
314
|
|
|
* @return void |
315
|
|
|
*/ |
316
|
|
|
private function _machine() |
317
|
|
|
{ |
318
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Manufacturer', 'Model')); |
319
|
|
|
if ($buffer) { |
|
|
|
|
320
|
|
|
$buf = ""; |
321
|
|
|
if (isset($buffer[0]['Manufacturer'])) { |
322
|
|
|
$buf .= ' '.$buffer[0]['Manufacturer']; |
323
|
|
|
} |
324
|
|
|
if (isset($buffer[0]['Model'])) { |
325
|
|
|
$buf .= ' '.$buffer[0]['Model']; |
326
|
|
|
} |
327
|
|
|
if (trim($buf) != "") { |
328
|
|
|
$this->sys->setMachine(trim($buf)); |
|
|
|
|
329
|
|
|
} |
330
|
|
|
} |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Hardwaredevices |
335
|
|
|
* |
336
|
|
|
* @return void |
337
|
|
|
*/ |
338
|
|
|
private function _hardware() |
339
|
|
|
{ |
340
|
|
|
foreach ($this->_devicelist('PCI') as $pciDev) { |
341
|
|
|
$dev = new HWDevice(); |
342
|
|
|
$dev->setName($pciDev); |
343
|
|
|
$this->sys->setPciDevices($dev); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
foreach ($this->_devicelist('IDE') as $ideDev) { |
347
|
|
|
$dev = new HWDevice(); |
348
|
|
|
$dev->setName($ideDev); |
349
|
|
|
$this->sys->setIdeDevices($dev); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
foreach ($this->_devicelist('SCSI') as $scsiDev) { |
353
|
|
|
$dev = new HWDevice(); |
354
|
|
|
$dev->setName($scsiDev); |
355
|
|
|
$this->sys->setScsiDevices($dev); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
foreach ($this->_devicelist('USB') as $usbDev) { |
359
|
|
|
$dev = new HWDevice(); |
360
|
|
|
$dev->setName($usbDev); |
361
|
|
|
$this->sys->setUsbDevices($dev); |
362
|
|
|
} |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* Network devices |
367
|
|
|
* |
368
|
|
|
* @return void |
369
|
|
|
*/ |
370
|
|
|
private function _network() |
371
|
|
|
{ |
372
|
|
|
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth')); |
373
|
|
|
$allNetworkAdapterConfigurations = CommonFunctions::getWMI($this->_wmi, 'Win32_NetworkAdapterConfiguration', array('Description', 'MACAddress', 'IPAddress', 'SettingID')); |
374
|
|
|
$allNetworkAdapter = CommonFunctions::getWMI($this->_wmi, 'Win32_NetworkAdapter', array('Name', 'GUID', 'Speed')); |
375
|
|
|
|
376
|
|
|
foreach ($allDevices as $device) { |
377
|
|
|
$dev = new NetDevice(); |
378
|
|
|
$name = $device['Name']; |
379
|
|
|
|
380
|
|
|
if (preg_match('/^isatap\.({[A-Fa-f0-9\-]*})/', $name, $ar_name)) { //isatap device |
381
|
|
|
foreach ($allNetworkAdapterConfigurations as $NetworkAdapterConfiguration) { |
382
|
|
|
if ($ar_name[1]==$NetworkAdapterConfiguration['SettingID']) { |
383
|
|
|
$dev->setName($NetworkAdapterConfiguration['Description']); |
384
|
|
|
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) { |
385
|
|
|
$dev->setInfo(preg_replace('/:/', '-', strtoupper($NetworkAdapterConfiguration['MACAddress']))); |
386
|
|
View Code Duplication |
if (isset($NetworkAdapterConfiguration['IPAddress'])) |
|
|
|
|
387
|
|
|
foreach($NetworkAdapterConfiguration['IPAddress'] as $ipaddres) |
388
|
|
|
if (($ipaddres!="0.0.0.0") && ($ipaddres!="::") && !preg_match('/^fe80::/i', $ipaddres)) |
389
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ipaddres)); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
break; |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) { |
396
|
|
|
$speedinfo = null; |
397
|
|
|
foreach ($allNetworkAdapter as $NetworkAdapter) { |
398
|
|
|
if ($ar_name[1]==$NetworkAdapter['GUID']) { |
399
|
|
View Code Duplication |
if (!empty($NetworkAdapter['Speed']) && ($NetworkAdapter['Speed']!=="9223372036854775807")) { |
|
|
|
|
400
|
|
|
if ($NetworkAdapter['Speed'] > 1000000000) { |
401
|
|
|
$speedinfo = ($NetworkAdapter['Speed']/1000000000)."Gb/s"; |
402
|
|
|
} else { |
403
|
|
|
$speedinfo = ($NetworkAdapter['Speed']/1000000)."Mb/s"; |
404
|
|
|
} |
405
|
|
|
} |
406
|
|
|
break; |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
View Code Duplication |
if (($speedinfo !== null) && ($speedinfo !== "")) { |
|
|
|
|
410
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo); |
411
|
|
|
} elseif (($speedinfo = $device['CurrentBandwidth']) >= 1000000) { |
412
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').($speedinfo/1000000)."Mb/s"); |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
if ($dev->getName() == "") { //no isatap or no isatap description |
417
|
|
|
$cname=preg_replace('/[^A-Za-z0-9]/', '_', $name); //convert to canonical |
418
|
|
|
if (preg_match('/\s-\s([^-]*)$/', $name, $ar_name)) |
419
|
|
|
$name=substr($name, 0, strlen($name)-strlen($ar_name[0])); |
420
|
|
|
$dev->setName($name); |
421
|
|
|
|
422
|
|
|
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) { |
423
|
|
|
foreach ($allNetworkAdapterConfigurations as $NetworkAdapterConfiguration) { |
424
|
|
|
if (preg_replace('/[^A-Za-z0-9]/', '_', $NetworkAdapterConfiguration['Description']) === $cname) { |
425
|
|
|
if ($dev->getInfo() !== null) { |
426
|
|
|
$dev->setInfo(''); //multiple with the same name |
427
|
|
|
} else { |
428
|
|
|
$dev->setInfo(preg_replace('/:/', '-', strtoupper($NetworkAdapterConfiguration['MACAddress']))); |
429
|
|
View Code Duplication |
if (isset($NetworkAdapterConfiguration['IPAddress'])) |
|
|
|
|
430
|
|
|
foreach($NetworkAdapterConfiguration['IPAddress'] as $ipaddres) |
431
|
|
|
if (($ipaddres!="0.0.0.0") && !preg_match('/^fe80::/i', $ipaddres)) |
432
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ipaddres)); |
433
|
|
|
} |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
$speedinfo = null; |
437
|
|
|
foreach ($allNetworkAdapter as $NetworkAdapter) { |
438
|
|
|
if (preg_replace('/[^A-Za-z0-9]/', '_', $NetworkAdapter['Name']) === $cname) { |
439
|
|
|
if ($speedinfo !== null) { |
440
|
|
|
$speedinfo = ""; //multiple with the same name |
441
|
|
View Code Duplication |
} else { |
|
|
|
|
442
|
|
|
if (!empty($NetworkAdapter['Speed']) && ($NetworkAdapter['Speed']!=="9223372036854775807")) { |
443
|
|
|
if ($NetworkAdapter['Speed'] > 1000000000) { |
444
|
|
|
$speedinfo = ($NetworkAdapter['Speed']/1000000000)."Gb/s"; |
445
|
|
|
} else { |
446
|
|
|
$speedinfo = ($NetworkAdapter['Speed']/1000000)."Mb/s"; |
447
|
|
|
} |
448
|
|
|
} else { |
449
|
|
|
$speedinfo = ""; |
450
|
|
|
} |
451
|
|
|
} |
452
|
|
|
} |
453
|
|
|
} |
454
|
|
View Code Duplication |
if (($speedinfo !== null) && ($speedinfo !== "")) { |
|
|
|
|
455
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo); |
456
|
|
|
} elseif (($speedinfo = $device['CurrentBandwidth']) >= 1000000) { |
457
|
|
|
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').($speedinfo/1000000)."Mb/s"); |
458
|
|
|
} |
459
|
|
|
} |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfrawdata_tcpip_networkinterface.asp |
463
|
|
|
// there is a possible bug in the wmi interfaceabout uint32 and uint64: http://www.ureader.com/message/1244948.aspx, so that |
464
|
|
|
// magative numbers would occour, try to calculate the nagative value from total - positive number |
465
|
|
|
$txbytes = $device['BytesSentPersec']; |
466
|
|
|
$rxbytes = $device['BytesReceivedPersec']; |
467
|
|
|
if (($txbytes < 0) && ($rxbytes < 0)) { |
468
|
|
|
$txbytes += 4294967296; |
469
|
|
|
$rxbytes += 4294967296; |
470
|
|
|
} elseif ($txbytes < 0) { |
471
|
|
View Code Duplication |
if ($device['BytesTotalPersec'] > $rxbytes) |
|
|
|
|
472
|
|
|
$txbytes = $device['BytesTotalPersec'] - $rxbytes; |
473
|
|
|
else |
474
|
|
|
$txbytes += 4294967296; |
475
|
|
|
} elseif ($rxbytes < 0) { |
476
|
|
View Code Duplication |
if ($device['BytesTotalPersec'] > $txbytes) |
|
|
|
|
477
|
|
|
$rxbytes = $device['BytesTotalPersec'] - $txbytes; |
478
|
|
|
else |
479
|
|
|
$rxbytes += 4294967296; |
480
|
|
|
} |
481
|
|
|
$dev->setTxBytes($txbytes); |
482
|
|
|
$dev->setRxBytes($rxbytes); |
483
|
|
|
$dev->setErrors($device['PacketsReceivedErrors']); |
484
|
|
|
$dev->setDrops($device['PacketsReceivedDiscarded']); |
485
|
|
|
|
486
|
|
|
$this->sys->setNetDevices($dev); |
487
|
|
|
} |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* Physical memory information and Swap Space information |
492
|
|
|
* |
493
|
|
|
* @link http://msdn2.microsoft.com/En-US/library/aa394239.aspx |
494
|
|
|
* @link http://msdn2.microsoft.com/en-us/library/aa394246.aspx |
495
|
|
|
* @return void |
496
|
|
|
*/ |
497
|
|
|
private function _memory() |
498
|
|
|
{ |
499
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, "Win32_OperatingSystem", array('TotalVisibleMemorySize', 'FreePhysicalMemory')); |
500
|
|
|
if ($buffer) { |
|
|
|
|
501
|
|
|
$this->sys->setMemTotal($buffer[0]['TotalVisibleMemorySize'] * 1024); |
502
|
|
|
$this->sys->setMemFree($buffer[0]['FreePhysicalMemory'] * 1024); |
503
|
|
|
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree()); |
504
|
|
|
} |
505
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PageFileUsage'); |
506
|
|
|
foreach ($buffer as $swapdevice) { |
507
|
|
|
$dev = new DiskDevice(); |
508
|
|
|
$dev->setName("SWAP"); |
509
|
|
|
$dev->setMountPoint($swapdevice['Name']); |
510
|
|
|
$dev->setTotal($swapdevice['AllocatedBaseSize'] * 1024 * 1024); |
511
|
|
|
$dev->setUsed($swapdevice['CurrentUsage'] * 1024 * 1024); |
512
|
|
|
$dev->setFree($dev->getTotal() - $dev->getUsed()); |
513
|
|
|
$dev->setFsType('swap'); |
514
|
|
|
$this->sys->setSwapDevices($dev); |
515
|
|
|
} |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
/** |
519
|
|
|
* filesystem information |
520
|
|
|
* |
521
|
|
|
* @return void |
522
|
|
|
*/ |
523
|
|
|
private function _filesystems() |
524
|
|
|
{ |
525
|
|
|
$typearray = array('Unknown', 'No Root Directory', 'Removable Disk', 'Local Disk', 'Network Drive', 'Compact Disc', 'RAM Disk'); |
526
|
|
|
$floppyarray = array('Unknown', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', '5 1/4 in.', 'Other', 'HD', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '5 1/4 in.', '3 1/2 in.', '3 1/2 in.', '8 in.'); |
527
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType')); |
528
|
|
|
foreach ($buffer as $filesystem) { |
529
|
|
|
$dev = new DiskDevice(); |
530
|
|
|
$dev->setMountPoint($filesystem['Name']); |
531
|
|
|
$dev->setFsType($filesystem['FileSystem']); |
532
|
|
|
if ($filesystem['Size'] > 0) { |
533
|
|
|
$dev->setTotal($filesystem['Size']); |
534
|
|
|
$dev->setFree($filesystem['FreeSpace']); |
535
|
|
|
$dev->setUsed($filesystem['Size'] - $filesystem['FreeSpace']); |
536
|
|
|
} |
537
|
|
|
if ($filesystem['MediaType'] != "" && $filesystem['DriveType'] == 2) { |
538
|
|
|
$dev->setName($typearray[$filesystem['DriveType']]." (".$floppyarray[$filesystem['MediaType']].")"); |
539
|
|
|
} else { |
540
|
|
|
$dev->setName($typearray[$filesystem['DriveType']]); |
541
|
|
|
} |
542
|
|
|
$this->sys->setDiskDevices($dev); |
543
|
|
|
} |
544
|
|
|
if (!$buffer && ($this->sys->getDistribution()=="ReactOS")) { |
|
|
|
|
545
|
|
|
// test for command 'free' on current disk |
546
|
|
|
if (CommonFunctions::executeProgram("cmd", "/c free 2>nul", $out_value, true)) { |
547
|
|
|
for ($letter='A'; $letter!='AA'; $letter++) if (CommonFunctions::executeProgram("cmd", "/c free ".$letter.": 2>nul", $out_value, false)) { |
548
|
|
|
if (preg_match('/\n\s*([\d\.\,]+).*\n\s*([\d\.\,]+).*\n\s*([\d\.\,]+).*$/', $out_value, $out_dig)) { |
549
|
|
|
$size = preg_replace('/(\.)|(\,)/', '', $out_dig[1]); |
550
|
|
|
$used = preg_replace('/(\.)|(\,)/', '', $out_dig[2]); |
551
|
|
|
$free = preg_replace('/(\.)|(\,)/', '', $out_dig[3]); |
552
|
|
|
if ($used + $free == $size) { |
553
|
|
|
$dev = new DiskDevice(); |
554
|
|
|
$dev->setMountPoint($letter.":"); |
555
|
|
|
$dev->setFsType('Unknown'); |
556
|
|
|
$dev->setTotal($size); |
557
|
|
|
$dev->setFree($free); |
558
|
|
|
$dev->setUsed($used); |
559
|
|
|
$this->sys->setDiskDevices($dev); |
560
|
|
|
} |
561
|
|
|
} |
562
|
|
|
} |
563
|
|
|
} |
564
|
|
|
} |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* get os specific encoding |
569
|
|
|
* |
570
|
|
|
* @see OS::getEncoding() |
571
|
|
|
* |
572
|
|
|
* @return string |
573
|
|
|
*/ |
574
|
|
|
public function getEncoding() |
575
|
|
|
{ |
576
|
|
|
return $this->_codepage; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* get os specific language |
581
|
|
|
* |
582
|
|
|
* @see OS::getLanguage() |
583
|
|
|
* |
584
|
|
|
* @return string |
585
|
|
|
*/ |
586
|
|
|
public function getLanguage() |
587
|
|
|
{ |
588
|
|
|
return $this->_syslang; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
public function _processes() |
592
|
|
|
{ |
593
|
|
|
$processes['*'] = 0; |
|
|
|
|
594
|
|
|
if (CommonFunctions::executeProgram("qprocess", "*", $strBuf, false) && (strlen($strBuf) > 0)) { |
595
|
|
|
$lines = preg_split('/\n/', $strBuf); |
596
|
|
|
$processes['*'] = (count($lines)-1) - 3 ; //correction for process "qprocess *" |
597
|
|
|
} |
598
|
|
|
if ($processes['*'] <= 0) { |
599
|
|
|
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption')); |
600
|
|
|
$processes['*'] = count($buffer); |
601
|
|
|
} |
602
|
|
|
$processes[' '] = $processes['*']; |
603
|
|
|
$this->sys->setProcesses($processes); |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* get the information |
609
|
|
|
* |
610
|
|
|
* @see PSI_Interface_OS::build() |
611
|
|
|
* |
612
|
|
|
* @return Void |
613
|
|
|
*/ |
614
|
|
View Code Duplication |
public function build() |
|
|
|
|
615
|
|
|
{ |
616
|
|
|
$this->_distro(); |
617
|
|
|
if ($this->sys->getDistribution()=="ReactOS") { |
618
|
|
|
$this->error->addError("WARN", "The ReactOS version of phpSysInfo is a work in progress, some things currently don't work"); |
619
|
|
|
} |
620
|
|
|
$this->_hostname(); |
621
|
|
|
$this->_users(); |
622
|
|
|
$this->_machine(); |
623
|
|
|
$this->_uptime(); |
624
|
|
|
$this->_cpuinfo(); |
625
|
|
|
$this->_network(); |
626
|
|
|
$this->_hardware(); |
627
|
|
|
$this->_filesystems(); |
628
|
|
|
$this->_memory(); |
629
|
|
|
$this->_loadavg(); |
630
|
|
|
$this->_processes(); |
631
|
|
|
} |
632
|
|
|
} |
633
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.