Source: delete.php
⬇️ Tải file Trang chính
<?php
require __DIR__.'/s3helper.php';
$cfg=s3_load_config();
$msg=null;

if($_SERVER['REQUEST_METHOD']==='POST'){
  $target=trim((string)($_POST['target']??''));
  $isFolder = ($_POST['is_folder'] ?? '') === '1';

  if($target===''){ $msg="Vui lòng nhập đường dẫn."; }
  else if($isFolder){
    $prefix = s3_norm_prefix($target);
    $res = s3_delete_prefix($cfg, $cfg['bucket'], $prefix);
    $msg = $res['ok'] ? "🗑️ Đã xoá thư mục '$prefix' với {$res['deleted']} object."
                      : "❌ Xoá thư mục lỗi (HTTP ".($res['http_code']??'?').")";
  } else {
    $key = ltrim($target,'/');
    $r = s3_send_request($cfg,'DELETE',$cfg['bucket'],$key,[],[],null);
    $msg = $r['ok'] ? "🗑️ Đã xoá file '$key'." : "❌ Xoá file lỗi (HTTP {$r['http_code']})";
  }
}
?>
<!doctype html><html><head><meta charset="utf-8"><title>Delete</title>
<style>body{font-family:Inter,Arial;background:#fafafa;padding:20px}input,button{padding:8px;margin:6px}.flash{padding:10px;border-radius:8px;background:#fee2e2;color:#991b1b;max-width:760px}.card{background:#fff;border:1px solid #e5e7eb;border-radius:12px;padding:16px;max-width:760px}</style></head>
<body>
<div class="card">
<h2>🗑️ Xoá trong bucket: <?=htmlspecialchars($cfg['bucket'])?></h2>
<?php if($msg):?><div class="flash"><?=$msg?></div><?php endif;?>
<form method="post" onsubmit="return confirm('Xác nhận xoá?');">
  <label>Đường dẫn cần xoá (file hoặc thư mục)</label>
  <input name="target" placeholder="vd file: images/2025/photo.jpg | thư mục: images/2025/ " style="width:420px" required>
  <label><input type="checkbox" name="is_folder" value="1"> Đây là thư mục (prefix)</label><br>
  <button>Xoá</button>
</form>
<p style="margin-top:12px"><a href="index.php">← Trang chính</a> • <a href="view_source.php?file=delete.php" target="_blank">Source</a></p>
</div>
</body></html>