当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonFunctions::getWMI方法代码示例

本文整理汇总了PHP中CommonFunctions::getWMI方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonFunctions::getWMI方法的具体用法?PHP CommonFunctions::getWMI怎么用?PHP CommonFunctions::getWMI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonFunctions的用法示例。


在下文中一共展示了CommonFunctions::getWMI方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * fill the private content var
  */
 public function __construct()
 {
     parent::__construct();
     if (PSI_OS == 'WINNT') {
         $_wmi = null;
         // don't set this params for local connection, it will not work
         $strHostname = '';
         $strUser = '';
         $strPassword = '';
         try {
             // initialize the wmi object
             $objLocator = new COM('WbemScripting.SWbemLocator');
             if ($strHostname == "") {
                 $_wmi = $objLocator->ConnectServer($strHostname, 'root\\WMI');
             } else {
                 $_wmi = $objLocator->ConnectServer($strHostname, 'root\\WMI', $strHostname . '\\' . $strUser, $strPassword);
             }
         } catch (Exception $e) {
             $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for ThermalZone data.");
         }
         if ($_wmi) {
             $this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
         }
     }
 }
开发者ID:JordaoS,项目名称:phpsysinfo,代码行数:28,代码来源:class.thermalzone.inc.php

示例2: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc target encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_PSSTATUS_ACCESS)) {
         case 'command':
             if (PSI_OS == 'WINNT') {
                 try {
                     $objLocator = new COM('WbemScripting.SWbemLocator');
                     $wmi = $objLocator->ConnectServer('', 'root\\CIMv2');
                     $process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'ProcessId'));
                     foreach ($process_wmi as $process) {
                         $this->_filecontent[] = array(strtolower(trim($process['Caption'])), trim($process['ProcessId']));
                     }
                 } catch (Exception $e) {
                 }
             } else {
                 if (defined('PSI_PLUGIN_PSSTATUS_PROCESSES') && is_string(PSI_PLUGIN_PSSTATUS_PROCESSES)) {
                     if (preg_match(ARRAY_EXP, PSI_PLUGIN_PSSTATUS_PROCESSES)) {
                         $processes = eval(PSI_PLUGIN_PSSTATUS_PROCESSES);
                     } else {
                         $processes = array(PSI_PLUGIN_PSSTATUS_PROCESSES);
                     }
                     if (defined('PSI_PLUGIN_PSSTATUS_USE_REGEX') && PSI_PLUGIN_PSSTATUS_USE_REGEX === true) {
                         foreach ($processes as $process) {
                             CommonFunctions::executeProgram("pgrep", "-n -x " . $process, $buffer, PSI_DEBUG);
                             if (strlen($buffer) > 0) {
                                 $this->_filecontent[] = array($process, $buffer);
                             }
                         }
                     } else {
                         foreach ($processes as $process) {
                             CommonFunctions::executeProgram("pidof", "-s " . $process, $buffer, PSI_DEBUG);
                             if (strlen($buffer) > 0) {
                                 $this->_filecontent[] = array($process, $buffer);
                             }
                         }
                     }
                 }
             }
             break;
         case 'data':
             CommonFunctions::rfts(APP_ROOT . "/data/psstatus.txt", $buffer);
             $processes = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
             foreach ($processes as $process) {
                 $ps = preg_split("/[\\s]?\\|[\\s]?/", $process, -1, PREG_SPLIT_NO_EMPTY);
                 if (count($ps) == 2) {
                     $this->_filecontent[] = array(trim($ps[0]), trim($ps[1]));
                 }
             }
             break;
         default:
             $this->global_error->addError("switch(PSI_PLUGIN_PSSTATUS_ACCESS)", "Bad psstatus configuration in phpsysinfo.ini");
             break;
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:60,代码来源:class.psstatus.inc.php

