Mercurial > hg > batmud > maputils
diff www/loc.php @ 1150:02fe48a608d7
Use APC for caching of location and wizard data.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 21 Jul 2011 20:38:06 +0300 |
parents | 52550f58cee5 |
children | e0794ddb605e |
line wrap: on
line diff
--- a/www/loc.php Thu Jul 21 20:36:17 2011 +0300 +++ b/www/loc.php Thu Jul 21 20:38:06 2011 +0300 @@ -64,22 +64,37 @@ if (preg_match("#^([a-z]{1,15})#i", $_GET["a"], $m)) { $coderName = $m[1]; $coderName = strtoupper(substr($coderName, 0, 1)).strtolower(substr($coderName, 1)); - $wizTable = readWizInfoFiles(); - } else + + $wizTable = apc_fetch("wizTable"); + if (empty($wizTable)) { + $wizTable = readWizInfoFiles(); + apc_store("wizTable", $wizTable, 3600); + } + } else { $coderName = "???"; + $errorStr = "Invalid wizard name."; + } } if (isset($_GET["n"])) { $locTable = array(); $setName = strtolower(basename($_GET["n"])); if (file_exists($setName.".loc")) { - parseLocFile($setName, $locTable, $applyFilter, $filter); + $locTable = apc_fetch("loc_".$setName); + if (empty($locTable)) { + parseLocFile($setName, $locTable, $applyFilter, $filter); + apc_store("loc_".$setName, $locTable, 3600); + } } else { $errorStr = "No such continent ID!"; unset($setName); } } else { - $locTable = readLocationFiles($applyFilter, $filter); + $locTable = apc_fetch("loc_locTable"); + if (empty($locTable)) { + $locTable = readLocationFiles($applyFilter, $filter); + apc_store("loc_locTable", $locTable, 3600); + } } @@ -158,7 +173,8 @@ <? /* Wizard/coder/creator information box */ -if (isset($coderName) && isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) { +if (isset($coderName)) { + if (isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) { // Profile picture $s = $wizTable[$coderName]["imageURL"]; @@ -196,6 +212,8 @@ } echo " </td>\n </tr>\n </table>\n</div>\n"; + } else + $errorStr = "No such wizard."; } @@ -354,6 +372,7 @@ } else { echo "<p><b>No locations known!</b></p>\n"; echo "</div>\n"; + $errorStr = "No locations known!"; } ?> </body>