Removed debug databases

This commit is contained in:
keplyx 2019-08-12 16:36:46 +02:00
parent f8c99519d8
commit cc11e1be6a

View file

@ -5,25 +5,11 @@ class Dao
private $conn;
private $debug = false;
private function get_debug_mode () {
$this->debug = file_exists(__DIR__.DIRECTORY_SEPARATOR."../DEBUG");
}
public function __construct()
{
$this->get_debug_mode();
if ($this->debug) {
$username = 'phpmyadmin';
$password = $this->read_password();;
$dsn = 'mysql:dbname=phpmyadmin;host=127.0.0.1';
} else {
$username = 'accueil_insa';
$password = $this->read_password();
$dsn = 'mysql:dbname=accueil_insa;host=127.0.0.1';
}
$username = 'accueil_insa';
$password = $this->read_password();
$dsn = 'mysql:dbname=accueil_insa;host=127.0.0.1';
try {
$this->conn = new PDO($dsn, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
} catch (PDOException $e) {
@ -33,10 +19,7 @@ class Dao
private function read_password()
{
if ($this->debug)
$real_path = __DIR__.DIRECTORY_SEPARATOR.".htpassdb_debug";
else
$real_path = __DIR__.DIRECTORY_SEPARATOR.".htpassdb";
$real_path = __DIR__.DIRECTORY_SEPARATOR.".htpassdb";
$file = fopen($real_path, "r") or die("Unable to open DB password file!");;
$password = fgets($file);
fclose($file);