Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 2976
1
<?php
1
<?php
2
/**
2
/**
3
 * parser Class
3
 * parser Class
4
 *
4
 *
5
 * PHP version 5
5
 * PHP version 5
6
 *
6
 *
7
 * @category  PHP
7
 * @category  PHP
8
 * @package   PSI
8
 * @package   PSI
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   SVN: $Id: class.Parser.inc.php 604 2012-07-10 07:31:34Z namiltd $
12
 * @version   SVN: $Id: class.Parser.inc.php 604 2012-07-10 07:31:34Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
14
 */
15
 /**
15
 /**
16
 * parser class with common used parsing metods
16
 * parser class with common used parsing metods
17
 *
17
 *
18
 * @category  PHP
18
 * @category  PHP
19
 * @package   PSI
19
 * @package   PSI
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
21
 * @copyright 2009 phpSysInfo
21
 * @copyright 2009 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
23
 * @version   Release: 3.0
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
25
 */
26
class Parser
26
class Parser
27
{
27
{
28
    /**
28
    /**
29
     * parsing the output of lspci command
29
     * parsing the output of lspci command
30
     *
30
     *
31
     * @param  bool  $debug
31
     * @param  bool  $debug
32
     * @return array
32
     * @return array
33
     */
33
     */
34
    public static function lspci($debug = PSI_DEBUG)
34
    public static function lspci($debug = PSI_DEBUG)
35
    {
35
    {
36
        $arrResults = array();
36
        $arrResults = array();
37
        if (CommonFunctions::executeProgram("lspci", "", $strBuf, $debug)) {
37
        if (CommonFunctions::executeProgram("lspci", (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS)?"-m":"", $strBuf, $debug)) {
38
            $arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
38
            $arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
39
            foreach ($arrLines as $strLine) {
39
            foreach ($arrLines as $strLine) {
40
                $arrParams = preg_split('/ /', trim($strLine), 2);
-
 
41
                if (count($arrParams) == 2)
-
 
42
                   $strName = $arrParams[1];
-
 
43
                else
-
 
44
                   $strName = "unknown";
-
 
45
                $strName = preg_replace('/\(.*\)/', '', $strName);
-
 
46
                $dev = new HWDevice();
40
                $dev = new HWDevice();
-
 
41
                $arrParams = preg_split('/(\"? ")|(\" (?=-))/', trim($strLine));
-
 
42
                if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && ($cp = count($arrParams)) >= 6) {
-
 
43
                    $arrParams[$cp-1] = trim($arrParams[$cp-1],'"'); // remove last "
-
 
44
                    $dev->setName($arrParams[1].': '.$arrParams[2].' '.$arrParams[3]);
-
 
45
                    if (preg_match('/^-/', $arrParams[4])) {
-
 
46
                        if (($arrParams[5] !== "") && !preg_match('/^Unknown vendor/', $arrParams[5])) {
-
 
47
                            $dev->setManufacturer(trim($arrParams[5]));
-
 
48
                        }
-
 
49
                        if (($arrParams[6] !== "") && !preg_match('/^Device /', $arrParams[6])) {
-
 
50
                            $dev->setProduct(trim($arrParams[6]));
-
 
51
                        }
-
 
52
                    } else {
-
 
53
                        if (($arrParams[4] !== "") && !preg_match('/^Unknown vendor/', $arrParams[4])) {
-
 
54
                            $dev->setManufacturer(trim($arrParams[4]));
-
 
55
                        }
-
 
56
                        if (($arrParams[5] !== "") && !preg_match('/^Device /', $arrParams[5])) {
-
 
57
                            $dev->setProduct(trim($arrParams[5]));
-
 
58
                        }
-
 
59
                    }
-
 
60
                } else {
-
 
61
                    $strLine=trim(preg_replace('/(")|( -\S+)/', '', $strLine));
-
 
62
                    $arrParams = preg_split('/ /', trim($strLine), 2);
-
 
63
                    if (count($arrParams) == 2)
-
 
64
                        $strName = preg_replace('/\(rev\s[^\)]+\)/', '', $arrParams[1]);
-
 
65
                    else
-
 
66
                       $strName = "unknown";
47
                $dev->setName($strName);
67
                    $dev->setName($strName);
-
 
68
                }
48
                $arrResults[] = $dev;
69
                $arrResults[] = $dev;
49
            }
70
            }
50
        }
71
        }
51
 
72
 
52
        return $arrResults;
73
        return $arrResults;
53
    }
74
    }
54
 
75
 
55
    /**
76
    /**
56
     * parsing the output of df command
77
     * parsing the output of df command
57
     *
78
     *
58
     * @param string $df_param   additional parameter for df command
79
     * @param string $df_param   additional parameter for df command
59
     * @param bool   $get_inodes
80
     * @param bool   $get_inodes
60
     *
81
     *
61
     * @return array
82
     * @return array
62
     */
83
     */
63
    public static function df($df_param = "", $get_inodes = true)
84
    public static function df($df_param = "", $get_inodes = true)
64
    {
85
    {
65
        $arrResult = array();
86
        $arrResult = array();
66
        if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) {
87
        if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) {
67
            $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
88
            $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
68
            foreach ($mount as $mount_line) {
89
            foreach ($mount as $mount_line) {
69
                if (preg_match("/(\S+) on ([\S ]+) type (.*) \((.*)\)/", $mount_line, $mount_buf)) {
90
                if (preg_match("/(\S+) on ([\S ]+) type (.*) \((.*)\)/", $mount_line, $mount_buf)) {
70
                    $parm = array();
91
                    $parm = array();
71
                    $parm['mountpoint'] = trim($mount_buf[2]);
92
                    $parm['mountpoint'] = trim($mount_buf[2]);
72
                    $parm['fstype'] = $mount_buf[3];
93
                    $parm['fstype'] = $mount_buf[3];
73
                    $parm['name'] = $mount_buf[1];
94
                    $parm['name'] = $mount_buf[1];
74
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
95
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
75
                    $mount_parm[] = $parm;
96
                    $mount_parm[] = $parm;
76
                } elseif (preg_match("/(\S+) is (.*) mounted on (\S+) \(type (.*)\)/", $mount_line, $mount_buf)) {
97
                } elseif (preg_match("/(\S+) is (.*) mounted on (\S+) \(type (.*)\)/", $mount_line, $mount_buf)) {
77
                    $parm = array();
98
                    $parm = array();
78
                    $parm['mountpoint'] = trim($mount_buf[3]);
99
                    $parm['mountpoint'] = trim($mount_buf[3]);
79
                    $parm['fstype'] = $mount_buf[4];
100
                    $parm['fstype'] = $mount_buf[4];
80
                    $parm['name'] = $mount_buf[1];
101
                    $parm['name'] = $mount_buf[1];
81
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[2];
102
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[2];
82
                    $mount_parm[] = $parm;
103
                    $mount_parm[] = $parm;
83
                } elseif (preg_match("/(\S+) (.*) on (\S+) \((.*)\)/", $mount_line, $mount_buf)) {
104
                } elseif (preg_match("/(\S+) (.*) on (\S+) \((.*)\)/", $mount_line, $mount_buf)) {
84
                    $parm = array();
105
                    $parm = array();
85
                    $parm['mountpoint'] = trim($mount_buf[3]);
106
                    $parm['mountpoint'] = trim($mount_buf[3]);
86
                    $parm['fstype'] = $mount_buf[2];
107
                    $parm['fstype'] = $mount_buf[2];
87
                    $parm['name'] = $mount_buf[1];
108
                    $parm['name'] = $mount_buf[1];
88
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
109
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
89
                    $mount_parm[] = $parm;
110
                    $mount_parm[] = $parm;
90
                } elseif (preg_match("/(\S+) on ([\S ]+) \((\S+)(,\s(.*))?\)/", $mount_line, $mount_buf)) {
111
                } elseif (preg_match("/(\S+) on ([\S ]+) \((\S+)(,\s(.*))?\)/", $mount_line, $mount_buf)) {
91
                    $parm = array();
112
                    $parm = array();
92
                    $parm['mountpoint'] = trim($mount_buf[2]);
113
                    $parm['mountpoint'] = trim($mount_buf[2]);
93
                    $parm['fstype'] = $mount_buf[3];
114
                    $parm['fstype'] = $mount_buf[3];
94
                    $parm['name'] = $mount_buf[1];
115
                    $parm['name'] = $mount_buf[1];
95
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = isset($mount_buf[5]) ? $mount_buf[5] : '';
116
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = isset($mount_buf[5]) ? $mount_buf[5] : '';
96
                    $mount_parm[] = $parm;
117
                    $mount_parm[] = $parm;
97
                }
118
                }
98
            }
119
            }
99
        } elseif (CommonFunctions::rfts("/etc/mtab", $mount)) {
120
        } elseif (CommonFunctions::rfts("/etc/mtab", $mount)) {
100
            $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
121
            $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
101
            foreach ($mount as $mount_line) {
122
            foreach ($mount as $mount_line) {
102
                if (preg_match("/(\S+) (\S+) (\S+) (\S+) ([0-9]+) ([0-9]+)/", $mount_line, $mount_buf)) {
123
                if (preg_match("/(\S+) (\S+) (\S+) (\S+) ([0-9]+) ([0-9]+)/", $mount_line, $mount_buf)) {
103
                    $parm = array();
124
                    $parm = array();
104
                    $mount_point = preg_replace("/\\\\040/i", ' ', $mount_buf[2]); //space as \040
125
                    $mount_point = preg_replace("/\\\\040/i", ' ', $mount_buf[2]); //space as \040
105
                    $parm['mountpoint'] = $mount_point;
126
                    $parm['mountpoint'] = $mount_point;
106
                    $parm['fstype'] = $mount_buf[3];
127
                    $parm['fstype'] = $mount_buf[3];
107
                    $parm['name'] = $mount_buf[1];
128
                    $parm['name'] = $mount_buf[1];
108
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
129
                    if (PSI_SHOW_MOUNT_OPTION) $parm['options'] = $mount_buf[4];
109
                    $mount_parm[] = $parm;
130
                    $mount_parm[] = $parm;
110
                }
131
                }
111
            }
132
            }
112
        }
133
        }
113
        if (CommonFunctions::executeProgram('df', '-k '.$df_param, $df, PSI_DEBUG) && ($df!=="")) {
134
        if (CommonFunctions::executeProgram('df', '-k '.$df_param, $df, PSI_DEBUG) && ($df!=="")) {
114
            $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
135
            $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
115
            if ($get_inodes && PSI_SHOW_INODES) {
136
            if ($get_inodes && PSI_SHOW_INODES) {
116
                if (CommonFunctions::executeProgram('df', '-i '.$df_param, $df2, PSI_DEBUG)) {
137
                if (CommonFunctions::executeProgram('df', '-i '.$df_param, $df2, PSI_DEBUG)) {
117
                    $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY);
138
                    $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY);
118
                    // Store inode use% in an associative array (df_inodes) for later use
139
                    // Store inode use% in an associative array (df_inodes) for later use
119
                    foreach ($df2 as $df2_line) {
140
                    foreach ($df2 as $df2_line) {
120
                        if (preg_match("/^(\S+).*\s([0-9]+)%/", $df2_line, $inode_buf)) {
141
                        if (preg_match("/^(\S+).*\s([0-9]+)%/", $df2_line, $inode_buf)) {
121
                            $df_inodes[$inode_buf[1]] = $inode_buf[2];
142
                            $df_inodes[$inode_buf[1]] = $inode_buf[2];
122
                        }
143
                        }
123
                    }
144
                    }
124
                }
145
                }
125
            }
146
            }
126
            foreach ($df as $df_line) {
147
            foreach ($df as $df_line) {
127
                $df_buf1 = preg_split("/(\%\s)/", $df_line, 3);
148
                $df_buf1 = preg_split("/(\%\s)/", $df_line, 3);
128
                if (count($df_buf1) < 2) {
149
                if (count($df_buf1) < 2) {
129
                    continue;
150
                    continue;
130
                }
151
                }
131
                if (preg_match("/(.*)(\s+)(([0-9]+)(\s+)([0-9]+)(\s+)([\-0-9]+)(\s+)([0-9]+)$)/", $df_buf1[0], $df_buf2)) {
152
                if (preg_match("/(.*)(\s+)(([0-9]+)(\s+)([0-9]+)(\s+)([\-0-9]+)(\s+)([0-9]+)$)/", $df_buf1[0], $df_buf2)) {
132
                    if (count($df_buf1) == 3) {
153
                    if (count($df_buf1) == 3) {
133
                        $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[2]);
154
                        $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[2]);
134
                    } else {
155
                    } else {
135
                        $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]);
156
                        $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]);
136
                    }
