Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2976 → Rev 3037

/web/acc/phpsysinfo/includes/os/class.AIX.inc.php
26,7 → 26,14
*/
class AIX extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* prtconf command result.
*/
private $_aixdata = array();
 
/**
35,7 → 42,7
*/
private function _hostname()
{
/* if (PSI_USE_VHOST === true) {
/* if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $ret)) {
64,8 → 71,8
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
81,8 → 88,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
329,11 → 336,11
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The AIX version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The AIX version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
349,9 → 356,6
$this->_scsi();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
358,5 → 362,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Android.inc.php
179,7 → 179,7
if (($lines = $this->_get_buildprop()) && preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) {
$buf = trim($ar_buf[1]);
}
if (is_null($buf) || ($buf == "")) {
if (($buf === null) || ($buf == "")) {
$this->sys->setDistribution('Android');
} else {
if (preg_match('/^(\d+\.\d+)/', $buf, $ver)
241,7 → 241,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
257,13 → 257,11
if (!$this->blockname || $this->blockname==='hardware') {
$this->_machine();
$this->_cpuinfo();
$this->_virtualizer();
$this->_pci();
$this->_usb();
$this->_i2c();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
270,5 → 268,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.BSDCommon.inc.php
28,6 → 28,11
abstract class BSDCommon extends OS
{
/**
* Assoc array of all CPUs loads.
*/
private $_cpu_loads = null;
 
/**
* content of the syslog
*
* @var array
210,7 → 215,7
*/
protected function hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $buf, PSI_DEBUG)) {
236,18 → 241,40
}
 
/**
* Processor Load
* optionally create a loadbar
* Virtualizer info
*
* @return void
*/
protected function loadavg()
private function virtualizer()
{
$s = $this->grabkey('vm.loadavg');
$s = preg_replace('/{ /', '', $s);
$s = preg_replace('/ }/', '', $s);
$this->sys->setLoad($s);
if (PSI_LOAD_BAR) {
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$testvirt = $this->sys->getVirtualizer();
$novm = true;
foreach ($testvirt as $virtkey=>$virtvalue) if ($virtvalue) {
$novm = false;
break;
}
// Detect QEMU cpu
if ($novm && isset($testvirt["cpuid:QEMU"])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
}
 
if ($novm && isset($testvirt["hypervisor"])) {
$this->sys->setVirtualizer('unknown');
}
}
}
 
/**
* CPU usage
*
* @return void
*/
protected function cpuusage()
{
if (($this->_cpu_loads === null)) {
$this->_cpu_loads = array();
if (PSI_OS != 'Darwin') {
if ($fd = $this->grabkey('kern.cp_time')) {
// Find out the CPU load
262,13 → 289,17
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));
if ($total2 != $total) {
$this->_cpu_loads['cpu'] = (100 * ($load2 - $load)) / ($total2 - $total);
} else {
$this->_cpu_loads['cpu'] = 0;
}
}
}
}
} else {
$ncpu = $this->grabkey('hw.ncpu');
if (!is_null($ncpu) && (trim($ncpu) != "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) {
if (($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);
276,14 → 307,38
foreach ($pslines as $psline) {
$sum+=trim($psline);
}
$this->sys->setLoadPercent(min($sum/$ncpu, 100));
$this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
}
}
}
}
 
if (isset($this->_cpu_loads['cpu'])) {
return $this->_cpu_loads['cpu'];
} else {
return null;
}
}
 
/**
* Processor Load
* optionally create a loadbar
*
* @return void
*/
protected function loadavg()
{
$s = $this->grabkey('vm.loadavg');
$s = preg_replace('/{ /', '', $s);
$s = preg_replace('/ }/', '', $s);
$this->sys->setLoad($s);
 
if (PSI_LOAD_BAR) {
$this->sys->setLoadPercent($this->cpuusage());
}
}
 
/**
* CPU information
*
* @return void
291,39 → 346,43
protected function cpuinfo()
{
$dev = new CpuDevice();
 
if (PSI_OS == 'NetBSD') {
if ($model = $this->grabkey('machdep.cpu_brand')) {
$dev->setModel($model);
}
if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
$dev->setCpuSpeed(round($cpuspeed / 1000000));
}
$cpumodel = $this->grabkey('hw.model');
$dev->setModel($cpumodel);
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
$this->sys->setVirtualizer("cpuid:QEMU", false);
}
 
if ($dev->getModel() === "") {
$dev->setModel($this->grabkey('hw.model'));
}
$notwas = true;
foreach ($this->readdmesg() as $line) {
if ($notwas) {
if (preg_match($this->_CPURegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
if ($dev->getCpuSpeed() === 0) {
$dev->setCpuSpeed(round($ar_buf[2]));
$regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
foreach ($regexps as $regexp) {
if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
if ($dev->getCpuSpeed() === 0) {
$dev->setCpuSpeed(round($ar_buf[2]));
}
$notwas = false;
break;
}
$notwas = false;
}
} else {
if (preg_match("/ Origin| Features/", $line, $ar_buf)) {
if (preg_match("/ Features2[ ]*=.*<(.*)>/", $line, $ar_buf)) {
if (preg_match("/^\s+Origin| Features/", $line, $ar_buf)) {
if (preg_match("/^\s+Origin[ ]*=[ ]*\"(.+)\"/", $line, $ar_buf)) {
$dev->setVendorId($ar_buf[1]);
} elseif (preg_match("/ Features2[ ]*=.*<(.+)>/", $line, $ar_buf)) {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if (($feat=="vmx") || ($feat=="svm")) {
$dev->setVirt($feat);
break 2;
} elseif ($feat=="hv") {
if ($dev->getVirt() === null) {
$dev->setVirt('hypervisor');
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
}
break;
}
} else break;
}
330,8 → 389,12
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
$this->sys->setCpus($dev);
}
338,6 → 401,99
}
 
/**
* Machine information
*
* @return void
*/
private function machine()
{
if ((PSI_OS == 'NetBSD') || (PSI_OS == 'OpenBSD')) {
$buffer = array();
if (PSI_OS == 'NetBSD') { // NetBSD
$buffer['Manufacturer'] = $this->grabkey('machdep.dmi.system-vendor');
$buffer['Model'] = $this->grabkey('machdep.dmi.system-product');
$buffer['Product'] = $this->grabkey('machdep.dmi.board-product');
$buffer['SMBIOSBIOSVersion'] = $this->grabkey('machdep.dmi.bios-version');
$buffer['ReleaseDate'] = $this->grabkey('machdep.dmi.bios-date');
} else { // OpenBSD
$buffer['Manufacturer'] = $this->grabkey('hw.vendor');
$buffer['Model'] = $this->grabkey('hw.product');
$buffer['Product'] = "";
$buffer['SMBIOSBIOSVersion'] = "";
$buffer['ReleaseDate'] = "";
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$vendor_array = array();
$vendor_array[] = $buffer['Model'];
$vendor_array[] = trim($buffer['Manufacturer']." ".$buffer['Model']);
if (PSI_OS == 'NetBSD') { // NetBSD
$vendor_array[] = $this->grabkey('machdep.dmi.board-vendor');
$vendor_array[] = $this->grabkey('machdep.dmi.bios-vendor');
}
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
}
}
 
$buf = "";
if (($buffer['Manufacturer'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=trim($buffer['Manufacturer'])) && ($buf2 !== "")) {
$buf .= ' '.$buf2;
}
 
if (($buffer['Model'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=trim($buffer['Model'])) && ($buf2 !== "")) {
$model = $buf2;
$buf .= ' '.$buf2;
}
if (($buffer['Product'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^BaseBoard Product Name$|^Not Specified$|^Default string$/i", $buf2=trim($buffer['Product'])) && ($buf2 !== "")) {
if ($buf2 !== $model) {
$buf .= '/'.$buf2;
} elseif (isset($buffer['SystemFamily']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Family$|^Not Specified$/i", $buf2=trim($buffer['SystemFamily'])) && ($buf2 !== "")) {
$buf .= '/'.$buf2;
}
}
 
$bver = "";
$brel = "";
if (($buf2=trim($buffer['SMBIOSBIOSVersion'])) !== "") {
$bver .= ' '.$buf2;
}
if ($buffer['ReleaseDate'] !== "") {
if (preg_match("/^(\d{4})(\d{2})(\d{2})$/", $buffer['ReleaseDate'], $dateout)) {
$brel .= ' '.$dateout[2].'/'.$dateout[3].'/'.$dateout[1];
} elseif (preg_match("/^\d{2}\/\d{2}\/\d{4}$/", $buffer['ReleaseDate'])) {
$brel .= ' '.$buffer['ReleaseDate'];
}
}
if ((trim($bver) !== "") || (trim($brel) !== "")) {
$buf .= ', BIOS'.$bver.$brel;
}
 
if (trim($buf) !== "") {
$this->sys->setMachine(trim($buf));
}
} elseif ((PSI_OS == 'FreeBSD') && defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$vendorid = $this->grabkey('hw.hv_vendor');
if (trim($vendorid) === "") {
foreach ($this->readdmesg() as $line) if (preg_match("/^Hypervisor: Origin = \"(.+)\"/", $line, $ar_buf)) {
if (trim($ar_buf[1]) !== "") {
$vendorid = $ar_buf[1];
}
break;
}
}
if (trim($vendorid) !== "") {
$virt = CommonFunctions::decodevirtualizer($vendorid);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
} else {
$this->sys->setVirtualizer('unknown');
}
}
}
}
 
/**
* SCSI devices
* get the scsi device information out of dmesg
*
404,8 → 560,8
}
/* cleaning */
foreach ($this->sys->getScsiDevices() as $finddev) {
if (strpos($finddev->getName(), ': ') !== false)
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
if (strpos($finddev->getName(), ': ') !== false)
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
}
}
 
658,11 → 814,34
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function uptime()
{
if ($kb = $this->grabkey('kern.boottime')) {
if (preg_match("/sec = ([0-9]+)/", $kb, $buf)) { // format like: { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004
$this->sys->setUptime(time() - $buf[1]);
} else {
date_default_timezone_set('UTC');
$kbt = strtotime($kb);
if (($kbt !== false) && ($kbt != -1)) {
$this->sys->setUptime(time() - $kbt); // format like: Sat Oct 2 10:56:40 2004
} else {
$this->sys->setUptime(time() - $kb); // format like: 1096732600
}
}
}
}
 
/**
* get the information
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
672,9 → 851,12
$this->kernel();
$this->_users();
$this->loadavg();
$this->uptime();
}
if (!$this->blockname || $this->blockname==='hardware') {
$this->machine();
$this->cpuinfo();
$this->virtualizer();
$this->pci();
$this->ide();
$this->scsi();
/web/acc/phpsysinfo/includes/os/class.Darwin.inc.php
90,25 → 90,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('sysctl', '-n kern.boottime', $a, PSI_DEBUG)) {
$tmp = explode(" ", $a);
if ($tmp[0]=="{") { /* kern.boottime= { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004 */
$data = trim($tmp[3], ",");
$this->sys->setUptime(time() - $data);
} else { /* kern.boottime= 1096732600 */
$this->sys->setUptime(time() - $a);
}
}
}
 
/**
* get CPU information
*
* @return void
119,9 → 100,9
if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
$dev->setModel(preg_replace('/Processor type: /', '', $buf));
$buf=$this->grabkey('hw.model');
if (!is_null($buf) && (trim($buf) != "")) {
if (($buf !== null) && (trim($buf) != "")) {
$this->sys->setMachine(trim($buf));
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ModelTranslation.txt', $buffer)) {
if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($buffer as $line) {
$ar_buf = preg_split("/:/", $line, 3);
134,12 → 115,12
}
}
$buf=$this->grabkey('machdep.cpu.brand_string');
if (!is_null($buf) && (trim($buf) != "") &&
if (($buf !== null) && (trim($buf) != "") &&
((trim($buf) != "i486 (Intel 80486)") || ($dev->getModel() == ""))) {
$dev->setModel(trim($buf));
}
$buf=$this->grabkey('machdep.cpu.features');
if (!is_null($buf) && (trim($buf) != "")) {
if (($buf !== null) && (trim($buf) != "")) {
if (preg_match("/ VMX/", $buf)) {
$dev->setVirt("vmx");
} elseif (preg_match("/ SVM/", $buf)) {
151,17 → 132,21
$dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
$bufn=$this->grabkey('hw.cpufrequency_min');
$bufx=$this->grabkey('hw.cpufrequency_max');
if (!is_null($bufn) && (trim($bufn) != "") && !is_null($bufx) && (trim($bufx) != "") && ($bufn != $bufx)) {
if (($bufn !== null) && (trim($bufn) != "") && ($bufx !== null) && (trim($bufx) != "") && ($bufn != $bufx)) {
$dev->setCpuSpeedMin(round($bufn / 1000000));
$dev->setCpuSpeedMax(round($bufx / 1000000));
}
$buf=$this->grabkey('hw.l2cachesize');
if (!is_null($buf) && (trim($buf) != "")) {
if ($buf !== "") {
$dev->setCache(round($buf));
}
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
$this->sys->setCpus($dev);
}
422,8 → 407,8
$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]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
$distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
}
}
485,13 → 470,12
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='hardware') {
/web/acc/phpsysinfo/includes/os/class.DragonFly.inc.php
32,7 → 32,7
public function __construct($blockname = false)
{
parent::__construct($blockname);
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/\n/^CPU: (.*) \((.*)-MHz (.*)\)/"); // multiple regexp separated by \n
$this->setCPURegExp2("/^(.*) at scsibus.*: <(.*)> .*/");
$this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /");
$this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]+$/");
40,19 → 40,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
preg_match("/sec = ([0-9]+)/", $a, $buf);
$this->sys->setUptime(time() - $buf[1]);
}
 