示例3: __construct

 /**
  * fill the private content var
  */
 public function __construct()
 {
     parent::__construct();
     $_wmi = null;
     try {
         // initialize the wmi object
         $objLocator = new COM('WbemScripting.SWbemLocator');
         $_wmi = $objLocator->ConnectServer('', 'root\\OpenHardwareMonitor');
     } catch (Exception $e) {
         $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
     }
     if ($_wmi) {
         $this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:18,代码来源:class.ohm.inc.php

示例4: __construct

 /**
  * fill the private content var
  */
 public function __construct()
 {
     parent::__construct();
     if (PSI_OS == 'WINNT') {
         $_wmi = null;
         try {
             // initialize the wmi object
             $objLocator = new COM('WbemScripting.SWbemLocator');
             $_wmi = $objLocator->ConnectServer('', 'root\\WMI');
         } catch (Exception $e) {
             $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for ThermalZone data.");
         }
         if ($_wmi) {
             $this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
         }
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:20,代码来源:class.thermalzone.inc.php

示例5: __construct

 /**
  * fill the private content var
  */
 public function __construct()
 {
     parent::__construct();
     // don't set this params for local connection, it will not work
     $strHostname = '';
     $strUser = '';
     $strPassword = '';
     try {
         // initialize the wmi object
         $objLocator = new COM('WbemScripting.SWbemLocator');
         if ($strHostname == "") {
             $this->_wmi = $objLocator->ConnectServer($strHostname, 'root\\OpenHardwareMonitor');
         } else {
             $this->_wmi = $objLocator->ConnectServer($strHostname, 'root\\OpenHardwareMonitor', $strHostname . '\\' . $strUser, $strPassword);
         }
     } catch (Exception $e) {
         $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed.");
     }
     $this->_buf = CommonFunctions::getWMI($this->_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
 }
开发者ID:l1ght13aby,项目名称:Ubilling,代码行数:23,代码来源:class.ohm.inc.php

示例6: __construct

 /**
  * fill the private content var
  */
 public function __construct()
 {
     parent::__construct();
     $_wmi = null;
     // don't set this params for local connection, it will not work
     $strHostname = '';
     $strUser = '';
     $strPassword = '';
     try {
         // initialize the wmi object
         $objLocator = new COM('WbemScripting.SWbemLocator');
         if ($strHostname == "") {
             $_wmi = $objLocator->ConnectServer($strHostname, 'root\\OpenHardwareMonitor');
         } else {
             $_wmi = $objLocator->ConnectServer($strHostname, 'root\\OpenHardwareMonitor', $strHostname . '\\' . $strUser, $strPassword);
         }
     } catch (Exception $e) {
         $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
     }
     if ($_wmi) {
         $this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
     }
 }
开发者ID:kampee,项目名称:phpsysinfo,代码行数:26,代码来源:class.ohm.inc.php

示例7: _filesystems

 /**
  * filesystem information
  *
  * @return void
  */
 private function _filesystems()
 {
     $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'));
     foreach ($buffer as $filesystem) {
         $dev = new DiskDevice();
         $dev->setMountPoint($filesystem['Name']);
         $dev->setFsType($filesystem['FileSystem']);
         if ($filesystem['Size'] > 0) {
             $dev->setTotal($filesystem['Size']);
             $dev->setFree($filesystem['FreeSpace']);
             $dev->setUsed($filesystem['Size'] - $filesystem['FreeSpace']);
         }
         if ($filesystem['MediaType'] != "" && $filesystem['DriveType'] == 2) {
             $dev->setName($typearray[$filesystem['DriveType']] . " (" . $floppyarray[$filesystem['MediaType']] . ")");
         } else {
             $dev->setName($typearray[$filesystem['DriveType']]);
         }
         $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 (preg_match('/\\n\\s*([\\d\\.\\,]+).*\\n\\s*([\\d\\.\\,]+).*\\n\\s*([\\d\\.\\,]+).*$/', $out_value, $out_dig)) {
                         $size = preg_replace('/(\\.)|(\\,)/', '', $out_dig[1]);
                         $used = preg_replace('/(\\.)|(\\,)/', '', $out_dig[2]);
                         $free = preg_replace('/(\\.)|(\\,)/', '', $out_dig[3]);
                         if ($used + $free == $size) {
                             $dev = new DiskDevice();
                             $dev->setMountPoint($letter . ":");
                             $dev->setFsType('Unknown');
                             $dev->setTotal($size);
                             $dev->setFree($free);
                             $dev->setUsed($used);
                             $this->sys->setDiskDevices($dev);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:caglaroflazoglu,项目名称:sentora-core,代码行数:50,代码来源:class.WINNT.inc.php

示例8: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_BAT_ACCESS)) {
         case 'command':
             if (PSI_OS == 'WINNT') {
                 $_cim = null;
                 //root\CIMv2
                 $_wmi = null;
                 //root\WMI
                 // don't set this params for local connection, it will not work
                 $strHostname = '';
                 $strUser = '';
                 $strPassword = '';
                 try {
                     // initialize the wmi object
                     $objLocatorCIM = new COM('WbemScripting.SWbemLocator');
                     if ($strHostname == "") {
                         $_cim = $objLocatorCIM->ConnectServer();
                     } else {
                         $_cim = $objLocatorCIM->ConnectServer($strHostname, 'root\\CIMv2', $strHostname . '\\' . $strUser, $strPassword);
                     }
                     // initialize the wmi object
                     $objLocatorWMI = new COM('WbemScripting.SWbemLocator');
                     if ($strHostname == "") {
                         $_wmi = $objLocatorWMI->ConnectServer($strHostname, 'root\\WMI');
                     } else {
                         $_wmi = $objLocatorWMI->ConnectServer($strHostname, 'root\\WMI', $strHostname . '\\' . $strUser, $strPassword);
                     }
                 } catch (Exception $e) {
                     $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed.");
                 }
                 $buffer_info = '';
                 $buffer_state = '';
                 $bufferWB = CommonFunctions::getWMI($_cim, 'Win32_Battery', array('EstimatedChargeRemaining', 'DesignVoltage', 'BatteryStatus', 'Chemistry'));
                 if (sizeof($bufferWB) > 0) {
                     $capacity = '';
                     if (isset($bufferWB[0]['EstimatedChargeRemaining'])) {
                         $capacity = $bufferWB[0]['EstimatedChargeRemaining'];
                     }
                     if (isset($bufferWB[0]['BatteryStatus'])) {
                         switch ($bufferWB[0]['BatteryStatus']) {
                             case 1:
                                 $batstat = 'Discharging';
                                 break;
                             case 2:
                                 $batstat = 'AC connected';
                                 break;
                             case 3:
                                 $batstat = 'Fully Charged';
                                 break;
                             case 4:
                                 $batstat = 'Low';
                                 break;
                             case 5:
                                 $batstat = 'Critical';
                                 break;
                             case 6:
                                 $batstat = 'Charging';
                                 break;
                             case 7:
                                 $batstat = 'Charging and High';
                                 break;
                             case 8:
                                 $batstat = 'Charging and Low';
                                 break;
                             case 9:
                                 $batstat = 'Charging and Critical';
                                 break;
                             case 10:
                                 $batstat = 'Undefined';
                                 break;
                             case 11:
                                 $batstat = 'Partially Charged';
                                 break;
                             default:
                                 $batstat = '';
                         }
                         if ($batstat != '') {
                             $buffer_state .= 'POWER_SUPPLY_STATUS=' . $batstat . "\n";
                         }
                     }
                     $techn = '';
                     if (isset($bufferWB[0]['Chemistry'])) {
                         switch ($bufferWB[0]['Chemistry']) {
                             case 1:
                                 $techn = 'Other';
                                 break;
                             case 2:
                                 $techn = 'Unknown';
                                 break;
                             case 3:
                                 $techn = 'PbAc';
                                 break;
                             case 4:
//.........这里部分代码省略.........
开发者ID:phucps89,项目名称:Tour,代码行数:101,代码来源:class.bat.inc.php

示例9: _processes

 public function _processes()
 {
     $processes['*'] = 0;
     $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
     foreach ($buffer as $process) {
         $processes['*']++;
     }
     $processes[' '] = $processes['*'];
     $this->sys->setProcesses($processes);
 }
开发者ID:hecto932,项目名称:OJplus,代码行数:10,代码来源:class.WINNT.inc.php

示例10: _processes

 public function _processes()
 {
     $processes['*'] = 0;
     if (CommonFunctions::executeProgram("qprocess", "*", $strBuf, false) && strlen(trim($strBuf)) > 0) {
         $lines = preg_split('/\\n/', $strBuf);
         $processes['*'] = count($lines) - 1 - 3;
         //correction for process "qprocess *"
     }
     if ($processes['*'] <= 0) {
         $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption'));
         $processes['*'] = count($buffer);
     }
     $processes[' '] = $processes['*'];
     $this->sys->setProcesses($processes);
 }
开发者ID:zseand,项目名称:phpsysinfo,代码行数:15,代码来源:class.WINNT.inc.php

示例11: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_PS_ACCESS)) {
         case 'command':
             if (PSI_OS == 'WINNT') {
                 try {
                     $objLocator = new COM('WbemScripting.SWbemLocator');
                     $wmi = $objLocator->ConnectServer('', 'root\\CIMv2');
                     $os_wmi = CommonFunctions::getWMI($wmi, 'Win32_OperatingSystem', array('TotalVisibleMemorySize'));
                     foreach ($os_wmi as $os) {
                         $memtotal = $os['TotalVisibleMemorySize'] * 1024;
                     }
                     $process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'CommandLine', 'ProcessId', 'ParentProcessId', 'WorkingSetSize'));
                     foreach ($process_wmi as $process) {
                         if (strlen(trim($process['CommandLine'])) > 0) {
                             $ps = trim($process['CommandLine']);
                         } else {
                             $ps = trim($process['Caption']);
                         }
                         if (trim($process['ProcessId']) != 0) {
                             $memusage = round(trim($process['WorkingSetSize']) * 100 / $memtotal, 1);
                             //ParentProcessId
                             //Unique identifier of the process that creates a process. Process identifier numbers are reused, so they
                             //only identify a process for the lifetime of that process. It is possible that the process identified by
                             //ParentProcessId is terminated, so ParentProcessId may not refer to a running process. It is also
                             //possible that ParentProcessId incorrectly refers to a process that reuses a process identifier. You can
                             //use the CreationDate property to determine whether the specified parent was created after the process
                             //represented by this Win32_Process instance was created.
                             //=> subtrees of processes may be missing (WHAT TODO?!?)
                             $this->_filecontent[] = trim($process['ProcessId']) . " " . trim($process['ParentProcessId']) . " " . $memusage . " " . $ps;
                         }
                     }
                 } catch (Exception $e) {
                 }
             } else {
                 CommonFunctions::executeProgram("ps", "axo pid,ppid,pmem,args", $buffer, PSI_DEBUG);
                 if ((PSI_OS == 'Linux' || PSI_OS == 'Android') && !preg_match("/^[^\n]+\n\\s*\\d+\\s+\\d+\\s+[\\d\\.]+\\s+.+/", $buffer)) {
                     //alternative method if no data
                     if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
                         $bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
                         $totalmem = 0;
                         foreach ($bufe as $buf) {
                             if (preg_match('/^MemTotal:\\s+(.*)\\s*kB/i', $buf, $ar_buf)) {
                                 $totalmem = $ar_buf[1];
                                 break;
                             }
                         }
                         $buffer = "  PID  PPID %MEM COMMAND\n";
                         $processlist = glob('/proc/*/status', GLOB_NOSORT);
                         if (($total = count($processlist)) > 0) {
                             natsort($processlist);
                             //first sort
                             $prosess = array();
                             foreach ($processlist as $processitem) {
                                 //second sort
                                 $process[] = $processitem;
                             }
                             $buf = "";
                             for ($i = 0; $i < $total; $i++) {
                                 if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
                                     if ($totalmem != 0 && preg_match('/^VmRSS:\\s+(\\d+)\\s+kB/m', $buf, $tmppmem)) {
                                         $pmem = round(100 * $tmppmem[1] / $totalmem, 1);
                                     } else {
                                         $pmem = 0;
                                     }
                                     $name = null;
                                     if (CommonFunctions::rfts(substr($process[$i], 0, strlen($process[$i]) - 6) . "cmdline", $namebuf, 0, 4096, false)) {
                                         $name = str_replace(chr(0), ' ', trim($namebuf));
                                     }
                                     if (preg_match('/^Pid:\\s+(\\d+)/m', $buf, $tmppid) && preg_match('/^PPid:\\s+(\\d+)/m', $buf, $tmpppid) && preg_match('/^Name:\\s+(.+)/m', $buf, $tmpargs)) {
                                         $pid = $tmppid[1];
                                         $ppid = $tmpppid[1];
                                         $args = $tmpargs[1];
                                         if ($name !== null) {
                                             if ($name !== "") {
                                                 $args = $name;
                                             } else {
                                                 $args = "[" . $args . "]";
                                             }
                                         }
                                         $buffer .= $pid . " " . $ppid . " " . $pmem . " " . $args . "\n";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             break;
         case 'data':
             CommonFunctions::rfts(APP_ROOT . "/data/ps.txt", $buffer);
             break;
         default:
             $this->global_error->addConfigError("__construct()", "PSI_PLUGIN_PS_ACCESS");
//.........这里部分代码省略.........
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:101,代码来源:class.ps.inc.php

示例12: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_BAT_ACCESS)) {
         case 'command':
             if (PSI_OS == 'Android') {
                 CommonFunctions::rfts('/sys/class/power_supply/battery/uevent', $buffer_info, 0, 4096, PSI_DEBUG);
                 $buffer_state = '';
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/capacity', $buffer1, 1, 4096, false)) {
                     $buffer_state .= 'POWER_SUPPLY_CAPACITY=' . $buffer1;
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/batt_temp', $buffer1, 1, 4096, false)) {
                     $buffer_state .= 'POWER_SUPPLY_TEMP=' . $buffer1;
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/batt_vol', $buffer1, 1, 4096, false)) {
                     if ($buffer1 < 100000) {
                         // uV or mV detection
                         $buffer1 = $buffer1 * 1000;
                     }
                     $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW=' . $buffer1 . "\n";
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/voltage_max_design', $buffer1, 1, 4096, false)) {
                     if ($buffer1 < 100000) {
                         // uV or mV detection
                         $buffer1 = $buffer1 * 1000;
                     }
                     $buffer_state .= 'POWER_SUPPLY_VOLTAGE_MAX_DESIGN=' . $buffer1 . "\n";
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/technology', $buffer1, 1, 4096, false)) {
                     $buffer_state .= 'POWER_SUPPLY_TECHNOLOGY=' . $buffer1;
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/status', $buffer1, 1, 4096, false)) {
                     $buffer_state .= 'POWER_SUPPLY_STATUS=' . $buffer1;
                 }
                 if (CommonFunctions::rfts('/sys/class/power_supply/battery/health', $buffer1, 1, 4096, false)) {
                     $buffer_state .= 'POWER_SUPPLY_HEALTH=' . $buffer1;
                 }
             } elseif (PSI_OS == 'WINNT') {
                 // don't set this params for local connection, it will not work
                 $strHostname = '';
                 $strUser = '';
                 $strPassword = '';
                 try {
                     // initialize the wmi object
                     $objLocator = new COM('WbemScripting.SWbemLocator');
                     if ($strHostname == "") {
                         $this->_wmi = $objLocator->ConnectServer();
                     } else {
                         $this->_wmi = $objLocator->ConnectServer($strHostname, 'rootcimv2', $strHostname . '\\' . $strUser, $strPassword);
                     }
                 } catch (Exception $e) {
                     $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed.");
                 }
                 $buffer_info = '';
                 $buffer_state = '';
                 $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Battery', array('EstimatedChargeRemaining', 'DesignVoltage', 'BatteryStatus', 'Chemistry'));
                 $capacity = '';
                 if (isset($buffer[0]['EstimatedChargeRemaining'])) {
                     $capacity = $buffer[0]['EstimatedChargeRemaining'];
                 }
                 if (isset($buffer[0]['DesignVoltage'])) {
                     $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW=' . 1000 * $buffer[0]['DesignVoltage'] . "\n";
                 }
                 if (isset($buffer[0]['BatteryStatus'])) {
                     switch ($buffer[0]['BatteryStatus']) {
                         case 1:
                             $batstat = 'Discharging';
                             break;
                         case 2:
                             $batstat = 'AC connected';
                             break;
                         case 3:
                             $batstat = 'Fully Charged';
                             break;
                         case 4:
                             $batstat = 'Low';
                             break;
                         case 5:
                             $batstat = 'Critical';
                             break;
                         case 6:
                             $batstat = 'Charging';
                             break;
                         case 7:
                             $batstat = 'Charging and High';
                             break;
                         case 8:
                             $batstat = 'Charging and Low';
                             break;
                         case 9:
                             $batstat = 'Charging and Critical';
                             break;
                         case 10:
                             $batstat = 'Undefined';
                             break;
//.........这里部分代码省略.........
开发者ID:BIGGANI,项目名称:zpanelx,代码行数:101,代码来源:class.bat.inc.php


注:本文中的CommonFunctions::getWMI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。