Mkdir

Creates a folder in the current working directory on the server.

Command line interface

Syntax

  1. $ mkdir [-m mode] dirname

Arguments

  • mode – (octal number, optional) The mode. Default: 0755. Ignored on Windows servers.
  • dirname – (string) Decided directory name.

Example

mkdir.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'mkdir') {
  5. if (file_exists($_POST['dir'])) die("1");
  6. die(@mkdir($_POST['dir'], $_POST['mode']) ? "0" : "2");
  7. }
  8. exit;
  9. }
  10. ?>
  11. /**
  12. * Make directory
  13. **/
  14. TinyShell.plugins.mkdir = new Class({
  15. description: "Create new directory",
  16. run : function(terminal, args) {
  17. this.t = terminal;
  18. if (args.length == 1 || (args.length == 3 && args[0] == "-m")) {
  19. this.mode = "0755";
  20. this.dir = args[0];
  21. if (args[0] == "-m") {
  22. this.mode = args[1];
  23. this.dir = args[2];
  24. }
  25. this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=mkdir&dir="+encodeURIComponent(this.dir)+"&mode="+encodeURIComponent(this.mode));
  26. } else {
  27. terminal.print("mkdir: usage: mkdir [-m mode] dirname");
  28. terminal.resume();
  29. }
  30. },
  31. print: function(r) {
  32. if (r == "1") this.t.print("mkdir: failed to create directory `"+this.dir+"'; file exists\n");
  33. else if (r == "2") this.t.print("mkdir: failed to create directory `"+this.dir+"'; permission denied\n");
  34. else this.t.print();
  35. this.t.resume();
  36. }
  37. });

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>