# HG changeset patch # User Matti Hamalainen # Date 1707663455 -7200 # Node ID 2a535f601677f39251d0d7d50025414e52b51f7b # Parent 1436eecc751f55a5be1e74e0ab7cd4b355659d3e Move parsing of timestamp and coders etc. a bit in preparation for further changes. diff -r 1436eecc751f -r 2a535f601677 www/common.inc.php --- 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 ".$record[4]." 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 ".$record[4]." 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