Parent Directory" : ""; } function trim_slash($url){ return preg_replace('://+:','/',$url); } function my_devs(&$devs) { global $disks; $text = []; $i = 0; foreach ($devs as $dev) { switch ($disks[$dev]['luksState']) { case 0: $text[$i] = ""._('Not encrypted').""; break; case 1: $text[$i] = ""._('Encrypted and unlocked').""; break; case 2: $text[$i] = ""._('Locked: missing encryption key').""; break; case 3: $text[$i] = ""._('Locked: wrong encryption key').""; break; default: $text[$i] = ""._('Locked: unknown error').""; break; } $text[$i++] .= compress($dev,8,0); } return implode(', ',$text); } extract(parse_plugin_cfg('dynamix',true)); $disks = parse_ini_file('state/disks.ini',true); $dir = realpath(htmlspecialchars_decode(rawurldecode($_GET['dir']))); $path = unscript($_GET['path']); [$root,$main,$rest] = my_explode('/',mb_substr($dir,1),3); $fix = $root=='mnt' ? ($main ?: '---') : ($root=='boot' ? _('flash') : '---'); $user = $root=='mnt' && in_array($main,['user','user0']); $fmt = "%F {$display['time']}"; $dirs = $files = []; $total = $i = 0; if ($user) { $tag = implode('|',array_merge(['disk'],pools_filter($disks))); $set = explode(';',str_replace(',;',',',preg_replace("/($tag)/",';$1',exec("shopt -s dotglob; getfattr --no-dereference --absolute-names --only-values -n system.LOCATIONS ".escapeshellarg($dir)."/* 2>/dev/null")))); } $stat = popen("shopt -s dotglob; stat -L -c'%F|%n|%s|%Y' ".escapeshellarg($dir)."/* 2>/dev/null",'r'); while (($row = fgets($stat))!==false) { $row .= $user ? "|{$set[++$i]}" : "|$fix"; if ($row[0]=='d') $dirs[] = $row; else $files[] = $row; } pclose($stat); echo ""._('Type').""._('Name').""._('Size').""._('Last Modified').""._('Location').""; if ($link = parent_link()) echo "
$link"; echo ""; foreach ($dirs as $row) { [$type,$full,$size,$time,$set] = my_explode('|',$row,5); $file = pathinfo($full); $full = str_replace($docroot,'',$full); $name = $file['basename']; $devs = explode(',',$set); echo ""; echo "
"; echo "".htmlspecialchars($name).""; echo "<"._('FOLDER').">"; echo "".my_time($time,$fmt).""; echo "".my_devs($devs).""; echo ""; } if (count($dirs)) echo ""; foreach ($files as $row) { [$type,$full,$size,$time,$set] = my_explode('|',$row,5); $file = pathinfo($full); $full = str_replace($docroot,'',$full); $name = $file['basename']; $ext = strtolower($file['extension']); $devs = explode(',',$set); $tag = strpos($set,',')===false ? '' : 'warning'; echo ""; echo "
"; echo "".htmlspecialchars($name).""; echo "".my_scale($size,$unit)." $unit"; echo "".my_time($time,$fmt).""; echo "".my_devs($devs).""; echo ""; $total += $size; } echo ""; $dirs = count($dirs); $files = count($files); $objs = $dirs + $files; if ($objs==0 && !exec("find ".escapeshellarg($dir)." -maxdepth 0 -empty -exec echo 1 \;")) { echo ""._('No listing: Too many files').""; } else { $total = ' ('.my_scale($total,$unit).' '.$unit.' '._('total').')'; echo "$objs "._('object'.($objs==1?'':'s')).": $dirs "._('director'.($dirs==1?'y':'ies')).", $files "._('file'.($files==1?'':'s'))."$total"; } ?>