Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

import.php 2.4 KiB

16 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. * $Id$
  18. *
  19. * This program is free software. It comes without any warranty, to
  20. * the extent permitted by applicable law. You can redistribute it
  21. * and/or modify it under the terms of the Do What The Fuck You Want
  22. * To Public License, Version 2, as published by Sam Hocevar. See
  23. * http://sam.zoy.org/wtfpl/COPYING for more details.
  24. */
  25. $imports = caca_get_import_list();
  26. $file = isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : NULL;
  27. $filename = isset($_FILES['file']) ? $_FILES['file']['name'] : NULL;
  28. $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : NULL;
  29. ?>
  30. <head>
  31. <title><?= ($filename == NULL) ? '' : htmlspecialchars($filename . ' | ') ?>libcaca importers test program</title>
  32. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  33. </head>
  34. <body>
  35. <?php
  36. if ($file == NULL)
  37. {
  38. ?>
  39. <form id="importform" name="importform" action="#" enctype="multipart/form-data" method="post">
  40. <label for="file">File:</label>
  41. <input id="file" name="file" type="file" />
  42. <br />
  43. <input type="submit" value="Import" />
  44. <label for="format">as</label>
  45. <select name="format" id="format" onchange="update_preview(this);">
  46. <?php
  47. foreach($imports as $import_format => $name)
  48. {
  49. ?><option value="<?= htmlspecialchars($import_format) ?>"<?=
  50. ($format == $import_format) ? ' selected="selected"' : '' ?>><?=
  51. htmlspecialchars($name . " (" . $import_format . ")") ?></option><?php
  52. }
  53. ?>
  54. </select>
  55. </form>
  56. <?php
  57. ;
  58. }
  59. if($file)
  60. {
  61. $cv = caca_create_canvas(0, 0);
  62. if(! $cv)
  63. {
  64. die("Can't create canvas\n");
  65. }
  66. if(caca_import_file($cv, $file, ($format == NULL) ? "" : $format) < 0)
  67. {
  68. die("could not import `" . htmlspecialchars($filename) . "'.\n");
  69. }
  70. echo caca_export_string($cv, "html3");
  71. }
  72. else
  73. {
  74. ?>See the <a href="export.php">libcaca export test program</a> for an <a
  75. href="export.php?format=caca">example file</a>.<?php
  76. }
  77. ?>
  78. </body>
  79. </html>