function render_partition($disk, $partition)
{
    global $plugin;
    if (!isset($partition['device'])) {
        return '';
    }
    $out = array();
    $mounted = is_mounted($partition['device']);
    if (!$mounted && $partition['fstype'] != 'btrfs' || $mounted && $partition['fstype'] == 'btrfs') {
        $fscheck = "<a class='exec' onclick='openWindow_fsck(\"/plugins/{$plugin}/include/fsck.php?disk={$partition[device]}&fs={$partition[fstype]}&type=ro\",\"Check filesystem\",600,900);'><i class='glyphicon glyphicon-th-large partition'></i>{$partition[part]}</a>";
    } else {
        $fscheck = "<i class='glyphicon glyphicon-th-large partition'></i>{$partition[part]}";
    }
    $mpoint = "<div>{$fscheck}<i class='glyphicon glyphicon-arrow-right'></i>";
    $mbutton = "<span style='width:auto;text-align:right;'>";
    if ($mounted) {
        $mpoint .= "<a href='/Shares/Browse?dir={$partition[mountpoint]}' target='_blank'>{$partition[mountpoint]}</a></div>";
        $mbutton .= "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/unassigned_umount {$partition[device]}');\"><i class='glyphicon glyphicon-export'></i> Unmount</button>";
    } else {
        $mpoint .= "<form method='POST' action='/plugins/{$plugin}/UnassignedDevices.php?action=change_mountpoint&serial={$partition[serial]}&partition={$partition[part]}' target='progressFrame' style='display:inline;margin:0;padding:0;'><span class='text exec'><a>{$partition[mountpoint]}</a></span><input class='input' type='text' name='mountpoint' value='{$partition[mountpoint]}' hidden /></form></div>";
        $mbutton .= "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/unassigned_mount {$partition[device]}');\"><i class='glyphicon glyphicon-import'></i>  Mount</button>";
    }
    $out[] = "<tr class='{$outdd} toggle-parts toggle-" . basename($disk['device']) . "' style='__SHOW__' >";
    $out[] = "<td></td>";
    $out[] = "<td>{$mpoint}</td>";
    $out[] = "<td>{$mbutton}</td>";
    $out[] = "<td>-</td>";
    $out[] = "<td >" . $partition['fstype'] . "</td>";
    $out[] = "<td><span>" . my_scale($partition['size'], $unit) . " {$unit}</span></td>";
    $out[] = render_used_and_free($partition);
    $out[] = "<td>" . (strlen($partition['target']) ? shell_exec("lsof '{$partition[target]}' 2>/dev/null|grep -c -v COMMAND") : "-") . "</td>";
    $out[] = "<td>-</td>";
    $out[] = "<td><input type='checkbox' class='toggle_share' info='" . htmlentities(json_encode($partition)) . "' " . ($partition['shared'] ? 'checked' : '') . "></td>";
    $out[] = "<td><a href='/Main/EditScript?s=" . urlencode($partition['serial']) . "&l=" . urlencode(basename($partition['mountpoint'])) . "&p=" . urlencode($partition['part']) . "'><img src='/webGui/images/default.png' style='cursor:pointer;width:16px;" . (get_config($partition['serial'], "command.{$partition[part]}") ? "" : "opacity: 0.4;") . "'></a></td>";
    $out[] = "<tr>";
    return $out;
}
Пример #2
0
             $fscheck = sprintf(get_fsck_commands($partition['fstype'])['ro'], $partition['device']);
             $icon = "<i class='glyphicon glyphicon-th-large partition'></i>";
             $fscheck = !$mounted ? "<a class='exec' onclick='openWindow(\"{$fscheck}\",\"Check filesystem\",600,900);'>{$icon}{$partition[part]}</a>" : "{$icon}{$partition[part]}";
             echo "{$fscheck}<i class='glyphicon glyphicon-arrow-right'></i>";
             if ($mounted) {
                 echo $partition['mountpoint'];
             } else {
                 echo "<form method='POST' action='/plugins/{$plugin}/USBDevicesList.php?action=change_mountpoint&serial={$partition[serial]}&partition={$partition[part]}' target='progressFrame' style='display:inline;margin:0;padding:0;'>";
                 echo "<span class='text exec'><a>{$partition[mountpoint]}</a></span><input class='input' type='text' name='mountpoint' value='{$partition[mountpoint]}' hidden />";
                 echo "</form>";
             }
             echo "<td><span style='width:auto;text-align:right;'>" . ($mounted ? "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/usb_umount {$partition[device]}');\"><i class='glyphicon glyphicon-export'></i> Unmount</button>" : "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/usb_mount {$partition[device]}');\"><i class='glyphicon glyphicon-import'></i>  Mount</button>") . "</span></td>";
             echo "</div></td><td>-</td>";
             echo "<td >" . $partition['fstype'] . "</td>";
             echo "<td><span>" . my_scale($partition['size'], $unit) . " {$unit}</span></td>";
             render_used_and_free($partition);
             // $d1 = time();
             echo "<td>" . (strlen($partition['target']) ? shell_exec("lsof '{$partition[target]}' 2>/dev/null|grep -c -v COMMAND") : "-") . "</td><td>-</td>";
             // debug("openfiles [${partition[device]}]: ".(time() - $d1));
             echo "<td><a href='/Main/EditScript?s=" . urlencode($partition['serial']) . "&l=" . urlencode(basename($partition['mountpoint'])) . "&p=" . urlencode($partition['part']) . "'><img src='/webGui/images/default.png' style='cursor:pointer;width:16px;" . (get_config($partition['serial'], "command.{$partition[part]}") ? "" : "opacity: 0.4;") . "'></a></td>";
         }
         echo "</tr>";
         $odd = $odd == "odd" ? "even" : "odd";
     }
 } else {
     echo "<tr><td colspan='12' style='text-align:center;font-weight:bold;'>No usb disks present.</td></tr>";
 }
 echo "</tbody></table>";
 $config_file = $GLOBALS["paths"]["config_file"];
 $config = is_file($config_file) ? @parse_ini_file($config_file, true) : array();
 $disks_serials = array();
