2770 |
rexy |
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 <BigMichi1@users.sourceforge.net>
|
|
|
10 |
* @copyright 2009 phpSysInfo
|
|
|
11 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
|
|
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 <BigMichi1@users.sourceforge.net>
|
|
|
23 |
* @copyright 2009 phpSysInfo
|
|
|
24 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
|
|
25 |
* @version Release: 3.0
|
|
|
26 |
* @link http://phpsysinfo.sourceforge.net
|
|
|
27 |
*/
|
|
|
28 |
class WINNT extends OS
|
|
|
29 |
{
|
|
|
30 |
/**
|
|
|
31 |
* holds the data from WMI Win32_OperatingSystem
|
|
|
32 |
*
|
|
|
33 |
* @var array
|
|
|
34 |
*/
|
|
|
35 |
private $_Win32_OperatingSystem = null;
|
325 |
richard |
36 |
|
2770 |
rexy |
37 |
/**
|
|
|
38 |
* holds the data from WMI Win32_ComputerSystem
|
|
|
39 |
*
|
|
|
40 |
* @var array
|
|
|
41 |
*/
|
|
|
42 |
private $_Win32_ComputerSystem = null;
|
325 |
richard |
43 |
|
2770 |
rexy |
44 |
/**
|
|
|
45 |
* holds the data from WMI Win32_Processor
|
|
|
46 |
*
|
|
|
47 |
* @var array
|
|
|
48 |
*/
|
|
|
49 |
private $_Win32_Processor = null;
|
325 |
richard |
50 |
|
2770 |
rexy |
51 |
/**
|
|
|
52 |
* holds the data from WMI Win32_PerfFormattedData_PerfOS_Processor
|
|
|
53 |
*
|
|
|
54 |
* @var array
|
|
|
55 |
*/
|
|
|
56 |
private $_Win32_PerfFormattedData_PerfOS_Processor = null;
|
325 |
richard |
57 |
|
2770 |
rexy |
58 |
/**
|
|
|
59 |
* holds the data from systeminfo command
|
|
|
60 |
*
|
|
|
61 |
* @var string
|
|
|
62 |
*/
|
|
|
63 |
private $_systeminfo = null;
|
325 |
richard |
64 |
|
2770 |
rexy |
65 |
/**
|
|
|
66 |
* holds the COM object that we pull all the WMI data from
|
|
|
67 |
*
|
|
|
68 |
* @var Object
|
|
|
69 |
*/
|
|
|
70 |
private $_wmi = null;
|
325 |
richard |
71 |
|
2770 |
rexy |
72 |
/**
|
|
|
73 |
* holds the COM object that we pull all the RegRead data from
|
|
|
74 |
*
|
|
|
75 |
* @var Object
|
|
|
76 |
*/
|
|
|
77 |
private $_reg = null;
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* holds the COM object that we pull all the EnumKey data from
|
|
|
81 |
*
|
|
|
82 |
* @var Object
|
|
|
83 |
*/
|
|
|
84 |
private $_key = null;
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* holds all devices, which are in the system
|
|
|
88 |
*
|
|
|
89 |
* @var array
|
|
|
90 |
*/
|
|
|
91 |
private $_wmidevices;
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* holds all disks, which are in the system
|
|
|
95 |
*
|
|
|
96 |
* @var array
|
|
|
97 |
*/
|
|
|
98 |
private $_wmidisks;
|
|
|
99 |
|
|
|
100 |
/**
|
|
|
101 |
* store language encoding of the system to convert some output to utf-8
|
|
|
102 |
*
|
|
|
103 |
* @var string
|
|
|
104 |
*/
|
|
|
105 |
private $_codepage = null;
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* store language of the system
|
|
|
109 |
*
|
|
|
110 |
* @var string
|
|
|
111 |
*/
|
|
|
112 |
private $_syslang = null;
|
|
|
113 |
|
|
|
114 |
/**
|
|
|
115 |
* reads the data from WMI Win32_OperatingSystem
|
|
|
116 |
*
|
|
|
117 |
* @return array
|
|
|
118 |
*/
|
|
|
119 |
private function _get_Win32_OperatingSystem()
|
|
|
120 |
{
|
|
|
121 |
if ($this->_Win32_OperatingSystem === null) $this->_Win32_OperatingSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_OperatingSystem', array('CodeSet', 'Locale', 'LastBootUpTime', 'LocalDateTime', 'Version', 'ServicePackMajorVersion', 'Caption', 'OSArchitecture', 'TotalVisibleMemorySize', 'FreePhysicalMemory'));
|
|
|
122 |
return $this->_Win32_OperatingSystem;
|
325 |
richard |
123 |
}
|
|
|
124 |
|
2770 |
rexy |
125 |
/**
|
|
|
126 |
* reads the data from WMI Win32_ComputerSystem
|
|
|
127 |
*
|
|
|
128 |
* @return array
|
|
|
129 |
*/
|
|
|
130 |
private function _get_Win32_ComputerSystem()
|
325 |
richard |
131 |
{
|
2770 |
rexy |
132 |
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model'));
|
|
|
133 |
return $this->_Win32_ComputerSystem;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
/**
|
|
|
137 |
* reads the data from WMI Win32_Processor
|
|
|
138 |
*
|
|
|
139 |
* @return array
|
|
|
140 |
*/
|
|
|
141 |
private function _get_Win32_Processor()
|
|
|
142 |
{
|
|
|
143 |
if ($this->_Win32_Processor === null) $this->_Win32_Processor = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('LoadPercentage', 'AddressWidth', 'Name', 'L2CacheSize', 'L3CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'NumberOfLogicalProcessors', 'MaxClockSpeed', 'Manufacturer'));
|
|
|
144 |
return $this->_Win32_Processor;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
/**
|
|
|
148 |
* reads the data from WMI Win32_PerfFormattedData_PerfOS_Processor
|
|
|
149 |
*
|
|
|
150 |
* @return array
|
|
|
151 |
*/
|
|
|
152 |
private function _get_Win32_PerfFormattedData_PerfOS_Processor()
|
|
|
153 |
{
|
|
|
154 |
if ($this->_Win32_PerfFormattedData_PerfOS_Processor === null) {
|
|
|
155 |
$this->_Win32_PerfFormattedData_PerfOS_Processor = array();
|
|
|
156 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
157 |
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "5.1", ">=")) { // minimal windows 2003 or windows XP
|
|
|
158 |
$cpubuffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfFormattedData_PerfOS_Processor', array('Name', 'PercentProcessorTime'));
|
|
|
159 |
if ($cpubuffer) foreach ($cpubuffer as $cpu) {
|
|
|
160 |
if (isset($cpu['Name']) && isset($cpu['PercentProcessorTime'])) {
|
|
|
161 |
$this->_Win32_PerfFormattedData_PerfOS_Processor['cpu'.$cpu['Name']] = $cpu['PercentProcessorTime'];
|
|
|
162 |
}
|
|
|
163 |
}
|
325 |
richard |
164 |
}
|
|
|
165 |
}
|
|
|
166 |
|
2770 |
rexy |
167 |
return $this->_Win32_PerfFormattedData_PerfOS_Processor;
|
325 |
richard |
168 |
}
|
|
|
169 |
|
2770 |
rexy |
170 |
/**
|
|
|
171 |
* reads the data from systeminfo
|
|
|
172 |
*
|
|
|
173 |
* @return string
|
|
|
174 |
*/
|
|
|
175 |
private function _get_systeminfo()
|
|
|
176 |
{
|
|
|
177 |
if ($this->_systeminfo === null) CommonFunctions::executeProgram('systeminfo', '', $this->_systeminfo, false);
|
|
|
178 |
return $this->_systeminfo;
|
325 |
richard |
179 |
}
|
|
|
180 |
|
2770 |
rexy |
181 |
/**
|
|
|
182 |
* build the global Error object and create the WMI connection
|
|
|
183 |
*/
|
|
|
184 |
public function __construct($blockname = false)
|
|
|
185 |
{
|
|
|
186 |
parent::__construct($blockname);
|
|
|
187 |
try {
|
|
|
188 |
// initialize the wmi object
|
|
|
189 |
$objLocator = new COM('WbemScripting.SWbemLocator');
|
|
|
190 |
$this->_wmi = $objLocator->ConnectServer('', 'root\CIMv2');
|
|
|
191 |
} catch (Exception $e) {
|
|
|
192 |
$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.");
|
|
|
193 |
}
|
|
|
194 |
try {
|
|
|
195 |
// initialize the RegRead object
|
|
|
196 |
$this->_reg = new COM("WScript.Shell");
|
|
|
197 |
} catch (Exception $e) {
|
|
|
198 |
//$this->error->addError("Windows Scripting Host error", "PhpSysInfo can not initialize Windows Scripting Host for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed.");
|
|
|
199 |
$this->_reg = false;
|
|
|
200 |
}
|
|
|
201 |
try {
|
|
|
202 |
// initialize the EnumKey object
|
|
|
203 |
$this->_key = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv");
|
|
|
204 |
} catch (Exception $e) {
|
|
|
205 |
//$this->error->addError("WWinmgmts Impersonationlevel Script Error", "PhpSysInfo can not initialize Winmgmts Impersonationlevel Script for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed.");
|
|
|
206 |
$this->_key = false;
|
|
|
207 |
}
|
325 |
richard |
208 |
|
2770 |
rexy |
209 |
$this->_getCodeSet();
|
|
|
210 |
}
|
325 |
richard |
211 |
|
2770 |
rexy |
212 |
/**
|
|
|
213 |
* store the codepage of the os for converting some strings to utf-8
|
|
|
214 |
*
|
|
|
215 |
* @return void
|
|
|
216 |
*/
|
|
|
217 |
private function _getCodeSet()
|
|
|
218 |
{
|
|
|
219 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
220 |
if (!$buffer) {
|
|
|
221 |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) {
|
|
|
222 |
$buffer[0]['CodeSet'] = $strBuf;
|
|
|
223 |
}
|
|
|
224 |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Language\\Default", $strBuf, false)) {
|
|
|
225 |
$buffer[0]['Locale'] = $strBuf;
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
if ($buffer && isset($buffer[0])) {
|
|
|
229 |
if (isset($buffer[0]['CodeSet'])) {
|
|
|
230 |
$codeset = $buffer[0]['CodeSet'];
|
|
|
231 |
if ($codeset == 932) {
|
|
|
232 |
$codename = ' (SJIS)';
|
|
|
233 |
} elseif ($codeset == 949) {
|
|
|
234 |
$codename = ' (EUC-KR)';
|
|
|
235 |
} elseif ($codeset == 950) {
|
|
|
236 |
$codename = ' (BIG-5)';
|
|
|
237 |
} else {
|
|
|
238 |
$codename = '';
|
|
|
239 |
}
|
|
|
240 |
CommonFunctions::setcp($codeset);
|
|
|
241 |
$this->_codepage = 'windows-'.$codeset.$codename;
|
|
|
242 |
}
|
|
|
243 |
if (isset($buffer[0]['Locale']) && (($locale = hexdec($buffer[0]['Locale']))>0)) {
|
|
|
244 |
$lang = "";
|
|
|
245 |
if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
|
|
|
246 |
if (isset($langdata['WINNT'][$locale])) {
|
|
|
247 |
$lang = $langdata['WINNT'][$locale];
|
|
|
248 |
}
|
|
|
249 |
}
|
|
|
250 |
if ($lang == "") {
|
|
|
251 |
$lang = 'Unknown';
|
|
|
252 |
}
|
|
|
253 |
$this->_syslang = $lang.' ('.$locale.')';
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
}
|
325 |
richard |
257 |
|
2770 |
rexy |
258 |
/**
|
|
|
259 |
* retrieve different device types from the system based on selector
|
|
|
260 |
*
|
|
|
261 |
* @param string $strType type of the devices that should be returned
|
|
|
262 |
*
|
|
|
263 |
* @return array list of devices of the specified type
|
|
|
264 |
*/
|
|
|
265 |
private function _devicelist($strType)
|
|
|
266 |
{
|
|
|
267 |
if (empty($this->_wmidevices)) {
|
|
|
268 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
269 |
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID', 'Manufacturer', 'PNPClass'));
|
|
|
270 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
271 |
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size', 'SerialNumber'));
|
|
|
272 |
} else {
|
|
|
273 |
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size'));
|
|
|
274 |
}
|
|
|
275 |
} else {
|
|
|
276 |
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID'));
|
|
|
277 |
$this->_wmidisks = array();
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
$list = array();
|
|
|
281 |
foreach ($this->_wmidevices as $device) {
|
|
|
282 |
if (substr($device['PNPDeviceID'], 0, strpos($device['PNPDeviceID'], "\\") + 1) == ($strType."\\")) {
|
|
|
283 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
284 |
if (!isset($device['PNPClass']) || ($device['PNPClass']===$strType) || ($device['PNPClass']==='System')) {
|
|
|
285 |
$device['PNPClass'] = null;
|
|
|
286 |
}
|
|
|
287 |
if (preg_match('/^\(.*\)$/', $device['Manufacturer'])) {
|
|
|
288 |
$device['Manufacturer'] = null;
|
|
|
289 |
}
|
|
|
290 |
$device['Capacity'] = null;
|
|
|
291 |
if (($strType==='IDE')||($strType==='SCSI')) {
|
|
|
292 |
foreach ($this->_wmidisks as $disk) {
|
|
|
293 |
if (($disk['PNPDeviceID'] === $device['PNPDeviceID']) && isset($disk['Size'])) {
|
|
|
294 |
$device['Capacity'] = $disk['Size'];
|
|
|
295 |
break;
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
$device['Serial'] = null;
|
|
|
300 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
301 |
if ($strType==='USB') {
|
|
|
302 |
if (preg_match('/\\\\(\w+)$/', $device['PNPDeviceID'], $buf)) {
|
|
|
303 |
$device['Serial'] = $buf[1];
|
|
|
304 |
}
|
|
|
305 |
} elseif (($strType==='IDE')||($strType==='SCSI')) {
|
|
|
306 |
foreach ($this->_wmidisks as $disk) {
|
|
|
307 |
if (($disk['PNPDeviceID'] === $device['PNPDeviceID']) && isset($disk['SerialNumber'])) {
|
|
|
308 |
$device['Serial'] = $disk['SerialNumber'];
|
|
|
309 |
break;
|
|
|
310 |
}
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
}
|
|
|
314 |
$list[] = array('Name'=>$device['Name'], 'Manufacturer'=>$device['Manufacturer'], 'Product'=>$device['PNPClass'], 'Capacity'=>$device['Capacity'], 'Serial'=>$device['Serial']);
|
|
|
315 |
} else {
|
|
|
316 |
$list[] = array('Name'=>$device['Name']);
|
|
|
317 |
}
|
|
|
318 |
}
|
|
|
319 |
}
|
325 |
richard |
320 |
|
2770 |
rexy |
321 |
return $list;
|
325 |
richard |
322 |
}
|
|
|
323 |
|
2770 |
rexy |
324 |
/**
|
|
|
325 |
* Host Name
|
|
|
326 |
*
|
|
|
327 |
* @return void
|
|
|
328 |
*/
|
|
|
329 |
private function _hostname()
|
|
|
330 |
{
|
|
|
331 |
if (PSI_USE_VHOST === true) {
|
|
|
332 |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
|
|
333 |
} else {
|
|
|
334 |
$buffer = $this->_get_Win32_ComputerSystem();
|
|
|
335 |
if (!$buffer && CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName\\ComputerName", $strBuf, false) && (strlen($strBuf) > 0)) {
|
|
|
336 |
$buffer[0]['Name'] = $strBuf;
|
|
|
337 |
}
|
|
|
338 |
if ($buffer) {
|
|
|
339 |
$result = $buffer[0]['Name'];
|
|
|
340 |
$ip = gethostbyname($result);
|
|
|
341 |
if ($ip != $result) {
|
|
|
342 |
if ((version_compare("10.0.0.0", $ip, "<=") && version_compare($ip, "10.255.255.255", "<=")) ||
|
|
|
343 |
(version_compare("172.16.0.0", $ip, "<=") && version_compare($ip, "172.31.255.255", "<=")) ||
|
|
|
344 |
(version_compare("192.168.0.0", $ip, "<=") && version_compare($ip, "192.168.255.255", "<=")) ||
|
|
|
345 |
(version_compare("127.0.0.0", $ip, "<=") && version_compare($ip, "127.255.255.255", "<=")) ||
|
|
|
346 |
(version_compare("169.254.1.0", $ip, "<=") && version_compare($ip, "169.254.254.255", "<=")) ||
|
|
|
347 |
(version_compare("255.255.255.255", $ip, "=="))) {
|
|
|
348 |
$this->sys->setHostname($result); // internal ip
|
|
|
349 |
} else {
|
|
|
350 |
$this->sys->setHostname(gethostbyaddr($ip));
|
|
|
351 |
}
|
|
|
352 |
}
|
|
|
353 |
} else {
|
|
|
354 |
if (CommonFunctions::readenv('COMPUTERNAME', $hnm)) $this->sys->setHostname($hnm);
|
|
|
355 |
}
|
|
|
356 |
}
|
|
|
357 |
}
|
325 |
richard |
358 |
|
2770 |
rexy |
359 |
/**
|
|
|
360 |
* UpTime
|
|
|
361 |
* time the system is running
|
|
|
362 |
*
|
|
|
363 |
* @return void
|
|
|
364 |
*/
|
|
|
365 |
private function _uptime()
|
|
|
366 |
{
|
|
|
367 |
$result = 0;
|
|
|
368 |
date_default_timezone_set('UTC');
|
|
|
369 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
370 |
if ($buffer && ($buffer[0]['LastBootUpTime'] !== null)) {
|
|
|
371 |
$local = $buffer[0]['LocalDateTime'];
|
|
|
372 |
$boot = $buffer[0]['LastBootUpTime'];
|
325 |
richard |
373 |
|
2770 |
rexy |
374 |
$lyear = intval(substr($local, 0, 4));
|
|
|
375 |
$lmonth = intval(substr($local, 4, 2));
|
|
|
376 |
$lday = intval(substr($local, 6, 2));
|
|
|
377 |
$lhour = intval(substr($local, 8, 2));
|
|
|
378 |
$lminute = intval(substr($local, 10, 2));
|
|
|
379 |
$lseconds = intval(substr($local, 12, 2));
|
|
|
380 |
$loffset = intval(substr($boot, 21, 4));
|
325 |
richard |
381 |
|
2770 |
rexy |
382 |
$byear = intval(substr($boot, 0, 4));
|
|
|
383 |
$bmonth = intval(substr($boot, 4, 2));
|
|
|
384 |
$bday = intval(substr($boot, 6, 2));
|
|
|
385 |
$bhour = intval(substr($boot, 8, 2));
|
|
|
386 |
$bminute = intval(substr($boot, 10, 2));
|
|
|
387 |
$bseconds = intval(substr($boot, 12, 2));
|
|
|
388 |
$boffset = intval(substr($boot, 21, 4));
|
325 |
richard |
389 |
|
2770 |
rexy |
390 |
if (version_compare($buffer[0]['Version'], "5.1", "<")) { // fix LastBootUpTime on Windows 2000 and older
|
|
|
391 |
$boffset += $boffset;
|
|
|
392 |
}
|
325 |
richard |
393 |
|
2770 |
rexy |
394 |
$localtime = mktime($lhour, $lminute, $lseconds, $lmonth, $lday, $lyear) - $loffset*60;
|
|
|
395 |
$boottime = mktime($bhour, $bminute, $bseconds, $bmonth, $bday, $byear) - $boffset*60;
|
325 |
richard |
396 |
|
2770 |
rexy |
397 |
$result = $localtime - $boottime;
|
325 |
richard |
398 |
|
2770 |
rexy |
399 |
$this->sys->setUptime($result);
|
|
|
400 |
} elseif (($this->sys->getDistribution()=="ReactOS") && CommonFunctions::executeProgram('uptime', '', $strBuf, false) && (strlen($strBuf) > 0) && preg_match("/^System Up Time:\s+(\d+) days, (\d+) Hours, (\d+) Minutes, (\d+) Seconds/", $strBuf, $ar_buf)) {
|
|
|
401 |
$sec = $ar_buf[4];
|
|
|
402 |
$min = $ar_buf[3];
|
|
|
403 |
$hours = $ar_buf[2];
|
|
|
404 |
$days = $ar_buf[1];
|
|
|
405 |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60 + $sec);
|
|
|
406 |
}
|
325 |
richard |
407 |
}
|
2770 |
rexy |
408 |
|
|
|
409 |
/**
|
|
|
410 |
* Number of Users
|
|
|
411 |
*
|
|
|
412 |
* @return void
|
|
|
413 |
*/
|
|
|
414 |
protected function _users()
|
|
|
415 |
{
|
|
|
416 |
if (CommonFunctions::executeProgram('quser', '', $strBuf, false) && (strlen($strBuf) > 0)) {
|
|
|
417 |
$lines = preg_split('/\n/', $strBuf);
|
|
|
418 |
$users = count($lines)-1;
|
|
|
419 |
} else {
|
|
|
420 |
$users = 0;
|
|
|
421 |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
|
|
|
422 |
foreach ($buffer as $process) {
|
|
|
423 |
if (strtoupper($process['Caption']) == strtoupper('explorer.exe')) {
|
|
|
424 |
$users++;
|
|
|
425 |
}
|
|
|
426 |
}
|
|
|
427 |
}
|
|
|
428 |
$this->sys->setUsers($users);
|
325 |
richard |
429 |
}
|
|
|
430 |
|
2770 |
rexy |
431 |
/**
|
|
|
432 |
* Distribution
|
|
|
433 |
*
|
|
|
434 |
* @return void
|
|
|
435 |
*/
|
|
|
436 |
private function _distro()
|
|
|
437 |
{
|
|
|
438 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
439 |
if ($buffer) {
|
|
|
440 |
$ver = $buffer[0]['Version'];
|
|
|
441 |
$kernel = $ver;
|
|
|
442 |
if ($buffer[0]['ServicePackMajorVersion'] > 0) {
|
|
|
443 |
$kernel .= ' SP'.$buffer[0]['ServicePackMajorVersion'];
|
|
|
444 |
}
|
|
|
445 |
if (isset($buffer[0]['OSArchitecture']) && preg_match("/^(\d+)/", $buffer[0]['OSArchitecture'], $bits)) {
|
|
|
446 |
$this->sys->setKernel($kernel.' ('.$bits[1].'-bit)');
|
|
|
447 |
} elseif (($allCpus = $this->_get_Win32_Processor()) && isset($allCpus[0]['AddressWidth'])) {
|
|
|
448 |
$this->sys->setKernel($kernel.' ('.$allCpus[0]['AddressWidth'].'-bit)');
|
|
|
449 |
} else {
|
|
|
450 |
$this->sys->setKernel($kernel);
|
|
|
451 |
}
|
|
|
452 |
$this->sys->setDistribution($buffer[0]['Caption']);
|
325 |
richard |
453 |
|
2770 |
rexy |
454 |
if (version_compare($ver, "5.1", "<"))
|
|
|
455 |
$icon = 'Win2000.png';
|
|
|
456 |
elseif (version_compare($ver, "5.1", ">=") && version_compare($ver, "6.0", "<"))
|
|
|
457 |
$icon = 'WinXP.png';
|
|
|
458 |
elseif (version_compare($ver, "6.0", ">=") && version_compare($ver, "6.2", "<"))
|
|
|
459 |
$icon = 'WinVista.png';
|
|
|
460 |
else
|
|
|
461 |
$icon = 'Win8.png';
|
|
|
462 |
$this->sys->setDistributionIcon($icon);
|
|
|
463 |
} elseif (CommonFunctions::executeProgram('cmd', '/c ver 2>nul', $ver_value, false)) {
|
|
|
464 |
if (preg_match("/ReactOS\r?\nVersion\s+(.+)/", $ver_value, $ar_temp)) {
|
|
|
465 |
$this->sys->setDistribution("ReactOS");
|
|
|
466 |
$this->sys->setKernel($ar_temp[1]);
|
|
|
467 |
$this->sys->setDistributionIcon('ReactOS.png');
|
|
|
468 |
$this->_wmi = false; // No WMI info on ReactOS yet
|
|
|
469 |
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*(.+)\]/", $ver_value, $ar_temp)) {
|
|
|
470 |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false) && (strlen($strBuf) > 0)) {
|
|
|
471 |
if (preg_match("/^Microsoft /", $strBuf)) {
|
|
|
472 |
$this->sys->setDistribution($strBuf);
|
|
|
473 |
} else {
|
|
|
474 |
$this->sys->setDistribution("Microsoft ".$strBuf);
|
|
|
475 |
}
|
|
|
476 |
} else {
|
|
|
477 |
$this->sys->setDistribution($ar_temp[1]);
|
|
|
478 |
}
|
|
|
479 |
$kernel = $ar_temp[2];
|
|
|
480 |
$this->sys->setKernel($kernel);
|
|
|
481 |
if ((($kernel[1] == '.') && ($kernel[0] <5)) || (substr($kernel, 0, 4) == '5.0.'))
|
|
|
482 |
$icon = 'Win2000.png';
|
|
|
483 |
elseif ((substr($kernel, 0, 4) == '6.0.') || (substr($kernel, 0, 4) == '6.1.'))
|
|
|
484 |
$icon = 'WinVista.png';
|
|
|
485 |
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.'))
|
|
|
486 |
$icon = 'Win8.png';
|
|
|
487 |
else
|
|
|
488 |
$icon = 'WinXP.png';
|
|
|
489 |
$this->sys->setDistributionIcon($icon);
|
|
|
490 |
} else {
|
|
|
491 |
$this->sys->setDistribution("WinNT");
|
|
|
492 |
$this->sys->setDistributionIcon('Win2000.png');
|
|
|
493 |
}
|
|
|
494 |
} else {
|
|
|
495 |
$this->sys->setDistribution("WinNT");
|
|
|
496 |
$this->sys->setDistributionIcon('Win2000.png');
|
|
|
497 |
}
|
|
|
498 |
}
|
325 |
richard |
499 |
|
2770 |
rexy |
500 |
/**
|
|
|
501 |
* Processor Load
|
|
|
502 |
* optionally create a loadbar
|
|
|
503 |
*
|
|
|
504 |
* @return void
|
|
|
505 |
*/
|
|
|
506 |
private function _loadavg()
|
|
|
507 |
{
|
|
|
508 |
if (($cpubuffer = $this->_get_Win32_PerfFormattedData_PerfOS_Processor()) && isset($cpubuffer['cpu_Total'])) {
|
|
|
509 |
$this->sys->setLoad($cpubuffer['cpu_Total']);
|
|
|
510 |
if (PSI_LOAD_BAR) {
|
|
|
511 |
$this->sys->setLoadPercent($cpubuffer['cpu_Total']);
|
|
|
512 |
}
|
|
|
513 |
} elseif ($buffer = $this->_get_Win32_Processor()) {
|
|
|
514 |
$loadok = true;
|
|
|
515 |
$sum = 0;
|
|
|
516 |
foreach ($buffer as $load) {
|
|
|
517 |
$value = $load['LoadPercentage'];
|
|
|
518 |
if ($value !== null) {
|
|
|
519 |
$sum += $value;
|
|
|
520 |
} else {
|
|
|
521 |
$loadok = false;
|
|
|
522 |
break;
|
|
|
523 |
}
|
|
|
524 |
}
|
|
|
525 |
if ($loadok) {
|
|
|
526 |
$percent = $sum / count($buffer);
|
|
|
527 |
$this->sys->setLoad($percent);
|
|
|
528 |
if (PSI_LOAD_BAR) {
|
|
|
529 |
$this->sys->setLoadPercent($percent);
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
}
|
325 |
richard |
534 |
|
2770 |
rexy |
535 |
/**
|
|
|
536 |
* CPU information
|
|
|
537 |
*
|
|
|
538 |
* @return void
|
|
|
539 |
*/
|
|
|
540 |
private function _cpuinfo()
|
|
|
541 |
{
|
|
|
542 |
$allCpus = $this->_get_Win32_Processor();
|
|
|
543 |
if (!$allCpus) {
|
|
|
544 |
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor";
|
|
|
545 |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) {
|
|
|
546 |
foreach ($arrBuf as $coreCount) {
|
|
|
547 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) {
|
|
|
548 |
$allCpus[$coreCount]['Name'] = $strBuf;
|
|
|
549 |
}
|
|
|
550 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\~MHz", $strBuf, false)) {
|
|
|
551 |
if (preg_match("/^0x([0-9a-f]+)$/i", $strBuf, $hexvalue)) {
|
|
|
552 |
$allCpus[$coreCount]['CurrentClockSpeed'] = hexdec($hexvalue[1]);
|
|
|
553 |
}
|
|
|
554 |
}
|
|
|
555 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\VendorIdentifier", $strBuf, false)) {
|
|
|
556 |
$allCpus[$coreCount]['Manufacturer'] = $strBuf;
|
|
|
557 |
}
|
|
|
558 |
}
|
|
|
559 |
}
|
|
|
560 |
}
|
325 |
richard |
561 |
|
2770 |
rexy |
562 |
$globalcpus = 0;
|
|
|
563 |
foreach ($allCpus as $oneCpu) {
|
|
|
564 |
$cpuCount = 1;
|
|
|
565 |
if (isset($oneCpu['NumberOfLogicalProcessors'])) {
|
|
|
566 |
$cpuCount = $oneCpu['NumberOfLogicalProcessors'];
|
|
|
567 |
} elseif (isset($oneCpu['NumberOfCores'])) {
|
|
|
568 |
$cpuCount = $oneCpu['NumberOfCores'];
|
|
|
569 |
}
|
|
|
570 |
$globalcpus+=$cpuCount;
|
|
|
571 |
}
|
325 |
richard |
572 |
|
2770 |
rexy |
573 |
foreach ($allCpus as $oneCpu) {
|
|
|
574 |
$cpuCount = 1;
|
|
|
575 |
if (isset($oneCpu['NumberOfLogicalProcessors'])) {
|
|
|
576 |
$cpuCount = $oneCpu['NumberOfLogicalProcessors'];
|
|
|
577 |
} elseif (isset($oneCpu['NumberOfCores'])) {
|
|
|
578 |
$cpuCount = $oneCpu['NumberOfCores'];
|
|
|
579 |
}
|
|
|
580 |
for ($i = 0; $i < $cpuCount; $i++) {
|
|
|
581 |
$cpu = new CpuDevice();
|
|
|
582 |
if (isset($oneCpu['Name'])) $cpu->setModel($oneCpu['Name']);
|
|
|
583 |
if (isset($oneCpu['L3CacheSize']) && ($oneCpu['L3CacheSize'] > 0)) {
|
|
|
584 |
$cpu->setCache($oneCpu['L3CacheSize'] * 1024);
|
|
|
585 |
} elseif (isset($oneCpu['L2CacheSize'])) {
|
|
|
586 |
$cpu->setCache($oneCpu['L2CacheSize'] * 1024);
|
|
|
587 |
}
|
|
|
588 |
if (isset($oneCpu['CurrentClockSpeed'])) {
|
|
|
589 |
$cpu->setCpuSpeed($oneCpu['CurrentClockSpeed']);
|
|
|
590 |
if (isset($oneCpu['MaxClockSpeed']) && ($oneCpu['CurrentClockSpeed'] < $oneCpu['MaxClockSpeed'])) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']);
|
|
|
591 |
}
|
|
|
592 |
if (isset($oneCpu['ExtClock'])) $cpu->setBusSpeed($oneCpu['ExtClock']);
|
|
|
593 |
if (isset($oneCpu['Manufacturer'])) $cpu->setVendorId($oneCpu['Manufacturer']);
|
|
|
594 |
if (PSI_LOAD_BAR) {
|
|
|
595 |
if (($cpubuffer = $this->_get_Win32_PerfFormattedData_PerfOS_Processor()) && (count($cpubuffer) == ($globalcpus+1)) && isset($cpubuffer['cpu'.$i])) {
|
|
|
596 |
$cpu->setLoad($cpubuffer['cpu'.$i]);
|
|
|
597 |
} elseif ((count($allCpus) == $globalcpus) && isset($oneCpu['LoadPercentage'])) {
|
|
|
598 |
$cpu->setLoad($oneCpu['LoadPercentage']);
|
|
|
599 |
}
|
|
|
600 |
}
|
|
|
601 |
$this->sys->setCpus($cpu);
|
|
|
602 |
}
|
|
|
603 |
}
|
|
|
604 |
}
|
325 |
richard |
605 |
|
2770 |
rexy |
606 |
/**
|
|
|
607 |
* Machine information
|
|
|
608 |
*
|
|
|
609 |
* @return void
|
|
|
610 |
*/
|
|
|
611 |
private function _machine()
|
|
|
612 |
{
|
|
|
613 |
$buffer = $this->_get_Win32_ComputerSystem();
|
|
|
614 |
if ($buffer) {
|
|
|
615 |
$buf = "";
|
|
|
616 |
if (isset($buffer[0]['Manufacturer']) && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=$buffer[0]['Manufacturer'])) {
|
|
|
617 |
$buf .= ' '.$buf2;
|
|
|
618 |
}
|
325 |
richard |
619 |
|
2770 |
rexy |
620 |
if (isset($buffer[0]['Model']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=$buffer[0]['Model'])) {
|
|
|
621 |
$buf .= ' '.$buf2;
|
|
|
622 |
}
|
|
|
623 |
if (trim($buf) != "") {
|
|
|
624 |
$this->sys->setMachine(trim($buf));
|
|
|
625 |
}
|
|
|
626 |
}
|
|
|
627 |
}
|
325 |
richard |
628 |
|
2770 |
rexy |
629 |
/**
|
|
|
630 |
* Hardwaredevices
|
|
|
631 |
*
|
|
|
632 |
* @return void
|
|
|
633 |
*/
|
|
|
634 |
private function _hardware()
|
|
|
635 |
{
|
|
|
636 |
foreach ($this->_devicelist('PCI') as $pciDev) {
|
|
|
637 |
$dev = new HWDevice();
|
|
|
638 |
$dev->setName($pciDev['Name']);
|
|
|
639 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
640 |
$dev->setManufacturer($pciDev['Manufacturer']);
|
|
|
641 |
$dev->setProduct($pciDev['Product']);
|
|
|
642 |
}
|
|
|
643 |
$this->sys->setPciDevices($dev);
|
|
|
644 |
}
|
325 |
richard |
645 |
|
2770 |
rexy |
646 |
foreach ($this->_devicelist('IDE') as $ideDev) {
|
|
|
647 |
$dev = new HWDevice();
|
|
|
648 |
$dev->setName($ideDev['Name']);
|
|
|
649 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
650 |
$dev->setCapacity($ideDev['Capacity']);
|
|
|
651 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
652 |
$dev->setSerial($ideDev['Serial']);
|
|
|
653 |
}
|
|
|
654 |
}
|
|
|
655 |
$this->sys->setIdeDevices($dev);
|
|
|
656 |
}
|
325 |
richard |
657 |
|
2770 |
rexy |
658 |
foreach ($this->_devicelist('SCSI') as $scsiDev) {
|
|
|
659 |
$dev = new HWDevice();
|
|
|
660 |
$dev->setName($scsiDev['Name']);
|
|
|
661 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
662 |
$dev->setCapacity($scsiDev['Capacity']);
|
|
|
663 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
664 |
$dev->setSerial($scsiDev['Serial']);
|
|
|
665 |
}
|
|
|
666 |
}
|
|
|
667 |
$this->sys->setScsiDevices($dev);
|
|
|
668 |
}
|
325 |
richard |
669 |
|
2770 |
rexy |
670 |
foreach ($this->_devicelist('USB') as $usbDev) {
|
|
|
671 |
$dev = new HWDevice();
|
|
|
672 |
$dev->setName($usbDev['Name']);
|
|
|
673 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
674 |
$dev->setManufacturer($usbDev['Manufacturer']);
|
|
|
675 |
$dev->setProduct($usbDev['Product']);
|
|
|
676 |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
677 |
$dev->setSerial($usbDev['Serial']);
|
|
|
678 |
}
|
|
|
679 |
}
|
|
|
680 |
$this->sys->setUsbDevices($dev);
|
|
|
681 |
}
|
|
|
682 |
}
|
325 |
richard |
683 |
|
2770 |
rexy |
684 |
/**
|
|
|
685 |
* Network devices
|
|
|
686 |
*
|
|
|
687 |
* @return void
|
|
|
688 |
*/
|
|
|
689 |
private function _network()
|
|
|
690 |
{
|
|
|
691 |
if ($this->_wmi) {
|
|
|
692 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
693 |
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "6.2", ">=")) { // minimal windows 2012 or windows 8
|
|
|
694 |
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkAdapter', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
|
|
|
695 |
} else {
|
|
|
696 |
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
|
|
|
697 |
}
|
|
|
698 |
if ($allDevices) {
|
|
|
699 |
$aliases = array();
|
|
|
700 |
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
|
|
|
701 |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) {
|
|
|
702 |
foreach ($arrBuf as $netID) {
|
|
|
703 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) { //a w Name jest net alias
|
|
|
704 |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$strInstanceID."\\FriendlyName", $strName, false)) {
|
|
|
705 |
$cname = str_replace(array('(', ')', '#'), array('[', ']', '_'), $strName); //convert to canonical
|
|
|
706 |
if (!isset($aliases[$cname])) { // duplicate checking
|
|
|
707 |
$aliases[$cname]['id'] = $netID;
|
|
|
708 |
$aliases[$cname]['name'] = $strName;
|
|
|
709 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\Name", $strCName, false)
|
|
|
710 |
&& (str_replace(array('(', ')', '#'), array('[', ']', '_'), $strCName) !== $cname)) {
|
|
|
711 |
$aliases[$cname]['netname'] = $strCName;
|
|
|
712 |
}
|
|
|
713 |
} else {
|
|
|
714 |
$aliases[$cname]['id'] = '';
|
|
|
715 |
}
|
|
|
716 |
}
|
|
|
717 |
}
|
|
|
718 |
}
|
|
|
719 |
}
|
325 |
richard |
720 |
|
2770 |
rexy |
721 |
$aliases2 = array();
|
|
|
722 |
$hkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards";
|
|
|
723 |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) {
|
|
|
724 |
foreach ($arrBuf as $netCount) {
|
|
|
725 |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\Description", $strName, false)
|
|
|
726 |
&& CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\ServiceName", $strGUID, false)) {
|
|
|
727 |
$cname = str_replace(array('(', ')', '#'), array('[', ']', '_'), $strName); //convert to canonical
|
|
|
728 |
if (!isset($aliases2[$cname])) { // duplicate checking
|
|
|
729 |
$aliases2[$cname]['id'] = $strGUID;
|
|
|
730 |
$aliases2[$cname]['name'] = $strName;
|
|
|
731 |
} else {
|
|
|
732 |
$aliases2[$cname]['id'] = '';
|
|
|
733 |
}
|
|
|
734 |
}
|
|
|
735 |
}
|
|
|
736 |
}
|
325 |
richard |
737 |
|
2770 |
rexy |
738 |
$allNetworkAdapterConfigurations = CommonFunctions::getWMI($this->_wmi, 'Win32_NetworkAdapterConfiguration', array('SettingID', /*'Description',*/ 'MACAddress', 'IPAddress'));
|
|
|
739 |
foreach ($allDevices as $device) if (!preg_match('/^WAN Miniport \[/', $device['Name'])) {
|
|
|
740 |
$dev = new NetDevice();
|
|
|
741 |
$name = $device['Name'];
|
325 |
richard |
742 |
|
2770 |
rexy |
743 |
if (preg_match('/^isatap\.({[A-Fa-f0-9\-]*})/', $name)) {
|
|
|
744 |
$dev->setName("Microsoft ISATAP Adapter");
|
|
|
745 |
} else {
|
|
|
746 |
if (preg_match('/\s-\s([^-]*)$/', $name, $ar_name)) {
|
|
|
747 |
$name=substr($name, 0, strlen($name)-strlen($ar_name[0]));
|
|
|
748 |
}
|
|
|
749 |
$dev->setName($name);
|
|
|
750 |
}
|
325 |
richard |
751 |
|
2770 |
rexy |
752 |
$macexist = false;
|
|
|
753 |
if (((($ali=$aliases) && isset($ali[$name])) || (($ali=$aliases2) && isset($ali[$name]))) && isset($ali[$name]['id']) && ($ali[$name]['id'] !== "")) {
|
|
|
754 |
foreach ($allNetworkAdapterConfigurations as $NetworkAdapterConfiguration) {
|
|
|
755 |
if ($ali[$name]['id']==$NetworkAdapterConfiguration['SettingID']) {
|
|
|
756 |
$mininame = $ali[$name]['name'];
|
|
|
757 |
if (preg_match('/^isatap\.({[A-Fa-f0-9\-]*})/', $mininame))
|
|
|
758 |
$mininame="Microsoft ISATAP Adapter";
|
|
|
759 |
elseif (preg_match('/\s-\s([^-]*)$/', $mininame, $ar_name))
|
|
|
760 |
$name=substr($mininame, 0, strlen($mininame)-strlen($ar_name[0]));
|
|
|
761 |
$dev->setName($mininame);
|
|
|
762 |
if (trim($NetworkAdapterConfiguration['MACAddress']) !== "") $macexist = true;
|
|
|
763 |
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) {
|
|
|
764 |
if (isset($ali[$name]['netname'])) $dev->setInfo(str_replace(';', ':', $ali[$name]['netname']));
|
|
|
765 |
if ((!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR)
|
|
|
766 |
&& (trim($NetworkAdapterConfiguration['MACAddress']) !== "")) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').str_replace(':', '-', strtoupper($NetworkAdapterConfiguration['MACAddress'])));
|
|
|
767 |
if (isset($NetworkAdapterConfiguration['IPAddress']))
|
|
|
768 |
foreach ($NetworkAdapterConfiguration['IPAddress'] as $ipaddres)
|
|
|
769 |
if (($ipaddres != "0.0.0.0") && ($ipaddres != "::") && !preg_match('/^fe80::/i', $ipaddres))
|
|
|
770 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ipaddres));
|
|
|
771 |
}
|
325 |
richard |
772 |
|
2770 |
rexy |
773 |
break;
|
|
|
774 |
}
|
|
|
775 |
}
|
|
|
776 |
}
|
|
|
777 |
|
|
|
778 |
if ($macexist
|
|
|
779 |
// || ($device['CurrentBandwidth'] >= 1000000)
|
|
|
780 |
|| ($device['BytesTotalPersec'] != 0)
|
|
|
781 |
|| ($device['BytesSentPersec'] != 0)
|
|
|
782 |
|| ($device['BytesReceivedPersec'] != 0)
|
|
|
783 |
|| ($device['PacketsReceivedErrors'] != 0)
|
|
|
784 |
|| ($device['PacketsReceivedDiscarded'] != 0)) { // hide unused
|
|
|
785 |
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) {
|
|
|
786 |
if (($speedinfo = $device['CurrentBandwidth']) >= 1000000) {
|
|
|
787 |
if ($speedinfo > 1000000000) {
|
|
|
788 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').round($speedinfo/1000000000, 2)."Gb/s");
|
|
|
789 |
} else {
|
|
|
790 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').round($speedinfo/1000000, 2)."Mb/s");
|
|
|
791 |
}
|
|
|
792 |
}
|
|
|
793 |
}
|
|
|
794 |
|
|
|
795 |
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfrawdata_tcpip_networkinterface.asp
|
|
|
796 |
// there is a possible bug in the wmi interfaceabout uint32 and uint64: http://www.ureader.com/message/1244948.aspx, so that
|
|
|
797 |
// magative numbers would occour, try to calculate the nagative value from total - positive number
|
|
|
798 |
$txbytes = $device['BytesSentPersec'];
|
|
|
799 |
$rxbytes = $device['BytesReceivedPersec'];
|
|
|
800 |
if (($txbytes < 0) && ($rxbytes < 0)) {
|
|
|
801 |
$txbytes += 4294967296;
|
|
|
802 |
$rxbytes += 4294967296;
|
|
|
803 |
} elseif ($txbytes < 0) {
|
|
|
804 |
if ($device['BytesTotalPersec'] > $rxbytes)
|
|
|
805 |
$txbytes = $device['BytesTotalPersec'] - $rxbytes;
|
|
|
806 |
else
|
|
|
807 |
$txbytes += 4294967296;
|
|
|
808 |
} elseif ($rxbytes < 0) {
|
|
|
809 |
if ($device['BytesTotalPersec'] > $txbytes)
|
|
|
810 |
$rxbytes = $device['BytesTotalPersec'] - $txbytes;
|
|
|
811 |
else
|
|
|
812 |
$rxbytes += 4294967296;
|
|
|
813 |
}
|
|
|
814 |
$dev->setTxBytes($txbytes);
|
|
|
815 |
$dev->setRxBytes($rxbytes);
|
|
|
816 |
$dev->setErrors($device['PacketsReceivedErrors']);
|
|
|
817 |
$dev->setDrops($device['PacketsReceivedDiscarded']);
|
|
|
818 |
|
|
|
819 |
$this->sys->setNetDevices($dev);
|
|
|
820 |
}
|
|
|
821 |
}
|
|
|
822 |
}
|
|
|
823 |
} elseif (($buffer = $this->_get_systeminfo()) && preg_match('/^(\s+)\[\d+\]:[^\r\n]+\r\n\s+[^\s\[]/m', $buffer, $matches, PREG_OFFSET_CAPTURE)) {
|
|
|
824 |
$netbuf = substr($buffer, $matches[0][1]);
|
|
|
825 |
if (preg_match('/^[^\s]/m', $netbuf, $matches2, PREG_OFFSET_CAPTURE)) {
|
|
|
826 |
$netbuf = substr($netbuf, 0, $matches2[0][1]);
|
|
|
827 |
}
|
|
|
828 |
$netstrs = preg_split('/^'.$matches[1][0].'\[\d+\]:/m', $netbuf, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
829 |
$devnr = 0;
|
|
|
830 |
foreach ($netstrs as $netstr) {
|
|
|
831 |
$netstrls = preg_split('/\r\n/', $netstr, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
832 |
if (sizeof($netstrls)>1) {
|
|
|
833 |
$dev = new NetDevice();
|
|
|
834 |
foreach ($netstrls as $nr=>$netstrl) {
|
|
|
835 |
if ($nr === 0) {
|
|
|
836 |
$name = trim($netstrl);
|
|
|
837 |
if ($name !== "") {
|
|
|
838 |
$dev->setName($name);
|
|
|
839 |
} else {
|
|
|
840 |
$dev->setName('dev'.$devnr);
|
|
|
841 |
$devnr++;
|
|
|
842 |
}
|
|
|
843 |
} elseif (preg_match('/\[\d+\]:\s+(.+)/', $netstrl, $netinfo)) {
|
|
|
844 |
$ipaddres = trim($netinfo[1]);
|
|
|
845 |
if (($ipaddres!="0.0.0.0") && !preg_match('/^fe80::/i', $ipaddres))
|
|
|
846 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ipaddres));
|
|
|
847 |
}
|
|
|
848 |
}
|
|
|
849 |
$this->sys->setNetDevices($dev);
|
|
|
850 |
}
|
|
|
851 |
}
|
|
|
852 |
}
|
|
|
853 |
}
|
|
|
854 |
|
|
|
855 |
/**
|
|
|
856 |
* Physical memory information and Swap Space information
|
|
|
857 |
*
|
|
|
858 |
* @link http://msdn2.microsoft.com/En-US/library/aa394239.aspx
|
|
|
859 |
* @link http://msdn2.microsoft.com/en-us/library/aa394246.aspx
|
|
|
860 |
* @return void
|
|
|
861 |
*/
|
|
|
862 |
private function _memory()
|
|
|
863 |
{
|
|
|
864 |
if ($this->_wmi) {
|
|
|
865 |
$buffer = $this->_get_Win32_OperatingSystem();
|
|
|
866 |
if ($buffer) {
|
|
|
867 |
$this->sys->setMemTotal($buffer[0]['TotalVisibleMemorySize'] * 1024);
|
|
|
868 |
$this->sys->setMemFree($buffer[0]['FreePhysicalMemory'] * 1024);
|
|
|
869 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
|
|
870 |
}
|
|
|
871 |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PageFileUsage');
|
|
|
872 |
foreach ($buffer as $swapdevice) {
|
|
|
873 |
$dev = new DiskDevice();
|
|
|
874 |
$dev->setName("SWAP");
|
|
|
875 |
$dev->setMountPoint($swapdevice['Name']);
|
|
|
876 |
$dev->setTotal($swapdevice['AllocatedBaseSize'] * 1024 * 1024);
|
|
|
877 |
$dev->setUsed($swapdevice['CurrentUsage'] * 1024 * 1024);
|
|
|
878 |
$dev->setFree($dev->getTotal() - $dev->getUsed());
|
|
|
879 |
$dev->setFsType('swap');
|
|
|
880 |
$this->sys->setSwapDevices($dev);
|
|
|
881 |
}
|
|
|
882 |
} elseif (($buffer = $this->_get_systeminfo()) && preg_match("/:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+\s([\d \xFF]+)\sMB\r\n/m", $buffer, $buffer2)) {
|
|
|
883 |
// && (preg_match("/:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+:\s([\d \xFF]+)\sMB\r\n.+\s([\d \xFF]+)\sMB\r\n.*:\s+(\S+)\r\n/m", $buffer, $buffer2)) {
|
|
|
884 |
$this->sys->setMemTotal(preg_replace('/(\s)|(\xFF)/', '', $buffer2[1]) * 1024 * 1024);
|
|
|
885 |
$this->sys->setMemFree(preg_replace('/(\s)|(\xFF)/', '', $buffer2[2]) * 1024 * 1024);
|
|
|
886 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
|
|
887 |
}
|
|
|
888 |
}
|
|
|
889 |
|
|
|
890 |
/**
|
|
|
891 |
* filesystem information
|
|
|
892 |
*
|
|
|
893 |
* @return void
|
|
|
894 |
*/
|
|
|
895 |
private function _filesystems()
|
|
|
896 |
{
|
|
|
897 |
$typearray = array('Unknown', 'No Root Directory', 'Removable Disk', 'Local Disk', 'Network Drive', 'Compact Disc', 'RAM Disk');
|
|
|
898 |
$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.');
|
|
|
899 |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType'));
|
|
|
900 |
foreach ($buffer as $filesystem) {
|
|
|
901 |
$dev = new DiskDevice();
|
|
|
902 |
$dev->setMountPoint($filesystem['Name']);
|
|
|
903 |
$dev->setFsType($filesystem['FileSystem']);
|
|
|
904 |
if ($filesystem['Size'] > 0) {
|
|
|
905 |
$dev->setTotal($filesystem['Size']);
|
|
|
906 |
$dev->setFree($filesystem['FreeSpace']);
|
|
|
907 |
$dev->setUsed($filesystem['Size'] - $filesystem['FreeSpace']);
|
|
|
908 |
}
|
|
|
909 |
if ($filesystem['MediaType'] != "" && $filesystem['DriveType'] == 2) {
|
|
|
910 |
$dev->setName($typearray[$filesystem['DriveType']]." (".$floppyarray[$filesystem['MediaType']].")");
|
|
|
911 |
} else {
|
|
|
912 |
$dev->setName($typearray[$filesystem['DriveType']]);
|
|
|
913 |
}
|
|
|
914 |
$this->sys->setDiskDevices($dev);
|
|
|
915 |
}
|
|
|
916 |
if (!$buffer && ($this->sys->getDistribution()=="ReactOS")) {
|
|
|
917 |
// test for command 'free' on current disk
|
|
|
918 |
if (CommonFunctions::executeProgram('cmd', '/c free 2>nul', $out_value, true)) {
|
|
|
919 |
for ($letter='A'; $letter!='AA'; $letter++) if (CommonFunctions::executeProgram('cmd', '/c free '.$letter.': 2>nul', $out_value, false)) {
|
|
|
920 |
$values = preg_replace('/[^\d\n]/', '', $out_value);
|
|
|
921 |
if (preg_match('/\n(\d+)\n(\d+)\n(\d+)$/', $values, $out_dig)) {
|
|
|
922 |
$size = $out_dig[1];
|
|
|
923 |
$used = $out_dig[2];
|
|
|
924 |
$free = $out_dig[3];
|
|
|
925 |
if ($used + $free == $size) {
|
|
|
926 |
$dev = new DiskDevice();
|
|
|
927 |
$dev->setMountPoint($letter.":");
|
|
|
928 |
$dev->setFsType('Unknown');
|
|
|
929 |
$dev->setName('Unknown');
|
|
|
930 |
$dev->setTotal($size);
|
|
|
931 |
$dev->setUsed($used);
|
|
|
932 |
$dev->setFree($free);
|
|
|
933 |
$this->sys->setDiskDevices($dev);
|
|
|
934 |
}
|
|
|
935 |
}
|
|
|
936 |
}
|
|
|
937 |
}
|
|
|
938 |
}
|
|
|
939 |
}
|
|
|
940 |
|
|
|
941 |
/**
|
|
|
942 |
* get os specific encoding
|
|
|
943 |
*
|
|
|
944 |
* @see OS::getEncoding()
|
|
|
945 |
*
|
|
|
946 |
* @return string
|
|
|
947 |
*/
|
|
|
948 |
public function getEncoding()
|
|
|
949 |
{
|
|
|
950 |
return $this->_codepage;
|
|
|
951 |
}
|
|
|
952 |
|
|
|
953 |
/**
|
|
|
954 |
* get os specific language
|
|
|
955 |
*
|
|
|
956 |
* @see OS::getLanguage()
|
|
|
957 |
*
|
|
|
958 |
* @return string
|
|
|
959 |
*/
|
|
|
960 |
public function getLanguage()
|
|
|
961 |
{
|
|
|
962 |
return $this->_syslang;
|
|
|
963 |
}
|
|
|
964 |
|
|
|
965 |
public function _processes()
|
|
|
966 |
{
|
|
|
967 |
$processes['*'] = 0;
|
|
|
968 |
if (CommonFunctions::executeProgram('qprocess', '*', $strBuf, false) && (strlen($strBuf) > 0)) {
|
|
|
969 |
$lines = preg_split('/\n/', $strBuf);
|
|
|
970 |
$processes['*'] = (count($lines)-1) - 3 ; //correction for process "qprocess *"
|
|
|
971 |
}
|
|
|
972 |
if ($processes['*'] <= 0) {
|
|
|
973 |
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
|
|
|
974 |
$processes['*'] = count($buffer);
|
|
|
975 |
}
|
|
|
976 |
$processes[' '] = $processes['*'];
|
|
|
977 |
$this->sys->setProcesses($processes);
|
|
|
978 |
}
|
|
|
979 |
|
|
|
980 |
/**
|
|
|
981 |
* get the information
|
|
|
982 |
*
|
|
|
983 |
* @see PSI_Interface_OS::build()
|
|
|
984 |
*
|
|
|
985 |
* @return Void
|
|
|
986 |
*/
|
|
|
987 |
public function build()
|
|
|
988 |
{
|
|
|
989 |
$this->_distro(); //share getDistribution()
|
|
|
990 |
if ($this->sys->getDistribution()=="ReactOS") {
|
|
|
991 |
$this->error->addError("WARN", "The ReactOS version of phpSysInfo is a work in progress, some things currently don't work");
|
|
|
992 |
}
|
|
|
993 |
if (!$this->blockname || $this->blockname==='vitals') {
|
|
|
994 |
$this->_hostname();
|
|
|
995 |
$this->_users();
|
|
|
996 |
$this->_uptime();
|
|
|
997 |
$this->_loadavg();
|
|
|
998 |
$this->_processes();
|
|
|
999 |
}
|
|
|
1000 |
if (!$this->blockname || $this->blockname==='network') {
|
|
|
1001 |
$this->_network();
|
|
|
1002 |
}
|
|
|
1003 |
if (!$this->blockname || $this->blockname==='hardware') {
|
|
|
1004 |
$this->_machine();
|
|
|
1005 |
$this->_cpuinfo();
|
|
|
1006 |
$this->_hardware();
|
|
|
1007 |
}
|
|
|
1008 |
if (!$this->blockname || $this->blockname==='filesystem') {
|
|
|
1009 |
$this->_filesystems();
|
|
|
1010 |
}
|
|
|
1011 |
if (!$this->blockname || $this->blockname==='memory') {
|
|
|
1012 |
$this->_memory();
|
|
|
1013 |
}
|
|
|
1014 |
}
|
|
|
1015 |
}
|