/[drupal]/contributions/sandbox/bonvga/fblike/images/picto-title.php
ViewVC logotype

Contents of /contributions/sandbox/bonvga/fblike/images/picto-title.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sun Nov 4 22:07:33 2007 UTC (2 years ago) by bonvga
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Initial import
1 <?php
2 // ; $Id: picto-title.php,v 1.3 2007/11/01 17:50:53 bonvga Exp $
3
4 // See the README.TXT file in the 'fonts' directory.
5
6 $config = array(
7 "logo" => array(
8 "font_path" => "fonts/LiberationSans-Bold.ttf",
9 "background_color" => "1E4470",
10 "text_color" => "FFFFFF",
11 "fixed_height" => 44,
12 "font_size" => 20
13 ),
14 "slogan" => array(
15 "font_path" => "fonts/LiberationSans-Italic.ttf",
16 "background_color" => "1E4470",
17 "text_color" => "FFFFFF",
18 "fixed_height" => 44,
19 "font_size" => 14
20 ),
21 "title" => array(
22 "font_path" => "fonts/LiberationSans-Regular.ttf",
23 "background_color" => "DBE3E7",
24 "text_color" => "446285",
25 "fixed_height" => 34,
26 "font_size" => 12
27 ),
28 );
29 $cache_directory = 'cache';
30
31 $text = $_GET["text"];
32 if ($text=="") {
33 $text = "Default title";
34 }
35 $text = html_entity_decode($text);
36 $text = strip_tags($text);
37 $text = stripcslashes($text);
38
39 $mode = $_GET["mode"];
40 if ($mode=="") {
41 $mode = "title";
42 }
43 if ($mode=="test") {
44 echo "PHP version : ".phpversion()."<br />";
45 echo "Zend version : ".zend_version()."<br />";
46 if ($check = get_extension_funcs('gd')) {
47 echo "GD support is available<br />";
48 if (in_array('gd_info', $check)) {
49 echo "function gd_info : OK<br />";
50 $gdinfo = gd_info();
51 echo "GD version : ".$gdinfo['GD Version']." (".$gdinfo['FreeType Linkage'].")<br />";
52 echo "FreeType Support : ".(($gdinfo['FreeType Support'])?"Enable":"Disable")."<br />";
53 echo "PNG Support : ".(($gdinfo['PNG Support'])?"Enable":"Disable")."<br />";
54 echo "<!--"; print_r($gdinfo); echo "-->";
55 } else {
56 echo "function gd_info : Not found<br />";
57 }
58 if (in_array('imagettfbbox', $check)) {
59 echo "function imagettfbbox : OK<br />";
60 } else {
61 echo "function imagettfbbox : Not found<br />";
62 }
63 if (in_array('imagecreatetruecolor', $check)) {
64 echo "function imagecreatetruecolor : OK<br />";
65 } else {
66 echo "function imagecreatetruecolor : Not found<br />";
67 }
68 if (in_array('imagecolorallocate', $check)) {
69 echo "function imagecolorallocate : OK<br />";
70 } else {
71 echo "function imagecolorallocate : Not found<br />";
72 }
73 if (in_array('imagefilledrectangle', $check)) {
74 echo "function imagefilledrectangle : OK<br />";
75 } else {
76 echo "function imagefilledrectangle : Not found<br />";
77 }
78 if (in_array('imagettftext', $check)) {
79 echo "function imagettftext : OK<br />";
80 } else {
81 echo "function imagettftext : Not found<br />";
82 }
83 if (in_array('imagepng', $check)) {
84 echo "function imagepng : OK<br />";
85 } else {
86 echo "function imagepng : Not found<br />";
87 }
88 if (in_array('imagedestroy', $check)) {
89 echo "function imagedestroy : OK<br />";
90 } else {
91 echo "function imagedestroy : Not found<br />";
92 }
93 } else {
94 echo "GD support is unavailable<br />";
95 }
96 if (is_writable($cache_directory)) {
97 echo "Cache directory : OK<br />";
98 } else {
99 echo "Cache directory : Not found or read only<br />";
100 }
101 exit;
102 }
103 if (!isset($config[$mode])) {
104 $mode = "title";
105 }
106
107 $filename = $cache_directory.'/'.md5(serialize($config[$mode]).$text).".png";
108 if (!file_exists($filename)) {
109 $textbox = imagettfbbox ($config[$mode]["font_size"], 0, $config[$mode]["font_path"], $text);
110 $image_width = $textbox[2]+20;
111 $im = imagecreatetruecolor($image_width, $config[$mode]["fixed_height"]);
112 $background_color = imagecolorallocate(
113 $im,
114 hexdec('0x'.$config[$mode]["background_color"]{0}.$config[$mode]["background_color"]{1}),
115 hexdec('0x'.$config[$mode]["background_color"]{2}.$config[$mode]["background_color"]{3}),
116 hexdec('0x'.$config[$mode]["background_color"]{4}.$config[$mode]["background_color"]{5})
117 );
118 $text_color = imagecolorallocate(
119 $im,
120 hexdec('0x'.$config[$mode]["text_color"]{0}.$config[$mode]["text_color"]{1}),
121 hexdec('0x'.$config[$mode]["text_color"]{2}.$config[$mode]["text_color"]{3}),
122 hexdec('0x'.$config[$mode]["text_color"]{4}.$config[$mode]["text_color"]{5})
123 );
124 imagefilledrectangle($im, 0, 0, ($image_width-1), ($config[$mode]["fixed_height"]-1), $background_color);
125 imagettftext($im, $config[$mode]["font_size"], 0, 10, (($config[$mode]["fixed_height"]-$textbox[5])/2), $text_color, $config[$mode]["font_path"], $text);
126 if (is_writable($cache_directory)) {
127 imagepng($im, $filename);
128 }
129 }
130 header("Content-type: image/png");
131 if (file_exists($filename)) {
132 readfile($filename);
133 } else {
134 imagepng($im);
135 }
136 if ($im) {
137 imagedestroy($im);
138 }
139 ?>

  ViewVC Help
Powered by ViewVC 1.1.2