Пример #3
0
function array_online($disk) {
  global $display, $temps, $counts, $tot_size, $tot_used, $tot_free, $reads, $writes, $errors;
  if (is_numeric($disk['temp'])) {
    $temps += $disk['temp'];
    $counts++;
  }
  $reads += $disk['numReads'];
  $writes += $disk['numWrites'];
  $errors += $disk['numErrors'];
  if (isset($disk['fsFree']) && $disk['name']!='parity') {
    $disk['fsUsed'] = $disk['fsSize'] - $disk['fsFree'];
    $tot_size += $disk['fsSize'];
    $tot_free += $disk['fsFree'];
    $tot_used += $disk['fsUsed'];
  }
  echo "<tr>";
  switch ($disk['status']) {
  case "DISK_NP":
//  Suppress empty slots to keep device list short
//  this actually should be configurable
//  echo "<td>".device_info($disk)."</td>";
//  echo "<td colspan='9'>Not installed</td>";
//  echo "<td></td>";
    break;
  case "DISK_OK_NP":
    echo "<td>".device_info($disk)."</td>";
    echo "<td>Not Installed</td>";
    echo "<td colspan='4'></td>";
    render_used_and_free($disk);
    echo "<td>".device_browse($disk)."</td>";
    break;
  case "DISK_NP_DSBL":
    echo "<td>".device_info($disk)."</td>";
    if ($disk['name']=="parity") {
      echo "<td>Not installed</td>";
      echo "<td colspan='9'></td>";
    } else {
      echo "<td><em>Not installed</em></td>";
      echo "<td colspan='4'></td>";
      render_used_and_free($disk);
      echo "<td>".device_browse($disk)."</td>";
    }
    break;
  case "DISK_DSBL":
    echo "<td>".device_info($disk)."</td>";
    echo "<td>".device_desc($disk)."</td>";
    echo "<td>".my_temp($disk['temp'])."</td>";
    echo "<td>".my_number($disk['numReads'])."</td>";
    echo "<td>".my_number($disk['numWrites'])."</td>";
    echo "<td>".my_number($disk['numErrors'])."</td>";
    if ($disk['name']=="parity") {
      echo "<td colspan='5'></td>";
    } else {
      render_used_and_free($disk);
      echo "<td>".device_browse($disk)."</td>";
    }
    break;
  default:
    echo "<td>".device_info($disk)."</td>";
    echo "<td>".device_desc($disk)."</td>";
    echo "<td>".my_temp($disk['temp'])."</td>";
    echo "<td>".my_number($disk['numReads'])."</td>";
    echo "<td>".my_number($disk['numWrites'])."</td>";
    echo "<td>".my_number($disk['numErrors'])."</td>";
    render_used_and_free($disk);
    echo "<td>".device_browse($disk)."</td>";
    break;
  }
  echo "</tr>";
}
function render_partition($disk, $partition)
{
    global $plugin, $paths, $echo;
    if (!isset($partition['device'])) {
        return array();
    }
    $out = array();
    $mounted = is_mounted($partition['device']);
    if ($mounted && is_file(get_config($disk[serial], "command.{$partition[part]}"))) {
        $fscheck = "<a title='Execute Script as udev simulating a device being installed.' class='exec' onclick='openWindow_fsck(\"/plugins/{$plugin}/include/script.php?device={$partition[device]}&owner=udev\",\"Execute Script\",600,900);'><i class='glyphicon glyphicon-flash partition'></i>{$partition[part]}</a>";
    } elseif (!$mounted && $partition['fstype'] != 'btrfs') {
        $fscheck = "<a title='File System Check.' class='exec' onclick='openWindow_fsck(\"/plugins/{$plugin}/include/fsck.php?device={$partition[device]}&fs={$partition[fstype]}&type=ro\",\"Check filesystem\",600,900);'><i class='glyphicon glyphicon-th-large partition'></i>{$partition[part]}</a>";
    } else {
        $fscheck = "<i class='glyphicon glyphicon-th-large partition'></i>{$partition[part]}";
    }
    $rm_partition = get_config("Config", "destructive_mode") == "enabled" ? "<span title='Remove Partition.' class='exec' style='color:#CC0000;font-weight:bold;' onclick='rm_partition(this,\"{$disk[device]}\",\"{$partition[part]}\");'><i class='glyphicon glyphicon-remove hdd'></i></span>" : "";
    $mpoint = "<div>{$fscheck}<i class='glyphicon glyphicon-arrow-right'></i>";
    if ($mounted) {
        $mpoint .= "<a title='Browse Share.' href='/Shares/Browse?dir={$partition[mountpoint]}'>{$partition[mountpoint]}</a></div>";
    } else {
        $mount_point = basename($partition[mountpoint]);
        $mpoint .= "<form title='Click to Change Mount Point.' method='POST' action='/plugins/{$plugin}/UnassignedDevices.php?action=change_mountpoint&serial={$partition[serial]}&partition={$partition[part]}' target='progressFrame' style='display:inline;margin:0;padding:0;'><span class='text exec'><a>{$partition[mountpoint]}</a></span><input class='input' type='text' name='mountpoint' value='{$mount_point}' hidden /></form> {$rm_partition}</div>";
    }
    $mbutton = make_mount_button($partition);
    $out[] = "<tr class='{$outdd} toggle-parts toggle-" . basename($disk['device']) . "' style='__SHOW__' >";
    $out[] = "<td></td>";
    $out[] = "<td>{$mpoint}</td>";
    $out[] = "<td class='mount'>{$mbutton}</td>";
    $out[] = "<td>-</td>";
    $out[] = "<td >" . $partition['fstype'] . "</td>";
    $out[] = "<td><span>" . my_scale($partition['size'], $unit) . " {$unit}</span></td>";
    $out[] = "<td>" . (strlen($partition['target']) ? shell_exec("/usr/bin/lsof '{$partition[target]}' 2>/dev/null|grep -c -v COMMAND") : "-") . "</td>";
    $out[] = render_used_and_free($partition);
    $out[] = "<td title='Turn on to Mount Device when Array is Started.'><input type='checkbox' class='automount' serial='" . $disk['partitions'][0]['serial'] . "' " . ($disk['partitions'][0]['automount'] ? 'checked' : '') . "></td>";
    $out[] = "<td title='Turn on to Share Device with SMB and/or NFS.'><input type='checkbox' class='toggle_share' info='" . htmlentities(json_encode($partition)) . "' " . ($partition['shared'] ? 'checked' : '') . "></td>";
    $out[] = "<td><a title='View Log.' href='/Main/ViewLog?s=" . urlencode($partition['serial']) . "&l=" . urlencode(basename($partition['mountpoint'])) . "&p=" . urlencode($partition['part']) . "'><img src='/plugins/{$plugin}/icons/view_log.png' style='cursor:pointer;width:16px;'></a></td>";
    $out[] = "<td><a title='Edit Device Script.' href='/Main/EditScript?s=" . urlencode($partition['serial']) . "&l=" . urlencode(basename($partition['mountpoint'])) . "&p=" . urlencode($partition['part']) . "'><img src='/plugins/{$plugin}/icons/edit_script.png' style='cursor:pointer;width:16px;" . (get_config($partition['serial'], "command_bg.{$partition[part]}") == "true" ? "" : "opacity: 0.4;") . "'></a></td>";
    $out[] = "<tr>";
    return $out;
}