[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 // phpSysInfo - A PHP System Information Script 4 // http://phpsysinfo.sourceforge.net/ 5 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (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 Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 20 // $Id: hardware.php,v 1.31 2006/01/15 17:17:54 bigmichi1 Exp $ 21 22 function xml_hardware (&$hddtemp_devices) 23 { 24 global $sysinfo; 25 global $text; 26 $pci_devices = ""; $ide_devices = ""; $usb_devices = ""; $scsi_devices = ""; 27 28 $sys = $sysinfo->cpu_info(); 29 30 $ar_buf = finddups($sysinfo->pci()); 31 32 if (count($ar_buf)) { 33 for ($i = 0, $max = sizeof($ar_buf); $i < $max; $i++) { 34 if ($ar_buf[$i]) { 35 $pci_devices .= " <Device><Name>" . htmlspecialchars(chop($ar_buf[$i]), ENT_QUOTES) . "</Name></Device>\n"; 36 } 37 } 38 } 39 40 $ar_buf = $sysinfo->ide(); 41 42 ksort($ar_buf); 43 44 if (count($ar_buf)) { 45 while (list($key, $value) = each($ar_buf)) { 46 $ide_devices .= " <Device>\n<Name>" . htmlspecialchars($key . ': ' . $ar_buf[$key]['model'], ENT_QUOTES) . "</Name>\n"; 47 if (isset($ar_buf[$key]['capacity'])) { 48 $ide_devices .= '<Capacity>' . htmlspecialchars($ar_buf[$key]['capacity'], ENT_QUOTES) . '</Capacity>'; 49 } 50 $hddtemp_devices[] = $key; 51 $ide_devices .= "</Device>\n"; 52 } 53 } 54 55 $ar_buf = $sysinfo->scsi(); 56 ksort($ar_buf); 57 58 if (count($ar_buf)) { 59 while (list($key, $value) = each($ar_buf)) { 60 $scsi_devices .= "<Device>\n"; 61 if ($key >= '0' && $key <= '9') { 62 $scsi_devices .= " <Name>" . htmlspecialchars($ar_buf[$key]['model'], ENT_QUOTES) . "</Name>\n"; 63 } else { 64 $scsi_devices .= " <Name>" . htmlspecialchars($key . ': ' . $ar_buf[$key]['model'], ENT_QUOTES) . "</Name>\n"; 65 } 66 if (isset($ar_buf[$key]['capacity'])) { 67 $scsi_devices .= '<Capacity>' . htmlspecialchars($ar_buf[$key]['capacity'], ENT_QUOTES) . '</Capacity>'; 68 } 69 $scsi_devices .= "</Device>\n"; 70 } 71 } 72 73 $ar_buf = finddups( $sysinfo->usb() ); 74 75 if (count($ar_buf)) { 76 for ($i = 0, $max = sizeof($ar_buf); $i < $max; $i++) { 77 if ($ar_buf[$i]) { 78 $usb_devices .= " <Device><Name>" . htmlspecialchars(chop($ar_buf[$i]), ENT_QUOTES) . "</Name></Device>\n"; 79 } 80 } 81 } 82 83 /* disabled since we output this information 84 $ar_buf = $sysinfo->sbus(); 85 if (count($ar_buf)) { 86 for ($i = 0, $max = sizeof($ar_buf); $i < $max; $i++) { 87 if ($ar_buf[$i]) { 88 $sbus_devices .= " <Device>" . htmlspecialchars(chop($ar_buf[$i]), ENT_QUOTES) . "</Device>\n"; 89 } 90 } 91 } 92 */ 93 $_text = " <Hardware>\n"; 94 $_text .= " <CPU>\n"; 95 if (isset($sys['cpus'])) { 96 $_text .= " <Number>" . htmlspecialchars($sys['cpus'], ENT_QUOTES) . "</Number>\n"; 97 } 98 if (isset($sys['model'])) { 99 $_text .= " <Model>" . htmlspecialchars($sys['model'], ENT_QUOTES) . "</Model>\n"; 100 } 101 if (isset($sys['cpuspeed'])) { 102 $_text .= " <Cpuspeed>" . htmlspecialchars($sys['cpuspeed'], ENT_QUOTES) . "</Cpuspeed>\n"; 103 } 104 if (isset($sys['busspeed'])) { 105 $_text .= " <Busspeed>" . htmlspecialchars($sys['busspeed'], ENT_QUOTES) . "</Busspeed>\n"; 106 } 107 if (isset($sys['cache'])) { 108 $_text .= " <Cache>" . htmlspecialchars($sys['cache'], ENT_QUOTES) . "</Cache>\n"; 109 } 110 if (isset($sys['bogomips'])) { 111 $_text .= " <Bogomips>" . htmlspecialchars($sys['bogomips'], ENT_QUOTES) . "</Bogomips>\n"; 112 } 113 $_text .= " </CPU>\n"; 114 115 $_text .= " <PCI>\n"; 116 if ($pci_devices) { 117 $_text .= $pci_devices; 118 } 119 $_text .= " </PCI>\n"; 120 121 $_text .= " <IDE>\n"; 122 if ($ide_devices) { 123 $_text .= $ide_devices; 124 } 125 $_text .= " </IDE>\n"; 126 127 $_text .= " <SCSI>\n"; 128 if ($scsi_devices) { 129 $_text .= $scsi_devices; 130 } 131 $_text .= " </SCSI>\n"; 132 133 $_text .= " <USB>\n"; 134 if ($usb_devices) { 135 $_text .= $usb_devices; 136 } 137 $_text .= " </USB>\n"; 138 139 /* 140 $_text .= " <SBUS>\n"; 141 if ($sbus_devices) { 142 $_text .= $sbus_devices; 143 } 144 $_text .= " </SBUS>\n"; 145 */ 146 147 $_text .= " </Hardware>\n"; 148 149 return $_text; 150 } 151 152 function html_hardware () 153 { 154 global $XPath; 155 global $text; 156 $pci_devices = ""; $ide_devices = ""; $usb_devices = ""; $scsi_devices = ""; 157 $textdir = direction(); 158 159 for ($i = 1, $max = sizeof($XPath->getDataParts('/phpsysinfo/Hardware/PCI')); $i < $max; $i++) { 160 if ($XPath->match("/phpsysinfo/Hardware/PCI/Device[$i]/Name")) { 161 $pci_devices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/PCI/Device[$i]/Name") . "</font></td></tr>"; 162 } 163 } 164 165 for ($i = 1, $max = sizeof($XPath->getDataParts('/phpsysinfo/Hardware/IDE')); $i < $max; $i++) { 166 if ($XPath->match("/phpsysinfo/Hardware/IDE/Device[$i]")) { 167 $ide_devices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/IDE/Device[$i]/Name"); 168 if ($XPath->match("/phpsysinfo/Hardware/IDE/Device[$i]/Capacity")) { 169 $ide_devices .= " (" . $text['capacity'] . ": " . format_bytesize($XPath->getData("/phpsysinfo/Hardware/IDE/Device[$i]/Capacity") / 2) . ")"; 170 } 171 $ide_devices .= "</font></td></tr>"; 172 } 173 } 174 175 for ($i = 1, $max = sizeof($XPath->getDataParts('/phpsysinfo/Hardware/SCSI')); $i < $max; $i++) { 176 if ($XPath->match("/phpsysinfo/Hardware/SCSI/Device[$i]")) { 177 $scsi_devices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/SCSI/Device[$i]/Name"); 178 if ($XPath->match("/phpsysinfo/Hardware/SCSI/Device[$i]/Capacity")) { 179 $scsi_devices .= " (" . $text['capacity'] . ": " . format_bytesize($XPath->getData("/phpsysinfo/Hardware/SCSI/Device[$i]/Capacity") / 2) . ")"; 180 } 181 $scsi_devices .= "</font></td></tr>"; 182 } 183 } 184 185 for ($i = 1, $max = sizeof($XPath->getDataParts('/phpsysinfo/Hardware/USB')); $i < $max; $i++) { 186 if ($XPath->match("/phpsysinfo/Hardware/USB/Device[$i]/Name")) { 187 $usb_devices .= "<tr><td valign=\"top\"><font size=\"-1\">-</font></td><td><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/USB/Device[$i]/Name") . "</font></td></tr>"; 188 } 189 } 190 191 $_text = "<table cellspacing=0 cellpadding=5 border=\"0\" width=\"100%\" align=\"center\">\n"; 192 193 if ($XPath->match("/phpsysinfo/Hardware/CPU/Number")) { 194 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['numcpu'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/CPU/Number") . "</font></td>\n </tr>\n"; 195 } 196 if ($XPath->match("/phpsysinfo/Hardware/CPU/Model")) { 197 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['cpumodel'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/CPU/Model") . "</font></td>\n </tr>\n"; 198 } 199 200 if ($XPath->match("/phpsysinfo/Hardware/CPU/Cpuspeed")) { 201 $tmp_speed = $XPath->getData("/phpsysinfo/Hardware/CPU/Cpuspeed"); 202 if ($tmp_speed < 1000) { 203 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['cpuspeed'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $tmp_speed . " MHz</font></td>\n </tr>\n"; 204 } else { 205 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['cpuspeed'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . round($tmp_speed / 1000, 2) . " GHz</font></td>\n </tr>\n"; 206 } 207 } 208 if ($XPath->match("/phpsysinfo/Hardware/CPU/Busspeed")) { 209 $tmp_speed = $XPath->getData("/phpsysinfo/Hardware/CPU/Busspeed"); 210 if ($tmp_speed < 1000) { 211 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['busspeed'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $tmp_speed . " MHz</font></td>\n </tr>\n"; 212 } else { 213 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['busspeed'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . round($tmp_speed / 1000, 2) . " GHz</font></td>\n </tr>\n"; 214 } 215 } 216 if ($XPath->match("/phpsysinfo/Hardware/CPU/Cache")) { 217 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['cache'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/CPU/Cache") . "</font></td>\n </tr>\n"; 218 } 219 if ($XPath->match("/phpsysinfo/Hardware/CPU/Bogomips")) { 220 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['bogomips'] . "</font></td>\n <td class=\"cellText small\"><font size=\"-1\">" . $XPath->getData("/phpsysinfo/Hardware/CPU/Bogomips") . "</font></td>\n </tr>\n"; 221 } 222 223 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['pci'] . "</font></td>\n <td class=\"cellText small\">"; 224 if ($pci_devices) { 225 $_text .= "<table border=0 cellspacing=0 cellpadding=2>" . $pci_devices . "</table>"; 226 } else { 227 $_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>"; 228 } 229 $_text .= "</td>\n </tr>\n"; 230 231 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['ide'] . "</font></td>\n <td class=\"cellText small\">"; 232 if ($ide_devices) { 233 $_text .= "<table>" . $ide_devices . "</table>"; 234 } else { 235 $_text .= "<font size=\"-1\"><i>" . $text['none'] . "</i></font>"; 236 } 237 $_text .= "</td>\n </tr>\n"; 238 239 if ($scsi_devices) { 240 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['scsi'] . "</font></td>\n <td class=\"cellText small\"><table>" . $scsi_devices . "</table></td>\n </tr>"; 241 } 242 243 if ($usb_devices) { 244 $_text .= " <tr>\n <td class=\"cellLabel small\" align=right valign=\"top\"><font size=\"-1\">" . $text['usb'] . "</font></td>\n <td class=\"cellText small\"><table>" . $usb_devices . "</table></td>\n </tr>"; 245 } 246 247 $_text .= "</table>"; 248 249 return $_text; 250 } 251 252 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |