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: hardware.php,v 1.36 2007/01/21 11:13:51 bigmichi1 Exp $
|
|
|
23 |
|
|
|
24 |
function xml_hardware() {
|
|
|
25 |
global $sysinfo;
|
|
|
26 |
global $text;
|
|
|
27 |
|
|
|
28 |
$strPcidevices = ""; $strIdedevices = ""; $strUsbdevices = ""; $strScsidevices = "";
|
|
|
29 |
|
|
|
30 |
$arrSys = $sysinfo->cpu_info();
|
|
|
31 |
|
|
|
32 |
$arrBuf = finddups( $sysinfo->pci() );
|
|
|
33 |
if( count( $arrBuf ) ) {
|
|
|
34 |
for( $i = 0, $max = sizeof($arrBuf); $i < $max; $i++ ) {
|
|
|
35 |
if( $arrBuf[$i] ) {
|
|
|
36 |
$strPcidevices .= " <Device><Name>" . htmlspecialchars( chop( $arrBuf[$i] ), ENT_QUOTES ) . "</Name></Device>\n";
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
$arrBuf = $sysinfo->ide();
|
|
|
42 |
if( count( $arrBuf ) ) {
|
|
|
43 |
foreach( $arrBuf as $strKey => $arrValue ) {
|
|
|
44 |
$strIdedevices .= " <Device>\n<Name>" . htmlspecialchars( $strKey . ': ' . $arrValue['model'], ENT_QUOTES ) . "</Name>\n";
|
|
|
45 |
if( isset( $arrValue['capacity'] ) ) {
|
|
|
46 |
$strIdedevices .= '<Capacity>' . htmlspecialchars( $arrValue['capacity'], ENT_QUOTES ) . '</Capacity>';
|
|
|
47 |
}
|
|
|
48 |
$strIdedevices .= "</Device>\n";
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
$arrBuf = $sysinfo->scsi();
|
|
|
53 |
if( count( $arrBuf ) ) {
|
|
|
54 |
foreach( $arrBuf as $strKey => $arrValue ) {
|
|
|
55 |
$strScsidevices .= "<Device>\n";
|
|
|
56 |
if( $strKey >= '0' && $strKey <= '9' ) {
|
|
|
57 |
$strScsidevices .= " <Name>" . htmlspecialchars( $arrValue['model'], ENT_QUOTES ) . "</Name>\n";
|
|
|
58 |
} else {
|
|
|
59 |
$strScsidevices .= " <Name>" . htmlspecialchars( $strKey . ': ' . $arrValue['model'], ENT_QUOTES ) . "</Name>\n";
|
|
|
60 |
}
|
|
|
61 |
if( isset( $arrrValue['capacity'])) {
|
|
|
62 |
$strScsidevices .= '<Capacity>' . htmlspecialchars( $arrValue['capacity'], ENT_QUOTES ) . '</Capacity>';
|
|
|
63 |
}
|
|
|
64 |
$strScsidevices .= "</Device>\n";
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
$arrBuf = finddups( $sysinfo->usb() );
|
|
|
69 |
if( count( $arrBuf ) ) {
|
|
|
70 |
for( $i = 0, $max = sizeof( $arrBuf ); $i < $max; $i++ ) {
|
|
|
71 |
if( $arrBuf[$i] ) {
|
|
|
72 |
$strUsbdevices .= " <Device><Name>" . htmlspecialchars( chop( $arrBuf[$i] ), ENT_QUOTES ) . "</Name></Device>\n";
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
$_text = " <Hardware>\n";
|
|
|
78 |
$_text .= " <CPU>\n";
|
|
|
79 |
if( isset( $arrSys['cpus'] ) ) {
|
|
|
80 |
$_text .= " <Number>" . htmlspecialchars( $arrSys['cpus'], ENT_QUOTES ) . "</Number>\n";
|
|
|
81 |
}
|
|
|
82 |
if( isset( $arrSys['model'] ) ) {
|
|
|
83 |
$_text .= " <Model>" . htmlspecialchars( $arrSys['model'], ENT_QUOTES ) . "</Model>\n";
|
|
|
84 |
}
|
|
|
85 |
if( isset( $arrSys['temp'] ) ) {
|
|
|
86 |
$_text .= " <Cputemp>" . htmlspecialchars( $arrSys['temp'], ENT_QUOTES ) . "</Cputemp>\n";
|
|
|
87 |
}
|
|
|
88 |
if( isset( $arrSys['cpuspeed'] ) ) {
|
|
|
89 |
$_text .= " <Cpuspeed>" . htmlspecialchars( $arrSys['cpuspeed'], ENT_QUOTES ) . "</Cpuspeed>\n";
|
|
|
90 |
}
|
|
|
91 |
if( isset( $arrSys['busspeed'] ) ) {
|
|
|
92 |
$_text .= " <Busspeed>" . htmlspecialchars( $arrSys['busspeed'], ENT_QUOTES ) . "</Busspeed>\n";
|
|
|
93 |
}
|
|
|
94 |
if( isset( $arrSys['cache'] ) ) {
|
|
|
95 |
$_text .= " <Cache>" . htmlspecialchars( $arrSys['cache'], ENT_QUOTES ) . "</Cache>\n";
|
|
|
96 |
}
|
|
|
97 |
if( isset( $arrSys['bogomips'] ) ) {
|
|
|
98 |
$_text .= " <Bogomips>" . htmlspecialchars( $arrSys['bogomips'], ENT_QUOTES ) . "</Bogomips>\n";
|
|
|
99 |
}
|
|
|
100 |
$_text .= " </CPU>\n";
|
|
|
101 |
$_text .= " <PCI>\n";
|
|
|
102 |
if( $strPcidevices) {
|
|
|
103 |
$_text .= $strPcidevices;
|
|
|
104 |
}
|
|
|
105 |
$_text .= " </PCI>\n";
|
|
|
106 |
$_text .= " <IDE>\n";
|
|
|
107 |
if( $strIdedevices) {
|
|
|
108 |
$_text .= $strIdedevices;
|
|
|
109 |
}
|
|
|
110 |
$_text .= " </IDE>\n";
|
|
|
111 |
$_text .= " <SCSI>\n";
|
|
|
112 |
if( $strScsidevices) {
|
|
|
113 |
$_text .= $strScsidevices;
|
|
|
114 |
}
|
|
|
115 |
$_text .= " </SCSI>\n";
|
|
|
116 |
$_text .= " <USB>\n";
|
|
|
117 |
if($strUsbdevices) {
|
|
|
118 |
$_text .= $strUsbdevices;
|
|
|
119 |
}
|
|
|
120 |
$_text .= " </USB>\n";
|
|
|
121 |
$_text .= " </Hardware>\n";
|
|
|
122 |
|
|
|
123 |
return $_text;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
function html_hardware () {
|
|
|
127 |
global $XPath;
|
|
|
128 |
global $text;
|
|
|
129 |
|
|
|
130 |
$strPcidevices = ""; $strIdedevices = ""; $strUsbdevices = ""; $strScsidevices = "";
|
|
|
131 |
|
|
|
132 |
$textdir = direction();
|
|
|
133 |
|
|
|
134 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Hardware/PCI" ) ); $i < $max; $i++ ) {
|
|
|
135 |
if( $XPath->match( "/phpsysinfo/Hardware/PCI/Device[" . $i . "]/Name" ) ) {
|
|
|
136 |
$strPcidevices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/PCI/Device[" . $i . "]/Name" ) . "</font></td></tr>";
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Hardware/IDE" ) ); $i < $max; $i++ ) {
|
|
|
141 |
if( $XPath->match( "/phpsysinfo/Hardware/IDE/Device[" . $i . "]" ) ) {
|
|
|
142 |
$strIdedevices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/IDE/Device[" . $i . "]/Name" );
|
|
|
143 |
if( $XPath->match( "/phpsysinfo/Hardware/IDE/Device[" . $i . "]/Capacity" ) ) {
|
|
|
144 |
$strIdedevices .= " (" . $text['capacity'] . ": " . format_bytesize( $XPath->getData( "/phpsysinfo/Hardware/IDE/Device[" . $i . "]/Capacity" ) / 2 ) . ")";
|
|
|
145 |
}
|
|
|
146 |
$strIdedevices .= "</font></td></tr>";
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Hardware/SCSI" ) ); $i < $max; $i++ ) {
|
|
|
151 |
if( $XPath->match( "/phpsysinfo/Hardware/SCSI/Device[" . $i . "]" ) ) {
|
|
|
152 |
$strScsidevices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/SCSI/Device[" . $i . "]/Name" );
|
|
|
153 |
if( $XPath->match( "/phpsysinfo/Hardware/SCSI/Device[" . $i . "]/Capacity" ) ) {
|
|
|
154 |
$strScsidevices .= " (" . $text['capacity'] . ": " . format_bytesize( $XPath->getData( "/phpsysinfo/Hardware/SCSI/Device[" . $i . "]/Capacity" ) / 2 ) . ")";
|
|
|
155 |
}
|
|
|
156 |
$strScsidevices .= "</font></td></tr>";
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
for( $i = 1, $max = sizeof( $XPath->getDataParts( "/phpsysinfo/Hardware/USB" ) ); $i < $max; $i++ ) {
|
|
|
161 |
if( $XPath->match( "/phpsysinfo/Hardware/USB/Device[" . $i . "]/Name" )) {
|
|
|
162 |
$strUsbdevices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/USB/Device[" . $i . "]/Name" ) . "</font></td></tr>";
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n";
|
|
|
167 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Number" ) ) {
|
|
|
168 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['numcpu'] . "</font></td>\n <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/CPU/Number" ) . "</font></td>\n </tr>\n";
|
|
|
169 |
}
|
|
|
170 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Model" ) ) {
|
|
|
171 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['cpumodel'] . "</font></td>\n <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/CPU/Model" );
|
|
|
172 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Cputemp" ) ) {
|
|
|
173 |
$_text .= " @ " . temperature( $XPath->getData( "/phpsysinfo/Hardware/CPU/Cputemp" ) );
|
|
|
174 |
}
|
|
|
175 |
$_text .= "</font></td>\n </tr>\n";
|
|
|
176 |
}
|
|
|
177 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Cpuspeed" ) ) {
|
|
|
178 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['cpuspeed'] . "</font></td>\n <td><font size=\"-1\">" . format_speed( $XPath->getData( "/phpsysinfo/Hardware/CPU/Cpuspeed" ) ) . "</font></td>\n </tr>\n";
|
|
|
179 |
}
|
|
|
180 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Busspeed" ) ) {
|
|
|
181 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['busspeed'] . "</font></td>\n <td><font size=\"-1\">" . format_speed( $XPath->getData( "/phpsysinfo/Hardware/CPU/Busspeed" ) ) . "</font></td>\n </tr>\n";
|
|
|
182 |
}
|
|
|
183 |
if( $XPath->match("/phpsysinfo/Hardware/CPU/Cache" ) ) {
|
|
|
184 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['cache'] . "</font></td>\n <td><font size=\"-1\">" . format_bytesize( $XPath->getData( "/phpsysinfo/Hardware/CPU/Cache" ) ) . "</font></td>\n </tr>\n";
|
|
|
185 |
}
|
|
|
186 |
if( $XPath->match( "/phpsysinfo/Hardware/CPU/Bogomips" ) ) {
|
|
|
187 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['bogomips'] . "</font></td>\n <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Hardware/CPU/Bogomips" ) . "</font></td>\n </tr>\n";
|
|
|
188 |
}
|
|
|
189 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['pci'] . "</font></td>\n <td>";
|
|
|
190 |
|
|
|
191 |
if( $strPcidevices) {
|
|
|
192 |
$_text .= "<table>" . $strPcidevices . "</table>";
|
|
|
193 |
} else {
|
|
|
194 |
$_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>";
|
|
|
195 |
}
|
|
|
196 |
$_text .= "</td>\n </tr>\n";
|
|
|
197 |
|
|
|
198 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['ide'] . "</font></td>\n <td>";
|
|
|
199 |
if( $strIdedevices ) {
|
|
|
200 |
$_text .= "<table>" . $strIdedevices . "</table>";
|
|
|
201 |
} else {
|
|
|
202 |
$_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>";
|
|
|
203 |
}
|
|
|
204 |
$_text .= "</td>\n </tr>\n";
|
|
|
205 |
|
|
|
206 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['scsi'] . "</font></td>\n <td>";
|
|
|
207 |
if( $strScsidevices ) {
|
|
|
208 |
$_text .= "<table>" . $strScsidevices . "</table></td>\n </tr>";
|
|
|
209 |
} else {
|
|
|
210 |
$_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>";
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
$_text .= " <tr>\n <td valign=\"top\"><font size=\"-1\">" . $text['usb'] . "</font></td>\n <td>";
|
|
|
214 |
if( $strUsbdevices) {
|
|
|
215 |
$_text .= "<table>" . $strUsbdevices . "</table></td>\n </tr>";
|
|
|
216 |
} else {
|
|
|
217 |
$_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>";
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
$_text .= "</table>";
|
|
|
221 |
|
|
|
222 |
return $_text;
|
|
|
223 |
}
|
|
|
224 |
?>
|