changeset 17:4a3508ac4745

Fixes.
author ccr@tnsp.org
date Sat, 08 Jan 2011 23:41:34 +0200
parents 5bfa7a3a6e7e
children 1084518d214a
files index.php
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Sat Jan 08 23:33:12 2011 +0200
+++ b/index.php	Sat Jan 08 23:41:34 2011 +0200
@@ -204,20 +204,25 @@
   " <tr>\n".
   "  <th></th>\n";
 
+  $imgWidth = 12;
+  $imgHeight = 80;
   foreach ($data2 as $key => $val) {
     $str = is_array($val) ? $val[0]." / ".$val[1] : $val;
-    echo "  <th><img src=\"textimg.php?text=".urlencode($str)."\" alt=\"".htmlentities($str)."\" width=\"12\" height=\"80\"></th>\n";
+
+    $filename = "txt_".preg_replace("/[^a-z0-9]/", "_", strtolower($str)).".png";
+    echo "  <th><img src=\"".urlencode($filename)."\" alt=\"".htmlentities($str)."\" width=\"".$imgWidth."\" height=\"".$imgHeight."\"></th>\n";
 
     if (!file_exists($filename)) {
-      $image = imagecreate(12, 80);
+      $image = imagecreate($imgWidth, $imgHeight);
       $c_black = imagecolorallocate($image,   0,   0,   0);
       $c_white = imagecolorallocate($image, 255, 255, 255);
 
       imagefill($image, 0, 0, $c_black);
-      imagestringup($image, 2, -2, 78, $text, $c_white);
+      imagestringup($image, 2, -2, 78, $str, $c_white);
 
       imagepng($image, $filename);
       imagedestroy($image);
+      chmod($filename, 0644);
     }
   }