function render_used_and_free($partition) { global $display; if (strlen($partition['target'])) { if (!$display['text']) { echo "<td>" . my_scale($partition['used'], $unit) . " {$unit}</td>"; echo "<td>" . my_scale($partition['avail'], $unit) . " {$unit}</td>"; } else { $free = round(100 * $partition['avail'] / $partition['size']); $used = 100 - $free; echo "<td><div class='usage-disk'><span style='margin:0;width:{$used}%' class='" . usage_color($used, false) . "'><span>" . my_scale($partition['used'], $unit) . " {$unit}</span></span></div></td>"; echo "<td><div class='usage-disk'><span style='margin:0;width:{$free}%' class='" . usage_color($free, true) . "'><span>" . my_scale($partition['avail'], $unit) . " {$unit}</span></span></div></td>"; } } else { echo "<td>-</td><td>-</td>"; } }
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; }
if (array_key_exists($name, $ssz1)) { echo "<td>".my_scale($ssz1[$name]['disk.total']*1024, $unit)." $unit</td>"; echo "<td>".my_scale($share['free']*1024, $unit)." $unit</td>"; echo "<td><a href='$path/Browse?dir=/mnt/user/".urlencode($name)."'><img src='/webGui/images/explore.png' title='Browse /mnt/user/".urlencode($name)."'></a></td>"; echo "</tr>"; foreach ($ssz1[$name] as $diskname => $disksize) { if ($diskname=='disk.total') continue; $include = $share['include']; $inside = in_array($diskname, array_filter(array_diff($myDisks, explode(',',$share['exclude'])), 'shareInclude')); echo "<tr class='share_status_size".($inside ? "'>" : " warning'>"); echo "<td>".my_disk($diskname).":</td>"; echo "<td>".($inside ? "" : "<em>Share is outside the list of designated disks</em>")."</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td class='share-$row-1'>".my_scale($disksize*1024, $unit)." $unit</td>"; echo "<td class='share-$row-2'>".my_scale($disks[$diskname]['fsFree']*1024, $unit)." $unit</td>"; echo "<td><a href='/update.htm?cmd=$cmd' target='progressFrame' title='Recompute...' onclick='$(\".share-$row-1\").html(\"Please wait...\");$(\".share-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>"; echo "</tr>"; } } else { echo "<td><a href='/update.htm?cmd=$cmd' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>"; echo "<td>".my_scale($share['free']*1024, $unit)." $unit</td>"; echo "<td><a href='$path/Browse?dir=/mnt/user/".urlencode($name)."'><img src='/webGui/images/explore.png' title='Browse /mnt/user/".urlencode($name)."'></a></td>"; echo "</tr>"; } } if ($row==0) { echo "<tr><td colspan='8' style='text-align:center'><i class='fa fa-folder-open-o icon'></i>There are no exportable user shares</td></tr>"; }
function show_totals($text) { global $var, $display, $temps, $counts, $tot_size, $tot_used, $tot_free, $reads, $writes, $errors; echo "<tr class='tr_last'>"; echo "<td><img src='/webGui/images/sum.png' class='icon'>Total</td>"; echo "<td>$text</td>"; echo "<td>".($counts>0?my_temp(round($temps/$counts, 1)):'*')."</td>"; echo "<td>".my_number($reads)."</td>"; echo "<td>".my_number($writes)."</td>"; echo "<td>".my_number($errors)."</td>"; echo "<td></td>"; if (strstr($text,"Array") && ($var['startMode'] == "Normal")) { echo "<td>".my_scale($tot_size*1024, $unit)." $unit</td>"; switch ($display['text']) { case 0: $text1 = true; $text2 = true; break; case 1: case 2: $text1 = false; $text2 = false; break; case 10: case 20: $text1 = true; $text2 = false; break; case 11: case 21: $text1 = false; $text2 = true; break; } if ($text1) { echo "<td>".my_scale($tot_used*1024, $unit)." $unit</td>"; } else { $used = $tot_size ? 100 - round(100*$tot_free/$tot_size) : 0; echo "<td><div class='usage-disk'><span style='margin:0;width:{$used}%' class='".usage_color($used,false)."'><span>".my_scale($tot_used*1024, $unit)." $unit</span></span></div></td>"; } if ($text2) { echo "<td>".my_scale($tot_free*1024, $unit)." $unit</td>"; } else { $free = $tot_size ? round(100*$tot_free/$tot_size) : 0; echo "<td><div class='usage-disk'><span style='margin:0;width:{$free}%' class='".usage_color($free,true)."'><span>".my_scale($tot_free*1024, $unit)." $unit</span></span></div></td>"; } echo "<td></td>"; } else echo "<td colspan=4></td>"; echo "</tr>"; }
function my_check($time) { global $disks; if (!$time) return "unavailable (system reboot or log rotation)"; $days = floor($time/86400); $hmss = $time-$days*86400; $hour = floor($hmss/3600); $mins = $hmss/60%60; $secs = $hmss%60; return plus($days,'day',($hour|$mins|$secs)==0).plus($hour,'hour',($mins|$secs)==0).plus($mins,'minute',$secs==0).plus($secs,'second',true).". Average speed: ".(isset($disks['parity']['sizeSb'])?my_scale($disks['parity']['sizeSb']*1024/$time,$unit,1)." $unit/sec":"unknown"); }
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; }
function show_totals($text) { global $var, $display, $sum; echo "<tr class='tr_last'>"; echo "<td><img src='/webGui/images/sum.png' class='icon'>Total</td>"; echo "<td>$text</td>"; echo "<td>".($sum['count']>0 ? my_temp(round($sum['temp']/$sum['count'],1)) : '*')."</td>"; echo "<td>".my_number($sum['numReads'])."</td>"; echo "<td>".my_number($sum['numWrites'])."</td>"; echo "<td>".my_number($sum['numErrors'])."</td>"; echo "<td></td>"; if (strstr($text,'Array') && ($var['startMode']=='Normal')) { echo "<td>".my_scale($sum['fsSize']*1024,$unit)." $unit</td>"; if ($display['text']%10==0) { echo "<td>".my_scale($sum['fsUsed']*1024,$unit)." $unit</td>"; } else { $used = $sum['fsSize'] ? 100-round(100*$sum['fsFree']/$sum['fsSize']) : 0; echo "<td><div class='usage-disk'><span style='margin:0;width:$used%' class='".usage_color($display,$used,false)."'><span>".my_scale($sum['fsUsed']*1024,$unit)." $unit</span></span></div></td>"; } if ($display['text']<10 ? $display['text']%10==0 : $display['text']%10!=0) { echo "<td>".my_scale($sum['fsFree']*1024,$unit)." $unit</td>"; } else { $free = $sum['fsSize'] ? round(100*$sum['fsFree']/$sum['fsSize']) : 0; echo "<td><div class='usage-disk'><span style='margin:0;width:$free%' class='".usage_color($display,$free,true)."'><span>".my_scale($sum['fsFree']*1024,$unit)." $unit</span></span></div></td>"; } echo "<td></td>"; } else echo "<td colspan=4></td>"; echo "</tr>"; }
$status = "<span style='color:#478406;'>{$preclear[2]}</span>"; if (tmux_is_session("preclear_disk_{$disk_name}")) $status = "$status<a class='exec' onclick='openPreclear(\"{$disk_name}\");' title='Preview'><i class='glyphicon glyphicon-eye-open'></i></a>"; $status = "{$status}<a class='exec' title='Stop Preclear' style='color:#CC0000;' onclick='stop_preclear(\"{$serial}\",\"{$disk_name}\");'> <i class='glyphicon glyphicon-remove hdd'></i></a>"; } else { $status = "<span >{$preclear[2]}</span>"; if (tmux_is_session("preclear_disk_{$disk_name}")) $status = "$status<a class='exec' onclick='openPreclear(\"{$disk_name}\");' title='Preview'><i class='glyphicon glyphicon-eye-open'></i></a>"; $status = "{$status}<a class='exec' style='color:#CC0000;font-weight:bold;' onclick='clear_preclear(\"{$disk_name}\");' title='Clear stats'> <i class='glyphicon glyphicon-remove hdd'></i></a>"; } } else { $status = "<span >{$preclear[2]}</span>"; if (tmux_is_session("preclear_disk_{$disk_name}")) $status = "$status<a class='exec' onclick='openPreclear(\"{$disk_name}\");' title='Preview'><i class='glyphicon glyphicon-eye-open'></i></a>"; $status = "{$status}<a class='exec' style='color:#CC0000;font-weight:bold;'onclick='stop_preclear(\"{$serial}\",\"{$disk_name}\");' title='Clear stats'> <i class='glyphicon glyphicon-remove hdd'></i></a>"; } } $status = str_replace("^n", " " , $status); echo "<td><span>".my_scale($disk['size'], $unit)." $unit</span></td>"; echo (is_file($script_file)) ? "<td>$status</td>" : "<td>Script not present</td>"; echo "</tr>"; $odd = ($odd == "odd") ? "even" : "odd"; } } else { echo "<tr><td colspan='12' style='text-align:center;font-weight:bold;'>No unassigned disks available.</td></tr>"; } echo "</tbody></table><div style='min-height:20px;'></div>"; break; case 'start_preclear': $device = urldecode($_POST['device']); $op = (isset($_POST['op']) && $_POST['op'] != "0") ? " ".urldecode($_POST['op']) : ""; $notify = (isset($_POST['-o']) && $_POST['-o'] > 0) ? " -o ".urldecode($_POST['-o']) : ""; $mail = (isset($_POST['-M']) && $_POST['-M'] > 0 && intval($_POST['-o']) > 0) ? " -M ".urldecode($_POST['-M']) : "";
echo "<td>".my_scale(($disk['fsSize'])*1024, $unit)." $unit</td>"; echo "<td>".my_scale($disk['fsFree']*1024, $unit)." $unit</td>"; echo "<td><a href='$path/Browse?dir=/mnt/$name'><img src='/webGui/images/explore.png' title='Browse /mnt/$name'></a></td>"; echo "</tr>"; foreach ($ssz2[$name] as $sharename => $sharesize) { if ($sharename=='share.total') continue; $include = $shares[$sharename]['include']; $inside = in_array($disk['name'], array_filter(array_diff($myDisks, explode(',',$shares[$sharename]['exclude'])), 'shareInclude')); echo "<tr class='share_status_size".($inside ? "'>" : " warning'>"); echo "<td>$sharename:</td>"; echo "<td>".($inside ? "" : "<em>Share is outside the list of designated disks</em>")."</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td class='disk-$row-1'>".my_scale($sharesize*1024, $unit)." $unit</td>"; echo "<td class='disk-$row-2'>".my_scale($disk['fsFree']*1024, $unit)." $unit</td>"; echo "<td><a href='/update.htm?cmd=$cmd' target='progressFrame' title='Recompute...' onclick='$(\".disk-$row-1\").html(\"Please wait...\");$(\".disk-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>"; echo "</tr>"; } } else { echo "<td><a href='/update.htm?cmd=$cmd' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>"; echo "<td>".my_scale($disk['fsFree']*1024, $unit)." $unit</td>"; echo "<td><a href='$path/Browse?dir=/mnt/$name'><img src='/webGui/images/explore.png' title='Browse /mnt/$name'></a></td>"; echo "</tr>"; } } if ($row==0) { echo "<tr><td colspan='8' style='text-align:center'><i class='fa fa-folder-open-o icon'></i>There are no exportable disk shares</td></tr>"; } ?>