157
                    }
137
                    if (count($df_buf) == 6) {
158
                    if (count($df_buf) == 6) {
138
                        $df_buf[5] = trim($df_buf[5]);
159
                        $df_buf[5] = trim($df_buf[5]);
139
                        $dev = new DiskDevice();
160
                        $dev = new DiskDevice();
140
                        $dev->setName(trim($df_buf[0]));
161
                        $dev->setName(trim($df_buf[0]));
141
                        if ($df_buf[2] < 0) {
162
                        if ($df_buf[2] < 0) {
142
                            $dev->setTotal($df_buf[3] * 1024);
163
                            $dev->setTotal($df_buf[3] * 1024);
143
                            $dev->setUsed($df_buf[3] * 1024);
164
                            $dev->setUsed($df_buf[3] * 1024);
144
                        } else {
165
                        } else {
145
                            $dev->setTotal($df_buf[1] * 1024);
166
                            $dev->setTotal($df_buf[1] * 1024);
146
                            $dev->setUsed($df_buf[2] * 1024);
167
                            $dev->setUsed($df_buf[2] * 1024);
147
                            if ($df_buf[3]>0) {
168
                            if ($df_buf[3]>0) {
148
                                $dev->setFree($df_buf[3] * 1024);
169
                                $dev->setFree($df_buf[3] * 1024);
149
                            }
170
                            }
150
                        }
171
                        }
151
                        if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($df_buf[5]);
172
                        if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($df_buf[5]);
152
 
173
 
153
                        $notwas = true;
174
                        $notwas = true;
154
                        if (isset($mount_parm)) {
175
                        if (isset($mount_parm)) {
155
                            foreach ($mount_parm as $mount_param) { //name and mountpoint find
176
                            foreach ($mount_parm as $mount_param) { //name and mountpoint find
156
                                if (($mount_param['name']===trim($df_buf[0])) && ($mount_param['mountpoint']===$df_buf[5])) {
177
                                if (($mount_param['name']===trim($df_buf[0])) && ($mount_param['mountpoint']===$df_buf[5])) {
157
                                    $dev->setFsType($mount_param['fstype']);
178
                                    $dev->setFsType($mount_param['fstype']);
158
                                    if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
179
                                    if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
159
                                        if (PSI_SHOW_MOUNT_CREDENTIALS) {
180
                                        if (PSI_SHOW_MOUNT_CREDENTIALS) {
160
                                            $dev->setOptions($mount_param['options']);
181
                                            $dev->setOptions($mount_param['options']);
161
                                        } else {
182
                                        } else {
162
                                            $mpo=$mount_param['options'];
183
                                            $mpo=$mount_param['options'];
163
 
184
 
164
                                            $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
185
                                            $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
165
                                            $mpo=preg_replace('/,guest,/i', ',', $mpo);
186
                                            $mpo=preg_replace('/,guest,/i', ',', $mpo);
166
 
187
 
167
                                            $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
188
                                            $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
168
                                            $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
189
                                            $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
169
 
190
 
170
                                            $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
191
                                            $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
171
                                            $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
192
                                            $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
172
 
193
 
173
                                            $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
194
                                            $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
174
                                            $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
195
                                            $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
175
 
196
 
176
                                            $dev->setOptions($mpo);
197
                                            $dev->setOptions($mpo);
177
                                        }
198
                                        }
178
                                    }
199
                                    }
179
                                    $notwas = false;
200
                                    $notwas = false;
180
                                    break;
201
                                    break;
181
                                }
202
                                }
182
                            }
203
                            }
183
                            if ($notwas) foreach ($mount_parm as $mount_param) { //mountpoint find
204
                            if ($notwas) foreach ($mount_parm as $mount_param) { //mountpoint find
184
                                if ($mount_param['mountpoint']===$df_buf[5]) {
205
                                if ($mount_param['mountpoint']===$df_buf[5]) {
185
                                    $dev->setFsType($mount_param['fstype']);
206
                                    $dev->setFsType($mount_param['fstype']);
186
                                    if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
207
                                    if (PSI_SHOW_MOUNT_OPTION && (trim($mount_param['options'])!=="")) {
187
                                        if (PSI_SHOW_MOUNT_CREDENTIALS) {
208
                                        if (PSI_SHOW_MOUNT_CREDENTIALS) {
188
                                            $dev->setOptions($mount_param['options']);
209
                                            $dev->setOptions($mount_param['options']);
189
                                        } else {
210
                                        } else {
190
                                            $mpo=$mount_param['options'];
211
                                            $mpo=$mount_param['options'];
191
 
212
 
192
                                            $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
213
                                            $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
193
                                            $mpo=preg_replace('/,guest,/i', ',', $mpo);
214
                                            $mpo=preg_replace('/,guest,/i', ',', $mpo);
194
 
215
 
195
                                            $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
216
                                            $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
196
                                            $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
217
                                            $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
197
 
218
 
198
                                            $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
219
                                            $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
199
                                            $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
220
                                            $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
200
 
221
 
201
                                            $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
222
                                            $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
202
                                            $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
223
                                            $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
203
 
224
 
204
                                            $dev->setOptions($mpo);
225
                                            $dev->setOptions($mpo);
205
                                        }
226
                                        }
206
                                    }
227
                                    }
207
                                    $notwas = false;
228
                                    $notwas = false;
208
                                    break;
229
                                    break;
209
                                }
230
                                }
210
                            }
231
                            }
211
                        }
