Subversion Repositories ALCASAR

Rev

Rev 2976 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
Line 37... Line 37...
37
     * get all information from all configured ups in phpsysinfo.ini and store output in internal array
37
     * get all information from all configured ups in phpsysinfo.ini and store output in internal array
38
     */
38
     */
39
    public function __construct()
39
    public function __construct()
40
    {
40
    {
41
        parent::__construct();
41
        parent::__construct();
-
 
42
        if (!defined('PSI_UPS_APCUPSD_ACCESS')) {
-
 
43
             define('PSI_UPS_APCUPSD_ACCESS', false);
-
 
44
        }
-
 
45
        switch (strtolower(PSI_UPS_APCUPSD_ACCESS)) {
-
 
46
        case 'data':
42
        if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
47
            if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
43
            if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
48
                if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
44
                $upses = eval(PSI_UPS_APCUPSD_LIST);
49
                    $upss = eval(PSI_UPS_APCUPSD_LIST);
-
 
50
                } else {
-
 
51
                    $upss = array(PSI_UPS_APCUPSD_LIST);
-
 
52
                }
45
            } else {
53
            } else {
46
                $upses = array(PSI_UPS_APCUPSD_LIST);
54
               $upss = array('UPS');
47
            }
55
            }
-
 
56
            $un = 0;
48
            foreach ($upses as $ups) {
57
            foreach ($upss as $ups) {
-
 
58
                $temp = "";
49
                CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp);
59
                CommonFunctions::rftsdata("upsapcupsd{$un}.tmp", $temp);
50
                if (! empty($temp)) {
60
                if (! empty($temp)) {
51
                    $this->_output[] = $temp;
61
                    $this->_output[] = $temp;
52
                }
62
                }
-
 
63
                $un++;
53
            }
64
            }
-
 
65
            break;
-
 
66
        default:
-
 
67
            if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) {
-
 
68
                if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) {
-
 
69
                    $upses = eval(PSI_UPS_APCUPSD_LIST);
-
 
70
                } else {
-
 
71
                    $upses = array(PSI_UPS_APCUPSD_LIST);
-
 
72
                }
-
 
73
                foreach ($upses as $ups) {
-
 
74
                    $temp = "";
-
 
75
                    CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp);
-
 
76
                    if (! empty($temp)) {
-
 
77
                        $this->_output[] = $temp;
-
 
78
                    }
-
 
79
                }
54
        } else { //use default if address and port not defined
80
            } else { //use default if address and port not defined
55
            if (!defined('PSI_EMU_HOSTNAME')) {
81
                if (!defined('PSI_EMU_HOSTNAME')) {
56
                CommonFunctions::executeProgram('apcaccess', 'status', $temp);
82
                    CommonFunctions::executeProgram('apcaccess', 'status', $temp);
57
            } else {
83
                } else {
58
                CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp);
84
                    CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp);
59
            }
85
                }
60
            if (! empty($temp)) {
86
                if (! empty($temp)) {
61
                $this->_output[] = $temp;
87
                    $this->_output[] = $temp;
-
 
88
                }
62
            }
89
            }
63
        }
90
        }
64
    }
91
    }
65
 
92
 
66
    /**
93
    /**
67
     * parse the input and store data in resultset for xml generation
94
     * parse the input and store data in resultset for xml generation
68
     *
95
     *
69
     * @return Void
96
     * @return void
70
     */
97
     */
71
    private function _info()
98
    private function _info()
72
    {
99
    {
73
        foreach ($this->_output as $ups) {
100
        foreach ($this->_output as $ups) {
74
 
101
 
Line 141... Line 168...
141
    /**
168
    /**
142
     * get the information
169
     * get the information
143
     *
170
     *
144
     * @see PSI_Interface_UPS::build()
171
     * @see PSI_Interface_UPS::build()
145
     *
172
     *
146
     * @return Void
173
     * @return void
147
     */
174
     */
148
    public function build()
175
    public function build()
149
    {
176
    {
150
        $this->_info();
177
        $this->_info();
151
    }
178
    }