Code Duplication    Length = 24-26 lines in 2 locations

phpsysinfo/includes/mb/class.ohm.inc.php 1 location

@@ 38-61 (lines=24) @@
35
    /**
36
     * fill the private content var
37
     */
38
    public function __construct()
39
    {
40
        parent::__construct();
41
        $_wmi = null;
42
        // don't set this params for local connection, it will not work
43
        $strHostname = '';
44
        $strUser = '';
45
        $strPassword = '';
46
        try {
47
            // initialize the wmi object
48
            $objLocator = new COM('WbemScripting.SWbemLocator');
49
            if ($strHostname == "") {
50
                $_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor');
51
52
            } else {
53
                $_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor', $strHostname.'\\'.$strUser, $strPassword);
54
            }
55
        } catch (Exception $e) {
56
            $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
57
        }
58
        if ($_wmi) {
59
            $this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
60
        }
61
    }
62
63
    /**
64
     * get temperature information

phpsysinfo/includes/mb/class.thermalzone.inc.php 1 location

@@ 38-63 (lines=26) @@
35
    /**
36
     * fill the private content var
37
     */
38
    public function __construct()
39
    {
40
        parent::__construct();
41
        if (PSI_OS == 'WINNT') {
42
            $_wmi = null;
43
            // don't set this params for local connection, it will not work
44
            $strHostname = '';
45
            $strUser = '';
46
            $strPassword = '';
47
            try {
48
                // initialize the wmi object
49
                $objLocator = new COM('WbemScripting.SWbemLocator');
50
                if ($strHostname == "") {
51
                    $_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI');
52
53
                } else {
54
                    $_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI', $strHostname.'\\'.$strUser, $strPassword);
55
                }
56
            } catch (Exception $e) {
57
                $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for ThermalZone data.");
58
            }
59
            if ($_wmi) {
60
                $this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
61
            }
62
        }
63
    }
64
65
    /**
66
     * get temperature information