$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; require_once "$docroot/webGui/include/Helpers.php"; // add translations $_SERVER['REQUEST_URI'] = 'shares'; require_once "$docroot/webGui/include/Translations.php"; $shares = parse_ini_file('state/shares.ini',true); $disks = parse_ini_file('state/disks.ini',true); $var = parse_ini_file('state/var.ini'); $sec = parse_ini_file('state/sec.ini',true); $sec_nfs = parse_ini_file('state/sec_nfs.ini',true); $compute = unscript(_var($_GET,'compute')); $path = unscript(_var($_GET,'path')); $fill = unscript(_var($_GET,'fill')); $display = []; $display['scale'] = unscript(_var($_GET,'scale')); $display['number'] = unscript(_var($_GET,'number','.,')); // Display export settings function disk_share_settings($protocol,$share) { if (empty($share)) return; if ($protocol!='yes' || _var($share,'export')=='-') return "-"; return (_var($share,'export')=='e') ? _(ucfirst(_var($share,'security'))) : ''._(ucfirst(_var($share,'security'))).''; } function globalInclude($name) { global $var; return substr($name,0,4)!='disk' || !_var($var,'shareUserInclude') || strpos(_var($var,'shareUserInclude').",","$name,")!==false; } function shareInclude($name) { global $include; return !$include || substr($name,0,4)!='disk' || strpos("$include,", "$name,")!==false; } function sharesOnly($disk) { return in_array(_var($disk,'type'),['Data','Cache']) && _var($disk,'exportable')=='yes'; } // filter disk shares $disks = array_filter($disks,'sharesOnly'); // Compute all disk shares & check encryption $crypto = false; foreach ($disks as $name => $disk) { if ($compute=='yes') exec("webGui/scripts/disk_size ".escapeshellarg($name)." ssz2"); $crypto |= strpos(_var($disk,'fsType'),'luks:')!==false; } // global shares include/exclude $myDisks = array_filter(array_diff(array_keys($disks), explode(',',_var($var,'shareUserExclude'))), 'globalInclude'); // Share size per disk $ssz2 = []; if ($fill) foreach (glob("state/*.ssz2", GLOB_NOSORT) as $entry) $ssz2[basename($entry, ".ssz2")] = file($entry,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); else exec("rm -f /var/local/emhttp/*.ssz2"); // Build table $row = 0; foreach ($disks as $name => $disk) { $color = _var($disk,'fsColor'); $row++; switch ($color) { case 'green-on' : $orb = 'circle'; $color = 'green'; $help = _('All files protected'); break; case 'yellow-on': $orb = 'warning'; $color = 'yellow'; $help = _('All files unprotected'); break; } if ($crypto) switch (_var($disk,'luksState',0)) { case 0: $luks = ""; break; case 1: $luks = ""._('All files encrypted').""; break; case 2: $luks = ""._('Some or all files unencrypted').""; break; default: $luks = ""._('Unknown encryption state').""; break; } else $luks = ""; echo "