cvs: pear /Services_Weather/Weather Metar.php

From: Date: Wed, 08 Mar 2006 12:33:22 +0000
Subject: cvs: pear /Services_Weather/Weather Metar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38970@lists.php.net to get a copy of this message
eru Wed Mar 8 12:33:22 2006 UTC Modified files: /pear/Services_Weather/Weather Metar.php Log: o Fixed missing quotation of SQL search (hh at fsck dot dk: Bug #6652) http://cvs.php.net/viewcvs.cgi/pear/Services_Weather/Weather/Metar.php?r1=1.85&r2=1.86&diff_format=u Index: pear/Services_Weather/Weather/Metar.php diff -u pear/Services_Weather/Weather/Metar.php:1.85 pear/Services_Weather/Weather/Metar.php:1.86 --- pear/Services_Weather/Weather/Metar.php:1.85 Thu Nov 17 08:19:41 2005 +++ pear/Services_Weather/Weather/Metar.php Wed Mar 8 12:33:22 2006 @@ -40,7 +40,7 @@ * @author Alexander Wirtz <alex@pc4p.net> * @copyright 2005 Alexander Wirtz * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Metar.php,v 1.85 2005/11/17 08:19:41 eru Exp $ + * @version CVS: $Id: Metar.php,v 1.86 2006/03/08 12:33:22 eru Exp $ * @link http://pear.php.net/package/Services_Weather * @link http://weather.noaa.gov/weather/metar.shtml * @link http://weather.noaa.gov/weather/taf.shtml @@ -1411,19 +1411,25 @@ // Try to part search string in name, state and country part // and build where clause from it for the select $location = explode(",", $location); + + // Trim, caps-low and quote the strings + for ($i = 0; $i < sizeof($location); $i++) { + $location[$i] = $this->_db->quote("%".strtolower(trim($location[$i]))."%"); + } + if (sizeof($location) == 1) { - $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; + $where = "LOWER(name) LIKE ".$location[0]; } elseif (sizeof($location) == 2) { - $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; - $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[1]))."%'"; + $where = "LOWER(name) LIKE ".$location[0]; + $where .= " AND LOWER(country) LIKE ".$location[1]; } elseif (sizeof($location) == 3) { - $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; - $where .= " AND LOWER(state) LIKE '%".strtolower(trim($location[1]))."%'"; - $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[2]))."%'"; + $where = "LOWER(name) LIKE ".$location[0]; + $where .= " AND LOWER(state) LIKE ".$location[1]; + $where .= " AND LOWER(country) LIKE ".$location[2]; } elseif (sizeof($location) == 4) { - $where = "LOWER(name) LIKE '%".strtolower(trim($location[0])).", ".strtolower(trim($location[1]))."%'"; - $where .= " AND LOWER(state) LIKE '%".strtolower(trim($location[2]))."%'"; - $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[3]))."%'"; + $where = "LOWER(name) LIKE ".substr($location[0], 0, -2).", ".substr($location[1], 2); + $where .= " AND LOWER(state) LIKE ".$location[2]; + $where .= " AND LOWER(country) LIKE ".$location[3]; } // Create select, locations with ICAO first

« previous php.pear.cvs (#38970) next »