/web/acc/phpsysinfo/includes/os/class.BSDCommon.inc.php |
---|
175,7 → 175,7 |
protected function readdmesg() |
{ |
if ($this->_dmesg === null) { |
if ((PSI_OS != "Darwin") && (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf))) { // Once again but with debug |
if ((PSI_OS != 'Darwin') && (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf))) { // Once again but with debug |
$parts = preg_split("/rebooting|Uptime/", $buf, -1, PREG_SPLIT_NO_EMPTY); |
$this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY); |
} else { |
247,21 → 247,38 |
$s = preg_replace('/{ /', '', $s); |
$s = preg_replace('/ }/', '', $s); |
$this->sys->setLoad($s); |
if (PSI_LOAD_BAR && (PSI_OS != "Darwin")) { |
if ($fd = $this->grabkey('kern.cp_time')) { |
// Find out the CPU load |
// user + sys = load |
// total = total |
preg_match($this->_CPURegExp2, $fd, $res); |
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys |
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
$fd = $this->grabkey('kern.cp_time'); |
preg_match($this->_CPURegExp2, $fd, $res); |
$load2 = $res[2] + $res[3] + $res[4]; |
$total2 = $res[2] + $res[3] + $res[4] + $res[5]; |
$this->sys->setLoadPercent((100 * ($load2 - $load)) / ($total2 - $total)); |
if (PSI_LOAD_BAR) { |
if (PSI_OS != 'Darwin') { |
if ($fd = $this->grabkey('kern.cp_time')) { |
// Find out the CPU load |
// user + sys = load |
// total = total |
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) { |
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys |
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
$fd = $this->grabkey('kern.cp_time'); |
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) { |
$load2 = $res[2] + $res[3] + $res[4]; |
$total2 = $res[2] + $res[3] + $res[4] + $res[5]; |
$this->sys->setLoadPercent((100 * ($load2 - $load)) / ($total2 - $total)); |
} |
} |
} |
} else { |
$ncpu = $this->grabkey('hw.ncpu'); |
if (!is_null($ncpu) && (trim($ncpu) != "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) { |
$pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY); |
if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) { |
array_shift($pslines); |
$sum = 0; |
foreach ($pslines as $psline) { |
$sum+=trim($psline); |
} |
$this->sys->setLoadPercent(min($sum/$ncpu, 100)); |
} |
} |
} |
} |
} |
275,7 → 292,7 |
{ |
$dev = new CpuDevice(); |
if (PSI_OS == "NetBSD") { |
if (PSI_OS == 'NetBSD') { |
if ($model = $this->grabkey('machdep.cpu_brand')) { |
$dev->setModel($model); |
} |
290,7 → 307,7 |
$notwas = true; |
foreach ($this->readdmesg() as $line) { |
if ($notwas) { |
if (preg_match($this->_CPURegExp1, $line, $ar_buf)) { |
if (preg_match($this->_CPURegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) { |
if ($dev->getCpuSpeed() === 0) { |
$dev->setCpuSpeed(round($ar_buf[2])); |
} |
329,11 → 346,11 |
protected function scsi() |
{ |
foreach ($this->readdmesg() as $line) { |
if (preg_match($this->_SCSIRegExp1, $line, $ar_buf)) { |
if (preg_match($this->_SCSIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) { |
$dev = new HWDevice(); |
$dev->setName($ar_buf[1].": ".trim($ar_buf[2])); |
$this->sys->setScsiDevices($dev); |
} elseif (preg_match($this->_SCSIRegExp2, $line, $ar_buf)) { |
} elseif (preg_match($this->_SCSIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 1)) { |
/* duplication security */ |
$notwas = true; |
foreach ($this->sys->getScsiDevices() as $finddev) { |
341,7 → 358,7 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) { |
$finddev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024); |
} else { |
} elseif (isset($ar_buf[2])) { |
$finddev->setCapacity($ar_buf[2] * 1024 * 1024); |
} |
} |
355,13 → 372,13 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) { |
$dev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024); |
} else { |
} elseif (isset($ar_buf[2])) { |
$dev->setCapacity($ar_buf[2] * 1024 * 1024); |
} |
} |
$this->sys->setScsiDevices($dev); |
} |
} elseif (preg_match($this->_SCSIRegExp3, $line, $ar_buf)) { |
} elseif (preg_match($this->_SCSIRegExp3, $line, $ar_buf) && (sizeof($ar_buf) > 1)) { |
/* duplication security */ |
$notwas = true; |
foreach ($this->sys->getScsiDevices() as $finddev) { |
368,7 → 385,7 |
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) { |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$finddev->setSerial(trim($ar_buf[2])); |
if (isset($ar_buf[2])) $finddev->setSerial(trim($ar_buf[2])); |
} |
$notwas = false; |
break; |
379,7 → 396,7 |
$dev->setName($ar_buf[1]); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$dev->setSerial(trim($ar_buf[2])); |
if (isset($ar_buf[2])) $dev->setSerial(trim($ar_buf[2])); |
} |
$this->sys->setScsiDevices($dev); |
} |
448,11 → 465,11 |
{ |
if ((!$results = Parser::lspci(false)) && (!$results = $this->pciconf())) { |
foreach ($this->readdmesg() as $line) { |
if (preg_match($this->_PCIRegExp1, $line, $ar_buf)) { |
if (preg_match($this->_PCIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) { |
$dev = new HWDevice(); |
$dev->setName($ar_buf[1].": ".$ar_buf[2]); |
$results[] = $dev; |
} elseif (preg_match($this->_PCIRegExp2, $line, $ar_buf)) { |
} elseif (preg_match($this->_PCIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 2)) { |
$dev = new HWDevice(); |
$dev->setName($ar_buf[1].": ".$ar_buf[2]); |
$results[] = $dev; |
592,7 → 609,19 |
*/ |
protected function usb() |
{ |
foreach ($this->readdmesg() as $line) { |
$notwas = true; |
if ((PSI_OS == 'FreeBSD') && CommonFunctions::executeProgram('usbconfig', '', $bufr, false)) { |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($lines as $line) { |
if (preg_match('/^(ugen[0-9]+\.[0-9]+): <([^,]*)(.*)> at (usbus[0-9]+)/', $line, $ar_buf)) { |
$notwas = false; |
$dev = new HWDevice(); |
$dev->setName($ar_buf[2]); |
$this->sys->setUSBDevices($dev); |
} |
} |
} |
if ($notwas) foreach ($this->readdmesg() as $line) { |
// if (preg_match('/^(ugen[0-9\.]+): <(.*)> (.*) (.*)/', $line, $ar_buf)) { |
// $dev->setName($ar_buf[1].": ".$ar_buf[2]); |
if (preg_match('/^(u[a-z]+[0-9]+): <([^,]*)(.*)> on (usbus[0-9]+)/', $line, $ar_buf)) { |
/web/acc/phpsysinfo/includes/os/class.Darwin.inc.php |
---|
325,14 → 325,16 |
$swap1 = preg_split('/M/', $swapBuff); |
$swap2 = preg_split('/=/', $swap1[1]); |
$swap3 = preg_split('/=/', $swap1[2]); |
$dev = new DiskDevice(); |
$dev->setName('SWAP'); |
$dev->setMountPoint('SWAP'); |
$dev->setFsType('swap'); |
$dev->setTotal($swap1[0] * 1024 * 1024); |
$dev->setUsed($swap2[1] * 1024 * 1024); |
$dev->setFree($swap3[1] * 1024 * 1024); |
$this->sys->setSwapDevices($dev); |
if (($swap=trim($swap1[0])) > 0) { |
$dev = new DiskDevice(); |
$dev->setName('SWAP'); |
$dev->setMountPoint('SWAP'); |
$dev->setFsType('swap'); |
$dev->setTotal($swap * 1024 * 1024); |
$dev->setUsed(trim($swap2[1]) * 1024 * 1024); |
$dev->setFree(trim($swap3[1]) * 1024 * 1024); |
$this->sys->setSwapDevices($dev); |
} |
} |
} |
} |
413,28 → 415,37 |
protected function distro() |
{ |
$this->sys->setDistributionIcon('Darwin.png'); |
if (!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG)) { |
if ((!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG) || !preg_match('/\n\s*System Version:/', $buffer)) |
&& (!CommonFunctions::executeProgram('sw_vers', '', $buffer, PSI_DEBUG) || !preg_match('/^ProductName:/', $buffer))) { |
parent::distro(); |
} else { |
$arrBuff = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($arrBuff as $line) { |
$arrLine = preg_split("/:/", $line, -1, PREG_SPLIT_NO_EMPTY); |
if (trim($arrLine[0]) === "System Version") { |
$distro = trim($arrLine[1]); |
if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) { |
$this->sys->setDistributionIcon('Apple.png'); |
if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) (\d+\.\d+)/', $distro, $ver) |
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true)) |
&& isset($list['OS X'][$ver[2]])) { |
$distro.=' '.$list['OS X'][$ver[2]]; |
$distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($distro_tmp as $info) { |
$info_tmp = preg_split('/:/', $info, 2); |
if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") && |
isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) { |
$distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]); |
} |
} |
if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) { |
$distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')'; |
} |
if (isset($distro_arr['System Version'])) { |
$distro = $distro_arr['System Version']; |
if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) { |
$this->sys->setDistributionIcon('Apple.png'); |
if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver) |
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) { |
if (isset($list['macOS'][$ver[2]])) { |
$distro.=' '.$list['macOS'][$ver[2]]; |
} elseif (isset($list['macOS'][$ver[3]])) { |
$distro.=' '.$list['macOS'][$ver[3]]; |
} |
} |
$this->sys->setDistribution($distro); |
return; |
} |
$this->sys->setDistribution($distro); |
} else { |
parent::distro(); |
} |
} |
} |
/web/acc/phpsysinfo/includes/os/class.FreeBSD.inc.php |
---|
133,9 → 133,16 |
*/ |
private function _distroicon() |
{ |
if (extension_loaded('pfSense') && CommonFunctions::rfts('/etc/version', $version, 1, 4096, false) && (trim($version) != '')) { // pfSense detection |
$this->sys->setDistribution('pfSense '. trim($version)); |
$this->sys->setDistributionIcon('pfSense.png'); |
if (CommonFunctions::rfts('/etc/version', $version, 1, 4096, false) && (($version=trim($version)) != '')) { |
if (extension_loaded('pfSense')) { // pfSense detection |
$this->sys->setDistribution('pfSense '. $version); |
$this->sys->setDistributionIcon('pfSense.png'); |
} elseif (preg_match('/^FreeNAS/i', $version)) { // FreeNAS detection |
$this->sys->setDistribution($version); |
$this->sys->setDistributionIcon('FreeNAS.png'); |
} else { |
$this->sys->setDistributionIcon('FreeBSD.png'); |
} |
} else { |
$this->sys->setDistributionIcon('FreeBSD.png'); |
} |
/web/acc/phpsysinfo/includes/os/class.Haiku.inc.php |
---|
45,12 → 45,12 |
$dev->setModel($ar_buf[1]); |
$arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($arrLines as $Line) { |
if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) { |
$dev->setCache(max($Line_buf[1]*1024, $dev->getCache())); |
} elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) { |
$dev->setCache(max($Line_buf[1]*1024*1024, $dev->getCache())); |
} elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) { |
$dev->setCache(max($Line_buf[1]*1024*1024*1024, $dev->getCache())); |
if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) { |
$dev->setCache(max(intval($Line_buf[1])*1024, $dev->getCache())); |
} elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) { |
$dev->setCache(max(intval($Line_buf[1])*1024*1024, $dev->getCache())); |
} elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf) || preg_match("/^\s+L0 Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) { |
$dev->setCache(max(intval($Line_buf[1])*1024*1024*1024, $dev->getCache())); |
} elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) { |
$dev->setVirt("vmx"); |
} elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) { |
156,19 → 156,28 |
*/ |
private function _uptime() |
{ |
if (CommonFunctions::executeProgram('uptime', '-u', $buf)) { |
if (preg_match("/^up (\d+) minute[s]?/", $buf, $ar_buf)) { |
$min = $ar_buf[1]; |
$this->sys->setUptime($min * 60); |
} elseif (preg_match("/^up (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) { |
if (CommonFunctions::executeProgram('uptime', '', $buf)) { |
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $ar_buf)) { |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
$days = $ar_buf[1]; |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60); |
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $buf, $ar_buf)) { |
$min = $ar_buf[2]; |
$hours = $ar_buf[1]; |
$this->sys->setUptime($hours * 3600 + $min * 60); |
} elseif (preg_match("/^up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) { |
} elseif (preg_match("/up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?$/", $buf, $ar_buf)) { |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
$days = $ar_buf[1]; |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60); |
} elseif (preg_match("/up (\d+) hour[s]?, (\d+) minute[s]?$/", $buf, $ar_buf)) { |
$min = $ar_buf[2]; |
$hours = $ar_buf[1]; |
$this->sys->setUptime($hours * 3600 + $min * 60); |
} elseif (preg_match("/up (\d+) minute[s]?$/", $buf, $ar_buf)) { |
$min = $ar_buf[1]; |
$this->sys->setUptime($min * 60); |
} |
} |
} |
231,7 → 240,7 |
if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) { |
$this->sys->setMemTotal($ar_buf[3]); |
$this->sys->setMemFree($ar_buf[1]); |
$this->sys->setMemCache($ar_buf[4]); |
$this->sys->setMemCache(min($ar_buf[4], $ar_buf[2])); |
$this->sys->setMemUsed($ar_buf[2]); |
} |
} |
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php |
---|
29,7 → 29,7 |
/** |
* Assoc array of all CPUs loads. |
*/ |
protected $_cpu_loads; |
private $_cpu_loads = null; |
/** |
* Machine |
75,7 → 75,7 |
} |
if ($machine != "") { |
$machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified) ?/i", "", $machine))); |
$machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $machine))); |
} |
if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection |
138,7 → 138,7 |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) { |
$result .= ' '.$strBuf; |
} |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) { |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) { |
$result = $ar_buf[1]; |
if (preg_match('/SMP/', $strBuf)) { |
$result .= ' (SMP)'; |
154,9 → 154,12 |
$result .= ' [docker]'; |
} |
} |
if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false) |
&& preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) { |
$result .= ' [lxss]'; |
if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false)) { |
if (preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) { |
$result .= ' [wsl]'; |
} elseif (preg_match('/^Linux version [\d\.-]+-microsoft-standard/', $strBuf2)) { |
$result .= ' [wsl2]'; |
} |
} |
$this->sys->setKernel($result); |
} |
228,7 → 231,7 |
$this->_cpu_loads = array(); |
$cpu_tmp = array(); |
if (CommonFunctions::rfts('/proc/stat', $buf)) { |
if (CommonFunctions::rfts('/proc/stat', $buf, 0, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) { |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) { |
foreach ($matches as $line) { |
$cpu = $line[1]; |
249,7 → 252,7 |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
if (CommonFunctions::rfts('/proc/stat', $buf)) { |
if (CommonFunctions::rfts('/proc/stat', $buf, 0, 4096, PSI_DEBUG)) { |
if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) { |
foreach ($matches as $line) { |
$cpu = $line[1]; |
279,7 → 282,7 |
if (isset($this->_cpu_loads[$cpuline])) { |
return $this->_cpu_loads[$cpuline]; |
} else { |
return 0; |
return null; |
} |
} |
612,13 → 615,13 |
} |
if ($booDevice) { |
$dev = new HWDevice(); |
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strLine))); |
$dev->setName(preg_replace('/\(rev\s[^\)]+\)\.$/', '', trim($strLine))); |
$this->sys->setPciDevices($dev); |
/* |
list($strKey, $strValue) = preg_split('/: /', $strLine, 2); |
if (!preg_match('/bridge/i', $strKey) && !preg_match('/USB/i ', $strKey)) { |
$dev = new HWDevice(); |
$dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strValue))); |
$dev->setName(preg_replace('/\(rev\s[^\)]+\)\.$/', '', trim($strValue))); |
$this->sys->setPciDevices($dev); |
} |
*/ |
773,6 → 776,10 |
if ($product!==null) { |
$usbarray[$usbid]['product'] = $product; |
} |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed'); |
if ($product!==null) { |
$usbarray[$usbid]['speed'] = $speed; |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial'); |
785,12 → 792,16 |
} |
} |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { //usb-devices |
$devnum = -1; |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($bufe as $buf) { |
if (preg_match('/^T/', $buf)) { |
$devnum++; |
if (preg_match('/\sSpd=([\d\.]+)/', $buf, $bufr) |
&& isset($bufr[1]) && ($bufr[1]!=="")) { |
$usbarray[$devnum]['speed'] = $bufr[1]; |
} |
} elseif (preg_match('/^S:/', $buf)) { |
list($key, $value) = preg_split('/: /', $buf, 2); |
list($key, $value2) = preg_split('/=/', $value, 2); |
859,10 → 870,14 |
$product = ''; |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL |
&& isset($usbdev['serial'])) { |
$dev->setSerial($usbdev['serial']); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
if (isset($usbdev['speed'])) { |
$dev->setSpeed($usbdev['speed']); |
} |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL |
&& isset($usbdev['serial'])) { |
$dev->setSerial($usbdev['serial']); |
} |
} |
if (isset($usbdev['name']) && (($name=$usbdev['name']) !== 'unknown')) { |
1007,9 → 1022,8 |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2) |
|| preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+link\/ether\s+(\S+)$/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+link\/ieee802.11\s+(\S+)$/i', $buf2, $ar_buf2)) { |
|| preg_match('/^\s+link\/\S+\s+(\S+)\s+brd/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $buf2, $ar_buf2)) { |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) { |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
if ($macaddr === '00-00-00-00-00-00') { // empty |
1038,7 → 1052,8 |
if ($macaddr != "") { |
$dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():'')); |
} |
if (CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535)) { |
if ((!CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) && |
(CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) { |
if ($speed > 1000) { |
$speed = $speed/1000; |
$unit = "G"; |
1085,8 → 1100,8 |
} |
$was = true; |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) { |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) { |
$speed = trim($buf); |
if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) && |
(CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) { |
if ($speed > 1000) { |
$speed = $speed/1000; |
$unit = "G"; |
1093,8 → 1108,8 |
} else { |
$unit = "M"; |
} |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) { |
$speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf)); |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (($duplex=strtolower(trim($buf)))!="") && ($duplex!='unknown')) { |
$speedinfo = $speed.$unit.'b/s '.$duplex; |
} else { |
$speedinfo = $speed.$unit.'b/s'; |
} |
1103,7 → 1118,8 |
} else { |
if ($was) { |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) { |
if (preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $line, $ar_buf2)) { |
if (preg_match('/^\s+link\/\S+\s+(\S+)\s+brd/i', $line, $ar_buf2) |
|| preg_match('/^\s+link\/\S+\s+(\S+)$/i', $line, $ar_buf2)) { |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
} elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) { |
if ($ar_buf2[1] != $ar_buf2[2]) { |
1157,8 → 1173,8 |
$dev->setName($ar_buf[1]); |
$was = true; |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) { |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) { |
$speed = trim($buf); |
if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) && |
(CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) { |
if ($speed > 1000) { |
$speed = $speed/1000; |
$unit = "G"; |
1165,15 → 1181,21 |
} else { |
$unit = "M"; |
} |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) { |
$speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf)); |
if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (($duplex=strtolower(trim($buf)))!="") && ($duplex!='unknown')) { |
$speedinfo = $speed.$unit.'b/s '.$duplex; |
} else { |
$speedinfo = $speed.$unit.'b/s'; |
} |
} |
if (preg_match('/^'.$ar_buf[1].'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2)) |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
elseif (preg_match('/^'.$ar_buf[1].':\s+ip\s+(\S+)\s+mask/i', $line, $ar_buf2)) |
if (preg_match('/^'.$ar_buf[1].'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2) |
|| preg_match('/^'.$ar_buf[1].'\s+Link\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $line, $ar_buf2)) { |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) { |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
if ($macaddr === '00-00-00-00-00-00') { // empty |
$macaddr = ""; |
} |
} |
} elseif (preg_match('/^'.$ar_buf[1].':\s+ip\s+(\S+)\s+mask/i', $line, $ar_buf2)) |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]); |
} |
} else { |
1195,8 → 1217,14 |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) { |
if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2) |
|| preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $line, $ar_buf2) |
|| preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $line, $ar_buf2)) { |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) { |
$macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1])); |
if ($macaddr === '00-00-00-00-00-00') { // empty |
$macaddr = ""; |
} |
} |
} elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $line, $ar_buf2) |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $line, $ar_buf2)) { |
if ($ar_buf2[1] != $ar_buf2[2]) { |
/web/acc/phpsysinfo/includes/os/class.OS.inc.php |
---|
132,9 → 132,9 |
*/ |
protected function _ip() |
{ |
if (PSI_USE_VHOST === true) { |
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) { |
if ((CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) //is server address defined |
&& !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result) |
&& !strstr($result, '.') && strstr($result, ':')) { //is IPv6, quick version of preg_match('/\(([[0-9A-Fa-f\:]+)\)/', $result) |
$dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA); |
if (isset($dnsrec[0]['ipv6'])) { //is DNS IPv6 record |
$this->sys->setIp($dnsrec[0]['ipv6']); //from DNS (avoid IPv6 NAT translation) |
144,16 → 144,131 |
} else { |
$this->sys->setIp(gethostbyname($this->sys->getHostname())); //IPv4 only |
} |
} elseif (((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) && (CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result))) { |
$this->sys->setIp(preg_replace('/^::ffff:/i', '', $result)); |
} else { |
if (CommonFunctions::readenv('SERVER_ADDR', $result) || CommonFunctions::readenv('LOCAL_ADDR', $result)) { |
$this->sys->setIp(preg_replace('/^::ffff:/i', '', $result)); |
//$this->sys->setIp(gethostbyname($this->sys->getHostname())); |
$hn = $this->sys->getHostname(); |
$ghbn = gethostbyname($hn); |
if (defined('PSI_EMU_HOSTNAME') && ($hn === $ghbn)) { |
$this->sys->setIp(PSI_EMU_HOSTNAME); |
} else { |
$this->sys->setIp(gethostbyname($this->sys->getHostname())); |
$this->sys->setIp($ghbn); |
} |
} |
} |
/** |
* MEM information from dmidecode |
* |
* @return void |
*/ |
protected function _dmimeminfo() |
{ |
$banks = array(); |
$buffer = ''; |
if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)=="data")) { |
CommonFunctions::rfts(PSI_APP_ROOT.'/data/dmidecode.txt', $buffer); |
} elseif (CommonFunctions::_findProgram('dmidecode')) { |
CommonFunctions::executeProgram('dmidecode', '-t 17', $buffer, PSI_DEBUG); |
} |
if (!empty($buffer)) { |
$banks = preg_split('/^(?=Handle\s)/m', $buffer, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($banks as $bank) if (preg_match('/^Handle\s/', $bank)) { |
$lines = preg_split("/\n/", $bank, -1, PREG_SPLIT_NO_EMPTY); |
$mem = array(); |
foreach ($lines as $line) if (preg_match('/^\s+([^:]+):(.+)/' ,$line, $params)) { |
if (preg_match('/^0x([A-F\d]+)/', $params2 = trim($params[2]), $buff)) { |
$mem[trim($params[1])] = trim($buff[1]); |
} elseif ($params2 != '') { |
$mem[trim($params[1])] = $params2; |
} |
} |
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)) { |
$dev = new HWDevice(); |
$name = ''; |
if (isset($mem['Part Number']) && !preg_match("/^PartNum\d+$/", $part = $mem['Part Number']) && ($part != 'None') && ($part != 'N/A') && ($part != 'Not Specified') && ($part != 'NOT AVAILABLE')) { |
$name = $part; |
} |
if (isset($mem['Locator']) && (($dloc = $mem['Locator']) != 'None') && ($dloc != 'N/A') && ($dloc != 'Not Specified')) { |
if ($name != '') { |
$name .= ' - '.$dloc; |
} else { |
$name = $dloc; |
} |
} |
if (isset($mem['Bank Locator']) && (($bank = $mem['Bank Locator']) != 'None') && ($bank != 'N/A') && ($bank != 'Not Specified')) { |
if ($name != '') { |
$name .= ' in '.$bank; |
} else { |
$name = 'Physical Memory in '.$bank; |
} |
} |
if ($name != '') { |
$dev->setName(trim($name)); |
} else { |
$dev->setName('Physical Memory'); |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
if (isset($mem['Manufacturer']) && !preg_match("/^([A-F\d]{4}|[A-F\d]{12}|[A-F\d]{16})$/", $manufacturer = $mem['Manufacturer']) && !preg_match("/^Manufacturer\d+$/", $manufacturer) && !preg_match("/^Mfg \d+$/", $manufacturer) && !preg_match("/^JEDEC ID:/", $manufacturer) && ($manufacturer != 'None') && ($manufacturer != 'N/A') && ($manufacturer != 'Not Specified') && ($manufacturer != 'UNKNOWN')) { |
$dev->setManufacturer($manufacturer); |
} |
if ($size[2] == 'G') { |
$dev->setCapacity($size[1]*1024*1024*1024); |
} else { |
$dev->setCapacity($size[1]*1024*1024); |
} |
$memtype = ''; |
if (isset($mem['Type']) && (($type = $mem['Type']) != 'None') && ($type != 'N/A') && ($type != 'Not Specified') && ($type != 'Other') && ($type != 'Unknown') && ($type != '<OUT OF SPEC>')) { |
if (isset($mem['Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)/', $mem['Speed'], $speed) && ($speed[1] > 0) && (preg_match('/^(DDR\d*)(.*)/', $type, $dr) || preg_match('/^(SDR)AM(.*)/', $type, $dr))) { |
if (isset($mem['Minimum Voltage']) && isset($mem['Total Width']) && |
preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) && |
($minv[1] > 0) && ($maxv[1] >0) && ($minv[1] < $maxv[1])) { |
$lv = 'L'; |
} else { |
$lv = ''; |
} |
if (isset($dr[2])) { |
$memtype = $dr[1].$lv.'-'.$speed[1].' '.$dr[2]; |
} else { |
$memtype = $dr[1].$lv.'-'.$speed[1]; |
} |
} else { |
$memtype = $type; |
} |
} |
if (isset($mem['Form Factor']) && (($form = $mem['Form Factor']) != 'None') && ($form != 'N/A') && ($form != 'Not Specified') && ($form != 'Other') && ($form != 'Unknown') && !preg_match('/ '.$form.'$/', $memtype)) { |
$memtype .= ' '.$form; |
} |
if (isset($mem['Data Width']) && isset($mem['Total Width']) && |
preg_match('/^(\d+)\sbits$/', $mem['Data Width'], $dataw) && preg_match('/^(\d+)\sbits$/', $mem['Total Width'], $totalw) && |
($dataw[1] > 0) && ($totalw[1] >0) && ($dataw[1] < $totalw[1])) { |
$memtype .= ' ECC'; |
} |
if (isset($mem['Type Detail']) && preg_match('/Registered/', $mem['Type Detail'])) { |
$memtype .= ' REG'; |
} |
if (($memtype = trim($memtype)) != '') { |
$dev->setProduct($memtype); |
} |
if (isset($mem['Configured Clock Speed']) && preg_match('/^(\d+)\s(MHz|MT\/s)$/', $mem['Configured Clock Speed'], $clock) && ($clock[1] > 0)) { |
$dev->setSpeed($clock[1]); |
} |
if (isset($mem['Configured Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Configured Voltage'], $voltage) && ($voltage[1] > 0)) { |
$dev->setVoltage($voltage[1]); |
} |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && |
isset($mem['Serial Number']) && !preg_match("/^SerNum\d+$/", $serial = $mem['Serial Number']) && ($serial != 'None') && ($serial != 'Not Specified')) { |
$dev->setSerial($serial); |
} |
} |
$this->sys->setMemDevices($dev); |
} |
} |
} |
} |
/** |
* get the filled or unfilled (with default values) System object |
* |
* @see PSI_Interface_OS::getSys() |
166,6 → 281,9 |
if (!$this->blockname || $this->blockname==='vitals') { |
$this->_ip(); |
} |
if ((!$this->blockname || $this->blockname==='hardware') && (PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) { |
$this->_dmimeminfo(); |
} |
return $this->sys; |
} |
/web/acc/phpsysinfo/includes/os/class.OpenBSD.inc.php |
---|
71,8 → 71,12 |
$dev->setName($ar_buf_b[0]); |
$dev->setTxBytes($ar_buf_b[4]); |
$dev->setRxBytes($ar_buf_b[3]); |
$dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]); |
$dev->setDrops($ar_buf_n[8]); |
if (sizeof($ar_buf_n) == 9) { |
$dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]); |
$dev->setDrops($ar_buf_n[8]); |
} elseif (sizeof($ar_buf_n) == 8) { |
$dev->setDrops($ar_buf_n[4] + $ar_buf_n[6]); |
} |
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS) && (CommonFunctions::executeProgram('ifconfig', $ar_buf_b[0].' 2>/dev/null', $bufr2, PSI_DEBUG))) { |
$speedinfo = ""; |
$bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY); |
/web/acc/phpsysinfo/includes/os/class.SunOS.inc.php |
---|
147,17 → 147,17 |
*/ |
private function _kernel() |
{ |
if (CommonFunctions::executeProgram('uname', '-s', $os, PSI_DEBUG) && ($os!="")) { |
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG) && ($version!="")) { |
$os.=' '.$version; |
if (CommonFunctions::executeProgram('uname', '-s', $kernel, PSI_DEBUG) && ($kernel != "")) { |
if (CommonFunctions::executeProgram('uname', '-r', $version, PSI_DEBUG) && ($version != "")) { |
$kernel.=' '.$version; |
} |
if (CommonFunctions::executeProgram('uname', '-v', $subversion, PSI_DEBUG) && ($subversion!="")) { |
$os.=' ('.$subversion.')'; |
if (CommonFunctions::executeProgram('uname', '-v', $subversion, PSI_DEBUG) && ($subversion != "")) { |
$kernel.=' ('.$subversion.')'; |
} |
if (CommonFunctions::executeProgram('uname', '-i', $platform, PSI_DEBUG) && ($platform!="")) { |
$os.=' '.$platform; |
if (CommonFunctions::executeProgram('uname', '-i', $platform, PSI_DEBUG) && ($platform != "")) { |
$kernel.=' '.$platform; |
} |
$this->sys->setKernel($os); |
$this->sys->setKernel($kernel); |
} |
} |
338,14 → 338,16 |
$this->sys->setMemTotal($this->_kstat('unix:0:system_pages:pagestotal') * $pagesize); |
$this->sys->setMemUsed($this->_kstat('unix:0:system_pages:pageslocked') * $pagesize); |
$this->sys->setMemFree($this->_kstat('unix:0:system_pages:pagesfree') * $pagesize); |
$dev = new DiskDevice(); |
$dev->setName('SWAP'); |
$dev->setFsType('swap'); |
$dev->setMountPoint('SWAP'); |
$dev->setTotal($this->_kstat('unix:0:vminfo:swap_avail') / 1024); |
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024); |
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024); |
$this->sys->setSwapDevices($dev); |
if (($swap=$this->_kstat('unix:0:vminfo:swap_avail')) > 0) { |
$dev = new DiskDevice(); |
$dev->setName('SWAP'); |
$dev->setFsType('swap'); |
$dev->setMountPoint('SWAP'); |
$dev->setTotal($swap / 1024); |
$dev->setUsed($this->_kstat('unix:0:vminfo:swap_alloc') / 1024); |
$dev->setFree($this->_kstat('unix:0:vminfo:swap_free') / 1024); |
$this->sys->setSwapDevices($dev); |
} |
} |
/** |
/web/acc/phpsysinfo/includes/os/class.WINNT.inc.php |
---|
63,7 → 63,7 |
private $_systeminfo = null; |
/** |
* holds the COM object that we pull all the WMI data from |
* holds the COM object that we pull WMI root\CIMv2 data from |
* |
* @var Object |
*/ |
70,7 → 70,7 |
private $_wmi = null; |
/** |
* holds the COM object that we pull all the RegRead data from |
* holds the COM object that we pull all the EnumKey and RegRead data from |
* |
* @var Object |
*/ |
77,11 → 77,11 |
private $_reg = null; |
/** |
* holds the COM object that we pull all the EnumKey data from |
* holds result of 'cmd /c ver' |
* |
* @var Object |
* @var string |
*/ |
private $_key = null; |
private $_ver = ""; |
/** |
* holds all devices, which are in the system |
88,7 → 88,7 |
* |
* @var array |
*/ |
private $_wmidevices; |
private $_wmidevices = array(); |
/** |
* holds all disks, which are in the system |
95,7 → 95,7 |
* |
* @var array |
*/ |
private $_wmidisks; |
private $_wmidisks = array(); |
/** |
* store language encoding of the system to convert some output to utf-8 |
129,7 → 129,7 |
*/ |
private function _get_Win32_ComputerSystem() |
{ |
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model')); |
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model', 'SystemFamily')); |
return $this->_Win32_ComputerSystem; |
} |
174,8 → 174,12 |
*/ |
private function _get_systeminfo() |
{ |
if ($this->_systeminfo === null) CommonFunctions::executeProgram('systeminfo', '', $this->_systeminfo, false); |
return $this->_systeminfo; |
if (!defined('PSI_EMU_HOSTNAME')) { |
if ($this->_systeminfo === null) CommonFunctions::executeProgram('systeminfo', '', $this->_systeminfo, false); |
return $this->_systeminfo; |
} else { |
return ''; |
} |
} |
/** |
184,27 → 188,60 |
public function __construct($blockname = false) |
{ |
parent::__construct($blockname); |
try { |
// initialize the wmi object |
$objLocator = new COM('WbemScripting.SWbemLocator'); |
$this->_wmi = $objLocator->ConnectServer('', 'root\CIMv2'); |
} catch (Exception $e) { |
$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."); |
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::executeProgram('cmd', '/c ver 2>nul', $ver_value, false) && (($ver_value = trim($ver_value)) !== "")) { |
$this->_ver = $ver_value; |
} |
try { |
// initialize the RegRead object |
$this->_reg = new COM("WScript.Shell"); |
} catch (Exception $e) { |
//$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."); |
$this->_reg = false; |
if (($this->_ver !== "") && preg_match("/ReactOS\r?\n\S+\s+.+/", $this->_ver)) { |
$this->_wmi = false; // No WMI info on ReactOS yet |
$this->_reg = false; // No EnumKey and ReadReg on ReactOS yet |
} else { |
if (PSI_OS == 'WINNT') { |
if (defined('PSI_EMU_HOSTNAME')) { |
try { |
$objLocator = new COM('WbemScripting.SWbemLocator'); |
$wmi = $objLocator->ConnectServer('', 'root\CIMv2'); |
$buffer = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('CodeSet')); |
if (!$buffer) { |
$reg = $objLocator->ConnectServer('', 'root\default'); |
if (CommonFunctions::readReg($reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) { |
$buffer[0]['CodeSet'] = $strBuf; |
} |
} |
if ($buffer && isset($buffer[0])) { |
if (isset($buffer[0]['CodeSet'])) { |
$codeset = $buffer[0]['CodeSet']; |
if ($codeset == 932) { |
$codename = ' (SJIS)'; |
} elseif ($codeset == 949) { |
$codename = ' (EUC-KR)'; |
} elseif ($codeset == 950) { |
$codename = ' (BIG-5)'; |
} else { |
$codename = ''; |
} |
define('PSI_SYSTEM_CODEPAGE', 'windows-'.$codeset.$codename); |
} |
} |
} catch (Exception $e) { |
define('PSI_SYSTEM_CODEPAGE', null); |
if (PSI_DEBUG) { |
$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"); |
} |
} |
} else { |
define('PSI_SYSTEM_CODEPAGE', null); |
} |
} |
$this->_wmi = CommonFunctions::initWMI('root\CIMv2', true); |
if (PSI_OS == 'WINNT') { |
$this->_reg = CommonFunctions::initWMI('root\default', PSI_DEBUG); |
if (gettype($this->_reg) === "object") { |
$this->_reg->Security_->ImpersonationLevel = 3; |
} |
} else { |
$this->_reg = false; // No EnumKey and ReadReg on Linux |
} |
} |
try { |
// initialize the EnumKey object |
$this->_key = new COM("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv"); |
} catch (Exception $e) { |
//$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."); |
$this->_key = false; |
} |
$this->_getCodeSet(); |
} |
274,9 → 311,44 |
} |
} else { |
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID')); |
$this->_wmidisks = array(); |
} |
if (empty($this->_wmidevices)) { |
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi"; |
$id = 0; |
if (CommonFunctions::enumKey($this->_reg, $hkey, $portBuf, false)) { |
foreach ($portBuf as $scsiport) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport, $busBuf, false)) { |
foreach ($busBuf as $scsibus) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus, $tarBuf, false)) { |
foreach ($tarBuf as $scsitar) if (!strncasecmp($scsitar, "Target Id ", strlen("Target Id "))) { |
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus."\\".$scsitar, $logBuf, false)) { |
foreach ($logBuf as $scsilog) if (!strncasecmp($scsilog, "Logical Unit Id ", strlen("Logical Unit Id "))) { |
$hkey2 = $hkey."\\".$scsiport."\\".$scsibus."\\".$scsitar."\\".$scsilog."\\"; |
if ((CommonFunctions::readReg($this->_reg, $hkey2."DeviceType", $typeBuf, false) || CommonFunctions::readReg($this->_reg, $hkey2."Type", $typeBuf, false)) |
&& (($typeBuf=strtolower(trim($typeBuf))) !== "")) { |
if ((($typeBuf == 'diskperipheral') || ($typeBuf == 'cdromperipheral')) |
&& CommonFunctions::readReg($this->_reg, $hkey2."Identifier", $ideBuf, false)) { |
$this->_wmidevices[] = array('Name'=>$ideBuf, 'PNPDeviceID'=>'SCSI\\'.$id); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL |
&& (CommonFunctions::readReg($this->_reg, $hkey2."SerialNumber", $serBuf, false)) |
&& (($serBuf=trim($serBuf)) !== "")) { |
$this->_wmidisks[] = array('PNPDeviceID'=>'SCSI\\'.$id, 'SerialNumber'=>$serBuf); |
} |
$id++; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
$list = array(); |
foreach ($this->_wmidevices as $device) { |
if (substr($device['PNPDeviceID'], 0, strpos($device['PNPDeviceID'], "\\") + 1) == ($strType."\\")) { |
284,7 → 356,7 |
if (!isset($device['PNPClass']) || ($device['PNPClass']===$strType) || ($device['PNPClass']==='System')) { |
$device['PNPClass'] = null; |
} |
if (preg_match('/^\(.*\)$/', $device['Manufacturer'])) { |
if (!isset($device['Manufacturer']) || preg_match('/^\(.*\)$/', $device['Manufacturer']) || (($device['PNPClass']==='USB') && preg_match('/\sUSB\s/', $device['Manufacturer']))) { |
$device['Manufacturer'] = null; |
} |
$device['Capacity'] = null; |
328,7 → 400,7 |
*/ |
private function _hostname() |
{ |
if (PSI_USE_VHOST === true) { |
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) { |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm); |
} else { |
$buffer = $this->_get_Win32_ComputerSystem(); |
347,11 → 419,19 |
(version_compare("255.255.255.255", $ip, "=="))) { |
$this->sys->setHostname($result); // internal ip |
} else { |
$this->sys->setHostname(gethostbyaddr($ip)); |
$hostname = gethostbyaddr($ip); |
if ($hostname !== false) |
$this->sys->setHostname($hostname); |
else |
$this->sys->setHostname($result); |
} |
} else { |
$this->sys->setHostname($result); |
} |
} else { |
if (CommonFunctions::readenv('COMPUTERNAME', $hnm)) $this->sys->setHostname($hnm); |
} elseif (defined('PSI_EMU_HOSTNAME')) { |
$this->sys->setHostname(PSI_EMU_HOSTNAME); |
} elseif (CommonFunctions::readenv('COMPUTERNAME', $hnm)) { |
$this->sys->setHostname($hnm); |
} |
} |
} |
413,7 → 493,7 |
*/ |
protected function _users() |
{ |
if (CommonFunctions::executeProgram('quser', '', $strBuf, false) && (strlen($strBuf) > 0)) { |
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::executeProgram('quser', '', $strBuf, false) && (strlen($strBuf) > 0)) { |
$lines = preg_split('/\n/', $strBuf); |
$users = count($lines)-1; |
} else { |
460,13 → 540,17 |
else |
$icon = 'Win8.png'; |
$this->sys->setDistributionIcon($icon); |
} elseif (CommonFunctions::executeProgram('cmd', '/c ver 2>nul', $ver_value, false)) { |
if (preg_match("/ReactOS\r?\nVersion\s+(.+)/", $ver_value, $ar_temp)) { |
$this->sys->setDistribution("ReactOS"); |
$this->sys->setKernel($ar_temp[1]); |
} elseif ($this->_ver !== "") { |
if (preg_match("/ReactOS\r?\n\S+\s+(.+)/", $this->_ver, $ar_temp)) { |
if (preg_match("/^(\d+\.\d+\.\d+[\S]*)(.+)$/", trim($ar_temp[1]), $ver_temp)) { |
$this->sys->setDistribution("ReactOS ".trim($ver_temp[1])); |
$this->sys->setKernel(trim($ver_temp[2])); |
} else { |
$this->sys->setDistribution("ReactOS"); |
$this->sys->setKernel($ar_temp[1]); |
} |
$this->sys->setDistributionIcon('ReactOS.png'); |
$this->_wmi = false; // No WMI info on ReactOS yet |
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*(.+)\]/", $ver_value, $ar_temp)) { |
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*(.+)\]/", $this->_ver, $ar_temp)) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false) && (strlen($strBuf) > 0)) { |
if (preg_match("/^Microsoft /", $strBuf)) { |
$this->sys->setDistribution($strBuf); |
488,12 → 572,12 |
$icon = 'WinXP.png'; |
$this->sys->setDistributionIcon($icon); |
} else { |
$this->sys->setDistribution("WinNT"); |
$this->sys->setDistributionIcon('Win2000.png'); |
$this->sys->setDistribution("WINNT"); |
$this->sys->setDistributionIcon('WINNT.png'); |
} |
} else { |
$this->sys->setDistribution("WinNT"); |
$this->sys->setDistributionIcon('Win2000.png'); |
$this->sys->setDistribution("WINNT"); |
$this->sys->setDistributionIcon('WINNT.png'); |
} |
} |
542,7 → 626,7 |
$allCpus = $this->_get_Win32_Processor(); |
if (!$allCpus) { |
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor"; |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) { |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $coreCount) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) { |
$allCpus[$coreCount]['Name'] = $strBuf; |
611,19 → 695,75 |
private function _machine() |
{ |
$buffer = $this->_get_Win32_ComputerSystem(); |
if ($buffer) { |
$buf = ""; |
if (isset($buffer[0]['Manufacturer']) && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=$buffer[0]['Manufacturer'])) { |
$bufferp = CommonFunctions::getWMI($this->_wmi, 'Win32_BaseBoard', array('Product')); |
$bufferb = CommonFunctions::getWMI($this->_wmi, 'Win32_BIOS', array('SMBIOSBIOSVersion', 'ReleaseDate')); |
if (!$buffer) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\systemManufacturer", $strBuf, false)) { |
$buffer[0]['Manufacturer'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemProductName", $strBuf, false)) { |
$buffer[0]['Model'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\SystemFamily", $strBuf, false)) { |
$buffer[0]['SystemFamily'] = $strBuf; |
} |
} |
if (!$bufferp) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BaseBoardProduct", $strBuf, false)) { |
$bufferp[0]['Product'] = $strBuf; |
} |
} |
if (!$bufferb) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSVersion", $strBuf, false)) { |
$bufferb[0]['SMBIOSBIOSVersion'] = $strBuf; |
} |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSReleaseDate", $strBuf, false)) { |
$bufferb[0]['ReleaseDate'] = $strBuf; |
} |
} |
$buf = ""; |
$model = ""; |
if ($buffer && isset($buffer[0])) { |
if (isset($buffer[0]['Manufacturer']) && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=trim($buffer[0]['Manufacturer'])) && ($buf2 !== "")) { |
$buf .= ' '.$buf2; |
} |
if (isset($buffer[0]['Model']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=$buffer[0]['Model'])) { |
if (isset($buffer[0]['Model']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=trim($buffer[0]['Model'])) && ($buf2 !== "")) { |
$model = $buf2; |
$buf .= ' '.$buf2; |
} |
if (trim($buf) != "") { |
$this->sys->setMachine(trim($buf)); |
} |
if ($bufferp && isset($bufferp[0])) { |
if (isset($bufferp[0]['Product']) && !preg_match("/^To be filled by O\.E\.M\.$|^BaseBoard Product Name$|^Not Specified$|^Default string$/i", $buf2=trim($bufferp[0]['Product'])) && ($buf2 !== "")) { |
if ($buf2 !== $model) { |
$buf .= '/'.$buf2; |
} elseif (isset($buffer[0]['SystemFamily']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Family$|^Not Specified$/i", $buf2=trim($buffer[0]['SystemFamily'])) && ($buf2 !== "")) { |
$buf .= '/'.$buf2; |
} |
} |
} |
if ($bufferb && isset($bufferb[0])) { |
$bver = ""; |
$brel = ""; |
if (isset($bufferb[0]['SMBIOSBIOSVersion']) && (($buf2=trim($bufferb[0]['SMBIOSBIOSVersion'])) !== "")) { |
$bver .= ' '.$buf2; |
} |
if (isset($bufferb[0]['ReleaseDate'])) { |
if (preg_match("/^(\d{4})(\d{2})(\d{2})\d{6}\.\d{6}\+\d{3}$/", $bufferb[0]['ReleaseDate'], $dateout)) { |
$brel .= ' '.$dateout[2].'/'.$dateout[3].'/'.$dateout[1]; |
} elseif (preg_match("/^\d{2}\/\d{2}\/\d{4}$/", $bufferb[0]['ReleaseDate'])) { |
$brel .= ' '.$bufferb[0]['ReleaseDate']; |
} |
} |
if ((trim($bver) !== "") || (trim($brel) !== "")) { |
$buf .= ', BIOS'.$bver.$brel; |
} |
} |
if (trim($buf) != "") { |
$this->sys->setMachine(trim($buf)); |
} |
} |
/** |
637,7 → 777,11 |
$dev = new HWDevice(); |
$dev->setName($pciDev['Name']); |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
$dev->setManufacturer($pciDev['Manufacturer']); |
if (($pciDev['Manufacturer'] !== null) && preg_match("/^@[^\.]+\.inf,%([^%]+)%$/i", trim($pciDev['Manufacturer']), $mbuff)) { |
$dev->setManufacturer($mbuff[1]); |
} else { |
$dev->setManufacturer($pciDev['Manufacturer']); |
} |
$dev->setProduct($pciDev['Product']); |
} |
$this->sys->setPciDevices($dev); |
698,16 → 842,16 |
if ($allDevices) { |
$aliases = array(); |
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"; |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) { |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $netID) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) { //a w Name jest net alias |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) { |
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$strInstanceID."\\FriendlyName", $strName, false)) { |
$cname = str_replace(array('(', ')', '#'), array('[', ']', '_'), $strName); //convert to canonical |
$cname = str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strName); //convert to canonical |
if (!isset($aliases[$cname])) { // duplicate checking |
$aliases[$cname]['id'] = $netID; |
$aliases[$cname]['name'] = $strName; |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\Name", $strCName, false) |
&& (str_replace(array('(', ')', '#'), array('[', ']', '_'), $strCName) !== $cname)) { |
&& (str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strCName) !== $cname)) { |
$aliases[$cname]['netname'] = $strCName; |
} |
} else { |
720,11 → 864,11 |
$aliases2 = array(); |
$hkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"; |
if (CommonFunctions::enumKey($this->_key, $hkey, $arrBuf, false)) { |
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) { |
foreach ($arrBuf as $netCount) { |
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\Description", $strName, false) |
&& CommonFunctions::readReg($this->_reg, $hkey."\\".$netCount."\\ServiceName", $strGUID, false)) { |
$cname = str_replace(array('(', ')', '#'), array('[', ']', '_'), $strName); //convert to canonical |
$cname = str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strName); //convert to canonical |
if (!isset($aliases2[$cname])) { // duplicate checking |
$aliases2[$cname]['id'] = $strGUID; |
$aliases2[$cname]['name'] = $strName; |
965,7 → 1109,7 |
public function _processes() |
{ |
$processes['*'] = 0; |
if (CommonFunctions::executeProgram('qprocess', '*', $strBuf, false) && (strlen($strBuf) > 0)) { |
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::executeProgram('qprocess', '*', $strBuf, false) && (strlen($strBuf) > 0)) { |
$lines = preg_split('/\n/', $strBuf); |
$processes['*'] = (count($lines)-1) - 3 ; //correction for process "qprocess *" |
} |
978,6 → 1122,184 |
} |
/** |
* MEM information |
* |
* @return void |
*/ |
private function _meminfo() |
{ |
$allMems = CommonFunctions::getWMI($this->_wmi, 'Win32_PhysicalMemory', array('PartNumber', 'DeviceLocator', 'Capacity', 'Manufacturer', 'SerialNumber', 'Speed', 'ConfiguredClockSpeed', 'ConfiguredVoltage', 'MemoryType', 'SMBIOSMemoryType', 'FormFactor', 'DataWidth', 'TotalWidth', 'BankLabel', 'MinVoltage', 'MaxVoltage')); |
if ($allMems) { |
$reg = false; |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
$arrMems = CommonFunctions::getWMI($this->_wmi, 'Win32_PhysicalMemoryArray', array('MemoryErrorCorrection')); |
$reg = (count($arrMems) == 1) && isset($arrMems[0]['MemoryErrorCorrection']) && ($arrMems[0]['MemoryErrorCorrection'] == 6); |
} |
foreach ($allMems as $mem) { |
$dev = new HWDevice(); |
$name = ''; |
if (isset($mem['PartNumber']) && !preg_match("/^PartNum\d+$/", $part = $mem['PartNumber']) && ($part != '') && ($part != 'None') && ($part != 'N/A') && ($part != 'NOT AVAILABLE')) { |
$name = $part; |
} |
if (isset($mem['DeviceLocator']) && (($dloc = $mem['DeviceLocator']) != '') && ($dloc != 'None') && ($dloc != 'N/A')) { |
if ($name != '') { |
$name .= ' - '.$dloc; |
} else { |
$name = $dloc; |
} |
} |
if (isset($mem['BankLabel']) && (($bank = $mem['BankLabel']) != '') && ($bank != 'None') && ($bank != 'N/A')) { |
if ($name != '') { |
$name .= ' in '.$bank; |
} else { |
$name = 'Physical Memory in '.$bank; |
} |
} |
if ($name != '') { |
$dev->setName(trim($name)); |
} else { |
$dev->setName('Physical Memory'); |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) { |
if (isset($mem['Manufacturer']) && !preg_match("/^([A-F\d]{4}|[A-F\d]{12}|[A-F\d]{16})$/", $manufacturer = $mem['Manufacturer']) && !preg_match("/^Manufacturer\d+$/", $manufacturer) && !preg_match("/^Mfg \d+$/", $manufacturer) && ($manufacturer != '') && ($manufacturer != 'None') && ($manufacturer != 'N/A') && ($manufacturer != 'UNKNOWN')) { |
$dev->setManufacturer($manufacturer); |
} |
if (isset($mem['Capacity'])) { |
$dev->setCapacity($mem['Capacity']); |
} |
$memtype = ''; |
if (isset($mem['MemoryType']) && (($memval = $mem['MemoryType']) != 0)) { |
switch ($memval) { |
// case 0: $memtype = 'Unknown'; break; |
// case 1: $memtype = 'Other'; break; |
case 2: $memtype = 'DRAM'; break; |
case 3: $memtype = 'Synchronous DRAM'; break; |
case 4: $memtype = 'Cache DRAM'; break; |
case 5: $memtype = 'EDO'; break; |
case 6: $memtype = 'EDRAM'; break; |
case 7: $memtype = 'VRAM'; break; |
case 8: $memtype = 'SRAM'; break; |
case 9: $memtype = 'RAM'; break; |
case 10: $memtype = 'ROM'; break; |
case 11: $memtype = 'Flash'; break; |
case 12: $memtype = 'EEPROM'; break; |
case 13: $memtype = 'FEPROM'; break; |
case 14: $memtype = 'EPROM'; break; |
case 15: $memtype = 'CDRAM'; break; |
case 16: $memtype = '3DRAM'; break; |
case 17: $memtype = 'SDRAM'; break; |
case 18: $memtype = 'SGRAM'; break; |
case 19: $memtype = 'RDRAM'; break; |
case 20: $memtype = 'DDR'; break; |
case 21: $memtype = 'DDR2'; break; |
case 22: $memtype = 'DDR2 FB-DIMM'; break; |
case 24: $memtype = 'DDR3'; break; |
case 25: $memtype = 'FBD2'; break; |
case 26: $memtype = 'DDR4'; break; |
} |
} elseif (isset($mem['SMBIOSMemoryType'])) { |
switch ($mem['SMBIOSMemoryType']) { |
// case 0: $memtype = 'Invalid'; break; |
// case 1: $memtype = 'Other'; break; |
// case 2: $memtype = 'Unknown'; break; |
case 3: $memtype = 'DRAM'; break; |
case 4: $memtype = 'EDRAM'; break; |
case 5: $memtype = 'VRAM'; break; |
case 6: $memtype = 'SRAM'; break; |
case 7: $memtype = 'RAM'; break; |
case 8: $memtype = 'ROM'; break; |
case 9: $memtype = 'FLASH'; break; |
case 10: $memtype = 'EEPROM'; break; |
case 11: $memtype = 'FEPROM'; break; |
case 12: $memtype = 'EPROM'; break; |
case 13: $memtype = 'CDRAM'; break; |
case 14: $memtype = '3DRAM'; break; |
case 15: $memtype = 'SDRAM'; break; |
case 16: $memtype = 'SGRAM'; break; |
case 17: $memtype = 'RDRAM'; break; |
case 18: $memtype = 'DDR'; break; |
case 19: $memtype = 'DDR2'; break; |
case 20: $memtype = 'DDR2 FB-DIMM'; break; |
case 24: $memtype = 'DDR3'; break; |
case 25: $memtype = 'FBD2'; break; |
case 26: $memtype = 'DDR4'; break; |
case 27: $memtype = 'LPDDR'; break; |
case 28: $memtype = 'LPDDR2'; break; |
case 29: $memtype = 'LPDDR3'; break; |
case 30: $memtype = 'DDR3'; break; |
case 31: $memtype = 'FBD2'; break; |
case 32: $memtype = 'Logical non-volatile device'; break; |
case 33: $memtype = 'HBM2'; break; |
case 34: $memtype = 'DDR5'; break; |
case 35: $memtype = 'LPDDR5'; break; |
} |
} |
if (isset($mem['Speed']) && (($speed = $mem['Speed']) > 0) && (preg_match('/^(DDR\d*)(.*)/', $memtype, $dr) || preg_match('/^(SDR)AM(.*)/', $memtype, $dr))) { |
if (isset($mem['MinVoltage']) && isset($mem['MaxVoltage']) && (($minv = $mem['MinVoltage']) > 0) && (($maxv = $mem['MaxVoltage']) > 0) && ($minv < $maxv)) { |
$lv = 'L'; |
} else { |
$lv = ''; |
} |
if (isset($dr[2])) { |
$memtype = $dr[1].$lv.'-'.$speed.' '.$dr[2]; |
} else { |
$memtype = $dr[1].$lv.'-'.$speed; |
} |
} |
if (isset($mem['FormFactor'])) { |
switch ($mem['FormFactor']) { |
// case 0: $memtype .= ' Unknown'; break; |
// case 1: $memtype .= ' Other'; break; |
case 2: $memtype .= ' SIP'; break; |
case 3: $memtype .= ' DIP'; break; |
case 4: $memtype .= ' ZIP'; break; |
case 5: $memtype .= ' SOJ'; break; |
case 6: $memtype .= ' Proprietary'; break; |
case 7: $memtype .= ' SIMM'; break; |
case 8: $memtype .= ' DIMM'; break; |
case 9: $memtype .= ' TSOPO'; break; |
case 10: $memtype .= ' PGA'; break; |
case 11: $memtype .= ' RIM'; break; |
case 12: $memtype .= ' SODIMM'; break; |
case 13: $memtype .= ' SRIMM'; break; |
case 14: $memtype .= ' SMD'; break; |
case 15: $memtype .= ' SSMP'; break; |
case 16: $memtype .= ' QFP'; break; |
case 17: $memtype .= ' TQFP'; break; |
case 18: $memtype .= ' SOIC'; break; |
case 19: $memtype .= ' LCC'; break; |
case 20: $memtype .= ' PLCC'; break; |
case 21: $memtype .= ' BGA'; break; |
case 22: $memtype .= ' FPBGA'; break; |
case 23: $memtype .= ' LGA'; break; |
} |
} |
if (isset($mem['DataWidth']) && isset($mem['TotalWidth']) && (($dataw = $mem['DataWidth']) > 0) && (($totalw = $mem['TotalWidth']) > 0) && ($dataw < $totalw)) { |
$memtype .= ' ECC'; |
} |
if ($reg) { |
$memtype .= ' REG'; |
} |
if (($memtype = trim($memtype)) != '') { |
$dev->setProduct($memtype); |
} |
if (isset($mem['ConfiguredClockSpeed']) && (($clock = $mem['ConfiguredClockSpeed']) > 0)) { |
$dev->setSpeed($clock); |
} |
if (isset($mem['ConfiguredVoltage']) && (($voltage = $mem['ConfiguredVoltage']) > 0)) { |
$dev->setVoltage($voltage/1000); |
} |
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && |
isset($mem['SerialNumber']) && !preg_match("/^SerNum\d+$/", $serial = $mem['SerialNumber']) && ($serial != '') && ($serial != 'None')) { |
$dev->setSerial($serial); |
} |
} |
$this->sys->setMemDevices($dev); |
} |
} |
} |
/** |
* get the information |
* |
* @see PSI_Interface_OS::build() |
1003,6 → 1325,7 |
if (!$this->blockname || $this->blockname==='hardware') { |
$this->_machine(); |
$this->_cpuinfo(); |
$this->_meminfo(); |
$this->_hardware(); |
} |
if (!$this->blockname || $this->blockname==='filesystem') { |