function create_cmd_output(&$action, &$a_disk, &$disk, &$partition, &$umount) { $cmdout = CMDOUT_PARA; ob_end_flush(); $retvalue = <<<EOD {$cmdout} EOD; switch ($action) { case "fsck": /* Get the id of the disk. */ $id = array_search_ex($disk, $a_disk, "name"); /* Get the filesystem type of the disk. */ $type = $a_disk[$id]['fstype']; /* Check if disk is mounted. */ $ismounted = disks_check_mount_fullname($disk . $partition); /* Umount disk if necessary. */ if ($umount && $ismounted) { $diskinit_str = "<strong class='red'>" . gettext("Note") . ":</strong> " . gettext("The disk is currently mounted! The mount point will be removed temporary to perform selected command.") . "<br /><br />"; $retvalue .= <<<EOD <div id="ismounted_out" style="font-family: Courier, monospace; font-size: small;"> <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> </div> EOD; disks_umount_fullname($disk . $partition); } switch ($type) { case "": case "ufs": case "ufs_no_su": case "ufsgpt": case "ufsgpt_no_su": $button = create_toggle_button("Checking disk", "ufsgn_fsck_out"); $cmd = "/sbin/fsck_ufs -y -f " . escapeshellarg($disk . $partition); $out = create_cmdout_container("ufsgn_fsck_out", $cmd); $retvalue .= assemble_cmdout($button, $out); break; case "gmirror": case "gvinum": case "graid5": $diskinit_str = sprintf(gettext("Use <a href='%s'>RAID tools</a> for this disk!"), "disks_raid_{$type}_tools.php"); $retvalue .= <<<EOD <div id="graid5_out" style="display: none; font-family: Courier, monospace; font-size: small;"> <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> </div> EOD; break; case "msdos": $button = create_toggle_button("Checking disk", "dos_fsck_out"); $cmd = "/sbin/fsck_msdosfs -y -f " . escapeshellarg($disk . $partition); $out = create_cmdout_container("dos_fsck_out", $cmd); $retvalue .= assemble_cmdout($button, $out); break; } /* Mount disk if necessary. */ if ($umount && $ismounted) { disks_mount_fullname($disk . $partition); } break; } return $retvalue; }
$notinitmbr = $_POST['notinitmbr']; /* Check if disk is mounted. */ if (isAjax() && disks_check_mount_fullname($disk)) { $statustxt = sprintf(gettext("The disk is currently mounted! <a href=%s>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); $divcontents = "<div style='background:#990000'><table>"; $divcontents .= "<tr><td>"; $divcontents .= "<img src='/themes/{$g['theme']}/images/icons/icon_error.gif' width='28' height='32'>"; $divcontents .= "</td><td><font color='white'><br> The following errors have occured:<p><ul>"; $divcontents .= "<font color='white'><li> " . $statustxt . "</li>"; $divcontents .= "</ul></td></table></div><br />"; header("HTTP/1.0 500 Internal Server Error"); header("Status: 500 Internal Server Error. {$statustxt}"); echo $divcontents; exit; } else { if (disks_check_mount_fullname($disk)) { $errormsg = sprintf(gettext("The disk is currently mounted! <a href=%s>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); $do_format = false; } } if ($do_format) { /* Get the id of the disk array entry. */ $NotFound = 1; $id = array_search_ex($disk, $a_disk, "fullname"); if ($id) { /* Set new filesystem type. */ $a_disk[$id]['fstype'] = $type; $NotFound = 0; } else { $id = array_search_ex($disk, $a_gmirror, "fullname"); }