Rm

Deletes a file from the server.

Command line interface

Syntax

  1. $ rm filename

Arguments

  • filename – (file) The file you wish to remove.

Example

Todo

  • Add support for recursive delete
  • Add support for multiple filenames

rm.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'rm') {
  5. if (!file_exists($_POST['file'])) die("1");
  6. if (is_dir($_POST['file'])) die("2");
  7. die(@unlink($_POST['file']) ? "0" : "3");
  8. }
  9. exit;
  10. }
  11. ?>
  12. /**
  13. * Remove file
  14. **/
  15. TinyShell.plugins.rm = new Class({
  16. description: "Remove file",
  17. run : function(terminal, args) {
  18. this.t = terminal;
  19. if (args.length != 1) {
  20. terminal.print("rm: usage: rm filename");
  21. terminal.resume();
  22. } else {
  23. this.file = args[0];
  24. this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=rm&file="+encodeURIComponent(this.file));
  25. }
  26. },
  27. print: function(r) {
  28. if (r == "1") this.t.print("rm: file `"+this.file+"'; file does not exist");
  29. else if (r == "2") this.t.print("rm: file `"+this.file+"'; is a directory");
  30. else if (r == "3") this.t.print("rm: file `"+this.file+"'; permission denied");
  31. else this.t.print();
  32. this.t.resume();
  33. }
  34. });

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>