filesystems.php

来自「phpSysInfo v2.3 显示CPU、内存、硬盘、系统温度、风扇速度等系统」· PHP 代码 · 共 122 行

PHP
122
字号
<?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;}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?