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: network.php,v 1.15 2007/02/08 20:16:25 bigmichi1 Exp $
|
|
|
23 |
|
|
|
24 |
//
|
|
|
25 |
// xml_network()
|
|
|
26 |
//
|
|
|
27 |
function xml_network () {
|
|
|
28 |
global $sysinfo;
|
|
|
29 |
|
|
|
30 |
$arrNet = $sysinfo->network();
|
|
|
31 |
|
|
|
32 |
$_text = " <Network>\n";
|
|
|
33 |
foreach( $arrNet as $strDev => $arrStats ) {
|
|
|
34 |
$_text .= " <NetDevice>\n"
|
|
|
35 |
. " <Name>" . htmlspecialchars( trim( $strDev ), ENT_QUOTES ) . "</Name>\n"
|
|
|
36 |
. " <RxBytes>" . htmlspecialchars( $arrStats['rx_bytes'], ENT_QUOTES ) . "</RxBytes>\n"
|
|
|
37 |
. " <TxBytes>" . htmlspecialchars( $arrStats['tx_bytes'], ENT_QUOTES ) . "</TxBytes>\n"
|
|
|
38 |
. " <Errors>" . htmlspecialchars( $arrStats['errs'], ENT_QUOTES ) . "</Errors>\n"
|
|
|
39 |
. " <Drops>" . htmlspecialchars( $arrStats['drop'], ENT_QUOTES ) . "</Drops>\n"
|
|
|
40 |
. " </NetDevice>\n";
|
|
|
41 |
}
|
|
|
42 |
$_text .= " </Network>\n";
|
|
|
43 |
|
|
|
44 |
return $_text;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
//
|
|
|
48 |
// html_network()
|
|
|
49 |
//
|
|
|
50 |
function html_network () {
|
|
|
51 |
global $XPath;
|
|
|
52 |
global $text;
|
|
|
53 |
|
|
|
54 |
$textdir = direction();
|
|
|
55 |
|
|
|
56 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
|
|
57 |
. " <tr>\n"
|
|
|
58 |
. " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['device'] . "</b></font></td>\n"
|
|
|
59 |
. " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['received'] . "</b></font></td>\n"
|
|
|
60 |
. " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['sent'] . "</b></font></td>\n"
|
|
|
61 |
. " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\"><b>" . $text['errors'] . "</b></font></td>\n"
|
|
|
62 |
. " </tr>\n";
|
|
|
63 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Network" ) ); $i < $max; $i++ ) {
|
|
|
64 |
if( $XPath->match( "/phpsysinfo/Network/NetDevice[" . $i . "]/Name" ) ) {
|
|
|
65 |
$_text .= " <tr>\n";
|
|
|
66 |
$_text .= " <td align=\"" . $textdir['left'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Name" ) . "</font></td>\n";
|
|
|
67 |
$_text .= " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/RxBytes" ) / 1024 ) . "</font></td>\n";
|
|
|
68 |
$_text .= " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/TxBytes" ) / 1024 ) . "</font></td>\n";
|
|
|
69 |
$_text .= " <td align=\"" . $textdir['right'] . "\" valign=\"top\"><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Errors" ) . '/' . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Drops" ) . "</font></td>\n";
|
|
|
70 |
$_text .= " </tr>\n";
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
$_text .= "</table>";
|
|
|
74 |
|
|
|
75 |
return $_text;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
function wml_network() {
|
|
|
79 |
global $XPath;
|
|
|
80 |
global $text;
|
|
|
81 |
|
|
|
82 |
$_text = "<card id=\"network\" title=\"" . $text['netusage'] . "\">\n";
|
|
|
83 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Network" ) ); $i < $max; $i++ ) {
|
|
|
84 |
if( $XPath->match( "/phpsysinfo/Network/NetDevice[" . $i . "]/Name" ) ) {
|
|
|
85 |
$_text .= "<p>" . $text['device'] . ": " . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Name" ) . "<br/>\n"
|
|
|
86 |
. "- U: " . format_bytesize( $XPath->getData("/phpsysinfo/Network/NetDevice[" . $i . "]/TxBytes" ) / 1024 ) . "<br/>\n"
|
|
|
87 |
. "- D: " . format_bytesize( $XPath->getData("/phpsysinfo/Network/NetDevice[" . $i . "]/RxBytes" ) / 1024 ) . "<br/>\n"
|
|
|
88 |
. "- E: " . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Errors" ) . '/' . $XPath->getData( "/phpsysinfo/Network/NetDevice[" . $i . "]/Drops" ) . "</p>\n";
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
$_text .= "</card>\n";
|
|
|
92 |
|
|
|
93 |
return $_text;
|
|
|
94 |
}
|
|
|
95 |
?>
|