.env en moins normalement

This commit is contained in:
Yasder5 2026-03-03 20:41:35 +01:00
parent f1ef53c4ac
commit c8343faec7
4 changed files with 9 additions and 12 deletions

4
.env
View file

@ -1,9 +1,9 @@
# config BDD # config BDD
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOSTNAME=boulayoune.com DB_HOSTNAME=localhost
DB_DATABASE=projet_folliow DB_DATABASE=projet_folliow
DB_USERNAME= DB_USERNAME=root
DB_PASSWORD= DB_PASSWORD=
IMG_PROJECT_PATH = uploads/projects/ IMG_PROJECT_PATH = uploads/projects/

View file

@ -1,14 +1,11 @@
Options -Indexes Options -Indexes
# Rediriger les erreurs serveur vers ton contrôleur
# On force le passage par index.php pour que ton routeur reçoive les paramètres
ErrorDocument 404 /index.php?ctrl=error&action=error_404
ErrorDocument 403 /index.php?ctrl=error&action=error_403
# --- Sécurité --- # --- Sécurité ---
<FilesMatch ".env"> <FilesMatch ".env">
Require all denied Require all denied
</FilesMatch> </FilesMatch>
<FilesMatch "(composer\.json|composer\.lock|package\.json|package-lock\.json|\.git)"> <FilesMatch "(composer\.json|composer\.lock|package\.json|package-lock\.json|\.git|\.env|\.gitignore|env)">
Require all denied Require all denied
</FilesMatch> </FilesMatch>

View file

@ -26,6 +26,6 @@
} }
if ($boolError) { if ($boolError) {
header("Location: index.php?ctrl=error&action=error_404"); $error = new \Controllers\ErrorCtrl();
exit; return $error->error_404();
} }

View file

@ -10,9 +10,9 @@
public function __construct(){ public function __construct(){
try{ try{
$this->_db = new PDO( $this->_db = new PDO(
"mysql:host=localhost;dbname=projet_folliow", "mysql:host=".$_ENV['DB_HOSTNAME'].";dbname=".$_ENV['DB_DATABASE'],
"projet_user", $_ENV['DB_USERNAME'],
"F0lliowRules!", $_ENV['DB_PASSWORD'],
array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC) array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC)
); );
$this->_db->exec("SET CHARACTER SET utf8"); $this->_db->exec("SET CHARACTER SET utf8");