POSSIBILITY OF SUCH DAMAGE.
*/
require "auth.inc";
require "guiconfig.inc";
$id = $_GET['id'];
if (isset($_POST['id'])) {
    $id = $_POST['id'];
}
$pgtitle = array(gettext("Disks"), gettext("Software RAID"), gettext("RAID1"), isset($id) ? gettext("Edit") : gettext("Add"));
if (!is_array($config['gmirror']['vdisk'])) {
    $config['gmirror']['vdisk'] = array();
}
array_sort_key($config['gmirror']['vdisk'], "name");
$a_raid =& $config['gmirror']['vdisk'];
$all_raid = get_conf_sraid_disks_list();
$a_disk = get_conf_disks_filtered_ex("fstype", "softraid");
if (!sizeof($a_disk)) {
    $nodisk_errors[] = gettext("You must add disks first.");
}
if (isset($id) && $a_raid[$id]) {
    $pconfig['uuid'] = $a_raid[$id]['uuid'];
    $pconfig['name'] = $a_raid[$id]['name'];
    $pconfig['devicespecialfile'] = $a_raid[$id]['devicespecialfile'];
    $pconfig['type'] = $a_raid[$id]['type'];
    $pconfig['balance'] = $a_raid[$id]['balance'];
    $pconfig['device'] = $a_raid[$id]['device'];
}
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    if ($_POST['Cancel']) {
*/
require "auth.inc";
require "guiconfig.inc";
if (isset($_GET['uuid'])) {
    $uuid = $_GET['uuid'];
}
if (isset($_POST['uuid'])) {
    $uuid = $_POST['uuid'];
}
$pgtitle = array(gettext("Disks"), gettext("ZFS"), gettext("Pools"), gettext("Virtual device"), isset($uuid) ? gettext("Edit") : gettext("Add"));
if (!isset($config['zfs']['vdevices']['vdevice']) || !is_array($config['zfs']['vdevices']['vdevice'])) {
    $config['zfs']['vdevices']['vdevice'] = array();
}
array_sort_key($config['zfs']['vdevices']['vdevice'], "name");
$a_vdevice =& $config['zfs']['vdevices']['vdevice'];
$a_disk = array_merge(get_conf_disks_filtered_ex("fstype", "zfs"), get_hast_disks_list());
function strip_dev($device)
{
    if (preg_match("/^\\/dev\\/(.+)\$/", $device, $m)) {
        $device = $m[1];
    }
    return $device;
}
function strip_partition($device)
{
    if (preg_match("/^(.*)p\\d+\$/", $device, $m)) {
        $device = $m[1];
    }
    return $device;
}
function strip_exists($device, &$a_vdevice)
			</ul>
		</td>
	</tr>
  <tr>
    <td class="tabcont">
    	<table width="100%" border="0">
  			<?php 
foreach (explode(" ", "concat mirror raid5 stripe vinum") as $class) {
    ?>
  			<?php 
    html_titleline("GEOM {$class}");
    ?>
				<tr>
			    <td>
			    	<pre><?php 
    if (0 >= count(get_conf_disks_filtered_ex("class", "g{$class}"))) {
        echo gettext("n/a");
    } else {
        unset($rawdata);
        disks_geom_cmd($class, "list", "", true, false, $rawdata);
        echo htmlspecialchars(implode("\n", $rawdata));
    }
    ?>
</pre>
			    </td>
			  </tr>
    		<?php 
}
?>
    	</table>
    </td>
	var pool = document.iform.pool.value;
	switch (pool) {
		<?php 
foreach ($a_pool as $pool) {
    ?>
		case "<?php 
    echo $pool['name'];
    ?>
": {
			<?php 
    $result = array();
    foreach ($pool['vdevice'] as $vdevicev) {
        $index = array_search_ex($vdevicev, $a_vdevice, "name");
        $vdevice = $a_vdevice[$index];
        foreach ($vdevice['device'] as $devicev) {
            $a_disk = get_conf_disks_filtered_ex("fstype", "zfs");
            $index = array_search_ex($devicev, $a_disk, "devicespecialfile");
            $result[] = $a_disk[$index];
        }
    }
    $i = 0;
    array_sort_key($result, "name");
    foreach ($result as $disk) {
        $checked = "";
        if (is_array($pconfig['device'])) {
            foreach ($pconfig['device'] as $devicev) {
                if ($devicev === $disk['name']) {
                    $checked = " checked=\"checked\"";
                    break;
                }
            }
function zfs_zpool_get_status()
{
    global $config;
    array_sort_key($config['zfs']['pools']['pool'], "name");
    array_sort_key($config['zfs']['vdevices']['vdevice'], "name");
    $a_pool = $config['zfs']['pools']['pool'];
    $a_vdevice = $config['zfs']['vdevices']['vdevice'];
    // Get zpool status informations
    $cmd = "zpool status -v";
    if (isset($_GET['pool'])) {
        $cmd .= " {$_GET['pool']}";
    }
    mwexec2($cmd, $rawdata);
    // Modify and render status informations
    $result = "";
    foreach ($rawdata as $line) {
        if (preg_match("/(\\s+)(?:pool\\:)(\\s+)(.*)/", $line, $match)) {
            $pool = trim($match[3]);
            $index = array_search_ex($pool, $a_pool, "name");
            if (0 && $index !== false) {
                $href = "<a href='disks_zfs_zpool_edit.php?uuid={$a_pool[$index]['uuid']}'>{$pool}</a>";
                $result .= "{$match[1]}pool:{$match[2]}{$href}";
            } else {
                $result .= htmlspecialchars($line);
            }
        } else {
            if (preg_match("/(\\s+)(?:scrub\\:)(\\s+)(.*)/", $line, $match)) {
                if (0 && isset($pool)) {
                    $href = "<a href='disks_zfs_zpool_tools.php?action=scrub&option=s&pool={$pool}' title=\"" . sprintf(gettext("Start scrub on '%s'."), $pool) . "\">scrub</a>:";
                } else {
                    $href = "scrub";
                }
                $result .= "{$match[1]}{$href}{$match[2]}{$match[3]}";
            } else {
                if (0 && isset($pool)) {
                    $a_disk = get_conf_disks_filtered_ex("fstype", "zfs");
                    $found = false;
                    if (count($a_disk) > 0 && false !== ($index = array_search_ex($pool, $a_pool, "name"))) {
                        $pool_conf = $a_pool[$index];
                        if (is_array($pool_conf['vdevice'])) {
                            foreach ($pool_conf['vdevice'] as $vdevicev) {
                                if (false !== ($index = array_search_ex($vdevicev, $a_vdevice, "name"))) {
                                    $vdevice = $a_vdevice[$index];
                                    if (is_array($vdevice['device'])) {
                                        foreach ($vdevice['device'] as $devicev) {
                                            $index = array_search_ex($devicev, $a_disk, "devicespecialfile");
                                            if ($index === false) {
                                                continue 2;
                                            }
                                            $disk = $a_disk[$index];
                                            $string = "/(\\s+)(?:" . $disk['name'] . ")(\\s+)(\\w+)(.*)/";
                                            if (preg_match($string, $line, $match)) {
                                                $href = "<a href='disks_zfs_zpool_tools.php'>{$disk['name']}</a>";
                                                if (0 && $match[3] == "ONLINE") {
                                                    $href1 = "<a href='disks_zfs_zpool_tools.php?action=offline&option=d&pool={$pool}&device={$disk[name]}'>{$match[3]}</a>";
                                                } else {
                                                    if (0 && $match[3] == "OFFLINE") {
                                                        $href1 = "<a href='disks_zfs_zpool_tools.php?action=online&option=d&pool={$pool}&device={$disk[name]}'>{$match[3]}</a>";
                                                    } else {
                                                        $href1 = "";
                                                    }
                                                }
                                                $result .= "{$match[1]}{$href}{$match[2]}{$href1}{$match[4]}";
                                                $found = true;
                                                continue 2;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!$found) {
                        $result .= htmlspecialchars($line);
                    }
                } else {
                    $result .= htmlspecialchars($line);
                }
            }
        }
        $result .= "<br />";
    }
    return $result;
}