You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

87 lines
2.4 KiB

  1. <?php
  2. header('Content-Type: text/html; charset=UTF-8');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  7. <?php
  8. /*
  9. * import libcaca importers test program
  10. * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
  11. *
  12. * This file is a Php port of "examples/import.c"
  13. * which is:
  14. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  15. * All Rights Reserved
  16. *
  17. * This program is free software. It comes without any warranty, to
  18. * the extent permitted by applicable law. You can redistribute it
  19. * and/or modify it under the terms of the Do What the Fuck You Want
  20. * to Public License, Version 2, as published by Sam Hocevar. See
  21. * http://www.wtfpl.net/ for more details.
  22. */
  23. $imports = caca_get_import_list();
  24. $file = isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : NULL;
  25. $filename = isset($_FILES['file']) ? $_FILES['file']['name'] : NULL;
  26. $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : NULL;
  27. ?>
  28. <head>
  29. <title><?= ($filename == NULL) ? '' : htmlspecialchars($filename . ' | ') ?>libcaca importers test program</title>
  30. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  31. </head>
  32. <body>
  33. <?php
  34. if ($file == NULL)
  35. {
  36. ?>
  37. <form id="importform" name="importform" action="#" enctype="multipart/form-data" method="post">
  38. <label for="file">File:</label>
  39. <input id="file" name="file" type="file" />
  40. <br />
  41. <input type="submit" value="Import" />
  42. <label for="format">as</label>
  43. <select name="format" id="format" onchange="update_preview(this);">
  44. <?php
  45. foreach($imports as $import_format => $name)
  46. {
  47. ?><option value="<?= htmlspecialchars($import_format) ?>"<?=
  48. ($format == $import_format) ? ' selected="selected"' : '' ?>><?=
  49. htmlspecialchars($name . " (" . $import_format . ")") ?></option><?php
  50. }
  51. ?>
  52. </select>
  53. </form>
  54. <?php
  55. ;
  56. }
  57. if($file)
  58. {
  59. $cv = caca_create_canvas(0, 0);
  60. if(! $cv)
  61. {
  62. die("Can't create canvas\n");
  63. }
  64. if(caca_import_file($cv, $file, ($format == NULL) ? "" : $format) < 0)
  65. {
  66. die("could not import `" . htmlspecialchars($filename) . "'.\n");
  67. }
  68. echo caca_export_string($cv, "html3");
  69. }
  70. else
  71. {
  72. ?>See the <a href="export.php">libcaca export test program</a> for an <a
  73. href="export.php?format=caca">example file</a>.<?php
  74. }
  75. ?>
  76. </body>
  77. </html>