File: filesystems.php

package info (click to toggle)
phpsysinfo 2.3-4sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,576 kB
  • ctags: 1,566
  • sloc: php: 8,060; sh: 67; makefile: 14
file content (121 lines) | stat: -rw-r--r-- 5,878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
//
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// $Id: filesystems.php,v 1.11 2003/11/27 06:19:01 webbie Exp $

//
// xml_filesystems()
//
function xml_filesystems () {
    global $sysinfo;
    $fs = $sysinfo->filesystems();

    $_text = "  <FileSystem>\n";
    for ($i=0, $max = sizeof($fs); $i < $max; $i++) {
        $sum['size'] += $fs[$i]['size'];
        $sum['used'] += $fs[$i]['used'];
        $sum['free'] += $fs[$i]['free'];
        $_text .= "    <Mount>\n";

        $_text .= "      <MountPoint>" . $fs[$i]['mount'] . "</MountPoint>\n";

        $_text .= "      <Type>" . $fs[$i]['fstype'] . "</Type>\n"
                . "      <Device>" . $fs[$i]['disk'] . "</Device>\n"
                . "      <Percent>" . $fs[$i]['percent'] . "</Percent>\n"
                . "      <Free>" . $fs[$i]['free'] . "</Free>\n"
                . "      <Used>" . $fs[$i]['used'] . "</Used>\n"
                . "      <Size>" . $fs[$i]['size'] . "</Size>\n"
                . "    </Mount>\n";
    }
    $_text .= "  </FileSystem>\n";
    return $_text;
}

//
// html_filesystems()
//
function html_filesystems () {
    global $XPath;
    global $text;
    global $show_mount_point;
    
    $scale_factor = 2;

    $_text  = '<table border="0" width="90%" align="center">';
    $_text .= '<tr>';

    if ($show_mount_point) {
      $_text .= '<td align="left" valign="top"><font size="-1"><b>' . $text['mount'] . '</b></font></td>';
    }

    $_text .= '<td align="left" valign="top"><font size="-1"><b>' . $text['type'] . '</b></font></td>'
           . '<td align="left" valign="top"><font size="-1"><b>' . $text['partition'] . '</b></font></td>'
           . '<td align="left" valign="top"><font size="-1"><b>' . $text['percent'] . '</b></font></td>'
           . '<td align="right" valign="top"><font size="-1"><b>' . $text['free'] . '</b></font></td>'
           . '<td align="right" valign="top"><font size="-1"><b>' . $text['used'] . '</b></font></td>'
           . '<td align="right" valign="top"><font size="-1"><b>' . $text['size'] . '</b></font></td></tr>';

    for ($i=1, $max = sizeof($XPath->getDataParts('/phpsysinfo/FileSystem')); $i < $max; $i++) {
        if ($XPath->match("/phpsysinfo/FileSystem/Mount[$i]/MountPoint")) {
            $sum['size'] += $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Size");
            $sum['used'] += $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Used");
            $sum['free'] += $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Free");

            $_text .= "\t<tr>\n";

            if ($show_mount_point) {
              $_text .= "\t\t<td align=\"left\" valign=\"top\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/MountPoint") . "</font></td>\n";
            }
            $_text .= "\t\t<td align=\"left\" valign=\"top\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Type") . "</font></td>\n";
            $_text .= "\t\t<td align=\"left\" valign=\"top\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Device") . "</font></td>\n";
            $_text .= "\t\t<td align=\"left\" valign=\"top\"><font size=\"-1\">";

            $_text .= create_bargraph($XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Percent"), $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Percent"), $scale_factor, $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Type"));

            $_text .= "&nbsp;" . $XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Percent") . "</font></td>\n";
            $_text .= "\t\t<td align=\"right\" valign=\"top\"><font size=\"-1\">" . format_bytesize($XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Free")) . "</font></td>\n";
            $_text .= "\t\t<td align=\"right\" valign=\"top\"><font size=\"-1\">" . format_bytesize($XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Used")) . "</font></td>\n";
            $_text .= "\t\t<td align=\"right\" valign=\"top\"><font size=\"-1\">" . format_bytesize($XPath->getData("/phpsysinfo/FileSystem/Mount[$i]/Size")) . "</font></td>\n";
            $_text .= "\t</tr>\n";
        }
    }

    $_text .= '<tr>';

    if ($show_mount_point) {
      $_text .= '<td colspan="3" align="right" valign="top"><font size="-1"><i>' . $text['totals'] . ' :&nbsp;&nbsp;</i></font></td>';
    } else {
      $_text .= '<td colspan="2" align="right" valign="top"><font size="-1"><i>' . $text['totals'] . ' :&nbsp;&nbsp;</i></font></td>';
    }

    $_text .= "\t\t<td align=\"left\" valign=\"top\"><font size=\"-1\">";

    $sum_percent = round(($sum['used'] * 100) / $sum['size']);
    $_text .= create_bargraph($sum_percent, $sum_percent, $scale_factor);

    $_text .= "&nbsp;" . $sum_percent . "%" .  "</font></td>\n";

    $_text .= '<td align="right" valign="top"><font size="-1">' . format_bytesize($sum['free']) . '</font></td>'
           . '<td align="right" valign="top"><font size="-1">' . format_bytesize($sum['used']) . '</font></td>'
           . '<td align="right" valign="top"><font size="-1">' . format_bytesize($sum['size']) . '</font></td></tr>'
           . '</table>';

    return $_text;
}
?>