diff --git a/application/libraries/Callbook.php b/application/libraries/Callbook.php index e6981a7ec..143214f16 100644 --- a/application/libraries/Callbook.php +++ b/application/libraries/Callbook.php @@ -50,6 +50,11 @@ class Callbook { if (! array_key_exists('geoloc', $callbook)) { $callbook['geoloc'] = ''; } + // qrz.com gives AA00aa if the user deleted his grid from the profile + $this->ci->load->library('qra'); + if (!$this->ci->qra->validate_grid($callbook['gridsquare'])) { + $callbook['gridsquare'] = ''; + } return $callbook; } diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index c7c63063f..5c0600943 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -201,6 +201,10 @@ class Qra { } function validate_grid($grid) { + // (Try to) Detect placeholders like AA00aa (returned from qrz.com for example) + if (strlen($grid) == 6 && strtoupper($grid) == 'AA00AA') { + return false; + } // Allow 6-digit locator if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}$/', $grid)) return true; // Allow 4-digit locator @@ -215,6 +219,7 @@ class Qra { else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}[0-9]{2}$/', $grid)) return true; // Allow 10-digit locator else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}$/', $grid)) return true; + return false; } }