Skip to content

Commit

Permalink
Release/1.7.9 test2 (#215)
Browse files Browse the repository at this point in the history
* Fix incorrect db table/column in update

* Updated translations

* Fix lat/long weather module validation
  • Loading branch information
dasgarner committed Sep 27, 2016
1 parent 4e3e36b commit dafd73e
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions modules/forecastio.module.php
Expand Up @@ -679,6 +679,12 @@ private function getForecastData($displayId)
$defaultLong = $this->GetOption('longitude', $defaultLong);
}

// Validate lat/long
if (!$this->isValidLatitude($defaultLat) || !$this->isValidLongitude($defaultLong)) {
Debug::LogEntry('audit', 'Invalid lat/long');
return false;
}

$apiKey = $this->GetSetting('apiKey');
if ($apiKey == '')
die(__('Incorrectly configured module'));
Expand Down Expand Up @@ -905,20 +911,22 @@ public function IsValid() {
return 1;
}

private function isValidLatitude($latitude){
if (preg_match("/^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6}$/", $latitude)) {
return true;
} else {
private function isValidLatitude($latitude) {
if (!is_numeric($latitude))
return false;
}

$latitude = doubleval($latitude);

return ($latitude >= -90 && $latitude <= 90);
}

private function isValidLongitude($longitude){
if (preg_match("/^-?([1]?[1-7][1-9]|[1]?[1-8][0]|[1-9]?[0-9])\.{1}\d{1,6}$/", $longitude)) {
return true;
} else {
private function isValidLongitude($longitude) {
if (!is_numeric($longitude))
return false;
}

$longitude = doubleval($longitude);

return ($longitude >= -180 && $longitude <= 180);
}
}
?>

0 comments on commit dafd73e

Please sign in to comment.