232
                        }
212
 
233
 
213
                        if ($notwas) {
234
                        if ($notwas) {
214
                            $dev->setFsType('unknown');
235
                            $dev->setFsType('unknown');
215
                        }
236
                        }
216
 
237
 
217
                        if ($get_inodes && PSI_SHOW_INODES && isset($df_inodes[trim($df_buf[0])])) {
238
                        if ($get_inodes && PSI_SHOW_INODES && isset($df_inodes[trim($df_buf[0])])) {
218
                            $dev->setPercentInodesUsed($df_inodes[trim($df_buf[0])]);
239
                            $dev->setPercentInodesUsed($df_inodes[trim($df_buf[0])]);
219
                        }
240
                        }
220
                        $arrResult[] = $dev;
241
                        $arrResult[] = $dev;
221
                    }
242
                    }
222
                }
243
                }
223
            }
244
            }
224
        } else {
245
        } else {
225
            if (isset($mount_parm)) {
246
            if (isset($mount_parm)) {
226
                foreach ($mount_parm as $mount_param) {
247
                foreach ($mount_parm as $mount_param) {
227
                    if (is_dir($mount_param['mountpoint'])) {
248
                    if (is_dir($mount_param['mountpoint'])) {
228
                        $total = disk_total_space($mount_param['mountpoint']);
249
                        $total = disk_total_space($mount_param['mountpoint']);
229
                        if (($mount_param['fstype'] != 'none') && ($total > 0)) {
250
                        if (($mount_param['fstype'] != 'none') && ($total > 0)) {
230
                            $dev = new DiskDevice();
251
                            $dev = new DiskDevice();
231
                            $dev->setName($mount_param['name']);
252
                            $dev->setName($mount_param['name']);
232
                            $dev->setFsType($mount_param['fstype']);
253
                            $dev->setFsType($mount_param['fstype']);
233
 
254
 
234
                            if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($mount_param['mountpoint']);
255
                            if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($mount_param['mountpoint']);
235
 
256
 
236
                            $dev->setTotal($total);
257
                            $dev->setTotal($total);
237
                            $free = disk_free_space($mount_param['mountpoint']);
258
                            $free = disk_free_space($mount_param['mountpoint']);
238
                            if ($free > 0) {
259
                            if ($free > 0) {
239
                                $dev->setFree($free);
260
                                $dev->setFree($free);
240
                            } else {
261
                            } else {
241
                                $free = 0;
262
                                $free = 0;
242
                            }
263
                            }
243
                            if ($total > $free) $dev->setUsed($total - $free);
264
                            if ($total > $free) $dev->setUsed($total - $free);
244
 
265
 
245
                            if (PSI_SHOW_MOUNT_OPTION) {
266
                            if (PSI_SHOW_MOUNT_OPTION) {
246
                                if (PSI_SHOW_MOUNT_CREDENTIALS) {
267
                                if (PSI_SHOW_MOUNT_CREDENTIALS) {
247
                                    $dev->setOptions($mount_param['options']);
268
                                    $dev->setOptions($mount_param['options']);
248
                                } else {
269
                                } else {
249
                                    $mpo=$mount_param['options'];
270
                                    $mpo=$mount_param['options'];
250
 
271
 
251
                                    $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
272
                                    $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo);
252
                                    $mpo=preg_replace('/,guest,/i', ',', $mpo);
273
                                    $mpo=preg_replace('/,guest,/i', ',', $mpo);
253
 
274
 
254
                                    $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
275
                                    $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo);
255
                                    $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
276
                                    $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo);
256
 
277
 
257
                                    $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
278
                                    $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo);
258
                                    $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
279
                                    $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo);
259
 
280
 
260
                                    $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
281
                                    $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo);
261
                                    $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
282
                                    $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo);
262
 
283
 
263
                                    $dev->setOptions($mpo);
284
                                    $dev->setOptions($mpo);
264
                                }
285
                                }
265
                            }
286
                            }
266
                            $arrResult[] = $dev;
287
                            $arrResult[] = $dev;
267
                        }
288
                        }
268
                    }
289
                    }
269
                }
290
                }
270
            }
291
            }
271
        }
292
        }
272
 
293
 
273
        return $arrResult;
294
        return $arrResult;
274
    }
295
    }
275
}
296
}
276
 
297