Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
325 richard 1
<?php
2
/***************************************************************************
3
 *   Copyright (C) 2006 by phpSysInfo - A PHP System Information Script    *
4
 *   http://phpsysinfo.sourceforge.net/                                    *
5
 *                                                                         *
6
 *   This program is free software; you can redistribute it and/or modify  *
7
 *   it under the terms of the GNU General Public License as published by  *
8
 *   the Free Software Foundation; either version 2 of the License, or     *
9
 *   (at your option) any later version.                                   *
10
 *                                                                         *
11
 *   This program is distributed in the hope that it will be useful,       *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU General Public License for more details.                          *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU General Public License     *
17
 *   along with this program; if not, write to the                         *
18
 *   Free Software Foundation, Inc.,                                       *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20
 ***************************************************************************/
21
 
22
// $Id: filesystems.php,v 1.31 2007/02/08 20:16:25 bigmichi1 Exp $
23
 
24
//
25
// xml_filesystems()
26
//
27
function xml_filesystems () {
28
	global $sysinfo;
29
	global $show_mount_point;
30
 
31
	$arrFs = $sysinfo->filesystems();
32
 
33
	$_text = "  <FileSystem>\n";
34
	for ( $i = 0, $max = sizeof( $arrFs ); $i < $max; $i++ ) {
35
		$_text .= "    <Mount>\n";
36
		$_text .= "      <MountPointID>" . htmlspecialchars( $i, ENT_QUOTES ) . "</MountPointID>\n";
37
 
38
		if( $show_mount_point ) {
39
			$_text .= "      <MountPoint>" . htmlspecialchars( $arrFs[$i]['mount'], ENT_QUOTES ) . "</MountPoint>\n";
40
		}
41
 
42
		$_text .= "      <Type>" . htmlspecialchars( $arrFs[$i]['fstype'], ENT_QUOTES ) . "</Type>\n"
43
				. "      <Device><Name>" . htmlspecialchars( $arrFs[$i]['disk'], ENT_QUOTES ) . "</Name></Device>\n"
44
				. "      <Percent>" . htmlspecialchars( $arrFs[$i]['percent'], ENT_QUOTES ) . "</Percent>\n"
45
				. "      <Free>" . htmlspecialchars( $arrFs[$i]['free'], ENT_QUOTES ) . "</Free>\n"
46
				. "      <Used>" . htmlspecialchars( $arrFs[$i]['used'], ENT_QUOTES ) . "</Used>\n"
47
				. "      <Size>" . htmlspecialchars( $arrFs[$i]['size'], ENT_QUOTES ) . "</Size>\n";
48
		if( isset( $arrFs[$i]['options'] ) ) {
49
			$_text .= "      <Options>" . htmlspecialchars( $arrFs[$i]['options'], ENT_QUOTES ) . "</Options>\n";
50
		}
51
		if( isset( $arrFs[$i]['inodes'] ) ) {
52
			$_text .= "      <Inodes>" . htmlspecialchars( $arrFs[$i]['inodes'], ENT_QUOTES ) . "</Inodes>\n";
53
		}
54
		$_text  .= "    </Mount>\n";
55
	}
56
	$_text .= "  </FileSystem>\n";
57
 
58
	return $_text;
59
}
60
 
61
//
62
// html_filesystems()
63
//
64
function html_filesystems () {
65
	global $XPath;
66
	global $text;
67
	global $show_mount_point;
68
 
69
	$textdir = direction();
70
 
71
	$arrSum = array("size" => 0, "used" => 0, "free" => 0);
72
	$arrCounteddevlist = array();
73
	$intScalefactor = 2;
74
 
75
	$_text  = "<table border=\"0\" width=\"100%\" align=\"center\">\n";
76
	$_text .= "  <tr>\n";
77
	if ($show_mount_point) {
78
		$_text .= "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['mount'] . "</b></font></td>\n";
79
	}
80
	$_text .= "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['type'] . "</b></font></td>\n"
81
			. "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['partition'] . "</b></font></td>\n"
82
			. "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['percent'] . "</b></font></td>\n"
83
			. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['free'] . "</b></font></td>\n"
84
			. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['used'] . "</b></font></td>\n"
85
			. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['size'] . "</b></font></td>\n  </tr>\n";
86
	for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/FileSystem" ) ); $i < $max; $i++ ) {
87
		if( $XPath->match( "/phpsysinfo/FileSystem/Mount[" . $i . "]/MountPointID" ) ) {
88
			if( ! $XPath->match( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Options" ) || ! stristr( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Options" ), "bind" ) ) {
89
				if( ! in_array( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Device/Name" ), $arrCounteddevlist ) ) {
90
					$arrSum['size'] += $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Size" );
91
					$arrSum['used'] += $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Used" );
92
					$arrSum['free'] += $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Free" );
93
					if( PHP_OS != "WINNT" ) {
94
						$arrCounteddevlist[] = $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Device/Name" );
95
					}
96
				}
97
			}
98
			$_text .= "  <tr>\n";		
99
			if( $show_mount_point ) {
100
				$_text .= "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/MountPoint" ) . "</font></td>\n";
101
			}
102
			$_text .= "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Type" ) . "</font></td>\n"
