72 rivejä
1.9 KiB

  1. <?php
  2. $pngmode = isset($_REQUEST['png']) ? ($_REQUEST['png'] != '') : false;
  3. if ($pngmode)
  4. header('Content-Type: image/png');
  5. else
  6. header('Content-Type: text/html; charset=UTF-8');
  7. if (! $pngmode)
  8. {
  9. ?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  11. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  13. <head>
  14. <title>Я люблю Либкаку</title>
  15. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  16. <link rel="StyleSheet" href="caca-php.css" type="text/css" />
  17. </head>
  18. <body text="silver" bgcolor="black">
  19. <?php
  20. ;
  21. }
  22. $pig_str = <<<EOT
  23. _._ _..._ .-', _.._(`))
  24. '-. ` ' /-._.-' ',/
  25. ) \ '.
  26. / _ _ | \
  27. | a a / PHP |
  28. \ .-. ;
  29. '-('' ).-' ,' ;
  30. '-; | .'
  31. \ \ /
  32. | 7 .__ _.-\ \
  33. | | | ``/ /` /
  34. jgs /,_| | /,_/ /
  35. /,_/ '`-'
  36. EOT;
  37. $canvas = caca_create_canvas(0, 0);
  38. caca_set_color_ansi($canvas, CACA_RED, CACA_WHITE);
  39. caca_import_string($canvas, $pig_str, "text");
  40. caca_set_color_ansi($canvas, CACA_BLUE, CACA_LIGHTGRAY);
  41. caca_put_str($canvas, 0, 0, "Я люблю Либкаку");
  42. if (! $pngmode)
  43. echo caca_export_string($canvas, "html3");
  44. $font = caca_load_builtin_font("Monospace Bold 12");
  45. $width = caca_get_canvas_width($canvas) * caca_get_font_width($font);
  46. $height = caca_get_canvas_height($canvas) * caca_get_font_height($font);
  47. $img = imagecreatetruecolor($width, $height);
  48. caca_render_canvas($canvas, $font, $img);
  49. if ($pngmode)
  50. imagepng($img);
  51. else
  52. {
  53. ?>
  54. <form action="#">
  55. <label for="png">Please, open new created png file:</label>
  56. <input type="submit" id="png" name="png" value="Display" />
  57. </form>
  58. </body>
  59. </html>
  60. <?php
  61. ;
  62. }