Rmdir

Removes a directory from the server.

Command line interface

Syntax

  1. $ rmdir dirname

Arguments

  • dirname – (directory) The folder you wish to delete.

Example

rmdir.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'rmdir') {
  5. if (!is_dir($_POST['dir'])) die("1");
  6. if (count(glob($_POST['dir']."/*"))) die("2");
  7. die(@rmdir($_POST['dir']) ? "0" : "3");
  8. }
  9. exit;
  10. }
  11. ?>
  12. /**
  13. * Remove directory
  14. **/
  15. TinyShell.plugins.rmdir = new Class({
  16. description: "Remove directory",
  17. run : function(terminal, args) {
  18. this.t = terminal;
  19. if (args.length == 1) {
  20. this.dir = args[0];
  21. this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=rmdir&dir="+encodeURIComponent(this.dir));
  22. } else {
  23. terminal.print("rmdir: usage: rmdir dirname");
  24. terminal.resume();
  25. }
  26. },
  27. print: function(r) {
  28. if (r == "1") this.t.print("mkdir: directory `"+this.dir+"'; not a directory");
  29. else if (r == "2") this.t.print("mkdir: directory `"+this.dir+"'; directory not empty");
  30. else if (r == "3") this.t.print("mkdir: directory `"+this.dir+"'; 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>