. */ include_once __DIR__ . '/../config/config.php'; include_once __DIR__ . '/../misc/logging.php'; include_once __DIR__ . '/../misc/utilities.php'; class Database { public $conn; public function getConnection() { $this->conn = null; try { if(!empty(get_config_value("DB_ENABLE_SSL","")) && !empty(get_config_value("ROOT_CA_PATH",""))){ if(!file_exists (ROOT_CA_PATH)){ Logger::getInstance()->error("MySQL connection error: the provided ROOT_CA_PATH does not exists!"); } else{ $this->conn = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD, array ( PDO::MYSQL_ATTR_SSL_CA => ROOT_CA_PATH, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false )); } } else{ $this->conn = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD); } $this->conn->exec("set names utf8"); } catch (PDOException $exception) { Logger::getInstance()->error("Connection error: " . $exception->getMessage()); } return $this->conn; } }