Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv29334 Modified Files: configurator.php Log Message: Because of the special demands of db_null, we now insert all the stations in one operation by calling $this->db->insert_stations(). Index: configurator.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/configurator.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- configurator.php 2001/05/20 13:07:16 1.5 +++ configurator.php 2001/06/27 11:32:25 1.6 @@ -250,15 +250,6 @@ 'connecting to the database, then please specify it ' . 'here. If not, then just leave this field blank.'); -$properties['db_path'] = - new text('db_path', - 'PHPWEATHER_BASE_DIR', - 'If you\'re using a text-style database, then use ' . - 'this option to select the directory you would like ' . - 'to use, for the database-files. If you wan\'t '. - 'PHP Weather to use it\'s base-directory, then leave ' . - 'this option at \'PHPWEATHER_BASE_DIR\'.'); - $properties['db_metars'] = new text('db_metars', 'metars', @@ -271,6 +262,13 @@ 'This is the name of the database/table that is used ' . 'to store the names of the stations.'); +$properties['db_countries'] = + new text('db_countries', + 'countries', + 'This is the name of the database that is used to ' . + 'store the names of the countries together with ' . + 'country-codes.'); + $properties['db_type'] = new select('db_type', array('null' => 'No database at all', @@ -356,7 +354,7 @@ /* We first check to see, if there's already a config-file. */ if (file_exists('defaults.php')) { - /* We make a backup-copy of the file */ + /* We make a copy of the file */ $new_filename = 'defaults.' . time() . '.php'; if (@copy('defaults.php', $new_filename)) { $fp = @fopen('defaults.php', 'w'); @@ -379,38 +377,39 @@ echo "<p>A configuration file could <b>not</b> be written. You should copy the above configuration to a file, and manually save it as <code>default.php</code>.\n"; } - if ($db_type != 'null') { - echo "<p>Click <a href=\"configurator.php?action=do_sql\">here</a> to create the necessary databases.</p>\n"; - } else { - echo "<p>You're all set!</p>\n"; - } + echo '<p>Click <a href="configurator.php?action=do_sql&time=' . time() . +"\">here</a> to create the necessary databases.</p>\n"; + } elseif ($action == 'do_sql') { -define('PHPWEATHER_BASE_DIR', getcwd()); -require('db_layer.php'); +define('PHPWEATHER_BASE_DIR', dirname(__FILE__)); +require(PHPWEATHER_BASE_DIR . '/db_layer.php'); $db = new db_layer(array()); if ($db->db->create_tables()) { - $rows = 0; - $countries = 0; + $num_rows = 0; + $num_countries = 0; echo "<p>The database has been configured. It will now be filled with data.</p>\n"; $fp = fopen('stations.csv', 'r'); while ($row = fgets($fp, 1024)) { $row = trim($row); if (substr($row, 0, 2) == '##' && substr($row, -2) == '##') { /* We've found a country */ - $country = substr($row, 3, -3); - $countries++; - echo "<p>Now processing stations in $country.</p>\n"; + $cc = substr($row, 3, 2); // The country-code. + $country = substr($row, 6, -3); // The name of the country. + $countries[$cc] = $country; + $num_countries++; + // echo "<p>Now processing stations in $country.</p>\n"; } elseif ($row[0] != '#' && $row != '') { list($icao, $name) = explode(';', $row, 2); - $rows++; - $db->db->insert_station($icao, $name, $country); + $num_rows++; + $data[$cc][$icao] = $name; } } - echo "<p>Data about $rows stations from $countries countries were inserted.</p>\n"; + $db->db->insert_stations($data, $countries); + + echo "<p>Data about $num_rows stations from $num_countries countries were +inserted.</p>\n"; } else { echo "<p>The database was <b>not</b> configured!</p>\n"; } _______________________________________________ PHPWeather-checkins mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/phpweather-checkins