您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

68 行
1.8 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">
  7. <head>
  8. <title>Caca power!</title>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  10. </head>
  11. <body>
  12. <?php
  13. /*
  14. * figlet.php sample program for libcaca php binding
  15. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  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://sam.zoy.org/wtfpl/COPYING for more details.
  22. */
  23. function unistr_to_ords($str, $encoding = 'UTF-8'){
  24. $str = mb_convert_encoding($str, "UCS-4BE", $encoding);
  25. $result = array();
  26. for ($i = 0; $i < mb_strlen($str, "UCS-4BE"); $i++){
  27. $c = mb_substr($str, $i, 1, "UCS-4BE");
  28. $val = unpack("N", $c);
  29. $result[] = $val[1];
  30. }
  31. return $result;
  32. }
  33. function show_figlet($str, $font) {
  34. $cv = caca_create_canvas(0, 0);
  35. if (!caca_canvas_set_figfont($cv, $font)) {
  36. return false;
  37. }
  38. $chars = unistr_to_ords($str);
  39. $color = 0;
  40. foreach ($chars as $c) {
  41. caca_set_color_ansi($cv, 1 + (($color += 4) % 15), CACA_WHITE);
  42. caca_put_figchar($cv, $c);
  43. }
  44. echo caca_export_string($cv, "html3");
  45. }
  46. $path = "/usr/share/figlet/";
  47. if (!is_dir($path)) {
  48. die("can not open directory $path.\n");
  49. }
  50. $dir = opendir($path);
  51. while (($it = readdir($dir)) != false) {
  52. if (is_file($path.$it) and ereg("\.[tf]lf$", $it)) {
  53. echo "<b>font : $it</b>\n";
  54. show_figlet("Libcaca", $path.$it);
  55. }
  56. }
  57. ?>
  58. </body>
  59. </html>