feat: add option to use secrets JSON file instead

This commit is contained in:
David Bailey 2023-12-11 23:30:39 +01:00
parent f02e6b3168
commit 4baa737d95
2 changed files with 13 additions and 2 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
/vendor/
/www/secrets
sftp.json

View file

@ -7,8 +7,16 @@ class MySQLAdapter {
public $data_directory;
function __construct() {
$this->raw = mysqli_connect(getenv('MYSQL_HOST'),
getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'), getenv('MYSQL_DATABASE'));
$db_params = json_decode(file_get_contents('secrets/db.json'), true);
if(null !== getenv('MYSQL_HOST')) {
$this->raw = mysqli_connect(getenv('MYSQL_HOST'),
getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'), getenv('MYSQL_DATABASE'));
}
else {
$this->raw = mysqli_connect($db_params['MYSQL_HOST'],
$db_params['MYSQL_USER'], $db_params['MYSQL_PASSWORD'], $db_params['MYSQL_DATABASE']);
}
$this->data_directory = 'raw';