changeset 52:5ecb69069be3

PHP 8 fixes.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 19 Jun 2023 02:28:32 +0300
parents 568f680e9d25
children b09aff132deb
files index.php info.php
diffstat 2 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Fri Sep 24 19:12:32 2021 +0300
+++ b/index.php	Mon Jun 19 02:28:32 2023 +0300
@@ -204,13 +204,14 @@
   "  <td>\n".
   "   <select multiple=\"multiple\" size=\"10\" name=\"h[]\">\n";
 
-reset($matTransNames);
-next($matTransNames);
-while (list($key, $value) = each($matTransNames))
+foreach ($matTransNames as $key => $value)
 {
-  echo "    <option".
-    (isset($setHideColumns[$key]) ? " selected=\"selected\"" : "").
-    " value=\"$key\">".chentities($value)."</option>\n";
+  if ($key != 0)
+  {
+    echo "    <option".
+      (isset($setHideColumns[$key]) ? " selected=\"selected\"" : "").
+      " value=\"$key\">".chentities($value)."</option>\n";
+  }
 }
 
 echo
@@ -343,14 +344,11 @@
         echo stGetTC("td", $col);
         if (is_array($kvalue))
         {
-          // Arrays need special handling, and is bit messy
-          reset($kvalue);
-
-          if (list($nam, $lode) = each($kvalue))
-            echo chentities($matTransTable[$kkey][$lode]);
-
-          while (list($nam, $lode) = each($kvalue))
-            echo ", ".chentities($matTransTable[$kkey][$lode]);
+          echo implode(", ",
+            array_map(function($lode) use ($kkey, $matTransTable)
+            {
+              return chentities($matTransTable[$kkey][$lode]);
+            }, $kvalue));
         }
         else
         {
--- a/info.php	Fri Sep 24 19:12:32 2021 +0300
+++ b/info.php	Mon Jun 19 02:28:32 2023 +0300
@@ -136,6 +136,7 @@
 //
 // Actual main code begins
 //
+$setShowMat = FALSE;
 if (($tmp = stGetRequestItem("m", FALSE, TRUE)) !== FALSE)
 {
   $tmp = preg_replace("/ +/", " ", preg_replace("/[^a-z ]/", " ", strtolower($tmp)));
@@ -155,7 +156,7 @@
     $setShowOnly = $tmp;
 }
 else
-if (isset($matDataTable[$setShowMat]))
+if ($setShowMat !== FALSE && isset($matDataTable[$setShowMat]))
 {
   // Get showOnly type from material class
   $mtype = $matDataTable[$setShowMat][14];
@@ -261,7 +262,7 @@
 //
 // Now, act accordingly ..
 //
-if (isset($setShowMat))
+if ($setShowMat !== FALSE)
 {
   //
   // We are showing information about one specific material