package main import ( "fmt" "html" "runtime" "github.com/dustin/go-humanize" "github.com/spf13/afero" ) func (r *wfmRequest) prompt(action string, mul []string) { header(r.w, r.uDir, r.eSort, "") r.w.Write([]byte(`

 

  ` + action + `
  `)) switch action { case "mkdir": r.w.Write([]byte(`  
Enter name for the new directory:

`)) case "mkfile": r.w.Write([]byte(`  
Enter name for the new file:

`)) case "mkurl": r.w.Write([]byte(`  
Enter name for the new url file:

 
Destination URL:

`)) case "rename": eBn := html.EscapeString(r.uFbn) r.w.Write([]byte(`  
Enter new name for the file ` + eBn + `:

`)) case "move": eBn := html.EscapeString(r.uFbn) r.w.Write([]byte(`  
Select destination folder for ` + eBn + `:

`)) case "delete": var a string fi, _ := r.fs.Stat(r.uDir + "/" + r.uFbn) if fi.IsDir() { a = "directory - recursively" } else { a = "file, size " + humanize.Bytes(uint64(fi.Size())) } eBn := html.EscapeString(r.uFbn) r.w.Write([]byte(`  
Are you sure you want to delete:
` + eBn + ` (` + a + `)

`)) case "multi_delete": fmt.Fprintf(r.w, " 
Are you sure you want to delete from %v:

    \n", html.EscapeString(r.uDir)) for _, f := range mul { fE := html.EscapeString(f) fmt.Fprintf(r.w, "\n"+ "
  • %v
  • \n", fE, fE) } fmt.Fprintln(r.w, "

") case "multi_move": fmt.Fprintf(r.w, " 
Move from: %v

\n"+ "To:

\n

    Items:

    \n", html.EscapeString(r.uDir), upDnDir(r.uDir, r.uFbn, r.fs), ) for _, f := range mul { fE := html.EscapeString(f) fmt.Fprintf(r.w, "\n"+ "

  • %v
  • \n", fE, fE) } fmt.Fprintln(r.w, "

") } r.w.Write([]byte(`

 
 

`)) footer(r.w) } func (r *wfmRequest) editText() { fi, err := r.fs.Stat(r.uDir + "/" + r.uFbn) if err != nil { htErr(r.w, "Unable to get file attributes", err) return } if fi.Size() > 1<<20 { htErr(r.w, "edit", fmt.Errorf("the file is too large for editing")) return } f, err := afero.ReadFile(r.fs, r.uDir+"/"+r.uFbn) if err != nil { htErr(r.w, "Unable to read file", err) return } header(r.w, r.uDir, r.eSort, `html, body, table, textarea, form { box-sizing: border-box; height:98%; }`) r.w.Write([]byte(`
File Editor: ` + html.EscapeString(r.uFbn) + `  

 
`)) footer(r.w) } func (r *wfmRequest) about(ua string) { header(r.w, r.uDir, r.eSort, "") r.w.Write([]byte(`

 

  Web File Manager
 
WFM Version v` + vers + `
Developed by Antoni Sawicki Et Al.
https://github.com/tenox7/wfm/
Copyright © 1994-2018 by Antoni Sawicki
Copyright © 2018-2022 by Google LLC
This is not an official Google product.

`)) if *aboutRnt { fmt.Fprintf(r.w, "Build: %v %v-%v
Agent: %v

", runtime.Version(), runtime.GOARCH, runtime.GOOS, ua) } r.w.Write([]byte(`

 
 

`)) footer(r.w) }