Not only check structure, check validity of Grid also

这个提交包含在:
int2001 2023-12-30 14:03:51 +00:00
父节点 c49b8e2163
当前提交 f102e7efd4
找不到此签名对应的密钥
GPG 密钥 ID: DFB1C13CD2DB037B

查看文件

@ -3279,12 +3279,18 @@ function lotw_last_qsl_date($user_id) {
if (isset($record['gridsquare'])){ if (isset($record['gridsquare'])){
$a_grids=explode(',',$record['gridsquare']); // Split at , if there are junctions $a_grids=explode(',',$record['gridsquare']); // Split at , if there are junctions
foreach ($a_grids as $singlegrid) { foreach ($a_grids as $singlegrid) {
$singlegrid=strtoupper($singlegrid);
if (strlen($singlegrid) == 4) $singlegrid .= "LL"; // Only 4 Chars? Fill with center "LL" as only A-R allowed
if (strlen($singlegrid) == 6) $singlegrid .= "55"; // Only 6 Chars? Fill with center "55"
if (strlen($singlegrid) == 8) $singlegrid .= "LL"; // Only 8 Chars? Fill with center "LL" as only A-R allowed
if (strlen($singlegrid)%2 != 0) { // Check if grid is structually valid if (strlen($singlegrid)%2 != 0) { // Check if grid is structually valid
$record['gridsquare']=''; // If not: Set to '' $record['gridsquare']=''; // If not: Set to ''
} else {
if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$/', $singlegrid)) $record['gridsquare']='';
} }
} }
$input_gridsquare = $record['gridsquare']; $input_gridsquare = $record['gridsquare'];
}else{ } else {
$input_gridsquare = NULL; $input_gridsquare = NULL;
} }
@ -3292,12 +3298,18 @@ function lotw_last_qsl_date($user_id) {
if (isset($record['vucc_grids'])){ if (isset($record['vucc_grids'])){
$a_grids=explode(',',$record['vucc_grids']); // Split at , if there are junctions $a_grids=explode(',',$record['vucc_grids']); // Split at , if there are junctions
foreach ($a_grids as $singlegrid) { foreach ($a_grids as $singlegrid) {
$singlegrid=strtoupper($singlegrid);
if (strlen($singlegrid) == 4) $singlegrid .= "LL"; // Only 4 Chars? Fill with center "LL" as only A-R allowed
if (strlen($singlegrid) == 6) $singlegrid .= "55"; // Only 6 Chars? Fill with center "55"
if (strlen($singlegrid) == 8) $singlegrid .= "LL"; // Only 8 Chars? Fill with center "LL" as only A-R allowed
if (strlen($singlegrid)%2 != 0) { // Check if grid is structually valid if (strlen($singlegrid)%2 != 0) { // Check if grid is structually valid
$record['vucc_grids']=''; // If not: Set to '' $record['vucc_grids']=''; // If not: Set to ''
} else {
if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$/', $singlegrid)) $record['vucc_grids']='';
} }
} }
$input_vucc_grids = $record['vucc_grids']; $input_vucc_grids = $record['vucc_grids'];
}else{ } else {
$input_vucc_grids = NULL; $input_vucc_grids = NULL;
} }