CVS: phpweather/db pw_db_common.php,1.10,1.11 pw_db_mysql.php,1.3,1.4...
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-03-26 18:52:46
|
Update of /cvsroot/phpweather/phpweather/db In directory usw-pr-cvs1:/tmp/cvs-serv14260 Modified Files: pw_db_common.php pw_db_mysql.php pw_db_pgsql.php Log Message: It's now up to the database backend to do it's own quoting on the data it receives in insert_metar() and update_metar(). This is because the backends have different needs: the 'real' databases want quotes quoted whereas the dba backend has to do escape colons. Index: pw_db_common.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_common.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- pw_db_common.php 26 Mar 2002 17:37:58 -0000 1.10 +++ pw_db_common.php 26 Mar 2002 18:52:43 -0000 1.11 @@ -104,17 +104,17 @@ $icao = substr($metar, 0, 4); if (list($m, $t) = $this->get_metar($icao)) { - if ($t <= $timestamp) { + if ($t < $timestamp && $m != $metar) { /* The METAR in the database is older than the new METAR, so * we go ahead with the update: */ - $this->update_metar($icao, addslashes($metar), $timestamp); + $this->update_metar($icao, $metar, $timestamp); $updated++; } else { $skipped++; } } else { /* There's no timestamp to check against in this case: */ - $this->insert_metar($icao, addslashes($metar), $timestamp); + $this->insert_metar($icao, $metar, $timestamp); $inserted++; } Index: pw_db_mysql.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_mysql.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- pw_db_mysql.php 25 Mar 2002 19:32:18 -0000 1.3 +++ pw_db_mysql.php 26 Mar 2002 18:52:43 -0000 1.4 @@ -173,7 +173,7 @@ */ function insert_metar($icao, $metar, $timestamp) { $this->query("INSERT INTO " . $this->properties['db_metars'] . - " SET icao = '$icao', metar = '$metar', " . + " SET icao = '$icao', metar = '" . addslashes($metar) . "', " . "timestamp = FROM_UNIXTIME($timestamp)"); } @@ -189,7 +189,7 @@ */ function update_metar($icao, $metar, $timestamp) { $this->query("UPDATE " . $this->properties['db_metars'] . - " SET metar = '$metar', " . + " SET metar = '" . addslashes($metar) . "', " . "timestamp = FROM_UNIXTIME($timestamp) " . "WHERE icao = '$icao'"); } Index: pw_db_pgsql.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_pgsql.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- pw_db_pgsql.php 20 Mar 2002 19:26:50 -0000 1.2 +++ pw_db_pgsql.php 26 Mar 2002 18:52:44 -0000 1.3 @@ -157,7 +157,8 @@ */ function insert_metar($station, $metar, $timestamp) { $this->query('INSERT INTO ' . $this->properties['db_metars'] . - " SET station = '$station', metar = '$metar', " . + " SET station = '$station', " . + "metar = '" . addslashes($metar) . "', " . "timestamp = FROM_UNIXTIME($timestamp)"); } @@ -173,7 +174,8 @@ */ function update_metar($station, $metar, $timestamp) { $this->query('UPDATE ' . $this->properties['db_metars'] . - " SET metar = '$metar', timestamp = '$timestamp' " . + " SET metar = '" . addslashes($metar) . + "', timestamp = '$timestamp' " . "WHERE station = '$station'"); } |