v1ral_ITS

Untitled

Aug 26th, 2026
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. set -e
  2. $OUT = "index.html"
  3. $DIR = "${1:-.}"
  4. $RECURSIVE = "0"
  5. # Optional flags
  6. foreach ($arg in ""$@"") {
  7.     case "$arg" in
  8.     --recursive|-r) RECURSIVE=1 ;;
  9.     esac
  10. }
  11. $DIR = "$(realpath "$DIR")"
  12. Write-Host "[*] Building index for: $DIR"
  13. # HTML header
  14. cat > "$OUT" <<EOF
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <meta charset="UTF-8">
  19. <title>Index of $(basename "$DIR")</title>
  20. <style>
  21. body { background:#0e0e0e; color:#e0e0e0; font-family:monospace; }
  22. a { color:#6cf; text-decoration:none; }
  23. .grid { display:flex; flex-wrap:wrap; gap:10px; }
  24. .item { width:200px; border:1px solid #333; padding:5px; }
  25. img { max-width:100%; height:auto; }
  26. </style>
  27. </head>
  28. <body>
  29. <h2>Index of $(basename "$DIR")</h2>
  30. <div class="grid">
  31. EOF
  32. # File listing
  33. if ([bool]$"$RECURSIVE" -eq 1) {
  34.     $FILES = "$(find "$DIR" -type f)"
  35. else {
  36.     $FILES = "$(find "$DIR" -maxdepth 1 -type f)"
  37. }
  38. while IFS= read -r file; do
  39. $rel = "${file#$DIR/}"
  40. $ext = "${file##*.}"
  41. $ext = "$(echo "$ext" | tr '[:upper:]' '[:lower:]')"
  42. Write-Host "<div class='item'>" >> "$OUT"
  43. case "$ext" in
  44. jpg|jpeg|png|gif|webp)
  45. Write-Host "<a href=\"$rel\"><img src=\"$rel\"></a><br>$rel" >> "$OUT"
  46. ;;
  47. mp4|mkv|webm)
  48. Write-Host "<video src=\"$rel\" controls width=180></video><br>$rel" >> "$OUT"
  49. ;;
  50. mp3|wav|ogg)
  51. Write-Host "<audio src=\"$rel\" controls></audio><br>$rel" >> "$OUT"
  52. ;;
  53. *)
  54. Write-Host "<a href=\"$rel\">$rel</a>" >> "$OUT"
  55. ;;
  56. esac
  57. Write-Host "</div>" >> "$OUT"
  58. done <<< "$FILES"
  59. # Footer
  60. cat >> "$OUT" <<EOF
  61. </div>
  62. </body>
  63. </html>
  64. EOF
  65. Write-Host "[✓] Created $OUT"
Advertisement
Add Comment
Please, Sign In to add comment