annotate index.php @ 41:ebd29544477c

More improvements in visual style, etc.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Mar 2011 16:15:16 +0200
parents bb335b891605
children 4617c39366a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
1 <?
20
6359c4b4711a Added setting for image path; Added some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
2 // Settings
15
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
3 $dataFile = "results.txt";
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
4 $cacheFile = "cache.php";
20
6359c4b4711a Added setting for image path; Added some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
5 $imagePath = "img/";
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
6
20
6359c4b4711a Added setting for image path; Added some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
7 // Execution time measurement
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
8 $tick = array_sum(explode(" ", microtime()));
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
9
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
10 if (!extension_loaded('gd')) {
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
11 if (!dl('gd.so')) {
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
12 echo "Could not load extension GD!";
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
13 exit;
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
14 }
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
15 }
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
16
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
17 $dbModes = array(
40
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
18 "min" => array("Mineral", 0, "minerals"),
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
19 "org" => array("Organ", 1, "organs"),
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
20 "herb" => array("Herb", 2, "herbs"),
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
21 "list" => array("Potion list", 3, "potions"),
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
22 );
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
23
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
24 $dbNames = array(
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
25 array(
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
26 "adamantium", "aluminium", "anipium", "batium", "brass", "bronze",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
27 "cesium", "chromium", "cobalt", "copper", "darksteel", "diggalite",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
28 "dukonium", "duraluminium", "durandium", "electrum", "gold",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
29 "graphite", "hematite", "highsteel", "illumium", "indium", "iridium",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
30 "iron", "kryptonite", "lead", "magnesium", "mithril", "molybdenum",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
31 "mowgles", "mowglite", "nickel", "nullium", "osmium", "palladium",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
32 "pewter", "platinum", "potassium", "pyrite", "quicksilver", "rhodium",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
33 "silicon", "silver", "starmetal", "steel", "tadmium", "tin", "titanium",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
34 "tormium", "tungsten", "uranium", "vanadium", "zhentorium", "zinc"
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
35 ),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
36
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
37 array(
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
38 "antenna", "arm", "beak", "bladder", "brain", "ear", "eye", "foot",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
39 "gill", "heart", "horn", "kidney", "leg", "liver", "lung", "nose",
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
40 "paw", "snout", "spleen", "stomach", "tail", "tendril", "wing"
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
41 ),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
42
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
43 array(
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
44 array("apple", "wormwood"), array("barberry", "yarrow"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
45 array("blueberry", "wolfbane"), array("burdock", "chickweed"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
46 array("cabbage", "arnica"), array("carrot", "thistle"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
47 array("cauliflower", "costmary"), array("chicory", "borage"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
48 array("cotton", "mysticspinach"), array("crystalline", "jaslah"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
49 array("elder", "honeysuckle"), array("foxglove", "holly"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
50 array("garlic", "nightshade"), array("ginseng", "mistletoe"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
51 array("hemlock", "tomato"), array("henbane", "jimsonweed"),
30
19757b28401d Research.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
52 array("lettuce", "water_lily"), array("lobelia", "comfrey"),
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
53 array("mushroom", "mangrel"), array("onion", "moss"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
54 array("pear", "boneset"), array("plum", "sweetflag"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
55 array("potato", "mandrake"), array("raspberry", "bloodroot"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
56 array("rhubarb", "soapwort"), array("spinach", "hcliz"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
57 array("strawberry", "mugwort"), array("turnip", "mysticcarrot"),
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
58 array("vine_seed", "lungwort")
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
59 ),
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
60
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
61 array("sorted by mineral", "sorted by organ", "sorted by herb pair", "sorted by potion name"),
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
62 );
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
63
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
64
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
65 $dbDims = array();
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
66 foreach ($dbNames as $key => $data)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
67 $dbDims[$key] = count($data);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
68 $db = array();
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
69
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
70
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
71 function alch_matrix_clear($val = ".")
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
72 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
73 global $dbDims, $db;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
74
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
75 for ($x = 0; $x < $dbDims[0]; $x++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
76 for ($y = 0; $y < $dbDims[1]; $y++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
77 for ($z = 0; $z < $dbDims[2]; $z++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
78 $db[$x][$y][$z] = $val;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
79 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
80
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
81
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
82 function alch_matrix_set_col_if($x, $y, $z, $idx, $ifval, $setval, $equals = TRUE)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
83 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
84 global $dbDims, $db;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
85
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
86 if ($x < 0) { $col = 0; $x = &$i; } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
87 if ($y < 0) { $col = 1; $y = &$i; } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
88 { $col = 2; $z = &$i; }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
89
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
90 for ($i = 0; $i < $dbDims[$col]; $i++) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
91 if (($db[$x][$y][$z][$idx] == $ifval) == $equals)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
92 $db[$x][$y][$z][$idx] = $setval;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
93 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
94 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
95
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
96
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
97 function alch_find_pairs($item, $key)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
98 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
99 foreach ($item as $key => $val) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
100 $minTab[$val[0]]++;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
101 $orgTab[$val[1]]++;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
102 $herbTab[$val[2]]++;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
103
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
104 // why?
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
105 if ($val[0] == 255) $t = true;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
106 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
107
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
108 // why?
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
109 if ($t) return 0;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
110
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
111
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
112 // ??? is it necessary to go through the whole array?
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
113 foreach ($minTab as $key => $val) if ($val > 1) $min = $key;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
114 foreach ($orgTab as $key => $val) if ($val > 1) $org = $key;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
115 foreach ($herbTab as $key => $val) if ($val > 1) $her = $key;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
116
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
117 if ($min != "" && $org != "") alch_matrix_set_col_if($min, $org, -1, 1, "", "*", TRUE);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
118 if ($min != "" && $her != "") alch_matrix_set_col_if($min, -1, $her, 1, "", "*", TRUE);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
119 if ($org != "" && $her != "") alch_matrix_set_col_if( -1, $org, $her, 1, "", "*", TRUE);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
120 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
121
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
122
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
123 function array_search_multi($val, $arr)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
124 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
125 foreach ($arr as $key => $pair)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
126 if ($pair[0] == $val || $pair[1] == $val)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
127 return $key;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
128
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
129 return false;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
130 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
131
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
132
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
133 function alch_matrix_cell($r)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
134 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
135 $res = $r[0];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
136 switch ($r[0]) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
137 case "!": $class = "accepted"; break;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
138
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
139 case "?": $class = ($r[1] == "*") ? "pairclose" : "close"; break;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
140
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
141 case "-": if ($r[1] == "-") $class = "nomatch";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
142 else if ($r[1] == "*") $class = "pairno";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
143 else if ($r[1] !== "") $class = "noclose";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
144 else $class = "nomark";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
145 break;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
146
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
147 case ".": if ($r[1] == "*") $class = "pair";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
148 $res = "&nbsp;";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
149 break;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
150 default: $class = "notres"; break;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
151 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
152 echo "<td class=\"".$class."\" title=\"".$r."\">".$res."</td>";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
153 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
154
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
155
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
156 function alch_matrix_print($mode, $active)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
157 {
22
ef3920a6a688 Bugfix imagePath option.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
158 global $dbNames, $dbModes, $db, $imagePath;
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
159
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
160 $pkey = $dbModes[$mode][1];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
161
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
162 if ($pkey == 0) { $key1 = 2; $key2 = 1; $px = $active; $py = &$colKey; $pz = &$rowKey; } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
163 if ($pkey == 1) { $key1 = 2; $key2 = 0; $px = &$colKey; $py = $active; $pz = &$rowKey; } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
164 { $key1 = 1; $key2 = 0; $px = &$colKey; $py = &$rowKey; $pz = $active; }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
165
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
166 $pdata = $dbNames[$pkey];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
167 $data1 = $dbNames[$key1];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
168 $data2 = $dbNames[$key2];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
169
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
170 // Determine number of columns by number of cells
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
171 $max = count($pdata);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
172 if ($max / 3 > 10)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
173 $div = $max / 3;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
174 else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
175 $div = $max / 2;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
176
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
177 // Print selection for primary key
40
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
178 echo "<table class=\"seltable\" border=\"1\" cellspacing=\"0\">\n";
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
179 $n = 0;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
180 foreach ($pdata as $key => $val) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
181 if ($n == 0) echo " <tr>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
182
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
183 echo " <td class=\"".
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
184 ($key == $active ? "atab" : "tab").
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
185 "\"><a href=\"?".$mode."=".$key."\">";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
186
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
187 if (is_array($val))
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
188 echo htmlentities($val[0])."<br />".htmlentities($val[1]);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
189 else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
190 echo htmlentities($val);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
191
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
192 echo "</a></td>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
193
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
194 if (++$n >= $div) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
195 echo " </tr>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
196 $n = 0;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
197 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
198 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
199 if ($n != 0)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
200 echo " </tr>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
201
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
202
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
203 // Print mix table header
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
204 $str = is_array($pdata[0]) ? $pdata[$active][0]." or ".$pdata[$active][1] : $pdata[$active];
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
205
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
206 echo "</table>\n".
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
207 "<h1>".htmlentities($str)."</h1>\n".
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
208 "<table class=\"mixtable\" border=\"1\" cellspacing=\"0\">\n".
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
209 " <tr>\n".
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
210 " <th></th>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
211
17
ccr@tnsp.org
parents: 16
diff changeset
212 $imgWidth = 12;
ccr@tnsp.org
parents: 16
diff changeset
213 $imgHeight = 80;
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
214 foreach ($data2 as $key => $val) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
215 $str = is_array($val) ? $val[0]." / ".$val[1] : $val;
17
ccr@tnsp.org
parents: 16
diff changeset
216
20
6359c4b4711a Added setting for image path; Added some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
217 // Create image files for the text entries, if they don't already exist
23
6f96cdfbbbac And another bugfix of the same sort.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
218 $filename = "txt_".preg_replace("/[^a-z0-9]/", "_", strtolower($str)).".png";
6f96cdfbbbac And another bugfix of the same sort.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
219 echo " <th><img src=\"".$imagePath.urlencode($filename)."\" alt=\"".htmlentities($str)."\" width=\"".$imgWidth."\" height=\"".$imgHeight."\"></th>\n";
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
220
23
6f96cdfbbbac And another bugfix of the same sort.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
221 if (!file_exists($imagePath.$filename)) {
17
ccr@tnsp.org
parents: 16
diff changeset
222 $image = imagecreate($imgWidth, $imgHeight);
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
223 $c_black = imagecolorallocate($image, 0, 0, 0);
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
224 $c_white = imagecolorallocate($image, 255, 255, 255);
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
225
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
226 imagefill($image, 0, 0, $c_black);
17
ccr@tnsp.org
parents: 16
diff changeset
227 imagestringup($image, 2, -2, 78, $str, $c_white);
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
228
23
6f96cdfbbbac And another bugfix of the same sort.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
229 imagepng($image, $imagePath.$filename);
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
230 imagedestroy($image);
24
8032690680c7 Oops, chmod() was still not using the imagePath setting. Durr. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
231 chmod($imagePath.$filename, 0644);
16
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
232 }
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
233 }
5bfa7a3a6e7e Move image text creation functionality to main module.
ccr@tnsp.org
parents: 15
diff changeset
234
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
235 echo " </tr>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
236
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
237 // Print the table itself
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
238 foreach ($data1 as $rowKey => $rowVal) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
239 $str = is_array($rowVal) ? $rowVal[0]." / ".$rowVal[1] : $rowVal;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
240 echo " <tr><th>".htmlentities($str)."</th>";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
241 foreach ($data2 as $colKey => $colVal) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
242 alch_matrix_cell($db[$px][$py][$pz]);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
243 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
244 echo "</tr>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
245 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
246 echo "</table>\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
247 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
248
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
249
11
b76d8d6aed50 Enable cache usage again.
ccr@tnsp.org
parents: 10
diff changeset
250 // Select view mode based on script GET arguments
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
251 $mode = "min";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
252 $active = 0;
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
253 foreach ($dbModes as $name => $data) {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
254 if (isset($_GET[$name])) {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
255 $active = intval($_GET[$name]);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
256 if ($active < 0 || $active >= $dbDims[$data[1]])
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
257 $active = 0;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
258 $mode = $name;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
259 break;
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
260 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
261 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
262
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
263 ?>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
264 <html>
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
265 <head>
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
266 <title>Potion research tool - <? echo $dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")"; ?></title>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
267 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
268 <link href="alch.css" title="compact" rel="stylesheet" type="text/css">
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
269 </head>
41
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
270 <script type="text/javascript">
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
271 <!--
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
272 var savePos = 0;
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
273 function vis()
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
274 {
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
275 var e = document.getElementById('legend');
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
276 e.style.height = "3em";
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
277 if (e.style.top != "0px") {
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
278 savePos = e.style.top;
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
279 e.style.top = "0px";
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
280 } else {
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
281 e.style.top = savePos;
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
282 }
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
283 }
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
284 -->
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
285 </script>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
286 <body>
40
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
287 <div id="info">
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
288 <?
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
289
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
290 alch_matrix_clear();
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
291
11
b76d8d6aed50 Enable cache usage again.
ccr@tnsp.org
parents: 10
diff changeset
292 #if (1)
b76d8d6aed50 Enable cache usage again.
ccr@tnsp.org
parents: 10
diff changeset
293 if (filemtime($dataFile) > filemtime($cacheFile))
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
294 {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
295 $file = fopen($dataFile, "r");
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
296
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
297 while (($line = fgets($file)) !== FALSE) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
298 list ($m, $o, $h, $r) = preg_split("/\s+/", trim($line), 4);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
299
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
300 // Get indexes
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
301 $mn = array_search($m, $dbNames[0]);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
302 $on = array_search($o, $dbNames[1]);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
303 $hn = array_search_multi($h, $dbNames[2]);
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
304
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
305 if ($mn === false || $on === false || $hn === false) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
306 echo "# Invalid data: '$line'<br />\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
307 continue;
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
308 }
8
121a3bfd3424 Minor cleanups.
ccr@tnsp.org
parents: 7
diff changeset
309
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
310 if ($r== "-") {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
311 alch_matrix_set_col_if( -1, $on, $hn, 0, "!", "-", FALSE);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
312 alch_matrix_set_col_if($mn, -1, $hn, 0, "!", "-", FALSE);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
313 alch_matrix_set_col_if($mn, $on, -1, 0, "!", "-", FALSE);
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
314
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
315 $db[$mn][$on][$hn][1] = "-";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
316 }
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
317 else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
318 if ($r[0] == "?") {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
319 if ($r[1] != "?")
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
320 $mat[$r][] = array($mn, $on, $hn);
5
4d62b5fa9650 Cleanups, bugfixes.
ccr@tnsp.org
parents: 4
diff changeset
321
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
322 if ($db[$mn][$on][$hn][0] == "-") {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
323 $db[$mn][$on][$hn] = $r;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
324 $db[$mn][$on][$hn][0] = "-";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
325 } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
326 $db[$mn][$on][$hn] = $r;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
327 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
328 else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
329 if ($r[0] == "!") {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
330 $t = $r;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
331 $t[0] = "?";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
332
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
333 $mat[$t][] = array(255, 255, 255);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
334 $db[$mn][$on][$hn] = $r;
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
335 }
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
336 } // while
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
337
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
338 array_walk($mat, "alch_find_pairs");
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
339
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
340 $cache = @fopen($cacheFile, "w");
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
341 if ($cache !== false) {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
342 fwrite($cache, serialize($db));
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
343 fclose($cache);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
344 echo "Made a new cache.<br />\n";
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
345 } else
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
346 echo "Error writing cache file!<br />\n";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
347
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
348 } else {
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
349
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
350 $cache = @file_get_contents($cacheFile);
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
351
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
352 if ($cache !== false)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
353 $db = unserialize($cache);
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
354
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
355 if (isset($db) && $db !== false)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
356 echo "Using cache made at " . date ("F d Y H:i:s.", filemtime($cacheFile))."<br>";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
357 }
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
358
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
359
20
6359c4b4711a Added setting for image path; Added some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 17
diff changeset
360 // Calculate statistics
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
361 $results = array();
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
362 for ($x = 0; $x < $dbDims[0]; $x++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
363 for ($y = 0; $y < $dbDims[1]; $y++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
364 for ($z = 0; $z < $dbDims[2]; $z++)
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
365 $results[$db[$x][$y][$z][0]]++;
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
366
40
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
367 echo "<b>".$results["!"]."</b> found potions, ".
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
368 "<b>".$results["?"]."</b> active partial matches, ".
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
369 "<b>".$results["-"]."</b> combinations eliminated, ".
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
370 "<b>".$results["."]."</b> combinations untested.\n".
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
371 "</div>\n";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
372
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
373
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
374 function printItem($x, $y, $z, $s, &$index)
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
375 {
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
376 global $dbNames, $db;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
377 $index++;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
378 echo "<tr>".
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
379 "<th>".$index."</th>".
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
380 "<td>".$dbNames[0][$x]."</td>".
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
381 "<td>".$dbNames[1][$y]."</td>".
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
382 "<td>".$dbNames[2][$z][0]." / ".$dbNames[2][$z][1]."</td>".
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
383 "<td>".$s."</td></tr>";
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
384 }
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
385
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
386 function checkItem($x, $y, $z, &$index)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
387 {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
388 global $dbNames, $db;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
389 $s = $db[$x][$y][$z];
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
390 if ($s[0] == "!")
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
391 printItem($x, $y, $z, substr($s, 1), $index);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
392 }
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
393
40
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
394 echo "<div id=\"controls\">Change index key to ";
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
395 foreach ($dbModes as $id => $data)
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
396 echo "[<a href=\"?".$id."=0\">".$data[2]."</a>] ";
bb335b891605 Various improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
397 echo "</div>\n";
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
398
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
399 if ($mode == "list")
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
400 {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
401 $index = 0;
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
402 echo "<h1>".$dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")</h1>
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
403 <table class=\"potlist\">
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
404 <tr>
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
405 <th>#</th>
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
406 <th><a href=\"?list=0\">Mineral</a></th>
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
407 <th><a href=\"?list=1\">Organ</a></th>
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
408 <th><a href=\"?list=2\">Herb</a></th>
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
409 <th><a href=\"?list=3\">Potion</a></th>
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
410 </tr>
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
411 ";
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
412 if ($active == 0)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
413 {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
414 for ($x = 0; $x < $dbDims[0]; $x++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
415 for ($y = 0; $y < $dbDims[1]; $y++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
416 for ($z = 0; $z < $dbDims[2]; $z++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
417 checkItem($x, $y, $z, $index);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
418 }
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
419 else if ($active == 1)
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
420 {
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
421 for ($y = 0; $y < $dbDims[1]; $y++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
422 for ($x = 0; $x < $dbDims[0]; $x++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
423 for ($z = 0; $z < $dbDims[2]; $z++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
424 checkItem($x, $y, $z, $index);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
425 }
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
426 else if ($active == 2)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
427 {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
428 for ($z = 0; $z < $dbDims[2]; $z++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
429 for ($x = 0; $x < $dbDims[0]; $x++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
430 for ($y = 0; $y < $dbDims[1]; $y++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
431 checkItem($x, $y, $z, $index);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
432 }
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
433 else
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
434 {
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
435 $potions = array();
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
436 for ($z = 0; $z < $dbDims[2]; $z++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
437 for ($x = 0; $x < $dbDims[0]; $x++)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
438 for ($y = 0; $y < $dbDims[1]; $y++)
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
439 {
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
440 $s = $db[$x][$y][$z];
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
441 if ($s[0] == "!")
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
442 $potions[substr($s, 1)] = array($x, $y, $z);
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
443 }
34
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
444 ksort($potions);
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
445 foreach ($potions as $name => $data)
0989d8dab1df Add sorting functionality, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
446 printItem($data[0], $data[1], $data[2], $name, $index);
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
447 }
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
448 echo "</table>\n";
38
03d7fc455629 Improve potion listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
449 }
03d7fc455629 Improve potion listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
450 else
03d7fc455629 Improve potion listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
451 {
32
d30a532eae93 Add a simple found potions listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
452 alch_matrix_print($mode, $active);
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
453 ?>
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
454
41
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
455 <table id="legend" border="1" cellspacing="1" onmouseover="vis();">
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
456 <tr><th colspan="2" class="noframe">Legend</th></tr>
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
457 <tr><td width="10%" class="notres">&nbsp;</td><th class="noframe">Not researched yet</th></tr>
8
121a3bfd3424 Minor cleanups.
ccr@tnsp.org
parents: 7
diff changeset
458 <tr><td class="nomatch">-</td><th class="noframe">No match</th></tr>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
459 <tr><td class="nomark">-</td><th class="noframe">Marked to no potion by another no match.</th></tr>
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
460 <tr><td class="noclose">-</td><th class="noframe">2 materials match, marked as no potion by another no match.</th></tr>
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
461 <tr><td class="close">?</td><th class="noframe">2 materials match</th></tr>
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
462 <tr><td class="accepted">!</td><th class="noframe">Accepted potion</th></tr>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
463 <tr><td class="pair">&nbsp</td><th class="noframe">Known to be possible potion by other attempts</th></tr>
41
ebd29544477c More improvements in visual style, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
464 <tr><td colspan="2">AlchTool 1.9b &copy; 2006-2011 Jeskko &amp; Ggr Pupunen</td></tr>
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
465 </table>
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
466 <?
38
03d7fc455629 Improve potion listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
467 }
03d7fc455629 Improve potion listing mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
468
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
469 $tock = array_sum(explode(" ",microtime()));
10
cc85bbc6d61b Refactor code, modularize, clean up. Logic stays mostly the same, though.
ccr@tnsp.org
parents: 8
diff changeset
470 echo "Page took " . round(($tock - $tick),2) . " seconds to process.<br />";
0
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
471 ?>
a928c3c75c5f Initial import.
ccr@tnsp.org
parents:
diff changeset
472 </body>
3
c99ef0e7f8db Cleanups.
ccr@tnsp.org
parents: 0
diff changeset
473 </html>