* * This file is a Php port of "examples/export.c" * which is: * Copyright (c) 2006 Sam Hocevar * All Rights Reserved * * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What the Fuck You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ define('WIDTH', 80); define('HEIGHT', 32); $pixels = imagecreatetruecolor(256, 256); $exports = caca_get_export_list(); $file = isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : NULL; $filename = isset($_FILES['file']) ? $_FILES['file']['name'] : NULL; $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : NULL; if((! $format) || (! array_key_exists($format, $exports))) { header("Content-type: text/html; charset=UTF-8"); ?> libcaca export test program
(optional)
<><><> <>--<>]"); caca_put_str($cv, WIDTH / 2 - 8, HEIGHT / 2 - 2, "[ドラゴン ボーレ]"); caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ"); caca_put_str($cv, WIDTH / 2 - 5, HEIGHT / 2 + 4, "(\") \\o/ <&>"); caca_set_attr($cv, CACA_BOLD); caca_put_str($cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold"); caca_set_attr($cv, CACA_BLINK); caca_put_str($cv, WIDTH / 2 - 9, HEIGHT / 2 + 3, "Blink"); caca_set_attr($cv, CACA_ITALICS); caca_put_str($cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics"); caca_set_attr($cv, CACA_UNDERLINE); caca_put_str($cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline"); caca_set_attr($cv, 0); caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE); caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA "); for($x = 0; $x < 16; $x++) { caca_set_color_argb($cv, 0xff00 | $x, 0xf00f | ($x << 4)); caca_put_char($cv, WIDTH / 2 - 7 + $x, HEIGHT / 2 + 6, ord('#')); } } $content_type_map = array( 'ansi' => 'text/plain; charset=CP437', 'utf8' => 'text/plain; charset=UTF-8', 'utf8cr' => 'text/plain; charset=UTF-8', 'html' => 'text/html; charset=UTF-8', 'html3' => 'text/html; charset=UTF-8', 'bbfr' => 'text/plain; charset=UTF-8', 'irc' => 'text/plain; charset=UTF-8', 'ps' => 'application/postscript', 'svg' => 'image/svg+xml', 'tga' => 'image/x-targa' ); $download_extension_map = array( 'caca' => 'caca', 'ansi' => 'txt', 'utf8' => 'txt', 'utf8cr' => 'txt', 'irc' => 'txt', 'tga' => 'tga' ); $inline_extension_map = array( 'bbfr' => 'txt', 'ps' => 'ps', 'svg' => 'svg' ); if (! array_key_exists($format, $content_type_map)) $content_type = 'application/octet-stream'; else $content_type = $content_type_map[$format]; header('Content-Type: ' . $content_type); if (array_key_exists($format, $download_extension_map)) header('Content-Disposition: attachment; filename=export.' . $download_extension_map[$format]); else if (array_key_exists($format, $inline_extension_map)) header('Content-Disposition: inline; filename=export.' . $inline_extension_map[$format]); echo caca_export_string($cv, $format); ?>