changeset 2589:2a535f601677

Move parsing of timestamp and coders etc. a bit in preparation for further changes.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 11 Feb 2024 16:57:35 +0200
parents 1436eecc751f
children f464c7064b81
files www/common.inc.php
diffstat 1 files changed, 24 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/www/common.inc.php	Sun Feb 11 16:49:49 2024 +0200
+++ b/www/common.inc.php	Sun Feb 11 16:57:35 2024 +0200
@@ -305,29 +305,6 @@
 
     if (preg_match("/^(\d+)\s*;\s*(\d+)\s*;\s*([0-3][A-Za-z%!\?\-]*)\s*;\s*([^;]+)\s*;\s*(.*?)\s*;\s*(.*?)\s*;\s*(.*?)\s*;\s*(.*?)\s*$/", $inLine, $record))
     {
-      // Split coder names
-      if (strlen($record[5]) > 0)
-        mpAddLocNames($coders, preg_split("/\s*,\s*/", $record[5]));
-      else
-        $coders = [];
-
-      // Get timestamp
-      if (strlen($record[6]) > 0)
-      {
-        if (sscanf($record[6], "%02d.%02d.%04d", $aday, $amonth, $ayear) == 3)
-        {
-          if (($added = mktime(0, 0, 0, $amonth, $aday, $ayear)) === FALSE)
-            $added = -1;
-        }
-        else
-        {
-          mpError("Location <b>".$record[4]."</b> has invalid timestamp '".$record[6]."'");
-          $added = -1;
-        }
-      }
-      else
-        $added = -1;
-
       // Get location names
       mpAddLocNames($names, preg_split("/\s*\|\s*/", $record[4]));
 
@@ -391,6 +368,30 @@
 
         mpGetGlobalCoords($filename, $record[1], $record[2], $glx, $gly);
 
+        // Split coder names
+        if (strlen($record[5]) > 0)
+          mpAddLocNames($coders, preg_split("/\s*,\s*/", $record[5]));
+        else
+          $coders = [];
+
+        // Get timestamp
+        $stamp = $record[6];
+        if (strlen($stamp) > 0)
+        {
+          if (sscanf($stamp, "%02d.%02d.%04d", $aday, $amonth, $ayear) == 3)
+          {
+            if (($added = mktime(0, 0, 0, $amonth, $aday, $ayear)) === FALSE)
+              $added = -1;
+          }
+          else
+          {
+            mpError("Location <b>".$record[4]."</b> has invalid timestamp '".$record[6]."'");
+            $added = -1;
+          }
+        }
+        else
+          $added = -1;
+
         // Add location to array of locations
         $locations[$id] = [
           "name" => $name, // NOTE! Name field should be the first one in this list due to how we are abusing asort() etc