mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Use validation function in Qra lib and extend by bogus grid detection
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user