$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; // add translations $_SERVER['REQUEST_URI'] = ''; require_once "$docroot/webGui/include/Translations.php"; require_once "$docroot/webGui/include/Helpers.php"; function write(&$rows) { if ($size = count($rows)) echo '
',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 '