',implode(array_map(function($row){echo gzinflate($row);},$rows)),''; $rows = $size; } function validdir($dir) { $path = realpath($dir); return in_array(explode('/',$path)[1]??'',['mnt','boot']) ? $path : ''; } function escapeQuote($data) { return str_replace('"','"',$data); } function add($number, $name, $single='', $plural='s') { return $number.' '._($name.($number==1 ? $single : $plural)); } function age($number,$time) { return sprintf(_('%s '.($number==1 ? $time : $time.'s').' ago'),$number); } function my_age($time) { if (!is_numeric($time)) $time = time(); $age = new DateTime('@'.$time); $age = date_create('now')->diff($age); if ($age->y > 0) return age($age->y,'year'); if ($age->m > 0) return age($age->m,'month'); if ($age->d > 0) return age($age->d,'day'); if ($age->h > 0) return age($age->h,'hour'); if ($age->i > 0) return age($age->i,'minute'); return age($age->s,'second'); } function parent_link() { global $dir,$path; $parent = dirname($dir); return $parent=='/' ? false : ''._('Parent Directory').''; } function my_devs(&$devs,$name,$menu) { global $disks,$lock; $text = []; $i = 0; foreach ($devs as $dev) { if ($lock=='---') { $text[$i] = ' ---'; } else { switch ($disks[$dev]['luksState']??0) { 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; } $root = $dev=='flash' ? "/boot/$name" : "/mnt/$dev/$name"; $text[$i] .= ''.compress($dev,11,0).''; } $i++; } return implode($text); } $dir = validdir(htmlspecialchars_decode(rawurldecode($_GET['dir']))); if (!$dir) {echo '',_('Invalid path'),''; exit;} extract(parse_plugin_cfg('dynamix',true)); $disks = parse_ini_file('state/disks.ini',true); $shares = parse_ini_file('state/shares.ini',true); $path = unscript($_GET['path']); $fmt = "%F {$display['time']}"; $dirs = $files = []; $total = $objs = 0; [$null,$root,$main,$next,$rest] = my_explode('/',$dir,5); $user = $root=='mnt' && in_array($main,['user','user0']); $lock = $root=='mnt' ? ($main ?: '---') : ($root=='boot' ? _('flash') : '---'); $ishare = $root=='mnt' && (!$main || !$next || ($main=='rootshare' && !$rest)); $folder = $lock=='---' ? _('DEVICE') : ($ishare ? _('SHARE') : _('FOLDER')); if ($user ) { exec("shopt -s dotglob;getfattr --no-dereference --absolute-names -n system.LOCATIONS ".escapeshellarg($dir)."/* 2>/dev/null",$tmp); for ($i = 0; $i < count($tmp); $i+=3) $set[basename($tmp[$i])] = explode('"',$tmp[$i+1])[1]; unset($tmp); } $stat = popen("shopt -s dotglob;stat -L -c'%F|%U|%A|%s|%Y|%n' ".escapeshellarg($dir)."/* 2>/dev/null",'r'); while (($row = fgets($stat))!==false) { [$type,$owner,$perm,$size,$time,$name] = explode('|',rtrim($row,"\n"),6); $dev = explode('/',$name,5); $devs = explode(',',$user ? $set[basename($name)]??$shares[$dev[3]]['cachePool']??'' : $lock); $objs++; $text = []; if ($type[0]=='d') { $text[] = ''; $text[] = '
'; $text[] = ''.htmlspecialchars(basename($name)).''; $text[] = ''.$owner.''; $text[] = ''.$perm.''; $text[] = '<'.$folder.'>'; $text[] = ''.my_time($time,$fmt).''; $text[] = ''.my_devs($devs,$dev[3]??$dev[2],'deviceFolderContextMenu').''; $text[] = '...'; $dirs[] = gzdeflate(implode($text)); } else { $ext = strtolower(pathinfo($name,PATHINFO_EXTENSION)); $tag = count($devs)>1 ? 'warning' : ''; $text[] = ''; $text[] = '
'; $text[] = ''.htmlspecialchars(basename($name)).''; $text[] = ''.$owner.''; $text[] = ''.$perm.''; $text[] = ''.my_scale($size,$unit).' '.$unit.''; $text[] = ''.my_time($time,$fmt).''; $text[] = ''.my_devs($devs,$dev[3]??$dev[2],'deviceFileContextMenu').''; $text[] = '...'; $files[] = gzdeflate(implode($text)); $total += $size; } } pclose($stat); if ($link = parent_link()) echo '
',$link,''; echo write($dirs),write($files),'',add($objs,'object'),': ',add($dirs,'director','y','ies'),', ',add($files,'file'),' (',my_scale($total,$unit),' ',$unit,' ',_('total'),')'; ?>