Subversion Repositories ALCASAR

Rev

Rev 3100 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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