Replace share size hack with more 'proper' solution

This commit is contained in:
bergware
2017-07-14 12:49:09 +02:00
parent 20b4c4230f
commit 16723e133f
5 changed files with 36 additions and 28 deletions
+8 -4
View File
@@ -3,8 +3,8 @@ Title="Disk Shares"
Cond="$var['fsState']=='Started' && $var['shareDisk']!='no'"
---
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -16,8 +16,12 @@ Cond="$var['fsState']=='Started' && $var['shareDisk']!='no'"
?>
<script>
function displayDisks(all) {
if (all == 'yes') $('#disk_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing disk shares!</td></tr>");
$.get('/webGui/include/DiskList.php',{compute:all,path:'<?=$path?>',prev:'<?=$prev?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>'},function(data){
if (all == 'yes') {
$.cookie('ssz','ssz',{path:'/'});
$('#disk_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing disk shares!</td></tr>");
}
$.get('/webGui/include/DiskList.php',{compute:all,path:'<?=$path?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>',fill:$.cookie('ssz')},function(data){
$.removeCookie('ssz',{path:'/'})
$('#disk_list').html(data);
$('#compute-disks').prop('disabled',!data || data.indexOf('colspan=')!=-1);
});
+8 -4
View File
@@ -3,8 +3,8 @@ Title="User Shares"
Cond="$var['fsState']=="Started" && $var['shareUser']=='e'"
---
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -16,8 +16,12 @@ Cond="$var['fsState']=="Started" && $var['shareUser']=='e'"
?>
<script>
function displayShares(all) {
if (all == 'yes') $('#share_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing user shares!</td></tr>");
$.get('/webGui/include/ShareList.php',{compute:all,path:'<?=addslashes(htmlspecialchars($path))?>',prev:'<?=addslashes(htmlspecialchars($prev))?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>'},function(data){
if (all == 'yes') {
$.cookie('ssz','ssz',{path:'/'});
$('#share_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing user shares!</td></tr>");
}
$.get('/webGui/include/ShareList.php',{compute:all,path:'<?=addslashes(htmlspecialchars($path))?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>',fill:$.cookie('ssz')},function(data){
$.removeCookie('ssz',{path:'/'})
$('#share_list').html(data);
$('#compute-shares').prop('disabled',!data || data.indexOf('colspan=')!=-1);
});
+10 -8
View File
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Helpers.php";
$shares = parse_ini_file('state/shares.ini',true);
@@ -22,6 +22,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
$sec_afp = parse_ini_file('state/sec_afp.ini',true);
$compute = $_GET['compute'];
$path = $_GET['path'];
$fill = $_GET['fill'];
$display = [];
$display['scale'] = $_GET['scale'];
@@ -53,9 +54,10 @@ $myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUs
// Share size per disk
$ssz2 = [];
foreach (glob("state/*.ssz2", GLOB_NOSORT) as $entry) {
$ssz2[basename($entry, ".ssz2")] = parse_ini_file($entry);
}
if ($fill)
foreach (glob("state/*.ssz2", GLOB_NOSORT) as $entry) $ssz2[basename($entry, ".ssz2")] = parse_ini_file($entry);
else
exec("rm -f /var/local/emhttp/*.ssz2");
// Build table
$row = 0;
@@ -93,11 +95,11 @@ foreach ($disks as $name => $disk) {
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&csrf_token={$var['csrf_token']}' 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 "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$.cookie(\"ssz\",\"ssz\",{path:\"/\"});$(\".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&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>";
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$.cookie('ssz','ssz',{path:'/'});$(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>";
+10 -8
View File
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Helpers.php";
$shares = parse_ini_file('state/shares.ini',true);
@@ -22,6 +22,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
$sec_afp = parse_ini_file('state/sec_afp.ini',true);
$compute = $_GET['compute'];
$path = $_GET['path'];
$fill = $_GET['fill'];
$display = [];
$display['scale'] = $_GET['scale'];
@@ -60,9 +61,10 @@ $myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUs
// Share size per disk
$ssz1 = [];
foreach (glob("state/*.ssz1", GLOB_NOSORT) as $entry) {
$ssz1[basename($entry, ".ssz1")] = parse_ini_file($entry);
}
if ($fill)
foreach (glob("state/*.ssz1", GLOB_NOSORT) as $entry) $ssz1[basename($entry, ".ssz1")] = parse_ini_file($entry);
else
exec("rm -f /var/local/emhttp/*.ssz1");
// Build table
$row = 0;
@@ -97,11 +99,11 @@ foreach ($shares as $name => $share) {
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&csrf_token={$var['csrf_token']}' 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 "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$.cookie(\"ssz\",\"ssz\",{path:\"/\"});$(\".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&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>";
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$.cookie('ssz','ssz',{path:'/'});$(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>";
-4
View File
@@ -58,10 +58,6 @@ $myPage = $site[basename($path)];
$pageroot = $docroot.'/'.dirname($myPage['file']);
$update = true; // set for legacy
// hack: maybe delete stale share size files
if ($myPage['name'] != 'Shares')
foreach(glob('/var/local/emhttp/*.ssz*', GLOB_NOSORT) as $sszfile) @unlink($sszfile);
// Giddyup
require_once "$docroot/webGui/include/DefaultPageLayout.php";
?>