/**
* get network information
*
* @return void
140,7 → 127,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
147,7 → 134,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.FreeBSD.inc.php
42,19 → 42,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$s = preg_split('/ /', $this->grabkey('kern.boottime'));
$a = preg_replace('/,/', '', $s[3]);
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
195,7 → 182,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
202,14 → 189,13
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memoryadditional();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memoryadditional();
}
}
}
/web/acc/phpsysinfo/includes/os/class.HPUX.inc.php
27,6 → 27,11
class HPUX extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* Virtual Host Name
*
* @return void
33,7 → 38,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('hostname', '', $ret)) {
62,8 → 67,8
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[3];
$hours = $ar_buf[2];
$days = $ar_buf[1];
80,8 → 85,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
125,7 → 130,6
case 'bogomips':
case 'cpu0bogo':
$dev->setBogomips($arrBuff[1]);
break;
}
}
}
358,7 → 362,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
377,9 → 381,6
$this->_scsi();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
386,5 → 387,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Haiku.inc.php
217,7 → 217,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
368,11 → 368,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
387,9 → 387,6
$this->_pci();
$this->_usb();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
396,5 → 393,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php
27,55 → 27,231
class Linux extends OS
{
/**
* Uptime command result.
*/
private $_uptime = null;
 
/**
* Assoc array of all CPUs loads.
*/
private $_cpu_loads = null;
 
/**
* Machine
*
* @return void
* Version string.
*/
private function _machine()
private $_kernel_string = null;
 
/**
* Array of info from Bios.
*/
private $_machine_info = null;
 
/**
* Array of info from dmesg.
*/
private $_dmesg_info = null;
 
/**
* Result of systemd-detect-virt.
*/
private $system_detect_virt = null;
 
/**
* Get info from dmesg
*
* @return array
*/
private function _get_dmesg_info()
{
$machine = "";
if ((CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)
&& preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))
||(CommonFunctions::executeProgram('dmesg', '', $result, false)
&& preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))) {
$machine = trim($ar_buf[1]);
} else { //data from /sys/devices/virtual/dmi/id/
$product = "";
$board = "";
$bios = "";
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$machine = trim($buf);
if ($this->_dmesg_info === null) {
$this->_dmesg_info = array();
if (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)) {
if (preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['dmi'] = trim($ar_buf[1]);
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$product = trim($buf);
if ((count($this->_dmesg_info) < ((defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null))?2:1)) && CommonFunctions::executeProgram('dmesg', '', $result, false)) {
if (!isset($this->_dmesg_info['dmi']) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['dmi'] = trim($ar_buf[1]);
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && !isset($this->_dmesg_info['hypervisor']) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
$this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$board = trim($buf);
}
 
return $this->_dmesg_info;
}
 
/**
* Get machine info
*
* @return string
*/
private function _get_machine_info()
{
if ($this->_machine_info === null) {
$this->_machine_info = array();
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
if (CommonFunctions::executeProgram('systemd-detect-virt', '-v', $resultv, false)) {
$this->system_detect_virt = $resultv;
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($buf);
$vendor_array = array();
if ((($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['dmi'])) {
$this->_machine_info['machine'] = $dmesg['dmi'];
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
/* Test this before sys_vendor to detect KVM over QEMU */
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = $product_name = trim($buf);
} else {
$product_name = '';
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/sys_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
if ($product_name != "") {
$vendor_array[] = trim($buf)." ".$product_name;
} else {
$vendor_array[] = trim($buf);
}
} else {
$vendor_array[] = $dmesg['dmi'];
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
}
} else { // 'machine' data from /sys/devices/virtual/dmi/id/
$bios = "";
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
// Test this before sys_vendor to detect KVM over QEMU
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = $product_name = trim($buf);
} else {
$product_name = '';
}
 
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/sys_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
if ($product_name != "") {
$this->_machine_info['machine'] = trim($buf)." ".$product_name;
} else {
$this->_machine_info['machine'] = trim($buf);
}
$vendor_array[] = $this->_machine_info["machine"];
} elseif ($product_name != "") {
$this->_machine_info['machine'] = $product_name;
}
 
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$vendor_array[] = trim($buf);
}
} else {
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
$this->_machine_info['machine'] = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= " ".trim($buf);
} else {
$this->_machine_info['machine'] = trim($buf);
}
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= "/".trim($buf);
} else {
$this->_machine_info['machine'] = trim($buf);
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($buf);
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($bios." ".trim($buf));
}
if ($bios != "") {
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] .= ", BIOS ".$bios;
} else {
$this->_machine_info['machine'] = "BIOS ".$bios;
}
}
}
if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) {
$bios = trim($bios." ".trim($buf));
if (isset($this->_machine_info['machine'])) {
$this->_machine_info['machine'] = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $this->_machine_info['machine'])));
}
if ($product != "") {
$machine .= " ".$product;
 
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array)>0) {
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->_machine_info['hypervisor'] = $virt;
}
}
if ($board != "") {
$machine .= "/".$board;
}
 
return $this->_machine_info;
}
 
/**
* Get kernel string
*
* @return string
*/
private function _get_kernel_string()
{
if ($this->_kernel_string === null) {
$this->_kernel_string = "";
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
$this->_kernel_string = $strBuf;
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
}
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
$this->_kernel_string .= ' '.$strBuf;
}
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
$this->_kernel_string = $ar_buf[1];
if (preg_match('/ SMP /', $strBuf)) {
$this->_kernel_string .= ' (SMP)';
}
}
}
if ($bios != "") {
$machine .= ", BIOS ".$bios;
}
}
 
if ($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)));
return $this->_kernel_string;
}
 
/**
* Machine
*
* @return void
*/
private function _machine()
{
$machine_info = $this->_get_machine_info();
if (isset($machine_info['machine'])) {
$machine = $machine_info['machine'];
} else {
$machine = "";
}
 
if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection
84,7 → 260,7
&& CommonFunctions::fileexists($filename="/etc/platform.conf") // Platform detection
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match("/^DISPLAY_NAME\s*=\s*(\S+)/m", $buf, $mach_buf) && ($mach_buf[1]!=="")) {
if ($machine != "") {
if ($machine !== "") {
$machine = "QNAP ".$mach_buf[1].' - '.$machine;
} else {
$machine = "QNAP ".$mach_buf[1];
91,7 → 267,7
}
}
 
if ($machine != "") {
if ($machine !== "") {
$this->sys->setMachine($machine);
}
}
103,7 → 279,7
*/
protected function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
115,7 → 291,6
} elseif (CommonFunctions::executeProgram('hostname', '', $ret)) {
$this->sys->setHostname($ret);
}
 
}
}
 
126,42 → 301,216
*/
private function _kernel()
{
$result = "";
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
$result = $strBuf;
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
if (preg_match('/SMP/', $strBuf)) {
$result .= ' (SMP)';
if (($verBuf = $this->_get_kernel_string()) != "") {
$this->sys->setKernel($verBuf);
}
}
 
/**
* Virtualizer info
*
* @return void
*/
protected function _virtualizer()
{
if (!defined('PSI_SHOW_VIRTUALIZER_INFO') || !PSI_SHOW_VIRTUALIZER_INFO) {
return;
}
if ($this->system_detect_virt !== null) {
if (($this->system_detect_virt !== "") && ($this->system_detect_virt !== "none")) {
$this->sys->setVirtualizer($this->system_detect_virt);
}
if (($verBuf = $this->_get_kernel_string()) !== "") {
if (preg_match('/^[\d\.-]+-microsoft-standard/', $verBuf)) {
$this->sys->setVirtualizer('wsl2', 'wsl'); // Windows Subsystem for Linux 2
}
}
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
$result .= ' '.$strBuf;
if (CommonFunctions::executeProgram('systemd-detect-virt', '-c', $resultc, false) && ($resultc !== "") && ($resultc !== "none")) {
$this->sys->setVirtualizer($resultc);
}
} 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)';
} else {
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo()
 
$novm = true;
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd)
 
// First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if
// it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process
// nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested
// inside another hypervisor.
$machine_info = $this->_get_machine_info();
if (isset($machine_info['hypervisor'])) {
$hypervisor = $machine_info['hypervisor'];
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen')) {
$this->sys->setVirtualizer($hypervisor);
$novm = false;
}
}
}
if ($result != "") {
 
// Detect UML
if ($novm) {
if (isset($cpuvirt["cpuid:UserModeLinux"])) {
$this->sys->setVirtualizer('uml'); // User-mode Linux
$novm = false;
}
}
 
// Detect Xen
if ($novm && is_dir('/proc/xen')) {
// xen Dom0 is detected as XEN in hypervisor and maybe others.
// In order to detect the Dom0 as not virtualization we need to
// double-check it
if (CommonFunctions::rfts('/sys/hypervisor/properties/features', $features, 1, 4096, false)) {
if ((hexdec($features) & 2048) == 0) { // XENFEAT_dom0 is not set
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
} elseif (CommonFunctions::rfts('/proc/xen/capabilities', $capabilities, 1, 4096, false) && !preg_match('/control_d/', $capabilities)) { // control_d not in capabilities
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
}
 
// Second, try to detect from CPUID, this will report KVM for whatever software is used even if info in DMI is overwritten.
// Since the vendor_id in /proc/cpuinfo is overwritten on virtualization we use values from msr-cpuid.
if ($novm && CommonFunctions::executeProgram('msr-cpuid', '', $bufr, false)
&& (preg_match('/^40000000 00000000: [0-9a-f]{8} \S{4} [0-9a-f]{8} ([A-Za-z0-9\.]{4}) [0-9a-f]{8} ([A-Za-z0-9\.]{4}) [0-9a-f]{8} ([A-Za-z0-9\.]{4})/m', $bufr, $cpuid))) {
$virt = CommonFunctions::decodevirtualizer($cpuid[1].$cpuid[2].$cpuid[3]);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
}
}
 
// Third, try to detect from DMI.
if ($novm && isset($hypervisor)) {
$this->sys->setVirtualizer($hypervisor);
$novm = false;
}
 
// Check high-level hypervisor sysfs file
if ($novm && CommonFunctions::rfts('/sys/hypervisor/type', $type, 1, 4096, false) && ($type === "xen")) {
$this->sys->setVirtualizer('xen'); // Xen hypervisor
$novm = false;
}
 
if ($novm) {
if (CommonFunctions::rfts('/proc/device-tree/hypervisor/compatible', $compatible, 1, 4096, false)) {
switch ($compatible) {
case 'linux,kvm':
$this->sys->setVirtualizer('kvm'); // KVM
$novm = false;
break;
case 'vmware':
$this->sys->setVirtualizer('vmware'); // VMware
$novm = false;
break;
case 'xen':
$this->sys->setVirtualizer('xen'); // Xen hypervisor
$novm = false;
}
} else {
if (CommonFunctions::fileexists('/proc/device-tree/ibm,partition-name')
&& CommonFunctions::fileexists('/proc/device-tree/hmc-managed?')
&& CommonFunctions::fileexists('/proc/device-tree/chosen/qemu,graphic-width')) {
$this->sys->setVirtualizer('powervm'); // IBM PowerVM hypervisor
$novm = false;
} else {
$names = CommonFunctions::findglob('/proc/device-tree', GLOB_NOSORT);
if (is_array($names) && (($total = count($names)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (preg_match('/fw-cfg/', $names[$i])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
break;
}
}
}
}
}
}
 
if ($novm && CommonFunctions::rfts('/proc/sysinfo', $sysinfo, 0, 4096, false) && preg_match('//VM00 Control Program:\s*(\S+)/m', $sysinfo, $vcp)) {
if ($vcp[1] === 'z/VM') {
$this->sys->setVirtualizer('zvm'); // s390 z/VM
} else {
$this->sys->setVirtualizer('kvm'); // KVM
}
$novm = false;
}
 
// Additional tests outside of the systemd-detect-virt source code
if ($novm && (($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['hypervisor'])) {
switch ($dmesg['hypervisor']) {
case 'VMware':
$this->sys->setVirtualizer('vmware'); // VMware
$novm = false;
break;
case 'KVM':
$this->sys->setVirtualizer('kvm'); // KVM
$novm = false;
break;
case 'Microsoft HyperV':
case 'Microsoft Hyper-V':
$this->sys->setVirtualizer('microsoft'); // Hyper-V
$novm = false;
break;
case 'ACRN':
$this->sys->setVirtualizer('acrn'); // ACRN hypervisor
$novm = false;
break;
case 'Jailhouse':
$this->sys->setVirtualizer('jailhouse'); // Jailhouse
$novm = false;
break;
case 'Xen':
case 'Xen PV':
case 'Xen HVM':
// xen Dom0 is detected as XEN in hypervisor and maybe others.
// In order to detect the Dom0 as not virtualization we need to
// double-check it
if (CommonFunctions::rfts('/sys/hypervisor/properties/features', $features, 1, 4096, false)) {
if ((hexdec($features) & 2048) == 0) { // XENFEAT_dom0 is not set
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
} elseif (CommonFunctions::rfts('/proc/xen/capabilities', $capabilities, 1, 4096, false) && !preg_match('/control_d/', $capabilities)) { // control_d not in capabilities
$this->sys->setVirtualizer('xen'); // Xen hypervisor (only domU, not dom0)
$novm = false;
}
}
}
 
// Detect QEMU cpu
if ($novm && isset($cpuvirt["cpuid:QEMU"])) {
$this->sys->setVirtualizer('qemu'); // QEMU
$novm = false;
}
 
if ($novm && isset($cpuvirt["hypervisor"])) {
$this->sys->setVirtualizer('unknown');
}
 
if ((count(CommonFunctions::gdc('/proc/vz', false)) == 0) && (count(CommonFunctions::gdc('/proc/bc', false)) > 0)) {
$this->sys->setVirtualizer('openvz'); // OpenVZ/Virtuozzo
}
 
if (($verBuf = $this->_get_kernel_string()) !== "") {
if (preg_match('/^[\d\.-]+-Microsoft/', $verBuf)) {
$this->sys->setVirtualizer('wsl'); // Windows Subsystem for Linux
} elseif (preg_match('/^[\d\.-]+-microsoft-standard/', $verBuf)) {
$this->sys->setVirtualizer('wsl2'); // Windows Subsystem for Linux 2
}
}
 
if (CommonFunctions::rfts('/proc/self/cgroup', $strBuf2, 0, 4096, false)) {
if (preg_match('/:\/lxc\//m', $strBuf2)) {
$result .= ' [lxc]';
if (preg_match('/:\/lxc\//m', $strBuf2)) {
$this->sys->setVirtualizer('lxc'); // Linux container
} elseif (preg_match('/:\/docker\//m', $strBuf2)) {
$result .= ' [docker]';
$this->sys->setVirtualizer('docker'); // Docker
} elseif (preg_match('/:\/system\.slice\/docker\-/m', $strBuf2)) {
$result .= ' [docker]';
$this->sys->setVirtualizer('docker'); // Docker
}
}
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);
}
}
 
176,21 → 525,21
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
$ar_buf = preg_split('/ /', $buf);
$this->sys->setUptime(trim($ar_buf[0]));
} elseif (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
} elseif (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $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+) day[s]?,[ ]+(\d+) min,/", $buf, $ar_buf)) {
} elseif (preg_match("/up (\d+) day[s]?,[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$days = $ar_buf[1];
$this->sys->setUptime($days * 86400 + $min * 60);
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60);
} elseif (preg_match("/up[ ]+(\d+) min,/", $buf, $ar_buf)) {
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[1];
$this->sys->setUptime($min * 60);
}
210,7 → 559,7
// don't need the extra values, only first three
unset($result[3]);
$this->sys->setLoad(implode(' ', $result));
} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/load average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
} elseif ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
if (PSI_LOAD_BAR) {
223,11 → 572,11
*
* @param String $cpuline cpu for which load should be meassured
*
* @return Integer
* @return int
*/
protected function _parseProcStat($cpuline)
{
if (is_null($this->_cpu_loads)) {
if ($this->_cpu_loads === null) {
$this->_cpu_loads = array();
 
$cpu_tmp = array();
295,6 → 644,7
protected function _cpuinfo()
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
 
$cpulist = null;
$raslist = null;
 
318,6 → 668,7
$_arch = null;
$_impl = null;
$_part = null;
$_vari = null;
$_hard = null;
$_revi = null;
$_cpus = null;
340,6 → 691,9
case 'cpu part':
$_part = $arrBuff1;
break;
case 'cpu variant':
$_vari = $arrBuff1;
break;
case 'hardware':
$_hard = $arrBuff1;
break;
361,9 → 715,9
break;
case 'vendor_id':
$_vend = $arrBuff1;
break;
case 'cpu':
$procname = $arrBuff1;
break;
}
}
}
377,6 → 731,7
$arch = null;
$impl = null;
$part = null;
$vari = null;
$dev = new CpuDevice();
$details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
foreach ($details as $detail) {
386,7 → 741,7
case 'processor':
$proc = $arrBuff1;
if (is_numeric($proc)) {
if (strlen($procname)>0) {
if (($procname !== null) && (strlen($procname)>0)) {
$dev->setModel($procname);
}
} else {
402,13 → 757,13
break;
case 'cpu mhz':
case 'clock':
if ($arrBuff1 > 0) { //openSUSE fix
if ($arrBuff1 > 0) { // openSUSE fix
$dev->setCpuSpeed($arrBuff1);
$speedset = true;
}
break;
case 'cpu mhz static':
if ($arrBuff1 > 0) { //openSUSE fix
if ($arrBuff1 > 0) { // openSUSE fix
$dev->setCpuSpeedMax($arrBuff1);
}
break;
434,9 → 789,15
$dev->setVirt("vmx");
} elseif (preg_match("/ svm/", $arrBuff1)) {
$dev->setVirt("svm");
} elseif (preg_match("/ hypervisor/", $arrBuff1)) {
$dev->setVirt("hypervisor");
}
if (preg_match("/ hypervisor/", $arrBuff1)) {
if ($dev->getVirt() === null) {
$dev->setVirt("hypervisor");
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
break;
case 'i size':
case 'd size':
455,9 → 816,14
case 'cpu part':
$part = $arrBuff1;
break;
case 'cpu variant':
$vari = $arrBuff1;
break;
case 'vendor_id':
$dev->setVendorId($arrBuff1);
break;
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $arrBuff1)) {
$this->sys->setVirtualizer("cpuid:UserModeLinux", false);
}
}
}
}
464,6 → 830,7
if ($arch === null) $arch = $_arch;
if ($impl === null) $impl = $_impl;
if ($part === null) $part = $_part;
if ($vari === null) $vari = $_vari;
 
// sparc64 specific code follows
// This adds the ability to display the cache that a CPU has
478,8 → 845,8
// sparc64 specific code ends
 
// XScale detection code
if (($arch === "5TE") && ($dev->getBogomips() != null)) {
$dev->setCpuSpeed($dev->getBogomips()); //BogoMIPS are not BogoMIPS on this CPU, it's the speed
if (($arch === "5TE") && ($dev->getBogomips() !== null)) {
$dev->setCpuSpeed($dev->getBogomips()); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
$speedset = true;
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
}
496,9 → 863,12
}
if (($dev->getVendorId() === null) && ($_vend !== null)) {
$dev->setVendorId($_vend);
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $_vend)) {
$this->sys->setVirtualizer("cpuid:UserModeLinux", false);
}
}
 
