diff --git a/.gitignore b/.gitignore index 848ff49..d399df6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -./assets/php/config.json \ No newline at end of file +assets/php/config.json \ No newline at end of file diff --git a/assets/php/example_config.json b/assets/php/example_config.json new file mode 100644 index 0000000..a2d5aa8 --- /dev/null +++ b/assets/php/example_config.json @@ -0,0 +1,7 @@ +{ + "host":"localhost", + "dbname": "db", + "user": "user", + "password": "pass", + "kind": "mysql" +} \ No newline at end of file diff --git a/assets/php/utils.php b/assets/php/utils.php index 3f7462c..0fa1cb0 100644 --- a/assets/php/utils.php +++ b/assets/php/utils.php @@ -3,11 +3,11 @@ $SESSION_COOKIE_NAME = "connection_id"; $MAX_COOKIE_LIFE = time() + 86400 * 30; // 30 days max +$config_array = json_decode(file_get_contents("config.json", true)); -$dsn = "mysql:dbname=food-inventory;host=localhost"; -$user = 'food-inventory'; -$password = 'xt3apB8uVbFIYJvp'; -$PDO = new PDO($dsn, $user, $password); +$dsn = $config_array->{"kind"} . ":dbname=" + . $config_array->{"dbname"} . ";host=" . $config_array->{"host"}; +$PDO = new PDO($dsn, $config_array->{"user"}, $config_array->{"password"}); $PDO->query('SET CHARSET UTF8'); function is_https()