Skip to content
Snippets Groups Projects

Use ENV variables for passwords

Files
59
@@ -69,8 +69,8 @@ class DBConnectionBase {
@@ -69,8 +69,8 @@ class DBConnectionBase {
public function __construct() {
public function __construct() {
// Apply settings that applies to all db classes
// Apply settings that applies to all db classes
$this->setMysqlUrl("mariadb");
$this->setMysqlUrl("mariadb");
$this->setMysqlUser("admin");
$this->setMysqlUser(getenv('MYSQL_USER'));
$this->setMysqlPassword("my-secret-pw");
$this->setMysqlPassword(getenv('MYSQL_PASSWORD'));
$this->setValidPaths("/localsite");
$this->setValidPaths("/localsite");
$this->setValidPaths("/home/data/httpd");
$this->setValidPaths("/home/data/httpd");
}
}
@@ -83,10 +83,10 @@ class DBConnectionBase {
@@ -83,10 +83,10 @@ class DBConnectionBase {
public function connect() {
public function connect() {
$this->validateCaller();
$this->validateCaller();
$dbh = mysql_connect($this->getMysqlUrl(), $this->getMysqlUser(), $this->getMysqlPassword());
$dbh = mysql_connect($this->getMysqlUrl(), $this->getMysqlUser(), $this->getMysqlPassword());
if (!$dbh) {
if (!$dbh) {
echo ("<p>Unable to connect to the database server at this time (" . get_class($this) . ").</p>");
echo ("<p>Unable to connect to the database server at this time (" . get_class($this) . ").</p>");
 
// header('HTTP/1.1 500 Internal Server Error'); We prefer to see the error in dev mode.
die();
die();
}
}
Loading