diff www/loc.php @ 1329:bc4b7535a576

Sync.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 Aug 2012 08:39:31 +0300
parents ab28c4ddf8b0
children 2f142b33e4ed
line wrap: on
line diff
--- a/www/loc.php	Mon Jun 25 21:09:02 2012 +0300
+++ b/www/loc.php	Tue Aug 14 08:39:31 2012 +0300
@@ -124,7 +124,7 @@
 
 echo " of ";
 
-if (isset($continentList[$setName])) {
+if (isset($setName) && isset($continentList[$setName])) {
   echo $continentList[$setName][0].
   ($continentList[$setName][3] ? " in " : " continent in ");
 }
@@ -175,47 +175,58 @@
 </div>
 
 <?
+function qcheck($arr, $key, &$result)
+{
+  if (isset($key) && isset($arr[$key]))
+  {
+    $result = $arr[$key];
+    return TRUE;
+  }
+  else
+  {
+    unset($result);
+    return FALSE;
+  }
+}
+
 /* Wizard/coder/creator information box
  */
 if (isset($coderName)) {
   if (isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) {
-
-  // Profile picture  
-  $s = $wizTable[$coderName]["imageURL"];
-  if (isset($s)) {
-    if (substr($s, 0, 6) == "bat://")
+    // Profile picture
+    if (qcheck($wizTable[$coderName], "imageURL", &$s)) {
+      // XXX: backwards compatibility check
+      if (substr($s, 0, 6) == "bat://")
+        $s = "img/unknown.png";
+    } else
       $s = "img/unknown.png";
-  } else
-    $s = "img/unknown.png";
 
-  echo "<div class=\"wizinfo\">\n <table>\n  <tr>\n".
-  "   <td class=\"img\"><img src=\"".$s."\" alt=\"".$coderName."\" /></td>\n".
-  "   <td class=\"info\">\n".
-  "    <h2>".$coderName."</h2>\n";
+    echo "<div class=\"wizinfo\">\n <table>\n  <tr>\n".
+    "   <td class=\"img\"><img src=\"".$s."\" alt=\"".$coderName."\" /></td>\n".
+    "   <td class=\"info\">\n".
+    "    <h2>".$coderName."</h2>\n";
 
-  // Description block
-  $s = $wizTable[$coderName]["desc"];
-  if (isset($s)) {
-    $s = preg_replace("/\~([A-Z][a-z]+)\~/i", "<a href=\"".$_SERVER["PHP_SELF"]."?a=\${1}\">\${1}</a>", $s);
+    // Description block
+    if (qcheck($wizTable[$coderName], "desc", &$s)) {
+      $s = preg_replace("/\~([A-Z][a-z]+)\~/i", "<a href=\"".$_SERVER["PHP_SELF"]."?a=\${1}\">\${1}</a>", $s);
 
-    foreach ($specTags as $tag => $rep)
-      $s = preg_replace("/\[".$tag."\]/i", $rep, $s);
+      foreach ($specTags as $tag => $rep)
+        $s = preg_replace("/\[".$tag."\]/i", $rep, $s);
 
-    echo "    <p>".$s."</p>\n";
-  }
+      echo "    <p>".$s."</p>\n";
+    }
 
-  // Links, etc.
-  echo "    [<a href=\"".fingerURL($coderName)."\">Finger</a>]\n";
+    // Links, etc.
+    echo "    [<a href=\"".fingerURL($coderName)."\">Finger</a>]\n";
 
-  $s = $wizTable[$coderName]["homeURL"];
-  if (isset($s)) {
-    if ($s == "bat")
-      $s = "http://wiz.bat.org/~".strtolower($coderName)."/";
-      
-    echo "    [<a href=\"".$s."\">Homepage</a>]<br />\n";
-  }
-  
-  echo "   </td>\n  </tr>\n </table>\n</div>\n";
+    if (qcheck($wizTable[$coderName], "homeURL", &$s)) {
+      if ($s == "bat")
+        $s = "http://wiz.bat.org/~".strtolower($coderName)."/";
+        
+      echo "    [<a href=\"".$s."\">Homepage</a>]<br />\n";
+    }
+    
+    echo "   </td>\n  </tr>\n </table>\n</div>\n";
   } else
     $errorStr = "No such wizard.";
 }