if ($proc != null) {
if ($proc !== null) {
if (!is_numeric($proc)) {
$proc = 0;
}
561,11 → 931,12
$this->sys->setMachine($_hard);
}
if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
if ($cpulist && (isset($cpulist['cpu'][$cpuimplpart = strtolower($impl.','.$part)]))) {
if ($cpulist && (((($vari !== null) && isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part.','.$vari)]))
|| isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part)])))) {
if (($cpumodel = $dev->getModel()) !== '') {
$dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpuimplpart]);
$dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]);
} else {
$dev->setModel($cpulist['cpu'][$cpuimplpart]);
$dev->setModel($cpulist['cpu'][$cpufromlist]);
}
}
} elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other hardware
572,15 → 943,23
$this->sys->setMachine($_hard);
}
 
if ($dev->getModel() === "") {
$dev->setModel("unknown");
$cpumodel = $dev->getModel();
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
$this->sys->setVirtualizer("cpuid:QEMU", false);
}
if ($cpumodel === "") {
if (($vendid = $dev->getVendorId()) !== "") {
$dev->setModel($vendid);
} else {
$dev->setModel("unknown");
}
}
$cpucount++;
$this->sys->setCpus($dev);
}
}
 
$cpudevices = glob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
$cpudevices = CommonFunctions::findglob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
if (is_array($cpudevices) && (($cpustopped = count($cpudevices)-$cpucount) > 0)) {
for (; $cpustopped > 0; $cpustopped--) {
$dev = new CpuDevice();
629,7 → 1008,7
}
}
} else {
$pcidevices = glob('/sys/bus/pci/devices/*/uevent', GLOB_NOSORT);
$pcidevices = CommonFunctions::findglob('/sys/bus/pci/devices/*/uevent', GLOB_NOSORT);
if (is_array($pcidevices) && (($total = count($pcidevices)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
717,7 → 1096,7
 
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
&& ($dev_type[1]==='Direct-Access')) {
$sizelist = glob('/sys/bus/scsi/devices/'.intval($scsiid[1]).':'.intval($scsiid[2]).':'.intval($scsiid[3]).':'.intval($scsiid[4]).'/*/*/size', GLOB_NOSORT);
$sizelist = CommonFunctions::findglob('/sys/bus/scsi/devices/'.intval($scsiid[1]).':'.intval($scsiid[2]).':'.intval($scsiid[3]).':'.intval($scsiid[4]).'/*/*/size', GLOB_NOSORT);
if (is_array($sizelist) && (($total = count($sizelist)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
749,7 → 1128,7
$device = preg_split("/ /", $buf, 7);
if (((isset($device[6]) && trim($device[6]) != "")) ||
((isset($device[5]) && trim($device[5]) != ""))) {
$usbid = intval($device[1]).'-'.intval(trim($device[3],':')).' '.$device[5];
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
if ((isset($device[6]) && trim($device[6]) != "")) {
$usbarray[$usbid]['name'] = trim($device[6]);
} else {
759,10 → 1138,10
}
}
 
$usbdevices = glob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { //is readable
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
792,7 → 1171,7
}
}
 
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { //usb-devices
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) {
817,8 → 1196,7
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
&& !preg_match('/\W/', trim($value2))) {
$usbarray[$devnum]['serial'] = trim($value2);
}
break;
}
}
}
}
901,7 → 1279,7
*/
protected function _i2c()
{
$i2cdevices = glob('/sys/bus/i2c/devices/*/name', GLOB_NOSORT);
$i2cdevices = CommonFunctions::findglob('/sys/bus/i2c/devices/*/name', GLOB_NOSORT);
if (is_array($i2cdevices) && (($total = count($i2cdevices)) > 0)) {
$buf = "";
for ($i = 0; $i < $total; $i++) {
957,24 → 1335,23
if (isset($nlocate[4]) && isset($nsize[4])) {
if (preg_match('/\/\s*([0-9\.]+)\s*(B|KB|MB|GB|TB|PB)$/', str_replace(',', '.', trim(substr($buf, $nlocate[4], $nsize[4]))), $tmpbuf)) {
switch ($tmpbuf[2]) {
case 'B':
$dev->setCapacity($tmpbuf[1]);
break;
case 'KB':
$dev->setCapacity(1000*$tmpbuf[1]);
break;
case 'MB':
$dev->setCapacity(1000*1000*$tmpbuf[1]);
break;
case 'GB':
$dev->setCapacity(1000*1000*1000*$tmpbuf[1]);
break;
case 'TB':
$dev->setCapacity(1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'PB':
$dev->setCapacity(1000*1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'B':
$dev->setCapacity($tmpbuf[1]);
break;
case 'KB':
$dev->setCapacity(1000*$tmpbuf[1]);
break;
case 'MB':
$dev->setCapacity(1000*1000*$tmpbuf[1]);
break;
case 'GB':
$dev->setCapacity(1000*1000*1000*$tmpbuf[1]);
break;
case 'TB':
$dev->setCapacity(1000*1000*1000*1000*$tmpbuf[1]);
break;
case 'PB':
$dev->setCapacity(1000*1000*1000*1000*1000*$tmpbuf[1]);
}
}
}
1026,7 → 1403,7
|| 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
if (($macaddr === '00-00-00-00-00-00') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
$macaddr = "";
}
}
1120,7 → 1497,12
if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
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]));
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') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
$macaddr = "";
}
}
} 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]) {
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1265,6 → 1647,8
protected function _memory()
{
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
$swaptotal = null;
$swapfree = null;
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
1275,11 → 1659,15
$this->sys->setMemCache($ar_buf[1] * 1024);
} elseif (preg_match('/^Buffers:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$this->sys->setMemBuffer($ar_buf[1] * 1024);
} elseif (preg_match('/^SwapTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$swaptotal = $ar_buf[1] * 1024;
} elseif (preg_match('/^SwapFree:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
$swapfree = $ar_buf[1] * 1024;
}
}
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
// values for splitting memory usage
if ($this->sys->getMemCache() !== null && $this->sys->getMemBuffer() !== null) {
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) {
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
}
if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
1295,6 → 1683,13
$dev->setFree($dev->getTotal() - $dev->getUsed());
$this->sys->setSwapDevices($dev);
}
} elseif (($swaptotal !== null) && ($swapfree !== null) && ($swaptotal > 0)) {
$dev = new DiskDevice();
$dev->setName("SWAP");
$dev->setTotal($swaptotal);
$dev->setFree($swapfree);
$dev->setUsed($dev->getTotal() - $dev->getFree());
$this->sys->setSwapDevices($dev);
}
}
}
1319,7 → 1714,7
$df_args .= "-x $Fstype ";
}
if ($df_args !== "") {
$df_args = trim($df_args); //trim spaces
$df_args = trim($df_args); // trim spaces
$arrResult = Parser::df("-P $df_args 2>/dev/null");
} else {
$arrResult = Parser::df("-P 2>/dev/null");
1342,17 → 1737,17
return;
}
// We have the '2>/dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && (strlen($distro_info) > 0)) {
$distro_tmp = preg_split("/\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && strlen($distro_info) > 0) {
$distro_tmp = preg_split("/\r?\n/", $distro_info, -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]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
$distro[trim($info_tmp[0])] = trim($info_tmp[1]);
}
}
if (!isset($distro['Distributor ID']) && !isset($distro['Description'])) { // Systems like StartOS
if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "")) {
if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "")) {
$this->sys->setDistribution(trim($distro_tmp[0]));
if (preg_match('/^(\S+)\s*/', $distro_tmp[0], $id_buf)
&& isset($list[trim($id_buf[1])]['Image'])) {
1360,9 → 1755,13
}
}
} else {
if (isset($distro['Description']) && ($distro['Description'] != "n/a") && isset($distro['Distributor ID']) && $distro['Distributor ID']=="Neon") { // Neon systems
$distro_tmp = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
$distro['Distributor ID'] = $distro_tmp[0];
}
if (isset($distro['Description'])
&& preg_match('/^NAME=\s*"?([^"\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
$distro['Description'] = $name_tmp[1];
&& preg_match('/^NAME=\s*"?([^"\r\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
$distro['Description'] = trim($name_tmp[1]);
}
if (isset($distro['Description'])
&& ($distro['Description'] != "n/a")
1381,22 → 1780,36
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
}
}
} elseif (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a")) {
$this->sys->setDistribution($distro['Distributor ID']);
if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
} elseif (isset($distro['Distributor ID'])) {
if ($distro['Distributor ID'] != "n/a") {
$this->sys->setDistribution($distro['Distributor ID']);
if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
}
if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
}
} elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
$this->sys->setDistribution($distro['Description']);
}
if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
$this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
}
}
if (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
} elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
$this->sys->setDistribution($distro['Description']);
if (isset($list[$distro['Description']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Description']]['Image']);
if (isset($distro['Distributor ID'])) {
$distrib = $distro['Distributor ID'];
if (isset($distro['Description'])) {
$distarr = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
if (isset($distarr[0])) {
if ($distrib != "n/a") {
$distrib .= ' '.$distarr[0];
} else {
$distrib = $distarr[0];
}
}
}
if (isset($list[$distrib]['Image'])) {
$this->sys->setDistributionIcon($list[$distrib]['Image']);
} elseif (($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
$this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
}
}
}
} else {
1411,11 → 1824,11
// Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
if (CommonFunctions::fileexists($filename="/etc/lsb-release")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
&& preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
&& (trim($desc_buf[1])!=trim($id_buf[1]))) {
$this->sys->setDistribution(trim($desc_buf[1]));
if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)
if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)
&& (trim($vers_buf[1])!=trim($desc_buf[1])) && strstr($vers_buf[1], ".")){
if (preg_match("/^(\d+)\.[0]+$/", trim($vers_buf[1]), $match_buf)) {
$tofind = $match_buf[1];
1432,10 → 1845,10
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
if (preg_match('/^DISTRIB_CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^DISTRIB_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
}
}
1470,13 → 1883,13
$this->sys->setDistributionIcon($distro['Image']);
}
if (isset($distribution['Name'])) {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($distribution['Name']);
} else {
$this->sys->setDistribution($distribution['Name']." ".trim($buf));
}
} else {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($section);
} else {
$this->sys->setDistribution(trim($buf));
1485,22 → 1898,22
if (isset($distribution['Files2'])) {
foreach (preg_split("/;/", $distribution['Files2'], -1, PREG_SPLIT_NO_EMPTY) as $filename2) {
if (CommonFunctions::fileexists($filename2) && CommonFunctions::rfts($filename2, $buf, 0, 4096, false)) {
if (preg_match('/^majorversion="?([^"\n]+)"?/m', $buf, $maj_buf)
&& preg_match('/^minorversion="?([^"\n]+)"?/m', $buf, $min_buf)) {
if (preg_match('/^majorversion="?([^"\r\n]+)/m', $buf, $maj_buf)
&& preg_match('/^minorversion="?([^"\r\n]+)/m', $buf, $min_buf)) {
$distr2=$maj_buf[1].'.'.$min_buf[1];
if (preg_match('/^buildphase="?([^"\n]+)"?/m', $buf, $pha_buf) && ($pha_buf[1]!=="0")) {
if (preg_match('/^buildphase="?([^"\r\n]+)/m', $buf, $pha_buf) && ($pha_buf[1]!=="0")) {
$distr2.='.'.$pha_buf[1];
}
if (preg_match('/^buildnumber="?([^"\n]+)"?/m', $buf, $num_buf)) {
if (preg_match('/^buildnumber="?([^"\r\n]+)/m', $buf, $num_buf)) {
$distr2.='-'.$num_buf[1];
}
if (preg_match('/^builddate="?([^"\n]+)"?/m', $buf, $dat_buf)) {
if (preg_match('/^builddate="?([^"\r\n]+)/m', $buf, $dat_buf)) {
$distr2.=' ('.$dat_buf[1].')';
}
$this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
} else {
$distr2=trim(substr($buf, 0, strpos($buf, "\n")));
if (!is_null($distr2) && ($distr2 != "")) {
if (($distr2 !== null) && ($distr2 != "")) {
$this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
}
}
1538,10 → 1951,10
}
} elseif ((CommonFunctions::fileexists($filename="/etc/distro-release")
&& CommonFunctions::rfts($filename, $buf, 1, 4096, false)
&& !is_null($buf) && (trim($buf) != ""))
&& ($buf !== null) && (trim($buf) != ""))
|| (CommonFunctions::fileexists($filename="/etc/system-release")
&& CommonFunctions::rfts($filename, $buf, 1, 4096, false)
&& !is_null($buf) && (trim($buf) != ""))) {
&& ($buf !== null) && (trim($buf) != ""))) {
$this->sys->setDistribution(trim($buf));
if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
&& isset($list[trim($id_buf[1])]['Image'])) {
1549,8 → 1962,8
}
} elseif (CommonFunctions::fileexists($filename="/etc/solydxk/info")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
if (preg_match('/^DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
&& preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
if (preg_match('/^DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
&& (trim($desc_buf[1])!=trim($id_buf[1]))) {
$this->sys->setDistribution(trim($desc_buf[1]));
} else {
1559,10 → 1972,10
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
if (preg_match('/^CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
}
}
1573,10 → 1986,10
}
} elseif (CommonFunctions::fileexists($filename="/etc/os-release")
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
&& (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)
|| preg_match('/^NAME="?([^"\n]+)"?/m', $buf, $id_buf))) {
if (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)) {
if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)) {
&& (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)
|| preg_match('/^NAME=["\']?([^"\'\r\n]+)/m', $buf, $id_buf))) {
if (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)) {
if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\r\n]+)/m', $buf, $desc_buf)) {
$this->sys->setDistribution(trim($desc_buf[1])." ".trim($tid_buf[1]));
} else {
if (isset($list['Tails']['Name'])) {
1587,8 → 2000,8
}
$this->sys->setDistributionIcon($list['Tails']['Image']);
} else {
if (preg_match('/^PRETTY_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)
&& !preg_match('/\$/', $desc_buf[1])) { //if is not defined by variable
if (preg_match('/^PRETTY_NAME=["\']?([^"\'\r\n]+)/m', $buf, $desc_buf)
&& !preg_match('/\$/', $desc_buf[1])) { // if is not defined by variable
$this->sys->setDistribution(trim($desc_buf[1]));
} else {
if (isset($list[trim($id_buf[1])]['Name'])) {
1596,9 → 2009,9
} else {
$this->sys->setDistribution(trim($id_buf[1]));
}
if (preg_match('/^VERSION="?([^"\n]+)"?/m', $buf, $vers_buf)) {
if (preg_match('/^VERSION=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
} elseif (preg_match('/^VERSION_ID="?([^"\n]+)"?/m', $buf, $vers_buf)) {
} elseif (preg_match('/^VERSION_ID=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
$this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
}
}
1614,13 → 2027,13
$this->sys->setDistributionIcon($list['Debian']['Image']);
}
if (isset($list['Debian']['Name'])) {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution($list['Debian']['Name']);
} else {
$this->sys->setDistribution($list['Debian']['Name']." ".trim($buf));
}
} else {
if (is_null($buf) || (trim($buf) == "")) {
if (($buf === null) || (trim($buf) == "")) {
$this->sys->setDistribution('Debian');
} else {
$this->sys->setDistribution(trim($buf));
1657,13 → 2070,13
*/
protected function _processes()
{
$process = glob('/proc/*/status', GLOB_NOSORT);
$process = CommonFunctions::findglob('/proc/*/status', GLOB_NOSORT);
if (is_array($process) && (($total = count($process)) > 0)) {
$processes['*'] = 0;
$buf = "";
for ($i = 0; $i < $total; $i++) {
if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
$processes['*']++; //current total
$processes['*']++; // current total
if (preg_match('/^State:\s+(\w)/m', $buf, $state)) {
if (isset($processes[$state[1]])) {
$processes[$state[1]]++;
1674,7 → 2087,7
}
}
if (!($processes['*'] > 0)) {
$processes['*'] = $processes[' '] = $total; //all unknown
$processes['*'] = $processes[' '] = $total; // all unknown
}
$this->sys->setProcesses($processes);
}
1685,7 → 2098,7
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
1701,6 → 2114,7
if (!$this->blockname || $this->blockname==='hardware') {
$this->_machine();
$this->_cpuinfo();
$this->_virtualizer();
$this->_pci();
$this->_ide();
$this->_scsi();
1708,9 → 2122,6
$this->_usb();
$this->_i2c();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
1717,5 → 2128,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.Minix.inc.php
27,6 → 27,11
class Minix extends OS
{
/**
* uptime command result.
*/
private $_uptime = null;
 
/**
* content of the syslog
*
* @var array
94,7 → 99,6
break;
case 'vendor_id':
$dev->setVendorId($arrBuff[1]);
break;
}
}
}
194,13 → 198,13
*/
private function _uptime()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $this->_uptime, $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)) {
} elseif (preg_match("/up (\d+):(\d+),/", $this->_uptime, $ar_buf)) {
$min = $ar_buf[2];
$hours = $ar_buf[1];
$this->sys->setUptime($hours * 3600 + $min * 60);
216,8 → 220,8
*/
private function _loadavg()
{
if (CommonFunctions::executeProgram('uptime', '', $buf)) {
if (preg_match("/load averages: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
if (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
if (preg_match("/load averages: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
}
}
230,7 → 234,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
328,11 → 332,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The Minix version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The Minix version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
346,9 → 350,6
$this->_pci();
$this->_cpuinfo();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
355,5 → 356,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.NetBSD.inc.php
32,7 → 32,7
public function __construct($blockname = false)
{
parent::__construct($blockname);
$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
//$this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
$this->setCPURegExp2("/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/");
$this->setSCSIRegExp1("/^(.*) at scsibus.*: <(.*)> .*/");
$this->setSCSIRegExp2("/^(sd[0-9]+): (.*)([MG])B,/");
41,18 → 41,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
148,6 → 136,77
}
 
/**
* CPU information
*
* @return void
*/
protected function cpuinfo()
{
$was = false;
$cpuarray = array();
foreach ($this->readdmesg() as $line) {
if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
$was = true;
$ar_buf[2] = trim($ar_buf[2]);
if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
if (($model = trim($ar_buf2[1])) !== "") {
$cpuarray[$ar_buf[1]]['model'] = $model;
}
if (($speed = trim($ar_buf2[2])) > 0) {
$cpuarray[$ar_buf[1]]['speed'] = $speed;
}
} elseif (preg_match("/^L2 cache (\d+) ([KM])B /", $ar_buf[2], $ar_buf2)) {
if ($ar_buf2[2]=="M") {
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
} elseif ($ar_buf2[2]=="K") {
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
}
}
} elseif (!preg_match("/^cpu[0-9]+ /", $line) && $was) {
break;
}
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
}
$ncpu = max($ncpu, count($cpuarray));
 
$model = $this->grabkey('machdep.cpu_brand');
$model2 = $this->grabkey('hw.model');
if ($cpuspeed = $this->grabkey('machdep.tsc_freq')) {
$speed = round($cpuspeed / 1000000);
} else {
$speed = "";
}
 
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
$dev = new CpuDevice();
 
if (isset($cpuarray[$cpu]['model'])) {
$dev->setModel($cpuarray[$cpu]['model']);
} elseif ($model !== "") {
$dev->setModel($model);
} elseif ($model2 !== "") {
$dev->setModel($model2);
}
if (isset($cpuarray[$cpu]['speed'])) {
$dev->setCpuSpeed($cpuarray[$cpu]['speed']);
} elseif ($speed !== "") {
$dev->setCpuSpeed($speed);
}
if (isset($cpuarray[$cpu]['cache'])) {
$dev->setCache($cpuarray[$cpu]['cache']);
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
$this->sys->setCpus($dev);
}
}
 
/**
* get icon name
*
* @return void
191,7 → 250,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
198,7 → 257,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.OS.inc.php
106,7 → 106,7
//} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/,\s+(\d+)\s+user[s]?,\s+load average[s]?:\s+(.*),\s+(.*),\s+(.*)$/", $buf, $ar_buf)) {
$this->sys->setUsers($ar_buf[1]);
} else {
$processlist = glob('/proc/*/cmdline', GLOB_NOSORT);
$processlist = CommonFunctions::findglob('/proc/*/cmdline', GLOB_NOSORT);
if (is_array($processlist) && (($total = count($processlist)) > 0)) {
$count = 0;
$buf = "";
132,7 → 132,7
*/
protected function _ip()
{
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) {
if (PSI_USE_VHOST && !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)
$dnsrec = dns_get_record($this->sys->getHostname(), DNS_AAAA);
165,25 → 165,9
*/
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;
}
}
$dmimd = CommonFunctions::readdmimemdata();
if (!empty($dmimd)) {
foreach ($dmimd as $mem) {
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)) {
$dev = new HWDevice();
$name = '';
221,7 → 205,7
$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']) &&
if (isset($mem['Minimum Voltage']) && isset($mem['Maximum Voltage']) &&
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';
/web/acc/phpsysinfo/includes/os/class.OpenBSD.inc.php
41,18 → 41,6
}
 
/**
* UpTime
* time the system is running
*
* @return void
*/
private function _uptime()
{
$a = $this->grabkey('kern.boottime');
$this->sys->setUptime(time() - $a);
}
 
/**
* get network information
*
* @return void
140,35 → 128,81
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
$was = false;
$cpuarray = array();
foreach ($this->readdmesg() as $line) {
if (preg_match("/^cpu[0-9]+: (.*)/", $line, $ar_buf)) {
if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
$was = true;
if (preg_match("/^cpu[0-9]+: (\d+)([KM])B (.*) L2 cache/", $line, $ar_buf2)) {
$ar_buf[2] = trim($ar_buf[2]);
if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
if (($model = trim($ar_buf2[1])) !== "") {
$cpuarray[$ar_buf[1]]['model'] = $model;
}
if (($speed = trim($ar_buf2[2])) > 0) {
$cpuarray[$ar_buf[1]]['speed'] = $speed;
}
} elseif (preg_match("/(\d+)([KM])B \S+ \S+ L[23] cache$/", $ar_buf[2], $ar_buf2)) {
if ($ar_buf2[2]=="M") {
$dev->setCache($ar_buf2[1]*1024*1024);
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
} elseif ($ar_buf2[2]=="K") {
$dev->setCache($ar_buf2[1]*1024);
$cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
}
} else {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
$feats = preg_split("/,/", strtolower($ar_buf[2]), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if (($feat=="vmx") || ($feat=="svm")) {
$dev->setVirt($feat);
$cpuarray[$ar_buf[1]]['virt'] = $feat;
} elseif ($feat=="hv") {
if (!isset($cpuarray[$ar_buf[1]]['virt'])) {
$cpuarray[$ar_buf[1]]['virt'] = 'hypervisor';
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$this->sys->setVirtualizer("hypervisor", false);
}
}
}
}
} elseif ($was) {
} elseif (!preg_match("/^cpu[0-9]+|^mtrr: |^acpitimer[0-9]+: /", $line) && $was) {
break;
}
}
 
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
if (($ncpu === "") || !($ncpu >= 1)) {
$ncpu = 1;
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
}
$ncpu = max($ncpu, count($cpuarray));
 
$model = $this->grabkey('hw.model');
$speed = $this->grabkey('hw.cpuspeed');
$vendor = $this->grabkey('machdep.cpuvendor');
 
for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
$dev = new CpuDevice();
 
if (isset($cpuarray[$cpu]['model'])) {
$dev->setModel($cpuarray[$cpu]['model']);
} elseif ($model !== "") {
$dev->setModel($model);
}
if (isset($cpuarray[$cpu]['speed'])) {
$dev->setCpuSpeed($cpuarray[$cpu]['speed']);
} elseif ($speed !== "") {
$dev->setCpuSpeed($speed);
}
if (isset($cpuarray[$cpu]['cache'])) {
$dev->setCache($cpuarray[$cpu]['cache']);
}
if (isset($cpuarray[$cpu]['virt'])) {
$dev->setVirt($cpuarray[$cpu]['virt']);
}
if ($vendor !== "") {
$dev->setVendorId($vendor);
}
if (($ncpu == 1) && PSI_LOAD_BAR) {
$dev->setLoad($this->cpuusage());
}
 
$this->sys->setCpus($dev);
}
}
216,7 → 250,7
*
* @see BSDCommon::build()
*
* @return Void
* @return void
*/
public function build()
{
223,7 → 257,6
parent::build();
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distroicon();
$this->_uptime();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
/web/acc/phpsysinfo/includes/os/class.QNX.inc.php
88,23 → 88,9
if (CommonFunctions::executeProgram('pidin', 'info', $buf)
&& preg_match('/^.* BootTime:(.*)/', $buf, $bstart)
&& CommonFunctions::executeProgram('date', '', $bstop)) {
/* default error handler */
if (function_exists('errorHandlerPsi')) {
restore_error_handler();
}
/* fatal errors only */
$old_err_rep = error_reporting();
error_reporting(E_ERROR);
 
date_default_timezone_set('UTC');
$uptime = strtotime($bstop)-strtotime($bstart[1]);
if ($uptime > 0) $this->sys->setUptime($uptime);
 
/* restore error level */
error_reporting($old_err_rep);
/* restore error handler */
if (function_exists('errorHandlerPsi')) {
set_error_handler('errorHandlerPsi');
}
}
}
 
125,7 → 111,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
205,11 → 191,11
/**
* get the information
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The QNX version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The QNX version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
220,9 → 206,6
if (!$this->blockname || $this->blockname==='hardware') {
$this->_cpuinfo();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
229,5 → 212,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.SunOS.inc.php
44,34 → 44,34
if ($this->_prtconf === null) {
$this->_prtconf = array();
if (CommonFunctions::executeProgram('prtconf', '-v', $buf, PSI_DEBUG) && ($buf!="")) {
$blocks = preg_split( '/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
$blocks = preg_split('/\n(?= \S)/', $buf, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks) && (count($blocks)>2)) {
array_shift($blocks);
foreach ($blocks as $block) {
if (preg_match('/^ (\S+) /',$block, $ar_buf)) {
if (preg_match('/^ (\S+) /', $block, $ar_buf)) {
$group = trim($ar_buf[1], ',');
$grouparr = array();
$blocks1 = preg_split( '/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
$blocks1 = preg_split('/\n(?= \S)/', $block, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks1) && count($blocks1)) {
array_shift($blocks1);
foreach ($blocks1 as $block1) {
if (!preg_match('/^ name=\'([^\']+)\'/',$block1)
&& preg_match('/^ (\S+) /',$block1, $ar_buf)) {
if (!preg_match('/^ name=\'([^\']+)\'/', $block1)
&& preg_match('/^ (\S+) /', $block1, $ar_buf)) {
$device = trim($ar_buf[1], ',');
$devicearr = array();
$blocks2 = preg_split( '/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
$blocks2 = preg_split('/\n(?= \S)/', $block1, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks2) && count($blocks2)) {
array_shift($blocks2);
foreach ($blocks2 as $block2) {
if (!preg_match('/^ name=\'([^\']+)\'/',$block2)
&& preg_match('/^ (\S+) /',$block2, $ar_buf)) {
if (!preg_match('/^ name=\'([^\']+)\'/', $block2)
&& preg_match('/^ (\S+) /', $block2, $ar_buf)) {
$subdev = trim($ar_buf[1], ',');
$subdevarr = array();
$blocks3 = preg_split( '/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
$blocks3 = preg_split('/\n(?= \S)/', $block2, -1, PREG_SPLIT_NO_EMPTY);
if (!empty($blocks3) && count($blocks3)) {
array_shift($blocks3);
foreach ($blocks3 as $block3) {
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m',$block3, $ar_buf)) {
if (preg_match('/^ name=\'([^\']+)\' [\s\S]+ value=\'?([^\']+)\'?/m', $block3, $ar_buf)) {
if ($subdev==='Hardware') {
$subdevarr[$ar_buf[1]] = $ar_buf[2];
$subdevarr['device'] = $device;
128,7 → 128,7
*/
private function _hostname()
{
if (PSI_USE_VHOST === true) {
if (PSI_USE_VHOST) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
454,11 → 454,11
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
$this->error->addError("WARN", "The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
$this->error->addWarning("The SunOS version of phpSysInfo is a work in progress, some things currently don't work");
if (!$this->blockname || $this->blockname==='vitals') {
$this->_distro();
$this->_hostname();
472,9 → 472,6
$this->_cpuinfo();
$this->_pci();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
481,5 → 478,8
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}
/web/acc/phpsysinfo/includes/os/class.WINNT.inc.php
28,11 → 28,18
class WINNT extends OS
{
/**
* holds codepage for chcp
*
* @var int
*/
private static $_cp = null;
 
/**
* holds the data from WMI Win32_OperatingSystem
*
* @var array
*/
private $_Win32_OperatingSystem = null;
private static $_Win32_OperatingSystem = null;
 
/**
* holds the data from WMI Win32_ComputerSystem
46,8 → 53,15
*
* @var array
*/
private $_Win32_Processor = null;
private static $_Win32_Processor = null;
 
/**
* holds the data from WMI Win32_PhysicalMemory
*
* @var array
*/
private static $_Win32_PhysicalMemory = null;
 
/**
* holds the data from WMI Win32_PerfFormattedData_PerfOS_Processor
*
67,7 → 81,7
*
* @var Object
*/
private $_wmi = null;
private static $_wmi = null;
 
/**
* holds the COM object that we pull all the EnumKey and RegRead data from
84,11 → 98,25
private $_ver = "";
 
/**
* holds system manufacturer
*
* @var string
*/
private $_Manufacturer = "";
 
/**
* holds system model
*
* @var string
*/
private $_Model = "";
 
/**
* holds all devices, which are in the system
*
* @var array
*/
private $_wmidevices = array();
private $_wmidevices = null;
 
/**
* holds all disks, which are in the system
112,14 → 140,41
private $_syslang = null;
 
/**
* value of checking run as administrator
*
* @var boolean
*/
private static $_asadmin = null;
 
/**
* returns codepage for chcp
*
* @return int
*/
public static function getcp()
{
return self::$_cp;
}
 
/**
* returns the COM object that we pull WMI root\CIMv2 data from
*
* @return Object
*/
public static function getcimv2wmi()
{
return self::$_wmi;
}
 
/**
* reads the data from WMI Win32_OperatingSystem
*
* @return array
*/
private function _get_Win32_OperatingSystem()
public static function _get_Win32_OperatingSystem()
{
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'));
return $this->_Win32_OperatingSystem;
if (self::$_Win32_OperatingSystem === null) self::$_Win32_OperatingSystem = self::getWMI(self::$_wmi, 'Win32_OperatingSystem', array('CodeSet', 'Locale', 'LastBootUpTime', 'LocalDateTime', 'Version', 'ServicePackMajorVersion', 'Caption', 'TotalVisibleMemorySize', 'FreePhysicalMemory'));
return self::$_Win32_OperatingSystem;
}
 
/**
129,7 → 184,7
*/
private function _get_Win32_ComputerSystem()
{
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = CommonFunctions::getWMI($this->_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model', 'SystemFamily'));
if ($this->_Win32_ComputerSystem === null) $this->_Win32_ComputerSystem = self::getWMI(self::$_wmi, 'Win32_ComputerSystem', array('Name', 'Manufacturer', 'Model', 'SystemFamily'));
return $this->_Win32_ComputerSystem;
}
 
138,13 → 193,24
*
* @return array
*/
private function _get_Win32_Processor()
public static function _get_Win32_Processor()
{
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'));
return $this->_Win32_Processor;
if (self::$_Win32_Processor === null) self::$_Win32_Processor = self::getWMI(self::$_wmi, 'Win32_Processor', array('DeviceID', 'LoadPercentage', 'AddressWidth', 'Name', 'L2CacheSize', 'L3CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'NumberOfLogicalProcessors', 'MaxClockSpeed', 'Manufacturer', 'Architecture', 'Caption', 'CurrentVoltage'));
return self::$_Win32_Processor;
}
 
/**
* reads the data from WMI Win32_PhysicalMemory
*
* @return array
*/
public static function _get_Win32_PhysicalMemory()
{
if (self::$_Win32_PhysicalMemory === null) self::$_Win32_PhysicalMemory = self::getWMI(self::$_wmi, 'Win32_PhysicalMemory', array('PartNumber', 'DeviceLocator', 'Capacity', 'Manufacturer', 'SerialNumber', 'Speed', 'ConfiguredClockSpeed', 'ConfiguredVoltage', 'MemoryType', 'SMBIOSMemoryType', 'FormFactor', 'DataWidth', 'TotalWidth', 'BankLabel', 'MinVoltage', 'MaxVoltage'));
return self::$_Win32_PhysicalMemory;
}
 
/**
* reads the data from WMI Win32_PerfFormattedData_PerfOS_Processor
*
* @return array
155,8 → 221,8
$this->_Win32_PerfFormattedData_PerfOS_Processor = array();
$buffer = $this->_get_Win32_OperatingSystem();
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "5.1", ">=")) { // minimal windows 2003 or windows XP
$cpubuffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfFormattedData_PerfOS_Processor', array('Name', 'PercentProcessorTime'));
if ($cpubuffer) foreach ($cpubuffer as $cpu) {
$cpubuffer = self::getWMI(self::$_wmi, 'Win32_PerfFormattedData_PerfOS_Processor', array('Name', 'PercentProcessorTime'));
foreach ($cpubuffer as $cpu) {
if (isset($cpu['Name']) && isset($cpu['PercentProcessorTime'])) {
$this->_Win32_PerfFormattedData_PerfOS_Processor['cpu'.$cpu['Name']] = $cpu['PercentProcessorTime'];
}
183,6 → 249,320
}
 
/**
* checks WINNT and 'run as Administrator' mode
*
* @return boolean
*/
public static function isAdmin()
{
if (self::$_asadmin == null) {
if (PSI_OS == 'WINNT') {
$strBuf = '';
CommonFunctions::executeProgram('sfc', '2>&1', $strBuf, false); // 'net session' for detection does not work if "Server" (LanmanServer) service is stopped
if (preg_match('/^\/SCANNOW\s/m', preg_replace('/(\x00)/', '', $strBuf))) { // SCANNOW checking - also if Unicode
self::$_asadmin = true;
} else {
self::$_asadmin = false;
}
} else {
self::$_asadmin = false;
}
}
 
return self::$_asadmin;
}
 
/**
* function for getting a list of values in the specified context
* optionally filter this list, based on the list from third parameter
*
* @param $wmi object holds the COM object that we pull the WMI data from
* @param string $strClass name of the class where the values are stored
* @param array $strValue filter out only needed values, if not set all values of the class are returned
*
* @return array content of the class stored in an array
*/
public static function getWMI($wmi, $strClass, $strValue = array())
{
$arrData = array();
if (gettype($wmi) === "object") {
$value = "";
try {
$objWEBM = $wmi->Get($strClass);
$arrProp = $objWEBM->Properties_;
$arrWEBMCol = $objWEBM->Instances_();
foreach ($arrWEBMCol as $objItem) {
if (is_array($arrProp)) {
reset($arrProp);
}
$arrInstance = array();
foreach ($arrProp as $propItem) {
$value = $objItem->{$propItem->Name}; //instead exploitable eval("\$value = \$objItem->".$propItem->Name.";");
if (empty($strValue)) {
if (is_string($value)) $arrInstance[$propItem->Name] = trim($value);
else $arrInstance[$propItem->Name] = $value;
} else {
if (in_array($propItem->Name, $strValue)) {
if (is_string($value)) $arrInstance[$propItem->Name] = trim($value);
else $arrInstance[$propItem->Name] = $value;
}
}
}
$arrData[] = $arrInstance;
}
} catch (Exception $e) {
if (PSI_DEBUG && (($message = trim($e->getMessage())) !== "<b>Source:</b> SWbemServicesEx<br/><b>Description:</b> Not found")) {
$error = PSI_Error::singleton();
$error->addError("getWMI()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $message)));
}
}
} elseif ((gettype($wmi) === "string") && (PSI_OS == 'Linux')) {
$delimeter = '@@@DELIM@@@';
if (CommonFunctions::executeProgram('wmic', '--delimiter="'.$delimeter.'" '.$wmi.' '.$strClass.'" 2>/dev/null', $strBuf, true) && preg_match("/^CLASS:\s/", $strBuf)) {
if (self::$_cp) {
if (self::$_cp == 932) {
$codename = ' (SJIS)';
} elseif (self::$_cp == 949) {
$codename = ' (EUC-KR)';
} elseif (self::$_cp == 950) {
$codename = ' (BIG-5)';
} else {
$codename = '';
}
self::convertCP($strBuf, 'windows-'.self::$_cp.$codename);
}
$lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY);
if (count($lines) >=3) {
unset($lines[0]);
$names = preg_split('/'.$delimeter.'/', $lines[1], -1, PREG_SPLIT_NO_EMPTY);
$namesc = count($names);
unset($lines[1]);
foreach ($lines as $line) {
$arrInstance = array();
$values = preg_split('/'.$delimeter.'/', $line, -1);
if (count($values) == $namesc) {
foreach ($values as $id=>$value) {
if (empty($strValue)) {
if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value);
else $arrInstance[$names[$id]] = null;
} else {
if (in_array($names[$id], $strValue)) {
if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value);
else $arrInstance[$names[$id]] = null;
}
}
}
$arrData[] = $arrInstance;
}
}
}
}
}
 
return $arrData;
}
 
/**
* readReg function
*
* @return boolean command successfull or not
*/
public static function readReg($reg, $strName, &$strBuffer, $booErrorRep = true, $dword = false, $bits64 = false)
{
$strBuffer = '';
 
if ($reg === false) {
if (defined('PSI_EMU_HOSTNAME')) {
return false;
}
$last = strrpos($strName, "\\");
$keyname = substr($strName, $last + 1);
if ($bits64) {
$param = ' /reg:64';
} else {
$param = '';
}
if ($dword) {
$valtype = "DWORD";
} else {
$valtype = "SZ|EXPAND_SZ";
}
if (self::$_cp) {
if (CommonFunctions::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.substr($strName, 0, $last).'" /v '.$keyname.$param.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_(".$valtype.")\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
if ($dword) {
$strBuffer = strval(hexdec($buffer2[2]));
} else {
$strBuffer = $buffer2[2];
}
} else {
return false;
}
} else {
if (CommonFunctions::executeProgram('reg', 'query "'.substr($strName, 0, $last).'" /v '.$keyname.$param.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_(".$valtype.")\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
if ($dword) {
$strBuffer = strval(hexdec($buffer2[2]));
} else {
$strBuffer = $buffer2[2];
}
} else {
return false;
}
}
} elseif (gettype($reg) === "object") {
$_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006);
$first = strpos($strName, "\\");
$last = strrpos($strName, "\\");
$hkey = substr($strName, 0, $first);
if (isset($_hkey[$hkey])) {
$sub_keys = new VARIANT();
try {
if ($dword) {
$reg->Get("StdRegProv")->GetDWORDValue(strval($_hkey[$hkey]), substr($strName, $first+1, $last-$first-1), substr($strName, $last+1), $sub_keys);
} else {
$reg->Get("StdRegProv")->GetStringValue(strval($_hkey[$hkey]), substr($strName, $first+1, $last-$first-1), substr($strName, $last+1), $sub_keys);
}
} catch (Exception $e) {
if ($booErrorRep) {
$error = PSI_Error::singleton();
$error->addError("GetStringValue()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));
}
 
return false;
}
if (variant_get_type($sub_keys) !== VT_NULL) {
$strBuffer = strval($sub_keys);
} else {
return false;
}
} else {
return false;
}
}
 
return true;
}
 
/**
* enumKey function
*
* @return boolean command successfull or not
*/
public static function enumKey($reg, $strName, &$arrBuffer, $booErrorRep = true)
{
$arrBuffer = array();
 
if ($reg === false) {
if (defined('PSI_EMU_HOSTNAME')) {
return false;
}
if (self::$_cp) {
if (CommonFunctions::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) {
foreach ($buffer2[1] as $sub_key) {
$arrBuffer[] = trim($sub_key);
}
} else {
return false;
}
} else {
if (CommonFunctions::executeProgram('reg', 'query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) {
foreach ($buffer2[1] as $sub_key) {
$arrBuffer[] = trim($sub_key);
}
} else {
return false;
}
}
} elseif (gettype($reg) === "object") {
$_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006);
$first = strpos($strName, "\\");
$hkey = substr($strName, 0, $first);
if (isset($_hkey[$hkey])) {
$sub_keys = new VARIANT();
try {
$reg->Get("StdRegProv")->EnumKey(strval($_hkey[$hkey]), substr($strName, $first+1), $sub_keys);
} catch (Exception $e) {
if ($booErrorRep) {
$error = PSI_Error::singleton();
$error->addError("enumKey()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));;
}
 
return false;
}
if (variant_get_type($sub_keys) !== VT_NULL) {
foreach ($sub_keys as $sub_key) {
$arrBuffer[] = $sub_key;
}
} else {
return false;
}
} else {
return false;
}
}
 
return true;
}
 
/**
* initWMI function
*
* @return string, object or false
*/
public static function initWMI($namespace, $booErrorRep = false)
{
$wmi = false;
if (self::$_wmi !== false) { // WMI not disabled
try {
if (PSI_OS == 'Linux') {
if (defined('PSI_EMU_HOSTNAME'))
$wmi = '--namespace="'.$namespace.'" -U '.PSI_EMU_USER.'%'.PSI_EMU_PASSWORD.' //'.PSI_EMU_HOSTNAME.' "select * from';
} elseif (PSI_OS == 'WINNT') {
$objLocator = new COM('WbemScripting.SWbemLocator');
if (defined('PSI_EMU_HOSTNAME'))
$wmi = $objLocator->ConnectServer(PSI_EMU_HOSTNAME, $namespace, PSI_EMU_USER, PSI_EMU_PASSWORD);
else
$wmi = $objLocator->ConnectServer('', $namespace);
}
} catch (Exception $e) {
if ($booErrorRep) {
$error = PSI_Error::singleton();
$error->addError("WMI connect ".$namespace." error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed or credentials.");
}
}
}
 
return $wmi;
}
 
/**
* convertCP function
*
* @return void
*/
public static function convertCP(&$strBuf, $encoding)
{
if (defined('PSI_SYSTEM_CODEPAGE') && (PSI_SYSTEM_CODEPAGE != null) && ($encoding != null) && ($encoding != PSI_SYSTEM_CODEPAGE)) {
$systemcp = PSI_SYSTEM_CODEPAGE;
if (preg_match("/^windows-\d+ \((.+)\)$/", $systemcp, $buf)) {
$systemcp = $buf[1];
}
if (preg_match("/^windows-\d+ \((.+)\)$/", $encoding, $buf)) {
$encoding = $buf[1];
}
$enclist = mb_list_encodings();
if (in_array($encoding, $enclist) && in_array($systemcp, $enclist)) {
$strBuf = mb_convert_encoding($strBuf, $encoding, $systemcp);
} elseif (function_exists("iconv")) {
if (($iconvout=iconv($systemcp, $encoding.'//IGNORE', $strBuf))!==false) {
$strBuf = $iconvout;
}
} elseif (function_exists("libiconv") && (($iconvout=libiconv($systemcp, $encoding, $strBuf))!==false)) {
$strBuf = $iconvout;
}
}
}
 
/**
* build the global Error object and create the WMI connection
*/
public function __construct($blockname = false)
192,7 → 572,7
$this->_ver = $ver_value;
}
if (($this->_ver !== "") && preg_match("/ReactOS\r?\n\S+\s+.+/", $this->_ver)) {
$this->_wmi = false; // No WMI info on ReactOS yet
self::$_wmi = false; // No WMI info on ReactOS yet
$this->_reg = false; // No EnumKey and ReadReg on ReactOS yet
} else {
if (PSI_OS == 'WINNT') {
200,27 → 580,30
try {
$objLocator = new COM('WbemScripting.SWbemLocator');
$wmi = $objLocator->ConnectServer('', 'root\CIMv2');
$buffer = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('CodeSet'));
$buffer = self::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)) {
if (self::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);
if ($buffer && isset($buffer[0]) && 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);
} else {
define('PSI_SYSTEM_CODEPAGE', null);
if (PSI_DEBUG) {
$this->error->addError("__construct()", "PhpSysInfo can not detect PSI_SYSTEM_CODEPAGE");
}
}
} catch (Exception $e) {
define('PSI_SYSTEM_CODEPAGE', null);
232,9 → 615,9
define('PSI_SYSTEM_CODEPAGE', null);
}
}
$this->_wmi = CommonFunctions::initWMI('root\CIMv2', true);
self::$_wmi = self::initWMI('root\CIMv2', true);
if (PSI_OS == 'WINNT') {
$this->_reg = CommonFunctions::initWMI('root\default', PSI_DEBUG);
$this->_reg = self::initWMI('root\default', PSI_DEBUG);
if (gettype($this->_reg) === "object") {
$this->_reg->Security_->ImpersonationLevel = 3;
}
255,10 → 638,10
{
$buffer = $this->_get_Win32_OperatingSystem();
if (!$buffer) {
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) {
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP", $strBuf, false)) {
$buffer[0]['CodeSet'] = $strBuf;
}
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Language\\Default", $strBuf, false)) {
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Language\\Default", $strBuf, false)) {
$buffer[0]['Locale'] = $strBuf;
}
}
274,7 → 657,7
} else {
$codename = '';
}
CommonFunctions::setcp($codeset);
self::$_cp = $codeset;
$this->_codepage = 'windows-'.$codeset.$codename;
}
if (isset($buffer[0]['Locale']) && (($locale = hexdec($buffer[0]['Locale']))>0)) {
301,37 → 684,76
*/
private function _devicelist($strType)
{
if (empty($this->_wmidevices)) {
if ($this->_wmidevices === null) {
$this->_wmidevices = array();
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID', 'Manufacturer', 'PNPClass'));
$this->_wmidevices = self::getWMI(self::$_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID', 'Manufacturer', 'PNPClass'));
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size', 'SerialNumber'));
$this->_wmidisks = self::getWMI(self::$_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size', 'SerialNumber'));
} else {
$this->_wmidisks = CommonFunctions::getWMI($this->_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size'));
$this->_wmidisks = self::getWMI(self::$_wmi, 'Win32_DiskDrive', array('PNPDeviceID', 'Size'));
}
} else {
$this->_wmidevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID'));
$this->_wmidevices = self::getWMI(self::$_wmi, 'Win32_PnPEntity', array('Name', 'PNPDeviceID'));
}
 
if (empty($this->_wmidevices)) {
$lstdevs = array();
$services = array();
foreach (array('PCI', 'USB') as $type) {
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$type;
if (self::enumKey($this->_reg, $hkey, $vendevs, false)) {
foreach ($vendevs as $vendev) if (self::enumKey($this->_reg, $hkey."\\".$vendev, $ids, false)) {
foreach ($ids as $id) {
if ($type === 'PCI') { // enumerate all PCI devices
$lstdevs[$type."\\".$vendev."\\".$id] = true;
} elseif (self::readReg($this->_reg, $hkey."\\".$vendev."\\".$id."\\Service", $service, false)) {
$services[$service] = true; // ever used USB services
break;
}
}
}
}
}
 
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services";
foreach ($services as $service=>$tmp) if (self::readReg($this->_reg, $hkey."\\".$service."\\Enum\\Count", $count, false, true) && ($count > 0)) {
for ($i = 0; $i < $count; $i++) if (self::readReg($this->_reg, $hkey."\\".$service."\\Enum\\".$i, $id, false) && preg_match("/^USB/", $id)) {
$lstdevs[$id] = true; // used USB devices
}
}
 
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\";
foreach ($lstdevs as $lstdev=>$tmp) {
if (self::readReg($this->_reg, $hkey.$lstdev."\\DeviceDesc", $nameBuf, false)) {
$namesplit = preg_split('/;/', $nameBuf, -1, PREG_SPLIT_NO_EMPTY);
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && self::readReg($this->_reg, $hkey.$lstdev."\\Mfg", $mfgBuf, false)) {
$mfgsplit = preg_split('/;/', $mfgBuf, -1, PREG_SPLIT_NO_EMPTY);
$this->_wmidevices[] = array('Name'=>$namesplit[count($namesplit)-1], 'PNPDeviceID'=>$lstdev, 'Manufacturer'=>$mfgsplit[count($mfgsplit)-1]);
} else {
$this->_wmidevices[] = array('Name'=>$namesplit[count($namesplit)-1], 'PNPDeviceID'=>$lstdev);
}
}
}
 
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi";
$id = 0;
if (CommonFunctions::enumKey($this->_reg, $hkey, $portBuf, false)) {
if (self::enumKey($this->_reg, $hkey, $portBuf, false)) {
foreach ($portBuf as $scsiport) {
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport, $busBuf, false)) {
if (self::enumKey($this->_reg, $hkey."\\".$scsiport, $busBuf, false)) {
foreach ($busBuf as $scsibus) {
if (CommonFunctions::enumKey($this->_reg, $hkey."\\".$scsiport."\\".$scsibus, $tarBuf, false)) {
if (self::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)) {
if (self::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))
if ((self::readReg($this->_reg, $hkey2."DeviceType", $typeBuf, false) || self::readReg($this->_reg, $hkey2."Type", $typeBuf, false))
&& (($typeBuf=strtolower(trim($typeBuf))) !== "")) {
if ((($typeBuf == 'diskperipheral') || ($typeBuf == 'cdromperipheral'))
&& CommonFunctions::readReg($this->_reg, $hkey2."Identifier", $ideBuf, false)) {
&& self::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))
&& self::readReg($this->_reg, $hkey2."SerialNumber", $serBuf, false)
&& (($serBuf=trim($serBuf)) !== "")) {
$this->_wmidisks[] = array('PNPDeviceID'=>'SCSI\\'.$id, 'SerialNumber'=>$serBuf);
}
371,6 → 793,7
$device['Serial'] = null;
if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
if ($strType==='USB') {
// if (preg_match('/\\\\([^\\\\][^&\\\\][^\\\\]+)$/', $device['PNPDeviceID'], $buf)) { // second character !== &
if (preg_match('/\\\\(\w+)$/', $device['PNPDeviceID'], $buf)) {
$device['Serial'] = $buf[1];
}
400,11 → 823,11
*/
private function _hostname()
{
if ((PSI_USE_VHOST === true) && !defined('PSI_EMU_HOSTNAME')) {
if (PSI_USE_VHOST && !defined('PSI_EMU_HOSTNAME')) {
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
} else {
$buffer = $this->_get_Win32_ComputerSystem();
if (!$buffer && CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName\\ComputerName", $strBuf, false) && (strlen($strBuf) > 0)) {
if (!$buffer && self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName\\ComputerName", $strBuf, false) && (strlen($strBuf) > 0)) {
$buffer[0]['Name'] = $strBuf;
}
if ($buffer) {
437,6 → 860,44
}
 
/**
* Virtualizer info
*
* @return void
*/
protected function _virtualizer()
{
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo()
 
$vendor_array = array();
if ($this->_Model != "") {
$vendor_array[] = $this->_Model;
}
if ($this->_Manufacturer != "") {
if ($this->_Model != "") {
$vendor_array[] = $this->_Manufacturer." ".$this->_Model;
} else {
$vendor_array[] = $this->_Manufacturer;
}
}
$novm = true;
if (count($vendor_array)>0) {
$virt = CommonFunctions::decodevirtualizer($vendor_array);
if ($virt !== null) {
$this->sys->setVirtualizer($virt);
$novm = false;
}
}
if ($novm) {
// Detect QEMU cpu
if (isset($cpuvirt["cpuid:QEMU"])) {
$this->sys->setVirtualizer('qemu'); // QEMU
}
}
}
}
 
/**
* UpTime
* time the system is running
*
477,7 → 938,7
$result = $localtime - $boottime;
 
$this->sys->setUptime($result);
} 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)) {
} elseif (!defined('PSI_EMU_HOSTNAME') && (substr($this->sys->getDistribution(), 0, 7)=="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)) {
$sec = $ar_buf[4];
$min = $ar_buf[3];
$hours = $ar_buf[2];
498,7 → 959,7
$users = count($lines)-1;
} else {
$users = 0;
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
$buffer = self::getWMI(self::$_wmi, 'Win32_Process', array('Caption'));
foreach ($buffer as $process) {
if (strtoupper($process['Caption']) == strtoupper('explorer.exe')) {
$users++;
518,19 → 979,50
$buffer = $this->_get_Win32_OperatingSystem();
if ($buffer) {
$ver = $buffer[0]['Version'];
$kernel = $ver;
if (($this->_ver !== "") && preg_match("/^Microsoft [^\[]*\s*\[\D*\s*(".$ver."\.\d+).*\]/", $this->_ver, $ar_temp)) {
$kernel = $ar_temp[1];
} else {
$kernel = $ver;
}
if ($buffer[0]['ServicePackMajorVersion'] > 0) {
$kernel .= ' SP'.$buffer[0]['ServicePackMajorVersion'];
}
if (isset($buffer[0]['OSArchitecture']) && preg_match("/^(\d+)/", $buffer[0]['OSArchitecture'], $bits)) {
$this->sys->setKernel($kernel.' ('.$bits[1].'-bit)');
} elseif (($allCpus = $this->_get_Win32_Processor()) && isset($allCpus[0]['AddressWidth'])) {
$this->sys->setKernel($kernel.' ('.$allCpus[0]['AddressWidth'].'-bit)');
} else {
$this->sys->setKernel($kernel);
if ($allCpus = $this->_get_Win32_Processor()) {
$addresswidth = 0;
if (isset($allCpus[0]['AddressWidth']) && (($addresswidth = $allCpus[0]['AddressWidth']) > 0)) {
$kernel .= ' ('.$addresswidth.'-bit)';
}
if (isset($allCpus[0]['Architecture'])) {
switch ($allCpus[0]['Architecture']) {
case 0: $kernel .= ' x86'; break;
case 1: $kernel .= ' MIPS'; break;
case 2: $kernel .= ' Alpha'; break;
case 3: $kernel .= ' PowerPC'; break;
case 5: $kernel .= ' ARM'; break;
case 6: $kernel .= ' ia64'; break;
case 9: if ($addresswidth == 32) {
$kernel .= ' x86';
} else {
$kernel .= ' x64';
}
break;
case 12: if ($addresswidth == 32) {
$kernel .= ' ARM';
} else {
$kernel .= ' ARM64';
}
}
}
}
$this->sys->setDistribution($buffer[0]['Caption']);
 
$this->sys->setKernel($kernel);
$distribution = $buffer[0]['Caption'];
if (version_compare($ver, "10.0", ">=") && !preg_match('/server/i', $buffer[0]['Caption']) && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
$karray = preg_split('/\./', $ver);
if (isset($karray[2]) && isset($list['win10'][$karray[2]])) {
$distribution .= ' ('.$list['win10'][$karray[2]].')';
}
}
$this->sys->setDistribution($distribution);
if (version_compare($ver, "5.1", "<"))
$icon = 'Win2000.png';
elseif (version_compare($ver, "5.1", ">=") && version_compare($ver, "6.0", "<"))
537,8 → 1029,10
$icon = 'WinXP.png';
elseif (version_compare($ver, "6.0", ">=") && version_compare($ver, "6.2", "<"))
$icon = 'WinVista.png';
elseif (version_compare($ver, "6.2", ">=") && version_compare($ver, "10.0.21996", "<"))
$icon = 'Win8.png';
else
$icon = 'Win8.png';
$icon = 'Win11.png';
$this->sys->setDistributionIcon($icon);
} elseif ($this->_ver !== "") {
if (preg_match("/ReactOS\r?\n\S+\s+(.+)/", $this->_ver, $ar_temp)) {
550,26 → 1044,48
$this->sys->setKernel($ar_temp[1]);
}
$this->sys->setDistributionIcon('ReactOS.png');
} 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)) {
} elseif (preg_match("/^(Microsoft [^\[]*)\s*\[\D*\s*([\.\d]+)\]/", $this->_ver, $ar_temp)) {
$ver = $ar_temp[2];
$kernel = $ver;
if (($this->_reg === false) && self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false, false, true) && (strlen($strBuf) > 0)) { // only if reg query via cmd
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $tmpBuf, false)) {
$kernel .= ' (64-bit)';
}
if (preg_match("/^Microsoft /", $strBuf)) {
$this->sys->setDistribution($strBuf);
$distribution = $strBuf;
} else {
$this->sys->setDistribution("Microsoft ".$strBuf);
$distribution = "Microsoft ".$strBuf;
}
} elseif (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName", $strBuf, false) && (strlen($strBuf) > 0)) {
if (preg_match("/^Microsoft /", $strBuf)) {
$distribution = $strBuf;
} else {
$distribution = "Microsoft ".$strBuf;
}
} else {
$this->sys->setDistribution($ar_temp[1]);
$distribution = $ar_temp[1];
}
$kernel = $ar_temp[2];
$this->sys->setKernel($kernel);
if ((($kernel[1] == '.') && ($kernel[0] <5)) || (substr($kernel, 0, 4) == '5.0.'))
if (version_compare($ver, "10.0", ">=") && !preg_match('/server/i', $this->sys->getDistribution()) && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
if (version_compare($ver, "10.0.21996", ">=") && version_compare($ver, "11.0", "<")) {
$distribution = preg_replace("/Windows 10/", "Windows 11", $distribution); // fix Windows 11 detection
}
$karray = preg_split('/\./', $ver);
if (isset($karray[2]) && isset($list['win10'][$karray[2]])) {
$distribution .= ' ('.$list['win10'][$karray[2]].')';
}
}
$this->sys->setDistribution($distribution);
if (version_compare($ver, "5.1", "<"))
$icon = 'Win2000.png';
elseif ((substr($kernel, 0, 4) == '6.0.') || (substr($kernel, 0, 4) == '6.1.'))
elseif (version_compare($ver, "5.1", ">=") && version_compare($ver, "6.0", "<"))
$icon = 'WinXP.png';
elseif (version_compare($ver, "6.0", ">=") && version_compare($ver, "6.2", "<"))
$icon = 'WinVista.png';
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.'))
elseif (version_compare($ver, "6.2", ">=") && version_compare($ver, "10.0.21996", "<"))
$icon = 'Win8.png';
else
$icon = 'WinXP.png';
$icon = 'Win11.png';
$this->sys->setDistributionIcon($icon);
} else {
$this->sys->setDistribution("WINNT");
624,21 → 1140,24
private function _cpuinfo()
{
$allCpus = $this->_get_Win32_Processor();
if (!$allCpus) {
if (empty($allCpus)) {
$hkey = "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor";
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) {
if (self::enumKey($this->_reg, $hkey, $arrBuf, false)) {
foreach ($arrBuf as $coreCount) {
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) {
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\ProcessorNameString", $strBuf, false)) {
$allCpus[$coreCount]['Name'] = $strBuf;
}
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\~MHz", $strBuf, false)) {
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\~MHz", $strBuf, false)) {
if (preg_match("/^0x([0-9a-f]+)$/i", $strBuf, $hexvalue)) {
$allCpus[$coreCount]['CurrentClockSpeed'] = hexdec($hexvalue[1]);
}
}
if (CommonFunctions::readReg($this->_reg, $hkey."\\".$coreCount."\\VendorIdentifier", $strBuf, false)) {
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\VendorIdentifier", $strBuf, false)) {
$allCpus[$coreCount]['Manufacturer'] = $strBuf;
}
if (self::readReg($this->_reg, $hkey."\\".$coreCount."\\Identifier", $strBuf, false)) {
$allCpus[$coreCount]['Caption'] = $strBuf;
}
}
}
}
654,6 → 1173,7
$globalcpus+=$cpuCount;
}
 
$cpulist = null;
foreach ($allCpus as $oneCpu) {
$cpuCount = 1;
if (isset($oneCpu['NumberOfLogicalProcessors'])) {
666,15 → 1186,62
if (isset($oneCpu['Name'])) $cpu->setModel($oneCpu['Name']);
if (isset($oneCpu['L3CacheSize']) && ($oneCpu['L3CacheSize'] > 0)) {
$cpu->setCache($oneCpu['L3CacheSize'] * 1024);
} elseif (isset($oneCpu['L2CacheSize'])) {
} elseif (isset($oneCpu['L2CacheSize']) && ($oneCpu['L2CacheSize'] > 0)) {
$cpu->setCache($oneCpu['L2CacheSize'] * 1024);
}
if (isset($oneCpu['CurrentClockSpeed'])) {
if (isset($oneCpu['CurrentVoltage']) && ($oneCpu['CurrentVoltage'] > 0)) {
$cpu->setVoltage($oneCpu['CurrentVoltage']/10);
}
if (isset($oneCpu['CurrentClockSpeed']) && ($oneCpu['CurrentClockSpeed'] > 0)) {
$cpu->setCpuSpeed($oneCpu['CurrentClockSpeed']);
if (isset($oneCpu['MaxClockSpeed']) && ($oneCpu['CurrentClockSpeed'] < $oneCpu['MaxClockSpeed'])) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']);
if (isset($oneCpu['MaxClockSpeed']) && ($oneCpu['CurrentClockSpeed'] <= $oneCpu['MaxClockSpeed'])) $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']);
}
if (isset($oneCpu['ExtClock'])) $cpu->setBusSpeed($oneCpu['ExtClock']);
if (isset($oneCpu['Manufacturer'])) $cpu->setVendorId($oneCpu['Manufacturer']);
if (isset($oneCpu['ExtClock']) && ($oneCpu['ExtClock'] > 0)) {
$cpu->setBusSpeed($oneCpu['ExtClock']);
}
if (isset($oneCpu['Manufacturer'])) {
$cpumanufacturer = $oneCpu['Manufacturer'];
$cpu->setVendorId($cpumanufacturer);
if ($cpumanufacturer === "QEMU") {
if (isset($oneCpu['Caption'])) {
$impl = '';
if (preg_match('/^ARMv8 \(64-bit\) Family 8 Model ([0-9a-fA-F]+) Revision[ ]+([0-9a-fA-F]+)$/', $oneCpu['Caption'], $partvar)) {
switch (strtolower($partvar[1])) {
case '51':
$impl = '0x0'; break; // Qemu
case 'd03':
case 'd07':
case 'd08':
$impl = '0x41'; break; // ARM Limited
case '1':
$impl = '0x46'; // Fujitsu Ltd.
}
} elseif (preg_match('/^ARM Family 7 Model ([0-9a-fA-F]+) Revision[ ]+([0-9a-fA-F]+)$/', $oneCpu['Caption'], $partvar)) {
switch (strtolower($partvar[1])) {
case 'c07':
case 'c0f':
$impl = '0x41'; // ARM Limited
}
}
if ($impl !== '') {
if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
if ($cpulist) {
if ((isset($cpulist['cpu'][$cpufromlist = strtolower($impl.',0x'.$partvar[1].',0x'.$partvar[2])]))
|| isset($cpulist['cpu'][$cpufromlist = strtolower($impl.',0x'.$partvar[1])])) {
if (($cpumodel = $cpu->getModel()) !== '') {
$cpu->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]);
} else {
$cpu->setModel($cpulist['cpu'][$cpufromlist]);
}
}
}
}
}
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
$this->sys->setVirtualizer("cpuid:QEMU", false);
}
}
}
if (PSI_LOAD_BAR) {
if (($cpubuffer = $this->_get_Win32_PerfFormattedData_PerfOS_Processor()) && (count($cpubuffer) == ($globalcpus+1)) && isset($cpubuffer['cpu'.$i])) {
$cpu->setLoad($cpubuffer['cpu'.$i]);
695,33 → 1262,43
private function _machine()
{
$buffer = $this->_get_Win32_ComputerSystem();
$bufferp = CommonFunctions::getWMI($this->_wmi, 'Win32_BaseBoard', array('Product'));
$bufferb = CommonFunctions::getWMI($this->_wmi, 'Win32_BIOS', array('SMBIOSBIOSVersion', 'ReleaseDate'));
$bufferp = self::getWMI(self::$_wmi, 'Win32_BaseBoard', array('Product'));
$bufferb = self::getWMI(self::$_wmi, 'Win32_BIOS', array('SMBIOSBIOSVersion', 'ReleaseDate'));
 
if (!$buffer) {
if (CommonFunctions::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\systemManufacturer", $strBuf, false)) {
if (self::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)) {
if (self::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)) {
if (self::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)) {
if (self::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)) {
if (self::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)) {
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\BIOS\\BIOSReleaseDate", $strBuf, false)) {
$bufferb[0]['ReleaseDate'] = $strBuf;
}
}
 
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
if (isset($buffer[0]['Manufacturer'])) {
$this->_Manufacturer = $buffer[0]['Manufacturer'];
}
if (isset($buffer[0]['Model'])) {
$this->_Model = $buffer[0]['Model'];
}
}
 
$buf = "";
$model = "";
if ($buffer && isset($buffer[0])) {
832,25 → 1409,25
*/
private function _network()
{
if ($this->_wmi) {
if (self::$_wmi) {
$buffer = $this->_get_Win32_OperatingSystem();
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version']) && version_compare($buffer[0]['Version'], "6.2", ">=")) { // minimal windows 2012 or windows 8
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkAdapter', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
$allDevices = self::getWMI(self::$_wmi, 'Win32_PerfRawData_Tcpip_NetworkAdapter', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
} else {
$allDevices = CommonFunctions::getWMI($this->_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
$allDevices = self::getWMI(self::$_wmi, 'Win32_PerfRawData_Tcpip_NetworkInterface', array('Name', 'BytesSentPersec', 'BytesTotalPersec', 'BytesReceivedPersec', 'PacketsReceivedErrors', 'PacketsReceivedDiscarded', 'CurrentBandwidth'));
}
if ($allDevices) {
$aliases = array();
$hkey = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) {
if (self::enumKey($this->_reg, $hkey, $arrBuf, false)) {
foreach ($arrBuf as $netID) {
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)) {
if (self::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\PnPInstanceId", $strInstanceID, false)) {
if (self::readReg($this->_reg, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\".$strInstanceID."\\FriendlyName", $strName, false)) {
$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)
if (self::readReg($this->_reg, $hkey."\\".$netID."\\Connection\\Name", $strCName, false)
&& (str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strCName) !== $cname)) {
$aliases[$cname]['netname'] = $strCName;
}
864,10 → 1441,10
 
$aliases2 = array();
$hkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards";
if (CommonFunctions::enumKey($this->_reg, $hkey, $arrBuf, false)) {
if (self::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)) {
if (self::readReg($this->_reg, $hkey."\\".$netCount."\\Description", $strName, false)
&& self::readReg($this->_reg, $hkey."\\".$netCount."\\ServiceName", $strGUID, false)) {
$cname = str_replace(array('(', ')', '#', '/'), array('[', ']', '_', '_'), $strName); //convert to canonical
if (!isset($aliases2[$cname])) { // duplicate checking
$aliases2[$cname]['id'] = $strGUID;
879,7 → 1456,7
}
}
 
$allNetworkAdapterConfigurations = CommonFunctions::getWMI($this->_wmi, 'Win32_NetworkAdapterConfiguration', array('SettingID', /*'Description',*/ 'MACAddress', 'IPAddress'));
$allNetworkAdapterConfigurations = self::getWMI(self::$_wmi, 'Win32_NetworkAdapterConfiguration', array('SettingID', /*'Description',*/ 'MACAddress', 'IPAddress'));
foreach ($allDevices as $device) if (!preg_match('/^WAN Miniport \[/', $device['Name'])) {
$dev = new NetDevice();
$name = $device['Name'];
903,11 → 1480,11
elseif (preg_match('/\s-\s([^-]*)$/', $mininame, $ar_name))
$name=substr($mininame, 0, strlen($mininame)-strlen($ar_name[0]));
$dev->setName($mininame);
if (trim($NetworkAdapterConfiguration['MACAddress']) !== "") $macexist = true;
if (isset($NetworkAdapterConfiguration['MACAddress']) && trim($NetworkAdapterConfiguration['MACAddress']) !== "") $macexist = true;
if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) {
if (isset($ali[$name]['netname'])) $dev->setInfo(str_replace(';', ':', $ali[$name]['netname']));
if ((!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR)
&& (trim($NetworkAdapterConfiguration['MACAddress']) !== "")) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').str_replace(':', '-', strtoupper($NetworkAdapterConfiguration['MACAddress'])));
&& $macexist) $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').str_replace(':', '-', strtoupper(trim($NetworkAdapterConfiguration['MACAddress']))));
if (isset($NetworkAdapterConfiguration['IPAddress']))
foreach ($NetworkAdapterConfiguration['IPAddress'] as $ipaddres)
if (($ipaddres != "0.0.0.0") && ($ipaddres != "::") && !preg_match('/^fe80::/i', $ipaddres))
1005,7 → 1582,7
*/
private function _memory()
{
if ($this->_wmi) {
if (self::$_wmi) {
$buffer = $this->_get_Win32_OperatingSystem();
if ($buffer) {
$this->sys->setMemTotal($buffer[0]['TotalVisibleMemorySize'] * 1024);
1012,7 → 1589,7
$this->sys->setMemFree($buffer[0]['FreePhysicalMemory'] * 1024);
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
}
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PageFileUsage');
$buffer = self::getWMI(self::$_wmi, 'Win32_PageFileUsage');
foreach ($buffer as $swapdevice) {
$dev = new DiskDevice();
$dev->setName("SWAP");
1040,11 → 1617,13
{
$typearray = array('Unknown', 'No Root Directory', 'Removable Disk', 'Local Disk', 'Network Drive', 'Compact Disc', 'RAM Disk');
$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.');
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType'));
$buffer = self::getWMI(self::$_wmi, 'Win32_LogicalDisk', array('Name', 'Size', 'FreeSpace', 'FileSystem', 'DriveType', 'MediaType'));
foreach ($buffer as $filesystem) {
$dev = new DiskDevice();
$dev->setMountPoint($filesystem['Name']);
$dev->setFsType($filesystem['FileSystem']);
if (isset($filesystem['FileSystem'])) {
$dev->setFsType($filesystem['FileSystem']);
}
if ($filesystem['Size'] > 0) {
$dev->setTotal($filesystem['Size']);
$dev->setFree($filesystem['FreeSpace']);
1057,10 → 1636,19
}
$this->sys->setDiskDevices($dev);
}
if (!$buffer && ($this->sys->getDistribution()=="ReactOS")) {
// test for command 'free' on current disk
if (CommonFunctions::executeProgram('cmd', '/c free 2>nul', $out_value, true)) {
for ($letter='A'; $letter!='AA'; $letter++) if (CommonFunctions::executeProgram('cmd', '/c free '.$letter.': 2>nul', $out_value, false)) {
if (!$buffer && !defined('PSI_EMU_HOSTNAME')) {
$letters = array();
if (CommonFunctions::executeProgram('fsutil', 'fsinfo drives 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/^Drives:\s*(.+)$/i', $out_value, $disks)) {
$diskarr = preg_split('/ /', $disks[1], -1, PREG_SPLIT_NO_EMPTY);
foreach ($diskarr as $disk) if (preg_match('/^(\w):\\\\$/', $disk, $diskletter)) {
$letters[] = $diskletter[1];
}
}
if (count($letters) == 0) for ($letter='A'; $letter!='AA'; $letter++) {
$letters[] = $letter;
}
if ((substr($this->sys->getDistribution(), 0, 7)=="ReactOS") && CommonFunctions::executeProgram('cmd', '/c free 2>nul', $out_value, false)) {
foreach ($letters as $letter) if (CommonFunctions::executeProgram('cmd', '/c free '.$letter.': 2>nul', $out_value, false)) {
$values = preg_replace('/[^\d\n]/', '', $out_value);
if (preg_match('/\n(\d+)\n(\d+)\n(\d+)$/', $values, $out_dig)) {
$size = $out_dig[1];
1069,7 → 1657,11
if ($used + $free == $size) {
$dev = new DiskDevice();
$dev->setMountPoint($letter.":");
$dev->setFsType('Unknown');
if (CommonFunctions::executeProgram('fsutil', 'fsinfo volumeinfo '.$letter.':\ 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/\nFile System Name\s*:\s*(\S+)/im', $out_value, $fsname)) {
$dev->setFsType($fsname[1]);
} else {
$dev->setFsType('Unknown');
}
$dev->setName('Unknown');
$dev->setTotal($size);
$dev->setUsed($used);
1078,6 → 1670,30
}
}
}
} else {
if (substr($this->sys->getDistribution(), 0, 7)=="ReactOS") {
$disksep = ':\\';
} else {
$disksep = ':';
}
foreach ($letters as $letter) {
$size = disk_total_space($letter.':\\');
$free = disk_free_space($letter.':\\');
if (($size !== false) && ($free !== false) && ($size >= 0) && ($free >= 0) && ($size >= $free)) {
$dev = new DiskDevice();
$dev->setMountPoint($letter.":");
if (CommonFunctions::executeProgram('fsutil', 'fsinfo volumeinfo '.$letter.$disksep.' 2>nul', $out_value, false) && ($out_value !== '') && preg_match('/\nFile System Name\s*:\s*(\S+)/im', $out_value, $fsname)) {
$dev->setFsType($fsname[1]);
} else {
$dev->setFsType('Unknown');
}
$dev->setName('Unknown');
$dev->setTotal($size);
$dev->setUsed($size - $free);
$dev->setFree($free);
$this->sys->setDiskDevices($dev);
}
}
}
}
}
1114,7 → 1730,7
$processes['*'] = (count($lines)-1) - 3 ; //correction for process "qprocess *"
}
if ($processes['*'] <= 0) {
$buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
$buffer = self::getWMI(self::$_wmi, 'Win32_Process', array('Caption'));
$processes['*'] = count($buffer);
}
$processes[' '] = $processes['*'];
1128,11 → 1744,11
*/
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'));
$allMems = self::_get_Win32_PhysicalMemory();
if ($allMems) {
$reg = false;
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
$arrMems = CommonFunctions::getWMI($this->_wmi, 'Win32_PhysicalMemoryArray', array('MemoryErrorCorrection'));
$arrMems = self::getWMI(self::$_wmi, 'Win32_PhysicalMemoryArray', array('MemoryErrorCorrection'));
$reg = (count($arrMems) == 1) && isset($arrMems[0]['MemoryErrorCorrection']) && ($arrMems[0]['MemoryErrorCorrection'] == 6);
}
foreach ($allMems as $mem) {
1170,68 → 1786,68
$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;
// 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';
}
} 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;
// 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';
}
}
if (isset($mem['Speed']) && (($speed = $mem['Speed']) > 0) && (preg_match('/^(DDR\d*)(.*)/', $memtype, $dr) || preg_match('/^(SDR)AM(.*)/', $memtype, $dr))) {
1248,30 → 1864,30
}
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;
// 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';
}
}
if (isset($mem['DataWidth']) && isset($mem['TotalWidth']) && (($dataw = $mem['DataWidth']) > 0) && (($totalw = $mem['TotalWidth']) > 0) && ($dataw < $totalw)) {
1304,13 → 1920,13
*
* @see PSI_Interface_OS::build()
*
* @return Void
* @return void
*/
public function build()
{
$this->_distro(); //share getDistribution()
if ($this->sys->getDistribution()=="ReactOS") {
$this->error->addError("WARN", "The ReactOS version of phpSysInfo is a work in progress, some things currently don't work");
$this->_distro(); // share getDistribution()
if (substr($this->sys->getDistribution(), 0, 7)=="ReactOS") {
$this->error->addWarning("The ReactOS version of phpSysInfo is a work in progress, some things currently don't work");
}
if (!$this->blockname || $this->blockname==='vitals') {
$this->_hostname();
1319,20 → 1935,21
$this->_loadavg();
$this->_processes();
}
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
if (!$this->blockname || $this->blockname==='hardware') {
$this->_machine();
$this->_cpuinfo();
$this->_virtualizer();
$this->_meminfo();
$this->_hardware();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
}
if (!$this->blockname || $this->blockname==='filesystem') {
$this->_filesystems();
}
if (!$this->blockname || $this->blockname==='memory') {
$this->_memory();
if (!$this->blockname || $this->blockname==='network') {
$this->_network();
}
}
}