changeset 20:6359c4b4711a

Added setting for image path; Added some comments.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Jan 2011 07:09:17 +0200
parents b2d28680cb29
children e20a847fbbac
files index.php
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Thu Jan 13 01:49:12 2011 +0200
+++ b/index.php	Fri Jan 14 07:09:17 2011 +0200
@@ -1,7 +1,10 @@
 <?
+// Settings
 $dataFile = "results.txt";
 $cacheFile = "cache.php";
+$imagePath = "img/";
 
+// Execution time measurement
 $tick = array_sum(explode(" ", microtime()));
 
 if (!extension_loaded('gd')) {
@@ -59,7 +62,6 @@
 $dbDims = array();
 foreach ($dbNames as $key => $data)
   $dbDims[$key] = count($data);
-
 $db = array();
 
 
@@ -209,7 +211,8 @@
   foreach ($data2 as $key => $val) {
     $str = is_array($val) ? $val[0]." / ".$val[1] : $val;
 
-    $filename = "txt_".preg_replace("/[^a-z0-9]/", "_", strtolower($str)).".png";
+    // Create image files for the text entries, if they don't already exist
+    $filename = $imagePath."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)) {
@@ -334,8 +337,8 @@
 }
 
 
+// Calculate statistics
 $results = array();
-
 for ($x = 0; $x < $dbDims[0]; $x++)
 for ($y = 0; $y < $dbDims[1]; $y++)
 for ($z = 0; $z < $dbDims[2]; $z++)