Image

Displays an image file.

Command line interface

Syntax

  1. $ image filename

Arguments

  • filename – (file) Image file to display.

Example

image.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. switch ($_POST["action"]) {
  5. case 'check':
  6. die(is_file($_POST['file']) && is_readable($_POST['file'])?"1":"-1");
  7. case 'fetch':
  8. readfile($_POST['file']);
  9. break;
  10. }
  11. exit;
  12. }
  13. ?>
  14. /**
  15. * Show image
  16. **/
  17. TinyShell.plugins.image = new Class({
  18. description: "Display image file",
  19. run : function(terminal, args) {
  20. this.t = terminal;
  21. if (args.length) {
  22. this.file = args[0];
  23. this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=check&file="+encodeURIComponent(this.file));
  24. } else {
  25. terminal.print("image: usage: image filename");
  26. terminal.resume();
  27. }
  28. },
  29. print: function(r) {
  30. if (r != "1") this.t.print("image: `"+this.file+"' is not a file");
  31. else this.t.print("<img src='"+this.t.create_url("<?php echo $_AJAX_URL?>", "action=fetch&file="+encodeURIComponent(this.file))+"' alt='Filename: "+this.file+"' />", true);
  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>