103
					. "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Device/Name" ) . "</font></td>\n"
104
					. "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">"
105
					. create_bargraph( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Used" ), $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Size" ), $intScalefactor, $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Type" ) )
106
					. "&nbsp;" . $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Percent" ) . "%";
107
			if( $XPath->match( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Inodes" ) ) {
108
				$_text .= " (" . $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Inodes" ) . "%)";
109
			}
110
			$_text .= "</font></td>\n"
111
					. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Free" ) ) . "</font></td>\n"
112
					. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Used" ) ) . "</font></td>\n"
113
					. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Size" ) ) . "</font></td>\n"
114
					. "  </tr>\n";
115
		}
116
	}
117
	$_text .= "  <tr>\n";
118
	if( $show_mount_point ) {
119
		$_text .= "  <td colspan=\"3\" align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><i>" . $text['totals'] . " :&nbsp;&nbsp;</i></font></td>\n";
120
	} else {
121
		$_text .= "  <td colspan=\"2\" align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><i>" . $text['totals'] . " :&nbsp;&nbsp;</i></font></td>\n";
122
	}
123
	$_text .= "    <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">"
124
		. create_bargraph( $arrSum['used'], $arrSum['size'], $intScalefactor )
125
		. "&nbsp;";
126
	if( $arrSum['size'] == 0 ) {
127
		$_text .= "0";
128
	} else {
129
		$_text .= round( 100 / $arrSum['size'] *  $arrSum['used'] );
130
	}
131
	$_text .= "%" .  "</font></td>\n"
132
		. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $arrSum['free'] ) . "</font></td>\n"
133
		. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $arrSum['used'] ) . "</font></td>\n"
134
		. "    <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $arrSum['size'] ) . "</font></td>\n  </tr>\n"
135
		. "</table>\n";
136
 
137
	return $_text;
138
}
139
 
140
function wml_filesystem() {
141
	global $XPath;
142
	global $text;
143
	global $show_mount_point;
144
 
145
	$_text = "<card id=\"filesystem\" title=\"" . $text['fs'] . "\">\n";
146
	for( $i = 1; $i < sizeof( $XPath->getDataParts( "/phpsysinfo/FileSystem" ) ); $i++ ) {
147
		if( $XPath->match( "/phpsysinfo/FileSystem/Mount[" . $i . "]/MountPointID" ) ) {
148
			$_text .= "<p>";
149
			if( $show_mount_point ) {
150
				$_text .= $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/MountPoint" ) . "<br/>\n";
151
			} else {
152
				$_text .= $XPath->getData( "/phpsysinfo/FileSystem/Mount[" . $i . "]/Device/Name" ) . "<br/>\n";
153
			}
154
			$_text .= "- " . $text['free'] . ": " . format_bytesize( $XPath->getData("/phpsysinfo/FileSystem/Mount[" . $i . "]/Free" ) ) . "<br/>\n"
155
					. "- " . $text['used'] . ": " . format_bytesize( $XPath->getData("/phpsysinfo/FileSystem/Mount[" . $i . "]/Used" ) ) . "<br/>\n"
156
					. "- " . $text['size'] . ": " . format_bytesize( $XPath->getData("/phpsysinfo/FileSystem/Mount[" . $i . "]/Size" ) ) . "<br/>\n"
157
					. "</p>\n";
158
		}
159
	}
160
    $_text .= "</card>\n";
161
 
162
    return $_text;
163
}
164
?>