function parse_filesystems() { global $show_bind, $show_inodes; $j = 0; $df = execute_program('df', '-k' . $this->df_param); $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); if ($show_inodes) { $df2 = execute_program('df', '-i' . $this->df_param); $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY); } $mount = execute_program('mount'); $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); foreach ($df as $df_line) { $df_buf1 = preg_split("/(\\%\\s)/", $df_line, 2); if (count($df_buf1) != 2) { continue; } preg_match("/(.*)(\\s+)(([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)\$)/", $df_buf1[0], $df_buf2); $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]); if ($show_inodes) { preg_match_all("/([0-9]+)%/", $df2[$j + 1], $inode_buf, PREG_SET_ORDER); } if (count($df_buf) == 6) { if (hide_mount($df_buf[5])) { continue; } $df_buf[0] = trim(str_replace("\$", "\\\$", $df_buf[0])); $df_buf[5] = trim($df_buf[5]); $current = 0; foreach ($mount as $mount_line) { $current++; if (preg_match("#" . $df_buf[0] . " on " . $df_buf[5] . " type (.*) \\((.*)\\)#", $mount_line, $mount_buf)) { $mount_buf[1] .= "," . $mount_buf[2]; } elseif (!preg_match("#" . $df_buf[0] . "(.*) on " . $df_buf[5] . " \\((.*)\\)#", $mount_line, $mount_buf)) { continue; } if ($show_bind || !stristr($mount_buf[2], "bind")) { $results[$j] = array(); $results[$j]['disk'] = str_replace("\\\$", "\$", $df_buf[0]); $results[$j]['size'] = $df_buf[1]; $results[$j]['used'] = $df_buf[2]; $results[$j]['free'] = $df_buf[3]; $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']); $results[$j]['mount'] = $df_buf[5]; $results[$j]['fstype'] = substr($mount_buf[1], 0, strpos($mount_buf[1], ",")); $results[$j]['options'] = substr($mount_buf[1], strpos($mount_buf[1], ",") + 1, strlen($mount_buf[1])); if ($show_inodes && isset($inode_buf[count($inode_buf) - 1][1])) { $results[$j]['inodes'] = $inode_buf[count($inode_buf) - 1][1]; } $j++; unset($mount[$current - 1]); sort($mount); break; } } } } return $results; }
public function filesystems() { if (!execute_program('df', '-k', $df, $this->debug)) { $df = ''; } $mounts = split("\n", $df); if (!execute_program('df', '-n', $dftypes, $this->debug)) { $dftypes = ''; } $mounttypes = split("\n", $dftypes); for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { $ar_buf = preg_split('/\\s+/', $mounts[$i], 6); $ty_buf = split(':', $mounttypes[$i - 1], 2); if (hide_mount($ar_buf[5])) { continue; } $results[$j] = array(); $results[$j]['disk'] = $ar_buf[0]; $results[$j]['size'] = $ar_buf[1]; $results[$j]['used'] = $ar_buf[2]; $results[$j]['free'] = $ar_buf[3]; $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']); $results[$j]['mount'] = $ar_buf[5]; $results[$j]['fstype'] = $ty_buf[1]; $j++; } return $results; }
public function filesystems() { $typearray = array("Unknown", "No Root Directory", "Removable Disk", "Local Disk", "Network Drive", "Compact Disc", "RAM Disk"); $floppyarray = array("Unknown", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", "3 1/2 in.", "3 1/2 in.", "5 1/4 in.", "5 1/4 in.", "5 1/4 in.", "5 1/4 in.", "5 1/4 in.", "Other", "HD", "3 1/2 in.", "3 1/2 in.", "5 1/4 in.", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", "8 in."); $buffer = $this->GetWMI("Win32_LogicalDisk", array("Name", "Size", "FreeSpace", "FileSystem", "DriveType", "MediaType")); $k = 0; foreach ($buffer as $filesystem) { if (hide_mount($filesystem["Name"])) { continue; } $results[$k]['mount'] = $filesystem["Name"]; $results[$k]['size'] = $filesystem["Size"] / 1024; $results[$k]['used'] = ($filesystem["Size"] - $filesystem["FreeSpace"]) / 1024; $results[$k]['free'] = $filesystem["FreeSpace"] / 1024; @($results[$k]['percent'] = ceil($results[$k]['used'] / $results[$k]['size'] * 100)); // silence this line, nobody is having a floppy in the drive everytime $results[$k]['fstype'] = $filesystem["FileSystem"]; $results[$k]['disk'] = $typearray[$filesystem["DriveType"]]; if ($filesystem["MediaType"] != "" && $filesystem["DriveType"] == 2) { $results[$k]['disk'] .= " (" . $floppyarray[$filesystem["MediaType"]] . ")"; } $k += 1; } return $results; }
function filesystems () { $df = execute_program('df', '-k'); $mounts = preg_split("/\n/", $df); $dftypes = execute_program('df', '-n'); $mounttypes = preg_split("/\n/", $dftypes); for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { $ar_buf = preg_split('/\s+/', $mounts[$i], 6); $ty_buf = preg_split('/:/', $mounttypes[$i-1], 2); if (hide_mount($ar_buf[5])) { continue; } $results[$j] = array(); $results[$j]['disk'] = $ar_buf[0]; $results[$j]['size'] = $ar_buf[1]; $results[$j]['used'] = $ar_buf[2]; $results[$j]['free'] = $ar_buf[3]; $results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']); $results[$j]['mount'] = $ar_buf[5]; $results[$j]['fstype'] = $ty_buf[1]; $j++; } return $results; }
function filesystems () { $df = execute_program('df', '-kP'); $mounts = preg_split("/\n/", $df); $fstype = array(); $s = execute_program('mount', '-v'); $lines = explode("\n", $s); $i = 0; while (list(, $line) = each($lines)) { $a = preg_split('/ /', $line); $fsdev[$a[0]] = $a[4]; } for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { $ar_buf = preg_split("/\s+/", $mounts[$i], 6); if (hide_mount($ar_buf[5])) { continue; } $results[$j] = array(); $results[$j]['disk'] = $ar_buf[0]; $results[$j]['size'] = $ar_buf[1]; $results[$j]['used'] = $ar_buf[2]; $results[$j]['free'] = $ar_buf[3]; $results[$j]['percent'] = $ar_buf[4]; $results[$j]['mount'] = $ar_buf[5]; ($fstype[$ar_buf[5]]) ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : $results[$j]['fstype'] = $fsdev[$ar_buf[0]]; $j++; } return $results; }
function filesystems() { global $show_bind; $fstype = array(); $fsoptions = array(); $df = execute_program('df', '-kP'); $mounts = split("\n", $df); $buffer = execute_program("mount"); $buffer = explode("\n", $buffer); $j = 0; foreach ($buffer as $line) { preg_match("/(.*) on (.*) type (.*) \\((.*)\\)/", $line, $result); if (count($result) == 5) { $dev = $result[1]; $mpoint = $result[2]; $type = $result[3]; $options = $result[4]; $fstype[$mpoint] = $type; $fsdev[$dev] = $type; $fsoptions[$mpoint] = $options; foreach ($mounts as $line2) { if (preg_match("#^" . str_replace("\$", "\\\$", $result[1]) . "#", $line2)) { $line2 = preg_replace("#^" . str_replace("\$", "\\\$", $result[1]) . "#", "", $line2); $ar_buf = preg_split("/(\\s+)/", $line2, 6); $ar_buf[0] = $result[1]; if (hide_mount($ar_buf[5]) || $ar_buf[0] == "") { continue; } if ($show_bind || !stristr($fsoptions[$ar_buf[5]], "bind")) { $results[$j] = array(); $results[$j]['disk'] = $ar_buf[0]; $results[$j]['size'] = $ar_buf[1]; $results[$j]['used'] = $ar_buf[2]; $results[$j]['free'] = $ar_buf[3]; $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']); $results[$j]['mount'] = $ar_buf[5]; $fstype[$ar_buf[5]] ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : ($results[$j]['fstype'] = $fsdev[$ar_buf[0]]); $results[$j]['options'] = $fsoptions[$ar_buf[5]]; $j++; } } } } } return $results; }
public function parse_filesystems() { $results = array(); $j = 0; if (execute_program('df', '-k' . $this->df_param, $df, $this->debug) || !empty($df)) { $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); natsort($df); if (showInodes) { if (execute_program('df', '-i' . $this->df_param, $df2, $this->debug) || !empty($df)) { $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY); // Store inode use% in an associative array (df_inodes) for later use foreach ($df2 as $df2_line) { if (preg_match("/^(\\S+).*\\s([0-9]+)%/", $df2_line, $inode_buf)) { $df_inodes[$inode_buf[1]] = $inode_buf[2]; } } unset($df2, $df2_line, $inode_buf); } } if (execute_program('mount', '', $mount, $this->debug)) { $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); foreach ($mount as $mount_line) { if (preg_match("/\\S+ on (\\S+) type (.*) \\((.*)\\)/", $mount_line, $mount_buf)) { $mount_parm[$mount_buf[1]]['fstype'] = $mount_buf[2]; $mount_parm[$mount_buf[1]]['options'] = $mount_buf[3]; } elseif (preg_match("/\\S+ (.*) on (\\S+) \\((.*)\\)/", $mount_line, $mount_buf)) { $mount_parm[$mount_buf[2]]['fstype'] = $mount_buf[1]; $mount_parm[$mount_buf[2]]['options'] = $mount_buf[3]; } elseif (preg_match("/\\S+ on (\\S+) \\((\\S+)(,\\s(.*))?\\)/", $mount_line, $mount_buf)) { $mount_parm[$mount_buf[1]]['fstype'] = $mount_buf[2]; $mount_parm[$mount_buf[1]]['options'] = isset($mount_buf[4]) ? $mount_buf[4] : ''; } } unset($mount, $mount_line, $mount_buf); foreach ($df as $df_line) { $df_buf1 = preg_split("/(\\%\\s)/", $df_line, 2); if (count($df_buf1) != 2) { continue; } preg_match("/(.*)(\\s+)(([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)\$)/", $df_buf1[0], $df_buf2); $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]); if (count($df_buf) == 6) { $df_buf[5] = trim($df_buf[5]); if (hide_mount($df_buf[5])) { continue; } $df_buf[0] = trim(str_replace("\$", "\\\$", $df_buf[0])); if (hide_fstype($mount_parm[$df_buf[5]]['fstype'])) { continue; } if (!showBind && stristr($mount_parm[$df_buf[5]]['options'], "bind")) { continue; } $results[$j] = array(); $results[$j]['disk'] = str_replace("\\\$", "\$", $df_buf[0]); $results[$j]['size'] = $df_buf[1]; $results[$j]['used'] = $df_buf[2]; $results[$j]['free'] = $df_buf[3]; if ($results[$j]['used'] < 0) { $results[$j]['size'] = $results[$j]['free']; $results[$j]['free'] = 0; $results[$j]['used'] = $results[$j]['size']; } if ($results[$j]['size'] == 0) { continue; } $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']); $results[$j]['mount'] = $df_buf[5]; $results[$j]['fstype'] = $mount_parm[$df_buf[5]]['fstype']; $results[$j]['options'] = $mount_parm[$df_buf[5]]['options']; if (showInodes && isset($df_inodes[$results[$j]['disk']])) { $results[$j]['inodes'] = $df_inodes[$results[$j]['disk']]; } $j++; } } return $results; } else { return array(); } } else { return array(); } }
function filesystems() { $df = execute_program('df', '-k'); $mounts = split("\n", $df); $fstype = array(); $s = execute_program('mount'); $lines = explode("\n", $s); $i = 0; while (list(, $line) = each($lines)) { ereg('(.*) \\((.*)\\)', $line, $a); $m = explode(' ', $a[0]); $fsdev[$m[0]] = $a[2]; } for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { $ar_buf = preg_split("/\\s+/", $mounts[$i], 6); switch ($ar_buf[0]) { case 'automount': // skip the automount entries // skip the automount entries case 'devfs': // skip the dev filesystem // skip the dev filesystem case 'fdesc': // skip the fdesc // skip the fdesc case 'procfs': // skip the proc filesystem // skip the proc filesystem case '<volfs>': // skip the vol filesystem continue 2; break; } if (hide_mount($ar_buf[5])) { continue; } $results[$j] = array(); $results[$j]['disk'] = $ar_buf[0]; $results[$j]['size'] = $ar_buf[1]; $results[$j]['used'] = $ar_buf[2]; $results[$j]['free'] = $ar_buf[3]; $results[$j]['percent'] = $ar_buf[4]; $results[$j]['mount'] = $ar_buf[5]; $fstype[$ar_buf[5]] ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : ($results[$j]['fstype'] = $fsdev[$ar_buf[0]]); $j++; } return $results; }