Implemented database refresh key: import.php?key=[user specified refresh_key] (Closes #1)

This commit is contained in:
Ismo Vuorinen
2013-11-22 09:27:39 +02:00
parent c9d8a92f3d
commit e0cda5cfa0
2 changed files with 14 additions and 1 deletions

View File

@@ -17,7 +17,8 @@ $config = array(
'user' => 'username',
'password' => 'password',
'table' => 'airports',
'create_table' => true
'create_table' => true,
'refresh_key' => 'lentolaskuridatabasekey' // You should change this to your reset key
);
// ----

View File

@@ -18,6 +18,18 @@ if (is_readable('config.php')) {
die("Couldn't find configuration file. Please check the installation guide.");
}
/**
* Test if import.php?key= value matches $config['refresh_key']
* If matches continue, else stop processing with error message.
*/
$key = (empty($_GET['key'])) ? null : $_GET['key'];
if ($config['refresh_key'] !== $key || empty($key)) {
$mysqli->close();
die("Wrong refresh_key, please check configuration file for the corrent key.");
}
/**
* If we can see lentolaskuri.sql and config.php setting
* $config['create_table'] is true, we try to create table for airports.